vendor: 40,706 bytes, lines 1-18
1import{a4 as Jo,a9 as r2,a8 as a2,aa as s2,ac as dl}from"./index-CvCLQTzb.js";import{a as o2}from"./C_xKmLTX-eQRBGHvX.js";var i2=Object.defineProperty,u2=(n,e,t)=>e in n?i2(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,fl=(n,e,t)=>u2(n,typeof e!="symbol"?e+"":e,t);function l2(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in n)){const s=Object.getOwnPropertyDescriptor(r,a);s&&Object.defineProperty(n,a,s.get?s:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var ml={},gl;function c2(){return gl||(gl=1,(function(){var n;function e(g){var v=0;return function(){return v<g.length?{done:!1,value:g[v++]}:{done:!0}}}var t=typeof Object.defineProperties=="function"?Object.defineProperty:function(g,v,k){return g==Array.prototype||g==Object.prototype||(g[v]=k.value),g};function r(g){g=[typeof globalThis=="object"&&globalThis,g,typeof window=="object"&&window,typeof self=="object"&&self,typeof dl=="object"&&dl];for(var v=0;v<g.length;++v){var k=g[v];if(k&&k.Math==Math)return k}throw Error("Cannot find global object")}var a=r(this);function s(g,v){if(v)e:{var k=a;g=g.split(".");for(var O=0;O<g.length-1;O++){var W=g[O];if(!(W in k))break e;k=k[W]}g=g[g.length-1],O=k[g],v=v(O),v!=O&&v!=null&&t(k,g,{configurable:!0,writable:!0,value:v})}}s("Symbol",function(g){function v(K){if(this instanceof v)throw new TypeError("Symbol is not a constructor");return new k(O+(K||"")+"_"+W++,K)}function k(K,G){this.g=K,t(this,"description",{configurable:!0,writable:!0,value:G})}if(g)return g;k.prototype.toString=function(){return this.g};var O="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",W=0;return v}),s("Symbol.iterator",function(g){if(g)return g;g=Symbol("Symbol.iterator");for(var v="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),k=0;k<v.length;k++){var O=a[v[k]];typeof O=="function"&&typeof O.prototype[g]!="function"&&t(O.prototype,g,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return g});function o(g){return g={next:g},g[Symbol.iterator]=function(){return this},g}function i(g){var v=typeof Symbol<"u"&&Symbol.iterator&&g[Symbol.iterator];return v?v.call(g):{next:e(g)}}function u(g){if(!(g instanceof Array)){g=i(g);for(var v,k=[];!(v=g.next()).done;)k.push(v.value);g=k}return g}var l=typeof Object.create=="function"?Object.create:function(g){function v(){}return v.prototype=g,new v},c;if(typeof Object.setPrototypeOf=="function")c=Object.setPrototypeOf;else{var p;e:{var h={a:!0},d={};try{d.__proto__=h,p=d.a;break e}catch{}p=!1}c=p?function(g,v){if(g.__proto__=v,g.__proto__!==v)throw new TypeError(g+" is not extensible");return g}:null}var m=c;function y(g,v){if(g.prototype=l(v.prototype),g.prototype.constructor=g,m)m(g,v);else for(var k in v)if(k!="prototype")if(Object.defineProperties){var O=Object.getOwnPropertyDescriptor(v,k);O&&Object.defineProperty(g,k,O)}else g[k]=v[k];g.ea=v.prototype}function b(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function x(g){if(g.l)throw new TypeError("Generator is already running");g.l=!0}b.prototype.o=function(g){this.h=g};function T(g,v){g.j={U:v,V:!0},g.g=g.m||g.s}b.prototype.return=function(g){this.j={return:g},this.g=this.s};function $(g,v,k){return g.g=k,{value:v}}function F(g){this.g=new b,this.h=g}function M(g,v){x(g.g);var k=g.g.i;return k?U(g,"return"in k?k.return:function(O){return{value:O,done:!0}},v,g.g.return):(g.g.return(v),X(g))}function U(g,v,k,O){try{var W=v.call(g.g.i,k);if(!(W instanceof Object))throw new TypeError("Iterator result "+W+" is not an object");if(!W.done)return g.g.l=!1,W;var K=W.value}catch(G){return g.g.i=null,T(g.g,G),X(g)}return g.g.i=null,O.call(g.g,K),X(g)}function X(g){for(;g.g.g;)try{var v=g.h(g.g);if(v)return g.g.l=!1,{value:v.value,done:!1}}catch(k){g.g.h=void 0,T(g.g,k)}if(g.g.l=!1,g.g.j){if(v=g.g.j,g.g.j=null,v.V)throw v.U;return{value:v.return,done:!0}}return{value:void 0,done:!0}}function z(g){this.next=function(v){return x(g.g),g.g.i?v=U(g,g.g.i.next,v,g.g.o):(g.g.o(v),v=X(g)),v},this.throw=function(v){return x(g.g),g.g.i?v=U(g,g.g.i.throw,v,g.g.o):(T(g.g,v),v=X(g)),v},this.return=function(v){return M(g,v)},this[Symbol.iterator]=function(){return this}}function L(g,v){return v=new z(new F(v)),m&&g.prototype&&m(v,g.prototype),v}function C(g,v){g instanceof String&&(g+="");var k=0,O=!1,W={next:function(){if(!O&&k<g.length){var K=k++;return{value:v(K,g[K]),done:!1}}return O=!0,{done:!0,value:void 0}}};return W[Symbol.iterator]=function(){return W},W}var q=typeof Object.assign=="function"?Object.assign:function(g,v){for(var k=1;k<arguments.length;k++){var O=arguments[k];if(O)for(var W in O)Object.prototype.hasOwnProperty.call(O,W)&&(g[W]=O[W])}return g};s("Object.assign",function(g){return g||q}),s("Promise",function(g){function v(G){this.h=0,this.i=void 0,this.g=[],this.o=!1;var J=this.j();try{G(J.resolve,J.reject)}catch(ne){J.reject(ne)}}function k(){this.g=null}function O(G){return G instanceof v?G:new v(function(J){J(G)})}if(g)return g;k.prototype.h=function(G){if(this.g==null){this.g=[];var J=this;this.i(function(){J.l()})}this.g.push(G)};var W=a.setTimeout;k.prototype.i=function(G){W(G,0)},k.prototype.l=function(){for(;this.g&&this.g.length;){var G=this.g;this.g=[];for(var J=0;J<G.length;++J){var ne=G[J];G[J]=null;try{ne()}catch(ue){this.j(ue)}}}this.g=null},k.prototype.j=function(G){this.i(function(){throw G})},v.prototype.j=function(){function G(ue){return function(ye){ne||(ne=!0,ue.call(J,ye))}}var J=this,ne=!1;return{resolve:G(this.C),reject:G(this.l)}},v.prototype.C=function(G){if(G===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(G instanceof v)this.F(G);else{e:switch(typeof G){case"object":var J=G!=null;break e;case"function":J=!0;break e;default:J=!1}J?this.u(G):this.m(G)}},v.prototype.u=function(G){var J=void 0;try{J=G.then}catch(ne){this.l(ne);return}typeof J=="function"?this.G(J,G):this.m(G)},v.prototype.l=function(G){this.s(2,G)},v.prototype.m=function(G){this.s(1,G)},v.prototype.s=function(G,J){if(this.h!=0)throw Error("Cannot settle("+G+", "+J+"): Promise already settled in state"+this.h);this.h=G,this.i=J,this.h===2&&this.D(),this.A()},v.prototype.D=function(){var G=this;W(function(){if(G.B()){var J=a.console;typeof J<"u"&&J.error(G.i)}},1)},v.prototype.B=function(){if(this.o)return!1;var G=a.CustomEvent,J=a.Event,ne=a.dispatchEvent;return typeof ne>"u"?!0:(typeof G=="function"?G=new G("unhandledrejection",{cancelable:!0}):typeof J=="function"?G=new J("unhandledrejection",{cancelable:!0}):(G=a.document.createEvent("CustomEvent"),G.initCustomEvent("unhandledrejection",!1,!0,G)),G.promise=this,G.reason=this.i,ne(G))},v.prototype.A=function(){if(this.g!=null){for(var G=0;G<this.g.length;++G)K.h(this.g[G]);this.g=null}};var K=new k;return v.prototype.F=function(G){var J=this.j();G.J(J.resolve,J.reject)},v.prototype.G=function(G,J){var ne=this.j();try{G.call(J,ne.resolve,ne.reject)}catch(ue){ne.reject(ue)}},v.prototype.then=function(G,J){function ne(Se,be){return typeof Se=="function"?function(pe){try{ue(Se(pe))}catch(f){ye(f)}}:be}var ue,ye,Ee=new v(function(Se,be){ue=Se,ye=be});return this.J(ne(G,ue),ne(J,ye)),Ee},v.prototype.catch=function(G){return this.then(void 0,G)},v.prototype.J=function(G,J){function ne(){switch(ue.h){case 1:G(ue.i);break;case 2:J(ue.i);break;default:throw Error("Unexpected state: "+ue.h)}}var ue=this;this.g==null?K.h(ne):this.g.push(ne),this.o=!0},v.resolve=O,v.reject=function(G){return new v(function(J,ne){ne(G)})},v.race=function(G){return new v(function(J,ne){for(var ue=i(G),ye=ue.next();!ye.done;ye=ue.next())O(ye.value).J(J,ne)})},v.all=function(G){var J=i(G),ne=J.next();return ne.done?O([]):new v(function(ue,ye){function Ee(pe){return function(f){Se[pe]=f,be--,be==0&&ue(Se)}}var Se=[],be=0;do Se.push(void 0),be++,O(ne.value).J(Ee(Se.length-1),ye),ne=J.next();while(!ne.done)})},v}),s("Object.is",function(g){return g||function(v,k){return v===k?v!==0||1/v===1/k:v!==v&&k!==k}}),s("Array.prototype.includes",function(g){return g||function(v,k){var O=this;O instanceof String&&(O=String(O));var W=O.length;for(k=k||0,0>k&&(k=Math.max(k+W,0));k<W;k++){var K=O[k];if(K===v||Object.is(K,v))return!0}return!1}}),s("String.prototype.includes",function(g){return g||function(v,k){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(v instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(v,k||0)!==-1}}),s("Array.prototype.keys",function(g){return g||function(){return C(this,function(v){return v})}});var ee=this||self;function te(g,v){g=g.split(".");var k=ee;g[0]in k||typeof k.execScript>"u"||k.execScript("var "+g[0]);for(var O;g.length&&(O=g.shift());)g.length||v===void 0?k[O]&&k[O]!==Object.prototype[O]?k=k[O]:k=k[O]={}:k[O]=v}function le(g,v){return v=String.fromCharCode.apply(null,v),g==null?v:g+v}var de,fe=typeof TextDecoder<"u",Re,ge=typeof TextEncoder<"u";function Te(g){if(ge)g=(Re||(Re=new TextEncoder)).encode(g);else{var v=void 0;v=v===void 0?!1:v;for(var k=0,O=new Uint8Array(3*g.length),W=0;W<g.length;W++){var K=g.charCodeAt(W);if(128>K)O[k++]=K;else{if(2048>K)O[k++]=K>>6|192;else{if(55296<=K&&57343>=K){if(56319>=K&&W<g.length){var G=g.charCodeAt(++W);if(56320<=G&&57343>=G){K=1024*(K-55296)+G-56320+65536,O[k++]=K>>18|240,O[k++]=K>>12&63|128,O[k++]=K>>6&63|128,O[k++]=K&63|128;continue}else W--}if(v)throw Error("Found an unpaired surrogate");K=65533}O[k++]=K>>12|224,O[k++]=K>>6&63|128}O[k++]=K&63|128}}g=O.subarray(0,k)}return g}var We={},Ne=null;function Ye(g,v){v===void 0&&(v=0),ur(),v=We[v];for(var k=Array(Math.floor(g.length/3)),O=v[64]||"",W=0,K=0;W<g.length-2;W+=3){var G=g[W],J=g[W+1],ne=g[W+2],ue=v[G>>2];G=v[(G&3)<<4|J>>4],J=v[(J&15)<<2|ne>>6],ne=v[ne&63],k[K++]=ue+G+J+ne}switch(ue=0,ne=O,g.length-W){case 2:ue=g[W+1],ne=v[(ue&15)<<2]||O;case 1:g=g[W],k[K]=v[g>>2]+v[(g&3)<<4|ue>>4]+ne+O}return k.join("")}function Vt(g){var v=g.length,k=3*v/4;k%3?k=Math.floor(k):"=.".indexOf(g[v-1])!=-1&&(k="=.".indexOf(g[v-2])!=-1?k-2:k-1);var O=new Uint8Array(k),W=0;return Vn(g,function(K){O[W++]=K}),O.subarray(0,W)}function Vn(g,v){function k(ne){for(;O<g.length;){var ue=g.charAt(O++),ye=Ne[ue];if(ye!=null)return ye;if(!/^[\s\xa0]*$/.test(ue))throw Error("Unknown base64 encoding at char: "+ue)}return ne}ur();for(var O=0;;){var W=k(-1),K=k(0),G=k(64),J=k(64);if(J===64&&W===-1)break;v(W<<2|K>>4),G!=64&&(v(K<<4&240|G>>2),J!=64&&v(G<<6&192|J))}}function ur(){if(!Ne){Ne={};for(var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),v=["+/=","+/","-_=","-_.","-_"],k=0;5>k;k++){var O=g.concat(v[k].split(""));We[k]=O;for(var W=0;W<O.length;W++){var K=O[W];Ne[K]===void 0&&(Ne[K]=W)}}}}var dn=typeof Uint8Array.prototype.slice=="function",Na;function zr(g,v,k){return v===k?Na||(Na=new Uint8Array(0)):dn?g.slice(v,k):new Uint8Array(g.subarray(v,k))}var Wt=0,zt=0;function Ze(g,v){v=v===void 0?{}:v,v=v.v===void 0?!1:v.v,this.h=null,this.g=this.j=this.l=0,this.m=!1,this.v=v,g&&Wn(this,g)}function Wn(g,v){v=v.constructor===Uint8Array?v:v.constructor===ArrayBuffer?new Uint8Array(v):v.constructor===Array?new Uint8Array(v):v.constructor===String?Vt(v):v instanceof Uint8Array?new Uint8Array(v.buffer,v.byteOffset,v.byteLength):new Uint8Array(0),g.h=v,g.l=0,g.j=g.h.length,g.g=g.l}Ze.prototype.reset=function(){this.g=this.l};function lr(g){for(var v=128,k=0,O=0,W=0;4>W&&128<=v;W++)v=g.h[g.g++],k|=(v&127)<<7*W;if(128<=v&&(v=g.h[g.g++],k|=(v&127)<<28,O|=(v&127)>>4),128<=v)for(W=0;5>W&&128<=v;W++)v=g.h[g.g++],O|=(v&127)<<7*W+3;if(128>v)return g=k>>>0,v=O>>>0,(O=v&2147483648)&&(g=~g+1>>>0,v=~v>>>0,g==0&&(v=v+1>>>0)),g=4294967296*v+(g>>>0),O?-g:g;g.m=!0}Ze.prototype.i=function(){var g=this.h,v=g[this.g],k=v&127;return 128>v?(this.g+=1,k):(v=g[this.g+1],k|=(v&127)<<7,128>v?(this.g+=2,k):(v=g[this.g+2],k|=(v&127)<<14,128>v?(this.g+=3,k):(v=g[this.g+3],k|=(v&127)<<21,128>v?(this.g+=4,k):(v=g[this.g+4],k|=(v&15)<<28,128>v?(this.g+=5,k>>>0):(this.g+=5,128<=g[this.g++]&&128<=g[this.g++]&&128<=g[this.g++]&&128<=g[this.g++]&&this.g++,k)))))},Ze.prototype.o=function(){var g=this.h[this.g],v=this.h[this.g+1],k=this.h[this.g+2],O=this.h[this.g+3];return this.g+=4,k=(g<<0|v<<8|k<<16|O<<24)>>>0,g=2*(k>>31)+1,v=k>>>23&255,k&=8388607,v==255?k?NaN:1/0*g:v==0?g*Math.pow(2,-149)*k:g*Math.pow(2,v-150)*(k+Math.pow(2,23))};var Gr=[];function Gt(){this.g=new Uint8Array(64),this.h=0}Gt.prototype.push=function(g){if(!(this.h+1<this.g.length)){var v=this.g;this.g=new Uint8Array(Math.ceil(1+2*this.g.length)),this.g.set(v)}this.g[this.h++]=g},Gt.prototype.length=function(){return this.h},Gt.prototype.end=function(){var g=this.g,v=this.h;return this.h=0,zr(g,0,v)};function nn(g,v){for(;127<v;)g.push(v&127|128),v>>>=7;g.push(v)}function zn(g){var v={},k=v.N===void 0?!1:v.N;this.o={v:v.v===void 0?!1:v.v},this.N=k,v=this.o,Gr.length?(k=Gr.pop(),v&&(k.v=v.v),g&&Wn(k,g),g=k):g=new Ze(g,v),this.g=g,this.m=this.g.g,this.h=this.i=this.l=-1,this.j=!1}zn.prototype.reset=function(){this.g.reset(),this.h=this.l=-1};function Tt(g){var v=g.g;if((v=v.g==v.j)||(v=g.j)||(v=g.g,v=v.m||0>v.g||v.g>v.j),v)return!1;g.m=g.g.g,v=g.g.i();var k=v&7;return k!=0&&k!=5&&k!=1&&k!=2&&k!=3&&k!=4?(g.j=!0,!1):(g.i=v,g.l=v>>>3,g.h=k,!0)}function rn(g){switch(g.h){case 0:if(g.h!=0)rn(g);else{for(g=g.g;g.h[g.g]&128;)g.g++;g.g++}break;case 1:g.h!=1?rn(g):(g=g.g,g.g+=8);break;case 2:if(g.h!=2)rn(g);else{var v=g.g.i();g=g.g,g.g+=v}break;case 5:g.h!=5?rn(g):(g=g.g,g.g+=4);break;case 3:v=g.l;do{if(!Tt(g)){g.j=!0;break}if(g.h==4){g.l!=v&&(g.j=!0);break}rn(g)}while(!0);break;default:g.j=!0}}function jr(g,v,k){var O=g.g.j,W=g.g.i(),K=g.g.g+W;if(g.g.j=K,k(v,g),k=K-g.g.g,k!==0)throw Error("Message parsing ended unexpectedly. Expected to read "+W+" bytes, instead read "+(W-k)+" bytes, either the data ended unexpectedly or the message misreported its own length");return g.g.g=K,g.g.j=O,v}function et(g){return g.g.o()}function cr(g){var v=g.g.i();g=g.g;var k=g.g;g.g+=v,g=g.h;var O;if(fe)(O=de)||(O=de=new TextDecoder("utf-8",{fatal:!1})),O=O.decode(g.subarray(k,k+v));else{v=k+v;for(var W=[],K=null,G,J,ne;k<v;)G=g[k++],128>G?W.push(G):224>G?k>=v?W.push(65533):(J=g[k++],194>G||(J&192)!==128?(k--,W.push(65533)):W.push((G&31)<<6|J&63)):240>G?k>=v-1?W.push(65533):(J=g[k++],(J&192)!==128||G===224&&160>J||G===237&&160<=J||((O=g[k++])&192)!==128?(k--,W.push(65533)):W.push((G&15)<<12|(J&63)<<6|O&63)):244>=G?k>=v-2?W.push(65533):(J=g[k++],(J&192)!==128||(G<<28)+(J-144)>>30!==0||((O=g[k++])&192)!==128||((ne=g[k++])&192)!==128?(k--,W.push(65533)):(G=(G&7)<<18|(J&63)<<12|(O&63)<<6|ne&63,G-=65536,W.push((G>>10&1023)+55296,(G&1023)+56320))):W.push(65533),8192<=W.length&&(K=le(K,W),W.length=0);O=le(K,W)}return O}function $a(g,v,k){var O=g.g.i();for(O=g.g.g+O;g.g.g<O;)k.push(v.call(g.g))}function Ra(g,v){g.h==2?$a(g,Ze.prototype.o,v):v.push(et(g))}function Tn(){this.h=[],this.i=0,this.g=new Gt}function jt(g,v){v.length!==0&&(g.h.push(v),g.i+=v.length)}function pr(g){var v=g.i+g.g.length();if(v===0)return new Uint8Array(0);v=new Uint8Array(v);for(var k=g.h,O=k.length,W=0,K=0;K<O;K++){var G=k[K];G.length!==0&&(v.set(G,W),W+=G.length)}return k=g.g,O=k.h,O!==0&&(v.set(k.g.subarray(0,O),W),k.h=0),g.h=[v],v}function Et(g,v,k){if(k!=null){nn(g.g,8*v+5),g=g.g;var O=k;O=(k=0>O?1:0)?-O:O,O===0?0<1/O?Wt=zt=0:(zt=0,Wt=2147483648):isNaN(O)?(zt=0,Wt=2147483647):34028234663852886e22<O?(zt=0,Wt=(k<<31|2139095040)>>>0):11754943508222875e-54>O?(O=Math.round(O/Math.pow(2,-149)),zt=0,Wt=(k<<31|O)>>>0):(v=Math.floor(Math.log(O)/Math.LN2),O*=Math.pow(2,-v),O=Math.round(8388608*O),16777216<=O&&++v,zt=0,Wt=(k<<31|v+127<<23|O&8388607)>>>0),k=Wt,g.push(k>>>0&255),g.push(k>>>8&255),g.push(k>>>16&255),g.push(k>>>24&255)}}var hr=typeof Uint8Array=="function";function _a(g,v,k){if(g!=null)return typeof g=="object"?hr&&g instanceof Uint8Array?k(g):Aa(g,v,k):v(g)}function Aa(g,v,k){if(Array.isArray(g)){for(var O=Array(g.length),W=0;W<g.length;W++)O[W]=_a(g[W],v,k);return Array.isArray(g)&&g.W&<(O),O}O={};for(W in g)O[W]=_a(g[W],v,k);return O}function ks(g){return typeof g=="number"?isFinite(g)?g:String(g):g}var Ts={W:{value:!0,configurable:!0}};function lt(g){return Array.isArray(g)&&!Object.isFrozen(g)&&Object.defineProperties(g,Ts),g}var Je;function Qe(g,v,k){var O=Je;Je=null,g||(g=O),O=this.constructor.ca,g||(g=O?[O]:[]),this.j=O?0:-1,this.m=this.g=null,this.h=g;e:{if(O=this.h.length,g=O-1,O&&(O=this.h[g],!(O===null||typeof O!="object"||Array.isArray(O)||hr&&O instanceof Uint8Array))){this.l=g-this.j,this.i=O;break e}v!==void 0&&-1<v?(this.l=Math.max(v,g+1-this.j),this.i=null):this.l=Number.MAX_VALUE}if(k)for(v=0;v<k.length;v++)g=k[v],g<this.l?(g+=this.j,(O=this.h[g])?lt(O):this.h[g]=vt):(dr(this),(O=this.i[g])?lt(O):this.i[g]=vt)}var vt=Object.freeze(lt([]));function dr(g){var v=g.l+g.j;g.h[v]||(g.i=g.h[v]={})}function Me(g,v,k){return v===-1?null:k!==void 0&&k||v>=g.l?g.i?g.i[v]:void 0:g.h[v+g.j]}function fr(g,v){var k=k===void 0?!1:k,O=Me(g,v,k);return O==null&&(O=vt),O===vt&&(O=lt([]),ke(g,v,O,k)),O}function Oa(g){var v=fr(g,3);if(g.m||(g.m={}),!g.m[3]){for(var k=0;k<v.length;k++)v[k]=+v[k];g.m[3]=!0}return v}function fn(g,v,k){return g=Me(g,v),g??k}function At(g,v,k){return g=Me(g,v),g=g==null?g:+g,g??(k===void 0?0:k)}function ke(g,v,k,O){O!==void 0&&O||v>=g.l?(dr(g),g.i[v]=k):g.h[v+g.j]=k}function Es(g,v,k){if(k===-1)return null;if(g.g||(g.g={}),!g.g[k]){var O=Me(g,k,!1);O&&(g.g[k]=new v(O))}return g.g[k]}function Hr(g,v){g.g||(g.g={});var k=g.g[1];if(!k){var O=fr(g,1);k=[];for(var W=0;W<O.length;W++)k[W]=new v(O[W]);g.g[1]=k}return k}function mr(g,v,k){var O=O===void 0?!1:O;g.g||(g.g={});var W=k&&mn(k);g.g[v]=k,ke(g,v,W,O)}function gr(g,v,k,O){var W=Hr(g,k);v=v||new k,g=fr(g,1),O!=null?(W.splice(O,0,v),g.splice(O,0,mn(v))):(W.push(v),g.push(mn(v)))}Qe.prototype.toJSON=function(){var g=mn(this);return Aa(g,ks,Ye)};function mn(g,v){if(g.g)for(var k in g.g){var O=g.g[k];if(Array.isArray(O))for(var W=0;W<O.length;W++)O[W]&&mn(O[W]);else O&&mn(O)}return g.h}Qe.prototype.toString=function(){return mn(this).toString()};function Xr(g,v){if(g=g.o){jt(v,v.g.end());for(var k=0;k<g.length;k++)jt(v,g[k])}}function Ot(g,v){if(v.h==4)return!1;var k=v.m;return rn(v),v.N||(v=zr(v.g.h,k,v.g.g),(k=g.o)?k.push(v):g.o=[v]),!0}function gn(g){Qe.call(this,g,-1,Vo)}y(gn,Qe),gn.prototype.getRows=function(){return Me(this,1)},gn.prototype.getCols=function(){return Me(this,2)},gn.prototype.getPackedDataList=function(){return Oa(this)},gn.prototype.getLayout=function(){return fn(this,4,0)};function Cs(g,v){for(;Tt(v);)switch(v.i){case 8:var k=v.g.i();ke(g,1,k);break;case 16:k=v.g.i(),ke(g,2,k);break;case 29:case 26:Ra(v,g.getPackedDataList());break;case 32:k=lr(v.g),ke(g,4,k);break;default:if(!Ot(g,v))return g}return g}var Vo=[3];function at(g,v){var k=void 0;return new(k||(k=Promise))(function(O,W){function K(ne){try{J(v.next(ne))}catch(ue){W(ue)}}function G(ne){try{J(v.throw(ne))}catch(ue){W(ue)}}function J(ne){ne.done?O(ne.value):new k(function(ue){ue(ne.value)}).then(K,G)}J((v=v.apply(g,void 0)).next())})}function yn(g){Qe.call(this,g)}y(yn,Qe);function Is(g,v){for(;Tt(v);)switch(v.i){case 8:var k=v.g.i();ke(g,1,k);break;case 21:k=et(v),ke(g,2,k);break;case 26:k=cr(v),ke(g,3,k);break;case 34:k=cr(v),ke(g,4,k);break;default:if(!Ot(g,v))return g}return g}function qr(g){Qe.call(this,g,-1,Ns)}y(qr,Qe),qr.prototype.addClassification=function(g,v){return gr(this,g,yn,v),this};var Ns=[1];function Gn(g){Qe.call(this,g)}y(Gn,Qe);function Wo(g,v){for(;Tt(v);)switch(v.i){case 13:var k=et(v);ke(g,1,k);break;case 21:k=et(v),ke(g,2,k);break;case 29:k=et(v),ke(g,3,k);break;case 37:k=et(v),ke(g,4,k);break;case 45:k=et(v),ke(g,5,k);break;default:if(!Ot(g,v))return g}return g}function $s(g){Qe.call(this,g,-1,_s)}y($s,Qe);function Rs(g){e:{var v=new $s;for(g=new zn(g);Tt(g);)switch(g.i){case 10:var k=jr(g,new Gn,Wo);gr(v,k,Gn,void 0);break;default:if(!Ot(v,g))break e}}return v}var _s=[1];function Kr(g){Qe.call(this,g)}y(Kr,Qe);function En(g){Qe.call(this,g,-1,Go)}y(En,Qe),En.prototype.getVertexType=function(){return fn(this,1,0)},En.prototype.getPrimitiveType=function(){return fn(this,2,0)},En.prototype.getVertexBufferList=function(){return Oa(this)},En.prototype.getIndexBufferList=function(){return fr(this,4)};function zo(g,v){for(;Tt(v);)switch(v.i){case 8:var k=lr(v.g);ke(g,1,k);break;case 16:k=lr(v.g),ke(g,2,k);break;case 29:case 26:Ra(v,g.getVertexBufferList());break;case 32:case 34:k=v;var O=g.getIndexBufferList();k.h==2?$a(k,Ze.prototype.i,O):O.push(k.g.i());break;default:if(!Ot(g,v))return g}return g}var Go=[3,4];function Yr(g){Qe.call(this,g)}y(Yr,Qe),Yr.prototype.getMesh=function(){return Es(this,En,1)},Yr.prototype.getPoseTransformMatrix=function(){return Es(this,gn,2)};function As(g){e:{var v=new Yr;for(g=new zn(g);Tt(g);)switch(g.i){case 10:var k=jr(g,new En,zo);mr(v,1,k);break;case 18:k=jr(g,new gn,Cs),mr(v,2,k);break;default:if(!Ot(v,g))break e}}return v}function Fa(g,v,k){if(k=g.createShader(k===0?g.VERTEX_SHADER:g.FRAGMENT_SHADER),g.shaderSource(k,v),g.compileShader(k),!g.getShaderParameter(k,g.COMPILE_STATUS))throw Error(`Could not compile WebGL shader. 2 3`+g.getShaderInfoLog(k));return k}function Da(g){return Hr(g,yn).map(function(v){return{index:fn(v,1,0),Y:At(v,2),label:Me(v,3)!=null?fn(v,3,""):void 0,displayName:Me(v,4)!=null?fn(v,4,""):void 0}})}function Ma(g){return{x:At(g,1),y:At(g,2),z:At(g,3),visibility:Me(g,4)!=null?At(g,4):void 0}}function yr(g,v){this.h=g,this.g=v,this.l=0}function jn(g,v,k){return Ft(g,v),typeof g.g.canvas.transferToImageBitmap=="function"?Promise.resolve(g.g.canvas.transferToImageBitmap()):k?Promise.resolve(g.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(g.g.canvas):(g.i===void 0&&(g.i=document.createElement("canvas")),new Promise(function(O){g.i.height=g.g.canvas.height,g.i.width=g.g.canvas.width,g.i.getContext("2d",{}).drawImage(g.g.canvas,0,0,g.g.canvas.width,g.g.canvas.height),O(g.i)}))}function Ft(g,v){var k=g.g;if(g.m===void 0){var O=Fa(k,` 4 attribute vec2 aVertex; 5 attribute vec2 aTex; 6 varying vec2 vTex; 7 void main(void) { 8 gl_Position = vec4(aVertex, 0.0, 1.0); 9 vTex = aTex; 10 }`,0),W=Fa(k,` 11 precision mediump float; 12 varying vec2 vTex; 13 uniform sampler2D sampler0; 14 void main(){ 15 gl_FragColor = texture2D(sampler0, vTex); 16 }`,1),K=k.createProgram();if(k.attachShader(K,O),k.attachShader(K,W),k.linkProgram(K),!k.getProgramParameter(K,k.LINK_STATUS))throw Error(`Could not compile WebGL program. 17 18`+k.getProgramInfoLog(K));O=g.m=K,k.useProgram(O),W=k.getUniformLocation(O,"sampler0"),g.j={I:k.getAttribLocation(O,"aVertex"),H:k.getAttribLocation(O,"aTex"),da:W},g.s=k.createBuffer(),k.bindBuffer(k.ARRAY_BUFFER,g.s),k.enableVertexAttribArray(g.j.I),k.vertexAttribPointer(g.j.I,2,k.FLOAT,!1,0,0),k.bufferData(k.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),k.STATIC_DRAW),k.bindBuffer(k.ARRAY_BUFFER,null),g.o=k.createBuffer(),k.bindBuffer(k.ARRAY_BUFFER,g.o),k.enableVertexAttribArray(g.j.H),k.vertexAttribPointer(g.j.H,2,k.FLOAT,!1,0,0),k.bufferData(k.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),k.STATIC_DRAW),k.bindBuffer(k.ARRAY_BUFFER,null),k.uniform1i(W,0)}O=g.j,k.useProgram(g.m),k.canvas.width=v.width,k.canvas.height=v.height,k.viewport(0,0,v.width,v.height),k.activeTexture(k.TEXTURE0),g.h.bindTexture2d(v.glName),k.enableVertexAttribArray(O.I),k.bindBuffer(k.ARRAY_BUFFER,g.s),k.vertexAttribPointer(O.I,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(O.H),k.bindBuffer(k.ARRAY_BUFFER,g.o),k.vertexAttribPointer(O.H,2,k.FLOAT,!1,0,0),k.bindFramebuffer(k.DRAW_FRAMEBUFFER?k.DRAW_FRAMEBUFFER:k.FRAMEBUFFER,null),k.clearColor(0,0,0,0),k.clear(k.COLOR_BUFFER_BIT),k.colorMask(!0,!0,!0,!0),k.drawArrays(k.TRIANGLE_FAN,0,4),k.disableVertexAttribArray(O.I),k.disableVertexAttribArray(O.H),k.bindBuffer(k.ARRAY_BUFFER,null),g.h.bindTexture2d(0)}function jo(g){this.g=g}var Ho=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Os(g,v){return v+g}function La(g,v){window[g]=v}function Ct(g){var v=document.createElement("script");return v.setAttribute("src",g),v.setAttribute("crossorigin","anonymous"),new Promise(function(k){v.addEventListener("load",function(){k()},!1),v.addEventListener("error",function(){k()},!1),document.body.appendChild(v)})}function Fs(){return at(this,function g(){return L(g,function(v){switch(v.g){case 1:return v.m=2,$(v,WebAssembly.instantiate(Ho),4);case 4:v.g=3,v.m=0;break;case 2:return v.m=0,v.j=null,v.return(!1);case 3:return v.return(!0)}})})}function Cn(g){if(this.g=g,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=g&&g.locateFile||Os,typeof window=="object")var v=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")v=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.S=v,g.options){v=i(Object.keys(g.options));for(var k=v.next();!k.done;k=v.next()){k=k.value;var O=g.options[k].default;O!==void 0&&(this.j[k]=typeof O=="function"?O():O)}}}n=Cn.prototype,n.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function Ds(g,v){return g.g.files===void 0?[]:typeof g.g.files=="function"?g.g.files(v):g.g.files}function Pa(g){return at(g,function v(){var k=this,O,W,K,G,J,ne,ue,ye,Ee,Se,be;return L(v,function(pe){switch(pe.g){case 1:return O=k,k.R?(W=Ds(k,k.j),$(pe,Fs(),2)):pe.return();case 2:if(K=pe.h,typeof window=="object")return La("createMediapipeSolutionsWasm",{locateFile:k.locateFile}),La("createMediapipeSolutionsPackedAssets",{locateFile:k.locateFile}),ne=W.filter(function(f){return f.data!==void 0}),ue=W.filter(function(f){return f.data===void 0}),ye=Promise.all(ne.map(function(f){var S=Hn(O,f.url);if(f.path!==void 0){var E=f.path;S=S.then(function(I){return O.overrideFile(E,I),Promise.resolve(I)})}return S})),Ee=Promise.all(ue.map(function(f){return f.simd===void 0||f.simd&&K||!f.simd&&!K?Ct(O.locateFile(f.url,O.S)):Promise.resolve()})).then(function(){return at(O,function f(){var S,E,I=this;return L(f,function(A){if(A.g==1)return S=window.createMediapipeSolutionsWasm,E=window.createMediapipeSolutionsPackedAssets,$(A,S(E),2);I.h=A.h,A.g=0})})}),Se=(function(){return at(O,function f(){var S=this;return L(f,function(E){return S.g.graph&&S.g.graph.url?E=$(E,Hn(S,S.g.graph.url),0):(E.g=0,E=void 0),E})})})(),$(pe,Promise.all([Ee,ye,Se]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return G=W.filter(function(f){return f.simd===void 0||f.simd&&K||!f.simd&&!K}).map(function(f){return O.locateFile(f.url,O.S)}),importScripts.apply(null,u(G)),$(pe,createMediapipeSolutionsWasm(Module),6);case 6:k.h=pe.h,k.l=new OffscreenCanvas(1,1),k.h.canvas=k.l,J=k.h.GL.createContext(k.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),k.h.GL.makeContextCurrent(J),pe.g=4;break;case 7:if(k.l=document.createElement("canvas"),be=k.l.getContext("webgl2",{}),!be&&(be=k.l.getContext("webgl",{}),!be))return alert("Failed to create WebGL canvas context when passing video frame."),pe.return();k.D=be,k.h.canvas=k.l,k.h.createContext(k.l,!0,!0,{});case 4:k.i=new k.h.SolutionWasm,k.R=!1,pe.g=0}})})}function Xo(g){return at(g,function v(){var k=this,O,W,K,G,J,ne,ue,ye;return L(v,function(Ee){if(Ee.g==1){if(k.g.graph&&k.g.graph.url&&k.P===k.g.graph.url)return Ee.return();if(k.o=!0,!k.g.graph||!k.g.graph.url){Ee.g=2;return}return k.P=k.g.graph.url,$(Ee,Hn(k,k.g.graph.url),3)}for(Ee.g!=2&&(O=Ee.h,k.i.loadGraph(O)),W=i(Object.keys(k.B)),K=W.next();!K.done;K=W.next())G=K.value,k.i.overrideFile(G,k.B[G]);if(k.B={},k.g.listeners)for(J=i(k.g.listeners),ne=J.next();!ne.done;ne=J.next())ue=ne.value,Ko(k,ue);ye=k.j,k.j={},k.setOptions(ye),Ee.g=0})})}n.reset=function(){return at(this,function g(){var v=this;return L(g,function(k){v.i&&(v.i.reset(),v.m={},v.s={}),k.g=0})})},n.setOptions=function(g,v){var k=this;if(v=v||this.g.options){for(var O=[],W=[],K={},G=i(Object.keys(g)),J=G.next();!J.done;K={K:K.K,L:K.L},J=G.next()){var ne=J.value;ne in this.j&&this.j[ne]===g[ne]||(this.j[ne]=g[ne],J=v[ne],J!==void 0&&(J.onChange&&(K.K=J.onChange,K.L=g[ne],O.push((function(ue){return function(){return at(k,function ye(){var Ee,Se=this;return L(ye,function(be){if(be.g==1)return $(be,ue.K(ue.L),2);Ee=be.h,Ee===!0&&(Se.o=!0),be.g=0})})}})(K))),J.graphOptionXref&&(ne={valueNumber:J.type===1?g[ne]:0,valueBoolean:J.type===0?g[ne]:!1,valueString:J.type===2?g[ne]:""},J=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),J.graphOptionXref),ne),W.push(J))))}(O.length!==0||W.length!==0)&&(this.o=!0,this.A=(this.A===void 0?[]:this.A).concat(W),this.u=(this.u===void 0?[]:this.u).concat(O))}};function qo(g){return at(g,function v(){var k=this,O,W,K,G,J,ne,ue;return L(v,function(ye){switch(ye.g){case 1:if(!k.o)return ye.return();if(!k.u){ye.g=2;break}O=i(k.u),W=O.next();case 3:if(W.done){ye.g=5;break}return K=W.value,$(ye,K(),4);case 4:W=O.next(),ye.g=3;break;case 5:k.u=void 0;case 2:if(k.A){for(G=new k.h.GraphOptionChangeRequestList,J=i(k.A),ne=J.next();!ne.done;ne=J.next())ue=ne.value,G.push_back(ue);k.i.changeOptions(G),G.delete(),k.A=void 0}k.o=!1,ye.g=0}})})}n.initialize=function(){return at(this,function g(){var v=this;return L(g,function(k){return k.g==1?$(k,Pa(v),2):k.g!=3?$(k,Xo(v),3):$(k,qo(v),0)})})};function Hn(g,v){return at(g,function k(){var O=this,W,K;return L(k,function(G){return v in O.F?G.return(O.F[v]):(W=O.locateFile(v,""),K=fetch(W).then(function(J){return J.arrayBuffer()}),O.F[v]=K,G.return(K))})})}n.overrideFile=function(g,v){this.i?this.i.overrideFile(g,v):this.B[g]=v},n.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},n.send=function(g,v){return at(this,function k(){var O=this,W,K,G,J,ne,ue,ye,Ee,Se;return L(k,function(be){switch(be.g){case 1:return O.g.inputs?(W=1e3*(v??performance.now()),$(be,O.C,2)):be.return();case 2:return $(be,O.initialize(),3);case 3:for(K=new O.h.PacketDataList,G=i(Object.keys(g)),J=G.next();!J.done;J=G.next())if(ne=J.value,ue=O.g.inputs[ne]){e:{var pe=O,f=g[ne];switch(ue.type){case"video":var S=pe.m[ue.stream];if(S||(S=new yr(pe.h,pe.D),pe.m[ue.stream]=S),pe=S,pe.l===0&&(pe.l=pe.h.createTexture()),typeof HTMLVideoElement<"u"&&f instanceof HTMLVideoElement){var E=f.videoWidth;S=f.videoHeight}else typeof HTMLImageElement<"u"&&f instanceof HTMLImageElement?(E=f.naturalWidth,S=f.naturalHeight):(E=f.width,S=f.height);S={glName:pe.l,width:E,height:S},E=pe.g,E.canvas.width=S.width,E.canvas.height=S.height,E.activeTexture(E.TEXTURE0),pe.h.bindTexture2d(pe.l),E.texImage2D(E.TEXTURE_2D,0,E.RGBA,E.RGBA,E.UNSIGNED_BYTE,f),pe.h.bindTexture2d(0),pe=S;break e;case"detections":for(S=pe.m[ue.stream],S||(S=new jo(pe.h),pe.m[ue.stream]=S),pe=S,pe.data||(pe.data=new pe.g.DetectionListData),pe.data.reset(f.length),S=0;S<f.length;++S){E=f[S];var I=pe.data,A=I.setBoundingBox,_=S,D=E.T,B=new Kr;ke(B,1,D.Z),ke(B,2,D.$),ke(B,3,D.height),ke(B,4,D.width),ke(B,5,D.rotation),ke(B,6,D.X);var j=D=new Tn;Et(j,1,Me(B,1)),Et(j,2,Me(B,2)),Et(j,3,Me(B,3)),Et(j,4,Me(B,4)),Et(j,5,Me(B,5));var Y=Me(B,6);if(Y!=null&&Y!=null){nn(j.g,48);var Q=j.g,re=Y;Y=0>re,re=Math.abs(re);var se=re>>>0;for(re=Math.floor((re-se)/4294967296),re>>>=0,Y&&(re=~re>>>0,se=(~se>>>0)+1,4294967295<se&&(se=0,re++,4294967295<re&&(re=0))),Wt=se,zt=re,Y=Wt,se=zt;0<se||127<Y;)Q.push(Y&127|128),Y=(Y>>>7|se<<25)>>>0,se>>>=7;Q.push(Y)}if(Xr(B,j),D=pr(D),A.call(I,_,D),E.O)for(I=0;I<E.O.length;++I)B=E.O[I],j=!!B.visibility,A=pe.data,_=A.addNormalizedLandmark,D=S,B=Object.assign(Object.assign({},B),{visibility:j?B.visibility:0}),j=new Gn,ke(j,1,B.x),ke(j,2,B.y),ke(j,3,B.z),B.visibility&&ke(j,4,B.visibility),Q=B=new Tn,Et(Q,1,Me(j,1)),Et(Q,2,Me(j,2)),Et(Q,3,Me(j,3)),Et(Q,4,Me(j,4)),Et(Q,5,Me(j,5)),Xr(j,Q),B=pr(B),_.call(A,D,B);if(E.M)for(I=0;I<E.M.length;++I){if(A=pe.data,_=A.addClassification,D=S,B=E.M[I],j=new yn,ke(j,2,B.Y),B.index&&ke(j,1,B.index),B.label&&ke(j,3,B.label),B.displayName&&ke(j,4,B.displayName),Q=B=new Tn,se=Me(j,1),se!=null&&se!=null)if(nn(Q.g,8),Y=Q.g,0<=se)nn(Y,se);else{for(re=0;9>re;re++)Y.push(se&127|128),se>>=7;Y.push(1)}Et(Q,2,Me(j,2)),Y=Me(j,3),Y!=null&&(Y=Te(Y),nn(Q.g,26),nn(Q.g,Y.length),jt(Q,Q.g.end()),jt(Q,Y)),Y=Me(j,4),Y!=null&&(Y=Te(Y),nn(Q.g,34),nn(Q.g,Y.length),jt(Q,Q.g.end()),jt(Q,Y)),Xr(j,Q),B=pr(B),_.call(A,D,B)}}pe=pe.data;break e;default:pe={}}}switch(ye=pe,Ee=ue.stream,ue.type){case"video":K.pushTexture2d(Object.assign(Object.assign({},ye),{stream:Ee,timestamp:W}));break;case"detections":Se=ye,Se.stream=Ee,Se.timestamp=W,K.pushDetectionList(Se);break;default:throw Error("Unknown input config type: '"+ue.type+"'")}}return O.i.send(K),$(be,O.C,4);case 4:K.delete(),be.g=0}})})};function Ms(g,v,k){return at(g,function O(){var W,K,G,J,ne,ue,ye=this,Ee,Se,be,pe,f,S,E,I;return L(O,function(A){switch(A.g){case 1:if(!k)return A.return(v);for(W={},K=0,G=i(Object.keys(k)),J=G.next();!J.done;J=G.next())ne=J.value,ue=k[ne],typeof ue!="string"&&ue.type==="texture"&&v[ue.stream]!==void 0&&++K;1<K&&(ye.G=!1),Ee=i(Object.keys(k)),J=Ee.next();case 2:if(J.done){A.g=4;break}if(Se=J.value,be=k[Se],typeof be=="string")return E=W,I=Se,$(A,Ls(ye,Se,v[be]),14);if(pe=v[be.stream],be.type==="detection_list"){if(pe){for(var _=pe.getRectList(),D=pe.getLandmarksList(),B=pe.getClassificationsList(),j=[],Y=0;Y<_.size();++Y){var Q=_.get(Y);e:{var re=new Kr;for(Q=new zn(Q);Tt(Q);)switch(Q.i){case 13:var se=et(Q);ke(re,1,se);break;case 21:se=et(Q),ke(re,2,se);break;case 29:se=et(Q),ke(re,3,se);break;case 37:se=et(Q),ke(re,4,se);break;case 45:se=et(Q),ke(re,5,se);break;case 48:se=lr(Q.g),ke(re,6,se);break;default:if(!Ot(re,Q))break e}}re={Z:At(re,1),$:At(re,2),height:At(re,3),width:At(re,4),rotation:At(re,5,0),X:fn(re,6,0)},Q=Hr(Rs(D.get(Y)),Gn).map(Ma);var ie=B.get(Y);e:for(se=new qr,ie=new zn(ie);Tt(ie);)switch(ie.i){case 10:se.addClassification(jr(ie,new yn,Is));break;default:if(!Ot(se,ie))break e}re={T:re,O:Q,M:Da(se)},j.push(re)}_=j}else _=[];W[Se]=_,A.g=7;break}if(be.type==="proto_list"){if(pe){for(_=Array(pe.size()),D=0;D<pe.size();D++)_[D]=pe.get(D);pe.delete()}else _=[];W[Se]=_,A.g=7;break}if(pe===void 0){A.g=3;break}if(be.type==="float_list"){W[Se]=pe,A.g=7;break}if(be.type==="proto"){W[Se]=pe,A.g=7;break}if(be.type!=="texture")throw Error("Unknown output config type: '"+be.type+"'");return f=ye.s[Se],f||(f=new yr(ye.h,ye.D),ye.s[Se]=f),$(A,jn(f,pe,ye.G),13);case 13:S=A.h,W[Se]=S;case 7:be.transform&&W[Se]&&(W[Se]=be.transform(W[Se])),A.g=3;break;case 14:E[I]=A.h;case 3:J=Ee.next(),A.g=2;break;case 4:return A.return(W)}})})}function Ls(g,v,k){return at(g,function O(){var W=this,K;return L(O,function(G){return typeof k=="number"||k instanceof Uint8Array||k instanceof W.h.Uint8BlobList?G.return(k):k instanceof W.h.Texture2dDataOut?(K=W.s[v],K||(K=new yr(W.h,W.D),W.s[v]=K),G.return(jn(K,k,W.G))):G.return(void 0)})})}function Ko(g,v){for(var k=v.name||"$",O=[].concat(u(v.wants)),W=new g.h.StringList,K=i(v.wants),G=K.next();!G.done;G=K.next())W.push_back(G.value);K=g.h.PacketListener.implement({onResults:function(J){for(var ne={},ue=0;ue<v.wants.length;++ue)ne[O[ue]]=J.get(ue);var ye=g.listeners[k];ye&&(g.C=Ms(g,ne,v.outs).then(function(Ee){Ee=ye(Ee);for(var Se=0;Se<v.wants.length;++Se){var be=ne[O[Se]];typeof be=="object"&&be.hasOwnProperty&&be.hasOwnProperty("delete")&&be.delete()}Ee&&(g.C=Ee)}))}}),g.i.attachMultiListener(W,K),W.delete()}n.onResults=function(g,v){this.listeners[v||"$"]=g},te("Solution",Cn),te("OptionType",{BOOL:0,NUMBER:1,aa:2,0:"BOOL",1:"NUMBER",2:"STRING"});function Yo(g){g=As(g);var v=g.getMesh();if(!v)return g;var k=new Float32Array(v.getVertexBufferList());v.getVertexBufferList=function(){return k};var O=new Uint32Array(v.getIndexBufferList());return v.getIndexBufferList=function(){return O},g}var Ba={files:[{url:"face_mesh_solution_packed_assets_loader.js"},{simd:!0,url:"face_mesh_solution_simd_wasm_bin.js"},{simd:!1,url:"face_mesh_solution_wasm_bin.js"}],graph:{url:"face_mesh.binarypb"},listeners:[{wants:["multi_face_geometry","image_transformed","multi_face_landmarks"],outs:{image:"image_transformed",multiFaceGeometry:{type:"proto_list",stream:"multi_face_geometry",transform:function(g){return g.map(Yo)}},multiFaceLandmarks:{type:"proto_list",stream:"multi_face_landmarks",transform:function(g){return g.map(function(v){return Hr(Rs(v),Gn).map(Ma)})}}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},enableFaceGeometry:{type:0,graphOptionXref:{calculatorName:"EnableFaceGeometryConstant",calculatorType:"ConstantSidePacketCalculator",fieldName:"bool_value"}},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},maxNumFaces:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorNumFaces",fieldName:"int_value"}},refineLandmarks:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorRefineLandmarks",fieldName:"bool_value"}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"facelandmarkfrontgpu__facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"facelandmarkfrontgpu__facelandmarkgpu__ThresholdingCalculator",fieldName:"threshold"}},cameraNear:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"near"}},cameraFar:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"far"}},cameraVerticalFovDegrees:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"vertical_fov_degrees"}}}},Ua=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],Va=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Wa=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],za=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Ga=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ja=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],Ps=[].concat(u(Ua),u(Va),u(Wa),u(za),u(Ga),u(ja));function Bs(g){g=g||{},g=Object.assign(Object.assign({},Ba),g),this.g=new Cn(g)}n=Bs.prototype,n.close=function(){return this.g.close(),Promise.resolve()},n.onResults=function(g){this.g.onResults(g)},n.initialize=function(){return at(this,function g(){var v=this;return L(g,function(k){return $(k,v.g.initialize(),0)})})},n.reset=function(){this.g.reset()},n.send=function(g){return at(this,function v(){var k=this;return L(v,function(O){return $(O,k.g.send(g),0)})})},n.setOptions=function(g){this.g.setOptions(g)},te("FACE_GEOMETRY",{Layout:{COLUMN_MAJOR:0,ROW_MAJOR:1,0:"COLUMN_MAJOR",1:"ROW_MAJOR"},PrimitiveType:{TRIANGLE:0,0:"TRIANGLE"},VertexType:{VERTEX_PT:0,0:"VERTEX_PT"},DEFAULT_CAMERA_PARAMS:{verticalFovDegrees:63,near:1,far:1e4}}),te("FaceMesh",Bs),te("FACEMESH_LIPS",Ua),te("FACEMESH_LEFT_EYE",Va),te("FACEMESH_LEFT_EYEBROW",Wa),te("FACEMESH_LEFT_IRIS",[[474,475],[475,476],[476,477],[477,474]
18]),te("FACEMESH_RIGHT_EYE",za),te("FACEMESH_RIGHT_EYEBROW",Ga),te("FACEMESH_RIGHT_IRIS",[[469,470],[470,471],[471,472],[472,469]]),te("FACEMESH_FACE_OVAL",ja),te("FACEMESH_CONTOURS",Ps),te("FACEMESH_TESSELATION",[
vendor: 14,069 bytes, line 18
18[127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,23
vendor: 10,272 bytes, line 18
181],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]
18]),te("matrixDataToMatrix",function(g){for(var v=g.getCols(),k=g.getRows(),O=g.getPackedDataList(),W=[],K=0;K<k;K++)W.push(Array(v));for(K=0;K<k;K++)for(var G=0;G<v;G++){var J=g.getLayout()===1?K*v+G:G*k+K;W[K][G]=O[J]}return W}),te("VERSION","0.4.1633559619")}).call(ml)),ml}var p2=c2();/** 19 * @license 20 * Copyright 2020 Google LLC. All Rights Reserved. 21 * Licensed under the Apache License, Version 2.0 (the "License"); 22 * you may not use this file except in compliance with the License. 23 * You may obtain a copy of the License at 24 * 25 * http://www.apache.org/licenses/LICENSE-2.0 26 * 27 * Unless required by applicable law or agreed to in writing, software 28 * distributed under the License is distributed on an "AS IS" BASIS, 29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 30 * See the License for the specific language governing permissions and 31 * limitations under the License. 32 * ============================================================================= 33 */const h2=1e-7,d2=1e-4;class f2{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class Bc{refCount(e){return Dt("refCount")}incRef(e){return Dt("incRef")}timerAvailable(){return!0}time(e){return Dt("time")}read(e){return Dt("read")}readSync(e){return Dt("readSync")}readToGPU(e,t){return Dt("readToGPU")}numDataIds(){return Dt("numDataIds")}disposeData(e,t){return Dt("disposeData")}write(e,t,r){return Dt("write")}move(e,t,r,a,s){return Dt("move")}memory(){return Dt("memory")}floatPrecision(){return Dt("floatPrecision")}epsilon(){return this.floatPrecision()===32?h2:d2}dispose(){return Dt("dispose")}}function Dt(n){throw new Error(`'${n}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}/** 34 * @license 35 * Copyright 2020 Google LLC. All Rights Reserved. 36 * Licensed under the Apache License, Version 2.0 (the "License"); 37 * you may not use this file except in compliance with the License. 38 * You may obtain a copy of the License at 39 * 40 * http://www.apache.org/licenses/LICENSE-2.0 41 * 42 * Unless required by applicable law or agreed to in writing, software 43 * distributed under the License is distributed on an "AS IS" BASIS, 44 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 45 * See the License for the specific language governing permissions and 46 * limitations under the License. 47 * ============================================================================= 48 */function eo(n,e,t){return Math.max(n,Math.min(e,t))}function ku(n){return n%2===0?n:n+1}function Ha(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function m2(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function R(n,e){if(!n)throw new Error(typeof e=="string"?e:e())}function Lt(n,e,t=""){R(qe(n,e),()=>t+` Shapes ${n} and ${e} must match`)}function ga(n){R(n!=null,()=>"The input to the tensor constructor must be a non-null value.")}function ia(n,e=[],t=!1){if(e==null&&(e=[]),Array.isArray(n)||wn(n)&&!t)for(let r=0;r<n.length;++r)ia(n[r],e,t);else e.push(n);return e}function ae(n){if(n.length===0)return 1;let e=n[0];for(let t=1;t<n.length;t++)e*=n[t];return e}function qe(n,e){if(n===e)return!0;if(n==null||e==null||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function ua(n){return n%1===0}function Ei(n){const e=Math.ceil(Math.sqrt(n));return[e,Math.ceil(n/e)]}function ra(n,e){return e<=n.length?n:n+" ".repeat(e-n.length)}function yl(n,e=a=>0,t,r=setTimeout){return new Promise((a,s)=>{let o=0;const i=()=>{if(n()){a();return}o++;const u=e(o);if(t!=null&&o>=t){s();return}r(i,u)};i()})}function g2(n,e){let t=1,r=-1;for(let s=0;s<n.length;++s)if(n[s]>=0)t*=n[s];else if(n[s]===-1){if(r!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${s}`);r=s}else if(n[s]<0)throw Error(`Shapes can not be < 0. Found ${n[s]} at dim ${s}`);if(r===-1){if(e>0&&e!==t)throw Error(`Size(${e}) must match the product of shape ${n}`);return n}if(t===0)throw Error(`Cannot infer the missing size in [${n}] when there are 0 elements`);if(e%t!==0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t}`);const a=n.slice();return a[r]=e/t,a}function rt(n,e){const t=e.length;return n=n==null?e.map((r,a)=>a):[].concat(n),R(n.every(r=>r>=-t&&r<t),()=>`All values in axis param must be in range [-${t}, ${t}) but got axis ${n}`),R(n.every(r=>ua(r)),()=>`All values in axis param must be integers but got axis ${n}`),n.map(r=>r<0?t+r:r)}function rr(n,e){const t=[],r=[],a=e!=null&&Array.isArray(e)&&e.length===0,s=e==null||a?null:rt(e,n).sort();let o=0;for(let i=0;i<n.length;++i){if(s!=null){if(s[o]===i&&n[i]!==1)throw new Error(`Can't squeeze axis ${i} since its dim '${n[i]}' is not 1`);(s[o]==null||s[o]>i)&&n[i]===1&&(t.push(n[i]),r.push(i)),s[o]<=i&&o++}n[i]!==1&&(t.push(n[i]),r.push(i))}return{newShape:t,keptDims:r}}function On(n,e){let t=null;if(n==null||n==="float32")t=new Float32Array(e);else if(n==="int32")t=new Int32Array(e);else if(n==="bool")t=new Uint8Array(e);else throw new Error(`Unknown data type ${n}`);return t}function kt(n,e){let t=null;if(n==null||n==="float32")t=new Float32Array(e);else if(n==="int32")t=new Int32Array(e);else if(n==="bool")t=new Uint8Array(e);else if(n==="string")t=new Array(e);else throw new Error(`Unknown data type ${n}`);return t}function y2(n,e){for(let t=0;t<n.length;t++){const r=n[t];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${e} being uploaded contains ${r}.`)}}function x2(n){return n==="bool"||n==="complex64"||n==="float32"||n==="int32"||n==="str
48ing"}function b2(n,e){return!(e==="complex64"||e==="float32"&&n!=="complex64"||e==="int32"&&n!=="float32"&&n!=="complex64"||e==="bool"&&n==="bool")}function wn(n){return n instanceof Float32Array||n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray}function Ci(n){if(n==="float32"||n==="int32")return 4;if(n==="complex64")return 8;if(n==="bool")return 1;throw new Error(`Unknown dtype ${n}`)}function v2(n){if(n==null)return 0;let e=0;return n.forEach(t=>e+=t.length),e}function bo(n){return typeof n=="string"||n instanceof String}function w2(n){return typeof n=="boolean"}function S2(n){return typeof n=="number"}function vo(n){return Array.isArray(n)?vo(n[0]):n instanceof Float32Array?"float32":n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray?"int32":S2(n)?"float32":bo(n)?"string":w2(n)?"bool":"float32"}function xl(n){return!!(n&&n.constructor&&n.call&&n.apply)}function Ii(n,e){for(let t=e;t<n;++t)if(n%t===0)return t;return n}function ot(n){const e=n.length;if(e<2)return[];const t=new Array(e-1);t[e-2]=n[e-1];for(let r=e-3;r>=0;--r)t[r]=t[r+1]*n[r+1];return t}function Uc(n,e,t,r=!1){const a=new Array;if(e.length===1){const s=e[0]*(r?2:1);for(let o=0;o<s;o++)a[o]=t[n+o]}else{const s=e[0],o=e.slice(1),i=o.reduce((u,l)=>u*l)*(r?2:1);for(let u=0;u<s;u++)a[u]=Uc(n+u*i,o,t,r)}return a}function Ni(n,e,t=!1){if(n.length===0)return e[0];const r=n.reduce((a,s)=>a*s)*(t?2:1);if(r===0)return[];if(r!==e.length)throw new Error(`[${n}] does not match the input size ${e.length}${t?" for a complex tensor":""}.`);return Uc(0,n,e,t)}function Vc(n,e){const t=er(n,e);for(let r=0;r<t.length;r++)t[r]=1;return t}function er(n,e){if(e==null||e==="float32"||e==="complex64")return new Float32Array(n);if(e==="int32")return new Int32Array(n);if(e==="bool")return new Uint8Array(n);throw new Error(`Unknown data type ${e}`)}function Wc(n){n.forEach(e=>{R(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${n}].`)})}function $i(n,e,t){if(e===0)return 0;if(e===1)return n[0];let r=n[n.length-1];for(let a=0;a<n.length-1;++a)r+=t[a]*n[a];return r}function Tu(n,e,t){if(e===0)return[];if(e===1)return[n];const r=new Array(e);for(let a=0;a<r.length-1;++a)r[a]=Math.floor(n/t[a]),n-=r[a]*t[a];return r[r.length-1]=n,r}function la(n){return n&&n.then&&typeof n.then=="function"}/** 49 * @license 50 * Copyright 2017 Google LLC. All Rights Reserved. 51 * Licensed under the Apache License, Version 2.0 (the "License"); 52 * you may not use this file except in compliance with the License. 53 * You may obtain a copy of the License at 54 * 55 * http://www.apache.org/licenses/LICENSE-2.0 56 * 57 * Unless required by applicable law or agreed to in writing, software 58 * distributed under the License is distributed on an "AS IS" BASIS, 59 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 60 * See the License for the specific language governing permissions and 61 * limitations under the License. 62 * ============================================================================= 63 */const bl="tfjsflags";class k2{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=T2,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&(H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,r){if(this.flagRegistry[e]={evaluationFn:t,setHook:r},this.urlFlags[e]!=null){const a=this.urlFlags[e];H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${a}.`),this.set(e,a)}}async getAsync(e){return e in this.flags?this.flags[e]:(this.flags[e]=await this.evaluateFlag(e),this.flags[e])}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(la(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(this.flagRegistry[e]==null)throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,this.flagRegistry[e].setHook!=null&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(this.flagRegistry[e]==null)throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(typeof this.global>"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")return;const e=this.getQueryParams(this.global.location.search);bl in e&&e[bl].split(",").forEach(t=>{const[r,a]=t.split(":");this.urlFlags[r]=C2(r,a)})}}function T2(n){const e={};return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(t,...r)=>(E2(e,r[0],r[1]),r.join("="))),e}function E2(n,e,t){n[decodeURIComponent(e)]=decodeURIComponent(t||"")}function C2(n,e){if(e=e.toLowerCase(),e==="true"||e==="false")return e==="true";if(`${+e}`===e)return+e;throw new Error(`Could not parse value flag value ${e} for flag ${n}.`)}function H(){return zc}let zc=null;function I2(n){zc=n}/** 64 * @license 65 * Copyright 2020 Google LLC. All Rights Reserved. 66 * Licensed under the Apache License, Version 2.0 (the "License");
67 * you may not use this file except in compliance with the License. 68 * You may obtain a copy of the License at 69 * 70 * http://www.apache.org/licenses/LICENSE-2.0 71 * 72 * Unless required by applicable law or agreed to in writing, software 73 * distributed under the License is distributed on an "AS IS" BASIS, 74 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 75 * See the License for the specific language governing permissions and 76 * limitations under the License. 77 * ============================================================================= 78 */let Qo;function Gc(){if(Qo==null){let n;if(typeof window<"u")n=window;else if(typeof global<"u")n=global;else if(typeof process<"u")n=process;else if(typeof self<"u")n=self;else throw new Error("Could not find a global object");Qo=n}return Qo}function N2(){const n=Gc();return n._tfGlobals==null&&(n._tfGlobals=new Map),n._tfGlobals}function Eu(n,e){const t=N2();if(t.has(n))return t.get(n);{const r=e();return t.set(n,r),t.get(n)}}const jc="Abs",Hc="Acos",Xc="Acosh",Cu="Add",qc="AddN",Kc="All",Yc="Any",Zc="ArgMax",Jc="ArgMin",Qc="Asin",ep="Asinh",tp="Atan",np="Atanh",rp="Atan2",ap="AvgPool",$2="AvgPoolGrad",sp="AvgPool3D",R2="AvgPool3DGrad",op="BatchMatMul",ip="BatchToSpaceND",up="Bincount",lp="BroadcastArgs",Iu="Cast",cp="Ceil",pp="ClipByValue",hp="Complex",dp="ComplexAbs",fp="Concat",mp="Conv2D",gp="Conv2DBackpropFilter",yp="Conv2DBackpropInput",xp="Conv3D",_2="Conv3DBackpropFilterV2",bp="Conv3DBackpropInputV2",vp="Cos",wp="Cosh",Sp="Cumprod",kp="Cumsum",Tp="CropAndResize",Ep="DenseBincount",Cp="DepthToSpace",Ip="DepthwiseConv2dNative",Np="DepthwiseConv2dNativeBackpropFilter",$p="DepthwiseConv2dNativeBackpropInput",Rp="Diag",_p="Dilation2D",Ap="RealDiv",Op="Einsum",Fp="Elu",A2="EluGrad",Dp="Erf",Mp="Equal",Lp="Exp",Pp="ExpandDims",Bp="Expm1",Up="FFT",Vp="Fill",Wp="FlipLeftRight",zp="Floor",Gp="FloorDiv",jp="FusedBatchNorm",Hp="GatherV2",Xp="GatherNd",qp="Greater",Kp="GreaterEqual",Nu="Identity",Yp="IFFT",Zp="Imag",Jp="IsFinite",Qp="IsInf",eh="IsNan",th="LeakyRelu",nh="Less",rh="LessEqual",ah="LinSpace",sh="Log",oh="Log1p",ih="LogicalAnd",uh="LogicalNot",lh="LogicalOr",ch="LRN",O2="LRNGrad",ph="Max",hh="Maximum",dh="MaxPool",F2="MaxPoolGrad",fh="MaxPool3D",D2="MaxPool3DGrad",mh="MaxPoolWithArgmax",gh="Mean",yh="Min",xh="Minimum",bh="MirrorPad",vh="Mod",wh="Multinomial",Sh="Multiply",kh="Neg",Th="NotEqual",Eh="NonMaxSuppressionV3",Ch="NonMaxSuppressionV4",Ih="NonMaxSuppressionV5",Nh="OnesLike",$h="OneHot",Rh="Pack",_h="PadV2",Ah="Pow",Oh="Prelu",Fh="Prod",Dh="RaggedGather",Mh="RaggedTensorToTensor",Lh="Range",Ph="Real",Bh="Reciprocal",Uh="Relu",Vh="Reshape",Wh="ResizeNearestNeighbor",M2="ResizeNearestNeighborGrad",zh="ResizeBilinear",L2="ResizeBilinearGrad",Gh="Relu6",jh="Reverse",Hh="Round",Xh="Rsqrt",qh="ScatterNd",Kh="SearchSorted",Yh="Select",Zh="Selu",Jh="Slice",Qh="Sin",ed="Sinh",td="Sign",nd="Sigmoid",rd="Softplus",ad="Sqrt",sd="Sum",od="SpaceToBatchND",id="SplitV",ud="Softmax",ld="SparseFillEmptyRows",cd="SparseReshape",pd="SparseSegmentMean",hd="SparseSegmentSum",dd="SparseToDense",fd="SquaredDifference",P2="Square",md="StridedSlice",gd="StringNGrams",yd="StringSplit",xd="StringToHashBucketFast",bd="Sub",vd="Tan",wd="Tanh",$u="Tile",Sd="TopK",kd="Transform",Ks="Transpose",Td="Unique",Ed="Unpack",Cd="UnsortedSegmentSum",Id="ZerosLike",Nd="Step",Ri="FromPixels",$d="RotateWithOffset",_i="_FusedMatMul",Ai="FusedConv2D",Oi="FusedDepthwiseConv2D";/** 79 * @license 80 * Copyright 2018 Google LLC. All Rights Reserved. 81 * Licensed under the Apache License, Version 2.0 (the "License"); 82 * you may not use this file except in compliance with the License. 83 * You may obtain a copy of the License at 84 * 85 * http://www.apache.org/licenses/LICENSE-2.0 86 * 87 * Unless required by applicable law or agreed to in writing, software 88 * distributed under the License is distributed on an "AS IS" BASIS, 89 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 90 * See the License for the specific language governing permissions and 91 * limitations under the License. 92 * ============================================================================= 93 */function ln(...n){H().getBool("IS_TEST")||H().getBool("PROD")||console.warn(...n)}function B2(...n){H().getBool("IS_TEST")||H().getBool("PROD")||console.log(...n)}/** 94 * @license 95 * Copyright 2019 Google LLC. All Rights Reserved. 96 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 9,388 bytes, lines 97-108
97 * you may not use this file except in compliance with the License. 98 * You may obtain a copy of the License at 99 * 100 * http://www.apache.org/licenses/LICENSE-2.0 101 * 102 * Unless required by applicable law or agreed to in writing, software 103 * distributed under the License is distributed on an "AS IS" BASIS, 104 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 105 * See the License for the specific language governing permissions and 106 * limitations under the License. 107 * ============================================================================= 108 */const to=Eu("kernelRegistry",()=>new Map),U2=Eu("gradRegistry",()=>new Map);function Fi(n,e){const t=Rd(n,e);return to.get(t)}function vl(n){return U2.get(n)}function wl(n){const e=to.entries(),t=[];for(;;){const{done:r,value:a}=e.next();if(r)break;const[s,o]=a,[i]=s.split("_");i===n&&t.push(o)}return t}function V2(n){const{kernelName:e,backendName:t}=n,r=Rd(e,t);to.has(r)&&ln(`The kernel '${e}' for backend '${t}' is already registered`),to.set(r,n)}function Rd(n,e){return`${e}_${n}`}var ei,Sl;function W2(){if(Sl)return ei;Sl=1,ei=e;var n=null;try{n=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function e(C,q,ee){this.low=C|0,this.high=q|0,this.unsigned=!!ee}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0});function t(C){return(C&&C.__isLong__)===!0}e.isLong=t;var r={},a={};function s(C,q){var ee,te,le;return q?(C>>>=0,(le=0<=C&&C<256)&&(te=a[C],te)?te:(ee=i(C,(C|0)<0?-1:0,!0),le&&(a[C]=ee),ee)):(C|=0,(le=-128<=C&&C<128)&&(te=r[C],te)?te:(ee=i(C,C<0?-1:0,!1),le&&(r[C]=ee),ee))}e.fromInt=s;function o(C,q){if(isNaN(C))return q?T:x;if(q){if(C<0)return T;if(C>=m)return X}else{if(C<=-y)return z;if(C+1>=y)return U}return C<0?o(-C,q).neg():i(C%d|0,C/d|0,q)}e.fromNumber=o;function i(C,q,ee){return new e(C,q,ee)}e.fromBits=i;var u=Math.pow;function l(C,q,ee){if(C.length===0)throw Error("empty string");if(C==="NaN"||C==="Infinity"||C==="+Infinity"||C==="-Infinity")return x;if(typeof q=="number"?(ee=q,q=!1):q=!!q,ee=ee||10,ee<2||36<ee)throw RangeError("radix");var te;if((te=C.indexOf("-"))>0)throw Error("interior hyphen");if(te===0)return l(C.substring(1),q,ee).neg();for(var le=o(u(ee,8)),de=x,fe=0;fe<C.length;fe+=8){var Re=Math.min(8,C.length-fe),ge=parseInt(C.substring(fe,fe+Re),ee);if(Re<8){var Te=o(u(ee,Re));de=de.mul(Te).add(o(ge))}else de=de.mul(le),de=de.add(o(ge))}return de.unsigned=q,de}e.fromString=l;function c(C,q){return typeof C=="number"?o(C,q):typeof C=="string"?l(C,q):i(C.low,C.high,typeof q=="boolean"?q:C.unsigned)}e.fromValue=c;var p=65536,h=1<<24,d=p*p,m=d*d,y=m/2,b=s(h),x=s(0);e.ZERO=x;var T=s(0,!0);e.UZERO=T;var $=s(1);e.ONE=$;var F=s(1,!0);e.UONE=F;var M=s(-1);e.NEG_ONE=M;var U=i(-1,2147483647,!1);e.MAX_VALUE=U;var X=i(-1,-1,!0);e.MAX_UNSIGNED_VALUE=X;var z=i(0,-2147483648,!1);e.MIN_VALUE=z;var L=e.prototype;return L.toInt=function(){return this.unsigned?this.low>>>0:this.low},L.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},L.toString=function(C){if(C=C||10,C<2||36<C)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(z)){var q=o(C),ee=this.div(q),te=ee.mul(q).sub(this);return ee.toString(C)+te.toInt().toString(C)}else return"-"+this.neg().toString(C);for(var le=o(u(C,6),this.unsigned),de=this,fe="";;){var Re=de.div(le),ge=de.sub(Re.mul(le)).toInt()>>>0,Te=ge.toString(C);if(de=Re,de.isZero())return Te+fe;for(;Te.length<6;)Te="0"+Te;fe=""+Te+fe}},L.getHighBits=function(){return this.high},L.getHighBitsUnsigned=function(){return this.high>>>0},L.getLowBits=function(){return this.low},L.getLowBitsUnsigned=function(){return this.low>>>0},L.getNumBitsAbs=function(){if(this.isNegative())return this.eq(z)?64:this.neg().getNumBitsAbs();for(var C=this.high!=0?this.high:this.low,q=31;q>0&&(C&1<<q)==0;q--);return this.high!=0?q+33:q+1},L.isZero=function(){return this.high===0&&this.low===0},L.eqz=L.isZero,L.isNegative=function(){return!this.unsigned&&this.high<0},L.isPositive=function(){return this.unsigned||this.high>=0},L.isOdd=function(){return(this.low&1)===1},L.isEven=function(){return(this.low&1)===0},L.equals=function(C){return t(C)||(C=c(C)),this.unsigned!==C.unsigned&&this.high>>>31===1&&C.high>>>31===1?!1:this.high===C.high&&this.low===C.low},L.eq=L.equals,L.notEquals=function(C){return!this.eq(C)},L.neq=L.notEquals,L.ne=L.notEquals,L.lessThan=function(C){return this.comp(C)<0},L.lt=L.lessThan,L.lessThanOrEqual=function(C){return this.comp(C)<=0},L.lte=L.lessThanOrEqual,L.le=L.lessThanOrEqual,L.greaterThan=function(C){return this.comp(C)>0},L.gt=L.greaterThan,L.greaterThanOrEqual=function(C){return this.comp(C)>=0},L.gte=L.greaterThanOrEqual,L.ge=L.greaterThanOrEqual,L.compare=function(C){if(t(C)||(C=c(C)),this.eq(C))return 0;var q=this.isNegative(),ee=C.isNegative();return q&&!ee?-1:!q&&ee?1:this.unsigned?C.high>>>0>this.high>>>0||C.high===this.high&&C.low>>>0>this.low>>>0?-1:1:this.sub(C).isNegative()?-1:1},L.comp=L.compare,L.negate=function(){return!this.unsigned&&this.eq(z)?z:this.not().add($)},L.neg=L.negate,L.add=function(C){t(C)||(C=c(C));var q=this.high>>>16,ee=this.high&65535,te=this.low>>>16,le=this.low&65535,de=C.high>>>16,fe=C.high&65535,Re=C.low>>>16,ge=C.low&65535,Te=0,We=0,Ne=0,Ye=0;return Ye+=le+ge,Ne+=Ye>>>16,Ye&=65535,Ne+=te+Re,We+=Ne>>>16,Ne&=65535,We+=ee+fe,Te+=We>>>16,We&=65535,Te+=q+de,Te&=65535,i(Ne<<16|Ye,Te<<16|We,this.unsigned)},L.subtract=function(C){return t(C)||(C=c(C)),this.add(C.neg())},L.sub=L.subtract,L.multiply=function(C){if(this.isZero())return x;if(t(C)||(C=c(C)),n){var q=n.mul(this.low,this.high,C.low,C.high);return i(q,n.get_high(),this.unsigned)}if(C.isZero())return x;if(this.eq(z))return C.isOdd()?z:x;if(C.eq(z))return this.isOdd()?z:x;if(this.isNegative())return C.isNegative()?this.neg().mul(C.neg()):this.neg().mul(C).neg();if(C.isNegative())return this.mul(C.neg()).neg();if(this.lt(b)&&C.lt(b))return o(this.toNumber()*C.toNumber(),this.unsigned);var ee=this.high>>>16,te=this.high&65535,le=this.low>>>16,de=this.low&65535,fe=C.high>>>16,Re=C.high&65535,ge=C.low>>>16,Te=C.low&65535,We=0,Ne=0,Ye=0,Vt=0;return Vt+=de*Te,Ye+=Vt>>>16,Vt&=65535,Ye+=le*Te,Ne+=Ye>>>16,Ye&=65535,Ye+=de*ge,Ne+=Ye>>>16,Ye&=65535,Ne+=te*Te,We+=Ne>>>16,Ne&=65535,Ne+=le*ge,We+=Ne>>>16,Ne&=65535,Ne+=de*Re,We+=Ne>>>16,Ne&=65535,We+=ee*Te+te*ge+le*Re+de*fe,We&=65535,i(Ye<<16|Vt,We<<16|Ne,this.unsigned)},L.mul=L.multiply,L.divide=function(C){if(t(C)||(C=c(C)),C.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&C.low===-1&&C.high===-1)return this;var q=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,C.low,C.high);return i(q,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?T:x;var ee,te,le;if(this.unsigned){if(C.unsigned||(C=C.toUnsigned()),C.gt(this))return T;if(C.gt(this.shru(1)))return F;le=T}else{if(this.eq(z)){if(C.eq($)||C.eq(M))return z;if(C.eq(z))return $;var de=this.shr(1);return ee=de.div(C).shl(1),ee.eq(x)?C.isNegative()?$:M:(te=this.sub(C.mul(ee)),le=ee.add(te.div(C)),le)}else if(C.eq(z))return this.unsigned?T:x;if(this.isNegative())return C.isNegative()?this.neg().div(C.neg()):this.neg().div(C).neg();if(C.isNegative())return this.div(C.neg()).neg();le=x}for(te=this;te.gte(C);){ee=Math.max(1,Math.floor(te.toNumber()/C.toNumber()));for(var fe=Math.ceil(Math.log(ee)/Math.LN2),Re=fe<=48?1:u(2,fe-48),ge=o(ee),Te=ge.mul(C);Te.isNegative()||Te.gt(te);)ee-=Re,ge=o(ee,this.unsigned),Te=ge.mul(C);ge.isZero()&&(ge=$),le=le.add(ge),te=te.sub(Te)}return le},L.div=L.divide,L.modulo=function(C){if(t(C)||(C=c(C)),n){var q=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,C.low,C.high);return i(q,n.get_high(),this.unsigned)}return this.sub(this.div(C).mul(C))},L.mod=L.modulo,L.rem=L.modulo,L.not=function(){return i(~this.low,~this.high,this.unsigned)},L.and=function(C){return t(C)||(C=c(C)),i(this.low&C.low,this.high&C.high,this.unsigned)},L.or=function(C){return t(C)||(C=c(C)),i(this.low|C.low,this.high|C.high,this.unsigned)},L.xor=function(C){return t(C)||(C=c(C)),i(this.low^C.low,this.high^C.high,this.unsigned)},L.shiftLeft=function(C){return t(C)&&(C=C.toInt()),(C&=63)===0?this:C<32?i(this.low<<C,this.high<<C|this.low>>>32-C,this.unsigned):i(0,this.low<<C-32,this.unsigned)},L.shl=L.shiftLeft,L.shiftRight=function(C){return t(C)&&(C=C.toInt()),(C&=63)===0?this:C<32?i(this.low>>>C|this.high<<32-C,this.high>>C,this.unsigned):i(this.high>>C-32,this.high>=0?0:-1,this.unsigned)}
vendor: 4,653 bytes, lines 108-126
108,L.shr=L.shiftRight,L.shiftRightUnsigned=function(C){if(t(C)&&(C=C.toInt()),C&=63,C===0)return this;var q=this.high;if(C<32){var ee=this.low;return i(ee>>>C|q<<32-C,q>>>C,this.unsigned)}else return C===32?i(q,0,this.unsigned):i(q>>>C-32,0,this.unsigned)},L.shru=L.shiftRightUnsigned,L.shr_u=L.shiftRightUnsigned,L.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},L.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},L.toBytes=function(C){return C?this.toBytesLE():this.toBytesBE()},L.toBytesLE=function(){var C=this.high,q=this.low;return[q&255,q>>>8&255,q>>>16&255,q>>>24,C&255,C>>>8&255,C>>>16&255,C>>>24]},L.toBytesBE=function(){var C=this.high,q=this.low;return[C>>>24,C>>>16&255,C>>>8&255,C&255,q>>>24,q>>>16&255,q>>>8&255,q&255]},e.fromBytes=function(C,q,ee){return ee?e.fromBytesLE(C,q):e.fromBytesBE(C,q)},e.fromBytesLE=function(C,q){return new e(C[0]|C[1]<<8|C[2]<<16|C[3]<<24,C[4]|C[5]<<8|C[6]<<16|C[7]<<24,q)},e.fromBytesBE=function(C,q){return new e(C[4]<<24|C[5]<<16|C[6]<<8|C[7],C[0]<<24|C[1]<<16|C[2]<<8|C[3],q)},ei}var _d=W2();const Ad=s2(_d),z2=l2({__proto__:null,default:Ad},[_d]);/** 109 * @license 110 * Copyright 2021 Google LLC. All Rights Reserved. 111 * Licensed under the Apache License, Version 2.0 (the "License"); 112 * you may not use this file except in compliance with the License. 113 * You may obtain a copy of the License at 114 * 115 * http://www.apache.org/licenses/LICENSE-2.0 116 * 117 * Unless required by applicable law or agreed to in writing, software 118 * distributed under the License is distributed on an "AS IS" BASIS, 119 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120 * See the License for the specific language governing permissions and 121 * limitations under the License. 122 * ============================================================================= 123 */const kr=Ad||z2;function wo(n){return kr.fromString(n,!0,16)}const Od=wo("c3a5c85c97cb3127"),Sr=wo("b492b66fbe98f273"),dt=wo("9ae16a3b2f90404f");function Di(n){return n.xor(n.shru(47))}function Fd(n,e,t){const r=n.slice(e,e+t);return kr.fromBytes(Array.from(r),!0,!0)}function Le(n,e){return Fd(n,e,8)}function kl(n,e){return Fd(n,e,4)}function nt(n,e){return e===0?n:n.shru(e).or(n.shl(64-e))}function Zn(n,e,t=wo("9ddfea08eb382d69")){let r=n.xor(e).mul(t);r=r.xor(r.shru(47));let a=e.xor(r).mul(t);return a=a.xor(a.shru(47)),a=a.mul(t),a}function G2(n,e,t,r,a,s){a=a.add(n),s=nt(s.add(a).add(r),21);const o=a;return a=a.add(e),a=a.add(t),s=s.add(nt(a,44)),[a.add(r),s.add(o)]}function Vs(n,e,t,r){return G2(Le(n,e),Le(n,e+8),Le(n,e+16),Le(n,e+24),t,r)}function j2(n,e=n.length){if(e>=8){const t=dt.add(e*2),r=Le(n,0).add(dt),a=Le(n,e-8),s=nt(a,37).mul(t).add(r),o=nt(r,25).add(a).mul(t);return Zn(s,o,t)}if(e>=4){const t=dt.add(e*2),r=kl(n,0);return Zn(r.shl(3).add(e),kl(n,e-4),t)}if(e>0){const t=n[0],r=n[e>>1],a=n[e-1],s=t+(r<<8),o=e+(a<<2);return Di(dt.mul(s).xor(Od.mul(o))).mul(dt)}return dt}function H2(n,e=n.length){const t=dt.add(e*2),r=Le(n,0).mul(Sr),a=Le(n,8),s=Le(n,e-8).mul(t),o=Le(n,e-16).mul(dt);return Zn(nt(r.add(a),43).add(nt(s,30)).add(o),r.add(nt(a.add(dt),18)).add(s),t)}function X2(n,e=n.length){const t=dt.add(e*2),r=Le(n,0).mul(dt),a=Le(n,8),s=Le(n,e-8).mul(t),o=Le(n,e-16).mul(dt),i=nt(r.add(a),43).add(nt(s,30)).add(o),u=Zn(i,r.add(nt(a.add(dt),18)).add(s),t),l=Le(n,16).mul(t),c=Le(n,24),p=i.add(Le(n,e-32)).mul(t),h=u.add(Le(n,e-24)).mul(t);return Zn(nt(l.add(c),43).add(nt(p,30)).add(h),l.add(nt(c.add(r),18)).add(p),t)}function q2(n,e=n.length){const t=kr.fromNumber(81,!0);if(e<=32)return e<=16?j2(n,e):H2(n,e);if(e<=64)return X2(n,e);let r=t,a=t.mul(Sr).add(113),s=Di(a.mul(dt).add(113)).mul(dt),o=[kr.UZERO,kr.UZERO],i=[kr.UZERO,kr.UZERO];r=r.mul(dt).add(Le(n,0));let u=0;const l=(e-1>>6)*64,c=l+(e-1&63)-63;do r=nt(r.add(a).add(o[0]).add(Le(n,u+8)),37).mul(Sr),a=nt(a.add(o[1]).add(Le(n,u+48)),42).mul(Sr),r=r.xor(i[1]),a=a.add(o[0]).add(Le(n,u+40)),s=nt(s.add(i[0]),33).mul(Sr),o=Vs(n,u,o[1].mul(Sr),r.add(i[0])),i=Vs(n,u+32,s.add(i[1]),a.add(Le(n,u+16))),[s,r]=[r,s],u+=64;while(u!==l);const p=Sr.add(s.and(255).shl(1));return u=c,i[0]=i[0].add(e-1&63),o[0]=o[0].add(i[0]),i[0]=i[0].add(o[0]),r=nt(r.add(a).add(o[0]).add(Le(n,u+8)),37).mul(p),a=nt(a.add(o[1]).add(Le(n,u+48)),42).mul(p),r=r.xor(i[1].mul(9)),a=a.add(o[0].mul(9).add(Le(n,u+40))),s=nt(s.add(i[0]),33).mul(p),o=Vs(n,u,o[1].mul(p),r.add(i[0])),i=Vs(n,u+32,s.add(i[1]),a.add(Le(n,u+16))),[s,r]=[r,s],Zn(Zn(o[0],i[0],p).add(Di(a).mul(Od)).add(s),Zn(o[1],i[1],p).add(r),p)}/** 124 * @license 125 * Copyright 2017 Google LLC. All Rights Reserved. 126 * Licensed under the Apache License, Version 2.0 (the "License");
127 * you may not use this file except in compliance with the License. 128 * You may obtain a copy of the License at 129 * 130 * http://www.apache.org/licenses/LICENSE-2.0 131 * 132 * Unless required by applicable law or agreed to in writing, software 133 * distributed under the License is distributed on an "AS IS" BASIS, 134 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135 * See the License for the specific language governing permissions and 136 * limitations under the License. 137 * ============================================================================= 138 */function ya(n,e){return e==="string"?Nr(n):So([n],e)}function K2(n,e){return n instanceof Float32Array&&e==="float32"||n instanceof Int32Array&&e==="int32"||n instanceof Uint8Array&&e==="bool"}function So(n,e){if(e==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(n)&&(n=ia(n)),H().getBool("DEBUG")&&y2(n,e),K2(n,e))return n;if(e==null||e==="float32"||e==="complex64")return new Float32Array(n);if(e==="int32")return new Int32Array(n);if(e==="bool"){const t=new Uint8Array(n.length);for(let r=0;r<t.length;++r)Math.round(n[r])!==0&&(t[r]=1);return t}else throw new Error(`Unknown data type ${e}`)}function an(){return H().platform.now()}function Nr(n,e="utf-8"){return e=e||"utf-8",H().platform.encode(n,e)}function ca(n,e="utf-8"){return e=e||"utf-8",H().platform.decode(n,e)}/** 139 * @license 140 * Copyright 2018 Google LLC. All Rights Reserved. 141 * Licensed under the Apache License, Version 2.0 (the "License"); 142 * you may not use this file except in compliance with the License. 143 * You may obtain a copy of the License at 144 * 145 * http://www.apache.org/licenses/LICENSE-2.0 146 * 147 * Unless required by applicable law or agreed to in writing, software 148 * distributed under the License is distributed on an "AS IS" BASIS, 149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 150 * See the License for the specific language governing permissions and 151 * limitations under the License. 152 * ============================================================================= 153 */class Y2{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new J2)}profileKernel(e,t,r){let a;const s=()=>{a=r()};let o;const i=an();if(this.backendTimer.timerAvailable())o=this.backendTimer.time(s);else{s();for(const u of a)u.dataSync();o=Promise.resolve({kernelMs:an()-i})}if(H().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let u=0;u<a.length;u++){const l=a[u];l.data().then(c=>{Z2(c,l.dtype,e)})}return{kernelName:e,outputs:a,inputs:t,timeMs:o.then(u=>u.kernelMs),extraInfo:o.then(u=>u.getExtraProfileInfo!=null?u.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:t,outputs:r,timeMs:a,inputs:s,extraInfo:o}=e;r.forEach(i=>{Promise.all([i.data(),a,o]).then(u=>{this.logger.logKernelProfile(t,i,u[0],u[1],s,u[2])})})}}function Z2(n,e,t){if(e!=="float32")return!1;for(let r=0;r<n.length;r++){const a=n[r];if(isNaN(a)||!isFinite(a))return console.warn(`Found ${a} in the result of '${t}'`),!0}return!1}class J2{logKernelProfile(e,t,r,a,s,o){const i=typeof a=="number"?ra(`${a}ms`,9):a.error,u=ra(e,25),l=t.rank,c=t.size,p=ra(t.shape.toString(),14);let h="";for(const d in s){const m=s[d];if(m!=null){const y=m.shape||t.shape,b=y.length;h+=`${d}: ${b}D ${b>0?y:""} `}}console.log(`%c${u} %c${i} %c${l}D ${p} %c${c} %c${h} %c${o}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}/** 154 * @license 155 * Copyright 2017 Google LLC. All Rights Reserved. 156 * Licensed under the Apache License, Version 2.0 (the "License"); 157 * you may not use this file except in compliance with the License. 158 * You may obtain a copy of the License at 159 * 160 * http://www.apache.org/licenses/LICENSE-2.0 161 * 162 * Unless required by applicable law or agreed to in writing, software 163 * distributed under the License is distributed on an "AS IS" BASIS, 164 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 165 * See the License for the specific language governing permissions and 166 * limitations under the License. 167 * ============================================================================= 168 */function Q2(n,e,t){const r={},a={};for(let u=0;u<e.length;u++)r[e[u].id]=!0;for(let u=0;u<n.length;u++){const l=n[u],c=l.inputs;for(const p in c){const h=c[p];let d=!1;for(let m=0;m<e.length;
vendor: 8,817 bytes, lines 168-205
168m++)if(r[h.id]){l.outputs.forEach(y=>r[y.id]=!0),d=!0,a[l.id]=!0;break}if(d)break}}const s={};s[t.id]=!0;const o={};for(let u=n.length-1;u>=0;u--){const l=n[u],c=l.inputs;for(let p=0;p<l.outputs.length;p++)if(s[l.outputs[p].id]){for(const h in c)s[c[h].id]=!0,o[l.id]=!0;break}}const i=[];for(let u=0;u<n.length;u++){const l=n[u];if(a[l.id]&&o[l.id]){const c={};for(const h in l.inputs){const d=l.inputs[h];r[d.id]&&(c[h]=d)}const p=Object.assign({},l);p.inputs=c,p.outputs=l.outputs,i.push(p)}}return i}function eg(n,e,t,r){for(let a=e.length-1;a>=0;a--){const s=e[a],o=[];if(s.outputs.forEach(u=>{const l=n[u.id];l!=null?o.push(l):o.push(null)}),s.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);const i=s.gradient(o);for(const u in s.inputs){if(!(u in i))throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(i)}.`);const l=t(()=>i[u]());if(l.dtype!=="float32")throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`);const c=s.inputs[u];if(!qe(l.shape,c.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`);if(n[c.id]==null)n[c.id]=l;else{const p=n[c.id];n[c.id]=r(p,l),p.dispose()}}}}/** 169 * @license 170 * Copyright 2018 Google LLC. All Rights Reserved. 171 * Licensed under the Apache License, Version 2.0 (the "License"); 172 * you may not use this file except in compliance with the License. 173 * You may obtain a copy of the License at 174 * 175 * http://www.apache.org/licenses/LICENSE-2.0 176 * 177 * Unless required by applicable law or agreed to in writing, software 178 * distributed under the License is distributed on an "AS IS" BASIS, 179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 180 * See the License for the specific language governing permissions and 181 * limitations under the License. 182 * ============================================================================= 183 */const Tl=20,Xa=3,ti=7;function tg(n,e,t,r){const a=ot(e),s=ng(n,e,t,a),o=e.length,i=Ys(n,e,t,a,s),u=["Tensor"];return r&&(u.push(` dtype: ${t}`),u.push(` rank: ${o}`),u.push(` shape: [${e}]`),u.push(" values:")),u.push(i.map(l=>" "+l).join(` 184`)),u.join(` 185`)}function ng(n,e,t,r){const a=ae(e),s=r[r.length-1],o=new Array(s).fill(0),i=e.length,u=t==="complex64"?Ya(n):n;if(i>1)for(let l=0;l<a/s;l++){const c=l*s;for(let p=0;p<s;p++)o[p]=Math.max(o[p],Ka(u[c+p],0,t).length)}return o}function Ka(n,e,t){let r;return Array.isArray(n)?r=`${parseFloat(n[0].toFixed(ti))} + ${parseFloat(n[1].toFixed(ti))}j`:bo(n)?r=`'${n}'`:t==="bool"?r=Dd(n):r=parseFloat(n.toFixed(ti)).toString(),ra(r,e)}function Dd(n){return n===0?"false":"true"}function Ys(n,e,t,r,a,s=!0){const o=t==="complex64"?2:1,i=e[0],u=e.length;if(u===0){if(t==="complex64"){const y=Ya(n);return[Ka(y[0],0,t)]}return t==="bool"?[Dd(n[0])]:[n[0].toString()]}if(u===1){if(i>Tl){const y=Xa*o;let b=Array.from(n.slice(0,y)),x=Array.from(n.slice((i-Xa)*o,i*o));return t==="complex64"&&(b=Ya(b),x=Ya(x)),["["+b.map((T,$)=>Ka(T,a[$],t)).join(", ")+", ..., "+x.map((T,$)=>Ka(T,a[i-Xa+$],t)).join(", ")+"]"]}return["["+(t==="complex64"?Ya(n):Array.from(n)).map((y,b)=>Ka(y,a[b],t)).join(", ")+"]"]}const l=e.slice(1),c=r.slice(1),p=r[0]*o,h=[];if(i>Tl){for(let y=0;y<Xa;y++){const b=y*p,x=b+p;h.push(...Ys(n.slice(b,x),l,t,c,a,!1))}h.push("...");for(let y=i-Xa;y<i;y++){const b=y*p,x=b+p;h.push(...Ys(n.slice(b,x),l,t,c,a,y===i-1))}}else for(let y=0;y<i;y++){const b=y*p,x=b+p;h.push(...Ys(n.slice(b,x),l,t,c,a,y===i-1))}const d=u===2?",":"";h[0]="["+h[0]+d;for(let y=1;y<h.length-1;y++)h[y]=" "+h[y]+d;let m=`, 186`;for(let y=2;y<u;y++)m+=` 187`;return h[h.length-1]=" "+h[h.length-1]+"]"+(s?"":m),h}function Ya(n){const e=[];for(let t=0;t<n.length;t+=2)e.push([n[t],n[t+1]]);return e}/** 188 * @license 189 * Copyright 2017 Google LLC. All Rights Reserved. 190 * Licensed under the Apache License, Version 2.0 (the "License"); 191 * you may not use this file except in compliance with the License. 192 * You may obtain a copy of the License at 193 * 194 * http://www.apache.org/licenses/LICENSE-2.0 195 * 196 * Unless required by applicable law or agreed to in writing, software 197 * distributed under the License is distributed on an "AS IS" BASIS, 198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 199 * See the License for the specific language governing permissions and 200 * limitations under the License. 201 * ============================================================================= 202 */class ts{constructor(e,t,r){if(this.dtype=t,this.shape=e.slice(),this.size=ae(e),r!=null){const a=r.length;R(a===this.size,()=>`Length of values '${a}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=r||kt(t,this.size),this.strides=ot(e)}set(e,...t){t.length===0&&(t=[0]),R(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);const r=this.locToIndex(t);this.values[r]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(const a of e){if(a<0||a>=this.shape[t]){const s=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(s)}t++}let r=e[e.length-1];for(let a=0;a<e.length-1;++a)r+=this.strides[a]*e[a];return this.values[r]}locToIndex(e){if(this.rank===0)return 0;if(this.rank===1)return e[0];let t=e[e.length-1];for(let r=0;r<e.length-1;++r)t+=this.strides[r]*e[r];return t}indexToLoc(e){if(this.rank===0)return[];if(this.rank===1)return[e];const t=new Array(this.shape.length);for(let r=0;r<t.length-1;++r)t[r]=Math.floor(e/this.strides[r]),e-=t[r]*this.strides[r];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return sn().makeTensor(this.values,this.shape,this.dtype)}}let sn=null,ta=null;function rg(n){sn=n}function ag(n){ta=n}class Ge{constructor(e,t,r,a){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=ae(e),this.strides=ot(e),this.dataId=r,this.id=a,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return ta.buffer(this.shape,this.dtype,e)}bufferSync(){return ta.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return Ni(this.shape,e,this.dtype==="complex64")}arraySync(){return Ni(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();const e=sn().read(this.dataId);if(this.dtype==="string"){const t=await e;try{return t.map(r=>ca(r))}catch{throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),sn().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=sn().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>ca(t))}catch{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();const e=await sn().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(sn().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return ta.print(this,e)}clone(){return this.throwIfDisposed(),ta.clone(this)}toString(e=!1){const t=this.dataSync();return tg(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),ta.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),sn().makeVariable(this,e,t,r)}}Object.defineProperty(Ge,Symbol.hasInstance,{value:n=>!!n&&n.data!=null&&n.dataSync!=null&&n.throwIfDisposed!=null});function sg(){return Eu("Tensor",()=>Ge)}sg();class Mi extends Ge{constructor(e,t,r,a){super(e.shape,e.dtype,e.dataId,a),this.trainable=t,this.name=r}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(!qe(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);sn().disposeTensor(this),this.dataId=e.dataId,sn().incRef(this,null)}dispose(){sn().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(Mi,Symbol.hasInstance,{value:n=>n instanceof Ge&&n.assign!=null&&n.assign instanceof Function});/** 203 * @license 204 * Copyright 2017 Google LLC. All Rights Reserved. 205 * Licensed under the Apache License, Version 2.0 (the "License");
206 * you may not use this file except in compliance with the License. 207 * You may obtain a copy of the License at 208 * 209 * http://www.apache.org/licenses/LICENSE-2.0 210 * 211 * Unless required by applicable law or agreed to in writing, software 212 * distributed under the License is distributed on an "AS IS" BASIS, 213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 214 * See the License for the specific language governing permissions and 215 * limitations under the License. 216 * ============================================================================= 217 */var El;(function(n){n.R0="R0",n.R1="R1",n.R2="R2",n.R3="R3",n.R4="R4",n.R5="R5",n.R6="R6"})(El||(El={}));var Li;(function(n){n.float32="float32",n.int32="int32",n.bool="int32",n.complex64="complex64"})(Li||(Li={}));var Pi;(function(n){n.float32="float32",n.int32="int32",n.bool="bool",n.complex64="complex64"})(Pi||(Pi={}));var Bi;(function(n){n.float32="float32",n.int32="float32",n.bool="float32",n.complex64="complex64"})(Bi||(Bi={}));var Ui;(function(n){n.float32="complex64",n.int32="complex64",n.bool="complex64",n.complex64="complex64"})(Ui||(Ui={}));const og={float32:Bi,int32:Li,bool:Pi,complex64:Ui};function Sn(n,e){if(n==="string"||e==="string"){if(n==="string"&&e==="string")return"string";throw new Error(`Can not upcast ${n} with ${e}`)}return og[n][e]}function Ru(n){return Sn(n,"int32")}/** 218 * @license 219 * Copyright 2018 Google LLC. All Rights Reserved. 220 * Licensed under the Apache License, Version 2.0 (the "License"); 221 * you may not use this file except in compliance with the License. 222 * You may obtain a copy of the License at 223 * 224 * http://www.apache.org/licenses/LICENSE-2.0 225 * 226 * Unless required by applicable law or agreed to in writing, software 227 * distributed under the License is distributed on an "AS IS" BASIS, 228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 229 * See the License for the specific language governing permissions and 230 * limitations under the License. 231 * ============================================================================= 232 */function Ke(n,e){if(n.dtype===e.dtype)return[n,e];const t=Sn(n.dtype,e.dtype);return[n.cast(t),e.cast(t)]}function ig(n,e){R(n.dtype===e.dtype,()=>`The dtypes of the first(${n.dtype}) and second(${e.dtype}) input must match`)}function Md(n){const e=[];return Ld(n,e,new Set),e}function Ld(n,e,t){if(n==null)return;if(n instanceof Ge){e.push(n);return}if(!ug(n))return;const r=n;for(const a in r){const s=r[a];t.has(s)||(t.add(s),Ld(s,e,t))}}function ug(n){return Array.isArray(n)||typeof n=="object"}/** 233 * @license 234 * Copyright 2018 Google LLC. All Rights Reserved. 235 * Licensed under the Apache License, Version 2.0 (the "License"); 236 * you may not use this file except in compliance with the License. 237 * You may obtain a copy of the License at 238 * 239 * http://www.apache.org/licenses/LICENSE-2.0 240 * 241 * Unless required by applicable law or agreed to in writing, software 242 * distributed under the License is distributed on an "AS IS" BASIS, 243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 244 * See the License for the specific language governing permissions and 245 * limitations under the License. 246 * ============================================================================= 247 */function ni(n){return n.kernelName!=null}class Cl{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(e=>e.name)))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class pa{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Cl}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const r=e[t];if(await this.initializeBackend(r).success){await this.setBackend(r);return}}throw new Error("Could not initialize any backends, all backend initializations failed.")}
vendor: 14,678 bytes, lines 247-250
247get backend(){if(this.pendingBackendInit!=null)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(this.backendInstance==null){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry))if(e in this.registryFactory){const{asyncInit:t}=this.initializeBackend(e);if(t)return null}else return null;return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,r=1){return e in this.registryFactory?(ln(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:r},!0)}async setBackend(e){if(this.registryFactory[e]==null)throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,this.registry[e]==null){this.backendInstance=null;const{success:t,asyncInit:r}=this.initializeBackend(e);if(!(r?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new Y2(this.backendInstance),!0}setupRegisteredKernels(){wl(this.backendName).forEach(e=>{e.setupFunc!=null&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){wl(e).forEach(t=>{t.disposeFunc!=null&&t.disposeFunc(this.registry[e])})}initializeBackend(e){const t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const r=t.factory();if(r&&!(r instanceof Bc)&&typeof r.then=="function"){const a=++this.pendingBackendInitId,s=r.then(o=>a<this.pendingBackendInitId?!1:(this.registry[e]=o,this.pendingBackendInit=null,!0)).catch(o=>(a<this.pendingBackendInitId||(this.pendingBackendInit=null,ln(`Initialization of backend ${e} failed`),ln(o.stack||o.message)),!1));return this.pendingBackendInit=s,{success:s,asyncInit:!0}}else return this.registry[e]=r,{success:!0,asyncInit:!1}}catch(r){return ln(`Initialization of backend ${e} failed`),ln(r.stack||r.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&this.pendingBackendInit!=null&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(Object.keys(this.registryFactory).length===0)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const r=e[t],{success:a,asyncInit:s}=this.initializeBackend(r);if(s||a)return{name:r,asyncInit:s}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const r=this.state.tensorInfo.get(t),a=r.backend,s=this.readSync(t),o=a.refCount(t);a.disposeData(t,!0),r.backend=e,e.move(t,s,r.shape,r.dtype,o),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let r=null;if(t==null){if(typeof e!="function")throw new Error("Please provide a function to tidy()");t=e}else{if(typeof e!="string"&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if(typeof t!="function")throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}let a;return this.scopedRun(()=>this.startScope(r),()=>this.endScope(a),()=>(a=t(),a instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),a))}scopedRun(e,t,r){e();try{const a=r();return t(),a}catch(a){throw t(),a}}nextTensorId(){return pa.nextTensorId++}nextVariableId(){return pa.nextVariableId++}clone(e){const t=V.runKernel(Nu,{x:e}),r={x:e},a=o=>({x:()=>{const i="float32",u={x:o},l={dtype:i};return V.runKernel(Iu,u,l)}}),s=[];return this.addTapeNode(this.state.activeScope.name,r,[t],a,s,{}),t}runKernel(e,t,r){if(this.backendName==null&&this.backend,Fi(e,this.backendName)==null)throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:r})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,r){const a=this.backend.numDataIds();let s=0;r.forEach(u=>{s+=u.dtype==="complex64"?3:1});const o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=a-t-s-o;if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,r=[];const a=this.isTapeOn(),s=this.state.numBytes,o=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let u;const l=ni(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(ni(e)){const{kernelName:m,inputs:y,attrs:b}=e;this.backendName==null&&this.backend;const x=Fi(m,this.backendName);R(x!=null,()=>`Cannot find registered kernel '${m}' for backend '${this.backendName}'`),i=()=>{const T=this.backend.numDataIds();u=x.kernelFunc({inputs:y,attrs:b,backend:this.backend});const $=Array.isArray(u)?u:[u];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(m,T,$);const F=$.map(M=>M.rank!=null?M:this.makeTensorFromTensorInfo(M));if(a){const M=this.getTensorsForGradient(m,y,F);r=this.saveTensorsForBackwardMode(M)}return F}}else{const{forwardFunc:m}=e,y=b=>{a&&(r=b.map(x=>this.keep(this.clone(x))))};i=()=>{const b=this.backend.numDataIds();u=this.tidy(()=>m(this.backend,y));const x=Array.isArray(u)?u:[u];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,b,x),x}}const{inputs:c,attrs:p}=e,h=ni(e)?null:e.backwardsFunc;let d;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(d=this.profiler.profileKernel(l,c,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs)}),a&&this.addTapeNode(l,c,t,h,r,p),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-o,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map(m=>c[m]!=null?c[m].shape:null),outputShapes:t.map(m=>m.shape),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(u)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(t=>this.keep(this.clone(t)))}getTensorsForGradient(e,t,r){const a=vl(e);if(a!=null){const s=a.inputsToSave||[],o=a.outputsToSave||[];let i;a.saveAllInputs?(R(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(l=>t[l])):i=s.map(l=>t[l]);const u=r.filter((l,c)=>o[c]);return i.concat(u)}return[]}makeTensor(e,t,r,a){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");r=r||"float32",a=a||this.backend;let s=e;r==="string"&&bo(e[0])&&(s=e.map(u=>Nr(u)));const o=a.write(s,t,r),i=new Ge(t,r,o,this.nextTensorId());if(this.trackTensor(i,a),r==="string"){const u=this.state.tensorInfo.get(o),l=v2(s);this.state.numBytes+=l-u.bytes,u.bytes=l}return i}makeTensorFromDataId(e,t,r,a){r=r||"float32";const s={dataId:e,shape:t,dtype:r};return this.makeTensorFromTensorInfo(s,a)}makeTensorFromTensorInfo(e,t){const{dataId:r,shape:a,dtype:s}=e,o=new Ge(a,s,r,this.nextTensorId());return this.trackTensor(o,t),o}makeVariable(e,t=!0,r,a){r=r||this.nextVariableId().toString(),a!=null&&a!==e.dtype&&(e=e.cast(a));const s=new Mi(e,t,r,this.nextTensorId());if(this.state.registeredVariables[s.name]!=null)throw new Error(`Variable with name ${s.name} was already registered`);return this.state.registeredVariables[s.name]=s,this.incRef(s,this.backend),s}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let r=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(r=e.size*Ci(e.dtype)),this.state.numBytes+=r,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:r})),e instanceof Mi||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,e.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),e.dtype!=="complex64"&&e.dtype!=="string"){const r=e.size*Ci(e.dtype);this.state.numBytes-=r}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,e.reasons==null&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,r=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(a=>a.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-r;for(const a of this.state.activeProfile.kernels)a.kernelTimeMs=await a.kernelTimeMs,a.extraInfo=await a.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,r,a,s,o){const i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:r,saved:s},u=vl(e);u!=null&&(a=u.gradFunc),a!=null&&(i.gradient=l=>(l=l.map((c,p)=>{if(c==null){const h=r[p],d=er(h.size,h.dtype);return this.makeTensor(d,h.shape,h.dtype)}return c}),a(l.length>1?l:l[0],s,o))),this.state.activeTape.push(i)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=Md(e),r=new Set(t.map(s=>s.id));for(let s=0;s<this.state.activeScope.track.length;s++){const o=this.state.activeScope.track[s];!o.kept&&!r.has(o.id)&&o.dispose()}const a=this.state.scopeStack.pop();this.state.activeScope=this.state.scopeStack.length===0?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(s=>{!s.kept&&s.scopeId===a.id&&this.track(s)})}gradients(e,t,r,a=!1){if(R(t.length>0,()=>"gradients() received an empty list of xs."),r!=null&&r.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${r.dtype}'`);const s=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));R(s instanceof Ge,()=>"The result y returned by f() must be a tensor.");const o=Q2(this.state.activeTape,t,s);if(!a&&o.length===0&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",()=>{const i={};i[s.id]=r??lg(s.shape),eg(i,o,l=>this.tidy(l),cg);const u=t.map(l=>i[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(const c of l.saved)c.dispose()}),this.state.activeTape=null),{value:s,grads:u}})}customGrad(e){return R(xl(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{R(t.every(i=>i instanceof Ge),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let r;const a={};t.forEach((i,u)=>{a[u]=i});const s=(i,u)=>(r=e(...t,u),R(r.value instanceof Ge,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),R(xl(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),o=(i,u)=>{const l=r.gradFunc(i,u),c=Array.isArray(l)?l:[l];R(c.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),R(c.every(h=>h instanceof Ge),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");const p={};return c.forEach((h,d)=>{p[d]=()=>h}),p};return this.runKernelFunc({forwardFunc:s,backwardsFunc:o,inputs:a})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=an(),r=await this.backend.time(e);return r.wallMs=an()-t,r}track(e){return this.state.activeScope!=null&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Cl;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}pa.nextTensorId=0;pa.nextVariableId=0;function lg(n){const e=Vc(ae(n),"float32");return V.makeTensor(e,n,"float32")}function Pd(){const n=Gc();if(n._tfengine==null){const e=new k2(n);n._tfengine=new pa(e)}return I2(n._tfengine.ENV),rg(()=>n._tfengine),n._tfengine}const V=Pd();function cg(n,e){const t={a:n,b:e};return V.runKernel(Cu,t)}/** 248 * @license 249 * Copyright 2017 Google LLC. All Rights Reserved. 250 * Licensed under the Apache License, Version 2.0 (the "License");
251 * you may not use this file except in compliance with the License. 252 * You may obtain a copy of the License at 253 * 254 * http://www.apache.org/licenses/LICENSE-2.0 255 * 256 * Unless required by applicable law or agreed to in writing, software 257 * distributed under the License is distributed on an "AS IS" BASIS, 258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 259 * See the License for the specific language governing permissions and 260 * limitations under the License. 261 * ============================================================================= 262 */function pg(){return typeof navigator<"u"&&navigator!=null}function Bd(n){if(n||pg()){if(n||(n=navigator),n.product==="ReactNative")return!0;const e=n.userAgent||n.vendor||(typeof window<"u"?window.opera:"");if(!e){const t=n;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}return!1}function Ud(){return typeof window<"u"&&window.document!=null||typeof WorkerGlobalScope<"u"}/** 263 * @license 264 * Copyright 2019 Google LLC. All Rights Reserved. 265 * Licensed under the Apache License, Version 2.0 (the "License"); 266 * you may not use this file except in compliance with the License. 267 * You may obtain a copy of the License at 268 * 269 * http://www.apache.org/licenses/LICENSE-2.0 270 * 271 * Unless required by applicable law or agreed to in writing, software 272 * distributed under the License is distributed on an "AS IS" BASIS, 273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 274 * See the License for the specific language governing permissions and 275 * limitations under the License. 276 * ============================================================================= 277 */const $t=H();$t.registerFlag("DEBUG",()=>!1,n=>{n&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")});$t.registerFlag("IS_BROWSER",()=>Ud());$t.registerFlag("IS_NODE",()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u");$t.registerFlag("IS_CHROME",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));$t.registerFlag("PROD",()=>!1);$t.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>$t.getBool("DEBUG"));$t.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);$t.registerFlag("IS_TEST",()=>!1);$t.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);$t.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);$t.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);$t.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1);$t.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);/** 278 * @license 279 * Copyright 2018 Google LLC. All Rights Reserved. 280 * Licensed under the Apache License, Version 2.0 (the "License");
281 * you may not use this file except in compliance with the License. 282 * You may obtain a copy of the License at 283 * 284 * http://www.apache.org/licenses/LICENSE-2.0 285 * 286 * Unless required by applicable law or agreed to in writing, software 287 * distributed under the License is distributed on an "AS IS" BASIS, 288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 289 * See the License for the specific language governing permissions and 290 * limitations under the License. 291 * ============================================================================= 292 */function ar(n,e){let t=n;if(wn(n))return e==="string"?[]:[n.length];if(!Array.isArray(n))return[];const r=[];for(;Array.isArray(t)||wn(t)&&e!=="string";)r.push(t.length),t=t[0];return Array.isArray(n)&&H().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Vd(n,r,[]),r}function Vd(n,e,t){if(t=t||[],!Array.isArray(n)&&!wn(n)){R(e.length===0,()=>`Element arr[${t.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);return}R(e.length>0,()=>`Element arr[${t.join("][")}] should be a primitive, but is an array of ${n.length} elements`),R(n.length===e[0],()=>`Element arr[${t.join("][")}] should have ${e[0]} elements, but has ${n.length} elements`);const r=e.slice(1);for(let a=0;a<n.length;++a)Vd(n[a],r,t.concat(a))}function Il(n,e,t,r){if(n!=="string_or_numeric"){if(n==null)throw new Error("Expected dtype cannot be null.");if(n!=="numeric"&&n!==e||n==="numeric"&&e==="string")throw new Error(`Argument '${t}' passed to '${r}' must be ${n} tensor, but got ${e} tensor`)}}function N(n,e,t,r="numeric"){if(n instanceof Ge)return Il(r,n.dtype,e,t),n;let a=vo(n);if(a!=="string"&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),Il(r,a,e,t),n==null||!wn(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"){const i=n==null?"null":n.constructor.name;throw new Error(`Argument '${e}' passed to '${t}' must be a Tensor or TensorLike, but got '${i}'`)}const s=ar(n,a);!wn(n)&&!Array.isArray(n)&&(n=[n]);const o=a!=="string"?So(n,a):ia(n,[],!0);return V.makeTensor(o,s,a)}function no(n,e,t,r="numeric"){if(!Array.isArray(n))throw new Error(`Argument ${e} passed to ${t} must be a \`Tensor[]\` or \`TensorLike[]\``);return n.map((a,s)=>N(a,`${e}[${s}]`,t,r))}/** 293 * @license 294 * Copyright 2018 Google LLC. All Rights Reserved. 295 * Licensed under the Apache License, Version 2.0 (the "License"); 296 * you may not use this file except in compliance with the License. 297 * You may obtain a copy of the License at 298 * 299 * http://www.apache.org/licenses/LICENSE-2.0 300 * 301 * Unless required by applicable law or agreed to in writing, software 302 * distributed under the License is distributed on an "AS IS" BASIS, 303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 304 * See the License for the specific language governing permissions and 305 * limitations under the License. 306 * ============================================================================= 307 */const Wd="__op";function P(n){const e=Object.keys(n);if(e.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let t=e[0];const r=n[t];t.endsWith("_")&&(t=t.substring(0,t.length-1)),t=t+Wd;const a=(...s)=>{V.startScope(t);try{const o=r(...s);return la(o)&&console.error("Cannot return a Promise inside of tidy."),V.endScope(o),o}catch(o){throw V.endScope(null),o}};return Object.defineProperty(a,"name",{value:t,configurable:!0}),a}/** 308 * @license 309 * Copyright 2020 Google LLC. All Rights Reserved. 310 * Licensed under the Apache License, Version 2.0 (the "License"); 311 * you may not use this file except in compliance with the License. 312 * You may obtain a copy of the License at 313 * 314 * http://www.apache.org/licenses/LICENSE-2.0 315 * 316 * Unless required by applicable law or agreed to in writing, software 317 * distributed under the License is distributed on an "AS IS" BASIS, 318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 319 * See the License for the specific language governing permissions and 320 * limitations under the License. 321 * ============================================================================= 322 */function hg(n,e){const t=N(n,"real","complex"),r=N(e,"imag","complex");Lt(t.shape,r.shape,`real and imag shapes, ${t.shape} and ${r.shape}, must match in call to tf.complex().`);const a={real:t,imag:r};return V.runKernel(hp,a)}const tr=P({complex_:hg});/** 323 * @license 324 * Copyright 2018 Google LLC. All Rights Reserved. 325 * Licensed under the Apache License, Version 2.0 (the "License");
326 * you may not use this file except in compliance with the License. 327 * You may obtain a copy of the License at 328 * 329 * http://www.apache.org/licenses/LICENSE-2.0 330 * 331 * Unless required by applicable law or agreed to in writing, software 332 * distributed under the License is distributed on an "AS IS" BASIS, 333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 334 * See the License for the specific language governing permissions and 335 * limitations under the License. 336 * ============================================================================= 337 */function sr(n,e,t,r){if(r==null&&(r=vo(n)),r==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!wn(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string")throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(e!=null){Wc(e);const a=ae(e),s=ae(t);R(a===s,()=>`Based on the provided shape, [${e}], the tensor should have ${a} values but has ${s}`);for(let o=0;o<t.length;++o){const i=t[o],u=o===t.length-1?i!==ae(e.slice(o)):!0;R(t[o]===e[o]||!u,()=>`Error creating a new Tensor. Inferred shape (${t}) does not match the provided shape (${e}). `)}}return!wn(n)&&!Array.isArray(n)&&(n=[n]),e=e||t,n=r!=="string"?So(n,r):ia(n,[],!0),V.makeTensor(n,e,r)}/** 338 * @license 339 * Copyright 2018 Google LLC. All Rights Reserved. 340 * Licensed under the Apache License, Version 2.0 (the "License"); 341 * you may not use this file except in compliance with the License. 342 * You may obtain a copy of the License at 343 * 344 * http://www.apache.org/licenses/LICENSE-2.0 345 * 346 * Unless required by applicable law or agreed to in writing, software 347 * distributed under the License is distributed on an "AS IS" BASIS, 348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 349 * See the License for the specific language governing permissions and 350 * limitations under the License. 351 * ============================================================================= 352 */function vn(n,e,t){const r=ar(n,t);return sr(n,e,r,t)}/** 353 * @license 354 * Copyright 2018 Google LLC. All Rights Reserved. 355 * Licensed under the Apache License, Version 2.0 (the "License"); 356 * you may not use this file except in compliance with the License. 357 * You may obtain a copy of the License at 358 * 359 * http://www.apache.org/licenses/LICENSE-2.0 360 * 361 * Unless required by applicable law or agreed to in writing, software 362 * distributed under the License is distributed on an "AS IS" BASIS, 363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 364 * See the License for the specific language governing permissions and 365 * limitations under the License. 366 * ============================================================================= 367 */const Vi={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};/** 368 * @license 369 * Copyright 2018 Google LLC. All Rights Reserved. 370 * Licensed under the Apache License, Version 2.0 (the "License"); 371 * you may not use this file except in compliance with the License. 372 * You may obtain a copy of the License at 373 * 374 * http://www.apache.org/licenses/LICENSE-2.0 375 * 376 * Unless required by applicable law or agreed to in writing, software 377 * distributed under the License is distributed on an "AS IS" BASIS, 378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 379 * See the License for the specific language governing permissions and 380 * limitations under the License. 381 * ============================================================================= 382 */const ro=4;async function dg(n,e){const t=[],r=[],a=Array.isArray(n)?n.map(o=>o.name):Object.keys(n);for(let o=0;o<a.length;++o){const i=a[o],u=Array.isArray(n)?n[o].tensor:n[i];if(u.dtype!=="float32"&&u.dtype!=="int32"&&u.dtype!=="bool"&&u.dtype!=="string"&&u.dtype!=="complex64")throw new Error(`Unsupported dtype in weight '${i}': ${u.dtype}`);const l={name:i,shape:u.shape,dtype:u.dtype};if(u.dtype==="string"){const c=new Promise(async p=>{const h=await u.bytes(),d=h.reduce((b,x)=>b+x.length,0)+ro*h.length,m=new Uint8Array(d);let y=0;for(let b=0;b<h.length;b++){const x=h[b],T=new Uint8Array(new Uint32Array([x.length]).buffer);
382m.set(T,y),y+=ro,m.set(x,y),y+=x.length}p(m)});r.push(c)}else r.push(u.data());e!=null&&(l.group=e),t.push(l)}const s=await Promise.all(r);return{data:fg(s),specs:t}}function zd(n,e){const t={};let r,a=0;for(const s of e){const o=s.name,i=s.dtype,u=s.shape,l=ae(u);let c;if("quantization"in s){const p=s.quantization;if(p.dtype==="uint8"||p.dtype==="uint16"){if(!("min"in p&&"scale"in p))throw new Error(`Weight ${s.name} with quantization ${p.dtype} doesn't have corresponding metadata min and scale.`)}else if(p.dtype==="float16"){if(i!=="float32")throw new Error(`Weight ${s.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${i}.`)}else throw new Error(`Weight ${s.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);const h=Vi[p.dtype],d=n.slice(a,a+l*h),m=p.dtype==="uint8"?new Uint8Array(d):new Uint16Array(d);if(i==="float32")if(p.dtype==="uint8"||p.dtype==="uint16"){c=new Float32Array(m.length);for(let y=0;y<m.length;y++){const b=m[y];c[y]=b*p.scale+p.min}}else if(p.dtype==="float16")r===void 0&&(r=vg()),c=r(m);else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`);else if(i==="int32"){if(p.dtype!=="uint8"&&p.dtype!=="uint16")throw new Error(`Unsupported quantization type ${p.dtype} for weight type int32.`);c=new Int32Array(m.length);for(let y=0;y<m.length;y++){const b=m[y];c[y]=Math.round(b*p.scale+p.min)}}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);a+=l*h}else if(i==="string"){const p=ae(s.shape);c=[];for(let h=0;h<p;h++){const d=new Uint32Array(n.slice(a,a+ro))[0];a+=ro;const m=new Uint8Array(n.slice(a,a+d));c.push(m),a+=d}}else{const p=Vi[i],h=n.slice(a,a+l*p);if(i==="float32")c=new Float32Array(h);else if(i==="int32")c=new Int32Array(h);else if(i==="bool")c=new Uint8Array(h);else if(i==="complex64"){c=new Float32Array(h);const d=new Float32Array(c.length/2),m=new Float32Array(c.length/2);for(let x=0;x<d.length;x++)d[x]=c[x*2],m[x]=c[x*2+1];const y=vn(d,u,"float32"),b=vn(m,u,"float32");t[o]=tr(y,b),y.dispose(),b.dispose()}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);a+=l*p}i!=="complex64"&&(t[o]=vn(c,u,i))}return t}function fg(n){if(n===null)throw new Error(`Invalid input value: ${JSON.stringify(n)}`);let e=0;const t=[];n.forEach(s=>{if(e+=s.byteLength,t.push(s.byteLength===s.buffer.byteLength?s:new s.constructor(s)),!(s instanceof Float32Array||s instanceof Int32Array||s instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`)});const r=new Uint8Array(e);let a=0;return t.forEach(s=>{r.set(new Uint8Array(s.buffer),a),a+=s.byteLength}),r.buffer}const _u=typeof Buffer<"u"&&(typeof Blob>"u"||typeof atob>"u"||typeof btoa>"u");function Nl(n){return _u?Buffer.byteLength(n):new Blob([n]).size}function mg(n){if(_u)return Buffer.from(n).toString("base64");const e=new Uint8Array(n);let t="";for(let r=0,a=e.length;r<a;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function gg(n){if(_u){const r=Buffer.from(n,"base64");return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t.set([e.charCodeAt(r)],r);return t.buffer}function Au(n){if(n.length===1)return n[0];let e=0;n.forEach(a=>{e+=a.byteLength});const t=new Uint8Array(e);let r=0;return n.forEach(a=>{t.set(new Uint8Array(a),r),r+=a.byteLength}),t.buffer}function $l(n){for(n=n.trim();n.endsWith("/");)n=n.slice(0,n.length-1);const e=n.split("/");return e[e.length-1]}function Gd(n,e){const t={modelTopology:n.modelTopology,format:n.format,generatedBy:n.generatedBy,convertedBy:n.convertedBy,weightsManifest:e};return n.signature!=null&&(t.signature=n.signature),n.userDefinedMetadata!=null&&(t.userDefinedMetadata=n.userDefinedMetadata),n.modelInitializer!=null&&(t.modelInitializer=n.modelInitializer),n.trainingConfig!=null&&(t.trainingConfig=n.trainingConfig),t}function jd(n,e,t){const r={modelTopology:n.modelTopology,format:n.format,generatedBy:n.generatedBy,convertedBy:n.convertedBy};if(n.trainingConfig!=null&&(r.trainingConfig=n.trainingConfig),n.weightsManifest!=null){if(!e)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!t)throw new Error("modelJSON has weightsManifest but weightData is null");r.weightSpecs=e,r.weightData=t}return n.signature!=null&&(r.signature=n.signature),n.userDefinedMetadata!=null&&(r.userDefinedMetadata=n.userDefinedMetadata),n.modelInitializer!=null&&(r.modelInitializer=n.modelInitializer),r}async function Ou(n,e){let t,r;return n.weightsManifest!=null&&([t,r]=await e(n.weightsManifest)),jd(n,t,r)}function hs(n){if(n.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:n.modelTopology==null?0:Nl(JSON.stringify(n.modelTopology)),weightSpecsBytes:n.weightSpecs==null?0:Nl(JSON.stringify(n.weightSpecs)),weightDataBytes:n.weightData==null?0:n.weightData.byteLength}}function Hd(n){const e=[];for(const t of n)e.push(...t.weights);return e}function yg(){const n=t=>{let r=t<<13,a=0;for(;(r&8388608)===0;)a-=8388608,r<<=1;return r&=-8388609,a+=947912704,r|a},e=new Uint32Array(2048);e[0]=0;for(let t=1;t<1024;t++)e[t]=n(t);for(let t=1024;t<2048;t++)e[t]=939524096+(t-1024<<13);return e}function xg(){const n=new Uint32Array(64);
382n[0]=0,n[31]=1199570944,n[32]=2147483648,n[63]=3347054592;for(let e=1;e<31;e++)n[e]=e<<23;for(let e=33;e<63;e++)n[e]=2147483648+(e-32<<23);return n}function bg(){const n=new Uint32Array(64);for(let e=0;e<64;e++)n[e]=1024;return n[0]=n[32]=0,n}function vg(){const n=yg(),e=xg(),t=bg();return r=>{const a=new ArrayBuffer(4*r.length),s=new Uint32Array(a);for(let o=0;o<r.length;o++){const i=r[o],u=n[t[i>>10]+(i&1023)]+e[i>>10];s[o]=u}return new Float32Array(a)}}/** 383 * @license 384 * Copyright 2018 Google LLC. All Rights Reserved. 385 * Licensed under the Apache License, Version 2.0 (the "License"); 386 * you may not use this file except in compliance with the License. 387 * You may obtain a copy of the License at 388 * 389 * http://www.apache.org/licenses/LICENSE-2.0 390 * 391 * Unless required by applicable law or agreed to in writing, software 392 * distributed under the License is distributed on an "AS IS" BASIS, 393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 394 * See the License for the specific language governing permissions and 395 * limitations under the License. 396 * ============================================================================= 397 */class ze{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return ze.instance==null&&(ze.instance=new ze),ze.instance}static registerSaveRouter(e){ze.getInstance().saveRouters.push(e)}static registerLoadRouter(e){ze.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return ze.getHandlers(e,"save")}static getLoadHandlers(e,t){return ze.getHandlers(e,"load",t)}static getHandlers(e,t,r){const a=[];return(t==="load"?ze.getInstance().loadRouters:ze.getInstance().saveRouters).forEach(s=>{const o=s(e,r);o!==null&&a.push(o)}),a}}const wg=n=>ze.registerSaveRouter(n),Sg=n=>ze.registerLoadRouter(n),kg=n=>ze.getSaveHandlers(n),Tg=(n,e)=>ze.getLoadHandlers(n,e);/** 398 * @license 399 * Copyright 2018 Google LLC. All Rights Reserved. 400 * Licensed under the Apache License, Version 2.0 (the "License"); 401 * you may not use this file except in compliance with the License. 402 * You may obtain a copy of the License at 403 * 404 * http://www.apache.org/licenses/LICENSE-2.0 405 * 406 * Unless required by applicable law or agreed to in writing, software 407 * distributed under the License is distributed on an "AS IS" BASIS, 408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 409 * See the License for the specific language governing permissions and 410 * limitations under the License. 411 * ============================================================================= 412 */const Wi="tensorflowjs",zi=1,Er="models_store",Kn="model_info_store";function Xd(){if(!H().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const n=typeof window>"u"?self:window,e=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB||n.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function Gi(n){const e=n.result;e.createObjectStore(Er,{keyPath:"modelPath"}),e.createObjectStore(Kn,{keyPath:"modelPath"})}class _r{constructor(e){if(this.indexedDB=Xd(),e==null||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((r,a)=>{const s=this.indexedDB.open(Wi,zi);s.onupgradeneeded=()=>Gi(s),s.onsuccess=()=>{const o=s.result;if(t==null){const i=o.transaction(Er,"readonly"),u=i.objectStore(Er).get(this.modelPath);u.onsuccess=()=>{if(u.result==null)return o.close(),a(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));r(u.result.modelArtifacts)},u.onerror=l=>(o.close(),a(u.error)),i.oncomplete=()=>o.close()}else{const i=hs(t),u=o.transaction(Kn,"readwrite");let l=u.objectStore(Kn);const c=l.put({modelPath:this.modelPath,modelArtifactsInfo:i});let p;c.onsuccess=()=>{p=o.transaction(Er,"readwrite");const h=p.objectStore(Er).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});h.onsuccess=()=>r({modelArtifactsInfo:i}),h.onerror=d=>{l=u.objectStore(Kn);const m=l.delete(this.modelPath);m.onsuccess=()=>(o.close(),a(h.error)),m.onerror=y=>(o.close(),a(h.error))}},c.onerror=h=>(o.close(),a(c.error)),u.oncomplete=()=>{p==null?o.close():p.oncomplete=()=>o.close()}}},s.onerror=o=>
vendor: 5,523 bytes, lines 412-427
412a(s.error)})}}_r.URL_SCHEME="indexeddb://";const qd=n=>H().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(_r.URL_SCHEME)?Eg(n.slice(_r.URL_SCHEME.length)):null;ze.registerSaveRouter(qd);ze.registerLoadRouter(qd);function Eg(n){return new _r(n)}function Cg(n){return n.startsWith(_r.URL_SCHEME)?n.slice(_r.URL_SCHEME.length):n}class Ig{constructor(){this.indexedDB=Xd()}async listModels(){return new Promise((e,t)=>{const r=this.indexedDB.open(Wi,zi);r.onupgradeneeded=()=>Gi(r),r.onsuccess=()=>{const a=r.result,s=a.transaction(Kn,"readonly"),o=s.objectStore(Kn).getAll();o.onsuccess=()=>{const i={};for(const u of o.result)i[u.modelPath]=u.modelArtifactsInfo;e(i)},o.onerror=i=>(a.close(),t(o.error)),s.oncomplete=()=>a.close()},r.onerror=a=>t(r.error)})}async removeModel(e){return e=Cg(e),new Promise((t,r)=>{const a=this.indexedDB.open(Wi,zi);a.onupgradeneeded=()=>Gi(a),a.onsuccess=()=>{const s=a.result,o=s.transaction(Kn,"readwrite"),i=o.objectStore(Kn),u=i.get(e);let l;u.onsuccess=()=>{if(u.result==null)return s.close(),r(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const c=i.delete(e),p=()=>{l=s.transaction(Er,"readwrite");const h=l.objectStore(Er).delete(e);h.onsuccess=()=>t(u.result.modelArtifactsInfo),h.onerror=d=>r(u.error)};c.onsuccess=p,c.onerror=h=>(p(),s.close(),r(u.error))}},u.onerror=c=>(s.close(),r(u.error)),o.oncomplete=()=>{l==null?s.close():l.oncomplete=()=>s.close()}},a.onerror=s=>r(a.error)})}}/** 413 * @license 414 * Copyright 2018 Google LLC. All Rights Reserved. 415 * Licensed under the Apache License, Version 2.0 (the "License"); 416 * you may not use this file except in compliance with the License. 417 * You may obtain a copy of the License at 418 * 419 * http://www.apache.org/licenses/LICENSE-2.0 420 * 421 * Unless required by applicable law or agreed to in writing, software 422 * distributed under the License is distributed on an "AS IS" BASIS, 423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 424 * See the License for the specific language governing permissions and 425 * limitations under the License. 426 * ============================================================================= 427 */const Nn="/",na="tensorflowjs_models",Kd="info",Ng="model_topology",$g="weight_specs",Rg="weight_data",_g="model_metadata";function Yd(n){return{info:[na,n,Kd].join(Nn),topology:[na,n,Ng].join(Nn),weightSpecs:[na,n,$g].join(Nn),weightData:[na,n,Rg].join(Nn),modelMetadata:[na,n,_g].join(Nn)}}function Zd(n){for(const e of Object.values(n))window.localStorage.removeItem(e)}function Ag(n){const e=n.split(Nn);if(e.length<3)throw new Error(`Invalid key format: ${n}`);return e.slice(1,e.length-1).join(Nn)}function Og(n){return n.startsWith(Ar.URL_SCHEME)?n.slice(Ar.URL_SCHEME.length):n}class Ar{constructor(e){if(!H().getBool("IS_BROWSER")||typeof window>"u"||typeof window.localStorage>"u")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=Yd(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),r=JSON.stringify(e.weightSpecs),a=hs(e);try{this.LS.setItem(this.keys.info,JSON.stringify(a)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,mg(e.weightData));const s={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:e.signature!=null?e.signature:void 0,userDefinedMetadata:e.userDefinedMetadata!=null?e.userDefinedMetadata:void 0,modelInitializer:e.modelInitializer!=null?e.modelInitializer:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:a}}catch{throw Zd(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${a.modelTopologyBytes}, weightSpecsBytes=${a.weightSpecsBytes}, weightDataBytes=${a.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},r=JSON.parse(this.LS.getItem(this.keys.topology));if(r==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=r;const a=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(a==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=a;const s=this.LS.getItem(this.keys.modelMetadata);if(s!=null){const i=JSON.parse(s);t.format=i.format,t.generatedBy=i.generatedBy,t.convertedBy=i.convertedBy,i.signature!=null&&(t.signature=i.signature),i.userDefinedMetadata!=null&&(t.userDefinedMetadata=i.userDefinedMetadata),i.modelInitializer!=null&&(t.modelInitializer=i.modelInitializer),i.trainingConfig!=null&&(t.trainingConfig=i.trainingConfig)}const o=this.LS.getItem(this.keys.weightData);if(o==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=gg(o),t}}Ar.URL_SCHEME="localstorage://";const Jd=n=>
427H().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(Ar.URL_SCHEME)?Fg(n.slice(Ar.URL_SCHEME.length)):null;ze.registerSaveRouter(Jd);ze.registerLoadRouter(Jd);function Fg(n){return new Ar(n)}class Dg{constructor(){R(H().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),R(typeof window>"u"||typeof window.localStorage<"u",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},t=na+Nn,r=Nn+Kd;for(let a=0;a<this.LS.length;++a){const s=this.LS.key(a);if(s.startsWith(t)&&s.endsWith(r)){const o=Ag(s);e[o]=JSON.parse(this.LS.getItem(s))}}return e}async removeModel(e){e=Og(e);const t=Yd(e);if(this.LS.getItem(t.info)==null)throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(t.info));return Zd(t),r}}/** 428 * @license 429 * Copyright 2018 Google LLC. All Rights Reserved. 430 * Licensed under the Apache License, Version 2.0 (the "License"); 431 * you may not use this file except in compliance with the License. 432 * You may obtain a copy of the License at 433 * 434 * http://www.apache.org/licenses/LICENSE-2.0 435 * 436 * Unless required by applicable law or agreed to in writing, software 437 * distributed under the License is distributed on an "AS IS" BASIS, 438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 439 * See the License for the specific language governing permissions and 440 * limitations under the License. 441 * ============================================================================= 442 */const aa="://";class ht{constructor(){this.managers={}}static getInstance(){return ht.instance==null&&(ht.instance=new ht),ht.instance}static registerManager(e,t){R(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(aa)&&(e=e.slice(0,e.indexOf(aa))),R(e.length>0,()=>"scheme must not be an empty string.");const r=ht.getInstance();R(r.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),r.managers[e]=t}static getManager(e){const t=ht.getInstance().managers[e];if(t==null)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(ht.getInstance().managers)}}function Zs(n){if(n.indexOf(aa)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ht.getSchemes().join(",")}`);return{scheme:n.split(aa)[0],path:n.split(aa)[1]}}async function Qd(n,e,t=!1){R(n!==e,()=>`Old path and new path are the same: '${n}'`);const r=ze.getLoadHandlers(n);R(r.length>0,()=>`Copying failed because no load handler is found for source URL ${n}.`),R(r.length<2,()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${n}.`);const a=r[0],s=ze.getSaveHandlers(e);R(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${e}.`),R(s.length<2,()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${e}.`);const o=s[0],i=Zs(n).scheme,u=Zs(n).path,l=i===Zs(n).scheme,c=await a.load();t&&l&&await ht.getManager(i).removeModel(u);const p=await o.save(c);return t&&!l&&await ht.getManager(i).removeModel(u),p.modelArtifactsInfo}async function Mg(){const n=ht.getSchemes(),e={};for(const t of n){const r=await ht.getManager(t).listModels();for(const a in r){const s=t+aa+a;e[s]=r[a]}}return e}async function Lg(n){const e=Zs(n);return ht.getManager(e.scheme).removeModel(e.path)}async function Pg(n,e){return Qd(n,e,!1)}async function Bg(n,e){return Qd(n,e,!0)}/** 443 * @license 444 * Copyright 2019 Google LLC. All Rights Reserved. 445 * Licensed under the Apache License, Version 2.0 (the "License"); 446 * you may not use this file except in compliance with the License. 447 * You may obtain a copy of the License at 448 * 449 * http://www.apache.org/licenses/LICENSE-2.0 450 * 451 * Unless required by applicable law or agreed to in writing, software 452 * distributed under the License is distributed on an "AS IS" BASIS, 453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 454 * See the License for the specific language governing permissions and 455 * limitations under the License. 456 * ============================================================================= 457 */class Ug{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){if(!window||!H().getBool("USE_SETTIMEOUTCUSTOM")){setTimeout(e,t);return}this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",r=>{if(r.source===window&&r.data.name===this.messageName){r.stopPropagation();const a=this.functionRefs[r.data.index];a(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))}}
vendor: 4,208 bytes, lines 457-520
457if(H().get("IS_BROWSER")){H().setPlatform("browser",new Ug);try{ht.registerManager(Ar.URL_SCHEME,new Dg)}catch{}try{ht.registerManager(_r.URL_SCHEME,new Ig)}catch{}}/** 458 * @license 459 * Copyright 2019 Google LLC. All Rights Reserved. 460 * Licensed under the Apache License, Version 2.0 (the "License"); 461 * you may not use this file except in compliance with the License. 462 * You may obtain a copy of the License at 463 * 464 * http://www.apache.org/licenses/LICENSE-2.0 465 * 466 * Unless required by applicable law or agreed to in writing, software 467 * distributed under the License is distributed on an "AS IS" BASIS, 468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 469 * See the License for the specific language governing permissions and 470 * limitations under the License. 471 * ============================================================================= 472 */const Vg={importFetch:()=>require("node-fetch")};let ri;class Wg{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return H().global.fetch!=null?H().global.fetch(e,t):(ri==null&&(ri=Vg.importFetch()),ri(e,t))}now(){const e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return e.length===0?"":new this.util.TextDecoder(t).decode(e)}}H().get("IS_NODE")&&!H().get("IS_BROWSER")&&H().setPlatform("node",new Wg);/** 473 * @license 474 * Copyright 2020 Google Inc. All Rights Reserved. 475 * Licensed under the Apache License, Version 2.0 (the "License"); 476 * you may not use this file except in compliance with the License. 477 * You may obtain a copy of the License at 478 * 479 * http://www.apache.org/licenses/LICENSE-2.0 480 * 481 * Unless required by applicable law or agreed to in writing, software 482 * distributed under the License is distributed on an "AS IS" BASIS, 483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 484 * See the License for the specific language governing permissions and 485 * limitations under the License. 486 * ============================================================================= 487 */function He(n,e="float32",t){return e=e||"float32",Wc(n),new ts(n,e,t)}/** 488 * @license 489 * Copyright 2020 Google Inc. All Rights Reserved. 490 * Licensed under the Apache License, Version 2.0 (the "License"); 491 * you may not use this file except in compliance with the License. 492 * You may obtain a copy of the License at 493 * 494 * http://www.apache.org/licenses/LICENSE-2.0 495 * 496 * Unless required by applicable law or agreed to in writing, software 497 * distributed under the License is distributed on an "AS IS" BASIS, 498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 499 * See the License for the specific language governing permissions and 500 * limitations under the License. 501 * ============================================================================= 502 */function zg(n,e){const t=N(n,"x","cast");if(!x2(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if(e==="string"&&t.dtype!=="string"||e!=="string"&&t.dtype==="string")throw new Error("Only strings can be casted to strings");const r={x:t},a={dtype:e};return V.runKernel(Iu,r,a)}const je=P({cast_:zg});/** 503 * @license 504 * Copyright 2020 Google LLC. All Rights Reserved. 505 * Licensed under the Apache License, Version 2.0 (the "License"); 506 * you may not use this file except in compliance with the License. 507 * You may obtain a copy of the License at 508 * 509 * http://www.apache.org/licenses/LICENSE-2.0 510 * 511 * Unless required by applicable law or agreed to in writing, software 512 * distributed under the License is distributed on an "AS IS" BASIS, 513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 514 * See the License for the specific language governing permissions and 515 * limitations under the License. 516 * ============================================================================= 517 */function Gg(n){const e={x:N(n,"x","clone","string_or_numeric")};return V.runKernel(Nu,e)}const Jn=P({clone_:Gg});/** 518 * @license 519 * Copyright 2020 Google Inc. All Rights Reserved. 520 * Licensed under the Apache License, Version 2.0 (the "License");
521 * you may not use this file except in compliance with the License. 522 * You may obtain a copy of the License at 523 * 524 * http://www.apache.org/licenses/LICENSE-2.0 525 * 526 * Unless required by applicable law or agreed to in writing, software 527 * distributed under the License is distributed on an "AS IS" BASIS, 528 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 529 * See the License for the specific language governing permissions and 530 * limitations under the License. 531 * ============================================================================= 532 */function ef(n,e=!1){console.log(n.toString(e))}/** 533 * @license 534 * Copyright 2020 Google Inc. All Rights Reserved. 535 * Licensed under the Apache License, Version 2.0 (the "License"); 536 * you may not use this file except in compliance with the License. 537 * You may obtain a copy of the License at 538 * 539 * http://www.apache.org/licenses/LICENSE-2.0 540 * 541 * Unless required by applicable law or agreed to in writing, software 542 * distributed under the License is distributed on an "AS IS" BASIS, 543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 544 * See the License for the specific language governing permissions and 545 * limitations under the License. 546 * ============================================================================= 547 */Pd();const jg={buffer:He,cast:je,clone:Jn,print:ef};ag(jg);/** 548 * @license 549 * Copyright 2018 Google LLC. All Rights Reserved. 550 * Licensed under the Apache License, Version 2.0 (the "License"); 551 * you may not use this file except in compliance with the License. 552 * You may obtain a copy of the License at 553 * 554 * http://www.apache.org/licenses/LICENSE-2.0 555 * 556 * Unless required by applicable law or agreed to in writing, software 557 * distributed under the License is distributed on an "AS IS" BASIS, 558 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 559 * See the License for the specific language governing permissions and 560 * limitations under the License. 561 * ============================================================================= 562 */const Hg="model",Xg=".json",qg=".weights.bin";function Rl(n){return new Promise(e=>setTimeout(e)).then(n)}class Or{constructor(e){if(!H().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Or.URL_SCHEME)&&(e=e.slice(Or.URL_SCHEME.length)),(e==null||e.length===0)&&(e=Hg),this.modelJsonFileName=e+Xg,this.weightDataFileName=e+qg}async save(e){if(typeof document>"u")throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const r=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],a=Gd(e,r),s=window.URL.createObjectURL(new Blob([JSON.stringify(a)],{type:"application/json"})),o=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(o.download=this.modelJsonFileName,o.href=s,await Rl(()=>
562o.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){const i=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;i.download=this.weightDataFileName,i.href=t,await Rl(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:hs(e)}}}}Or.URL_SCHEME="downloads://";class Kg{constructor(e){if(e==null||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{const r=new FileReader;r.onload=a=>{const s=JSON.parse(a.target.result),o=s.modelTopology;if(o==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(s.weightsManifest==null){t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){e({modelTopology:o});return}const i=Ou(s,u=>this.loadWeights(u));e(i)},r.onerror=a=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),r.readAsText(this.jsonFile)})}loadWeights(e){const t=[],r=[];for(const o of e)t.push(...o.weights),r.push(...o.paths);const a=this.checkManifestAndWeightFiles(e),s=r.map(o=>this.loadWeightsFile(o,a[o]));return Promise.all(s).then(o=>[t,Au(o)])}loadWeightsFile(e,t){return new Promise((r,a)=>{const s=new FileReader;s.onload=o=>{const i=o.target.result;r(i)},s.onerror=o=>a(`Failed to weights data from file of path '${e}'.`),s.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){const t=[],r=this.weightsFiles.map(s=>$l(s.name)),a={};for(const s of e)s.paths.forEach(o=>{const i=$l(o);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),r.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);a[o]=this.weightsFiles[r.indexOf(i)]});if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return a}}const Yg=n=>H().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(Or.URL_SCHEME)?Zg(n.slice(Or.URL_SCHEME.length)):null;ze.registerSaveRouter(Yg);function Zg(n="model"){return new Or(n)}function Jg(n){return new Kg(n)}/** 563 * @license 564 * Copyright 2019 Google LLC. All Rights Reserved. 565 * Licensed under the Apache License, Version 2.0 (the "License"); 566 * you may not use this file except in compliance with the License. 567 * You may obtain a copy of the License at 568 * 569 * http://www.apache.org/licenses/LICENSE-2.0 570 * 571 * Unless required by applicable law or agreed to in writing, software 572 * distributed under the License is distributed on an "AS IS" BASIS, 573 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 574 * See the License for the specific language governing permissions and 575 * limitations under the License. 576 * ============================================================================= 577 */function _l(n,e,t,r){o(n),t=t??0,r=r??1,i(t,r);let a=0;const s=u=>(u.then(l=>{const c=t+ ++a/n.length*(r-t);return e(c),l}),u);function o(u){R(u!=null&&Array.isArray(u)&&u.length>0,()=>"promises must be a none empty array")}function i(u,l){R(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${u}`),R(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${l}`),R(l>=u,()=>`startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`)}return Promise.all(n.map(s))}/** 578 * @license 579 * Copyright 2018 Google LLC. All Rights Reserved. 580 * Licensed under the Apache License, Version 2.0 (the "License"); 581 * you may not use this file except in compliance with the License. 582 * You may obtain a copy of the License at 583 * 584 * http://www.apache.org/licenses/LICENSE-2.0 585 * 586 * Unless required by applicable law or agreed to in writing, software 587 * distributed under the License is distributed on an "AS IS" BASIS, 588 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 589 * See the License for the specific language governing permissions and 590 * limitations under the License. 591 * ============================================================================= 592 */async function tf(n,e){e==null&&(e={});const t=e.fetchFunc==null?H().platform.fetch:e.fetchFunc,r=n.map(s=>t(s,e.requestInit,{isBinary:!0})),a=(e.onProgress==null?await Promise.all(r):await _l(r,e.onProgress,0,.5)).map(s=>s.arrayBuffer());return e.onProgress==null?await Promise.all(a):await _l(a,e.onProgress,.5,1)}async function Qg(n,e="",t,r){return nf(a=>tf(a,{requestInit:r}))(n,e,t)}function nf(n){return async(e,t="",r)=>{const a=e.map(()=>!1),s={},o=r!=null?r.map(()=>!1):[],i=[];if(e.forEach((d,m)=>{let y=0;
592d.weights.forEach(b=>{const x="quantization"in b?b.quantization.dtype:b.dtype,T=Vi[x]*ae(b.shape),$=()=>{a[m]=!0,s[m]==null&&(s[m]=[]),s[m].push({manifestEntry:b,groupOffset:y,sizeBytes:T})};r!=null?r.forEach((F,M)=>{F===b.name&&($(),o[M]=!0)}):$(),i.push(b.name),y+=T})}),!o.every(d=>d)){const d=r.filter((m,y)=>!o[y]);throw new Error(`Could not find weights in manifest with names: ${d.join(", ")}. 593Manifest JSON has weights with names: ${i.join(", ")}.`)}const u=a.reduce((d,m,y)=>(m&&d.push(y),d),[]),l=[];u.forEach(d=>{e[d].paths.forEach(m=>{const y=t+(t.endsWith("/")?"":"/")+m;l.push(y)})});const c=await n(l),p={};let h=0;return u.forEach(d=>{const m=e[d].paths.length;let y=0;for(let $=0;$<m;$++)y+=c[h+$].byteLength;const b=new ArrayBuffer(y),x=new Uint8Array(b);let T=0;for(let $=0;$<m;$++){const F=new Uint8Array(c[h+$]);x.set(F,T),T+=F.byteLength}s[d].forEach($=>{const F=b.slice($.groupOffset,$.groupOffset+$.sizeBytes),M=zd(F,[$.manifestEntry]);for(const U in M)p[U]=M[U]}),h+=m}),p}}/** 594 * @license 595 * Copyright 2018 Google LLC. All Rights Reserved. 596 * Licensed under the Apache License, Version 2.0 (the "License"); 597 * you may not use this file except in compliance with the License. 598 * You may obtain a copy of the License at 599 * 600 * http://www.apache.org/licenses/LICENSE-2.0 601 * 602 * Unless required by applicable law or agreed to in writing, software 603 * distributed under the License is distributed on an "AS IS" BASIS, 604 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 605 * See the License for the specific language governing permissions and 606 * limitations under the License. 607 * ============================================================================= 608 */const e0="application/octet-stream",t0="application/json";class Fu{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?(R(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=H().platform.fetch,R(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&R(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.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const r=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],a=Gd(e,r);t.body.append("model.json",new Blob([JSON.stringify(a)],{type:t0}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:e0}),"model.weights.bin");const s=await this.fetch(this.path,t);if(s.ok)return{modelArtifactsInfo:hs(e),responses:[s]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${s.status}.`)}async load(){const 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{let s=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?s+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":s+=" Please make sure the server is serving valid JSON for this request.",new Error(s)}const r=t.modelTopology,a=t.weightsManifest;if(r==null&&a==null)throw new Error(`The JSON from HTTP path ${this.path}
608 contains neither model topology or manifest for weights.`);return Ou(t,s=>this.loadWeights(s))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[r,a]=n0(t),s=this.weightPathPrefix||r,o=Hd(e),i=[],u=[];for(const c of e)for(const p of c.paths)this.weightUrlConverter!=null?u.push(this.weightUrlConverter(p)):i.push(s+p+a);this.weightUrlConverter&&i.push(...await Promise.all(u));const l=await tf(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[o,Au(l)]}}Fu.URL_SCHEME_REGEX=/^https?:\/\//;function n0(n){const e=n.lastIndexOf("/"),t=n.lastIndexOf("?"),r=n.substring(0,e),a=t>e?n.substring(t):"";return[r+"/",a]}function ji(n){return n.match(Fu.URL_SCHEME_REGEX)!=null}const rf=(n,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let t=!0;if(Array.isArray(n)?t=n.every(r=>ji(r)):t=ji(n),t)return Du(n,e)}return null};ze.registerSaveRouter(rf);ze.registerLoadRouter(rf);function Du(n,e){return new Fu(n,e)}function r0(n,e){return Du(n,e)}/** 609 * @license 610 * Copyright 2018 Google LLC. All Rights Reserved. 611 * Licensed under the Apache License, Version 2.0 (the "License"); 612 * you may not use this file except in compliance with the License. 613 * You may obtain a copy of the License at 614 * 615 * http://www.apache.org/licenses/LICENSE-2.0 616 * 617 * Unless required by applicable law or agreed to in writing, software 618 * distributed under the License is distributed on an "AS IS" BASIS, 619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 620 * See the License for the specific language governing permissions and 621 * limitations under the License. 622 * ============================================================================= 623 */class ai{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class af{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class a0{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function s0(n,e,t,r){const a=arguments;return new a0(sf(...a))}function sf(n,e,t,r){return arguments.length===1?n.modelTopology!=null||n.weightSpecs!=null?new ai(n):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new ai({modelTopology:n})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new ai({modelTopology:n,weightSpecs:e,weightData:t,trainingConfig:r}))}function o0(n){return new af(n)}function i0(n){return new af(n)}/** 624 * @license 625 * Copyright 2018 Google LLC. All Rights Reserved. 626 * Licensed under the Apache License, Version 2.0 (the "License"); 627 * you may not use this file except in compliance with the License. 628 * You may obtain a copy of the License at 629 * 630 * http://www.apache.org/licenses/LICENSE-2.0 631 * 632 * Unless required by applicable law or agreed to in writing, software 633 * distributed under the License is distributed on an "AS IS" BASIS, 634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 635 * See the License for the specific language governing permissions and 636 * limitations under the License. 637 * ============================================================================= 638 */const of=Object.freeze(Object.defineProperty({__proto__:null,browserFiles:Jg,browserHTTPRequest:r0,concatenateArrayBuffers:Au,copyModel:Pg,decodeWeights:zd,encodeWeights:dg,fromMemory:s0,fromMemorySync:sf,getLoadHandlers:Tg,getModelArtifactsForJSON:Ou,getModelArtifactsForJSONSync:jd,getModelArtifactsInfoForJSON:hs,getSaveHandlers:kg,getWeightSpecs:Hd,http:Du,isHTTPScheme:ji,listModels:Mg,loadWeights:Qg,moveModel:Bg,registerLoadRouter:Sg,registerSaveRouter:wg,removeModel:Lg,weightsLoaderFactory:nf,withSaveHandler:o0,withSaveHandlerSync:i0},Symbol.toStringTag,{value:"Module"}));/** 639 * @license 640 * Copyright 2020 Google LLC. All Rights Reserved. 641 * Licensed under the Apache License, Version 2.0 (the "License");
642 * you may not use this file except in compliance with the License. 643 * You may obtain a copy of the License at 644 * 645 * http://www.apache.org/licenses/LICENSE-2.0 646 * 647 * Unless required by applicable law or agreed to in writing, software 648 * distributed under the License is distributed on an "AS IS" BASIS, 649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 650 * See the License for the specific language governing permissions and 651 * limitations under the License. 652 * ============================================================================= 653 */function u0(n,e,t=!1,r=!1){let a=N(n,"a","matMul"),s=N(e,"b","matMul");[a,s]=Ke(a,s);const o={a,b:s},i={transposeA:t,transposeB:r};return V.runKernel(op,o,i)}const Oe=P({matMul_:u0});/** 654 * @license 655 * Copyright 2020 Google LLC. All Rights Reserved. 656 * Licensed under the Apache License, Version 2.0 (the "License"); 657 * you may not use this file except in compliance with the License. 658 * You may obtain a copy of the License at 659 * 660 * http://www.apache.org/licenses/LICENSE-2.0 661 * 662 * Unless required by applicable law or agreed to in writing, software 663 * distributed under the License is distributed on an "AS IS" BASIS, 664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 665 * See the License for the specific language governing permissions and 666 * limitations under the License. 667 * ============================================================================= 668 */function l0(n,e,t=1,r=0,a="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const s={indices:N(n,"indices","oneHot","int32")},o={dtype:a,depth:e,onValue:t,offValue:r};return V.runKernel($h,s,o)}const c0=P({oneHot_:l0});/** 669 * @license 670 * Copyright 2018 Google LLC. All Rights Reserved. 671 * Licensed under the Apache License, Version 2.0 (the "License"); 672 * you may not use this file except in compliance with the License. 673 * You may obtain a copy of the License at 674 * 675 * http://www.apache.org/licenses/LICENSE-2.0 676 * 677 * Unless required by applicable law or agreed to in writing, software 678 * distributed under the License is distributed on an "AS IS" BASIS, 679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 680 * See the License for the specific language governing permissions and 681 * limitations under the License. 682 * ============================================================================= 683 */function Jr(){return V}function Xe(n,e){return V.tidy(n,e)}function bn(n){Md(n).forEach(e=>e.dispose())}function Yn(n){return V.keep(n)}function p0(n,e,t=1){return V.registerBackend(n,e,t)}/** 684 * @license 685 * Copyright 2020 Google LLC. All Rights Reserved. 686 * Licensed under the Apache License, Version 2.0 (the "License"); 687 * you may not use this file except in compliance with the License. 688 * You may obtain a copy of the License at 689 * 690 * http://www.apache.org/licenses/LICENSE-2.0 691 * 692 * Unless required by applicable law or agreed to in writing, software 693 * distributed under the License is distributed on an "AS IS" BASIS, 694 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 695 * See the License for the specific language governing permissions and 696 * limitations under the License. 697 * ============================================================================= 698 */function h0(n){const e={input:N(n,"input","imag")};return V.runKernel(Zp,e)}const ko=P({imag_:h0});/** 699 * @license 700 * Copyright 2018 Google LLC. All Rights Reserved. 701 * Licensed under the Apache License, Version 2.0 (the "License"); 702 * you may not use this file except in compliance with the License. 703 * You may obtain a copy of the License at 704 * 705 * http://www.apache.org/licenses/LICENSE-2.0 706 * 707 * Unless required by applicable law or agreed to in writing, software 708 * distributed under the License is distributed on an "AS IS" BASIS, 709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 710 * See the License for the specific language governing permissions and 711 * limitations under the License. 712 * ============================================================================= 713 */function d0(n){const e={x:N(n,"x","neg")};return V.runKernel(kh,e)}const An=P({neg_:d0});/** 714 * @license 715 * Copyright 2020 Google LLC. All Rights Reserved. 716 * Licensed under the Apache License, Version 2.0 (the "License");
717 * you may not use this file except in compliance with the License. 718 * You may obtain a copy of the License at 719 * 720 * http://www.apache.org/licenses/LICENSE-2.0 721 * 722 * Unless required by applicable law or agreed to in writing, software 723 * distributed under the License is distributed on an "AS IS" BASIS, 724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 725 * See the License for the specific language governing permissions and 726 * limitations under the License. 727 * ============================================================================= 728 */function f0(n){const e={input:N(n,"input","real")};return V.runKernel(Ph,e)}const ns=P({real_:f0});/** 729 * @license 730 * Copyright 2018 Google LLC. All Rights Reserved. 731 * Licensed under the Apache License, Version 2.0 (the "License"); 732 * you may not use this file except in compliance with the License. 733 * You may obtain a copy of the License at 734 * 735 * http://www.apache.org/licenses/LICENSE-2.0 736 * 737 * Unless required by applicable law or agreed to in writing, software 738 * distributed under the License is distributed on an "AS IS" BASIS, 739 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 740 * See the License for the specific language governing permissions and 741 * limitations under the License. 742 * ============================================================================= 743 */function m0(n,e,t){const r=N(n,"x","transpose");if(e==null&&(e=r.shape.map((o,i)=>i).reverse()),R(r.rank===e.length,()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${e}.`),e.forEach(o=>{R(o>=0&&o<r.rank,()=>`All entries in 'perm' must be between 0 and ${r.rank-1} but got ${e}`)}),r.rank<=1)return r.clone();const a={x:r},s={perm:e};return r.dtype==="complex64"?Xe(()=>{let o=ns(r),i=ko(r);return o=V.runKernel(Ks,{x:o},s),i=V.runKernel(Ks,{x:i},s),t&&(i=An(i)),tr(o,i)}):V.runKernel(Ks,a,s)}const Hi=P({transpose_:m0});/** 744 * @license 745 * Copyright 2017 Google LLC. All Rights Reserved. 746 * Licensed under the Apache License, Version 2.0 (the "License"); 747 * you may not use this file except in compliance with the License. 748 * You may obtain a copy of the License at 749 * 750 * http://www.apache.org/licenses/LICENSE-2.0 751 * 752 * Unless required by applicable law or agreed to in writing, software 753 * distributed under the License is distributed on an "AS IS" BASIS, 754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 755 * See the License for the specific language governing permissions and 756 * limitations under the License. 757 * ============================================================================= 758 */function ao(n,e){const t=n.length,r=[];for(let a=0;a<t;a++){const s=t-1-a,o=n[s]||1;(e[e.length-1-a]||1)>1&&o===1&&r.unshift(s)}return r}function uf(n,e){const t=[];for(let r=0;r<e.length;r++){const a=n[n.length-r-1],s=e.length-r-1,o=e[s];(a==null||a===1&&o>1)&&t.unshift(s)}return t}function $e(n,e){const t=[],r=Math.max(n.length,e.length);for(let a=0;a<r;a++){let s=n[n.length-a-1];s==null&&(s=1);let o=e[e.length-a-1];if(o==null&&(o=1),s===1)t.unshift(o);else if(o===1)t.unshift(s);else if(s!==o){const i=`Operands could not be broadcast together with shapes ${n} and ${e}.`;throw Error(i)}else t.unshift(s)}return t}/** 759 * @license 760 * Copyright 2018 Google LLC. All Rights Reserved. 761 * Licensed under the Apache License, Version 2.0 (the "License"); 762 * you may not use this file except in compliance with the License. 763 * You may obtain a copy of the License at 764 * 765 * http://www.apache.org/licenses/LICENSE-2.0 766 * 767 * Unless required by applicable law or agreed to in writing, software 768 * distributed under the License is distributed on an "AS IS" BASIS, 769 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 770 * See the License for the specific language governing permissions and 771 * limitations under the License. 772 * ============================================================================= 773 */function lf(n,e,t){if(ga(n),e!=null&&e.length!==3)throw new Error("tensor3d() requires shape to have three numbers");const r=ar(n,t);if(r.length!==3&&r.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(r.length===1&&e==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return sr(n,e,r,t)}/** 774 * @license 775 * Copyright 2019 Google LLC. All Rights Reserved. 776 * Licensed under the Apache License, Version 2.0 (the "License");
777 * you may not use this file except in compliance with the License. 778 * You may obtain a copy of the License at 779 * 780 * http://www.apache.org/licenses/LICENSE-2.0 781 * 782 * Unless required by applicable law or agreed to in writing, software 783 * distributed under the License is distributed on an "AS IS" BASIS, 784 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 785 * See the License for the specific language governing permissions and 786 * limitations under the License. 787 * ============================================================================= 788 */let br;function g0(n,e=3){if(e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(n==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let t=!1,r=!1,a=!1,s=!1,o=!1,i=!1;if(n.data instanceof Uint8Array)t=!0;else if(typeof ImageData<"u"&&n instanceof ImageData)r=!0;else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)a=!0;else if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)s=!0;else if(n.getContext!=null)o=!0;else if(typeof ImageBitmap<"u"&&n instanceof ImageBitmap)i=!0;else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${n.constructor.name}`);if(Fi(Ri,V.backendName)!=null){const h={pixels:n},d={numChannels:e};return V.runKernel(Ri,h,d)}const[u,l]=a?[n.videoWidth,n.videoHeight]:[n.width,n.height];let c;if(o)c=n.getContext("2d").getImageData(0,0,u,l).data;else if(r||t)c=n.data;else if(s||a||i){if(br==null)if(typeof document>"u")if(typeof OffscreenCanvas<"u"&&typeof OffscreenCanvasRenderingContext2D<"u")br=new OffscreenCanvas(1,1).getContext("2d");else throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");else br=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});br.canvas.width=u,br.canvas.height=l,br.drawImage(n,0,0,u,l),c=br.getImageData(0,0,u,l).data}let p;if(e===4)p=new Int32Array(c);else{const h=u*l;p=new Int32Array(h*e);for(let d=0;d<h;d++)for(let m=0;m<e;++m)p[d*e+m]=c[d*4+m]}return lf(p,[l,u,e],"int32")}async function cf(n,e){let t=N(n,"img","toPixels");if(!(n instanceof Ge)){const l=t;t=je(l,"int32"),l.dispose()}if(t.rank!==2&&t.rank!==3)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${t.rank}.`);const[r,a]=t.shape.slice(0,2),s=t.rank===2?1:t.shape[2];if(s>4||s===2)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${s}`);if(t.dtype!=="float32"&&t.dtype!=="int32")throw new Error(`Unsupported type for toPixels: ${t.dtype}. Please use float32 or int32 tensors.`);const o=await t.data(),i=t.dtype==="float32"?255:1,u=new Uint8ClampedArray(a*r*4);for(let l=0;l<r*a;++l){const c=[0,0,0,255];for(let h=0;h<s;h++){const d=o[l*s+h];if(t.dtype==="float32"){if(d<0||d>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${d}.`)}else if(t.dtype==="int32"&&(d<0||d>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${d}.`);s===1?(c[0]=d*i,c[1]=d*i,c[2]=d*i):c[h]=d*i}const p=l*4;u[p+0]=Math.round(c[0]),u[p+1]=Math.round(c[1]),u[p+2]=Math.round(c[2]),u[p+3]=Math.round(c[3])}return t!==n&&t.dispose(),u}const pf=P({fromPixels_:g0});function hf(n,e){const t=n.shape.length,r=e.shape.length;if(t<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${t}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if(e.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[r-1]>t)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[r-1]} vs. ${t}`);if(ae(n.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${n.shape}.`);const a=e.shape,s=a[a.length-1];let o=1;for(let p=0;p<a.length-1;++p)o*=a[p];const i=n.shape,u=a.slice();u.pop();let l=1;for(let p=s;p<t;++p)l*=i[p],u.push(i[p]);const c=[...ot(n.shape).map(p=>p/l),1].slice(0,s);return[u,o,l,c]}function df(n,e,t){const r=e.rank>1?e.shape[e.rank-1]:1,a=e.rank>1?e.rank-1:1,s=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t.shape}, indices.shape: ${e.shape}, shape: ${n}, sliceDim: ${r}, and batchDim: ${a}.`;if(t.rank<a)throw new Error(s+` update.rank < ${a}. `);if(n.length<r+(t.rank-a))throw new Error(s+` Output shape length < ${r+(t.rank-a)}`);if(t.rank!==a+n.length-r)throw new Error(s+` update.rank != ${a+n.length-r}`);for(let o=0;o<a;++o)if(t.shape[o]!==e.shape[o])throw new Error(s+` updates.shape[${o}] (${t.shape[o]}
788) != indices.shape[${o}] (${e.shape[o]}).`);for(let o=0;o<t.rank-a;++o)if(t.shape[o+a]!==n[o+r])throw new Error(s+` updates.shape[${o+a}] (${t.shape[o+a]}) != shape[${o+a}] (${n[o+a]})`)}function ff(n,e,t){if(e.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${e.rank}.`);if(n.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${n.rank}.`);if(e.dtype!=="int32")throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${e.dtype}`);if(t.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${t}`);if(t.length===0){if(e.size===0)throw new Error(`Indices specified for empty output. indices shape: ${e.shape}`);if(n.size===0)throw new Error(`Updates specified for empty output. updates shape: ${n.shape}`)}df(t,e,n)}function Mu(n,e,t){const r=e.shape.length,a=r>1?e.shape[r-1]:1,s=t.length;let o=1;for(let p=a;p<s;++p)o*=t[p];const i=a<1?1:a,u=ae(e.shape)/i,l=[...ot(t.slice(0,a)),1],c=ae(t);return{sliceRank:a,numUpdates:u,sliceSize:o,strides:l,outputSize:c}}/** 789 * @license 790 * Copyright 2021 Google LLC. All Rights Reserved. 791 * Licensed under the Apache License, Version 2.0 (the "License"); 792 * you may not use this file except in compliance with the License. 793 * You may obtain a copy of the License at 794 * 795 * http://www.apache.org/licenses/LICENSE-2.0 796 * 797 * Unless required by applicable law or agreed to in writing, software 798 * distributed under the License is distributed on an "AS IS" BASIS, 799 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 800 * See the License for the specific language governing permissions and 801 * limitations under the License. 802 * ============================================================================= 803 */const Xi=-2,y0=-1;function mf(n,e,t){const r=n.shape.length;R(r===e.length,()=>`Error in slice${r}D: Length of begin ${e} must match the rank of the array (${r}).`),R(r===t.length,()=>`Error in slice${r}D: Length of size ${t} must match the rank of the array (${r}).`);for(let a=0;a<r;++a)R(e[a]+t[a]<=n.shape[a],()=>`Error in slice${r}D: begin[${a}] + size[${a}] (${e[a]+t[a]}) would overflow input.shape[${a}] (${n.shape[a]})`)}function x0(n){const e=[];let t=0;for(;n>0;)n&1&&e.push(t),n/=2,t++;return e}function gf(n,e,t){const r=[];for(let a=0;a<n.length;a++)r[a]=Math.ceil((e[a]-n[a])/t[a]);return r}function yf(n,e,t,r){const a=[...n];for(let s=a.length;s<r.length;s++)a.push(1);for(let s=0;s<t;s++)s===0?a[e]=1:(a.splice(e,0,1),a.pop());return a}function xf(n,e,t){return t<=n?t:t-(e-1)}function bf(n,e){const t=[];for(let r=0;r<n;r++)t.push(e+r);return t}function b0(n,e,t,r,a,s,o,i,u){const l=n.length;let c=new Array(l),p=new Array(l),h=new Array(l);if(e.length&&t>0){const d=e[0],m=t+1;c=vf(o,d,m,r,n),p=wf(i,d,m,a,n),h=yf(s,d,m,n)}else for(let d=0;d<l;d++)c[d]=kf(o,r,s,n,d,u),p[d]=Tf(i,a,s,n,d,u),h[d]=Sf(s,d,u);return{begin:c,end:p,strides:h}}function vf(n,e,t,r,a){const s=[...a],o=bf(t,e);for(let i=0;i<s.length;i++)if(o.indexOf(i)>-1)s[i]=0;else{const u=xf(e,t,i);let l=r[u];n&1<<u&&(l=0),s[i]=l}return s}function wf(n,e,t,r,a){const s=[...a],o=bf(t,e);for(let i=0;i<s.length;i++)if(o.indexOf(i)>-1)s[i]=Number.MAX_SAFE_INTEGER;else{const u=xf(e,t,i);let l=r[u];n&1<<u&&(l=Number.MAX_SAFE_INTEGER),s[i]=l}for(let i=0;i<s.length;i++){const u=a[i];s[i]<0&&(s[i]+=u),s[i]=eo(0,s[i],a[i])}return s}function Sf(n,e,t){let r=n[e];return(t&1<<e||r==null)&&(r=1),r}function kf(n,e,t,r,a,s){let o=e[a];const i=t[a]||1;(n&1<<a||s&1<<a||o==null)&&(i>0?o=Number.MIN_SAFE_INTEGER:o=Number.MAX_SAFE_INTEGER);const u=r[a];return o<0&&(o+=u),o=eo(0,o,u-1),o}function Tf(n,e,t,r,a,s){let o=e[a];const i=t[a]||1;(n&1<<a||s&1<<a||o==null)&&(i>0?o=Number.MAX_SAFE_INTEGER:o=Number.MIN_SAFE_INTEGER);const u=r[a];return o<0&&(o+=u),i>0?o=eo(0,o,u):o=eo(-1,o,u-1),o}function Lu(n,e,t){let r=t.length;for(let a=0;a<t.length;a++)if(t[a]>1){r=a;break}for(let a=r+1;a<t.length;a++)if(e[a]>0||t[a]!==n[a])return!1;return!0}function Pu(n,e){let t=n.length>0?n[n.length-1]:1;for(let r=0;r<n.length-1;r++)t+=n[r]*e[r];return t}function Ef(n,e,t){let r;const a=n.shape.length;typeof e=="number"?r=[e,...new Array(a-1).fill(0)]:e.length<a?r=e.concat(new Array(a-e.length).fill(0)):r=e.slice(),r.forEach(o=>{R(o!==-1,()=>"slice() does not support negative begin indexing.")});let s;return t==null?s=new Array(a).fill(-1):typeof t=="number"?s=[t,...new Array(a-1).fill(-1)]:t.length<a?s=t.concat(new Array(a-t.length).fill(-1)):s=t,s=s.map((o,i)=>o>=0?o:(R(o===-1,()=>`Negative size values should be exactly -1 but got ${o} for the slice() size at index ${i}.`),n.shape[i]-r[i])),[r,s]}function Cf(n,e,t,r,a,s,o,i,u){let l;if(r==null?(l=new Array(e.length),l.fill(1)):l=r,o!=null&&(o&o-1)!==0)throw new Error("Multiple ellipses in slice is not allowed.");let c=!1;const p={dims:l.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:t.slice(),strides:l.slice(),beginMask:a,endMask:s,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:u};for(let T=0;T<p.dims;
vendor: 4,360 bytes, lines 803-821
803T++)c&&(1<<T&i)!==0&&p.numAddAxisAfterEllipsis++,1<<T&o&&(c=!0);c||(p.ellipsisMask|=1<<p.dims,p.dims++);const h={dims:n.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};v0(p,h);let d=!0,m=!0,y=!0;const b=[],x=[];for(let T=0;T<n.length;++T){if(h.strides[T]===0)throw Error(`strides[${T}] must be non-zero`);const $=!!(h.shrinkAxisMask&1<<T),F=n[T];if(F===-1){b.push($?1:-1);continue}const M=[h.beginMask&1<<T,h.endMask&1<<T],U=[h.strides[T]>0?0:-1,h.strides[T]>0?F:F-1];if($&&h.strides[T]<=0)throw Error("only stride 1 allowed on non-range indexing.");y=y&&h.strides[T]===1;const X=!!(h.beginMask&1<<T&&h.endMask&1<<T);if(h.beginValid&&h.endValid){if($){const q=h.begin[T]<0?F+h.begin[T]:h.begin[T];if(h.begin[T]=q,h.end[T]=h.begin[T]+1,q<0||q>=F)throw Error(`slice index ${h.begin[T]} of dimension ${T} out of bounds.`)}else h.begin[T]=Al(h.begin[T],0,h.strides[T],F,M,U),h.end[T]=Al(h.end[T],1,h.strides[T],F,M,U);const C=h.strides[T]===1&&h.begin[T]===0&&h.end[T]===F;d=d&&C,m=m&&(T===0&&h.strides[T]===1||C)}else d=d&&h.strides[T]===1&&X,m=m&&(T===0&&h.strides[T]===1||X);let z,L=!1;if(h.beginValid&&h.endValid?(z=h.end[T]-h.begin[T],L=!0):$?(z=1,L=!0):X&&F>=0&&(h.strides[T]<0?z=-F:z=F,L=!0),L){let C;z===0||z<0!=h.strides[T]<0?C=0:C=Math.trunc(z/h.strides[T])+(z%h.strides[T]!==0?1:0),b.push(C)}else b.push(-1)}for(let T=0;T<h.finalShapeGatherIndices.length;++T){const $=h.finalShapeGatherIndices[T];$>=0?x.push(b[$]):$===Xi&&x.push(1)}return{finalShapeSparse:x.filter((T,$)=>h.finalShapeGatherIndices[$]!==Xi),finalShape:x,isIdentity:d,sliceDim0:m,isSimpleSlice:y,begin:h.begin,end:h.end,strides:h.strides}}function v0(n,e){e.beginMask=0,e.endMask=0,e.shrinkAxisMask=0;let t=0;e.beginValid=n.begin!=null,e.endValid=n.end!=null,e.begin=new Array(e.dims),e.end=new Array(e.dims),e.strides=new Array(e.dims),e.finalShapeGatherIndices=[],e.finalShapeGatherIndicesSparse=[],e.inputShapeGatherIndicesSparse=new Array(e.dims);for(let r=0;r<n.dims;r++)if(1<<r&n.ellipsisMask){const a=Math.min(e.dims-(n.dims-r)+1+n.numAddAxisAfterEllipsis,e.dims);for(;t<a;t++)e.begin[t]=0,e.end[t]=0,e.strides[t]=1,e.beginMask|=1<<t,e.endMask|=1<<t,e.finalShapeGatherIndices.push(t),e.finalShapeGatherIndicesSparse.push(-1),e.inputShapeGatherIndicesSparse[t]=r}else if(1<<r&n.newAxisMask)e.finalShapeGatherIndices.push(Xi),e.finalShapeGatherIndicesSparse.push(-1);else{if(t===e.begin.length)throw Error(`Index out of range using input dim ${t}; input has only ${e.dims} dims, ${e.begin.length}.`);n.begin!=null&&(e.begin[t]=n.begin[r]),n.end!=null&&(e.end[t]=n.end[r]),e.strides[t]=n.strides[r],n.beginMask&1<<r&&(e.beginMask|=1<<t),n.endMask&1<<r&&(e.endMask|=1<<t),n.shrinkAxisMask&1<<r?(e.finalShapeGatherIndices.push(y0),e.finalShapeGatherIndicesSparse.push(-1),e.shrinkAxisMask|=1<<t):(e.finalShapeGatherIndices.push(t),e.finalShapeGatherIndicesSparse.push(r)),e.inputShapeGatherIndicesSparse[t]=r,t++}}function Al(n,e,t,r,a,s){if(a[e])return t>0?s[e]:s[e+1&1];{const o=n<0?r+n:n;return o<s[0]?s[0]:o>s[1]?s[1]:o}}const w0=Object.freeze(Object.defineProperty({__proto__:null,assertParamsValid:mf,computeFlatOffset:Pu,computeOutShape:gf,getNormalizedAxes:b0,isSliceContinous:Lu,maskToAxes:x0,parseSliceParams:Ef,sliceInfo:Cf,startForAxis:kf,startIndicesWithElidedDims:vf,stopForAxis:Tf,stopIndicesWithElidedDims:wf,stridesForAxis:Sf,stridesWithElidedDims:yf},Symbol.toStringTag,{value:"Module"}));/** 804 * @license 805 * Copyright 2020 Google LLC. All Rights Reserved. 806 * Licensed under the Apache License, Version 2.0 (the "License"); 807 * you may not use this file except in compliance with the License. 808 * You may obtain a copy of the License at 809 * 810 * http://www.apache.org/licenses/LICENSE-2.0 811 * 812 * Unless required by applicable law or agreed to in writing, software 813 * distributed under the License is distributed on an "AS IS" BASIS, 814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 815 * See the License for the specific language governing permissions and 816 * limitations under the License. 817 * ============================================================================= 818 */function S0(n,e){let t=N(n,"a","add"),r=N(e,"b","add");[t,r]=Ke(t,r);const a={a:t,b:r};return V.runKernel(Cu,a)}const Pe=P({add_:S0});/** 819 * @license 820 * Copyright 2020 Google LLC. All Rights Reserved. 821 * Licensed under the Apache License, Version 2.0 (the "License");
822 * you may not use this file except in compliance with the License. 823 * You may obtain a copy of the License at 824 * 825 * http://www.apache.org/licenses/LICENSE-2.0 826 * 827 * Unless required by applicable law or agreed to in writing, software 828 * distributed under the License is distributed on an "AS IS" BASIS, 829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 830 * See the License for the specific language governing permissions and 831 * limitations under the License. 832 * ============================================================================= 833 */function k0(n,e){let t=N(n,"a","floorDiv"),r=N(e,"b","floorDiv");[t,r]=Ke(t,r);const a={a:t,b:r};return V.runKernel(Gp,a)}const If=P({floorDiv_:k0});/** 834 * @license 835 * Copyright 2020 Google LLC. All Rights Reserved. 836 * Licensed under the Apache License, Version 2.0 (the "License"); 837 * you may not use this file except in compliance with the License. 838 * You may obtain a copy of the License at 839 * 840 * http://www.apache.org/licenses/LICENSE-2.0 841 * 842 * Unless required by applicable law or agreed to in writing, software 843 * distributed under the License is distributed on an "AS IS" BASIS, 844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 845 * See the License for the specific language governing permissions and 846 * limitations under the License. 847 * ============================================================================= 848 */function T0(n,e){let t=N(n,"a","div"),r=N(e,"b","div");if([t,r]=Ke(t,r),t.dtype==="int32"&&r.dtype==="int32")return If(t,r);const a={a:t,b:r},s={};return V.runKernel(Ap,a,s)}const De=P({div_:T0});/** 849 * @license 850 * Copyright 2020 Google LLC. All Rights Reserved. 851 * Licensed under the Apache License, Version 2.0 (the "License"); 852 * you may not use this file except in compliance with the License. 853 * You may obtain a copy of the License at 854 * 855 * http://www.apache.org/licenses/LICENSE-2.0 856 * 857 * Unless required by applicable law or agreed to in writing, software 858 * distributed under the License is distributed on an "AS IS" BASIS, 859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 860 * See the License for the specific language governing permissions and 861 * limitations under the License. 862 * ============================================================================= 863 */function E0(n,e){let t=N(n,"a","mul"),r=N(e,"b","mul");[t,r]=Ke(t,r);const a={a:t,b:r};return V.runKernel(Sh,a)}const me=P({mul_:E0});/** 864 * @license 865 * Copyright 2018 Google LLC. All Rights Reserved. 866 * Licensed under the Apache License, Version 2.0 (the "License"); 867 * you may not use this file except in compliance with the License. 868 * You may obtain a copy of the License at 869 * 870 * http://www.apache.org/licenses/LICENSE-2.0 871 * 872 * Unless required by applicable law or agreed to in writing, software 873 * distributed under the License is distributed on an "AS IS" BASIS, 874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 875 * See the License for the specific language governing permissions and 876 * limitations under the License. 877 * ============================================================================= 878 */function C0(n){const e=N(n,"x","abs");if(e.dtype==="complex64"){const t={x:e};return V.runKernel(dp,t)}else{const t={x:e};return V.runKernel(jc,t)}}const Kt=P({abs_:C0});/** 879 * @license 880 * Copyright 2018 Google LLC. All Rights Reserved. 881 * Licensed under the Apache License, Version 2.0 (the "License"); 882 * you may not use this file except in compliance with the License. 883 * You may obtain a copy of the License at 884 * 885 * http://www.apache.org/licenses/LICENSE-2.0 886 * 887 * Unless required by applicable law or agreed to in writing, software 888 * distributed under the License is distributed on an "AS IS" BASIS, 889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 890 * See the License for the specific language governing permissions and 891 * limitations under the License. 892 * ============================================================================= 893 */function I0(n){const e={x:N(n,"x","acos")};return V.runKernel(Hc,e)}const N0=P({acos_:I0});/** 894 * @license 895 * Copyright 2018 Google LLC. All Rights Reserved. 896 * Licensed under the Apache License, Version 2.0 (the "License");
897 * you may not use this file except in compliance with the License. 898 * You may obtain a copy of the License at 899 * 900 * http://www.apache.org/licenses/LICENSE-2.0 901 * 902 * Unless required by applicable law or agreed to in writing, software 903 * distributed under the License is distributed on an "AS IS" BASIS, 904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 905 * See the License for the specific language governing permissions and 906 * limitations under the License. 907 * ============================================================================= 908 */function $0(n){const e={x:N(n,"x","acosh")};return V.runKernel(Xc,e)}const R0=P({acosh_:$0});/** 909 * @license 910 * Copyright 2020 Google LLC. All Rights Reserved. 911 * Licensed under the Apache License, Version 2.0 (the "License"); 912 * you may not use this file except in compliance with the License. 913 * You may obtain a copy of the License at 914 * 915 * http://www.apache.org/licenses/LICENSE-2.0 916 * 917 * Unless required by applicable law or agreed to in writing, software 918 * distributed under the License is distributed on an "AS IS" BASIS, 919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 920 * See the License for the specific language governing permissions and 921 * limitations under the License. 922 * ============================================================================= 923 */function _0(n){R(Array.isArray(n),()=>"The argument passed to tf.addN() must be a list of tensors"),R(n.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${n.length}`);const e=n.map((a,s)=>N(a,`tensors${s}`,"addN")),t=e[0];e.forEach(a=>{if(a.dtype!==t.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),e.forEach(a=>{if(!qe(a.shape,t.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});const r=e;return V.runKernel(qc,r)}const A0=P({addN_:_0});/** 924 * @license 925 * Copyright 2020 Google LLC. All Rights Reserved. 926 * Licensed under the Apache License, Version 2.0 (the "License"); 927 * you may not use this file except in compliance with the License. 928 * You may obtain a copy of the License at 929 * 930 * http://www.apache.org/licenses/LICENSE-2.0 931 * 932 * Unless required by applicable law or agreed to in writing, software 933 * distributed under the License is distributed on an "AS IS" BASIS, 934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 935 * See the License for the specific language governing permissions and 936 * limitations under the License. 937 * ============================================================================= 938 */function O0(n,e=null,t=!1){const r={x:N(n,"x","all","bool")},a={axis:e,keepDims:t};return V.runKernel(Kc,r,a)}const F0=P({all_:O0});/** 939 * @license 940 * Copyright 2020 Google LLC. All Rights Reserved. 941 * Licensed under the Apache License, Version 2.0 (the "License"); 942 * you may not use this file except in compliance with the License. 943 * You may obtain a copy of the License at 944 * 945 * http://www.apache.org/licenses/LICENSE-2.0 946 * 947 * Unless required by applicable law or agreed to in writing, software 948 * distributed under the License is distributed on an "AS IS" BASIS, 949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 950 * See the License for the specific language governing permissions and 951 * limitations under the License. 952 * ============================================================================= 953 */function D0(n,e=null,t=!1){const r={x:N(n,"x","any","bool")},a={axis:e,keepDims:t};return V.runKernel(Yc,r,a)}const M0=P({any_:D0});/** 954 * @license 955 * Copyright 2020 Google Inc. All Rights Reserved. 956 * Licensed under the Apache License, Version 2.0 (the "License"); 957 * you may not use this file except in compliance with the License. 958 * You may obtain a copy of the License at 959 * 960 * http://www.apache.org/licenses/LICENSE-2.0 961 * 962 * Unless required by applicable law or agreed to in writing, software 963 * distributed under the License is distributed on an "AS IS" BASIS, 964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 965 * See the License for the specific language governing permissions and 966 * limitations under the License. 967 * ============================================================================= 968 */function L0(n,e=0){const t={x:N(n,"x","argMax")},r={axis:e};return V.runKernel(Zc,t,r)}const P0=P({argMax_:L0});/** 969 * @license 970 * Copyright 2020 Google Inc. All Rights Reserved. 971 * Licensed under the Apache License, Version 2.0 (the "License");
972 * you may not use this file except in compliance with the License. 973 * You may obtain a copy of the License at 974 * 975 * http://www.apache.org/licenses/LICENSE-2.0 976 * 977 * Unless required by applicable law or agreed to in writing, software 978 * distributed under the License is distributed on an "AS IS" BASIS, 979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 980 * See the License for the specific language governing permissions and 981 * limitations under the License. 982 * ============================================================================= 983 */function B0(n,e=0){const t={x:N(n,"x","argMin")},r={axis:e};return V.runKernel(Jc,t,r)}const U0=P({argMin_:B0});/** 984 * @license 985 * Copyright 2018 Google LLC. All Rights Reserved. 986 * Licensed under the Apache License, Version 2.0 (the "License"); 987 * you may not use this file except in compliance with the License. 988 * You may obtain a copy of the License at 989 * 990 * http://www.apache.org/licenses/LICENSE-2.0 991 * 992 * Unless required by applicable law or agreed to in writing, software 993 * distributed under the License is distributed on an "AS IS" BASIS, 994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 995 * See the License for the specific language governing permissions and 996 * limitations under the License. 997 * ============================================================================= 998 */function V0(n){const e={x:N(n,"x","asin")};return V.runKernel(Qc,e)}const W0=P({asin_:V0});/** 999 * @license 1000 * Copyright 2018 Google LLC. All Rights Reserved. 1001 * Licensed under the Apache License, Version 2.0 (the "License"); 1002 * you may not use this file except in compliance with the License. 1003 * You may obtain a copy of the License at 1004 * 1005 * http://www.apache.org/licenses/LICENSE-2.0 1006 * 1007 * Unless required by applicable law or agreed to in writing, software 1008 * distributed under the License is distributed on an "AS IS" BASIS, 1009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1010 * See the License for the specific language governing permissions and 1011 * limitations under the License. 1012 * ============================================================================= 1013 */function z0(n){const e={x:N(n,"x","asinh")};return V.runKernel(ep,e)}const G0=P({asinh_:z0});/** 1014 * @license 1015 * Copyright 2018 Google LLC. All Rights Reserved. 1016 * Licensed under the Apache License, Version 2.0 (the "License"); 1017 * you may not use this file except in compliance with the License. 1018 * You may obtain a copy of the License at 1019 * 1020 * http://www.apache.org/licenses/LICENSE-2.0 1021 * 1022 * Unless required by applicable law or agreed to in writing, software 1023 * distributed under the License is distributed on an "AS IS" BASIS, 1024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1025 * See the License for the specific language governing permissions and 1026 * limitations under the License. 1027 * ============================================================================= 1028 */function j0(n){const e={x:N(n,"x","atan")};return V.runKernel(tp,e)}const H0=P({atan_:j0});/** 1029 * @license 1030 * Copyright 2020 Google LLC. All Rights Reserved. 1031 * Licensed under the Apache License, Version 2.0 (the "License"); 1032 * you may not use this file except in compliance with the License. 1033 * You may obtain a copy of the License at 1034 * 1035 * http://www.apache.org/licenses/LICENSE-2.0 1036 * 1037 * Unless required by applicable law or agreed to in writing, software 1038 * distributed under the License is distributed on an "AS IS" BASIS, 1039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1040 * See the License for the specific language governing permissions and 1041 * limitations under the License. 1042 * ============================================================================= 1043 */function X0(n,e){let t=N(n,"a","atan2"),r=N(e,"b","atan2");[t,r]=Ke(t,r);const a={a:t,b:r};return V.runKernel(rp,a)}const q0=P({atan2_:X0});/** 1044 * @license 1045 * Copyright 2018 Google LLC. All Rights Reserved. 1046 * Licensed under the Apache License, Version 2.0 (the "License"); 1047 * you may not use this file except in compliance with the License. 1048 * You may obtain a copy of the License at 1049 * 1050 * http://www.apache.org/licenses/LICENSE-2.0 1051 * 1052 * Unless required by applicable law or agreed to in writing, softw
1052are 1053 * distributed under the License is distributed on an "AS IS" BASIS, 1054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1055 * See the License for the specific language governing permissions and 1056 * limitations under the License. 1057 * ============================================================================= 1058 */function K0(n){const e={x:N(n,"x","atanh")};return V.runKernel(np,e)}const Y0=P({atanh_:K0});/** 1059 * @license 1060 * Copyright 2020 Google LLC. All Rights Reserved. 1061 * Licensed under the Apache License, Version 2.0 (the "License"); 1062 * you may not use this file except in compliance with the License. 1063 * You may obtain a copy of the License at 1064 * 1065 * http://www.apache.org/licenses/LICENSE-2.0 1066 * 1067 * Unless required by applicable law or agreed to in writing, software 1068 * distributed under the License is distributed on an "AS IS" BASIS, 1069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1070 * See the License for the specific language governing permissions and 1071 * limitations under the License. 1072 * ============================================================================= 1073 */function Nf(n,e,t,r,a="NHWC",s){const o=n[3],i=[...e,o],u=xa(a);return Pt(n,i,t,s,r,null,null,u)}function Pr(n,e,t,r,a,s,o="channelsLast"){const[i,u]=so(e);let l;if(o==="channelsLast")l=[i,u,n[3],n[3]];else if(o==="channelsFirst")l=[i,u,n[1],n[1]];else throw new Error(`Unknown dataFormat ${o}`);return Pt(n,l,t,r,a,s,!1,o)}function ds(n,e,t,r,a,s,o="NDHWC"){const[i,u,l]=qi(e);let c,p;if(o==="NDHWC")p="channelsLast",c=[i,u,l,n[4],n[4]];else if(o==="NCDHW")p="channelsFirst",c=[i,u,l,n[1],n[1]];else throw new Error(`Unknown dataFormat ${o}`);return fs(n,c,t,r,a,!1,p,s)}function Pt(n,e,t,r,a,s,o=!1,i="channelsLast"){let[u,l,c,p]=[-1,-1,-1,-1];if(i==="channelsLast")[u,l,c,p]=n;else if(i==="channelsFirst")[u,p,l,c]=n;else throw new Error(`Unknown dataFormat ${i}`);const[h,d,,m]=e,[y,b]=so(t),[x,T]=so(r),$=sa(h,x),F=sa(d,T),{padInfo:M,outHeight:U,outWidth:X}=Q0(a,l,c,y,b,$,F,s,i),z=o?m*p:m;let L;return i==="channelsFirst"?L=[u,z,U,X]:i==="channelsLast"&&(L=[u,U,X,z]),{batchSize:u,dataFormat:i,inHeight:l,inWidth:c,inChannels:p,outHeight:U,outWidth:X,outChannels:z,padInfo:M,strideHeight:y,strideWidth:b,filterHeight:h,filterWidth:d,effectiveFilterHeight:$,effectiveFilterWidth:F,dilationHeight:x,dilationWidth:T,inShape:n,outShape:L,filterShape:e}}function fs(n,e,t,r,a,s=!1,o="channelsLast",i){let[u,l,c,p,h]=[-1,-1,-1,-1,-1];if(o==="channelsLast")[u,l,c,p,h]=n;else if(o==="channelsFirst")[u,h,l,c,p]=n;else throw new Error(`Unknown dataFormat ${o}`);const[d,m,y,,b]=e,[x,T,$]=qi(t),[F,M,U]=qi(r),X=sa(d,F),z=sa(m,M),L=sa(y,U),{padInfo:C,outDepth:q,outHeight:ee,outWidth:te}=e3(a,l,c,p,x,T,$,X,z,L,i),le=s?b*h:b;let de;return o==="channelsFirst"?de=[u,le,q,ee,te]:o==="channelsLast"&&(de=[u,q,ee,te,le]),{batchSize:u,dataFormat:o,inDepth:l,inHeight:c,inWidth:p,inChannels:h,outDepth:q,outHeight:ee,outWidth:te,outChannels:le,padInfo:C,strideDepth:x,strideHeight:T,strideWidth:$,filterDepth:d,filterHeight:m,filterWidth:y,effectiveFilterDepth:X,effectiveFilterHeight:z,effectiveFilterWidth:L,dilationDepth:F,dilationHeight:M,dilationWidth:U,inShape:n,outShape:de,filterShape:e}}function Z0(n,e,t,r,a){r==null&&(r=Bu(n,e,t));const s=n[0],o=n[1],i=$r((s-e+2*r)/t+1,a),u=$r((o-e+2*r)/t+1,a);return[i,u]}function J0(n,e,t,r,a,s){a==null&&(a=Bu(n,e,r));const o=n[0],i=n[1],u=n[2],l=$r((o-e+2*a)/r+1,s),c=$r((i-e+2*a)/r+1,s),p=$r((u-e+2*a)/r+1,s);return[l,c,p,t]}function Bu(n,e,t,r=1){const a=sa(e,r);return Math.floor((n[0]*(t-1)-t+a)/2)}function so(n){return typeof n=="number"?[n,n,n]:n.length===2?[n[0],n[1],1]:n}function qi(n){return typeof n=="number"?[n,n,n]:n}function sa(n,e){return e<=1?n:n+(n-1)*(e-1)}function Q0(n,e,t,r,a,s,o,i,u){let l,c,p;if(typeof n=="number"){l={top:n,bottom:n,left:n,right:n,type:n===0?"VALID":"NUMBER"};const h=Z0([e,t],s,r,n,i);c=h[0],p=h[1]}else if(n==="same"){c=Math.ceil(e/r),p=Math.ceil(t/a);const h=Math.max(0,(c-1)*r+s-e),d=Math.max(0,(p-1)*a+o-t),m=Math.floor(h/2),y=h-m,b=Math.floor(d/2),x=d-b;l={top:m,bottom:y,left:b,right:x,type:"SAME"}}else if(n==="valid")l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((e-s+1)/r),p=Math.ceil((t-o+1)/a);else if(typeof n=="object"){const h=u==="channelsLast"?n[1][0]:n[2][0],d=u==="channelsLast"?n[1][1]:n[2][1],m=u==="channelsLast"?n[2][0]:n[3][0],y=u==="channelsLast"?n[2][1]:n[3][1];
vendor: 4,305 bytes, lines 1073-1112
1073l={top:h,bottom:d,left:m,right:y,type:h===0&&d===0&&m===0&&y===0?"VALID":"EXPLICIT"},c=$r((e-s+h+d)/r+1,i),p=$r((t-o+m+y)/a+1,i)}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:l,outHeight:c,outWidth:p}}function e3(n,e,t,r,a,s,o,i,u,l,c){let p,h,d,m;if(typeof n=="number"){p={top:n,bottom:n,left:n,right:n,front:n,back:n,type:n===0?"VALID":"NUMBER"};const y=J0([e,t,r,1],i,1,a,n,c);h=y[0],d=y[1],m=y[2]}else if(n==="same"){h=Math.ceil(e/a),d=Math.ceil(t/s),m=Math.ceil(r/o);const y=(h-1)*a+i-e,b=(d-1)*s+u-t,x=(m-1)*o+l-r,T=Math.floor(y/2),$=y-T,F=Math.floor(b/2),M=b-F,U=Math.floor(x/2),X=x-U;p={top:F,bottom:M,left:U,right:X,front:T,back:$,type:"SAME"}}else if(n==="valid")p={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((e-i+1)/a),d=Math.ceil((t-u+1)/s),m=Math.ceil((r-l+1)/o);else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:p,outDepth:h,outHeight:d,outWidth:m}}function $r(n,e){if(!e)return Math.trunc(n);switch(e){case"round":return Math.round(n);case"ceil":return Math.ceil(n);case"floor":return Math.floor(n);default:throw new Error(`Unknown roundingMode ${e}`)}}function rs(n){const[e,t,r]=so(n);return e===1&&t===1&&r===1}function _t(n,e){return rs(n)||rs(e)}function xa(n){if(n==="NHWC")return"channelsLast";if(n==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${n}`)}function Jt(n,e,t){if(t!=null){if(typeof e=="string")throw Error(`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);if(typeof e=="number")R(ua(e),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);else if(typeof e=="object")e.forEach(r=>{r.forEach(a=>{R(ua(a),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${a}.`)})});else throw Error(`Error in ${n}: Unknown padding parameter: ${e}`)}}/** 1074 * @license 1075 * Copyright 2020 Google LLC. All Rights Reserved. 1076 * Licensed under the Apache License, Version 2.0 (the "License"); 1077 * you may not use this file except in compliance with the License. 1078 * You may obtain a copy of the License at 1079 * 1080 * http://www.apache.org/licenses/LICENSE-2.0 1081 * 1082 * Unless required by applicable law or agreed to in writing, software 1083 * distributed under the License is distributed on an "AS IS" BASIS, 1084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1085 * See the License for the specific language governing permissions and 1086 * limitations under the License. 1087 * ============================================================================= 1088 */function t3(n,e){const t={x:N(n,"x","reshape","string_or_numeric")},r={shape:e};return V.runKernel(Vh,t,r)}const Z=P({reshape_:t3});/** 1089 * @license 1090 * Copyright 2020 Google LLC. All Rights Reserved. 1091 * Licensed under the Apache License, Version 2.0 (the "License"); 1092 * you may not use this file except in compliance with the License. 1093 * You may obtain a copy of the License at 1094 * 1095 * http://www.apache.org/licenses/LICENSE-2.0 1096 * 1097 * Unless required by applicable law or agreed to in writing, software 1098 * distributed under the License is distributed on an "AS IS" BASIS, 1099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1100 * See the License for the specific language governing permissions and 1101 * limitations under the License. 1102 * ============================================================================= 1103 */function n3(n,e,t,r,a){const s=N(n,"x","avgPool","float32"),o=1;R(_t(t,o),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`);let i=s,u=!1;s.rank===3&&(u=!0,i=Z(s,[1,s.shape[0],s.shape[1],s.shape[2]])),R(i.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${i.rank}.`),Jt("avgPool",r,a);const l={x:i},c={filterSize:e,strides:t,pad:r,dimRoundingMode:a};let p=V.runKernel(ap,l,c);return p=je(p,s.dtype),u?Z(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const $f=P({avgPool_:n3});/** 1104 * @license 1105 * Copyright 2020 Google LLC. All Rights Reserved. 1106 * Licensed under the Apache License, Version 2.0 (the "License"); 1107 * you may not use this file except in compliance with the License. 1108 * You may obtain a copy of the License at 1109 * 1110 * http://www.apache.org/licenses/LICENSE-2.0 1111 * 1112 * Unless required by applicable law or agreed to in writing, softw
1112are 1113 * distributed under the License is distributed on an "AS IS" BASIS, 1114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1115 * See the License for the specific language governing permissions and 1116 * limitations under the License. 1117 * ============================================================================= 1118 */function r3(n,e,t,r,a,s="NDHWC"){const o=N(n,"x","avgPool3d","float32");let i=o,u=!1;o.rank===4&&(u=!0,i=Z(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),R(i.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`),R(s==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),Jt("avgPool3d",r,a);const l={x:i},c={filterSize:e,strides:t,pad:r,dimRoundingMode:a,dataFormat:s};let p=V.runKernel(sp,l,c);return p=je(p,i.dtype),u?Z(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const a3=P({avgPool3d_:r3});/** 1119 * @license 1120 * Copyright 2020 Google LLC. All Rights Reserved. 1121 * Licensed under the Apache License, Version 2.0 (the "License"); 1122 * you may not use this file except in compliance with the License. 1123 * You may obtain a copy of the License at 1124 * 1125 * http://www.apache.org/licenses/LICENSE-2.0 1126 * 1127 * Unless required by applicable law or agreed to in writing, software 1128 * distributed under the License is distributed on an "AS IS" BASIS, 1129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1130 * See the License for the specific language governing permissions and 1131 * limitations under the License. 1132 * ============================================================================= 1133 */function s3(n,e=0){R(n.length>=1,()=>"Pass at least one tensor to concat");const t=no(n,"tensors","concat","string_or_numeric");if(t[0].dtype==="complex64"&&t.forEach(s=>{if(s.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor 1134 with dtype ${s.dtype}. `)}),t.length===1)return Jn(t[0]);const r=t,a={axis:e};return V.runKernel(fp,r,a)}const it=P({concat_:s3});/** 1135 * @license 1136 * Copyright 2018 Google LLC. All Rights Reserved. 1137 * Licensed under the Apache License, Version 2.0 (the "License"); 1138 * you may not use this file except in compliance with the License. 1139 * You may obtain a copy of the License at 1140 * 1141 * http://www.apache.org/licenses/LICENSE-2.0 1142 * 1143 * Unless required by applicable law or agreed to in writing, software 1144 * distributed under the License is distributed on an "AS IS" BASIS, 1145 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1146 * See the License for the specific language governing permissions and 1147 * limitations under the License. 1148 * ============================================================================= 1149 */function o3(n){const e={x:N(n,"x","sigmoid","float32")};return V.runKernel(nd,e)}const Rr=P({sigmoid_:o3});/** 1150 * @license 1151 * Copyright 2018 Google LLC. All Rights Reserved. 1152 * Licensed under the Apache License, Version 2.0 (the "License"); 1153 * you may not use this file except in compliance with the License. 1154 * You may obtain a copy of the License at 1155 * 1156 * http://www.apache.org/licenses/LICENSE-2.0 1157 * 1158 * Unless required by applicable law or agreed to in writing, software 1159 * distributed under the License is distributed on an "AS IS" BASIS, 1160 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1161 * See the License for the specific language governing permissions and 1162 * limitations under the License. 1163 * ============================================================================= 1164 */function i3(n,e,t){const r=N(n,"x","slice","string_or_numeric");if(r.rank===0)throw new Error("Slicing scalar is not possible");const a={x:r},s={begin:e,size:t};return V.runKernel(Jh,a,s)}const we=P({slice_:i3});/** 1165 * @license 1166 * Copyright 2018 Google LLC. All Rights Reserved. 1167 * Licensed under the Apache License, Version 2.0 (the "License"); 1168 * you may not use this file except in compliance with the License. 1169 * You may obtain a copy of the License at 1170 * 1171 * http://www.apache.org/licenses/LICENSE-2.0 1172 * 1173 * Unless required by applicable law or agreed to in writing, softw
1173are 1174 * distributed under the License is distributed on an "AS IS" BASIS, 1175 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1176 * See the License for the specific language governing permissions and 1177 * limitations under the License. 1178 * ============================================================================= 1179 */function u3(n){const e={x:N(n,"x","tanh","float32")};return V.runKernel(wd,e)}const Ki=P({tanh_:u3});/** 1180 * @license 1181 * Copyright 2020 Google LLC. All Rights Reserved. 1182 * Licensed under the Apache License, Version 2.0 (the "License"); 1183 * you may not use this file except in compliance with the License. 1184 * You may obtain a copy of the License at 1185 * 1186 * http://www.apache.org/licenses/LICENSE-2.0 1187 * 1188 * Unless required by applicable law or agreed to in writing, software 1189 * distributed under the License is distributed on an "AS IS" BASIS, 1190 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1191 * See the License for the specific language governing permissions and 1192 * limitations under the License. 1193 * ============================================================================= 1194 */function l3(n,e,t,r,a,s){const o=N(n,"forgetBias","basicLSTMCell"),i=N(e,"lstmKernel","basicLSTMCell"),u=N(t,"lstmBias","basicLSTMCell"),l=N(r,"data","basicLSTMCell"),c=N(a,"c","basicLSTMCell"),p=N(s,"h","basicLSTMCell"),h=it([l,p],1),d=Oe(h,i),m=Pe(d,u),y=m.shape[0],b=m.shape[1]/4,x=[y,b],T=we(m,[0,0],x),$=we(m,[0,b],x),F=we(m,[0,b*2],x),M=we(m,[0,b*3],x),U=Pe(me(Rr(T),Ki($)),me(c,Rr(Pe(o,F)))),X=me(Ki(U),Rr(M));return[U,X]}const c3=P({basicLSTMCell_:l3});/** 1195 * @license 1196 * Copyright 2020 Google LLC. All Rights Reserved. 1197 * Licensed under the Apache License, Version 2.0 (the "License"); 1198 * you may not use this file except in compliance with the License. 1199 * You may obtain a copy of the License at 1200 * 1201 * http://www.apache.org/licenses/LICENSE-2.0 1202 * 1203 * Unless required by applicable law or agreed to in writing, software 1204 * distributed under the License is distributed on an "AS IS" BASIS, 1205 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1206 * See the License for the specific language governing permissions and 1207 * limitations under the License. 1208 * ============================================================================= 1209 */function p3(n,e,t){const r=N(n,"x","batchToSpaceND"),a=e.reduce((i,u)=>i*u);R(r.rank>=1+e.length,()=>`input rank is ${r.rank} but should be > than blockShape.length ${e.length}`),R(t.length===e.length,()=>`crops.length is ${t.length} but should be equal to blockShape.length ${e.length}`),R(r.shape[0]%a===0,()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${a}`);const s={x:r},o={blockShape:e,crops:t};return V.runKernel(ip,s,o)}const Rf=P({batchToSpaceND_:p3});function h3(n){let e;return n.rank===0||n.rank===1?e=Z(n,[1,1,1,n.size]):n.rank===2?e=Z(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?e=Z(n,[1,n.shape[0],n.shape[1],n.shape[2]]):e=n,e}/** 1210 * @license 1211 * Copyright 2020 Google LLC. All Rights Reserved. 1212 * Licensed under the Apache License, Version 2.0 (the "License"); 1213 * you may not use this file except in compliance with the License. 1214 * You may obtain a copy of the License at 1215 * 1216 * http://www.apache.org/licenses/LICENSE-2.0 1217 * 1218 * Unless required by applicable law or agreed to in writing, software 1219 * distributed under the License is distributed on an "AS IS" BASIS, 1220 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1221 * See the License for the specific language governing permissions and 1222 * limitations under the License. 1223 * ============================================================================= 1224 */function d3(n,e,t,r,a,s){s==null&&(s=.001);const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),u=N(t,"variance","batchNorm");let l;a!=null&&(l=N(a,"scale","batchNorm"));let c;r!=null&&(c=N(r,"offset","batchNorm")),R(i.rank===u.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),R(c==null||i.rank===c.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),R(l==null||i.rank===l.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const p={x:h3(o),scale:l,offset:c,mean:i,variance:u},h={varianceEpsilon:s},d=V.runKernel(jp,p,h);return Z(d,o.shape)}const To=P({batchNorm_:d3});function f3(n,e,t,r,a,s){const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),u=N(t,"variance","batchNorm");let l;a!=null&&(l=N(a,"scale","batchNorm"));let c;return r!=null&&(c=N(r,"offset","batchNorm")),R(o.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`),R(i.rank===2||i.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}
1224.`),R(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`),l!=null&&R(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`),c!=null&&R(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`),To(o,i,u,c,l,s)}const m3=P({batchNorm2d_:f3});function g3(n,e,t,r,a,s){const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),u=N(t,"variance","batchNorm");let l;a!=null&&(l=N(a,"scale","batchNorm"));let c;return r!=null&&(c=N(r,"offset","batchNorm")),R(o.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`),R(i.rank===3||i.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`),R(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`),l!=null&&R(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`),c!=null&&R(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`),To(o,i,u,c,l,s)}const y3=P({batchNorm3d_:g3});function x3(n,e,t,r,a,s){const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),u=N(t,"variance","batchNorm");let l;a!=null&&(l=N(a,"scale","batchNorm"));let c;return r!=null&&(c=N(r,"offset","batchNorm")),R(o.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`),R(i.rank===4||i.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`),R(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`),l!=null&&R(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`),c!=null&&R(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`),To(o,i,u,c,l,s)}const b3=P({batchNorm4d_:x3});/** 1225 * @license 1226 * Copyright 2020 Google LLC. All Rights Reserved. 1227 * Licensed under the Apache License, Version 2.0 (the "License"); 1228 * you may not use this file except in compliance with the License. 1229 * You may obtain a copy of the License at 1230 * 1231 * http://www.apache.org/licenses/LICENSE-2.0 1232 * 1233 * Unless required by applicable law or agreed to in writing, software 1234 * distributed under the License is distributed on an "AS IS" BASIS, 1235 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1236 * See the License for the specific language governing permissions and 1237 * limitations under the License. 1238 * ============================================================================= 1239 */function v3(n,e,t){const r=N(n,"x","bincount"),a=N(e,"weights","bincount");R(r.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`),R(t>=0,()=>`size must be non-negative, but got ${t}.`),R(a.size===r.size||a.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`);const s={x:r,weights:a},o={size:t};return V.runKernel(up,s,o)}const _f=P({bincount_:v3});/** 1240 * @license 1241 * Copyright 2021 Google LLC. All Rights Reserved. 1242 * Licensed under the Apache License, Version 2.0 (the "License"); 1243 * you may not use this file except in compliance with the License. 1244 * You may obtain a copy of the License at 1245 * 1246 * http://www.apache.org/licenses/LICENSE-2.0 1247 * 1248 * Unless required by applicable law or agreed to in writing, software 1249 * distributed under the License is distributed on an "AS IS" BASIS, 1250 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1251 * See the License for the specific language governing permissions and 1252 * limitations under the License. 1253 * ============================================================================= 1254 */function w3(n,e){const t=N(n,"s0","broadcastArgs","int32"),r=N(e,"s1","broadcastArgs","int32");if(t.rank!==1)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${t.rank}`);if(r.rank!==1)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:t,s1:r};return V.runKernel(lp,a)}const S3=P({broadcastArgs_:w3});/** 1255 * @license 1256 * Copyright 2020 Google LLC. All Rights Reserved. 1257 * Licensed under the Apache License, Version 2.0 (the "License");
1258 * you may not use this file except in compliance with the License. 1259 * You may obtain a copy of the License at 1260 * 1261 * http://www.apache.org/licenses/LICENSE-2.0 1262 * 1263 * Unless required by applicable law or agreed to in writing, software 1264 * distributed under the License is distributed on an "AS IS" BASIS, 1265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1266 * See the License for the specific language governing permissions and 1267 * limitations under the License. 1268 * ============================================================================= 1269 */function k3(n,e){let t=N(n,"broadcastTo","x");const r=t.shape;if(e.some(u=>!(u>0)||u%1!==0))throw new Error(`broadcastTo(): Invalid broadcast shape [${e}].`);if(e.length<t.rank)throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${t.rank}.`);if(e.length>t.rank){const u=t.shape.slice();for(;u.length<e.length;)u.unshift(1);t=Z(t,u)}const a=t.shape,s=Array.from(e);for(let u=e.length-1;u>=0;u--)if(a[u]===e[u])s[u]=1;else if(t.shape[u]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${e}].`);if(s.map((u,l)=>u>1?l:-1).filter(u=>u>=0).length===0)return Jn(t);const o={x:t},i={reps:s};return V.runKernel($u,o,i)}const Qa=P({broadcastTo_:k3});/** 1270 * @license 1271 * Copyright 2018 Google LLC. All Rights Reserved. 1272 * Licensed under the Apache License, Version 2.0 (the "License"); 1273 * you may not use this file except in compliance with the License. 1274 * You may obtain a copy of the License at 1275 * 1276 * http://www.apache.org/licenses/LICENSE-2.0 1277 * 1278 * Unless required by applicable law or agreed to in writing, software 1279 * distributed under the License is distributed on an "AS IS" BASIS, 1280 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1281 * See the License for the specific language governing permissions and 1282 * limitations under the License. 1283 * ============================================================================= 1284 */function T3(n){const e={x:N(n,"x","ceil","float32")};return V.runKernel(cp,e)}const E3=P({ceil_:T3});/** 1285 * @license 1286 * Copyright 2020 Google LLC. All Rights Reserved. 1287 * Licensed under the Apache License, Version 2.0 (the "License"); 1288 * you may not use this file except in compliance with the License. 1289 * You may obtain a copy of the License at 1290 * 1291 * http://www.apache.org/licenses/LICENSE-2.0 1292 * 1293 * Unless required by applicable law or agreed to in writing, software 1294 * distributed under the License is distributed on an "AS IS" BASIS, 1295 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1296 * See the License for the specific language governing permissions and 1297 * limitations under the License. 1298 * ============================================================================= 1299 */function Eo(n,e,t){const r={shape:n,value:e,dtype:t};return V.runKernel(Vp,{},r)}/** 1300 * @license 1301 * Copyright 2018 Google LLC. All Rights Reserved. 1302 * Licensed under the Apache License, Version 2.0 (the "License"); 1303 * you may not use this file except in compliance with the License. 1304 * You may obtain a copy of the License at 1305 * 1306 * http://www.apache.org/licenses/LICENSE-2.0 1307 * 1308 * Unless required by applicable law or agreed to in writing, software 1309 * distributed under the License is distributed on an "AS IS" BASIS, 1310 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1311 * See the License for the specific language governing permissions and 1312 * limitations under the License. 1313 * ============================================================================= 1314 */function C3(n,e,t){const r=N(n,"x","clipByValue");if(R(e<=t,()=>`Error in clip: min (${e}) must be less than or equal to max (${t}).`),e===t)return Eo(r.shape,e,r.dtype);const a={x:r},s={clipValueMin:e,clipValueMax:t};return V.runKernel(pp,a,s)}const Af=P({clipByValue_:C3});function I3(n){return it(n,0)}const N3=P({concat1d_:I3});function $3(n,e){return it(n,e)}const R3=P({concat2d_:$3});function _3(n,e){return it(n,e)}const A3=P({concat3d_:_3});function O3(n,e){return it(n,e)}const F3=P({concat4d_:O3});/** 1315 * @license 1316 * Copyright 2020 Google LLC. All Rights Reserved. 1317 * Licensed under the Apache License, Version 2.0 (the "License");
1318 * you may not use this file except in compliance with the License. 1319 * You may obtain a copy of the License at 1320 * 1321 * http://www.apache.org/licenses/LICENSE-2.0 1322 * 1323 * Unless required by applicable law or agreed to in writing, software 1324 * distributed under the License is distributed on an "AS IS" BASIS, 1325 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1326 * See the License for the specific language governing permissions and 1327 * limitations under the License. 1328 * ============================================================================= 1329 */function D3(n,e,t,r,a="NHWC",s=[1,1],o){const i=N(n,"x","conv2d","float32"),u=N(e,"filter","conv2d","float32");let l=i,c=!1;i.rank===3&&(c=!0,l=Z(i,[1,i.shape[0],i.shape[1],i.shape[2]])),R(l.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`),R(u.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${u.rank}.`),Jt("conv2d",r,o);const p=a==="NHWC"?l.shape[3]:l.shape[1];R(p===u.shape[2],()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${u.shape[2]}.`),R(_t(t,s),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${s}'`);const h={x:l,filter:u},d={strides:t,pad:r,dataFormat:a,dilations:s,dimRoundingMode:o},m=V.runKernel(mp,h,d);return c?Z(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const Co=P({conv2d_:D3});function M3(n,e,t,r,a="NWC",s=1,o){const i=N(n,"x","conv1d"),u=N(e,"filter","conv1d");let l=i,c=!1;i.rank===2&&(c=!0,l=Z(i,[1,i.shape[0],i.shape[1]])),R(l.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`),R(u.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${u.rank}.`),Jt("conv1d",r,o),R(l.shape[2]===u.shape[1],()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${u.shape[1]}.`),R(_t(t,s),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${t} and dilation '${s}'`),R(a==="NWC",()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`);const p=Z(u,[1,u.shape[0],u.shape[1],u.shape[2]]),h=Z(l,[l.shape[0],1,l.shape[1],l.shape[2]]),d=Co(h,p,[1,t],r,"NHWC",[1,s],o);return c?Z(d,[d.shape[2],d.shape[3]]):Z(d,[d.shape[0],d.shape[2],d.shape[3]])}const L3=P({conv1d_:M3});/** 1330 * @license 1331 * Copyright 2020 Google LLC. All Rights Reserved. 1332 * Licensed under the Apache License, Version 2.0 (the "License"); 1333 * you may not use this file except in compliance with the License. 1334 * You may obtain a copy of the License at 1335 * 1336 * http://www.apache.org/licenses/LICENSE-2.0 1337 * 1338 * Unless required by applicable law or agreed to in writing, software 1339 * distributed under the License is distributed on an "AS IS" BASIS, 1340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1341 * See the License for the specific language governing permissions and 1342 * limitations under the License. 1343 * ============================================================================= 1344 */function P3(n,e,t,r,a,s="NHWC",o){R(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let i=n,u=e,l=!1;e.rank===3&&(l=!0,u=Z(e,[1,e.shape[0],e.shape[1],e.shape[2]]),i=[1,n[0],n[1],n[2]]),R(i.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`),R(u.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${u.rank}`),R(t.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${t.rank}`);const c=s==="NHWC"?i[3]:i[1],p=s==="NHWC"?u.shape[3]:u.shape[1];R(c===t.shape[2],()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${t.shape[2]}.`),R(p===t.shape[3],()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${t.shape[3]}.`),Jt("conv2dDerInput",a,o);const h={dy:u,filter:t},d={strides:r,pad:a,dataFormat:s,dimRoundingMode:o,inputShape:i},m=V.runKernel(yp,h,d);return l?Z(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const Of=P({conv2DBackpropInput_:P3});function B3(n,e,t,r,a,s){const o=N(n,"x","conv2dTranspose"),i=N(e,"filter","conv2dTranspose");return Of(t,o,i,r,a,"NHWC",s)}const U3=P({conv2dTranspose_:B3});/** 1345 * @license 1346 * Copyright 2020 Google LLC. All Rights Reserved. 1347 * Licensed under the Apache License, Version 2.0 (the "License");
1348 * you may not use this file except in compliance with the License. 1349 * You may obtain a copy of the License at 1350 * 1351 * http://www.apache.org/licenses/LICENSE-2.0 1352 * 1353 * Unless required by applicable law or agreed to in writing, software 1354 * distributed under the License is distributed on an "AS IS" BASIS, 1355 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1356 * See the License for the specific language governing permissions and 1357 * limitations under the License. 1358 * ============================================================================= 1359 */function V3(n,e,t,r,a="NDHWC",s=[1,1,1]){const o=N(n,"x","conv3d"),i=N(e,"filter","conv3d");let u=o,l=!1;o.rank===4&&(l=!0,u=Z(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),R(u.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${u.rank}.`),R(i.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`),R(u.shape[4]===i.shape[3],()=>`Error in conv3d: depth of input (${u.shape[4]}) must match input depth for filter ${i.shape[3]}.`),R(_t(t,s),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${t} and dilations '${s}'`),R(a==="NDHWC",()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`);const c={x:u,filter:i},p={strides:t,pad:r,dataFormat:a,dilations:s},h=V.runKernel(xp,c,p);return l?Z(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const W3=P({conv3d_:V3});/** 1360 * @license 1361 * Copyright 2020 Google LLC. All Rights Reserved. 1362 * Licensed under the Apache License, Version 2.0 (the "License"); 1363 * you may not use this file except in compliance with the License. 1364 * You may obtain a copy of the License at 1365 * 1366 * http://www.apache.org/licenses/LICENSE-2.0 1367 * 1368 * Unless required by applicable law or agreed to in writing, software 1369 * distributed under the License is distributed on an "AS IS" BASIS, 1370 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1371 * See the License for the specific language governing permissions and 1372 * limitations under the License. 1373 * ============================================================================= 1374 */function z3(n,e,t,r,a){R(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let s=n,o=e,i=!1;e.rank===4&&(i=!0,o=Z(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),s=[1,n[0],n[1],n[2],n[3]]);const u=s[4],l=o.shape[4];R(s.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${s.length}.`),R(o.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`),R(t.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${t.rank}`),R(u===t.shape[3],()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${t.shape[3]}.`),R(l===t.shape[4],()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${t.shape[4]}.`);const c={dy:o,filter:t},p={pad:a,strides:r,inputShape:s},h=V.runKernel(bp,c,p);return i?Z(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const G3=P({conv3DBackpropInput_:z3});function j3(n,e,t,r,a){const s=N(n,"x","conv3dTranspose"),o=N(e,"filter","conv3dTranspose");return G3(t,s,o,r,a)}const H3=P({conv3dTranspose_:j3});/** 1375 * @license 1376 * Copyright 2018 Google LLC. All Rights Reserved. 1377 * Licensed under the Apache License, Version 2.0 (the "License"); 1378 * you may not use this file except in compliance with the License. 1379 * You may obtain a copy of the License at 1380 * 1381 * http://www.apache.org/licenses/LICENSE-2.0 1382 * 1383 * Unless required by applicable law or agreed to in writing, software 1384 * distributed under the License is distributed on an "AS IS" BASIS, 1385 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1386 * See the License for the specific language governing permissions and 1387 * limitations under the License. 1388 * ============================================================================= 1389 */function X3(n){const e={x:N(n,"x","cos","float32")};return V.runKernel(vp,e)}const q3=P({cos_:X3});/** 1390 * @license 1391 * Copyright 2018 Google LLC. All Rights Reserved. 1392 * Licensed under the Apache License, Version 2.0 (the "License");
1393 * you may not use this file except in compliance with the License. 1394 * You may obtain a copy of the License at 1395 * 1396 * http://www.apache.org/licenses/LICENSE-2.0 1397 * 1398 * Unless required by applicable law or agreed to in writing, software 1399 * distributed under the License is distributed on an "AS IS" BASIS, 1400 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1401 * See the License for the specific language governing permissions and 1402 * limitations under the License. 1403 * ============================================================================= 1404 */function K3(n){const e={x:N(n,"x","cosh","float32")};return V.runKernel(wp,e)}const Y3=P({cosh_:K3});/** 1405 * @license 1406 * Copyright 2022 Google LLC. All Rights Reserved. 1407 * Licensed under the Apache License, Version 2.0 (the 'License'); 1408 * you may not use this file except in compliance with the License. 1409 * You may obtain a copy of the License at 1410 * 1411 * http://www.apache.org/licenses/LICENSE-2.0 1412 * 1413 * Unless required by applicable law or agreed to in writing, software 1414 * distributed under the License is distributed on an 'AS IS' BASIS, 1415 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1416 * See the License for the specific language governing permissions and 1417 * limitations under the License. 1418 * ============================================================================= 1419 */function Z3(n,e=0,t=!1,r=!1){const a={x:N(n,"x","cumprod")},s={axis:e,exclusive:t,reverse:r};return V.runKernel(Sp,a,s)}const J3=P({cumprod_:Z3});/** 1420 * @license 1421 * Copyright 2018 Google LLC. All Rights Reserved. 1422 * Licensed under the Apache License, Version 2.0 (the "License"); 1423 * you may not use this file except in compliance with the License. 1424 * You may obtain a copy of the License at 1425 * 1426 * http://www.apache.org/licenses/LICENSE-2.0 1427 * 1428 * Unless required by applicable law or agreed to in writing, software 1429 * distributed under the License is distributed on an "AS IS" BASIS, 1430 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1431 * See the License for the specific language governing permissions and 1432 * limitations under the License. 1433 * ============================================================================= 1434 */function Q3(n,e=0,t=!1,r=!1){const a={x:N(n,"x","cumsum")},s={axis:e,exclusive:t,reverse:r};return V.runKernel(kp,a,s)}const ey=P({cumsum_:Q3});/** 1435 * @license 1436 * Copyright 2020 Google LLC. All Rights Reserved. 1437 * Licensed under the Apache License, Version 2.0 (the "License"); 1438 * you may not use this file except in compliance with the License. 1439 * You may obtain a copy of the License at 1440 * 1441 * http://www.apache.org/licenses/LICENSE-2.0 1442 * 1443 * Unless required by applicable law or agreed to in writing, software 1444 * distributed under the License is distributed on an "AS IS" BASIS, 1445 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1446 * See the License for the specific language governing permissions and 1447 * limitations under the License. 1448 * ============================================================================= 1449 */function ty(n,e,t,r=!1){const a=N(n,"x","denseBincount"),s=N(e,"weights","denseBincount");R(a.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`),R(a.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`),R(t>=0,()=>`size must be non-negative, but got ${t}.`),R(s.size===a.size||s.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${s.shape}.`);const o={x:a,weights:s},i={size:t,binaryOutput:r};return V.runKernel(Ep,o,i)}const ny=P({denseBincount_:ty});/** 1450 * @license 1451 * Copyright 2020 Google LLC. All Rights Reserved. 1452 * Licensed under the Apache License, Version 2.0 (the "License"); 1453 * you may not use this file except in compliance with the License. 1454 * You may obtain a copy of the License at 1455 * 1456 * http://www.apache.org/licenses/LICENSE-2.0 1457 * 1458 * Unless required by applicable law or agreed to in writing, software 1459 * distributed under the License is distributed on an "AS IS" BASIS, 1460 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1461 * See the License for the specific language governing permissions and 1462 * limitations under the License. 1463 * ============================================================================= 1464 */function ry(n,e,t="NHWC"){const r=N(n,"x","depthToSpace","float32"),a=t==="NHWC"?r.shape[1]:r.shape[2],s=t==="NHWC"?r.shape[2]:r.shape[3],o=t==="NHWC"?r.shape[3]:r.shape[1];R(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),R(a*e>=0,()=>
vendor: 4,255 bytes, lines 1464-1516
1464`Negative dimension size caused by overflow when multiplying 1465 ${a} and ${e} for depthToSpace with input shape 1466 ${r.shape}`),R(s*e>=0,()=>`Negative dimension size caused by overflow when multiplying 1467 ${s} and ${e} for depthToSpace with input shape 1468 ${r.shape}`),R(o%(e*e)===0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${o} for depthToSpace with input shape ${r.shape}`);const i={x:r},u={blockSize:e,dataFormat:t};return V.runKernel(Cp,i,u)}const ay=P({depthToSpace_:ry});/** 1469 * @license 1470 * Copyright 2020 Google LLC. All Rights Reserved. 1471 * Licensed under the Apache License, Version 2.0 (the "License"); 1472 * you may not use this file except in compliance with the License. 1473 * You may obtain a copy of the License at 1474 * 1475 * http://www.apache.org/licenses/LICENSE-2.0 1476 * 1477 * Unless required by applicable law or agreed to in writing, software 1478 * distributed under the License is distributed on an "AS IS" BASIS, 1479 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1480 * See the License for the specific language governing permissions and 1481 * limitations under the License. 1482 * ============================================================================= 1483 */function sy(n,e,t,r,a="NHWC",s=[1,1],o){const i=N(n,"x","depthwiseConv2d","float32"),u=N(e,"filter","depthwiseConv2d","float32");let l=i,c=!1;i.rank===3&&(c=!0,l=Z(i,[1,i.shape[0],i.shape[1],i.shape[2]])),R(l.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`),R(u.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${u.rank}.`);const p=a==="NHWC"?l.shape[3]:l.shape[1];R(p===u.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${u.shape[2]}.`),Jt("depthwiseConv2d",r,o);const h={x:l,filter:u},d={strides:t,pad:r,dataFormat:a,dilations:s,dimRoundingMode:o},m=V.runKernel(Ip,h,d);return c?Z(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const Uu=P({depthwiseConv2d_:sy});/** 1484 * @license 1485 * Copyright 2020 Google LLC. All Rights Reserved. 1486 * Licensed under the Apache License, Version 2.0 (the "License"); 1487 * you may not use this file except in compliance with the License. 1488 * You may obtain a copy of the License at 1489 * 1490 * http://www.apache.org/licenses/LICENSE-2.0 1491 * 1492 * Unless required by applicable law or agreed to in writing, software 1493 * distributed under the License is distributed on an "AS IS" BASIS, 1494 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1495 * See the License for the specific language governing permissions and 1496 * limitations under the License. 1497 * ============================================================================= 1498 */function oy(n){const e={x:N(n,"x","diag")};return V.runKernel(Rp,e)}const iy=P({diag_:oy});/** 1499 * @license 1500 * Copyright 2020 Google LLC. All Rights Reserved. 1501 * Licensed under the Apache License, Version 2.0 (the "License"); 1502 * you may not use this file except in compliance with the License. 1503 * You may obtain a copy of the License at 1504 * 1505 * http://www.apache.org/licenses/LICENSE-2.0 1506 * 1507 * Unless required by applicable law or agreed to in writing, software 1508 * distributed under the License is distributed on an "AS IS" BASIS, 1509 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1510 * See the License for the specific language governing permissions and 1511 * limitations under the License. 1512 * ============================================================================= 1513 */function uy(n,e,t,r,a=[1,1],s="NHWC"){const o=N(n,"x","dilation2d"),i=N(e,"filter","dilation2d");R(o.rank===3||o.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`),R(i.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`),R(s==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${s}`);let u=o,l=!1;o.rank===3&&(u=Z(o,[1,o.shape[0],o.shape[1],o.shape[2]]),l=!0);const c={x:u,filter:i},p={strides:t,pad:r,dilations:a},h=V.runKernel(_p,c,p);return l?Z(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const ly=P({dilation2d_:uy});/** 1514 * @license 1515 * Copyright 2020 Google LLC. All Rights Reserved. 1516 * Licensed under the Apache License, Version 2.0 (the "License");
1517 * you may not use this file except in compliance with the License. 1518 * You may obtain a copy of the License at 1519 * 1520 * http://www.apache.org/licenses/LICENSE-2.0 1521 * 1522 * Unless required by applicable law or agreed to in writing, software 1523 * distributed under the License is distributed on an "AS IS" BASIS, 1524 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1525 * See the License for the specific language governing permissions and 1526 * limitations under the License. 1527 * ============================================================================= 1528 */function cy(n,e){let t=N(n,"a","equal","string_or_numeric"),r=N(e,"b","equal","string_or_numeric");[t,r]=Ke(t,r),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(Mp,a)}const Ff=P({equal_:cy});/** 1529 * @license 1530 * Copyright 2020 Google LLC. All Rights Reserved. 1531 * Licensed under the Apache License, Version 2.0 (the "License"); 1532 * you may not use this file except in compliance with the License. 1533 * You may obtain a copy of the License at 1534 * 1535 * http://www.apache.org/licenses/LICENSE-2.0 1536 * 1537 * Unless required by applicable law or agreed to in writing, software 1538 * distributed under the License is distributed on an "AS IS" BASIS, 1539 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1540 * See the License for the specific language governing permissions and 1541 * limitations under the License. 1542 * ============================================================================= 1543 */function py(n,e,t){const r=N(e,"a","where"),a=N(t,"b","where"),s=N(n,"condition","where","bool"),o=$e($e(s.shape,r.shape),a.shape),i=Qa(s,o),u=Qa(r,o),l=Qa(a,o),c={condition:i,t:u,e:l};return V.runKernel(Yh,c)}const ha=P({where_:py});/** 1544 * @license 1545 * Copyright 2018 Google LLC. All Rights Reserved. 1546 * Licensed under the Apache License, Version 2.0 (the "License"); 1547 * you may not use this file except in compliance with the License. 1548 * You may obtain a copy of the License at 1549 * 1550 * http://www.apache.org/licenses/LICENSE-2.0 1551 * 1552 * Unless required by applicable law or agreed to in writing, software 1553 * distributed under the License is distributed on an "AS IS" BASIS, 1554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1555 * See the License for the specific language governing permissions and 1556 * limitations under the License. 1557 * ============================================================================= 1558 */function hy(n){const e={x:N(n,"x","zerosLike")};return V.runKernel(Id,e)}const Vu=P({zerosLike_:hy});/** 1559 * @license 1560 * Copyright 2020 Google LLC. All Rights Reserved. 1561 * Licensed under the Apache License, Version 2.0 (the "License"); 1562 * you may not use this file except in compliance with the License. 1563 * You may obtain a copy of the License at 1564 * 1565 * http://www.apache.org/licenses/LICENSE-2.0 1566 * 1567 * Unless required by applicable law or agreed to in writing, software 1568 * distributed under the License is distributed on an "AS IS" BASIS, 1569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1570 * See the License for the specific language governing permissions and 1571 * limitations under the License. 1572 * ============================================================================= 1573 */function dy(n,e){let t=N(n,"a","div"),r=N(e,"b","div");[t,r]=Ke(t,r);const a=De(t,r),s=Vu(a),o=Ff(r,s);return ha(o,s,a)}const fy=P({divNoNan_:dy});/** 1574 * @license 1575 * Copyright 2020 Google LLC. All Rights Reserved. 1576 * Licensed under the Apache License, Version 2.0 (the "License"); 1577 * you may not use this file except in compliance with the License. 1578 * You may obtain a copy of the License at 1579 * 1580 * http://www.apache.org/licenses/LICENSE-2.0 1581 * 1582 * Unless required by applicable law or agreed to in writing, software 1583 * distributed under the License is distributed on an "AS IS" BASIS, 1584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1585 * See the License for the specific language governing permissions and 1586 * limitations under the License. 1587 * ============================================================================= 1588 */function my(n,e){const t=N(n,"t1","dot"),r=N(e,"t2","dot");R((t.rank===1||t.rank===2)&&(r.rank===1||r.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${t.rank} and ${r.rank}.`);const a=t.rank===1?t.size:t.shape[1],s=r.rank===1?r.size:r.shape[0];if(R(a===s,()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${s}.`),t.rank===1&&r.rank===1){const o=Z(t,[1,-1]),i=Z(r,[-1,1]),u=Oe(o,i);return Z(u,[])}else if(t.rank===1&&r.rank===2){const o=Z(t,[1,-1]),i=Z(r,[r.shape[0],r.shape[1]]),u=Oe(o,i);return Z(u,[u.size])}else if(t.rank===2&&r.rank===1){const o=Z(r,[-1,1]),i=Oe(t,o);return Z(i,[i.size])}else{const o=Z(r,[r.shape[0],r.shape[1]]);return Oe(t,o)}}const gy=P({dot_:my});/** 1589 * @license 1590 * Copyright 2021 Google LLC. All Rights Reserved. 1591 * Licensed under the Apache License, Version 2.0 (the "License");
1592 * you may not use this file except in compliance with the License. 1593 * You may obtain a copy of the License at 1594 * 1595 * http://www.apache.org/licenses/LICENSE-2.0 1596 * 1597 * Unless required by applicable law or agreed to in writing, software 1598 * distributed under the License is distributed on an "AS IS" BASIS, 1599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1600 * See the License for the specific language governing permissions and 1601 * limitations under the License. 1602 * ============================================================================= 1603 */function yy(n,...e){const t=e.map((a,s)=>N(a,`tensors${s}`,"einsum")),r={equation:n};return V.runKernel(Op,t,r)}const xy=P({einsum_:yy});/** 1604 * @license 1605 * Copyright 2020 Google LLC. All Rights Reserved. 1606 * Licensed under the Apache License, Version 2.0 (the "License"); 1607 * you may not use this file except in compliance with the License. 1608 * You may obtain a copy of the License at 1609 * 1610 * http://www.apache.org/licenses/LICENSE-2.0 1611 * 1612 * Unless required by applicable law or agreed to in writing, software 1613 * distributed under the License is distributed on an "AS IS" BASIS, 1614 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1615 * See the License for the specific language governing permissions and 1616 * limitations under the License. 1617 * ============================================================================= 1618 */function by(n){const e={x:N(n,"x","elu","float32")};return V.runKernel(Fp,e)}const Df=P({elu_:by});/** 1619 * @license 1620 * Copyright 2018 Google LLC. All Rights Reserved. 1621 * Licensed under the Apache License, Version 2.0 (the "License"); 1622 * you may not use this file except in compliance with the License. 1623 * You may obtain a copy of the License at 1624 * 1625 * http://www.apache.org/licenses/LICENSE-2.0 1626 * 1627 * Unless required by applicable law or agreed to in writing, software 1628 * distributed under the License is distributed on an "AS IS" BASIS, 1629 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1630 * See the License for the specific language governing permissions and 1631 * limitations under the License. 1632 * ============================================================================= 1633 */function vy(n){let e=N(n,"x","erf");R(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=je(e,"float32"));const t={x:e};return V.runKernel(Dp,t)}const wy=P({erf_:vy});/** 1634 * @license 1635 * Copyright 2017 Google LLC. All Rights Reserved. 1636 * Licensed under the Apache License, Version 2.0 (the "License"); 1637 * you may not use this file except in compliance with the License. 1638 * You may obtain a copy of the License at 1639 * 1640 * http://www.apache.org/licenses/LICENSE-2.0 1641 * 1642 * Unless required by applicable law or agreed to in writing, software 1643 * distributed under the License is distributed on an "AS IS" BASIS, 1644 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1645 * See the License for the specific language governing permissions and 1646 * limitations under the License. 1647 * ============================================================================= 1648 */function Wu(n,e){for(let t=0;t<n.length;++t)if(n[n.length-t-1]!==e-1-t)return!1;return!0}function Mf(n,e,t){const r=n.length+e.length,a=[];let s=0,o=0;for(let i=0;i<r;i++)t.indexOf(i)===-1?a.push(n[s++]):a.push(e[o++]);return a}function kn(n,e){const t=[],r=n.length;for(let s=0;s<r;s++)e.indexOf(s)===-1&&t.push(n[s]);const a=e.map(s=>n[s]);return[t,a]}function Bt(n,e){const t=e.map(r=>1);return Mf(n,t,e)}function hn(n,e,t){R(Wu(e,t),()=>`${n} supports only inner-most axes for now. Got axes ${e} and rank-${t} input.`)}function Qt(n,e){if(Wu(n,e))return null;const t=[];for(let r=0;r<e;++r)n.indexOf(r)===-1&&t.push(r);return n.forEach(r=>t.push(r)),t}function zu(n){return n.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function en(n,e){const t=[];for(let r=e-n;r<e;++r)t.push(r);return t}/** 1649 * @license 1650 * Copyright 2020 Google LLC. All Rights Reserved. 1651 * Licensed under the Apache License, Version 2.0 (the "License"); 1652 * you may not use this file except in compliance with the License. 1653 * You may obtain a copy of the License at 1654 * 1655 * http://www.apache.org/licenses/LICENSE-2.0 1656 * 1657 * Unless required by applicable law or agreed to in writing, softw
1657are 1658 * distributed under the License is distributed on an "AS IS" BASIS, 1659 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1660 * See the License for the specific language governing permissions and 1661 * limitations under the License. 1662 * ============================================================================= 1663 */function Sy(n,e=null,t=!1){const r={x:N(n,"x","max")},a={reductionIndices:e,keepDims:t};return V.runKernel(ph,r,a)}const oa=P({max_:Sy});/** 1664 * @license 1665 * Copyright 2020 Google Inc. All Rights Reserved. 1666 * Licensed under the Apache License, Version 2.0 (the "License"); 1667 * you may not use this file except in compliance with the License. 1668 * You may obtain a copy of the License at 1669 * 1670 * http://www.apache.org/licenses/LICENSE-2.0 1671 * 1672 * Unless required by applicable law or agreed to in writing, software 1673 * distributed under the License is distributed on an "AS IS" BASIS, 1674 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1675 * See the License for the specific language governing permissions and 1676 * limitations under the License. 1677 * ============================================================================= 1678 */function ky(n,e=null,t=!1){const r={x:N(n,"x","min")},a={axis:e,keepDims:t};return V.runKernel(yh,r,a)}const Yi=P({min_:ky});/** 1679 * @license 1680 * Copyright 2020 Google LLC. All Rights Reserved. 1681 * Licensed under the Apache License, Version 2.0 (the "License"); 1682 * you may not use this file except in compliance with the License. 1683 * You may obtain a copy of the License at 1684 * 1685 * http://www.apache.org/licenses/LICENSE-2.0 1686 * 1687 * Unless required by applicable law or agreed to in writing, software 1688 * distributed under the License is distributed on an "AS IS" BASIS, 1689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1690 * See the License for the specific language governing permissions and 1691 * limitations under the License. 1692 * ============================================================================= 1693 */function Ty(n,e){let t=N(n,"base","pow"),r=N(e,"exp","pow");[t,r]=Ke(t,r);const a={a:t,b:r};return V.runKernel(Ah,a)}const Gu=P({pow_:Ty});/** 1694 * @license 1695 * Copyright 2018 Google LLC. All Rights Reserved. 1696 * Licensed under the Apache License, Version 2.0 (the "License"); 1697 * you may not use this file except in compliance with the License. 1698 * You may obtain a copy of the License at 1699 * 1700 * http://www.apache.org/licenses/LICENSE-2.0 1701 * 1702 * Unless required by applicable law or agreed to in writing, software 1703 * distributed under the License is distributed on an "AS IS" BASIS, 1704 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1705 * See the License for the specific language governing permissions and 1706 * limitations under the License. 1707 * ============================================================================= 1708 */function Ae(n,e){if((wn(n)&&e!=="string"||Array.isArray(n))&&e!=="complex64")throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if(e==="string"&&wn(n)&&!(n instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return sr(n,[],[],e)}/** 1709 * @license 1710 * Copyright 2018 Google LLC. All Rights Reserved. 1711 * Licensed under the Apache License, Version 2.0 (the "License"); 1712 * you may not use this file except in compliance with the License. 1713 * You may obtain a copy of the License at 1714 * 1715 * http://www.apache.org/licenses/LICENSE-2.0 1716 * 1717 * Unless required by applicable law or agreed to in writing, software 1718 * distributed under the License is distributed on an "AS IS" BASIS, 1719 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1720 * See the License for the specific language governing permissions and 1721 * limitations under the License. 1722 * ============================================================================= 1723 */function Ey(n){const e={x:N(n,"x","sqrt","float32")};return V.runKernel(ad,e)}const Zi=P({sqrt_:Ey});/** 1724 * @license 1725 * Copyright 2019 Google LLC. All Rights Reserved. 1726 * Licensed under the Apache License, Version 2.0 (the "License");
1727 * you may not use this file except in compliance with the License. 1728 * You may obtain a copy of the License at 1729 * 1730 * http://www.apache.org/licenses/LICENSE-2.0 1731 * 1732 * Unless required by applicable law or agreed to in writing, software 1733 * distributed under the License is distributed on an "AS IS" BASIS, 1734 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1735 * See the License for the specific language governing permissions and 1736 * limitations under the License. 1737 * ============================================================================= 1738 */function Cy(n){const e=N(n,"x","square"),t={};return V.runKernel("Square",{x:e},t)}const Io=P({square_:Cy});/** 1739 * @license 1740 * Copyright 2018 Google LLC. All Rights Reserved. 1741 * Licensed under the Apache License, Version 2.0 (the "License"); 1742 * you may not use this file except in compliance with the License. 1743 * You may obtain a copy of the License at 1744 * 1745 * http://www.apache.org/licenses/LICENSE-2.0 1746 * 1747 * Unless required by applicable law or agreed to in writing, software 1748 * distributed under the License is distributed on an "AS IS" BASIS, 1749 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1750 * See the License for the specific language governing permissions and 1751 * limitations under the License. 1752 * ============================================================================= 1753 */function Iy(n,e=null,t=!1){let r=N(n,"x","sum");r.dtype==="bool"&&(r=je(r,"int32"));const a={x:r},s={axis:e,keepDims:t};return V.runKernel(sd,a,s)}const Ve=P({sum_:Iy});/** 1754 * @license 1755 * Copyright 2018 Google LLC. All Rights Reserved. 1756 * Licensed under the Apache License, Version 2.0 (the "License"); 1757 * you may not use this file except in compliance with the License. 1758 * You may obtain a copy of the License at 1759 * 1760 * http://www.apache.org/licenses/LICENSE-2.0 1761 * 1762 * Unless required by applicable law or agreed to in writing, software 1763 * distributed under the License is distributed on an "AS IS" BASIS, 1764 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1765 * See the License for the specific language governing permissions and 1766 * limitations under the License. 1767 * ============================================================================= 1768 */function Ny(n,e="euclidean",t=null,r=!1){n=N(n,"x","norm");const a=Lf(n,e,t);let s=a.shape;if(r){const o=rt(t,n.shape);s=Bt(a.shape,o)}return Z(a,s)}function Lf(n,e,t=null){if(n.rank===0)return Kt(n);if(n.rank!==1&&t===null)return Lf(Z(n,[-1]),e,t);if(n.rank===1||typeof t=="number"||Array.isArray(t)&&t.length===1){if(e===1)return Ve(Kt(n),t);if(e===1/0)return oa(Kt(n),t);
vendor: 4,154 bytes, lines 1768-1837
1768if(e===-1/0)return Yi(Kt(n),t);if(e==="euclidean"||e===2)return Zi(Ve(Gu(Kt(n),Ae(2,"int32")),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}if(Array.isArray(t)&&t.length===2){if(e===1)return oa(Ve(Kt(n),t[0]),t[1]-1);if(e===1/0)return oa(Ve(Kt(n),t[1]),t[0]);if(e===-1/0)return Yi(Ve(Kt(n),t[1]),t[0]);if(e==="fro"||e==="euclidean")return Zi(Ve(Io(n),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}throw new Error(`Error in norm: invalid axis: ${t}`)}const No=P({norm_:Ny});/** 1769 * @license 1770 * Copyright 2022 Google LLC. All Rights Reserved. 1771 * Licensed under the Apache License, Version 2.0 (the "License"); 1772 * you may not use this file except in compliance with the License. 1773 * You may obtain a copy of the License at 1774 * 1775 * http://www.apache.org/licenses/LICENSE-2.0 1776 * 1777 * Unless required by applicable law or agreed to in writing, software 1778 * distributed under the License is distributed on an "AS IS" BASIS, 1779 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1780 * See the License for the specific language governing permissions and 1781 * limitations under the License. 1782 * ============================================================================= 1783 */function $y(n,e=null,t=!1){return No(n,"euclidean",e,t)}const Ry=P({euclideanNorm_:$y});/** 1784 * @license 1785 * Copyright 2018 Google LLC. All Rights Reserved. 1786 * Licensed under the Apache License, Version 2.0 (the "License"); 1787 * you may not use this file except in compliance with the License. 1788 * You may obtain a copy of the License at 1789 * 1790 * http://www.apache.org/licenses/LICENSE-2.0 1791 * 1792 * Unless required by applicable law or agreed to in writing, software 1793 * distributed under the License is distributed on an "AS IS" BASIS, 1794 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1795 * See the License for the specific language governing permissions and 1796 * limitations under the License. 1797 * ============================================================================= 1798 */function _y(n){const e={x:N(n,"x","exp")};return V.runKernel(Lp,e)}const Fn=P({exp_:_y});/** 1799 * @license 1800 * Copyright 2020 Google LLC. All Rights Reserved. 1801 * Licensed under the Apache License, Version 2.0 (the "License"); 1802 * you may not use this file except in compliance with the License. 1803 * You may obtain a copy of the License at 1804 * 1805 * http://www.apache.org/licenses/LICENSE-2.0 1806 * 1807 * Unless required by applicable law or agreed to in writing, software 1808 * distributed under the License is distributed on an "AS IS" BASIS, 1809 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1810 * See the License for the specific language governing permissions and 1811 * limitations under the License. 1812 * ============================================================================= 1813 */function Ay(n,e=0){const t=N(n,"x","expandDims","string_or_numeric");R(e<=t.rank,()=>"Axis must be <= rank of the tensor");const r={input:t},a={dim:e};return V.runKernel(Pp,r,a)}const on=P({expandDims_:Ay});/** 1814 * @license 1815 * Copyright 2018 Google LLC. All Rights Reserved. 1816 * Licensed under the Apache License, Version 2.0 (the "License"); 1817 * you may not use this file except in compliance with the License. 1818 * You may obtain a copy of the License at 1819 * 1820 * http://www.apache.org/licenses/LICENSE-2.0 1821 * 1822 * Unless required by applicable law or agreed to in writing, software 1823 * distributed under the License is distributed on an "AS IS" BASIS, 1824 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1825 * See the License for the specific language governing permissions and 1826 * limitations under the License. 1827 * ============================================================================= 1828 */function Oy(n){const e={x:N(n,"x","expm1")};return V.runKernel(Bp,e)}const Fy=P({expm1_:Oy});/** 1829 * @license 1830 * Copyright 2020 Google LLC. All Rights Reserved. 1831 * Licensed under the Apache License, Version 2.0 (the "License"); 1832 * you may not use this file except in compliance with the License. 1833 * You may obtain a copy of the License at 1834 * 1835 * http://www.apache.org/licenses/LICENSE-2.0 1836 * 1837 * Unless required by applicable law or agreed to in writing, softw
1837are 1838 * distributed under the License is distributed on an "AS IS" BASIS, 1839 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1840 * See the License for the specific language governing permissions and 1841 * limitations under the License. 1842 * ============================================================================= 1843 */function Dy(n,e){const t=N(n,"x","tile","string_or_numeric");R(t.rank===e.length,()=>`Error in transpose: rank of input ${t.rank} must match length of reps ${e}.`);const r={x:t},a={reps:e};return V.runKernel($u,r,a)}const es=P({tile_:Dy});/** 1844 * @license 1845 * Copyright 2020 Google LLC. All Rights Reserved. 1846 * Licensed under the Apache License, Version 2.0 (the "License"); 1847 * you may not use this file except in compliance with the License. 1848 * You may obtain a copy of the License at 1849 * 1850 * http://www.apache.org/licenses/LICENSE-2.0 1851 * 1852 * Unless required by applicable law or agreed to in writing, software 1853 * distributed under the License is distributed on an "AS IS" BASIS, 1854 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1855 * See the License for the specific language governing permissions and 1856 * limitations under the License. 1857 * ============================================================================= 1858 */function My(n,e,t,r="float32"){e==null&&(e=n);const a=He([n,e],r),s=n<=e?n:e;for(let i=0;i<s;++i)a.set(1,i,i);const o=Z(a.toTensor(),[n,e]);if(t==null)return o;if(t.length===1)return es(on(o,0),[t[0],1,1]);if(t.length===2)return es(on(on(o,0),0),[t[0],t[1],1,1]);if(t.length===3)return es(on(on(on(o,0),0),0),[t[0],t[1],t[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${t.length}D.`)}const Pf=P({eye_:My});/** 1859 * @license 1860 * Copyright 2018 Google LLC. All Rights Reserved. 1861 * Licensed under the Apache License, Version 2.0 (the "License"); 1862 * you may not use this file except in compliance with the License. 1863 * You may obtain a copy of the License at 1864 * 1865 * http://www.apache.org/licenses/LICENSE-2.0 1866 * 1867 * Unless required by applicable law or agreed to in writing, software 1868 * distributed under the License is distributed on an "AS IS" BASIS, 1869 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1870 * See the License for the specific language governing permissions and 1871 * limitations under the License. 1872 * ============================================================================= 1873 */function Ly(n){const e={x:N(n,"x","floor","float32")};return V.runKernel(zp,e)}const Bf=P({floor_:Ly});/** 1874 * @license 1875 * Copyright 2018 Google LLC. All Rights Reserved. 1876 * Licensed under the Apache License, Version 2.0 (the "License"); 1877 * you may not use this file except in compliance with the License. 1878 * You may obtain a copy of the License at 1879 * 1880 * http://www.apache.org/licenses/LICENSE-2.0 1881 * 1882 * Unless required by applicable law or agreed to in writing, software 1883 * distributed under the License is distributed on an "AS IS" BASIS, 1884 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1885 * See the License for the specific language governing permissions and 1886 * limitations under the License. 1887 * ============================================================================= 1888 */function Py(n,e,t=0,r=0){const a=N(n,"x","gather"),s=N(e,"indices","gather","int32"),o={x:a,indices:s},i={axis:t,batchDims:r};return V.runKernel(Hp,o,i)}const Uf=P({gather_:Py});/** 1889 * @license 1890 * Copyright 2020 Google LLC. All Rights Reserved. 1891 * Licensed under the Apache License, Version 2.0 (the "License"); 1892 * you may not use this file except in compliance with the License. 1893 * You may obtain a copy of the License at 1894 * 1895 * http://www.apache.org/licenses/LICENSE-2.0 1896 * 1897 * Unless required by applicable law or agreed to in writing, software 1898 * distributed under the License is distributed on an "AS IS" BASIS, 1899 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1900 * See the License for the specific language governing permissions and 1901 * limitations under the License. 1902 * ============================================================================= 1903 */function By(n,e){let t=N(n,"a","greater","string_or_numeric"),r=N(e,"b","greater","string_or_numeric");[t,r]=Ke(t,r),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(qp,a)}const $o=P({greater_:By});/** 1904 * @license 1905 * Copyright 2020 Google LLC. All Rights Reserved. 1906 * Licensed under the Apache License, Version 2.0 (the "License");
1907 * you may not use this file except in compliance with the License. 1908 * You may obtain a copy of the License at 1909 * 1910 * http://www.apache.org/licenses/LICENSE-2.0 1911 * 1912 * Unless required by applicable law or agreed to in writing, software 1913 * distributed under the License is distributed on an "AS IS" BASIS, 1914 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1915 * See the License for the specific language governing permissions and 1916 * limitations under the License. 1917 * ============================================================================= 1918 */function Uy(n,e){let t=N(n,"a","greaterEqual","string_or_numeric"),r=N(e,"b","greaterEqual","string_or_numeric");[t,r]=Ke(t,r),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(Kp,a)}const Vf=P({greaterEqual_:Uy});/** 1919 * @license 1920 * Copyright 2018 Google LLC. All Rights Reserved. 1921 * Licensed under the Apache License, Version 2.0 (the "License"); 1922 * you may not use this file except in compliance with the License. 1923 * You may obtain a copy of the License at 1924 * 1925 * http://www.apache.org/licenses/LICENSE-2.0 1926 * 1927 * Unless required by applicable law or agreed to in writing, software 1928 * distributed under the License is distributed on an "AS IS" BASIS, 1929 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1930 * See the License for the specific language governing permissions and 1931 * limitations under the License. 1932 * ============================================================================= 1933 */function Vy(n){const e={x:N(n,"x","isFinite")};return V.runKernel(Jp,e)}const Wy=P({isFinite_:Vy});/** 1934 * @license 1935 * Copyright 2018 Google LLC. All Rights Reserved. 1936 * Licensed under the Apache License, Version 2.0 (the "License"); 1937 * you may not use this file except in compliance with the License. 1938 * You may obtain a copy of the License at 1939 * 1940 * http://www.apache.org/licenses/LICENSE-2.0 1941 * 1942 * Unless required by applicable law or agreed to in writing, software 1943 * distributed under the License is distributed on an "AS IS" BASIS, 1944 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1945 * See the License for the specific language governing permissions and 1946 * limitations under the License. 1947 * ============================================================================= 1948 */function zy(n){const e={x:N(n,"x","isInf")};return V.runKernel(Qp,e)}const Gy=P({isInf_:zy});/** 1949 * @license 1950 * Copyright 2018 Google LLC. All Rights Reserved. 1951 * Licensed under the Apache License, Version 2.0 (the "License"); 1952 * you may not use this file except in compliance with the License. 1953 * You may obtain a copy of the License at 1954 * 1955 * http://www.apache.org/licenses/LICENSE-2.0 1956 * 1957 * Unless required by applicable law or agreed to in writing, software 1958 * distributed under the License is distributed on an "AS IS" BASIS, 1959 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1960 * See the License for the specific language governing permissions and 1961 * limitations under the License. 1962 * ============================================================================= 1963 */function jy(n){const e={x:N(n,"x","isNaN")};return V.runKernel(eh,e)}const Hy=P({isNaN_:jy});/** 1964 * @license 1965 * Copyright 2020 Google LLC. All Rights Reserved. 1966 * Licensed under the Apache License, Version 2.0 (the "License"); 1967 * you may not use this file except in compliance with the License. 1968 * You may obtain a copy of the License at 1969 * 1970 * http://www.apache.org/licenses/LICENSE-2.0 1971 * 1972 * Unless required by applicable law or agreed to in writing, software 1973 * distributed under the License is distributed on an "AS IS" BASIS, 1974 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1975 * See the License for the specific language governing permissions and 1976 * limitations under the License. 1977 * ============================================================================= 1978 */function Xy(n,e=.2){const t={x:N(n,"x","leakyRelu")},r={alpha:e};return V.runKernel(th,t,r)}const Wf=P({leakyRelu_:Xy});/** 1979 * @license 1980 * Copyright 2020 Google LLC. All Rights Reserved. 1981 * Licensed under the Apache License, Version 2.0 (the "License");
1982 * you may not use this file except in compliance with the License. 1983 * You may obtain a copy of the License at 1984 * 1985 * http://www.apache.org/licenses/LICENSE-2.0 1986 * 1987 * Unless required by applicable law or agreed to in writing, software 1988 * distributed under the License is distributed on an "AS IS" BASIS, 1989 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1990 * See the License for the specific language governing permissions and 1991 * limitations under the License. 1992 * ============================================================================= 1993 */function qy(n,e){let t=N(n,"a","less","string_or_numeric"),r=N(e,"b","less","string_or_numeric");[t,r]=Ke(t,r),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(nh,a)}const Ky=P({less_:qy});/** 1994 * @license 1995 * Copyright 2020 Google LLC. All Rights Reserved. 1996 * Licensed under the Apache License, Version 2.0 (the "License"); 1997 * you may not use this file except in compliance with the License. 1998 * You may obtain a copy of the License at 1999 * 2000 * http://www.apache.org/licenses/LICENSE-2.0 2001 * 2002 * Unless required by applicable law or agreed to in writing, software 2003 * distributed under the License is distributed on an "AS IS" BASIS, 2004 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2005 * See the License for the specific language governing permissions and 2006 * limitations under the License. 2007 * ============================================================================= 2008 */function Yy(n,e){let t=N(n,"a","lessEqual","string_or_numeric"),r=N(e,"b","lessEqual","string_or_numeric");[t,r]=Ke(t,r),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(rh,a)}const ju=P({lessEqual_:Yy});/** 2009 * @license 2010 * Copyright 2018 Google LLC. All Rights Reserved. 2011 * Licensed under the Apache License, Version 2.0 (the "License"); 2012 * you may not use this file except in compliance with the License. 2013 * You may obtain a copy of the License at 2014 * 2015 * http://www.apache.org/licenses/LICENSE-2.0 2016 * 2017 * Unless required by applicable law or agreed to in writing, software 2018 * distributed under the License is distributed on an "AS IS" BASIS, 2019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2020 * See the License for the specific language governing permissions and 2021 * limitations under the License. 2022 * ============================================================================= 2023 */function Zy(n,e,t){if(t<=0)throw new Error("The number of values should be positive.");const r={start:n,stop:e,num:t};return V.runKernel(ah,{},r)}/** 2024 * @license 2025 * Copyright 2020 Google LLC. All Rights Reserved. 2026 * Licensed under the Apache License, Version 2.0 (the "License"); 2027 * you may not use this file except in compliance with the License. 2028 * You may obtain a copy of the License at 2029 * 2030 * http://www.apache.org/licenses/LICENSE-2.0 2031 * 2032 * Unless required by applicable law or agreed to in writing, software 2033 * distributed under the License is distributed on an "AS IS" BASIS, 2034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2035 * See the License for the specific language governing permissions and 2036 * limitations under the License. 2037 * ============================================================================= 2038 */function Jy(n,e=5,t=1,r=1,a=.5){const s=N(n,"x","localResponseNormalization");R(s.rank===4||s.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got 2039 rank ${s.rank}.`),R(ua(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let o=s,i=!1;s.rank===3&&(i=!0,o=Z(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const u={x:o},l={depthRadius:e,bias:t,alpha:r,beta:a},c=V.runKernel(ch,u,l);return i?Z(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const Qy=P({localResponseNormalization_:Jy});/** 2040 * @license 2041 * Copyright 2018 Google LLC. All Rights Reserved. 2042 * Licensed under the Apache License, Version 2.0 (the "License"); 2043 * you may not use this file except in compliance with the License. 2044 * You may obtain a copy of the License at 2045 * 2046 * http://www.apache.org/licenses/LICENSE-2.0 2047 * 2048 * Unless required by applicable law or agreed to in writing, softw
2048are 2049 * distributed under the License is distributed on an "AS IS" BASIS, 2050 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2051 * See the License for the specific language governing permissions and 2052 * limitations under the License. 2053 * ============================================================================= 2054 */function ex(n){const e={x:N(n,"x","log","float32")};return V.runKernel(sh,e)}const as=P({log_:ex});/** 2055 * @license 2056 * Copyright 2018 Google LLC. All Rights Reserved. 2057 * Licensed under the Apache License, Version 2.0 (the "License"); 2058 * you may not use this file except in compliance with the License. 2059 * You may obtain a copy of the License at 2060 * 2061 * http://www.apache.org/licenses/LICENSE-2.0 2062 * 2063 * Unless required by applicable law or agreed to in writing, software 2064 * distributed under the License is distributed on an "AS IS" BASIS, 2065 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2066 * See the License for the specific language governing permissions and 2067 * limitations under the License. 2068 * ============================================================================= 2069 */function tx(n){const e={x:N(n,"x","log1p")};return V.runKernel(oh,e)}const zf=P({log1p_:tx});/** 2070 * @license 2071 * Copyright 2018 Google LLC. All Rights Reserved. 2072 * Licensed under the Apache License, Version 2.0 (the "License"); 2073 * you may not use this file except in compliance with the License. 2074 * You may obtain a copy of the License at 2075 * 2076 * http://www.apache.org/licenses/LICENSE-2.0 2077 * 2078 * Unless required by applicable law or agreed to in writing, software 2079 * distributed under the License is distributed on an "AS IS" BASIS, 2080 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2081 * See the License for the specific language governing permissions and 2082 * limitations under the License. 2083 * ============================================================================= 2084 */function Dn(n){return V.customGrad(n)}/** 2085 * @license 2086 * Copyright 2018 Google LLC. All Rights Reserved. 2087 * Licensed under the Apache License, Version 2.0 (the "License"); 2088 * you may not use this file except in compliance with the License. 2089 * You may obtain a copy of the License at 2090 * 2091 * http://www.apache.org/licenses/LICENSE-2.0 2092 * 2093 * Unless required by applicable law or agreed to in writing, software 2094 * distributed under the License is distributed on an "AS IS" BASIS, 2095 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2096 * See the License for the specific language governing permissions and 2097 * limitations under the License. 2098 * ============================================================================= 2099 */function nx(n){const e={x:N(n,"x","softplus")};return V.runKernel(rd,e)}const Gf=P({softplus_:nx});/** 2100 * @license 2101 * Copyright 2018 Google LLC. All Rights Reserved. 2102 * Licensed under the Apache License, Version 2.0 (the "License"); 2103 * you may not use this file except in compliance with the License. 2104 * You may obtain a copy of the License at 2105 * 2106 * http://www.apache.org/licenses/LICENSE-2.0 2107 * 2108 * Unless required by applicable law or agreed to in writing, software 2109 * distributed under the License is distributed on an "AS IS" BASIS, 2110 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2111 * See the License for the specific language governing permissions and 2112 * limitations under the License. 2113 * ============================================================================= 2114 */function rx(n){const e=N(n,"x","logSigmoid");return Dn(t=>({value:An(Gf(An(t))),gradFunc:r=>me(r,Rr(An(t)))}))(e)}const ax=P({logSigmoid_:rx});/** 2115 * @license 2116 * Copyright 2020 Google LLC. All Rights Reserved. 2117 * Licensed under the Apache License, Version 2.0 (the "License"); 2118 * you may not use this file except in compliance with the License. 2119 * You may obtain a copy of the License at 2120 * 2121 * http://www.apache.org/licenses/LICENSE-2.0 2122 * 2123 * Unless required by applicable law or agreed to in writing, software 2124 * distributed under the License is distributed on an "AS IS" BASIS, 2125 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2126 * See the License for the specific language governing permissions and 2127 * limitations under the License. 2128 * ============================================================================= 2129 */function sx(n,e){let t=N(n,"a","sub"),r=N(e,"b","sub");[t,r]=Ke(t,r);const a={a:t,b:r};return V.runKernel(bd,a)}const Ce=P({sub_:sx});/** 2130 * @license 2131 * Copyright 2020 Google Inc. All Rights Reserved. 2132 * Licensed under the Apache License, Version 2.0 (the "License");
2133 * you may not use this file except in compliance with the License. 2134 * You may obtain a copy of the License at 2135 * 2136 * http://www.apache.org/licenses/LICENSE-2.0 2137 * 2138 * Unless required by applicable law or agreed to in writing, software 2139 * distributed under the License is distributed on an "AS IS" BASIS, 2140 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2141 * See the License for the specific language governing permissions and 2142 * limitations under the License. 2143 * ============================================================================= 2144 */function ox(n,e=-1){const t=N(n,"logits","logSoftmax");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and axis was ${e}`);return Dn((r,a)=>{const s=oa(r,e,!0),o=Ce(r,s),i=Ce(je(o,"float32"),as(Ve(Fn(o),e,!0)));return a([i]),{value:i,gradFunc:(u,l)=>{const[c]=l,p=!0,h=Fn(c);return Ce(u,me(Ve(u,e,p),h))}}})(t)}const ix=P({logSoftmax_:ox});/** 2145 * @license 2146 * Copyright 2020 Google LLC. All Rights Reserved. 2147 * Licensed under the Apache License, Version 2.0 (the "License"); 2148 * you may not use this file except in compliance with the License. 2149 * You may obtain a copy of the License at 2150 * 2151 * http://www.apache.org/licenses/LICENSE-2.0 2152 * 2153 * Unless required by applicable law or agreed to in writing, software 2154 * distributed under the License is distributed on an "AS IS" BASIS, 2155 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2156 * See the License for the specific language governing permissions and 2157 * limitations under the License. 2158 * ============================================================================= 2159 */function ux(n,e=null,t=!1){const r=N(n,"x","logSumExp"),a=rt(e,r.shape),s=oa(r,a,!0),o=Ce(r,s),i=Fn(o),u=Ve(i,a),l=as(u),c=Pe(Z(s,l.shape),l);if(t){const p=Bt(c.shape,a);return Z(c,p)}return c}const jf=P({logSumExp_:ux});/** 2160 * @license 2161 * Copyright 2020 Google LLC. All Rights Reserved. 2162 * Licensed under the Apache License, Version 2.0 (the "License"); 2163 * you may not use this file except in compliance with the License. 2164 * You may obtain a copy of the License at 2165 * 2166 * http://www.apache.org/licenses/LICENSE-2.0 2167 * 2168 * Unless required by applicable law or agreed to in writing, software 2169 * distributed under the License is distributed on an "AS IS" BASIS, 2170 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2171 * See the License for the specific language governing permissions and 2172 * limitations under the License. 2173 * ============================================================================= 2174 */function lx(n,e){const t=N(n,"a","logicalAnd","bool"),r=N(e,"b","logicalAnd","bool");$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(ih,a)}const oo=P({logicalAnd_:lx});/** 2175 * @license 2176 * Copyright 2020 Google LLC. All Rights Reserved. 2177 * Licensed under the Apache License, Version 2.0 (the "License"); 2178 * you may not use this file except in compliance with the License. 2179 * You may obtain a copy of the License at 2180 * 2181 * http://www.apache.org/licenses/LICENSE-2.0 2182 * 2183 * Unless required by applicable law or agreed to in writing, software 2184 * distributed under the License is distributed on an "AS IS" BASIS, 2185 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2186 * See the License for the specific language governing permissions and 2187 * limitations under the License. 2188 * ============================================================================= 2189 */function cx(n){const e={x:N(n,"x","logicalNot","bool")};return V.runKernel(uh,e)}const Hf=P({logicalNot_:cx});/** 2190 * @license 2191 * Copyright 2020 Google LLC. All Rights Reserved. 2192 * Licensed under the Apache License, Version 2.0 (the "License"); 2193 * you may not use this file except in compliance with the License. 2194 * You may obtain a copy of the License at 2195 * 2196 * http://www.apache.org/licenses/LICENSE-2.0 2197 * 2198 * Unless required by applicable law or agreed to in writing, software 2199 * distributed under the License is distributed on an "AS IS" BASIS, 2200 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2201 * See the License for the specific language governing permissions and 2202 * limitations under the License. 2203 * ============================================================================= 2204 */function px(n,e){const t=N(n,"a","logicalOr","bool"),r=N(e,"b","logicalOr","bool");$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(lh,a)}const Xf=P({logicalOr_:px});/** 2205 * @license 2206 * Copyright 2020 Google LLC. All Rights Reserved. 2207 * Licensed under the Apache License, Version 2.0 (the "License");
2208 * you may not use this file except in compliance with the License. 2209 * You may obtain a copy of the License at 2210 * 2211 * http://www.apache.org/licenses/LICENSE-2.0 2212 * 2213 * Unless required by applicable law or agreed to in writing, software 2214 * distributed under the License is distributed on an "AS IS" BASIS, 2215 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2216 * See the License for the specific language governing permissions and 2217 * limitations under the License. 2218 * ============================================================================= 2219 */function hx(n,e){const t=N(n,"a","logicalXor","bool"),r=N(e,"b","logicalXor","bool");return $e(t.shape,r.shape),oo(Xf(n,e),Hf(oo(n,e)))}const dx=P({logicalXor_:hx});/** 2220 * @license 2221 * Copyright 2022 Google LLC. All Rights Reserved. 2222 * Licensed under the Apache License, Version 2.0 (the "License"); 2223 * you may not use this file except in compliance with the License. 2224 * You may obtain a copy of the License at 2225 * 2226 * http://www.apache.org/licenses/LICENSE-2.0 2227 * 2228 * Unless required by applicable law or agreed to in writing, software 2229 * distributed under the License is distributed on an "AS IS" BASIS, 2230 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2231 * See the License for the specific language governing permissions and 2232 * limitations under the License. 2233 * ============================================================================= 2234 */const Ws=2147483648;function fx(n,e,t="left"){const r=N(n,"sortedSequence","searchSorted"),a=N(e,"values","searchSorted"),s=r.shape[r.shape.length-1],o=a.shape[a.shape.length-1],i=Z(r,[-1,s]),u=Z(a,[-1,o]);if(i.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(i.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(ae(u.shape)>=Ws)throw new Error(`values tensor size must less than ${Ws}`);if(i.shape[1]>=Ws)throw new Error(`trailing dim_size must less than ${Ws} for int32 output type, was ${i.shape[1]}`);const l={sortedSequence:i,values:u},c={side:t};return V.runKernel(Kh,l,c)}const Hu=P({searchSorted_:fx});/** 2235 * @license 2236 * Copyright 2022 Google LLC. All Rights Reserved. 2237 * Licensed under the Apache License, Version 2.0 (the "License"); 2238 * you may not use this file except in compliance with the License. 2239 * You may obtain a copy of the License at 2240 * 2241 * http://www.apache.org/licenses/LICENSE-2.0 2242 * 2243 * Unless required by applicable law or agreed to in writing, software 2244 * distributed under the License is distributed on an "AS IS" BASIS, 2245 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2246 * See the License for the specific language governing permissions and 2247 * limitations under the License. 2248 * ============================================================================= 2249 */function mx(n,e){return Hu(n,e,"left")}/** 2250 * @license 2251 * Copyright 2020 Google LLC. All Rights Reserved. 2252 * Licensed under the Apache License, Version 2.0 (the "License"); 2253 * you may not use this file except in compliance with the License. 2254 * You may obtain a copy of the License at 2255 * 2256 * http://www.apache.org/licenses/LICENSE-2.0 2257 * 2258 * Unless required by applicable law or agreed to in writing, software 2259 * distributed under the License is distributed on an "AS IS" BASIS, 2260 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2261 * See the License for the specific language governing permissions and 2262 * limitations under the License. 2263 * ============================================================================= 2264 */function gx(n,e,t,r,a){const s=N(n,"x","maxPool"),o=1;let i=s,u=!1;s.rank===3&&(u=!0,i=Z(s,[1,s.shape[0],s.shape[1],s.shape[2]])),R(i.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${i.rank}.`),R(_t(t,o),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`),Jt("maxPool",r,a);const l={x:i},c={filterSize:e,strides:t,pad:r,dimRoundingMode:a},p=V.runKernel(dh,l,c);return u?Z(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const qf=P({maxPool_:gx});/** 2265 * @license 2266 * Copyright 2020 Google LLC. All Rights Reserved. 2267 * Licensed under the Apache License, Version 2.0 (the "License");
2268 * you may not use this file except in compliance with the License. 2269 * You may obtain a copy of the License at 2270 * 2271 * http://www.apache.org/licenses/LICENSE-2.0 2272 * 2273 * Unless required by applicable law or agreed to in writing, software 2274 * distributed under the License is distributed on an "AS IS" BASIS, 2275 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2276 * See the License for the specific language governing permissions and 2277 * limitations under the License. 2278 * ============================================================================= 2279 */function yx(n,e=[1,1,1],t,r,a,s="NDHWC"){const o=N(n,"x","maxPool3d");let i=o,u=!1;o.rank===4&&(u=!0,i=Z(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),R(i.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`),R(s==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),Jt("maxPool3d",r,a);const l={x:i},c={filterSize:e,strides:t,pad:r,dimRoundingMode:a,dataFormat:s},p=V.runKernel(fh,l,c);return u?Z(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const xx=P({maxPool3d_:yx});/** 2280 * @license 2281 * Copyright 2018 Google LLC. All Rights Reserved. 2282 * Licensed under the Apache License, Version 2.0 (the "License"); 2283 * you may not use this file except in compliance with the License. 2284 * You may obtain a copy of the License at 2285 * 2286 * http://www.apache.org/licenses/LICENSE-2.0 2287 * 2288 * Unless required by applicable law or agreed to in writing, software 2289 * distributed under the License is distributed on an "AS IS" BASIS, 2290 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2291 * See the License for the specific language governing permissions and 2292 * limitations under the License. 2293 * ============================================================================= 2294 */function bx(n,e,t,r,a=!1){const s={x:N(n,"x","maxPoolWithArgmax")},o={filterSize:e,strides:t,pad:r,includeBatchInIndex:a},i=V.runKernel(mh,s,o);return{result:i[0],indexes:i[1]}}const vx=P({maxPoolWithArgmax_:bx});/** 2295 * @license 2296 * Copyright 2020 Google LLC. All Rights Reserved. 2297 * Licensed under the Apache License, Version 2.0 (the "License"); 2298 * you may not use this file except in compliance with the License. 2299 * You may obtain a copy of the License at 2300 * 2301 * http://www.apache.org/licenses/LICENSE-2.0 2302 * 2303 * Unless required by applicable law or agreed to in writing, software 2304 * distributed under the License is distributed on an "AS IS" BASIS, 2305 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2306 * See the License for the specific language governing permissions and 2307 * limitations under the License. 2308 * ============================================================================= 2309 */function wx(n,e){let t=N(n,"a","maximum"),r=N(e,"b","maximum");[t,r]=Ke(t,r),t.dtype==="bool"&&(t=je(t,"int32"),r=je(r,"int32")),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(hh,a)}const Sx=P({maximum_:wx});/** 2310 * @license 2311 * Copyright 2020 Google Inc. All Rights Reserved. 2312 * Licensed under the Apache License, Version 2.0 (the "License"); 2313 * you may not use this file except in compliance with the License. 2314 * You may obtain a copy of the License at 2315 * 2316 * http://www.apache.org/licenses/LICENSE-2.0 2317 * 2318 * Unless required by applicable law or agreed to in writing, software 2319 * distributed under the License is distributed on an "AS IS" BASIS, 2320 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2321 * See the License for the specific language governing permissions and 2322 * limitations under the License. 2323 * ============================================================================= 2324 */function kx(n,e=null,t=!1){const r={x:N(n,"x","mean")},a={axis:e,keepDims:t};return V.runKernel(gh,r,a)}const io=P({mean_:kx});/** 2325 * @license 2326 * Copyright 2018 Google LLC. All Rights Reserved. 2327 * Licensed under the Apache License, Version 2.0 (the "License"); 2328 * you may not use this file except in compliance with the License. 2329 * You may obtain a copy of the License at 2330 * 2331 * http://www.apache.org/licenses/LICENSE-2.0 2332 * 2333 * Unless required by applicable law or agreed to in writing, softw
2333are 2334 * distributed under the License is distributed on an "AS IS" BASIS, 2335 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2336 * See the License for the specific language governing permissions and 2337 * limitations under the License. 2338 * ============================================================================= 2339 */function Fr(n,e="float32"){if(e==="complex64"){const r=Fr(n,"float32"),a=Fr(n,"float32");return tr(r,a)}const t=er(ae(n),e);return V.makeTensor(t,n,e)}/** 2340 * @license 2341 * Copyright 2018 Google LLC. All Rights Reserved. 2342 * Licensed under the Apache License, Version 2.0 (the "License"); 2343 * you may not use this file except in compliance with the License. 2344 * You may obtain a copy of the License at 2345 * 2346 * http://www.apache.org/licenses/LICENSE-2.0 2347 * 2348 * Unless required by applicable law or agreed to in writing, software 2349 * distributed under the License is distributed on an "AS IS" BASIS, 2350 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2351 * See the License for the specific language governing permissions and 2352 * limitations under the License. 2353 * ============================================================================= 2354 */function Cr(n,e="float32"){if(e==="complex64"){const r=Cr(n,"float32"),a=Fr(n,"float32");return tr(r,a)}const t=Vc(ae(n),e);return V.makeTensor(t,n,e)}/** 2355 * @license 2356 * Copyright 2021 Google LLC. All Rights Reserved. 2357 * Licensed under the Apache License, Version 2.0 (the "License"); 2358 * you may not use this file except in compliance with the License. 2359 * You may obtain a copy of the License at 2360 * 2361 * http://www.apache.org/licenses/LICENSE-2.0 2362 * 2363 * Unless required by applicable law or agreed to in writing, software 2364 * distributed under the License is distributed on an "AS IS" BASIS, 2365 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2366 * See the License for the specific language governing permissions and 2367 * limitations under the License. 2368 * ============================================================================= 2369 */function Tx(n,e,{indexing:t="xy"}={}){if(t!=="xy"&&t!=="ij")throw new TypeError(`${t} is not a valid third argument to meshgrid`);if(n===void 0)return[];let r=N(n,"x","meshgrid",n instanceof Ge?n.dtype:"float32");if(e===void 0)return[r];let a=N(e,"y","meshgrid",e instanceof Ge?e.dtype:"float32");const s=ae(r.shape),o=ae(a.shape);return t==="xy"?(r=Z(r,[1,-1]),a=Z(a,[-1,1]),[Oe(Cr([o,1],r.dtype),r),Oe(a,Cr([1,s],a.dtype))]):(r=Z(r,[-1,1]),a=Z(a,[1,-1]),[Oe(r,Cr([1,o],r.dtype)),Oe(Cr([s,1],a.dtype),a)])}/** 2370 * @license 2371 * Copyright 2020 Google LLC. All Rights Reserved. 2372 * Licensed under the Apache License, Version 2.0 (the "License"); 2373 * you may not use this file except in compliance with the License. 2374 * You may obtain a copy of the License at 2375 * 2376 * http://www.apache.org/licenses/LICENSE-2.0 2377 * 2378 * Unless required by applicable law or agreed to in writing, software 2379 * distributed under the License is distributed on an "AS IS" BASIS, 2380 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2381 * See the License for the specific language governing permissions and 2382 * limitations under the License. 2383 * ============================================================================= 2384 */function Ex(n,e){let t=N(n,"a","minimum"),r=N(e,"b","minimum");[t,r]=Ke(t,r),t.dtype==="bool"&&(t=je(t,"int32"),r=je(r,"int32")),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(xh,a)}const Kf=P({minimum_:Ex});/** 2385 * @license 2386 * Copyright 2020 Google LLC. All Rights Reserved. 2387 * Licensed under the Apache License, Version 2.0 (the "License"); 2388 * you may not use this file except in compliance with the License. 2389 * You may obtain a copy of the License at 2390 * 2391 * http://www.apache.org/licenses/LICENSE-2.0 2392 * 2393 * Unless required by applicable law or agreed to in writing, software 2394 * distributed under the License is distributed on an "AS IS" BASIS, 2395 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2396 * See the License for the specific language governing permissions and 2397 * limitations under the License. 2398 * ============================================================================= 2399 */function Cx(n,e,t){R(t==="reflect"||t==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${t}.`);const r=N(n,"x","mirrorPad");if(r.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");R(e.length===r.rank,()=>`Padding doesn't match input. Must be ${r.rank}. Got ${e.length}.`);const a=t==="reflect"?1:0;for(let i=0;i<r.rank;i++)R(e[i].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),R(e[i][0]>=0&&e[i][0]<=r.shape[i]-a&&e[i][1]>=0&&e[i][1]<=r.shape[i]-a,()=>`Padding in dimension ${i} cannot be greater than or equal to ${r.shape[i]-a} or less than 0 for input of shape ${r.shape}`);const s={paddings:e,mode:t},o={x:r};return V.runKernel(bh,o,s)}const Ix=P({mirrorPad_:Cx});/** 2400 * @license 2401 * Copyright 2020 Google LLC. All Rights Reserved. 2402 * Licensed under the Apache License, Version 2.0 (the "License");
2403 * you may not use this file except in compliance with the License. 2404 * You may obtain a copy of the License at 2405 * 2406 * http://www.apache.org/licenses/LICENSE-2.0 2407 * 2408 * Unless required by applicable law or agreed to in writing, software 2409 * distributed under the License is distributed on an "AS IS" BASIS, 2410 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2411 * See the License for the specific language governing permissions and 2412 * limitations under the License. 2413 * ============================================================================= 2414 */function Nx(n,e){let t=N(n,"a","mod"),r=N(e,"b","mod");[t,r]=Ke(t,r);const a={a:t,b:r};return V.runKernel(vh,a)}const $x=P({mod_:Nx});/** 2415 * @license 2416 * Copyright 2020 Google LLC. All Rights Reserved. 2417 * Licensed under the Apache License, Version 2.0 (the "License"); 2418 * you may not use this file except in compliance with the License. 2419 * You may obtain a copy of the License at 2420 * 2421 * http://www.apache.org/licenses/LICENSE-2.0 2422 * 2423 * Unless required by applicable law or agreed to in writing, software 2424 * distributed under the License is distributed on an "AS IS" BASIS, 2425 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2426 * See the License for the specific language governing permissions and 2427 * limitations under the License. 2428 * ============================================================================= 2429 */function Rx(n,e=null,t=!1){n=N(n,"x","moments");const r=rt(e,n.shape),a=io(n,r,t);let s=a.shape;t||(s=Bt(a.shape,r));const o=Io(Ce(je(n,"float32"),Z(a,s))),i=io(o,r,t);return{mean:a,variance:i}}const _x=P({moments_:Rx});function Ax(n,e,t,r){const a=N(e,"data","multiRNNCell"),s=no(t,"c","multiRNNCell"),o=no(r,"h","multiRNNCell");let i=a;const u=[];for(let p=0;p<n.length;p++){const h=n[p](i,s[p],o[p]);u.push(h[0]),u.push(h[1]),i=h[1]}const l=[],c=[];for(let p=0;p<u.length;p+=2)l.push(u[p]),c.push(u[p+1]);return[l,c]}const Ox=P({multiRNNCell_:Ax});/** 2430 * @license 2431 * Copyright 2020 Google LLC. All Rights Reserved. 2432 * Licensed under the Apache License, Version 2.0 (the "License"); 2433 * you may not use this file except in compliance with the License. 2434 * You may obtain a copy of the License at 2435 * 2436 * http://www.apache.org/licenses/LICENSE-2.0 2437 * 2438 * Unless required by applicable law or agreed to in writing, software 2439 * distributed under the License is distributed on an "AS IS" BASIS, 2440 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2441 * See the License for the specific language governing permissions and 2442 * limitations under the License. 2443 * ============================================================================= 2444 */function Fx(n,e,t,r=!1){const a=N(n,"logits","multinomial"),s=a.size,o=a.rank;if(s<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${s}.`);if(o>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`);t=t||Math.random();const i={logits:o===1?Z(a,[1,-1]):a},u={numSamples:e,seed:t,normalized:r},l=V.runKernel(wh,i,u);return o===1?Z(l,[l.size]):l}const Dx=P({multinomial_:Fx});/** 2445 * @license 2446 * Copyright 2020 Google LLC. All Rights Reserved. 2447 * Licensed under the Apache License, Version 2.0 (the "License"); 2448 * you may not use this file except in compliance with the License. 2449 * You may obtain a copy of the License at 2450 * 2451 * http://www.apache.org/licenses/LICENSE-2.0 2452 * 2453 * Unless required by applicable law or agreed to in writing, software 2454 * distributed under the License is distributed on an "AS IS" BASIS, 2455 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2456 * See the License for the specific language governing permissions and 2457 * limitations under the License. 2458 * ============================================================================= 2459 */function Mx(n,e){let t=N(n,"a","notEqual","string_or_numeric"),r=N(e,"b","notEqual","string_or_numeric");[t,r]=Ke(t,r),$e(t.shape,r.shape);const a={a:t,b:r};return V.runKernel(Th,a)}const Yf=P({notEqual_:Mx});/** 2460 * @license 2461 * Copyright 2018 Google LLC. All Rights Reserved. 2462 * Licensed under the Apache License, Version 2.0 (the "License");
2463 * you may not use this file except in compliance with the License. 2464 * You may obtain a copy of the License at 2465 * 2466 * http://www.apache.org/licenses/LICENSE-2.0 2467 * 2468 * Unless required by applicable law or agreed to in writing, software 2469 * distributed under the License is distributed on an "AS IS" BASIS, 2470 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2471 * See the License for the specific language governing permissions and 2472 * limitations under the License. 2473 * ============================================================================= 2474 */function Lx(n){const e={x:N(n,"x","onesLike")};return V.runKernel(Nh,e)}const Px=P({onesLike_:Lx});function Bx(n,e){const t=N(n,"v1","outerProduct"),r=N(e,"v2","outerProduct");R(t.rank===1&&r.rank===1,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${t.rank} and ${r.rank}.`);const a=Z(t,[-1,1]),s=Z(r,[1,-1]);return Oe(a,s)}const Ux=P({outerProduct_:Bx});/** 2475 * @license 2476 * Copyright 2020 Google LLC. All Rights Reserved. 2477 * Licensed under the Apache License, Version 2.0 (the "License"); 2478 * you may not use this file except in compliance with the License. 2479 * You may obtain a copy of the License at 2480 * 2481 * http://www.apache.org/licenses/LICENSE-2.0 2482 * 2483 * Unless required by applicable law or agreed to in writing, software 2484 * distributed under the License is distributed on an "AS IS" BASIS, 2485 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2486 * See the License for the specific language governing permissions and 2487 * limitations under the License. 2488 * ============================================================================= 2489 */function Vx(n,e,t=0){const r=N(n,"x","pad");if(r.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:e,constantValue:t},s={x:r};return V.runKernel(_h,s,a)}const ms=P({pad_:Vx});function Wx(n,e,t=0){return R(e.length===2,()=>"Invalid number of paddings. Must be length of 2."),ms(n,[e],t)}const zx=P({pad1d_:Wx});function Gx(n,e,t=0){return R(e.length===2&&e[0].length===2&&e[1].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),ms(n,e,t)}const jx=P({pad2d_:Gx});function Hx(n,e,t=0){return R(e.length===3&&e[0].length===2&&e[1].length===2&&e[2].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),ms(n,e,t)}const Xx=P({pad3d_:Hx});function qx(n,e,t=0){return R(e.length===4&&e[0].length===2&&e[1].length===2&&e[2].length===2&&e[3].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),ms(n,e,t)}const Kx=P({pad4d_:qx});/** 2490 * @license 2491 * Copyright 2020 Google LLC. All Rights Reserved. 2492 * Licensed under the Apache License, Version 2.0 (the "License"); 2493 * you may not use this file except in compliance with the License. 2494 * You may obtain a copy of the License at 2495 * 2496 * http://www.apache.org/licenses/LICENSE-2.0 2497 * 2498 * Unless required by applicable law or agreed to in writing, software 2499 * distributed under the License is distributed on an "AS IS" BASIS, 2500 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2501 * See the License for the specific language governing permissions and 2502 * limitations under the License. 2503 * ============================================================================= 2504 */function Yx(n,e,t){const r=N(n,"x","spaceToBatchND");R(r.rank>=1+e.length,()=>`input rank ${r.rank} should be > than [blockShape] ${e.length}`),R(t.length===e.length,()=>`paddings.shape[0] ${t.length} must be equal to [blockShape] ${e.length}`),R(r.shape.reduce((o,i,u)=>u>0&&u<=e.length?o&&(i+t[u-1][0]+t[u-1][1])%e[u-1]===0:o,!0),()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${t.toString()} must be divisible by blockShapes ${e.toString()}`);const a={x:r},s={blockShape:e,paddings:t};return V.runKernel(od,a,s)}const Zf=P({spaceToBatchND_:Yx});/** 2505 * @license 2506 * Copyright 2018 Google LLC. All Rights Reserved. 2507 * Licensed under the Apache License, Version 2.0 (the "License"); 2508 * you may not use this file except in compliance with the License. 2509 * You may obtain a copy of the License at 2510 * 2511 * http://www.apache.org/licenses/LICENSE-2.0 2512 * 2513 * Unless required by applicable law or agreed to in writing, softw
2513are 2514 * distributed under the License is distributed on an "AS IS" BASIS, 2515 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2516 * See the License for the specific language governing permissions and 2517 * limitations under the License. 2518 * ============================================================================= 2519 */function Zx(n,e,t,r,a,s,o){a==null&&(a=[1,1]),s==null&&(s=1),r===0&&(r="valid");const i=N(n,"x","maxPool");let u=i,l=!1;i.rank===3&&(l=!0,u=Z(i,[1,i.shape[0],i.shape[1],i.shape[2]])),R(_t(s,a),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${s} and dilations '${a}'`);const c=Pr(u.shape,e,s,a,r),p=[c.dilationHeight,c.dilationWidth];let h;r==="same"?h=Qx([c.filterHeight,c.filterWidth],p):h=[[0,0],[0,0]];const d=p[0]===1&&p[1]===1,[m,y]=Jx([c.inHeight,c.inWidth],p,h),b=d?r:"valid",x=d?u:Zf(u,p,m),T=(t==="avg"?()=>$f(x,e,s,b,o):()=>qf(x,e,s,b,o))(),$=d?T:Rf(T,p,y);return l?Z($,[$.shape[1],$.shape[2],$.shape[3]]):$}function Jx(n,e,t){const r=t.map(c=>c[0]),a=t.map(c=>c[1]),s=n.concat(r,a),o=e.map((c,p)=>(c-s[p]%c)%c),i=a.map((c,p)=>c+o[p]),u=e.map((c,p)=>[r[p],i[p]]),l=e.map((c,p)=>[0,o[p]]);return[u,l]}function Qx(n,e){const t=n.map((s,o)=>s+(s-1)*(e[o]-1)).map(s=>s-1),r=t.map(s=>Math.floor(s/2)),a=t.map((s,o)=>s-r[o]);return t.map((s,o)=>[r[o],a[o]])}const e4=P({pool_:Zx});/** 2520 * @license 2521 * Copyright 2020 Google LLC. All Rights Reserved. 2522 * Licensed under the Apache License, Version 2.0 (the "License"); 2523 * you may not use this file except in compliance with the License. 2524 * You may obtain a copy of the License at 2525 * 2526 * http://www.apache.org/licenses/LICENSE-2.0 2527 * 2528 * Unless required by applicable law or agreed to in writing, software 2529 * distributed under the License is distributed on an "AS IS" BASIS, 2530 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2531 * See the License for the specific language governing permissions and 2532 * limitations under the License. 2533 * ============================================================================= 2534 */function t4(n,e){const t=N(n,"x","prelu"),r=N(e,"alpha","prelu"),a={x:t,alpha:r};return V.runKernel(Oh,a)}const Jf=P({prelu_:t4});/** 2535 * @license 2536 * Copyright 2020 Google LLC. All Rights Reserved. 2537 * Licensed under the Apache License, Version 2.0 (the "License"); 2538 * you may not use this file except in compliance with the License. 2539 * You may obtain a copy of the License at 2540 * 2541 * http://www.apache.org/licenses/LICENSE-2.0 2542 * 2543 * Unless required by applicable law or agreed to in writing, software 2544 * distributed under the License is distributed on an "AS IS" BASIS, 2545 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2546 * See the License for the specific language governing permissions and 2547 * limitations under the License. 2548 * ============================================================================= 2549 */function n4(n,e=null,t=!1){let r=N(n,"x","prod");r.dtype==="bool"&&(r=je(r,"int32"));const a={x:r},s={axis:e,keepDims:t};return V.runKernel(Fh,a,s)}const r4=P({prod_:n4});/** 2550 * @license 2551 * Copyright 2022 Google LLC. All Rights Reserved. 2552 * Licensed under the Apache License, Version 2.0 (the "License"); 2553 * you may not use this file except in compliance with the License. 2554 * You may obtain a copy of the License at 2555 * 2556 * http://www.apache.org/licenses/LICENSE-2.0 2557 * 2558 * Unless required by applicable law or agreed to in writing, software 2559 * distributed under the License is distributed on an "AS IS" BASIS, 2560 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2561 * See the License for the specific language governing permissions and 2562 * limitations under the License. 2563 * ============================================================================= 2564 */function a4(n,e,t,r){const a=n.map((c,p)=>N(c,`tensors${p}`,"raggedGather","int32")),s=N(e,"paramsDenseValues","raggedGather"),o=N(t,"indices","raggedGather","int32"),i={paramsNestedSplits:a,paramsDenseValues:s,indices:o},u={outputRaggedRank:r},l=V.runKernel(Dh,i,u);return{outputNestedSplits:l.slice(0,l.length-1),outputDenseValues:l[l.length-1]}}const s4=P({raggedGather_:a4});/** 2565 * @license 2566 * Copyright 2022 Google LLC. All Rights Reserved. 2567 * Licensed under the Apache License, Version 2.0 (the "License");
2568 * you may not use this file except in compliance with the License. 2569 * You may obtain a copy of the License at 2570 * 2571 * http://www.apache.org/licenses/LICENSE-2.0 2572 * 2573 * Unless required by applicable law or agreed to in writing, software 2574 * distributed under the License is distributed on an "AS IS" BASIS, 2575 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2576 * See the License for the specific language governing permissions and 2577 * limitations under the License. 2578 * ============================================================================= 2579 */function o4(n,e,t,r,a){const s=N(n,"shape","raggedTensorToTensor","int32"),o=N(e,"values","raggedTensorToTensor"),i=N(t,"defaultValue","raggedTensorToTensor",o.dtype),u=r.map((p,h)=>N(p,`tensors${h}`,"raggedTensorToTensor","int32")),l={shape:s,values:o,defaultValue:i,rowPartitionTensors:u},c={rowPartitionTypes:a};return V.runKernel(Mh,l,c)}const i4=P({raggedTensorToTensor_:o4});/** 2580 * @license 2581 * Copyright 2020 Google LLC. All Rights Reserved. 2582 * Licensed under the Apache License, Version 2.0 (the "License"); 2583 * you may not use this file except in compliance with the License. 2584 * You may obtain a copy of the License at 2585 * 2586 * http://www.apache.org/licenses/LICENSE-2.0 2587 * 2588 * Unless required by applicable law or agreed to in writing, software 2589 * distributed under the License is distributed on an "AS IS" BASIS, 2590 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2591 * See the License for the specific language governing permissions and 2592 * limitations under the License. 2593 * ============================================================================= 2594 */function u4(n,e,t){const r=ae(n);let a=null;if(t==null||t==="float32")a=new Float32Array(r);else if(t==="int32")a=new Int32Array(r);else if(t==="bool")a=new Uint8Array(r);else throw new Error(`Unknown data type ${t}`);for(let s=0;s<r;s++)a[s]=e();return V.makeTensor(a,n,t)}const l4=P({rand_:u4});var Ji={exports:{}},c4=Ji.exports,Ol;function p4(){return Ol||(Ol=1,(function(n){(function(e,t,r){function a(u){var l=this,c=i();l.next=function(){var p=2091639*l.s0+l.c*23283064365386963e-26;return l.s0=l.s1,l.s1=l.s2,l.s2=p-(l.c=p|0)},l.c=1,l.s0=c(" "),l.s1=c(" "),l.s2=c(" "),l.s0-=c(u),l.s0<0&&(l.s0+=1),l.s1-=c(u),l.s1<0&&(l.s1+=1),l.s2-=c(u),l.s2<0&&(l.s2+=1),c=null}function s(u,l){return l.c=u.c,l.s0=u.s0,l.s1=u.s1,l.s2=u.s2,l}function o(u,l){var c=new a(u),p=l&&l.state,h=c.next;return h.int32=function(){return c.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,p&&(typeof p=="object"&&s(p,c),h.state=function(){return s(c,{})}),h}function i(){var u=4022871197,l=function(c){c=String(c);for(var p=0;p<c.length;p++){u+=c.charCodeAt(p);var h=.02519603282416938*u;u=h>>>0,h-=u,h*=u,u=h>>>0,h-=u,u+=h*4294967296}return(u>>>0)*23283064365386963e-26};return l}t&&t.exports?t.exports=o:this.alea=o})(c4,n)})(Ji)),Ji.exports}var Qi={exports:{}},h4=Qi.exports,Fl;function d4(){return Fl||(Fl=1,(function(n){(function(e,t,r){function a(i){var u=this,l="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var p=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^p^p>>>8},i===(i|0)?u.x=i:l+=i;for(var c=0;c<l.length+64;c++)u.x^=l.charCodeAt(c)|0,u.next()}function s(i,u){return u.x=i.x,u.y=i.y,u.z=i.z,u.w=i.w,u}function o(i,u){var l=new a(i),c=u&&u.state,p=function(){return(l.next()>>>0)/4294967296};return p.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,m=(h+d)/(1<<21);while(m===0);return m},p.int32=l.next,p.quick=p,c&&(typeof c=="object"&&s(c,l),p.state=function(){return s(l,{})}),p}t&&t.exports?t.exports=o:this.xor128=o})(h4,n)})(Qi)),Qi.exports}var eu={exports:{}},f4=eu.exports,Dl;function m4(){return Dl||(Dl=1,(function(n){(function(e,t,r){function a(i){var u=this,l="";u.next=function(){var p=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(p^p<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,i===(i|0)?u.x=i:l+=i;for(var c=0;c<l.length+64;c++)u.x^=l.charCodeAt(c)|0,c==l.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function s(i,u){return u.x=i.x,u.y=i.y,u.z=i.z,u.w=i.w,u.v=i.v,u.d=i.d,u}function o(i,u){var l=new a(i),c=u&&u.state,p=function(){return(l.next()>>>0)/4294967296};return p.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,m=(h+d)/(1<<21);while(m===0);return m},p.int32=l.next,p.quick=p,c&&(typeof c=="object"&&s(c,l),p.state=function(){return s(l,{})}),p}t&&t.exports?t.exports=o:this.xorwow=o})(f4,n)})(eu)),eu.exports}var tu={exports:{}},g4=tu.exports,Ml;function y4(){return Ml||(Ml=1,(function(n){(function(e,t,r){function a(i){var u=this;u.next=function(){var c=u.x,p=u.i,h,d;return h=c[p],h^=h>>>7,d=h^h<<24,h=c[p+1&7],d^=h^h>>>10,h=c[p+3&7],d^=h^h>>>3,h=c[p+4&7],d^=h^h<<7,h=c[p+7&7],h=h^h<<13,d^=h^h<<9,c[p]=d,u.i=p+1&7,d};function l(c,p){var h,d=[];if(p===(p|0))d[0]=p;else for(p=""+p,h=0;h<p.length;++h)d[h&7]=d[h&7]<<15^p.charCodeAt(h)+d[h+1&7]<<13;for(;d.length<8;)d.push(0);for(h=0;h<8&&d[h]===0;++h);for(h==8?d[7]=-1:d[h],c.x=d,c.i=0,h=256;h>0;--h)c.next()}l(u,i)}function s(i,u){return u.x=i.x.slice(),u.i=i.i,u}function o(i,u){i==null&&(i=+new Date);var l=new a(i),c=u&&u.state,p=function(){return(l.next()>>>0)/4294967296};return p.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,m=(h+d)/(1<<21);while(m===0);return m},p.int32=l.next,p.quick=p,c&&(c.x&&s(c,l),p.state=function(){return s(l,{})}),p}t&&t.exports?t.exports=o:this.xorshift7=o})(g4,n)})(tu)),tu.exports}var nu={exports:{}},x4=nu.exports,Ll;function b4(){return Ll||(Ll=1,(function(n){(function(e,t,r){function a(i){var u=this;u.next=function(){var c=u.w,p=u.X,h=u.i,d,m;return u.w=c=c+1640531527|0,m=p[h+34&127],d=p[h=h+1&127],m^=m<<13,d^=d<<17,m^=m>>>15,d^=d>>>12,m=p[h]=m^d,u.i=h,m+(c^c>>>16)|0};function l(c,p){var h,d,m,y,b,x=[],T=128;for(p===(p|0)?(d=p,p=null):(p=p+"\0",d=0,T=Math.max(T,p.length)),m=0,y=-32;y<T;
2594++y)p&&(d^=p.charCodeAt((y+32)%p.length)),y===0&&(b=d),d^=d<<10,d^=d>>>15,d^=d<<4,d^=d>>>13,y>=0&&(b=b+1640531527|0,h=x[y&127]^=d+b,m=h==0?m+1:0);for(m>=128&&(x[(p&&p.length||0)&127]=-1),m=127,y=512;y>0;--y)d=x[m+34&127],h=x[m=m+1&127],d^=d<<13,h^=h<<17,d^=d>>>15,h^=h>>>12,x[m]=d^h;c.w=b,c.X=x,c.i=m}l(u,i)}function s(i,u){return u.i=i.i,u.w=i.w,u.X=i.X.slice(),u}function o(i,u){i==null&&(i=+new Date);var l=new a(i),c=u&&u.state,p=function(){return(l.next()>>>0)/4294967296};return p.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,m=(h+d)/(1<<21);while(m===0);return m},p.int32=l.next,p.quick=p,c&&(c.X&&s(c,l),p.state=function(){return s(l,{})}),p}t&&t.exports?t.exports=o:this.xor4096=o})(x4,n)})(nu)),nu.exports}var ru={exports:{}},v4=ru.exports,Pl;function w4(){return Pl||(Pl=1,(function(n){(function(e,t,r){function a(i){var u=this,l="";u.next=function(){var p=u.b,h=u.c,d=u.d,m=u.a;return p=p<<25^p>>>7^h,h=h-d|0,d=d<<24^d>>>8^m,m=m-p|0,u.b=p=p<<20^p>>>12^h,u.c=h=h-d|0,u.d=d<<16^h>>>16^m,u.a=m-p|0},u.a=0,u.b=0,u.c=-1640531527,u.d=1367130551,i===Math.floor(i)?(u.a=i/4294967296|0,u.b=i|0):l+=i;for(var c=0;c<l.length+20;c++)u.b^=l.charCodeAt(c)|0,u.next()}function s(i,u){return u.a=i.a,u.b=i.b,u.c=i.c,u.d=i.d,u}function o(i,u){var l=new a(i),c=u&&u.state,p=function(){return(l.next()>>>0)/4294967296};return p.double=function(){do var h=l.next()>>>11,d=(l.next()>>>0)/4294967296,m=(h+d)/(1<<21);while(m===0);return m},p.int32=l.next,p.quick=p,c&&(typeof c=="object"&&s(c,l),p.state=function(){return s(l,{})}),p}t&&t.exports?t.exports=o:this.tychei=o})(v4,n)})(ru)),ru.exports}var au={exports:{}}
2594,S4=au.exports,Bl;function k4(){return Bl||(Bl=1,(function(n){(function(e,t,r){var a=256,s=6,o=52,i="random",u=r.pow(a,s),l=r.pow(2,o),c=l*2,p=a-1,h;function d(F,M,U){var X=[];M=M==!0?{entropy:!0}:M||{};var z=x(b(M.entropy?[F,$(t)]:F??T(),3),X),L=new m(X),C=function(){for(var q=L.g(s),ee=u,te=0;q<l;)q=(q+te)*a,ee*=a,te=L.g(1);for(;q>=c;)q/=2,ee/=2,te>>>=1;return(q+te)/ee};return C.int32=function(){return L.g(4)|0},C.quick=function(){return L.g(4)/4294967296},C.double=C,x($(L.S),t),(M.pass||U||function(q,ee,te,le){return le&&(le.S&&y(le,L),q.state=function(){return y(L,{})}),te?(r[i]=q,ee):q})(C,z,"global"in M?M.global:this==r,M.state)}function m(F){var M,U=F.length,X=this,z=0,L=X.i=X.j=0,C=X.S=[];for(U||(F=[U++]);z<a;)C[z]=z++;for(z=0;z<a;z++)C[z]=C[L=p&L+F[z%U]+(M=C[z])],C[L]=M;(X.g=function(q){for(var ee,te=0,le=X.i,de=X.j,fe=X.S;q--;)ee=fe[le=p&le+1],te=te*a+fe[p&(fe[le]=fe[de=p&de+ee])+(fe[de]=ee)];return X.i=le,X.j=de,te})(a)}function y(F,M){return M.i=F.i,M.j=F.j,M.S=F.S.slice(),M}function b(F,M){var U=[],X=typeof F,z;if(M&&X=="object")for(z in F)try{U.push(b(F[z],M-1))}catch{}return U.length?U:X=="string"?F:F+"\0"}function x(F,M){for(var U=F+"",X,z=0;z<U.length;)M[p&z]=p&(X^=M[p&z]*19)+U.charCodeAt(z++);return $(M)}function T(){try{var F;return h&&(F=h.randomBytes)?F=F(a):(F=new Uint8Array(a),(e.crypto||e.msCrypto).getRandomValues(F)),$(F)}catch{var M=e.navigator,U=M&&M.plugins;return[+new Date,e,U,e.screen,$(t)]}}function $(F){return String.fromCharCode.apply(0,F)}if(x(r.random(),t),n.exports){n.exports=d;try{h=o2}catch{}}else r["seed"+i]=d})(typeof self<"u"?self:S4,[],Math)})(au)),au.exports}var si,Ul;function T4(){if(Ul)return si;Ul=1;var n=p4(),e=d4(),t=m4(),r=y4(),a=b4(),s=w4(),o=k4();return o.alea=n,o.xor128=e,o.xorwow=t,o.xorshift7=r,o.xor4096=a,o.tychei=s,si=o,si}var Xu=T4();/** 2595 * @license 2596 * Copyright 2018 Google LLC. All Rights Reserved. 2597 * Licensed under the Apache License, Version 2.0 (the "License"); 2598 * you may not use this file except in compliance with the License. 2599 * You may obtain a copy of the License at 2600 * 2601 * http://www.apache.org/licenses/LICENSE-2.0 2602 * 2603 * Unless required by applicable law or agreed to in writing, software 2604 * distributed under the License is distributed on an "AS IS" BASIS, 2605 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2606 * See the License for the specific language governing permissions and 2607 * limitations under the License. 2608 * ============================================================================= 2609 */class qu{constructor(e,t,r,a,s){this.mean=e,this.stdDev=t,this.dtype=r,this.nextVal=NaN,this.truncated=a,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);const o=s||Math.random();this.random=Xu.alea(o.toString())}nextValue(){if(!isNaN(this.nextVal)){const a=this.nextVal;return this.nextVal=NaN,a}let e,t,r=!1;for(;!r;){let a,s,o;do a=2*this.random()-1,s=2*this.random()-1,o=a*a+s*s;while(o>=1||o===0);const i=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*a*i,t=this.mean+this.stdDev*s*i,(!this.truncated||this.isValidTruncated(e))&&(r=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class E4{constructor(e,t,r,a){this.alpha=e,this.beta=1/t,this.dtype=r;const s=a||Math.random();this.randu=Xu.alea(s.toString()),this.randn=new qu(0,1,r,!1,this.randu()),e<1?this.d=e+2/3:this.d=e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,r,a,s,o;for(;;){do a=this.randn.nextValue(),o=1+this.c*a;while(o<=0);if(o*=o*o,e=a*a,t=1-.331*e*e,r=.5*e+this.d*(1-o+Math.log(o)),s=this.randu(),s<t||Math.log(s)<r)break}return o=1/this.beta*this.d*o,this.alpha<1&&(o*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(o)}convertValue(e){return this.dtype==="float32"?e:Math.round(e)}}class C4{constructor(e=0,t=1,r,a){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=r,a==null&&(a=Math.random()),typeof a=="number"&&(a=a.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=Xu.alea(a)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}
2609nextValue(){return this.convertValue(this.min+this.range*this.random())}}/** 2610 * @license 2611 * Copyright 2020 Google LLC. All Rights Reserved. 2612 * Licensed under the Apache License, Version 2.0 (the "License"); 2613 * you may not use this file except in compliance with the License. 2614 * You may obtain a copy of the License at 2615 * 2616 * http://www.apache.org/licenses/LICENSE-2.0 2617 * 2618 * Unless required by applicable law or agreed to in writing, software 2619 * distributed under the License is distributed on an "AS IS" BASIS, 2620 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2621 * See the License for the specific language governing permissions and 2622 * limitations under the License. 2623 * ============================================================================= 2624 */function I4(n,e,t=1,r="float32",a){if(t==null&&(t=1),r==null&&(r="float32"),r!=="float32"&&r!=="int32")throw new Error(`Unsupported data type ${r}`);const s=new E4(e,t,r,a),o=He(n,r);for(let i=0;i<o.values.length;i++)o.values[i]=s.nextValue();return o.toTensor()}const N4=P({randomGamma_:I4});/** 2625 * @license 2626 * Copyright 2020 Google LLC. All Rights Reserved. 2627 * Licensed under the Apache License, Version 2.0 (the "License"); 2628 * you may not use this file except in compliance with the License. 2629 * You may obtain a copy of the License at 2630 * 2631 * http://www.apache.org/licenses/LICENSE-2.0 2632 * 2633 * Unless required by applicable law or agreed to in writing, software 2634 * distributed under the License is distributed on an "AS IS" BASIS, 2635 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2636 * See the License for the specific language governing permissions and 2637 * limitations under the License. 2638 * ============================================================================= 2639 */function $4(n,e=0,t=1,r,a){if(r!=null&&r==="bool")throw new Error(`Unsupported data type ${r}`);const s=new qu(e,t,r,!1,a),o=He(n,r);for(let i=0;i<o.values.length;i++)o.values[i]=s.nextValue();return o.toTensor()}const Qf=P({randomNormal_:$4});/** 2640 * @license 2641 * Copyright 2022 Google LLC. All Rights Reserved. 2642 * Licensed under the Apache License, Version 2.0 (the "License"); 2643 * you may not use this file except in compliance with the License. 2644 * You may obtain a copy of the License at 2645 * 2646 * http://www.apache.org/licenses/LICENSE-2.0 2647 * 2648 * Unless required by applicable law or agreed to in writing, software 2649 * distributed under the License is distributed on an "AS IS" BASIS, 2650 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2651 * See the License for the specific language governing permissions and 2652 * limitations under the License. 2653 * ============================================================================= 2654 */function R4(n,e,t){if(e!=null&&e==="bool")throw new Error(`Unsupported data type ${e}`);return Qf(n,0,1,e,t)}const _4=P({randomStandardNormal_:R4});/** 2655 * @license 2656 * Copyright 2020 Google LLC. All Rights Reserved. 2657 * Licensed under the Apache License, Version 2.0 (the "License"); 2658 * you may not use this file except in compliance with the License. 2659 * You may obtain a copy of the License at 2660 * 2661 * http://www.apache.org/licenses/LICENSE-2.0 2662 * 2663 * Unless required by applicable law or agreed to in writing, software 2664 * distributed under the License is distributed on an "AS IS" BASIS, 2665 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2666 * See the License for the specific language governing permissions and 2667 * limitations under the License. 2668 * ============================================================================= 2669 */function A4(n,e=0,t=1,r="float32",a){const s=He(n,r),o=new C4(e,t,null,a);for(let i=0;i<s.values.length;i++)s.values[i]=o.nextValue();return s.toTensor()}const e1=P({randomUniform_:A4});/** 2670 * @license 2671 * Copyright 2018 Google LLC. All Rights Reserved. 2672 * Licensed under the Apache License, Version 2.0 (the "License"); 2673 * you may not use this file except in compliance with the License. 2674 * You may obtain a copy of the License at 2675 * 2676 * http://www.apache.org/licenses/LICENSE-2.0 2677 * 2678 * Unless required by applicable law or agreed to in writing, softw
2678are 2679 * distributed under the License is distributed on an "AS IS" BASIS, 2680 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2681 * See the License for the specific language governing permissions and 2682 * limitations under the License. 2683 * ============================================================================= 2684 */function ss(n,e,t=1,r="float32"){if(t===0)throw new Error("Cannot have a step of zero");const a={start:n,stop:e,step:t,dtype:r};return V.runKernel(Lh,{},a)}/** 2685 * @license 2686 * Copyright 2018 Google LLC. All Rights Reserved. 2687 * Licensed under the Apache License, Version 2.0 (the "License"); 2688 * you may not use this file except in compliance with the License. 2689 * You may obtain a copy of the License at 2690 * 2691 * http://www.apache.org/licenses/LICENSE-2.0 2692 * 2693 * Unless required by applicable law or agreed to in writing, software 2694 * distributed under the License is distributed on an "AS IS" BASIS, 2695 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2696 * See the License for the specific language governing permissions and 2697 * limitations under the License. 2698 * ============================================================================= 2699 */function O4(n){const e={x:N(n,"x","reciprocal")};return V.runKernel(Bh,e)}const F4=P({reciprocal_:O4});/** 2700 * @license 2701 * Copyright 2020 Google LLC. All Rights Reserved. 2702 * Licensed under the Apache License, Version 2.0 (the "License"); 2703 * you may not use this file except in compliance with the License. 2704 * You may obtain a copy of the License at 2705 * 2706 * http://www.apache.org/licenses/LICENSE-2.0 2707 * 2708 * Unless required by applicable law or agreed to in writing, software 2709 * distributed under the License is distributed on an "AS IS" BASIS, 2710 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2711 * See the License for the specific language governing permissions and 2712 * limitations under the License. 2713 * ============================================================================= 2714 */function D4(n){const e={x:N(n,"x","relu")};return V.runKernel(Uh,e)}const Ro=P({relu_:D4});/** 2715 * @license 2716 * Copyright 2020 Google LLC. All Rights Reserved. 2717 * Licensed under the Apache License, Version 2.0 (the "License"); 2718 * you may not use this file except in compliance with the License. 2719 * You may obtain a copy of the License at 2720 * 2721 * http://www.apache.org/licenses/LICENSE-2.0 2722 * 2723 * Unless required by applicable law or agreed to in writing, software 2724 * distributed under the License is distributed on an "AS IS" BASIS, 2725 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2726 * See the License for the specific language governing permissions and 2727 * limitations under the License. 2728 * ============================================================================= 2729 */function M4(n){const e={x:N(n,"x","relu6")};return V.runKernel(Gh,e)}const t1=P({relu6_:M4});/** 2730 * @license 2731 * Copyright 2018 Google LLC. All Rights Reserved. 2732 * Licensed under the Apache License, Version 2.0 (the "License"); 2733 * you may not use this file except in compliance with the License. 2734 * You may obtain a copy of the License at 2735 * 2736 * http://www.apache.org/licenses/LICENSE-2.0 2737 * 2738 * Unless required by applicable law or agreed to in writing, software 2739 * distributed under the License is distributed on an "AS IS" BASIS, 2740 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2741 * See the License for the specific language governing permissions and 2742 * limitations under the License. 2743 * ============================================================================= 2744 */function L4(n,e){const t={x:N(n,"x","reverse")},r={dims:e};return V.runKernel(jh,t,r)}const Dr=P({reverse_:L4});/** 2745 * @license 2746 * Copyright 2020 Google LLC. All Rights Reserved. 2747 * Licensed under the Apache License, Version 2.0 (the "License"); 2748 * you may not use this file except in compliance with the License. 2749 * You may obtain a copy of the License at 2750 * 2751 * http://www.apache.org/licenses/LICENSE-2.0 2752 * 2753 * Unless required by applicable law or agreed to in writing, software 2754 * distributed under the License is distributed on an "AS IS" BASIS, 2755 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2756 * See the License for the specific language governing permissions and 2757 * limitations under the License. 2758 * ============================================================================= 2759 */function P4(n){const e=N(n,"x","reverse");return R(e.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`),Dr(e,0)}const B4=P({reverse1d_:P4});/** 2760 * @license 2761 * Copyright 2020 Google LLC. All Rights Reserved. 2762 * Licensed under the Apache License, Version 2.0 (the "License");
2763 * you may not use this file except in compliance with the License. 2764 * You may obtain a copy of the License at 2765 * 2766 * http://www.apache.org/licenses/LICENSE-2.0 2767 * 2768 * Unless required by applicable law or agreed to in writing, software 2769 * distributed under the License is distributed on an "AS IS" BASIS, 2770 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2771 * See the License for the specific language governing permissions and 2772 * limitations under the License. 2773 * ============================================================================= 2774 */function U4(n,e){const t=N(n,"x","reverse");return R(t.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${t.rank}.`),Dr(t,e)}const V4=P({reverse2d_:U4});/** 2775 * @license 2776 * Copyright 2020 Google LLC. All Rights Reserved. 2777 * Licensed under the Apache License, Version 2.0 (the "License"); 2778 * you may not use this file except in compliance with the License. 2779 * You may obtain a copy of the License at 2780 * 2781 * http://www.apache.org/licenses/LICENSE-2.0 2782 * 2783 * Unless required by applicable law or agreed to in writing, software 2784 * distributed under the License is distributed on an "AS IS" BASIS, 2785 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2786 * See the License for the specific language governing permissions and 2787 * limitations under the License. 2788 * ============================================================================= 2789 */function W4(n,e){const t=N(n,"x","reverse");return R(t.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${t.rank}.`),Dr(t,e)}const z4=P({reverse3d_:W4});/** 2790 * @license 2791 * Copyright 2020 Google LLC. All Rights Reserved. 2792 * Licensed under the Apache License, Version 2.0 (the "License"); 2793 * you may not use this file except in compliance with the License. 2794 * You may obtain a copy of the License at 2795 * 2796 * http://www.apache.org/licenses/LICENSE-2.0 2797 * 2798 * Unless required by applicable law or agreed to in writing, software 2799 * distributed under the License is distributed on an "AS IS" BASIS, 2800 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2801 * See the License for the specific language governing permissions and 2802 * limitations under the License. 2803 * ============================================================================= 2804 */function G4(n,e){const t=N(n,"x","reverse");return R(t.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${t.rank}.`),Dr(t,e)}const j4=P({reverse4d_:G4});/** 2805 * @license 2806 * Copyright 2018 Google LLC. All Rights Reserved. 2807 * Licensed under the Apache License, Version 2.0 (the "License"); 2808 * you may not use this file except in compliance with the License. 2809 * You may obtain a copy of the License at 2810 * 2811 * http://www.apache.org/licenses/LICENSE-2.0 2812 * 2813 * Unless required by applicable law or agreed to in writing, software 2814 * distributed under the License is distributed on an "AS IS" BASIS, 2815 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2816 * See the License for the specific language governing permissions and 2817 * limitations under the License. 2818 * ============================================================================= 2819 */function H4(n){const e={x:N(n,"x","round")};return V.runKernel(Hh,e)}const n1=P({round_:H4});/** 2820 * @license 2821 * Copyright 2018 Google LLC. All Rights Reserved. 2822 * Licensed under the Apache License, Version 2.0 (the "License"); 2823 * you may not use this file except in compliance with the License. 2824 * You may obtain a copy of the License at 2825 * 2826 * http://www.apache.org/licenses/LICENSE-2.0 2827 * 2828 * Unless required by applicable law or agreed to in writing, software 2829 * distributed under the License is distributed on an "AS IS" BASIS, 2830 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2831 * See the License for the specific language governing permissions and 2832 * limitations under the License. 2833 * ============================================================================= 2834 */function X4(n){const e={x:N(n,"x","rsqrt","float32")};return V.runKernel(Xh,e)}const q4=P({rsqrt_:X4});/** 2835 * @license 2836 * Copyright 2020 Google LLC. All Rights Reserved. 2837 * Licensed under the Apache License, Version 2.0 (the "License");
2838 * you may not use this file except in compliance with the License. 2839 * You may obtain a copy of the License at 2840 * 2841 * http://www.apache.org/licenses/LICENSE-2.0 2842 * 2843 * Unless required by applicable law or agreed to in writing, software 2844 * distributed under the License is distributed on an "AS IS" BASIS, 2845 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2846 * See the License for the specific language governing permissions and 2847 * limitations under the License. 2848 * ============================================================================= 2849 */function K4(n){const e={x:N(n,"x","selu")};return V.runKernel(Zh,e)}const Y4=P({selu_:K4});function Z4(n,e,t,r,a,s=[1,1],o="NHWC"){const i=N(n,"x","separableConv2d"),u=N(e,"depthwiseFilter","separableConv2d"),l=N(t,"pointwiseFilter","separableConv2d");let c=i,p=!1;if(i.rank===3&&(p=!0,c=Z(i,[1,i.shape[0],i.shape[1],i.shape[2]])),o==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");R(c.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`),R(u.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`),R(l.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`),R(l.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`),R(l.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`);const h=u.shape[2],d=u.shape[3];R(l.shape[2]===h*d,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${h*d}, but got ${l.shape[2]}.`);const m=Uu(c,u,r,a,o,s),y=Co(m,l,1,"valid",o);return p?Z(y,[y.shape[1],y.shape[2],y.shape[3]]):y}const J4=P({separableConv2d_:Z4});/** 2850 * @license 2851 * Copyright 2020 Google Inc. All Rights Reserved. 2852 * Licensed under the Apache License, Version 2.0 (the "License"); 2853 * you may not use this file except in compliance with the License. 2854 * You may obtain a copy of the License at 2855 * 2856 * http://www.apache.org/licenses/LICENSE-2.0 2857 * 2858 * Unless required by applicable law or agreed to in writing, software 2859 * distributed under the License is distributed on an "AS IS" BASIS, 2860 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2861 * See the License for the specific language governing permissions and 2862 * limitations under the License. 2863 * ============================================================================= 2864 */async function Q4(n,e){const t=N(n,"x","setdiff1d"),r=N(e,"y","setdiff1d");R(t.dtype===r.dtype,()=>`x and y should have the same dtype, but got x (${t.dtype}) and y (${r.dtype}).`),R(t.rank===1,()=>`x should be 1D tensor, but got x (${t.shape}).`),R(r.rank===1,()=>`y should be 1D tensor, but got y (${r.shape}).`);const a=await t.data(),s=await r.data(),o=new Set(s);let i=0;for(let c=0;c<a.length;c++)o.has(a[c])||i++;const u=new ts([i],t.dtype),l=new ts([i],"int32");for(let c=0,p=0;c<a.length;c++)o.has(a[c])||(u.values[p]=a[c],l.values[p]=c,p++);return[u.toTensor(),l.toTensor()]}const eb=Q4;/** 2865 * @license 2866 * Copyright 2018 Google LLC. All Rights Reserved. 2867 * Licensed under the Apache License, Version 2.0 (the "License"); 2868 * you may not use this file except in compliance with the License. 2869 * You may obtain a copy of the License at 2870 * 2871 * http://www.apache.org/licenses/LICENSE-2.0 2872 * 2873 * Unless required by applicable law or agreed to in writing, software 2874 * distributed under the License is distributed on an "AS IS" BASIS, 2875 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2876 * See the License for the specific language governing permissions and 2877 * limitations under the License. 2878 * ============================================================================= 2879 */function tb(n){const e={x:N(n,"x","sign")};return V.runKernel(td,e)}const nb=P({sign_:tb});/** 2880 * @license 2881 * Copyright 2018 Google LLC. All Rights Reserved. 2882 * Licensed under the Apache License, Version 2.0 (the "License"); 2883 * you may not use this file except in compliance with the License. 2884 * You may obtain a copy of the License at 2885 * 2886 * http://www.apache.org/licenses/LICENSE-2.0 2887 * 2888 * Unless required by applicable law or agreed to in writing, softw
2888are 2889 * distributed under the License is distributed on an "AS IS" BASIS, 2890 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2891 * See the License for the specific language governing permissions and 2892 * limitations under the License. 2893 * ============================================================================= 2894 */function rb(n){const e={x:N(n,"x","sin","float32")};return V.runKernel(Qh,e)}const ab=P({sin_:rb});/** 2895 * @license 2896 * Copyright 2018 Google LLC. All Rights Reserved. 2897 * Licensed under the Apache License, Version 2.0 (the "License"); 2898 * you may not use this file except in compliance with the License. 2899 * You may obtain a copy of the License at 2900 * 2901 * http://www.apache.org/licenses/LICENSE-2.0 2902 * 2903 * Unless required by applicable law or agreed to in writing, software 2904 * distributed under the License is distributed on an "AS IS" BASIS, 2905 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2906 * See the License for the specific language governing permissions and 2907 * limitations under the License. 2908 * ============================================================================= 2909 */function sb(n){const e={x:N(n,"x","sinh")};return V.runKernel(ed,e)}const ob=P({sinh_:sb});/** 2910 * @license 2911 * Copyright 2018 Google LLC. All Rights Reserved. 2912 * Licensed under the Apache License, Version 2.0 (the "License"); 2913 * you may not use this file except in compliance with the License. 2914 * You may obtain a copy of the License at 2915 * 2916 * http://www.apache.org/licenses/LICENSE-2.0 2917 * 2918 * Unless required by applicable law or agreed to in writing, software 2919 * distributed under the License is distributed on an "AS IS" BASIS, 2920 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2921 * See the License for the specific language governing permissions and 2922 * limitations under the License. 2923 * ============================================================================= 2924 */function ib(n,e,t){const r=N(n,"x","slice1d");return R(r.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`),we(r,[e],[t])}const ub=P({slice1d_:ib});/** 2925 * @license 2926 * Copyright 2018 Google LLC. All Rights Reserved. 2927 * Licensed under the Apache License, Version 2.0 (the "License"); 2928 * you may not use this file except in compliance with the License. 2929 * You may obtain a copy of the License at 2930 * 2931 * http://www.apache.org/licenses/LICENSE-2.0 2932 * 2933 * Unless required by applicable law or agreed to in writing, software 2934 * distributed under the License is distributed on an "AS IS" BASIS, 2935 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2936 * See the License for the specific language governing permissions and 2937 * limitations under the License. 2938 * ============================================================================= 2939 */function lb(n,e,t){const r=N(n,"x","slice2d");return R(r.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`),we(r,e,t)}const cb=P({slice2d_:lb});/** 2940 * @license 2941 * Copyright 2018 Google LLC. All Rights Reserved. 2942 * Licensed under the Apache License, Version 2.0 (the "License"); 2943 * you may not use this file except in compliance with the License. 2944 * You may obtain a copy of the License at 2945 * 2946 * http://www.apache.org/licenses/LICENSE-2.0 2947 * 2948 * Unless required by applicable law or agreed to in writing, software 2949 * distributed under the License is distributed on an "AS IS" BASIS, 2950 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2951 * See the License for the specific language governing permissions and 2952 * limitations under the License. 2953 * ============================================================================= 2954 */function pb(n,e,t){const r=N(n,"x","slice3d");return R(r.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`),we(r,e,t)}const hb=P({slice3d_:pb});/** 2955 * @license 2956 * Copyright 2018 Google LLC. All Rights Reserved. 2957 * Licensed under the Apache License, Version 2.0 (the "License"); 2958 * you may not use this file except in compliance with the License. 2959 * You may obtain a copy of the License at 2960 * 2961 * http://www.apache.org/licenses/LICENSE-2.0 2962 * 2963 * Unless required by applicable law or agreed to in writing, softw
2963are 2964 * distributed under the License is distributed on an "AS IS" BASIS, 2965 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2966 * See the License for the specific language governing permissions and 2967 * limitations under the License. 2968 * ============================================================================= 2969 */function db(n,e,t){const r=N(n,"x","slice4d");return R(r.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`),we(r,e,t)}const fb=P({slice4d_:db});/** 2970 * @license 2971 * Copyright 2018 Google LLC. All Rights Reserved. 2972 * Licensed under the Apache License, Version 2.0 (the "License"); 2973 * you may not use this file except in compliance with the License. 2974 * You may obtain a copy of the License at 2975 * 2976 * http://www.apache.org/licenses/LICENSE-2.0 2977 * 2978 * Unless required by applicable law or agreed to in writing, software 2979 * distributed under the License is distributed on an "AS IS" BASIS, 2980 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2981 * See the License for the specific language governing permissions and 2982 * limitations under the License. 2983 * ============================================================================= 2984 */function mb(n,e=-1){const t=N(n,"logits","softmax","float32");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${e}`);const r={logits:t},a={dim:e};return V.runKernel(ud,r,a)}const gb=P({softmax_:mb});/** 2985 * @license 2986 * Copyright 2020 Google LLC. All Rights Reserved. 2987 * Licensed under the Apache License, Version 2.0 (the "License"); 2988 * you may not use this file except in compliance with the License. 2989 * You may obtain a copy of the License at 2990 * 2991 * http://www.apache.org/licenses/LICENSE-2.0 2992 * 2993 * Unless required by applicable law or agreed to in writing, software 2994 * distributed under the License is distributed on an "AS IS" BASIS, 2995 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2996 * See the License for the specific language governing permissions and 2997 * limitations under the License. 2998 * ============================================================================= 2999 */function yb(n){R(n.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${n.dtype}.`);const e={input:n};return V.runKernel(Up,e)}const Ku=P({fft_:yb});/** 3000 * @license 3001 * Copyright 2020 Google LLC. All Rights Reserved. 3002 * Licensed under the Apache License, Version 2.0 (the "License"); 3003 * you may not use this file except in compliance with the License. 3004 * You may obtain a copy of the License at 3005 * 3006 * http://www.apache.org/licenses/LICENSE-2.0 3007 * 3008 * Unless required by applicable law or agreed to in writing, software 3009 * distributed under the License is distributed on an "AS IS" BASIS, 3010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3011 * See the License for the specific language governing permissions and 3012 * limitations under the License. 3013 * ============================================================================= 3014 */function xb(n){R(n.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${n.dtype}.`);const e={input:n};return V.runKernel(Yp,e)}const uo=P({ifft_:xb});/** 3015 * @license 3016 * Copyright 2018 Google LLC. All Rights Reserved. 3017 * Licensed under the Apache License, Version 2.0 (the "License"); 3018 * you may not use this file except in compliance with the License. 3019 * You may obtain a copy of the License at 3020 * 3021 * http://www.apache.org/licenses/LICENSE-2.0 3022 * 3023 * Unless required by applicable law or agreed to in writing, software 3024 * distributed under the License is distributed on an "AS IS" BASIS, 3025 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3026 * See the License for the specific language governing permissions and 3027 * limitations under the License. 3028 * ============================================================================= 3029 */function bb(n){const e=n.shape[n.shape.length-1],t=n.size/e;let r;if(e<=2){const a=Z(n,[t,e]);r=uo(a)}else{const a=[t,2*(e-1)],s=Z(ns(n),[t,e]),o=Z(ko(n),[t,e]),i=Dr(we(s,[0,1],[t,e-2]),1),u=me(Dr(we(o,[0,1],[t,e-2]),1),Ae(-1)),l=it([s,i],1),c=it([o,u],1),p=Z(tr(l,c),[a[0],a[1]]);r=uo(p)}if(r=ns(r),n.rank===3&&n.shape[0]!==0){const a=r,s=n.shape[0];r=Z(r,[s,r.shape[0]/s,r.shape[1]]),a.dispose()}return r}const r1=P({irfft_:bb});/** 3030 * @license 3031 * Copyright 2020 Google LLC. All Rights Reserved. 3032 * Licensed under the Apache License, Version 2.0 (the "License");
3033 * you may not use this file except in compliance with the License. 3034 * You may obtain a copy of the License at 3035 * 3036 * http://www.apache.org/licenses/LICENSE-2.0 3037 * 3038 * Unless required by applicable law or agreed to in writing, software 3039 * distributed under the License is distributed on an "AS IS" BASIS, 3040 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3041 * See the License for the specific language governing permissions and 3042 * limitations under the License. 3043 * ============================================================================= 3044 */function vb(n,e,t=0){const r={x:N(n,"x","split")},a={numOrSizeSplits:e,axis:t};return V.runKernel(id,r,a)}const os=P({split_:vb});/** 3045 * @license 3046 * Copyright 2018 Google LLC. All Rights Reserved. 3047 * Licensed under the Apache License, Version 2.0 (the "License"); 3048 * you may not use this file except in compliance with the License. 3049 * You may obtain a copy of the License at 3050 * 3051 * http://www.apache.org/licenses/LICENSE-2.0 3052 * 3053 * Unless required by applicable law or agreed to in writing, software 3054 * distributed under the License is distributed on an "AS IS" BASIS, 3055 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3056 * See the License for the specific language governing permissions and 3057 * limitations under the License. 3058 * ============================================================================= 3059 */function wb(n,e){R(n.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${n.dtype}`);let t=n.shape[n.shape.length-1];const r=n.size/t;let a;if(e!=null&&e<t){const m=n.shape.map(b=>0),y=n.shape.map(b=>b);y[n.shape.length-1]=e,a=we(n,m,y),t=e}else if(e!=null&&e>t){const m=n.shape.map(y=>y);m[n.shape.length-1]=e-t,a=it([n,Fr(m)],n.shape.length-1),t=e}else a=n;const s=Vu(a),o=Z(tr(a,s),[r,t]),i=Ku(o),u=Math.floor(t/2)+1,l=ns(i),c=ko(i),p=os(l,[u,t-u],l.shape.length-1),h=os(c,[u,t-u],c.shape.length-1),d=a.shape.slice();return d[a.shape.length-1]=u,Z(tr(p[0],h[0]),d)}const Yu=P({rfft_:wb});/** 3060 * @license 3061 * Copyright 2020 Google LLC. All Rights Reserved. 3062 * Licensed under the Apache License, Version 2.0 (the "License"); 3063 * you may not use this file except in compliance with the License. 3064 * You may obtain a copy of the License at 3065 * 3066 * http://www.apache.org/licenses/LICENSE-2.0 3067 * 3068 * Unless required by applicable law or agreed to in writing, software 3069 * distributed under the License is distributed on an "AS IS" BASIS, 3070 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3071 * See the License for the specific language governing permissions and 3072 * limitations under the License. 3073 * ============================================================================= 3074 */function Sb(n,e){let t=N(n,"a","squaredDifference"),r=N(e,"b","squaredDifference");[t,r]=Ke(t,r),$e(t.shape,r.shape);const a={a:t,b:r},s={};return V.runKernel(fd,a,s)}const a1=P({squaredDifference_:Sb});/** 3075 * @license 3076 * Copyright 2020 Google LLC. All Rights Reserved. 3077 * Licensed under the Apache License, Version 2.0 (the "License"); 3078 * you may not use this file except in compliance with the License. 3079 * You may obtain a copy of the License at 3080 * 3081 * http://www.apache.org/licenses/LICENSE-2.0 3082 * 3083 * Unless required by applicable law or agreed to in writing, software 3084 * distributed under the License is distributed on an "AS IS" BASIS, 3085 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3086 * See the License for the specific language governing permissions and 3087 * limitations under the License. 3088 * ============================================================================= 3089 */function kb(n,e){const t=N(n,"x","squeeze","string_or_numeric");return Z(t,rr(t.shape,e).newShape)}const tt=P({squeeze_:kb});/** 3090 * @license 3091 * Copyright 2020 Google LLC. All Rights Reserved. 3092 * Licensed under the Apache License, Version 2.0 (the "License"); 3093 * you may not use this file except in compliance with the License. 3094 * You may obtain a copy of the License at 3095 * 3096 * http://www.apache.org/licenses/LICENSE-2.0 3097 * 3098 * Unless required by applicable law or agreed to in writing, softw
3098are 3099 * distributed under the License is distributed on an "AS IS" BASIS, 3100 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3101 * See the License for the specific language governing permissions and 3102 * limitations under the License. 3103 * ============================================================================= 3104 */function Tb(n,e=0){const t=no(n,"tensors","stack","string_or_numeric");R(t.length>=1,()=>"Pass at least one tensor to tf.stack"),t.length>0&&R(e<=t[0].rank,()=>"Axis must be <= rank of the tensor");const r=t,a={axis:e};return V.runKernel(Rh,r,a)}const Mn=P({stack_:Tb});/** 3105 * @license 3106 * Copyright 2018 Google LLC. All Rights Reserved. 3107 * Licensed under the Apache License, Version 2.0 (the "License"); 3108 * you may not use this file except in compliance with the License. 3109 * You may obtain a copy of the License at 3110 * 3111 * http://www.apache.org/licenses/LICENSE-2.0 3112 * 3113 * Unless required by applicable law or agreed to in writing, software 3114 * distributed under the License is distributed on an "AS IS" BASIS, 3115 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3116 * See the License for the specific language governing permissions and 3117 * limitations under the License. 3118 * ============================================================================= 3119 */function Eb(n,e=0){const t={x:N(n,"x","step")},r={alpha:e};return V.runKernel(Nd,t,r)}const s1=P({step_:Eb});/** 3120 * @license 3121 * Copyright 2018 Google LLC. All Rights Reserved. 3122 * Licensed under the Apache License, Version 2.0 (the "License"); 3123 * you may not use this file except in compliance with the License. 3124 * You may obtain a copy of the License at 3125 * 3126 * http://www.apache.org/licenses/LICENSE-2.0 3127 * 3128 * Unless required by applicable law or agreed to in writing, software 3129 * distributed under the License is distributed on an "AS IS" BASIS, 3130 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3131 * See the License for the specific language governing permissions and 3132 * limitations under the License. 3133 * ============================================================================= 3134 */function Cb(n,e,t,r,a=0,s=0,o=0,i=0,u=0){const l={x:N(n,"x","stridedSlice","string_or_numeric")},c={begin:e,end:t,strides:r,beginMask:a,endMask:s,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:u};return V.runKernel(md,l,c)}const Ib=P({stridedSlice_:Cb});/** 3135 * @license 3136 * Copyright 2018 Google LLC. All Rights Reserved. 3137 * Licensed under the Apache License, Version 2.0 (the "License"); 3138 * you may not use this file except in compliance with the License. 3139 * You may obtain a copy of the License at 3140 * 3141 * http://www.apache.org/licenses/LICENSE-2.0 3142 * 3143 * Unless required by applicable law or agreed to in writing, software 3144 * distributed under the License is distributed on an "AS IS" BASIS, 3145 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3146 * See the License for the specific language governing permissions and 3147 * limitations under the License. 3148 * ============================================================================= 3149 */function Nb(n){const e={x:N(n,"x","tan","float32")};return V.runKernel(vd,e)}const $b=P({tan_:Nb});/** 3150 * @license 3151 * Copyright 2018 Google LLC. All Rights Reserved. 3152 * Licensed under the Apache License, Version 2.0 (the "License"); 3153 * you may not use this file except in compliance with the License. 3154 * You may obtain a copy of the License at 3155 * 3156 * http://www.apache.org/licenses/LICENSE-2.0 3157 * 3158 * Unless required by applicable law or agreed to in writing, software 3159 * distributed under the License is distributed on an "AS IS" BASIS, 3160 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3161 * See the License for the specific language governing permissions and 3162 * limitations under the License. 3163 * ============================================================================= 3164 */function gt(n,e){ga(n);const t=ar(n,e);if(t.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return sr(n,null,t,e)}/** 3165 * @license 3166 * Copyright 2018 Google LLC. All Rights Reserved. 3167 * Licensed under the Apache License, Version 2.0 (the "License");
3168 * you may not use this file except in compliance with the License. 3169 * You may obtain a copy of the License at 3170 * 3171 * http://www.apache.org/licenses/LICENSE-2.0 3172 * 3173 * Unless required by applicable law or agreed to in writing, software 3174 * distributed under the License is distributed on an "AS IS" BASIS, 3175 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3176 * See the License for the specific language governing permissions and 3177 * limitations under the License. 3178 * ============================================================================= 3179 */function Qn(n,e,t){if(ga(n),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");const r=ar(n,t);if(r.length!==2&&r.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(r.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return sr(n,e,r,t)}/** 3180 * @license 3181 * Copyright 2018 Google LLC. All Rights Reserved. 3182 * Licensed under the Apache License, Version 2.0 (the "License"); 3183 * you may not use this file except in compliance with the License. 3184 * You may obtain a copy of the License at 3185 * 3186 * http://www.apache.org/licenses/LICENSE-2.0 3187 * 3188 * Unless required by applicable law or agreed to in writing, software 3189 * distributed under the License is distributed on an "AS IS" BASIS, 3190 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3191 * See the License for the specific language governing permissions and 3192 * limitations under the License. 3193 * ============================================================================= 3194 */function Rb(n,e,t){if(ga(n),e!=null&&e.length!==4)throw new Error("tensor4d() requires shape to have four numbers");const r=ar(n,t);if(r.length!==4&&r.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(r.length===1&&e==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return sr(n,e,r,t)}/** 3195 * @license 3196 * Copyright 2018 Google LLC. All Rights Reserved. 3197 * Licensed under the Apache License, Version 2.0 (the "License"); 3198 * you may not use this file except in compliance with the License. 3199 * You may obtain a copy of the License at 3200 * 3201 * http://www.apache.org/licenses/LICENSE-2.0 3202 * 3203 * Unless required by applicable law or agreed to in writing, software 3204 * distributed under the License is distributed on an "AS IS" BASIS, 3205 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3206 * See the License for the specific language governing permissions and 3207 * limitations under the License. 3208 * ============================================================================= 3209 */function _b(n,e,t){if(ga(n),e!=null&&e.length!==5)throw new Error("tensor5d() requires shape to have five numbers");const r=ar(n,t);if(r.length!==5&&r.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(r.length===1&&e==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return sr(n,e,r,t)}/** 3210 * @license 3211 * Copyright 2018 Google LLC. All Rights Reserved. 3212 * Licensed under the Apache License, Version 2.0 (the "License"); 3213 * you may not use this file except in compliance with the License. 3214 * You may obtain a copy of the License at 3215 * 3216 * http://www.apache.org/licenses/LICENSE-2.0 3217 * 3218 * Unless required by applicable law or agreed to in writing, software 3219 * distributed under the License is distributed on an "AS IS" BASIS, 3220 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3221 * See the License for the specific language governing permissions and 3222 * limitations under the License. 3223 * ============================================================================= 3224 */function Ab(n,e,t){if(ga(n),e!=null&&e.length!==6)throw new Error("tensor6d() requires shape to have six numbers");const r=ar(n,t);if(r.length!==6&&r.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(r.length===1&&e==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return e=e||r,sr(n,e,r,t)}/** 3225 * @license 3226 * Copyright 2018 Google LLC. All Rights Reserved. 3227 * Licensed under the Apache License, Version 2.0 (the "License");
3228 * you may not use this file except in compliance with the License. 3229 * You may obtain a copy of the License at 3230 * 3231 * http://www.apache.org/licenses/LICENSE-2.0 3232 * 3233 * Unless required by applicable law or agreed to in writing, software 3234 * distributed under the License is distributed on an "AS IS" BASIS, 3235 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3236 * See the License for the specific language governing permissions and 3237 * limitations under the License. 3238 * ============================================================================= 3239 */function Ob(n,e=1,t=!0){const r=N(n,"x","topk");if(r.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${e}`);const s={x:r},o={k:e,sorted:t},[i,u]=V.runKernel(Sd,s,o);return{values:i,indices:u}}const Fb=P({topk_:Ob});/** 3240 * @license 3241 * Copyright 2020 Google LLC. All Rights Reserved. 3242 * Licensed under the Apache License, Version 2.0 (the "License"); 3243 * you may not use this file except in compliance with the License. 3244 * You may obtain a copy of the License at 3245 * 3246 * http://www.apache.org/licenses/LICENSE-2.0 3247 * 3248 * Unless required by applicable law or agreed to in writing, software 3249 * distributed under the License is distributed on an "AS IS" BASIS, 3250 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3251 * See the License for the specific language governing permissions and 3252 * limitations under the License. 3253 * ============================================================================= 3254 */function Db(n,e=0,t=1,r,a){if(r!=null&&r==="bool")throw new Error("Unsupported data type $ { dtype }");const s=new qu(e,t,r,!0,a),o=He(n,r);for(let i=0;i<o.values.length;i++)o.values[i]=s.nextValue();return o.toTensor()}const Mb=P({truncatedNormal_:Db});/** 3255 * @license 3256 * Copyright 2020 Google LLC. All Rights Reserved. 3257 * Licensed under the Apache License, Version 2.0 (the "License"); 3258 * you may not use this file except in compliance with the License. 3259 * You may obtain a copy of the License at 3260 * 3261 * http://www.apache.org/licenses/LICENSE-2.0 3262 * 3263 * Unless required by applicable law or agreed to in writing, software 3264 * distributed under the License is distributed on an "AS IS" BASIS, 3265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3266 * See the License for the specific language governing permissions and 3267 * limitations under the License. 3268 * ============================================================================= 3269 */function Lb(n,e=0){const t=N(n,"x","unique","string_or_numeric");R(t.rank>0,()=>"The input tensor must be at least 1D");const r={x:t},a={axis:e},[s,o]=V.runKernel(Td,r,a);return{values:s,indices:o}}const Pb=P({unique_:Lb});/** 3270 * @license 3271 * Copyright 2020 Google LLC. All Rights Reserved. 3272 * Licensed under the Apache License, Version 2.0 (the "License"); 3273 * you may not use this file except in compliance with the License. 3274 * You may obtain a copy of the License at 3275 * 3276 * http://www.apache.org/licenses/LICENSE-2.0 3277 * 3278 * Unless required by applicable law or agreed to in writing, software 3279 * distributed under the License is distributed on an "AS IS" BASIS, 3280 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3281 * See the License for the specific language governing permissions and 3282 * limitations under the License. 3283 * ============================================================================= 3284 */function Bb(n,e,t){const r=N(n,"x","unsortedSegmentSum"),a=N(e,"segmentIds","unsortedSegmentSum","int32");R(ua(t),()=>"numSegments must be of dtype int");const s={x:r,segmentIds:a},o={numSegments:t};return V.runKernel(Cd,s,o)}const Ub=P({unsortedSegmentSum_:Bb});/** 3285 * @license 3286 * Copyright 2020 Google LLC. All Rights Reserved. 3287 * Licensed under the Apache License, Version 2.0 (the "License"); 3288 * you may not use this file except in compliance with the License. 3289 * You may obtain a copy of the License at 3290 * 3291 * http://www.apache.org/licenses/LICENSE-2.0 3292 * 3293 * Unless required by applicable law or agreed to in writing, softw
3293are 3294 * distributed under the License is distributed on an "AS IS" BASIS, 3295 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3296 * See the License for the specific language governing permissions and 3297 * limitations under the License. 3298 * ============================================================================= 3299 */function Vb(n,e=0){const t=N(n,"x","unstack","string_or_numeric");R(e>=-t.shape.length&&e<t.shape.length,()=>`Axis = ${e} is not in [-${t.shape.length}, ${t.shape.length})`);const r={value:t},a={axis:e};return V.runKernel(Ed,r,a)}const Br=P({unstack_:Vb});/** 3300 * @license 3301 * Copyright 2022 Google LLC. All Rights Reserved. 3302 * Licensed under the Apache License, Version 2.0 (the "License"); 3303 * you may not use this file except in compliance with the License. 3304 * You may obtain a copy of the License at 3305 * 3306 * http://www.apache.org/licenses/LICENSE-2.0 3307 * 3308 * Unless required by applicable law or agreed to in writing, software 3309 * distributed under the License is distributed on an "AS IS" BASIS, 3310 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3311 * See the License for the specific language governing permissions and 3312 * limitations under the License. 3313 * ============================================================================= 3314 */function Wb(n,e){return Hu(n,e,"right")}/** 3315 * @license 3316 * Copyright 2018 Google LLC. All Rights Reserved. 3317 * Licensed under the Apache License, Version 2.0 (the "License"); 3318 * you may not use this file except in compliance with the License. 3319 * You may obtain a copy of the License at 3320 * 3321 * http://www.apache.org/licenses/LICENSE-2.0 3322 * 3323 * Unless required by applicable law or agreed to in writing, software 3324 * distributed under the License is distributed on an "AS IS" BASIS, 3325 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3326 * See the License for the specific language governing permissions and 3327 * limitations under the License. 3328 * ============================================================================= 3329 */function zb(n,e=!0,t,r){return V.makeVariable(n,e,t,r)}/** 3330 * @license 3331 * Copyright 2018 Google LLC. All Rights Reserved. 3332 * Licensed under the Apache License, Version 2.0 (the "License"); 3333 * you may not use this file except in compliance with the License. 3334 * You may obtain a copy of the License at 3335 * 3336 * http://www.apache.org/licenses/LICENSE-2.0 3337 * 3338 * Unless required by applicable law or agreed to in writing, software 3339 * distributed under the License is distributed on an "AS IS" BASIS, 3340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3341 * See the License for the specific language governing permissions and 3342 * limitations under the License. 3343 * ============================================================================= 3344 */function o1(n,e){const t=[];for(let s=0;s<e.length;s++)e[s]&&t.push(s);const r=He(n,"int32"),a=He([t.length,n.length],"int32");for(let s=0;s<t.length;s++){const o=r.indexToLoc(t[s]),i=s*n.length;a.values.set(o,i)}return a.toTensor()}/** 3345 * @license 3346 * Copyright 2020 Google LLC. All Rights Reserved. 3347 * Licensed under the Apache License, Version 2.0 (the "License"); 3348 * you may not use this file except in compliance with the License. 3349 * You may obtain a copy of the License at 3350 * 3351 * http://www.apache.org/licenses/LICENSE-2.0 3352 * 3353 * Unless required by applicable law or agreed to in writing, software 3354 * distributed under the License is distributed on an "AS IS" BASIS, 3355 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3356 * See the License for the specific language governing permissions and 3357 * limitations under the License. 3358 * ============================================================================= 3359 */async function Gb(n){const e=N(n,"condition","whereAsync","bool"),t=await e.data(),r=o1(e.shape,t);return n!==e&&e.dispose(),r}const i1=Gb;/** 3360 * @license 3361 * Copyright 2018 Google LLC. All Rights Reserved. 3362 * Licensed under the Apache License, Version 2.0 (the "License"); 3363 * you may not use this file except in compliance with the License. 3364 * You may obtain a copy of the License at 3365 * 3366 * http://www.apache.org/licenses/LICENSE-2.0 3367 * 3368 * Unless required by applicable law or agreed to in writing, softw
3368are 3369 * distributed under the License is distributed on an "AS IS" BASIS, 3370 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3371 * See the License for the specific language governing permissions and 3372 * limitations under the License. 3373 * ============================================================================= 3374 */async function jb(n,e,t){const r=N(n,"tensor","boolMask"),a=N(e,"mask","boolMask","bool"),s=t??0,o=a.rank,i=r.shape;R(o>0,()=>"mask cannot be scalar"),Lt(i.slice(s,s+o),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let y=s;y<s+o;y++)u*=i[y];const l=i.slice(0,s).concat([u],i.slice(s+o)),c=Z(r,l),p=Z(a,[-1]),h=await i1(p),d=tt(h,[1]),m=Uf(c,d,s);return n!==r&&r.dispose(),e!==a&&a.dispose(),d.dispose(),c.dispose(),p.dispose(),h.dispose(),m}const Hb=jb;/** 3375 * @license 3376 * Copyright 2018 Google LLC. All Rights Reserved. 3377 * Licensed under the Apache License, Version 2.0 (the "License"); 3378 * you may not use this file except in compliance with the License. 3379 * You may obtain a copy of the License at 3380 * 3381 * http://www.apache.org/licenses/LICENSE-2.0 3382 * 3383 * Unless required by applicable law or agreed to in writing, software 3384 * distributed under the License is distributed on an "AS IS" BASIS, 3385 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3386 * See the License for the specific language governing permissions and 3387 * limitations under the License. 3388 * ============================================================================= 3389 */function Xb(n,e,t,r,a=!0){const s=N(n,"v","movingAverage"),o=N(e,"x","movingAverage"),i=N(t,"decay","movingAverage");ig(s,o),R(qe(s.shape,o.shape),()=>"Shape mismatch in v and x");const u=Ae(1),l=Ce(u,i);let c=me(Ce(o,s),l);if(a){R(r!=null,()=>"When using zeroDebias: true, step is required.");const p=N(r,"step","movingAverage");c=De(c,Ce(u,Gu(i,p)))}return Pe(s,c)}const qb=P({movingAverage_:Xb});/** 3390 * @license 3391 * Copyright 2018 Google LLC. All Rights Reserved. 3392 * Licensed under the Apache License, Version 2.0 (the "License"); 3393 * you may not use this file except in compliance with the License. 3394 * You may obtain a copy of the License at 3395 * 3396 * http://www.apache.org/licenses/LICENSE-2.0 3397 * 3398 * Unless required by applicable law or agreed to in writing, software 3399 * distributed under the License is distributed on an "AS IS" BASIS, 3400 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3401 * See the License for the specific language governing permissions and 3402 * limitations under the License. 3403 * ============================================================================= 3404 */function Kb(n,e,t){const r=N(n,"indices","scatterND","int32"),a=N(e,"updates","scatterND");ff(a,r,t);const s={indices:r,updates:a},o={shape:t};return V.runKernel(qh,s,o)}const Yb=P({scatterND_:Kb});function Zb(n,e,t,r){if(n.dtype!=="int32")throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${n.dtype}.`);if(n.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${n.shape}.`);const a=n.rank>0?n.shape[0]:1,s=n.rank>1?n.shape[1]:1;if(t.length!==s)throw new Error(`outputShape has incorrect number of elements:, ${t.length}, should be: ${s}.`);const o=e.size;if(!(e.rank===0||e.rank===1&&o===a))throw new Error(`sparseValues has incorrect shape ${e.shape}, should be [] or [${a}]`);if(e.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}/** 3405 * @license 3406 * Copyright 2018 Google LLC. All Rights Reserved. 3407 * Licensed under the Apache License, Version 2.0 (the "License"); 3408 * you may not use this file except in compliance with the License. 3409 * You may obtain a copy of the License at 3410 * 3411 * http://www.apache.org/licenses/LICENSE-2.0 3412 * 3413 * Unless required by applicable law or agreed to in writing, software 3414 * distributed under the License is distributed on an "AS IS" BASIS, 3415 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3416 * See the License for the specific language governing permissions and 3417 * limitations under the License. 3418 * ============================================================================= 3419 */function Jb(n,e,t,r=0){const a=N(n,"sparseIndices","sparseToDense","int32"),s=N(e,"sparseValues","sparseToDense","string_or_numeric"),o=N(r,"defaultValue","sparseToDense",s.dtype);Zb(a,s,t,o);const i={sparseIndices:a,sparseValues:s,defaultValue:o},u={outputShape:t};return V.runKernel(dd,i,u)}const Qb=P({sparseToDense_:Jb});/** 3420 * @license 3421 * Copyright 2018 Google LLC. All Rights Reserved. 3422 * Licensed under the Apache License, Version 2.0 (the "License");
3423 * you may not use this file except in compliance with the License. 3424 * You may obtain a copy of the License at 3425 * 3426 * http://www.apache.org/licenses/LICENSE-2.0 3427 * 3428 * Unless required by applicable law or agreed to in writing, software 3429 * distributed under the License is distributed on an "AS IS" BASIS, 3430 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3431 * See the License for the specific language governing permissions and 3432 * limitations under the License. 3433 * ============================================================================= 3434 */function ev(n,e){const t=N(e,"indices","gatherND","int32"),r={params:N(n,"x","gatherND","string_or_numeric"),indices:t};return V.runKernel(Xp,r)}const tv=P({gatherND_:ev});/** 3435 * @license 3436 * Copyright 2019 Google LLC. All Rights Reserved. 3437 * Licensed under the Apache License, Version 2.0 (the "License"); 3438 * you may not use this file except in compliance with the License. 3439 * You may obtain a copy of the License at 3440 * 3441 * http://www.apache.org/licenses/LICENSE-2.0 3442 * 3443 * Unless required by applicable law or agreed to in writing, software 3444 * distributed under the License is distributed on an "AS IS" BASIS, 3445 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3446 * See the License for the specific language governing permissions and 3447 * limitations under the License. 3448 * ============================================================================= 3449 */function nv(n,e){if(e==null)return n.shape.slice();if(qe(n.shape,e))return e;if(n.shape.length===e.length){const t=[];for(let r=0;r<n.shape.length;r++)e[r]==null&&n.shape[r]!=null?t.push(n.shape[r]):t.push(e[r]);return t}return e}/** 3450 * @license 3451 * Copyright 2018 Google LLC. All Rights Reserved. 3452 * Licensed under the Apache License, Version 2.0 (the "License"); 3453 * you may not use this file except in compliance with the License. 3454 * You may obtain a copy of the License at 3455 * 3456 * http://www.apache.org/licenses/LICENSE-2.0 3457 * 3458 * Unless required by applicable law or agreed to in writing, software 3459 * distributed under the License is distributed on an "AS IS" BASIS, 3460 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3461 * See the License for the specific language governing permissions and 3462 * limitations under the License. 3463 * ============================================================================= 3464 */function rv(n,e,t,r){const a=N(n,"x","dropout");if(R(a.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`),R(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return n instanceof Ge?a.clone():a;const s=nv(a,t),o=1-e,i=De(Bf(Pe(e1(s,0,1,"float32",r),o)),o);return me(a,i)}const av=P({dropout_:rv});/** 3465 * @license 3466 * Copyright 2019 Google LLC. All Rights Reserved. 3467 * Licensed under the Apache License, Version 2.0 (the "License"); 3468 * you may not use this file except in compliance with the License. 3469 * You may obtain a copy of the License at 3470 * 3471 * http://www.apache.org/licenses/LICENSE-2.0 3472 * 3473 * Unless required by applicable law or agreed to in writing, software 3474 * distributed under the License is distributed on an "AS IS" BASIS, 3475 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3476 * See the License for the specific language governing permissions and 3477 * limitations under the License. 3478 * ============================================================================= 3479 */function u1(n){return Math.floor(Math.pow(2,Math.ceil(Math.log(n)/Math.log(2))))}function Zu(n,e,t){const r=1-n%2,a=new Float32Array(n);for(let s=0;s<n;++s){const o=2*Math.PI*s/(n+r-1);a[s]=e-t*Math.cos(o)}return gt(a,"float32")}/** 3480 * @license 3481 * Copyright 2019 Google LLC. All Rights Reserved. 3482 * Licensed under the Apache License, Version 2.0 (the "License"); 3483 * you may not use this file except in compliance with the License. 3484 * You may obtain a copy of the License at 3485 * 3486 * http://www.apache.org/licenses/LICENSE-2.0 3487 * 3488 * Unless required by applicable law or agreed to in writing, software 3489 * distributed under the License is distributed on an "AS IS" BASIS, 3490 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3491 * See the License for the specific language governing permissions and 3492 * limitations under the License. 3493 * ============================================================================= 3494 */async function sv(n,e,t=1){const r=N(n,"predictions","inTopK"),a=N(e,"targets","inTopK");R(r.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`),R(r.rank-1===a.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`),Lt(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const s=r.shape[r.shape.length-1];R(t>0&&t<=s,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${t}`);const o=await r.data(),i=await a.data(),[u,l]=[o.length/s,s],c=On("bool",u);for(let p=0;p<u;p++){const h=p*l,d=o.subarray(h,h+l),m=[];for(let y=0;y<d.length;y++)m.push({value:d[y],index:y});m.sort((y,b)=>
vendor: 6,911 bytes, lines 3494-3542
3494b.value-y.value),c[p]=0;for(let y=0;y<t;y++)if(m[y].index===i[p]){c[p]=1;break}}return n!==r&&r.dispose(),e!==a&&a.dispose(),vn(c,a.shape,"bool")}const ov=sv;/** 3495 * @license 3496 * Copyright 2020 Google LLC. All Rights Reserved. 3497 * Licensed under the Apache License, Version 2.0 (the "License"); 3498 * you may not use this file except in compliance with the License. 3499 * You may obtain a copy of the License at 3500 * 3501 * http://www.apache.org/licenses/LICENSE-2.0 3502 * 3503 * Unless required by applicable law or agreed to in writing, software 3504 * distributed under the License is distributed on an "AS IS" BASIS, 3505 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3506 * See the License for the specific language governing permissions and 3507 * limitations under the License. 3508 * ============================================================================= 3509 */function iv(n,e,t,r,a,s="NHWC",o){let i=n;n.rank===3&&(i=Z(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let u=e;u.rank===3&&(u=Z(e,[1,e.shape[0],e.shape[1],e.shape[2]])),R(i.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`),R(u.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${u.shape}.`),R(t.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${t}.`);const l=s==="NHWC"?i.shape[3]:i.shape[1],c=s==="NHWC"?u.shape[3]:u.shape[1];R(l===t[2],()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${t[2]}.`),R(c===t[3],()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${t[3]}).`),Jt("conv2dDerFilter",a,o);const p={x:i,dy:u},h={strides:r,pad:a,dataFormat:s,dimRoundingMode:o,filterShape:t};return V.runKernel(gp,p,h)}const uv=P({conv2DBackpropFilter_:iv});/** 3510 * @license 3511 * Copyright 2019 Google LLC. All Rights Reserved. 3512 * Licensed under the Apache License, Version 2.0 (the "License"); 3513 * you may not use this file except in compliance with the License. 3514 * You may obtain a copy of the License at 3515 * 3516 * http://www.apache.org/licenses/LICENSE-2.0 3517 * 3518 * Unless required by applicable law or agreed to in writing, software 3519 * distributed under the License is distributed on an "AS IS" BASIS, 3520 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3521 * See the License for the specific language governing permissions and 3522 * limitations under the License. 3523 * ============================================================================= 3524 */function _o(n,e,t){if(t==null||t==="linear")return n;if(t==="relu")return me(n,s1(e));throw new Error(`Cannot compute gradient for fused activation ${t}.`)}function Ao(n,e){let t=e;const r=uf(n.shape,e.shape);return r.length>0&&(t=Ve(t,r)),Z(t,n.shape)}function Oo(n,e,t,r){if(e==="linear")return n;if(e==="relu")return Ro(n);if(e==="elu")return Df(n);if(e==="relu6")return t1(n);if(e==="prelu")return Jf(n,t);if(e==="leakyrelu")return Wf(n,r);if(e==="sigmoid")return Rr(n);throw new Error(`Unknown fused activation ${e}.`)}const Fo=(n,e)=>!(n>0)||e==="linear";/** 3525 * @license 3526 * Copyright 2019 Google LLC. All Rights Reserved. 3527 * Licensed under the Apache License, Version 2.0 (the "License"); 3528 * you may not use this file except in compliance with the License. 3529 * You may obtain a copy of the License at 3530 * 3531 * http://www.apache.org/licenses/LICENSE-2.0 3532 * 3533 * Unless required by applicable law or agreed to in writing, software 3534 * distributed under the License is distributed on an "AS IS" BASIS, 3535 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3536 * See the License for the specific language governing permissions and 3537 * limitations under the License. 3538 * ============================================================================= 3539 */function lv({x:n,filter:e,strides:t,pad:r,dataFormat:a="NHWC",dilations:s=[1,1],dimRoundingMode:o,bias:i,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(u=u||"linear",Fo(V.state.gradientDepth,u)===!1){R(a==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let U=Co(n,e,t,r,a,s,o);return i!=null&&(U=Pe(U,i)),Oo(U,u,l,c)}const p=N(n,"x","conv2d","float32"),h=N(e,"filter","conv2d","float32");let d=p,m=!1;p.rank===3&&(m=!0,d=Z(p,[1,p.shape[0],p.shape[1],p.shape[2]])),R(d.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`),R(h.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${h.rank}.`),Jt("fused conv2d",r,o);const y=a==="NHWC"?d.shape[3]:d.shape[1];R(h.shape[2]===y,()=>`Error in conv2d: depth of input (${y}) must match input depth for filter ${h.shape[2]}.`),R(_t(t,s),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${s}'`);const b=Pt(d.shape,h.shape,t,s,r,o);let x;i!=null&&(x=N(i,"bias","fused conv2d"),[x]=Ke(x,p),a==="NHWC"?$e(b.outShape,x.shape):(R(x.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${x.shape.length}.`),R(x.shape.length===0||x.shape[0]===b.outChannels||x.shape[0]===1,()=>`Error in fused conv2d: bias shape (${x.shape}) is not compatible with the number of output channels (${b.outChannels})`)));let T;if(l!=null){const U=l.shape;if(R(U.length<=1||U.length===3,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${U.length}.`),U.length===1)R(U[0]===1||U[0]===b.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${U}) is not compatible with the number of output channels (${b.outChannels}).`);else if(U.length===3)try{$e(U,b.outShape)}catch{const X=`Error in fused conv2d: PReLU activation weights (${U}) is not compatible with the output shape of the conv2d (${b.outShape}).`;throw Error(X)}T=N(l,"prelu weights","fused conv2d")}const $=(U,X)=>{R(a==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`);const[z,L,C,q]=X,ee=_o(U,C,u);R(rs(s),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);const te=Of(L.shape,ee,z,t,r),le=uv(L,ee,z.shape,t,r),de=[te,le];if(q!=null){const fe=Ao(q,ee);de.push(fe)}return de},F={x:d,filter:h,bias:x,preluActivationWeights:T},M={strides:t,pad:r,dataFormat:a,dilations:s,dimRoundingMode:o,activation:u,leakyreluAlpha:c};return i==null?Dn((U,X,z)=>{let L=V.runKernel(Ai,F,M);return z([X,U,L]),m&&(L=Z(L,[L.shape[1],L.shape[2],L.shape[3]])),{value:L,gradFunc:$}})(d,h):Dn((U,X,z,L)=>{let C=V.runKernel(Ai,F,M);return L([X,U,C,z]),m&&(C=Z(C,[C.shape[1],C.shape[2],C.shape[3]])),{value:C,gradFunc:$}})(d,h,x)}const cv=P({fusedConv2d_:lv});/** 3540 * @license 3541 * Copyright 2020 Google LLC. All Rights Reserved. 3542 * Licensed under the Apache License, Version 2.0 (the "License");
3543 * you may not use this file except in compliance with the License. 3544 * You may obtain a copy of the License at 3545 * 3546 * http://www.apache.org/licenses/LICENSE-2.0 3547 * 3548 * Unless required by applicable law or agreed to in writing, software 3549 * distributed under the License is distributed on an "AS IS" BASIS, 3550 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3551 * See the License for the specific language governing permissions and 3552 * limitations under the License. 3553 * ============================================================================= 3554 */function pv(n,e,t,r,a,s=[1,1],o){let i=n;n.rank===3&&(i=Z(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let u=e;u.rank===3&&(u=Z(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const l={x:i,dy:u},c={strides:r,pad:a,dimRoundingMode:o,dilations:s,filterShape:t};return V.runKernel(Np,l,c)}const hv=P({depthwiseConv2dNativeBackpropFilter_:pv});/** 3555 * @license 3556 * Copyright 2020 Google LLC. All Rights Reserved. 3557 * Licensed under the Apache License, Version 2.0 (the "License"); 3558 * you may not use this file except in compliance with the License. 3559 * You may obtain a copy of the License at 3560 * 3561 * http://www.apache.org/licenses/LICENSE-2.0 3562 * 3563 * Unless required by applicable law or agreed to in writing, software 3564 * distributed under the License is distributed on an "AS IS" BASIS, 3565 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3566 * See the License for the specific language governing permissions and 3567 * limitations under the License. 3568 * ============================================================================= 3569 */function dv(n,e,t,r,a,s=[1,1],o){let i=e,u=!1;e.rank===3&&(u=!0,i=Z(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const l={dy:i,filter:t},c={strides:r,pad:a,dimRoundingMode:o,dilations:s,inputShape:n},p=V.runKernel($p,l,c);return u?Z(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const fv=P({depthwiseConv2dNativeBackpropInput_:dv});/** 3570 * @license 3571 * Copyright 2019 Google LLC. All Rights Reserved. 3572 * Licensed under the Apache License, Version 2.0 (the "License"); 3573 * you may not use this file except in compliance with the License. 3574 * You may obtain a copy of the License at 3575 * 3576 * http://www.apache.org/licenses/LICENSE-2.0 3577 * 3578 * Unless required by applicable law or agreed to in writing, software 3579 * distributed under the License is distributed on an "AS IS" BASIS, 3580 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3581 * See the License for the specific language governing permissions and 3582 * limitations under the License. 3583 * ============================================================================= 3584 */function mv({x:n,filter:e,strides:t,pad:r,dataFormat:a="NHWC",dilations:s=[1,1],dimRoundingMode:o,bias:i,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(Fo(V.state.gradientDepth,u)===!1){let M=Uu(n,e,t,r,a,s,o);return i!=null&&(M=Pe(M,i)),Oo(M,u,l,c)}const p=N(n,"x","depthwiseConv2d","float32"),h=N(e,"filter","depthwiseConv2d","float32");let d=p,m=!1;p.rank===3&&(m=!0,d=Z(p,[1,p.shape[0],p.shape[1],p.shape[2]])),R(d.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`),R(h.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${h.rank}.`),R(d.shape[3]===h.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${d.shape[3]}) must match the inChannels dimension in filter ${h.shape[2]}.`),s==null&&(s=[1,1]),R(_t(t,s),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${t} and dilations '${s}'`),Jt("fused depthwiseConv2d",r,o);const y=Pt(d.shape,h.shape,t,s,r,o,!0);let b;i!=null&&(b=N(i,"bias","fused conv2d"),[b]=Ke(b,p),$e(y.outShape,b.shape));let x;l!=null&&(x=N(l,"prelu weights","fused depthwiseConv2d"));const T=(M,U)=>{R(rs(s),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);const[X,z,L,C]=U,q=_o(M,L,u),ee=fv(z.shape,q,X,t,r,s,o),te=hv(z,q,X.shape,t,r,s,o);if(C!=null){const le=Ao(b,q);return[ee,te,le]}return[ee,te]},$={x:d,filter:h,bias:b,preluActivationWeights:x},F={strides:t,pad:r,dataFormat:a,dilations:s,dimRoundingMode:o,activation:u,leakyreluAlpha:c};return i==null?Dn((M,U,X)=>{let z=V.runKernel(Oi,$,F);return X([U,M,z]),m&&(z=Z(z,[z.shape[1],z.shape[2],z.shape[3]])),{value:z,gradFunc:T}})(d,h):Dn((M,U,X,z)=>{let L=V.runKernel(Oi,$,F);return z([U,M,L,X]),m&&(L=Z(L,[L.shape[1],L.shape[2],L.shape[3]])),{value:L,gradFunc:T}})(d,h,b)}const gv=P({fusedDepthwiseConv2d_:mv});/** 3585 * @license 3586 * Copyright 2019 Google LLC. All Rights Reserved. 3587 * Licensed under the Apache License, Version 2.0 (the "License");
3588 * you may not use this file except in compliance with the License. 3589 * You may obtain a copy of the License at 3590 * 3591 * http://www.apache.org/licenses/LICENSE-2.0 3592 * 3593 * Unless required by applicable law or agreed to in writing, software 3594 * distributed under the License is distributed on an "AS IS" BASIS, 3595 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3596 * See the License for the specific language governing permissions and 3597 * limitations under the License. 3598 * ============================================================================= 3599 */function yv({a:n,b:e,transposeA:t=!1,transposeB:r=!1,bias:a,activation:s="linear",preluActivationWeights:o,leakyreluAlpha:i=.2}){if(Fo(V.state.gradientDepth,s)===!1){let C=Oe(n,e,t,r);return a!=null&&(C=Pe(C,a)),Oo(C,s,o,i)}let u=N(n,"a","fused matMul"),l=N(e,"b","fused matMul");[u,l]=Ke(u,l);const c=t?u.shape[u.rank-2]:u.shape[u.rank-1],p=r?l.shape[l.rank-1]:l.shape[l.rank-2],h=t?u.shape[u.rank-1]:u.shape[u.rank-2],d=r?l.shape[l.rank-2]:l.shape[l.rank-1],m=u.shape.slice(0,-2),y=l.shape.slice(0,-2),b=ae(m),x=ae(y);R(c===p,()=>`Error in fused matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${u.shape} and ${l.shape} and transposeA=${t} and transposeB=${r} must match.`);const T=$e(u.shape.slice(0,-2),l.shape.slice(0,-2)).concat([h,d]),$=t?Z(u,[b,c,h]):Z(u,[b,h,c]),F=r?Z(l,[x,d,p]):Z(l,[x,p,d]);let M;a!=null&&(M=N(a,"bias","fused matMul"),[M]=Ke(M,u),$e(T,M.shape));let U;o!=null&&(U=N(o,"prelu weights","fused matMul"));const X=(C,q)=>{const[ee,te,le,de]=q,fe=_o(Z(C,le.shape),le,s);let Re,ge;if(!t&&!r?(Re=Oe(fe,te,!1,!0),ge=Oe(ee,fe,!0,!1)):!t&&r?(Re=Oe(fe,te,!1,!1),ge=Oe(fe,ee,!0,!1)):t&&!r?(Re=Oe(te,fe,!1,!0),ge=Oe(ee,fe,!1,!1)):(Re=Oe(te,fe,!0,!0),ge=Oe(fe,ee,!0,!0)),a!=null){const Te=Ao(de,fe);return[Re,ge,Te]}else return[Re,ge]},z={a:$,b:F,bias:M,preluActivationWeights:U},L={transposeA:t,transposeB:r,activation:s,leakyreluAlpha:i};return a==null?Dn((C,q,ee)=>{const te=V.runKernel(_i,z,L);return ee([C,q,te]),{value:Z(te,T),gradFunc:X}})($,F):Dn((C,q,ee,te)=>{const le=V.runKernel(_i,z,L);return te([C,q,le,ee]),{value:Z(le,T),gradFunc:X}})($,F,M)}const xv=P({fusedMatMul_:yv});/** 3600 * @license 3601 * Copyright 2019 Google LLC. All Rights Reserved. 3602 * Licensed under the Apache License, Version 2.0 (the "License"); 3603 * you may not use this file except in compliance with the License. 3604 * You may obtain a copy of the License at 3605 * 3606 * http://www.apache.org/licenses/LICENSE-2.0 3607 * 3608 * Unless required by applicable law or agreed to in writing, software 3609 * distributed under the License is distributed on an "AS IS" BASIS, 3610 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3611 * See the License for the specific language governing permissions and 3612 * limitations under the License. 3613 * ============================================================================= 3614 */const bv=Object.freeze(Object.defineProperty({__proto__:null,conv2d:cv,depthwiseConv2d:gv,matMul:xv},Symbol.toStringTag,{value:"Module"}));/** 3615 * @license 3616 * Copyright 2019 Google LLC. All Rights Reserved. 3617 * Licensed under the Apache License, Version 2.0 (the "License"); 3618 * you may not use this file except in compliance with the License. 3619 * You may obtain a copy of the License at 3620 * 3621 * http://www.apache.org/licenses/LICENSE-2.0 3622 * 3623 * Unless required by applicable law or agreed to in writing, software 3624 * distributed under the License is distributed on an "AS IS" BASIS, 3625 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3626 * See the License for the specific language governing permissions and 3627 * limitations under the License. 3628 * ============================================================================= 3629 */function vv(n){return Zu(n,.54,.46)}const wv=P({hammingWindow_:vv});/** 3630 * @license 3631 * Copyright 2019 Google LLC. All Rights Reserved. 3632 * Licensed under the Apache License, Version 2.0 (the "License"); 3633 * you may not use this file except in compliance with the License. 3634 * You may obtain a copy of the License at 3635 * 3636 * http://www.apache.org/licenses/LICENSE-2.0 3637 * 3638 * Unless required by applicable law or agreed to in writing, softw
3638are 3639 * distributed under the License is distributed on an "AS IS" BASIS, 3640 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3641 * See the License for the specific language governing permissions and 3642 * limitations under the License. 3643 * ============================================================================= 3644 */function Sv(n){return Zu(n,.5,.5)}const l1=P({hannWindow_:Sv});/** 3645 * @license 3646 * Copyright 2019 Google LLC. All Rights Reserved. 3647 * Licensed under the Apache License, Version 2.0 (the "License"); 3648 * you may not use this file except in compliance with the License. 3649 * You may obtain a copy of the License at 3650 * 3651 * http://www.apache.org/licenses/LICENSE-2.0 3652 * 3653 * Unless required by applicable law or agreed to in writing, software 3654 * distributed under the License is distributed on an "AS IS" BASIS, 3655 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3656 * See the License for the specific language governing permissions and 3657 * limitations under the License. 3658 * ============================================================================= 3659 */function kv(n,e,t,r=!1,a=0){let s=0;const o=[];for(;s+e<=n.size;)o.push(we(n,s,e)),s+=t;if(r)for(;s<n.size;){const i=s+e-n.size,u=it([we(n,s,e-i),Eo([i],a)]);o.push(u),s+=t}return o.length===0?Qn([],[0,e]):Z(it(o),[o.length,e])}const c1=P({frame_:kv});/** 3660 * @license 3661 * Copyright 2019 Google LLC. All Rights Reserved. 3662 * Licensed under the Apache License, Version 2.0 (the "License"); 3663 * you may not use this file except in compliance with the License. 3664 * You may obtain a copy of the License at 3665 * 3666 * http://www.apache.org/licenses/LICENSE-2.0 3667 * 3668 * Unless required by applicable law or agreed to in writing, software 3669 * distributed under the License is distributed on an "AS IS" BASIS, 3670 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3671 * See the License for the specific language governing permissions and 3672 * limitations under the License. 3673 * ============================================================================= 3674 */function Tv(n,e,t,r,a=l1){r==null&&(r=u1(e));const s=c1(n,e,t),o=me(s,a(e));return Yu(o,r)}const Ev=P({stft_:Tv});/** 3675 * @license 3676 * Copyright 2020 Google LLC. All Rights Reserved. 3677 * Licensed under the Apache License, Version 2.0 (the "License"); 3678 * you may not use this file except in compliance with the License. 3679 * You may obtain a copy of the License at 3680 * 3681 * http://www.apache.org/licenses/LICENSE-2.0 3682 * 3683 * Unless required by applicable law or agreed to in writing, software 3684 * distributed under the License is distributed on an "AS IS" BASIS, 3685 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3686 * See the License for the specific language governing permissions and 3687 * limitations under the License. 3688 * ============================================================================= 3689 */function Cv(n,e,t,r,a="bilinear",s=0){const o=N(n,"image","cropAndResize"),i=N(e,"boxes","cropAndResize","float32"),u=N(t,"boxInd","cropAndResize","int32"),l=i.shape[0];R(o.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`),R(i.rank===2&&i.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${i.shape}.`),R(u.rank===1&&u.shape[0]===l,()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${i.shape}.`),R(r.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`),R(r[0]>=1&&r[1]>=1,()=>`cropSize must be atleast [1,1], but was ${r}`),R(a==="bilinear"||a==="nearest",()=>`method must be bilinear or nearest, but was ${a}`);const c={image:o,boxes:i,boxInd:u},p={method:a,extrapolationValue:s,cropSize:r};return V.runKernel(Tp,c,p)}const Iv=P({cropAndResize_:Cv});/** 3690 * @license 3691 * Copyright 2020 Google LLC. All Rights Reserved. 3692 * Licensed under the Apache License, Version 2.0 (the "License"); 3693 * you may not use this file except in compliance with the License. 3694 * You may obtain a copy of the License at 3695 * 3696 * http://www.apache.org/licenses/LICENSE-2.0 3697 * 3698 * Unless required by applicable law or agreed to in writing, softw
3698are 3699 * distributed under the License is distributed on an "AS IS" BASIS, 3700 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3701 * See the License for the specific language governing permissions and 3702 * limitations under the License. 3703 * ============================================================================= 3704 */function Nv(n){const e=N(n,"image","flipLeftRight","float32");R(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const t={image:e};return V.runKernel(Wp,t,{})}const $v=P({flipLeftRight_:Nv});/** 3705 * @license 3706 * Copyright 2021 Google LLC. All Rights Reserved. 3707 * Licensed under the Apache License, Version 2.0 (the "License"); 3708 * you may not use this file except in compliance with the License. 3709 * You may obtain a copy of the License at 3710 * 3711 * http://www.apache.org/licenses/LICENSE-2.0 3712 * 3713 * Unless required by applicable law or agreed to in writing, software 3714 * distributed under the License is distributed on an "AS IS" BASIS, 3715 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3716 * See the License for the specific language governing permissions and 3717 * limitations under the License. 3718 * ============================================================================= 3719 */function Rv(n){const e=N(n,"image","grayscaleToRGB"),t=e.rank-1,r=e.shape[t];R(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),R(r===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);const a=new Array(e.rank);return a.fill(1,0,t),a[t]=3,es(e,a)}const _v=P({grayscaleToRGB_:Rv});/** 3720 * @license 3721 * Copyright 2020 Google LLC. All Rights Reserved. 3722 * Licensed under the Apache License, Version 2.0 (the "License"); 3723 * you may not use this file except in compliance with the License. 3724 * You may obtain a copy of the License at 3725 * 3726 * http://www.apache.org/licenses/LICENSE-2.0 3727 * 3728 * Unless required by applicable law or agreed to in writing, software 3729 * distributed under the License is distributed on an "AS IS" BASIS, 3730 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3731 * See the License for the specific language governing permissions and 3732 * limitations under the License. 3733 * ============================================================================= 3734 */function Av(n,e,t=0,r=.5){const a=N(n,"image","rotateWithOffset","float32");R(a.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`);const s={image:a},o={radians:e,fillValue:t,center:r};return V.runKernel($d,s,o)}const Ov=P({rotateWithOffset_:Av});/** 3735 * @license 3736 * Copyright 2020 Google LLC. All Rights Reserved. 3737 * Licensed under the Apache License, Version 2.0 (the "License"); 3738 * you may not use this file except in compliance with the License. 3739 * You may obtain a copy of the License at 3740 * 3741 * http://www.apache.org/licenses/LICENSE-2.0 3742 * 3743 * Unless required by applicable law or agreed to in writing, software 3744 * distributed under the License is distributed on an "AS IS" BASIS, 3745 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3746 * See the License for the specific language governing permissions and 3747 * limitations under the License. 3748 * ============================================================================= 3749 */function ba(n,e,t,r,a,s){r==null&&(r=.5),a==null&&(a=Number.NEGATIVE_INFINITY),s==null&&(s=0);const o=n.shape[0];return t=Math.min(t,o),R(0<=r&&r<=1,()=>`iouThreshold must be in [0, 1], but was '${r}'`),R(n.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${n.rank}'`),R(n.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${n.shape[1]}`),R(e.rank===1,()=>"scores must be a 1D tensor"),R(e.shape[0]===o,()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${e.shape[0]}`),R(0<=s&&s<=1,()=>`softNmsSigma must be in [0, 1], but was '${s}'`),{maxOutputSize:t,iouThreshold:r,scoreThreshold:a,softNmsSigma:s}}/** 3750 * @license 3751 * Copyright 2020 Google LLC. All Rights Reserved. 3752 * Licensed under the Apache License, Version 2.0 (the "License");
3753 * you may not use this file except in compliance with the License. 3754 * You may obtain a copy of the License at 3755 * 3756 * http://www.apache.org/licenses/LICENSE-2.0 3757 * 3758 * Unless required by applicable law or agreed to in writing, software 3759 * distributed under the License is distributed on an "AS IS" BASIS, 3760 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3761 * See the License for the specific language governing permissions and 3762 * limitations under the License. 3763 * ============================================================================= 3764 */function Fv(n,e,t,r=.5,a=Number.NEGATIVE_INFINITY){const s=N(n,"boxes","nonMaxSuppression","float32"),o=N(e,"scores","nonMaxSuppression","float32"),i=ba(s,o,t,r,a);t=i.maxOutputSize,r=i.iouThreshold,a=i.scoreThreshold;const u={maxOutputSize:t,iouThreshold:r,scoreThreshold:a};return V.runKernel(Eh,{boxes:s,scores:o},u)}const Dv=P({nonMaxSuppression_:Fv});/** 3765 * @license 3766 * Copyright 2019 Google LLC. All Rights Reserved. 3767 * Licensed under the Apache License, Version 2.0 (the "License"); 3768 * you may not use this file except in compliance with the License. 3769 * You may obtain a copy of the License at 3770 * 3771 * http://www.apache.org/licenses/LICENSE-2.0 3772 * 3773 * Unless required by applicable law or agreed to in writing, software 3774 * distributed under the License is distributed on an "AS IS" BASIS, 3775 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3776 * See the License for the specific language governing permissions and 3777 * limitations under the License. 3778 * ============================================================================= 3779 */function Mv(n,e,t){const r=Lv(n,e,t),a=r<0?-(r+1):r;n.splice(a,0,e)}function Lv(n,e,t){return Bv(n,e,t||Pv)}function Pv(n,e){return n>e?1:n<e?-1:0}function Bv(n,e,t){let r=0,a=n.length,s=0,o=!1;for(;r<a;){s=r+(a-r>>>1);const i=t(e,n[s]);i>0?r=s+1:(a=s,o=!i)}return o?r:-r-1}/** 3780 * @license 3781 * Copyright 2020 Google LLC. All Rights Reserved. 3782 * Licensed under the Apache License, Version 2.0 (the "License"); 3783 * you may not use this file except in compliance with the License. 3784 * You may obtain a copy of the License at 3785 * 3786 * http://www.apache.org/licenses/LICENSE-2.0 3787 * 3788 * Unless required by applicable law or agreed to in writing, software 3789 * distributed under the License is distributed on an "AS IS" BASIS, 3790 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3791 * See the License for the specific language governing permissions and 3792 * limitations under the License. 3793 * ============================================================================= 3794 */function p1(n,e,t,r,a){return Ju(n,e,t,r,a,0)}function h1(n,e,t,r,a,s){return Ju(n,e,t,r,a,0,!1,s,!0)}function d1(n,e,t,r,a,s){return Ju(n,e,t,r,a,s,!0)}function Ju(n,e,t,r,a,s,o=!1,i=!1,u=!1){const l=[];for(let b=0;b<e.length;b++)e[b]>a&&l.push({score:e[b],boxIndex:b,suppressBeginIndex:0});l.sort(Vl);const c=s>0?-.5/s:0,p=[],h=[];for(;p.length<t&&l.length>0;){const b=l.pop(),{score:x,boxIndex:T,suppressBeginIndex:$}=b;if(x<a)break;let F=!1;for(let M=p.length-1;M>=$;--M){const U=Uv(n,T,p[M]);if(U>=r){F=!0;break}if(b.score=b.score*Vv(r,c,U),b.score<=a)break}b.suppressBeginIndex=p.length,F||(b.score===x?(p.push(T),h.push(b.score)):b.score>a&&Mv(l,b,Vl))}const d=p.length,m=t-d;i&&m>0&&(p.push(...new Array(m).fill(0)),h.push(...new Array(m).fill(0)));const y={selectedIndices:p};return o&&(y.selectedScores=h),u&&(y.validOutputs=d),y}function Uv(n,e,t){const r=n.subarray(e*4,e*4+4),a=n.subarray(t*4,t*4+4),s=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),h=Math.max(a[1],a[3]),d=(i-s)*(u-o),m=(p-l)*(h-c);if(d<=0||m<=0)return 0;const y=Math.max(s,l),b=Math.max(o,c),x=Math.min(i,p),T=Math.min(u,h),$=Math.max(x-y,0)*Math.max(T-b,0);return $/(d+m-$)}function Vv(n,e,t){const r=Math.exp(e*t*t);return t<=n?r:0}function Vl(n,e){return n.score-e.score||n.score===e.score&&e.boxIndex-n.boxIndex}/** 3795 * @license 3796 * Copyright 2020 Google LLC. All Rights Reserved. 3797 * Licensed under the Apache License, Version 2.0 (the "License");
3798 * you may not use this file except in compliance with the License. 3799 * You may obtain a copy of the License at 3800 * 3801 * http://www.apache.org/licenses/LICENSE-2.0 3802 * 3803 * Unless required by applicable law or agreed to in writing, software 3804 * distributed under the License is distributed on an "AS IS" BASIS, 3805 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3806 * See the License for the specific language governing permissions and 3807 * limitations under the License. 3808 * ============================================================================= 3809 */async function Wv(n,e,t,r=.5,a=Number.NEGATIVE_INFINITY){const s=N(n,"boxes","nonMaxSuppressionAsync"),o=N(e,"scores","nonMaxSuppressionAsync"),i=ba(s,o,t,r,a);t=i.maxOutputSize,r=i.iouThreshold,a=i.scoreThreshold;const u=await Promise.all([s.data(),o.data()]),l=u[0],c=u[1],{selectedIndices:p}=p1(l,c,t,r,a);return s!==n&&s.dispose(),o!==e&&o.dispose(),gt(p,"int32")}const zv=Wv;/** 3810 * @license 3811 * Copyright 2020 Google LLC. All Rights Reserved. 3812 * Licensed under the Apache License, Version 2.0 (the "License"); 3813 * you may not use this file except in compliance with the License. 3814 * You may obtain a copy of the License at 3815 * 3816 * http://www.apache.org/licenses/LICENSE-2.0 3817 * 3818 * Unless required by applicable law or agreed to in writing, software 3819 * distributed under the License is distributed on an "AS IS" BASIS, 3820 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3821 * See the License for the specific language governing permissions and 3822 * limitations under the License. 3823 * ============================================================================= 3824 */function Gv(n,e,t,r=.5,a=Number.NEGATIVE_INFINITY,s=0){const o=N(n,"boxes","nonMaxSuppression"),i=N(e,"scores","nonMaxSuppression"),u=ba(o,i,t,r,a,s);t=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,s=u.softNmsSigma;const l={boxes:o,scores:i},c={maxOutputSize:t,iouThreshold:r,scoreThreshold:a,softNmsSigma:s},p=V.runKernel(Ih,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}const jv=P({nonMaxSuppressionWithScore_:Gv});/** 3825 * @license 3826 * Copyright 2020 Google LLC. All Rights Reserved. 3827 * Licensed under the Apache License, Version 2.0 (the "License"); 3828 * you may not use this file except in compliance with the License. 3829 * You may obtain a copy of the License at 3830 * 3831 * http://www.apache.org/licenses/LICENSE-2.0 3832 * 3833 * Unless required by applicable law or agreed to in writing, software 3834 * distributed under the License is distributed on an "AS IS" BASIS, 3835 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3836 * See the License for the specific language governing permissions and 3837 * limitations under the License. 3838 * ============================================================================= 3839 */async function Hv(n,e,t,r=.5,a=Number.NEGATIVE_INFINITY,s=0){const o=N(n,"boxes","nonMaxSuppressionAsync"),i=N(e,"scores","nonMaxSuppressionAsync"),u=ba(o,i,t,r,a,s);t=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,s=u.softNmsSigma;const l=await Promise.all([o.data(),i.data()]),c=l[0],p=l[1],{selectedIndices:h,selectedScores:d}=d1(c,p,t,r,a,s);return o!==n&&o.dispose(),i!==e&&i.dispose(),{selectedIndices:gt(h,"int32"),selectedScores:gt(d)}}const Xv=Hv;/** 3840 * @license 3841 * Copyright 2020 Google LLC. All Rights Reserved. 3842 * Licensed under the Apache License, Version 2.0 (the "License"); 3843 * you may not use this file except in compliance with the License. 3844 * You may obtain a copy of the License at 3845 * 3846 * http://www.apache.org/licenses/LICENSE-2.0 3847 * 3848 * Unless required by applicable law or agreed to in writing, software 3849 * distributed under the License is distributed on an "AS IS" BASIS, 3850 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3851 * See the License for the specific language governing permissions and 3852 * limitations under the License. 3853 * ============================================================================= 3854 */function qv(n,e,t,r=.5,a=Number.NEGATIVE_INFINITY,s=!1){const o=N(n,"boxes","nonMaxSuppression"),i=N(e,"scores","nonMaxSuppression"),u=ba(o,i,t,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,h={boxes:o,scores:i},d={maxOutputSize:l,iouThreshold:c,scoreThreshold:p,padToMaxOutputSize:s},m=V.runKernel(Ch,h,d);return{selectedIndices:m[0],validOutputs:m[1]}}const Kv=P({nonMaxSuppressionPadded_:qv});/** 3855 * @license 3856 * Copyright 2020 Google LLC. All Rights Reserved. 3857 * Licensed under the Apache License, Version 2.0 (the "License");
3858 * you may not use this file except in compliance with the License. 3859 * You may obtain a copy of the License at 3860 * 3861 * http://www.apache.org/licenses/LICENSE-2.0 3862 * 3863 * Unless required by applicable law or agreed to in writing, software 3864 * distributed under the License is distributed on an "AS IS" BASIS, 3865 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3866 * See the License for the specific language governing permissions and 3867 * limitations under the License. 3868 * ============================================================================= 3869 */async function Yv(n,e,t,r=.5,a=Number.NEGATIVE_INFINITY,s=!1){const o=N(n,"boxes","nonMaxSuppressionAsync"),i=N(e,"scores","nonMaxSuppressionAsync"),u=ba(o,i,t,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,[h,d]=await Promise.all([o.data(),i.data()]),{selectedIndices:m,validOutputs:y}=h1(h,d,l,c,p,s);return o!==n&&o.dispose(),i!==e&&i.dispose(),{selectedIndices:gt(m,"int32"),validOutputs:Ae(y,"int32")}}const Zv=Yv;/** 3870 * @license 3871 * Copyright 2020 Google LLC. All Rights Reserved. 3872 * Licensed under the Apache License, Version 2.0 (the "License"); 3873 * you may not use this file except in compliance with the License. 3874 * You may obtain a copy of the License at 3875 * 3876 * http://www.apache.org/licenses/LICENSE-2.0 3877 * 3878 * Unless required by applicable law or agreed to in writing, software 3879 * distributed under the License is distributed on an "AS IS" BASIS, 3880 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3881 * See the License for the specific language governing permissions and 3882 * limitations under the License. 3883 * ============================================================================= 3884 */function Jv(n,e,t=!1,r=!1){const a=N(n,"images","resizeBilinear");R(a.rank===3||a.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`),R(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),R(r===!1||t===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let s=a,o=!1;a.rank===3&&(o=!0,s=Z(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const i={images:s},u={alignCorners:t,halfPixelCenters:r,size:e},l=V.runKernel(zh,i,u);return o?Z(l,[l.shape[1],l.shape[2],l.shape[3]]):l}const Qv=P({resizeBilinear_:Jv});/** 3885 * @license 3886 * Copyright 2020 Google LLC. All Rights Reserved. 3887 * Licensed under the Apache License, Version 2.0 (the "License"); 3888 * you may not use this file except in compliance with the License. 3889 * You may obtain a copy of the License at 3890 * 3891 * http://www.apache.org/licenses/LICENSE-2.0 3892 * 3893 * Unless required by applicable law or agreed to in writing, software 3894 * distributed under the License is distributed on an "AS IS" BASIS, 3895 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3896 * See the License for the specific language governing permissions and 3897 * limitations under the License. 3898 * ============================================================================= 3899 */function ew(n,e,t=!1,r=!1){const a=N(n,"images","resizeNearestNeighbor");R(a.rank===3||a.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`),R(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),R(a.dtype==="float32"||a.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),R(r===!1||t===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let s=a,o=!1;a.rank===3&&(o=!0,s=Z(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const i={images:s},u={alignCorners:t,halfPixelCenters:r,size:e},l=V.runKernel(Wh,i,u);return o?Z(l,[l.shape[1],l.shape[2],l.shape[3]]):l}const tw=P({resizeNearestNeighbor_:ew});/** 3900 * @license 3901 * Copyright 2021 Google LLC. All Rights Reserved. 3902 * Licensed under the Apache License, Version 2.0 (the "License"); 3903 * you may not use this file except in compliance with the License. 3904 * You may obtain a copy of the License at 3905 * 3906 * https://www.apache.org/licenses/LICENSE-2.0 3907 * 3908 * Unless required by applicable law or agreed to in writing, softw
3908are 3909 * distributed under the License is distributed on an "AS IS" BASIS, 3910 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3911 * See the License for the specific language governing permissions and 3912 * limitations under the License. 3913 * ============================================================================= 3914 */function nw(n,e="binary",t=!1,r=.5){const a=N(n,"image","threshold"),s=.2989,o=.587,i=.114,u=a.shape[0]*a.shape[1];let l=me(gt([r]),255),c,p,h,d;if(R(a.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`),R(a.shape[2]===3||a.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`),R(a.dtype==="int32"||a.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`),R(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),a.shape[2]===3){[c,p,h]=os(a,[1,1,1],-1);const y=me(c,s),b=me(p,o),x=me(h,i);d=Pe(Pe(y,b),x)}else d=n;if(e==="otsu"){const y=_f(je(n1(d),"int32"),vn([]),256);l=rw(y,u)}const m=t?ju(d,l):$o(d,l);return je(me(m,255),"int32")}function rw(n,e){let t=gt([-1]),r=gt([0]),a=gt([0]),s,o,i,u,l,c;for(let p=0;p<n.size-1;p++){s=we(n,0,p+1),o=we(n,p+1),l=De(Ve(s),e),c=De(Ve(o),e);const h=Ve(me(s,ss(0,s.size)));i=De(h,Ve(s));const d=Eo(o.shape,s.size),m=Pe(ss(0,o.size),d),y=me(o,m);u=De(Ve(y),Ve(o));const b=Ce(i,u),x=Ce(i,u),T=me(l,c);a=me(me(T,b),x);const $=$o(a,r);r=ha($,a,r),t=ha($,gt([p]),t)}return t}const aw=P({threshold_:nw});/** 3915 * @license 3916 * Copyright 2021 Google LLC. All Rights Reserved. 3917 * Licensed under the Apache License, Version 2.0 (the "License"); 3918 * you may not use this file except in compliance with the License. 3919 * You may obtain a copy of the License at 3920 * 3921 * http://www.apache.org/licenses/LICENSE-2.0 3922 * 3923 * Unless required by applicable law or agreed to in writing, software 3924 * distributed under the License is distributed on an "AS IS" BASIS, 3925 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3926 * See the License for the specific language governing permissions and 3927 * limitations under the License. 3928 * ============================================================================= 3929 */function sw(n,e,t="nearest",r="constant",a=0,s){const o=N(n,"image","transform","float32"),i=N(e,"transforms","transform","float32");R(o.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${o.rank}.`),R(i.rank===2&&(i.shape[0]===o.shape[0]||i.shape[0]===1)&&i.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),R(s==null||s.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${s}.`);const u={image:o,transforms:i},l={interpolation:t,fillMode:r,fillValue:a,outputShape:s};return V.runKernel(kd,u,l)}const ow=P({transform_:sw});/** 3930 * @license 3931 * Copyright 2020 Google LLC. All Rights Reserved. 3932 * Licensed under the Apache License, Version 2.0 (the "License"); 3933 * you may not use this file except in compliance with the License. 3934 * You may obtain a copy of the License at 3935 * 3936 * http://www.apache.org/licenses/LICENSE-2.0 3937 * 3938 * Unless required by applicable law or agreed to in writing, software 3939 * distributed under the License is distributed on an "AS IS" BASIS, 3940 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3941 * See the License for the specific language governing permissions and 3942 * limitations under the License. 3943 * ============================================================================= 3944 */function iw(n,e,t){R(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),R(t%1===0,()=>`bandPart(): numUpper must be an integer, got ${t}.`);const r=N(n,"a","bandPart");R(r.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`);const a=r.shape,[s,o]=r.shape.slice(-2);if(!(e<=s))throw new Error(`bandPart(): numLower (${e}) must not be greater than the number of rows (${s}).`);if(!(t<=o))throw new Error(`bandPart(): numUpper (${t}) must not be greater than the number of columns (${o}).`);e<0&&(e=s),t<0&&(t=o);const i=Z(ss(0,s,1,"int32"),[-1,1]),u=ss(0,o,1,"int32"),l=Ce(i,u),c=oo(ju(l,Ae(+e,"int32")),Vf(l,Ae(-t,"int32"))),p=Fr([s,o],r.dtype);return Z(Mn(Br(Z(r,[-1,s,o])).map(h=>ha(c,h,p))),a)}const uw=P({bandPart_:iw});/** 3945 * @license 3946 * Copyright 2020 Google LLC. All Rights Reserved. 3947 * Licensed under the Apache License, Version 2.0 (the "License");
3948 * you may not use this file except in compliance with the License. 3949 * You may obtain a copy of the License at 3950 * 3951 * http://www.apache.org/licenses/LICENSE-2.0 3952 * 3953 * Unless required by applicable law or agreed to in writing, software 3954 * distributed under the License is distributed on an "AS IS" BASIS, 3955 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3956 * See the License for the specific language governing permissions and 3957 * limitations under the License. 3958 * ============================================================================= 3959 */function lw(n){let e;if(Array.isArray(n)){e=!1,R(n!=null&&n.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const a=n[0].shape[0];for(let s=1;s<n.length;++s)R(n[s].shape[0]===a,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${n[s].shape[0]} vs. ${a})`)}else e=!0,n=os(n,n.shape[0],0).map(a=>tt(a,[0]));R(n.length<=n[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${n.length}) exceeds number of dimensions (${n[0].shape[0]}).`);const t=[],r=n;for(let a=0;a<n.length;++a)t.push(V.tidy(()=>{let s=r[a];if(a>0)for(let o=0;o<a;++o){const i=me(Ve(me(t[o],s)),t[o]);s=Ce(s,i)}return De(s,No(s,"euclidean"))}));return e?Mn(t,0):t}const cw=P({gramSchmidt_:lw});/** 3960 * @license 3961 * Copyright 2020 Google LLC. All Rights Reserved. 3962 * Licensed under the Apache License, Version 2.0 (the "License"); 3963 * you may not use this file except in compliance with the License. 3964 * You may obtain a copy of the License at 3965 * 3966 * http://www.apache.org/licenses/LICENSE-2.0 3967 * 3968 * Unless required by applicable law or agreed to in writing, software 3969 * distributed under the License is distributed on an "AS IS" BASIS, 3970 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3971 * See the License for the specific language governing permissions and 3972 * limitations under the License. 3973 * ============================================================================= 3974 */function pw(n,e=!1){if(R(n.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${n.rank}`),n.rank===2)return Wl(n,e);{const t=n.shape.slice(0,n.shape.length-2).reduce((u,l)=>u*l),r=Br(Z(n,[t,n.shape[n.shape.length-2],n.shape[n.shape.length-1]]),0),a=[],s=[];r.forEach(u=>{const[l,c]=Wl(u,e);a.push(l),s.push(c)});const o=Z(Mn(a,0),n.shape),i=Z(Mn(s,0),n.shape);return[o,i]}}function Wl(n,e=!1){return V.tidy(()=>{R(n.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${n.shape.length}D Tensor.`);const t=n.shape[0],r=n.shape[1];let a=Pf(t),s=Jn(n);const o=Qn([[1]],[1,1]);let i=Jn(o);const u=t>=r?r:t;for(let l=0;l<u;++l){const c=s,p=i,h=a;[i,s,a]=V.tidy(()=>{const d=we(s,[l,l],[t-l,1]),m=No(d),y=we(s,[l,l],[1,1]),b=ha($o(y,0),Qn([[-1]]),Qn([[1]])),x=Ce(y,me(b,m)),T=De(d,x);T.shape[0]===1?i=Jn(o):i=it([o,we(T,[1,0],[T.shape[0]-1,T.shape[1]])],0);const $=An(De(Oe(b,x),m)),F=we(s,[l,0],[t-l,r]),M=me($,i),U=Hi(i);if(l===0)s=Ce(F,Oe(M,Oe(U,F)));else{const L=Ce(F,Oe(M,Oe(U,F)));s=it([we(s,[0,0],[l,r]),L],0)}const X=Hi(M),z=we(a,[0,l],[t,a.shape[1]-l]);if(l===0)a=Ce(z,Oe(Oe(z,i),X));else{const L=Ce(z,Oe(Oe(z,i),X));a=it([we(a,[0,0],[t,l]),L],1)}return[i,s,a]}),bn([c,p,h])}return!e&&t>r&&(a=we(a,[0,0],[t,r]),s=we(s,[0,0],[r,r])),[a,s]})}const hw=P({qr_:pw});/** 3975 * @license 3976 * Copyright 2020 Google LLC. All Rights Reserved. 3977 * Licensed under the Apache License, Version 2.0 (the "License"); 3978 * you may not use this file except in compliance with the License. 3979 * You may obtain a copy of the License at 3980 * 3981 * http://www.apache.org/licenses/LICENSE-2.0 3982 * 3983 * Unless required by applicable law or agreed to in writing, software 3984 * distributed under the License is distributed on an "AS IS" BASIS, 3985 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3986 * See the License for the specific language governing permissions and 3987 * limitations under the License. 3988 * ============================================================================= 3989 */var St;(function(n){n[n.NONE=0]="NONE",n[n.MEAN=1]="MEAN",n[n.SUM=2]="SUM",n[n.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"})(St||(St={}));function dw(n,e,t=St.SUM_BY_NONZERO_WEIGHTS){const r=N(n,"losses","computeWeightedLoss");let a=null;e!=null&&(a=N(e,"weights","computeWeightedLoss"));const s=a==null?r:me(r,a);if(t===St.NONE)return s;if(t===St.SUM)return Ve(s);if(t===St.MEAN){if(a==null)return io(s);{const o=r.size/a.size,i=De(Ve(s),Ve(a));return o>1?De(i,Ae(o)):i}}if(t===St.SUM_BY_NONZERO_WEIGHTS){if(a==null)return De(Ve(s),Ae(r.size));{const o=me(a,Cr(r.shape)),i=je(Ve(Yf(o,Ae(0))),"float32");return De(Ve(s),i)}}throw Error(`Unknown reduction: ${t}`)}const Bn=P({computeWeightedLoss_:dw});/** 3990 * @license 3991 * Copyright 2020 Google LLC. All Rights Reserved. 3992 * Licensed under the Apache License, Version 2.0 (the "License");
3993 * you may not use this file except in compliance with the License. 3994 * You may obtain a copy of the License at 3995 * 3996 * http://www.apache.org/licenses/LICENSE-2.0 3997 * 3998 * Unless required by applicable law or agreed to in writing, software 3999 * distributed under the License is distributed on an "AS IS" BASIS, 4000 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4001 * See the License for the specific language governing permissions and 4002 * limitations under the License. 4003 * ============================================================================= 4004 */function fw(n,e,t,r=St.SUM_BY_NONZERO_WEIGHTS){const a=N(n,"labels","absoluteDifference"),s=N(e,"predictions","absoluteDifference");let o=null;t!=null&&(o=N(t,"weights","absoluteDifference")),Lt(a.shape,s.shape,"Error in absoluteDifference: ");const i=Kt(Ce(a,s));return Bn(i,o,r)}const mw=P({absoluteDifference_:fw});function gw(n,e,t,r,a=St.SUM_BY_NONZERO_WEIGHTS){const s=N(n,"labels","cosineDistance"),o=N(e,"predictions","cosineDistance");let i=null;r!=null&&(i=N(r,"weights","cosineDistance")),Lt(s.shape,o.shape,"Error in cosineDistance: ");const u=Ae(1),l=Ce(u,Ve(me(s,o),t,!0));return Bn(l,i,a)}const yw=P({cosineDistance_:gw});function xw(n,e,t,r=St.SUM_BY_NONZERO_WEIGHTS){let a=N(n,"labels","hingeLoss");const s=N(e,"predictions","hingeLoss");let o=null;t!=null&&(o=N(t,"weights","hingeLoss")),Lt(a.shape,s.shape,"Error in hingeLoss: ");const i=Ae(1);a=Ce(me(Ae(2),a),i);const u=Ro(Ce(i,me(a,s)));return Bn(u,o,r)}const bw=P({hingeLoss_:xw});/** 4005 * @license 4006 * Copyright 2020 Google LLC. All Rights Reserved. 4007 * Licensed under the Apache License, Version 2.0 (the "License"); 4008 * you may not use this file except in compliance with the License. 4009 * You may obtain a copy of the License at 4010 * 4011 * http://www.apache.org/licenses/LICENSE-2.0 4012 * 4013 * Unless required by applicable law or agreed to in writing, software 4014 * distributed under the License is distributed on an "AS IS" BASIS, 4015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4016 * See the License for the specific language governing permissions and 4017 * limitations under the License. 4018 * ============================================================================= 4019 */function vw(n,e,t,r=1,a=St.SUM_BY_NONZERO_WEIGHTS){const s=N(n,"labels","huberLoss"),o=N(e,"predictions","huberLoss");let i=null;t!=null&&(i=N(t,"weights","huberLoss")),Lt(s.shape,o.shape,"Error in huberLoss: ");const u=Ae(r),l=Kt(Ce(o,s)),c=Kf(l,u),p=Ce(l,c),h=Pe(me(Ae(.5),Io(c)),me(u,p));return Bn(h,i,a)}const ww=P({huberLoss_:vw});/** 4020 * @license 4021 * Copyright 2020 Google LLC. All Rights Reserved. 4022 * Licensed under the Apache License, Version 2.0 (the "License"); 4023 * you may not use this file except in compliance with the License. 4024 * You may obtain a copy of the License at 4025 * 4026 * http://www.apache.org/licenses/LICENSE-2.0 4027 * 4028 * Unless required by applicable law or agreed to in writing, software 4029 * distributed under the License is distributed on an "AS IS" BASIS, 4030 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4031 * See the License for the specific language governing permissions and 4032 * limitations under the License. 4033 * ============================================================================= 4034 */function Sw(n,e,t,r=1e-7,a=St.SUM_BY_NONZERO_WEIGHTS){const s=N(n,"labels","logLoss"),o=N(e,"predictions","logLoss");let i=null;t!=null&&(i=N(t,"weights","logLoss")),Lt(s.shape,o.shape,"Error in logLoss: ");const u=Ae(1),l=Ae(r),c=An(me(s,as(Pe(o,l)))),p=me(Ce(u,s),as(Pe(Ce(u,o),l))),h=Ce(c,p);return Bn(h,i,a)}const kw=P({logLoss_:Sw});/** 4035 * @license 4036 * Copyright 2020 Google LLC. All Rights Reserved. 4037 * Licensed under the Apache License, Version 2.0 (the "License"); 4038 * you may not use this file except in compliance with the License. 4039 * You may obtain a copy of the License at 4040 * 4041 * http://www.apache.org/licenses/LICENSE-2.0 4042 * 4043 * Unless required by applicable law or agreed to in writing, software 4044 * distributed under the License is distributed on an "AS IS" BASIS, 4045 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4046 * See the License for the specific language governing permissions and 4047 * limitations under the License. 4048 * ============================================================================= 4049 */function Tw(n,e,t,r=St.SUM_BY_NONZERO_WEIGHTS){const a=N(n,"labels","meanSquaredError"),s=N(e,"predictions","meanSquaredError");let o=null;t!=null&&(o=N(t,"weights","meanSquaredError")),Lt(a.shape,s.shape,"Error in meanSquaredError: ");const i=a1(a,s);return Bn(i,o,r)}const Ew=P({meanSquaredError_:Tw});/** 4050 * @license 4051 * Copyright 2020 Google LLC. All Rights Reserved. 4052 * Licensed under the Apache License, Version 2.0 (the "License");
4053 * you may not use this file except in compliance with the License. 4054 * You may obtain a copy of the License at 4055 * 4056 * http://www.apache.org/licenses/LICENSE-2.0 4057 * 4058 * Unless required by applicable law or agreed to in writing, software 4059 * distributed under the License is distributed on an "AS IS" BASIS, 4060 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4061 * See the License for the specific language governing permissions and 4062 * limitations under the License. 4063 * ============================================================================= 4064 */function Cw(n,e){const t=N(n,"labels","sigmoidCrossEntropyWithLogits"),r=N(e,"logits","sigmoidCrossEntropyWithLogits");Lt(t.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const a=Ro(r),s=me(r,t),o=zf(Fn(An(Kt(r))));return Pe(Ce(a,s),o)}function Iw(n,e,t,r=0,a=St.SUM_BY_NONZERO_WEIGHTS){let s=N(n,"multiClassLabels","sigmoidCrossEntropy");const o=N(e,"logits","sigmoidCrossEntropy");let i=null;if(t!=null&&(i=N(t,"weights","sigmoidCrossEntropy")),Lt(s.shape,o.shape,"Error in sigmoidCrossEntropy: "),r>0){const l=Ae(r),c=Ae(1),p=Ae(.5);s=Pe(me(s,Ce(c,l)),me(p,l))}const u=Cw(s,o);return Bn(u,i,a)}const Nw=P({sigmoidCrossEntropy_:Iw});/** 4065 * @license 4066 * Copyright 2020 Google LLC. All Rights Reserved. 4067 * Licensed under the Apache License, Version 2.0 (the "License"); 4068 * you may not use this file except in compliance with the License. 4069 * You may obtain a copy of the License at 4070 * 4071 * http://www.apache.org/licenses/LICENSE-2.0 4072 * 4073 * Unless required by applicable law or agreed to in writing, software 4074 * distributed under the License is distributed on an "AS IS" BASIS, 4075 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4076 * See the License for the specific language governing permissions and 4077 * limitations under the License. 4078 * ============================================================================= 4079 */function $w(n,e,t=-1){if(t===-1&&(t=e.rank-1),t!==e.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${e.rank} and dim was ${t}`);return Dn((r,a,s)=>{const o=jf(a,[t],!0),i=Ce(je(a,"float32"),o);s([r,i]);const u=An(me(i,r));return{value:Ve(u,[t]),gradFunc:(l,c)=>{const[p,h]=c,d=Bt(l.shape,[t]);return[me(Z(l,d),Ce(je(p,"float32"),Fn(h))),me(Z(l,d),Ce(Fn(h),je(p,"float32")))]}}})(n,e)}function Rw(n,e,t,r=0,a=St.SUM_BY_NONZERO_WEIGHTS){let s=N(n,"onehotLabels","softmaxCrossEntropy");const o=N(e,"logits","softmaxCrossEntropy");let i=null;if(t!=null&&(i=N(t,"weights","softmaxCrossEntropy")),Lt(s.shape,o.shape,"Error in softmaxCrossEntropy: "),r>0){const l=Ae(r),c=Ae(1),p=Ae(s.shape[1]);s=Pe(me(s,Ce(c,l)),De(l,p))}const u=$w(s,o);return Bn(u,i,a)}const _w=P({softmaxCrossEntropy_:Rw});/** 4080 * @license 4081 * Copyright 2021 Google LLC. All Rights Reserved. 4082 * Licensed under the Apache License, Version 2.0 (the "License"); 4083 * you may not use this file except in compliance with the License. 4084 * You may obtain a copy of the License at 4085 * 4086 * http://www.apache.org/licenses/LICENSE-2.0 4087 * 4088 * Unless required by applicable law or agreed to in writing, software 4089 * distributed under the License is distributed on an "AS IS" BASIS, 4090 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4091 * See the License for the specific language governing permissions and 4092 * limitations under the License. 4093 * ============================================================================= 4094 */function Aw(n,e,t,r){const a=N(n,"indices","sparseFillEmptyRows","int32"),s=N(e,"values","sparseFillEmptyRows"),o=N(t,"denseShape","sparseFillEmptyRows","int32"),i=N(r,"defaultValue","sparseFillEmptyRows",s.dtype);if(a.rank!==2)throw new Error(`Indices should be Tensor2D but received shape 4095 ${a.shape}`);if(s.rank!==1)throw new Error(`Values should be Tensor1D but received shape ${s.shape}`);if(o.rank!==1)throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`);if(i.rank!==0)throw new Error(`Default value should be a scalar but received shape ${i.shape}`);const u={indices:a,values:s,denseShape:o,defaultValue:i},l=V.runKernel(ld,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}const Ow=P({sparseFillEmptyRows_:Aw});/** 4096 * @license 4097 * Copyright 2021 Google LLC. All Rights Reserved. 4098 * Licensed under the Apache License, Version 2.0 (the "License");
4099 * you may not use this file except in compliance with the License. 4100 * You may obtain a copy of the License at 4101 * 4102 * http://www.apache.org/licenses/LICENSE-2.0 4103 * 4104 * Unless required by applicable law or agreed to in writing, software 4105 * distributed under the License is distributed on an "AS IS" BASIS, 4106 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4107 * See the License for the specific language governing permissions and 4108 * limitations under the License. 4109 * ============================================================================= 4110 */function Fw(n,e,t){const r=N(n,"inputIndices","sparseReshape","int32"),a=N(e,"inputShape","sparseReshape","int32"),s=N(t,"newShape","sparseReshape","int32");if(r.rank!==2)throw new Error(`Input indices should be Tensor2D but received shape 4111 ${r.shape}`);if(a.rank!==1)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(s.rank!==1)throw new Error(`New shape should be Tensor1D but received shape ${s.shape}`);const o={inputIndices:r,inputShape:a,newShape:s},i=V.runKernel(cd,o);return{outputIndices:i[0],outputShape:i[1]}}const Dw=P({sparseReshape_:Fw});/** 4112 * @license 4113 * Copyright 2021 Google LLC. All Rights Reserved. 4114 * Licensed under the Apache License, Version 2.0 (the "License"); 4115 * you may not use this file except in compliance with the License. 4116 * You may obtain a copy of the License at 4117 * 4118 * http://www.apache.org/licenses/LICENSE-2.0 4119 * 4120 * Unless required by applicable law or agreed to in writing, software 4121 * distributed under the License is distributed on an "AS IS" BASIS, 4122 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4123 * See the License for the specific language governing permissions and 4124 * limitations under the License. 4125 * ============================================================================= 4126 */function Mw(n,e,t){const r=N(n,"data","sparseSegmentMean"),a=N(e,"indices","sparseSegmentMean","int32"),s=N(t,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(a.rank!==1)throw new Error(`Indices should be Tensor1D but received shape 4127 ${a.shape}`);if(s.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape 4128 ${s.shape}`);const o={data:r,indices:a,segmentIds:s};return V.runKernel(pd,o)}const Lw=P({sparseSegmentMean_:Mw});/** 4129 * @license 4130 * Copyright 2021 Google LLC. All Rights Reserved. 4131 * Licensed under the Apache License, Version 2.0 (the "License"); 4132 * you may not use this file except in compliance with the License. 4133 * You may obtain a copy of the License at 4134 * 4135 * http://www.apache.org/licenses/LICENSE-2.0 4136 * 4137 * Unless required by applicable law or agreed to in writing, software 4138 * distributed under the License is distributed on an "AS IS" BASIS, 4139 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4140 * See the License for the specific language governing permissions and 4141 * limitations under the License. 4142 * ============================================================================= 4143 */function Pw(n,e,t){const r=N(n,"data","sparseSegmentSum"),a=N(e,"indices","sparseSegmentSum","int32"),s=N(t,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(a.rank!==1)throw new Error(`Indices should be Tensor1D but received shape 4144 ${a.shape}`);if(s.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape 4145 ${s.shape}`);const o={data:r,indices:a,segmentIds:s};return V.runKernel(hd,o)}const Bw=P({sparseSegmentSum_:Pw});/** 4146 * @license 4147 * Copyright 2021 Google LLC. All Rights Reserved. 4148 * Licensed under the Apache License, Version 2.0 (the "License"); 4149 * you may not use this file except in compliance with the License. 4150 * You may obtain a copy of the License at 4151 * 4152 * http://www.apache.org/licenses/LICENSE-2.0 4153 * 4154 * Unless required by applicable law or agreed to in writing, software 4155 * distributed under the License is distributed on an "AS IS" BASIS, 4156 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4157 * See the License for the specific language governing permissions and 4158 * limitations under the License. 4159 * ============================================================================= 4160 */function Uw(n,e,t,r,a,s,o,i){const u=N(n,"data","stringNGrams","string");if(u.dtype!=="string")throw new Error("Data must be of datatype string");if(u.shape.length!==1)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=N(e,"dataSplits","stringNGrams");if(l.dtype!=="int32")throw new Error("Data splits must be of datatype int32");const c={separator:t,nGramWidths:r,leftPad:a,rightPad:s,padWidth:o,preserveShortSequences:i},p={data:u,dataSplits:l},h=V.runKernel(gd,p,c);return{nGrams:h[0],nGramsSplits:h[1]}}const Vw=P({stringNGrams_:Uw});/** 4161 * @license 4162 * Copyright 2021 Google LLC. All Rights Reserved. 4163 * Licensed under the Apache License, Version 2.0 (the "License");
4164 * you may not use this file except in compliance with the License. 4165 * You may obtain a copy of the License at 4166 * 4167 * http://www.apache.org/licenses/LICENSE-2.0 4168 * 4169 * Unless required by applicable law or agreed to in writing, software 4170 * distributed under the License is distributed on an "AS IS" BASIS, 4171 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4172 * See the License for the specific language governing permissions and 4173 * limitations under the License. 4174 * ============================================================================= 4175 */function Ww(n,e,t=!0){const r=N(n,"input","stringSplit","string"),a=N(e,"delimiter","stringSplit","string");if(r.rank!==1)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(a.rank!==0)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const s={skipEmpty:t},o={input:r,delimiter:a},i=V.runKernel(yd,o,s);return{indices:i[0],values:i[1],shape:i[2]}}const zw=P({stringSplit_:Ww});/** 4176 * @license 4177 * Copyright 2021 Google LLC. All Rights Reserved. 4178 * Licensed under the Apache License, Version 2.0 (the "License"); 4179 * you may not use this file except in compliance with the License. 4180 * You may obtain a copy of the License at 4181 * 4182 * http://www.apache.org/licenses/LICENSE-2.0 4183 * 4184 * Unless required by applicable law or agreed to in writing, software 4185 * distributed under the License is distributed on an "AS IS" BASIS, 4186 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4187 * See the License for the specific language governing permissions and 4188 * limitations under the License. 4189 * ============================================================================= 4190 */function Gw(n,e){const t=N(n,"input","stringToHashBucketFast","string"),r={numBuckets:e};if(e<=0)throw new Error("Number of buckets must be at least 1");const a={input:t};return V.runKernel(xd,a,r)}const jw=P({stringToHashBucketFast_:Gw});/** 4191 * @license 4192 * Copyright 2020 Google LLC. All Rights Reserved. 4193 * Licensed under the Apache License, Version 2.0 (the "License"); 4194 * you may not use this file except in compliance with the License. 4195 * You may obtain a copy of the License at 4196 * 4197 * http://www.apache.org/licenses/LICENSE-2.0 4198 * 4199 * Unless required by applicable law or agreed to in writing, software 4200 * distributed under the License is distributed on an "AS IS" BASIS, 4201 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4202 * See the License for the specific language governing permissions and 4203 * limitations under the License. 4204 * ============================================================================= 4205 */const Hw={fft:Ku,ifft:uo,rfft:Yu,irfft:r1},Xw={hammingWindow:wv,hannWindow:l1,frame:c1,stft:Ev},va={flipLeftRight:$v,grayscaleToRGB:_v,resizeNearestNeighbor:tw,resizeBilinear:Qv,rotateWithOffset:Ov,cropAndResize:Iv,nonMaxSuppression:Dv,nonMaxSuppressionAsync:zv,nonMaxSuppressionWithScore:jv,nonMaxSuppressionWithScoreAsync:Xv,nonMaxSuppressionPadded:Kv,nonMaxSuppressionPaddedAsync:Zv,threshold:aw,transform:ow},qw={bandPart:uw,gramSchmidt:cw,qr:hw},Kw={absoluteDifference:mw,computeWeightedLoss:Bn,cosineDistance:yw,hingeLoss:bw,huberLoss:ww,logLoss:kw,meanSquaredError:Ew,sigmoidCrossEntropy:Nw,softmaxCrossEntropy:_w},Yw={sparseFillEmptyRows:Ow,sparseReshape:Dw,sparseSegmentMean:Lw,sparseSegmentSum:Bw},Zw={stringNGrams:Vw,stringSplit:zw,stringToHashBucketFast:jw};/** 4206 * @license 4207 * Copyright 2017 Google LLC. All Rights Reserved. 4208 * Licensed under the Apache License, Version 2.0 (the "License"); 4209 * you may not use this file except in compliance with the License. 4210 * You may obtain a copy of the License at 4211 * 4212 * http://www.apache.org/licenses/LICENSE-2.0 4213 * 4214 * Unless required by applicable law or agreed to in writing, software 4215 * distributed under the License is distributed on an "AS IS" BASIS, 4216 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4217 * See the License for the specific language governing permissions and 4218 * limitations under the License. 4219 * ============================================================================= 4220 */const Jw=typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:n=>n();function Qw(){return new Promise(n=>Jw(()=>n()))}/** 4221 * @license 4222 * Copyright 2017 Google LLC. All Rights Reserved. 4223 * Licensed under the Apache License, Version 2.0 (the "License");
4224 * you may not use this file except in compliance with the License. 4225 * You may obtain a copy of the License at 4226 * 4227 * http://www.apache.org/licenses/LICENSE-2.0 4228 * 4229 * Unless required by applicable law or agreed to in writing, software 4230 * distributed under the License is distributed on an "AS IS" BASIS, 4231 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4232 * See the License for the specific language governing permissions and 4233 * limitations under the License. 4234 * ============================================================================= 4235 */function f1(n,e){const t=n[0].length;n.forEach((a,s)=>{R(a.length===t,()=>`Error in concat${t}D: rank of tensors[${s}] must be the same as the rank of the rest (${t})`)}),R(e>=0&&e<t,()=>`Error in concat${t}D: axis must be between 0 and ${t-1}.`);const r=n[0];n.forEach((a,s)=>{for(let o=0;o<t;o++)R(o===e||a[o]===r[o],()=>`Error in concat${t}D: Shape of tensors[${s}] (${a}) does not match the shape of the rest (${r}) along the non-concatenated axis ${s}.`)})}function Mr(n,e){const t=n[0].slice();for(let r=1;r<n.length;r++)t[e]+=n[r][e];return t}/** 4236 * @license 4237 * Copyright 2022 Google LLC. All Rights Reserved. 4238 * Licensed under the Apache License, Version 2.0 (the "License"); 4239 * you may not use this file except in compliance with the License. 4240 * You may obtain a copy of the License at 4241 * 4242 * http://www.apache.org/licenses/LICENSE-2.0 4243 * 4244 * Unless required by applicable law or agreed to in writing, software 4245 * distributed under the License is distributed on an "AS IS" BASIS, 4246 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4247 * See the License for the specific language governing permissions and 4248 * limitations under the License. 4249 * ============================================================================= 4250 */var un;(function(n){n[n.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",n[n.VALUE_ROWIDS=1]="VALUE_ROWIDS",n[n.ROW_LENGTHS=2]="ROW_LENGTHS",n[n.ROW_SPLITS=3]="ROW_SPLITS",n[n.ROW_LIMITS=4]="ROW_LIMITS",n[n.ROW_STARTS=5]="ROW_STARTS"})(un||(un={}));function m1(n,e,t){let r=new Array;if(t==null&&e==null)return r;if(e==null)for(;r.length<n+t.length;)r.push(-1);else r=e.slice();if(t==null)return r;if(n+t.length!==r.length)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.rank = ${n+t.length}, but shape.rank = ${r.length}`);for(let a=1;a<t.length;++a){const s=t[a],o=r[r.length-t.length+a],i=r[o];if(s>=0)if(i>=0){if(i!==s)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${a+n}] = ${s} but shape[${a+n}] = ${i}`)}else r[o]=s}return r}function g1(n){const e={FIRST_DIM_SIZE:un.FIRST_DIM_SIZE,VALUE_ROWIDS:un.VALUE_ROWIDS,ROW_LENGTHS:un.ROW_LENGTHS,ROW_SPLITS:un.ROW_SPLITS,ROW_LIMITS:un.ROW_LIMITS,ROW_STARTS:un.ROW_STARTS},t=[];for(const r of n)if(r in e)t.push(e[r]);else break;return t}function y1(n){return n.length===0?0:n[0]===un.FIRST_DIM_SIZE?n.length-1:n.length}function x1(n,e){if(n==null||e==null)return;const t=n.length,r=e.length;if(t>=r)throw new Error(`defaultValue.shape=${n} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${t} must be less than ragged tensor input flatValues.rank = ${r})`);for(let a=0;a<Math.min(t,r-1);++a){const s=n[a],o=e[a+1];if(s>=0&&o>=0&&s!==1&&s!==o)throw new Error(`defaultValue.shape=${n}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${a-n.length}] = ${s} but ragged tensor input.flatValues.shape[${a-n.length}] = ${o}`)}}/** 4251 * @license 4252 * Copyright 2017 Google LLC. All Rights Reserved. 4253 * Licensed under the Apache License, Version 2.0 (the "License"); 4254 * you may not use this file except in compliance with the License. 4255 * You may obtain a copy of the License at 4256 * 4257 * http://www.apache.org/licenses/LICENSE-2.0 4258 * 4259 * Unless required by applicable law or agreed to in writing, software 4260 * distributed under the License is distributed on an "AS IS" BASIS, 4261 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4262 * See the License for the specific language governing permissions and 4263 * limitations under the License. 4264 * ============================================================================= 4265 */const Qu=30;function Do(n){return n<=Qu?n:Ii(n,Math.floor(Math.sqrt(n)))}/** 4266 * @license 4267 * Copyright 2020 Google LLC. All Rights Reserved. 4268 * Licensed under the Apache License, Version 2.0 (the "License");
4269 * you may not use this file except in compliance with the License. 4270 * You may obtain a copy of the License at 4271 * 4272 * http://www.apache.org/licenses/LICENSE-2.0 4273 * 4274 * Unless required by applicable law or agreed to in writing, software 4275 * distributed under the License is distributed on an "AS IS" BASIS, 4276 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4277 * See the License for the specific language governing permissions and 4278 * limitations under the License. 4279 * ============================================================================= 4280 */function b1(n,e,t){const r=t*(typeof n=="number"?n:n[0]),a=e*(typeof n=="number"?n:n[1]);return[r,a]}/** 4281 * @license 4282 * Copyright 2018 Google LLC. All Rights Reserved. 4283 * Licensed under the Apache License, Version 2.0 (the "License"); 4284 * you may not use this file except in compliance with the License. 4285 * You may obtain a copy of the License at 4286 * 4287 * http://www.apache.org/licenses/LICENSE-2.0 4288 * 4289 * Unless required by applicable law or agreed to in writing, software 4290 * distributed under the License is distributed on an "AS IS" BASIS, 4291 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4292 * See the License for the specific language governing permissions and 4293 * limitations under the License. 4294 * ============================================================================= 4295 */function el(n,e,t,r=!0){let a=[];if(r)a=a.concat(e.slice(0)),a.push(n[0]/t),a=a.concat(n.slice(1));else{a=a.concat(n[0]);const s=e.length;for(let o=0;o<s;++o)a=a.concat([n[o+1]/e[o],e[o]]);a=a.concat(n.slice(s+1))}return a}function tl(n,e,t=!0){const r=[];if(t){r.push(e);for(let a=e+1;a<n;++a)a<=2*e?(r.push(a),r.push(a-(e+1))):r.push(a)}else{const a=[],s=[];for(let o=1;o<n;++o)o>=e*2+1||o%2===1?s.push(o):a.push(o);r.push(...a),r.push(0),r.push(...s)}return r}function nl(n,e,t,r=!0){const a=[];r?a.push(n[0]/t):a.push(n[0]*t);for(let s=1;s<n.length;++s)s<=e.length?r?a.push(e[s-1]*n[s]):a.push(n[s]/e[s-1]):a.push(n[s]);return a}function v1(n,e){const t=[0];for(let r=0;r<e;++r)t.push(n[r][0]);return t}function w1(n,e,t){const r=n.slice(0,1);for(let a=0;a<t;++a)r.push(n[a+1]-e[a][0]-e[a][1]);return r}/** 4296 * @license 4297 * Copyright 2018 Google LLC. All Rights Reserved. 4298 * Licensed under the Apache License, Version 2.0 (the "License"); 4299 * you may not use this file except in compliance with the License. 4300 * You may obtain a copy of the License at 4301 * 4302 * http://www.apache.org/licenses/LICENSE-2.0 4303 * 4304 * Unless required by applicable law or agreed to in writing, software 4305 * distributed under the License is distributed on an "AS IS" BASIS, 4306 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4307 * See the License for the specific language governing permissions and 4308 * limitations under the License. 4309 * ============================================================================= 4310 */const S1=1.7580993408473768,k1=1.0507009873554805;/** 4311 * @license 4312 * Copyright 2018 Google LLC. All Rights Reserved. 4313 * Licensed under the Apache License, Version 2.0 (the "License"); 4314 * you may not use this file except in compliance with the License. 4315 * You may obtain a copy of the License at 4316 * 4317 * http://www.apache.org/licenses/LICENSE-2.0 4318 * 4319 * Unless required by applicable law or agreed to in writing, software 4320 * distributed under the License is distributed on an "AS IS" BASIS, 4321 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4322 * See the License for the specific language governing permissions and 4323 * limitations under the License. 4324 * ============================================================================= 4325 */const T1=.3275911,E1=.254829592,C1=-.284496736,I1=1.421413741,N1=-1.453152027,$1=1.061405429;/** 4326 * @license 4327 * Copyright 2018 Google LLC. All Rights Reserved. 4328 * Licensed under the Apache License, Version 2.0 (the "License"); 4329 * you may not use this file except in compliance with the License. 4330 * You may obtain a copy of the License at 4331 * 4332 * http://www.apache.org/licenses/LICENSE-2.0 4333 * 4334 * Unless required by applicable law or agreed to in writing, software 4335 * distributed under the License is distributed on an "AS IS" BASIS, 4336 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4337 * See the License for the specific language governing permissions and 4338 * limitations under the License. 4339 * ============================================================================= 4340 */function su(n,e){if(n.length!==e.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${n.length}, imag: ${e.length}.`);const t=new Float32Array(n.length*2);for(let r=0;r<t.length;r+=2)t[r]=n[r/2],t[r+1]=e[r/2];return t}function e6(n){const e=new Float32Array(n.length/2),t=new Float32Array(n.length/2);for(let r=0;r<n.length;r+=2)e[r/2]=n[r],t[r/2]=n[r+1];return{real:e,imag:t}}function t6(n){const e=Math.ceil(n.length/4),t=new Float32Array(e),r=new Float32Array(e);for(let a=0;a<n.length;a+=4)t[Math.floor(a/4)]=n[a],r[Math.floor(a/4)]=n[a+1];return{real:t,imag:r}}function n6(n){const e=Math.floor(n.length/4),t=new Float32Array(e),r=new Float32Array(e);for(let a=2;a<n.length;a+=4)t[Math.floor(a/4)]=n[a],r[Math.floor(a/4)]=n[a+1];return{real:t,imag:r}}function r6(n,e){const t=n[e*2],r=n[e*2+1];return{real:t,imag:r}}function a6(n,e,t,r){n[r*2]=e,n[r*2+1]=t}function s6(n,e){const t=new Float32Array(n/2),r=new Float32Array(n/2);for(let a=0;a<Math.ceil(n/2);a++){const s=(e?2:-2)*Math.PI*(a/n);t[a]=Math.cos(s),r[a]=Math.sin(s)}return{real:t,imag:r}}function o6(n,e,t){const r=(t?2:-2)*Math.PI*(n/e),a=Math.cos(r),s=Math.sin(r);return{real:a,imag:s}}/** 4341 * @license 4342 * Copyright 2021 Google LLC. All Rights Reserved. 4343 * Licensed under the Apache License, Version 2.0 (the "License");
4344 * you may not use this file except in compliance with the License. 4345 * You may obtain a copy of the License at 4346 * 4347 * http://www.apache.org/licenses/LICENSE-2.0 4348 * 4349 * Unless required by applicable law or agreed to in writing, software 4350 * distributed under the License is distributed on an "AS IS" BASIS, 4351 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4352 * See the License for the specific language governing permissions and 4353 * limitations under the License. 4354 * ============================================================================= 4355 */const oi="->",i6=/->/g,zl=",",Gl="...";function R1(n,e){n=n.replace(/\s/g,"");const t=(n.length-n.replace(i6,"").length)/oi.length;if(t<1)throw new Error("Equations without an arrow are not supported.");if(t>1)throw new Error(`Equation must contain exactly one arrow ("${oi}").`);const[r,a]=n.split(oi);R(r.indexOf(Gl)===-1,()=>`The ellipsis notation ("${Gl}") is not supported yet.`);const s=r.split(zl),o=s.length;if(e!==o)throw new Error(`Expected ${o} input tensors, received ${e}`);if(o>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const i=[];for(let h=0;h<a.length;++h){const d=a[h];if(!s.some(m=>m.indexOf(d)!==-1))throw new Error(`Output subscripts contain the label ${d} not present in the input subscripts.`);i.indexOf(d)===-1&&i.push(d)}for(let h=0;h<r.length;++h){const d=r[h];i.indexOf(d)===-1&&d!==zl&&i.push(d)}const u=new Array(s.length);for(let h=0;h<o;++h){if(new Set(s[h].split("")).size!==s[h].length)throw new Error(`Found duplicate axes in input component ${s[h]}. Support for duplicate axes in input is not implemented yet.`);u[h]=[];for(let d=0;d<s[h].length;++d)u[h].push(i.indexOf(s[h][d]))}const l=i.length,c=a.length,p=[];for(let h=c;h<l;++h)p.push(h);return{allDims:i,summedDims:p,idDims:u}}function _1(n,e){let t=new Array(n);t.fill(-1);for(let a=0;a<e.length;++a)t[e[a]]=a;const r=[];for(let a=0;a<n;++a)t[a]===-1&&r.push(a);return t=t.filter(a=>a!==-1),{permutationIndices:t,expandDims:r}}function A1(n,e,t){const r=new Array(n);for(let a=0;a<t.length;++a){const s=t[a].shape;for(let o=0;o<e[a].length;++o)r[e[a][o]]===void 0?r[e[a][o]]=s[o]:R(r[e[a][o]]===s[o],()=>`Expected dimension ${r[e[a][o]]} at axis ${o} of input shaped ${JSON.stringify(s)}, but got dimension ${s[o]}`)}}function O1(n,e){const t=n,r=[];let a=0;n.length===0&&t.push(-1),a=n.length+1;for(let o=0;o<a;++o)r.push([]);const s=[];for(let o=0;o<t.length;++o){const i=t[o],u=u6(e,i);for(const l of u)s.indexOf(l)===-1&&(r[o].push(l),s.push(l))}return{path:t,steps:r}}function F1(n){return n.every((e,t)=>e===t)}function u6(n,e){const t=[];for(let r=0;r<n.length;++r)(n[r].length===0||n[r].indexOf(e)!==-1||e===-1)&&t.push(r);return t}function D1(n,e,t=0){let r=[];if(typeof e=="number")R(n.shape[t]%e===0,()=>"Number of splits must evenly divide the axis."),r=new Array(e).fill(n.shape[t]/e);else{const a=e.reduce((o,i)=>(i===-1&&(o+=1),o),0);R(a<=1,()=>"There should be only one negative value in split array.");const s=e.indexOf(-1);if(s!==-1){const o=e.reduce((i,u)=>u>0?i+u:i);e[s]=n.shape[t]-o}R(n.shape[t]===e.reduce((o,i)=>o+i),()=>"The sum of sizes must match the size of the axis dimension."),r=e}return r}/** 4356 * @license 4357 * Copyright 2021 Google LLC. All Rights Reserved. 4358 * Licensed under the Apache License, Version 2.0 (the "License"); 4359 * you may not use this file except in compliance with the License. 4360 * You may obtain a copy of the License at 4361 * 4362 * http://www.apache.org/licenses/LICENSE-2.0 4363 * 4364 * Unless required by applicable law or agreed to in writing, software 4365 * distributed under the License is distributed on an "AS IS" BASIS, 4366 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4367 * See the License for the specific language governing permissions and 4368 * limitations under the License. 4369 * ============================================================================= 4370 */function M1(n){return`Received SparseTensor with denseShape[0] = 0 but 4371 indices.shape[0] = ${n}`}function L1(n,e){return`indices(${n}, 0) is invalid: ${e} < 0`}function P1(n,e,t){return`indices(${n}
4371, 0) is invalid: ${e} >= ${t}`}/** 4372 * @license 4373 * Copyright 2021 Google LLC. All Rights Reserved. 4374 * Licensed under the Apache License, Version 2.0 (the "License"); 4375 * you may not use this file except in compliance with the License. 4376 * You may obtain a copy of the License at 4377 * 4378 * http://www.apache.org/licenses/LICENSE-2.0 4379 * 4380 * Unless required by applicable law or agreed to in writing, software 4381 * distributed under the License is distributed on an "AS IS" BASIS, 4382 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4383 * See the License for the specific language governing permissions and 4384 * limitations under the License. 4385 * ============================================================================= 4386 */function B1(n,e){return`only one output dimension may be -1, not both ${n} and ${e}`}function U1(n,e){return`size ${n} must be non-negative, not ${e}`}function V1(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function W1(n,e){const t=ae(n),r=ae(e);return`Input to reshape is a SparseTensor with ${t} 4387 dense values, but the requested shape requires a multiple of ${r}. inputShape=${n} outputShape= ${e}`}function z1(n,e){const t=ae(n),r=ae(e);return`Input to reshape is a tensor with ${t} dense values, but the requested shape has ${r}. inputShape=${n} outputShape=${e}`}/** 4388 * @license 4389 * Copyright 2021 Google LLC. All Rights Reserved. 4390 * Licensed under the Apache License, Version 2.0 (the "License"); 4391 * you may not use this file except in compliance with the License. 4392 * You may obtain a copy of the License at 4393 * 4394 * http://www.apache.org/licenses/LICENSE-2.0 4395 * 4396 * Unless required by applicable law or agreed to in writing, software 4397 * distributed under the License is distributed on an "AS IS" BASIS, 4398 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4399 * See the License for the specific language governing permissions and 4400 * limitations under the License. 4401 * ============================================================================= 4402 */function ou(){return"segment ids must be >= 0"}function G1(){return"segment ids are not increasing"}function j1(n,e){return`Segment id ${n} out of range [0, ${e}), possibly because segmentIds input is not sorted.`}function H1(n,e,t){return`Bad: indices[${n}] == ${e} out of range [0, ${t})`}/** 4403 * @license 4404 * Copyright 2018 Google LLC. All Rights Reserved. 4405 * Licensed under the Apache License, Version 2.0 (the "License"); 4406 * you may not use this file except in compliance with the License. 4407 * You may obtain a copy of the License at 4408 * 4409 * http://www.apache.org/licenses/LICENSE-2.0 4410 * 4411 * Unless required by applicable law or agreed to in writing, software 4412 * distributed under the License is distributed on an "AS IS" BASIS, 4413 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4414 * See the License for the specific language governing permissions and 4415 * limitations under the License. 4416 * ============================================================================= 4417 */function X1(n,e){let t=!1,r;for(n<=Qu?(r=n,t=!0):r=Ii(n,Math.floor(Math.sqrt(n)));!t;)r>e||r===n?t=!0:r=Ii(n,r+1);return r}function q1(n,e,t){const r=[],a=n.length;for(let s=0;s<a;s++)s!==e?r.push(n[s]):r.push(t);return r}function K1(n,e,t,r){const a=e.shape.length,s=n.shape.length;if(r!==0&&(r<-a||r>a))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>s)throw new Error(`batchDims (${r}) must be less than rank(x) ( 4418 ${s}).`);if(t<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${t}).`);for(let p=0;p<r;++p)if(n.shape[p]!==e.shape[p])throw new Error(`x.shape[${p}]: ${n.shape[p]} should be equal to indices.shape[${p}]: ${e.shape[p]}.`);const o=n.shape[t],i=[];let u=1,l=1,c=1;for(let p=0;p<r;++p)i.push(n.shape[p]),u*=n.shape[p];for(let p=r;p<t;p++)i.push(n.shape[p]),l*=n.shape[p];for(let p=r;p<a;p++)i.push(e.shape[p]);for(let p=t+1;p<s;p++)i.push(n.shape[p]),c*=n.shape[p];return{batchSize:u,sliceSize:c,outerSize:l,dimSize:o,outputShape:i}}const l6=Object.freeze(Object.defineProperty({__proto__:null,collectGatherOpShapeInfo:K1,computeOutShape:q1,segOpComputeOptimalWindowSize:X1},Symbol.toStringTag,{value:"Module"}));/** 4419 * @license 4420 * Copyright 2018 Google LLC. All Rights Reserved. 4421 * Licensed under the Apache License, Version 2.0 (the "License");
4422 * you may not use this file except in compliance with the License. 4423 * You may obtain a copy of the License at 4424 * 4425 * http://www.apache.org/licenses/LICENSE-2.0 4426 * 4427 * Unless required by applicable law or agreed to in writing, software 4428 * distributed under the License is distributed on an "AS IS" BASIS, 4429 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4430 * See the License for the specific language governing permissions and 4431 * limitations under the License. 4432 * ============================================================================= 4433 */function is(n){try{return n.map(e=>ca(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Y1(n){return n.map(e=>Nr(e))}const c6=Object.freeze(Object.defineProperty({__proto__:null,ERF_A1:E1,ERF_A2:C1,ERF_A3:I1,ERF_A4:N1,ERF_A5:$1,ERF_P:T1,PARALLELIZE_THRESHOLD:Qu,get RowPartitionType(){return un},SELU_SCALE:k1,SELU_SCALEALPHA:S1,applyActivation:Oo,assertAndGetBroadcastShape:$e,assertAxesAreInnerMostDims:hn,assertParamsConsistent:f1,assignToTypedArray:a6,axesAreInnerMostDims:Wu,calculateShapes:Mu,checkEinsumDimSizes:A1,checkPadOnDimRoundingMode:Jt,combineLocations:Mf,combineRaggedTensorToTensorShapes:m1,complexWithEvenIndex:t6,complexWithOddIndex:n6,computeConv2DInfo:Pt,computeConv3DInfo:fs,computeDefaultPad:Bu,computeDilation2DInfo:Nf,computeOptimalWindowSize:Do,computeOutAndReduceShapes:kn,computeOutShape:Mr,computePool2DInfo:Pr,computePool3DInfo:ds,convertConv2DDataFormat:xa,decodeEinsumEquation:R1,eitherStridesOrDilationsAreOne:_t,expandShapeToKeepDim:Bt,exponent:o6,exponents:s6,fromStringArrayToUint8:Y1,fromUint8ToStringArray:is,getAxesPermutation:Qt,getBroadcastDims:ao,getComplexWithIndex:r6,getEinsumComputePath:O1,getEinsumPermutation:_1,getFusedBiasGradient:Ao,getFusedDyActivation:_o,getImageCenter:b1,getInnerMostAxes:en,getPermuted:tl,getRaggedRank:y1,getReductionAxes:uf,getReshaped:el,getReshapedPermuted:nl,getRowPartitionTypesHelper:g1,getSliceBeginCoords:v1,getSliceSize:w1,getSparseFillEmptyRowsIndicesDenseShapeMismatch:M1,getSparseFillEmptyRowsNegativeIndexErrorMessage:L1,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:P1,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:V1,getSparseReshapeInputOutputMismatchErrorMessage:z1,getSparseReshapeInputOutputMultipleErrorMessage:W1,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:B1,getSparseReshapeNegativeOutputDimErrorMessage:U1,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:H1,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:ou,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:G1,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:j1,getUndoAxesPermutation:zu,isIdentityPermutation:F1,log:B2,mergeRealAndImagArrays:su,prepareAndValidate:hf,prepareSplitSize:D1,segment_util:l6,shouldFuse:Fo,slice_util:w0,splitRealAndImagArrays:e6,tupleValuesAreOne:rs,upcastType:Sn,validateDefaultValueShape:x1,validateInput:ff,validateUpdateShape:df,warn:ln},Symbol.toStringTag,{value:"Module"}));/** 4434 * @license 4435 * Copyright 2018 Google LLC. All Rights Reserved. 4436 * Licensed under the Apache License, Version 2.0 (the "License"); 4437 * you may not use this file except in compliance with the License. 4438 * You may obtain a copy of the License at 4439 * 4440 * http://www.apache.org/licenses/LICENSE-2.0 4441 * 4442 * Unless required by applicable law or agreed to in writing, software 4443 * distributed under the License is distributed on an "AS IS" BASIS, 4444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4445 * See the License for the specific language governing permissions and 4446 * limitations under the License. 4447 * ============================================================================= 4448 */const Tr={},zs={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function p6(n,e){Tr[n]=e}function pn(n,e){if(!(n in Tr)||e!=null){const r=d6(n,e);if(r!==null)Tr[n]=r;else return console.log("Could not get context for WebGL version",n),null}const t=Tr[n];return t==null||t.isContextLost()?(delete Tr[n],pn(n)):(t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),Tr[n])}function h6(n){if(typeof OffscreenCanvas<"u"&&n===2)return new OffscreenCanvas(300,150);if(typeof document<"u")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function d6(n,e){if(n!==1&&n!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=e??h6(n);return t.addEventListener("webglcontextlost",r=>{r.preventDefault(),delete Tr[n]},!1),H().getBool("SOFTWARE_WEBGL_ENABLED")&&(zs.failIfMajorPerformanceCaveat=!1),n===1?t.getContext("webgl",zs)||t.getContext("experimental-webgl",zs):t.getContext("webgl2",zs)}/** 4449 * @license 4450 * Copyright 2017 Google LLC. All Rights Reserved. 4451 * Licensed under the Apache License, Version 2.0 (the "License");
4452 * you may not use this file except in compliance with the License. 4453 * You may obtain a copy of the License at 4454 * 4455 * http://www.apache.org/licenses/LICENSE-2.0 4456 * 4457 * Unless required by applicable law or agreed to in writing, software 4458 * distributed under the License is distributed on an "AS IS" BASIS, 4459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4460 * See the License for the specific language governing permissions and 4461 * limitations under the License. 4462 * ============================================================================= 4463 */var us;(function(n){n[n.DENSE=0]="DENSE",n[n.SHARED_BATCH=1]="SHARED_BATCH"})(us||(us={}));var Mt;(function(n){n[n.RENDER=0]="RENDER",n[n.UPLOAD=1]="UPLOAD",n[n.PIXELS=2]="PIXELS",n[n.DOWNLOAD=3]="DOWNLOAD"})(Mt||(Mt={}));var st;(function(n){n[n.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",n[n.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",n[n.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",n[n.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",n[n.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})(st||(st={}));function gs(n,e){return[e,n]}function f6(n,e){return n*e}function Gs(n){const e=ae(n),t=Math.ceil(e/4);return Ei(t)}function wa(n,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(n/2))]}function m6(n,e){const[t,r]=wa(n,e);return t*r*4}function rl(n,e){const t=n;let r,a,s,o,i,u,l,c,p,h;return H().getNumber("WEBGL_VERSION")===2?(r=t.R32F,a=t.R16F,s=t.RGBA16F,o=t.RGBA32F,i=t.RED,l=4,c=1,p=t.HALF_FLOAT,h=t.FLOAT,u=t.RGBA8):(r=n.RGBA,a=n.RGBA,s=n.RGBA,o=t.RGBA,i=n.RGBA,l=4,c=4,p=e!=null?e.HALF_FLOAT_OES:null,h=n.FLOAT,u=n.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:a,internalFormatPackedHalfFloat:s,internalFormatPackedFloat:o,textureFormatFloat:i,downloadTextureFormat:u,downloadUnpackNumChannels:l,defaultNumChannels:c,textureTypeHalfFloat:p,textureTypeFloat:h}}/** 4464 * @license 4465 * Copyright 2017 Google LLC. All Rights Reserved. 4466 * Licensed under the Apache License, Version 2.0 (the "License"); 4467 * you may not use this file except in compliance with the License. 4468 * You may obtain a copy of the License at 4469 * 4470 * http://www.apache.org/licenses/LICENSE-2.0 4471 * 4472 * Unless required by applicable law or agreed to in writing, software 4473 * distributed under the License is distributed on an "AS IS" BASIS, 4474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4475 * See the License for the specific language governing permissions and 4476 * limitations under the License. 4477 * ============================================================================= 4478 */function ce(n,e){const t=e();return H().getBool("DEBUG")&&g6(n),t}function g6(n){const e=n.getError();if(e!==n.NO_ERROR)throw new Error("WebGL Error: "+v6(n,e))}const y6=596e-10,x6=65504;function b6(n){return!!(H().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||n===0||y6<Math.abs(n)&&Math.abs(n)<x6)}function v6(n,e){switch(e){case n.NO_ERROR:return"NO_ERROR";case n.INVALID_ENUM:return"INVALID_ENUM";case n.INVALID_VALUE:return"INVALID_VALUE";case n.INVALID_OPERATION:return"INVALID_OPERATION";case n.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case n.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case n.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${e}`}}function js(n,e){return Un(n,()=>n.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function w6(n,e){const t=Un(n,()=>n.createShader(n.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(ce(n,()=>n.shaderSource(t,e)),ce(n,()=>n.compileShader(t)),n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw console.log(n.getShaderInfoLog(t)),new Error("Failed to compile vertex shader.");return t}function S6(n,e){const t=Un(n,()=>n.createShader(n.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(ce(n,()=>n.shaderSource(t,e)),ce(n,()=>n.compileShader(t)),H().get("ENGINE_COMPILE_ONLY"))return t;if(n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw Z1(e,n.getShaderInfoLog(t)),new Error("Failed to compile fragment shader.");return t}const k6=/ERROR: [0-9]+:([0-9]+):/g;function Z1(n,e){const t=k6.exec(e);if(t==null){console.log(`Couldn't parse line number in error: ${e}`),console.log(n);return}const r=+t[1],a=n.split(` 4479`),s=a.length.toString().length+2,o=a.map((p,h)=>ra((h+1).toString(),s)+p);let i=0;for(let p=0;p<o.length;p++)i=Math.max(o[p].length,i);const u=o.slice(0,r-1),l=o.slice(r-1,r),c=o.slice(r);console.log(u.join(` 4480`)),console.log(e.split(` 4481`)[0]),console.log(`%c ${ra(l[0],i)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(c.join(` 4482`))}function T6(n){return Un(n,()=>n.createProgram(),"Unable to create WebGLProgram.")}function E6(n,e){if(ce(n,()=>n.linkProgram(e)),!H().get("ENGINE_COMPILE_ONLY")&&n.getProgramParameter(e,n.LINK_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function ii(n,e){if(ce(n,()=>n.validateProgram(e)),n.getProgramParameter(e,n.VALIDATE_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function C6(n,e){const t=Un(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return ce(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),ce(n,()=>n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function I6(n,e){const t=Un(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return ce(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t)),ce(n,()=>n.bufferData(n.ELEMENT_ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function N6(n){return Un(n,()=>n.createTexture(),"Unable to create WebGLTexture.")}function $6(n,e){const t=H().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(n<=0||e<=0){const r=`[${n}x${e}]`;
vendor: 5,497 bytes, line 4482
4482throw new Error("Requested texture size "+r+" is invalid.")}if(n>t||e>t){const r=`[${n}x${e}]`,a=`[${t}x${t}]`;throw new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU "+a+".")}}function R6(n){return Un(n,()=>n.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function jl(n,e,t,r,a,s,o){const i=n.getAttribLocation(e,t);return i===-1?!1:(ce(n,()=>n.bindBuffer(n.ARRAY_BUFFER,r)),ce(n,()=>n.vertexAttribPointer(i,a,n.FLOAT,!1,s,o)),ce(n,()=>n.enableVertexAttribArray(i)),!0)}function _6(n,e,t){M6(n,t),ce(n,()=>n.activeTexture(n.TEXTURE0+t)),ce(n,()=>n.bindTexture(n.TEXTURE_2D,e))}function A6(n,e,t){return Un(n,()=>n.getUniformLocation(e,t),'uniform "'+t+'" not present in program.')}function O6(n,e,t){return n.getUniformLocation(e,t)}function F6(n,e,t,r){ce(n,()=>_6(n,e,r)),ce(n,()=>n.uniform1i(t,r))}function ui(n,e,t){ce(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,t)),ce(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0))}function Hl(n,e){ce(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,e)),ce(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,null,0))}function Hs(n){const e=n.checkFramebufferStatus(n.FRAMEBUFFER);if(e!==n.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+D6(n,e))}function D6(n,e){switch(e){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case n.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function Un(n,e,t){const r=ce(n,()=>e());if(r==null)throw new Error(t);return r}function M6(n,e){const t=n.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+n.TEXTURE0;if(r<n.TEXTURE0||r>t){const a=`[gl.TEXTURE0, gl.TEXTURE${t}]`;throw new Error(`textureUnit must be in ${a}.`)}}function da(n,e=2){return ae(n.slice(0,n.length-e))}function fa(n){if(n.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[n.length>1?n[n.length-2]:1,n[n.length-1]]}function li(n){let e=[1,1,1];return n.length===0||n.length===1&&n[0]===1||(e=[da(n),...fa(n)]),e}function L6(n,e=!1){let t=H().getNumber("WEBGL_MAX_TEXTURE_SIZE"),r=H().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");r===1/0&&H().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(r=t/2),e&&(t=t*2,r=r*2,n=n.map((i,u)=>u>=n.length-2?ku(n[u]):n[u]),n.length===1&&(n=[2,n[0]])),n.length!==2&&(n=rr(n).newShape);let a=ae(n),s=null;n.length<=1&&a<=t?s=[1,a]:n.length===2&&n[0]<=t&&n[1]<=t?s=n:n.length===3&&n[0]*n[1]<=t&&n[2]<=t?s=[n[0]*n[1],n[2]]:n.length===3&&n[0]<=t&&n[1]*n[2]<=t?s=[n[0],n[1]*n[2]]:n.length===4&&n[0]*n[1]*n[2]<=t&&n[3]<=t?s=[n[0]*n[1]*n[2],n[3]]:n.length===4&&n[0]<=t&&n[1]*n[2]*n[3]<=t&&(s=[n[0],n[1]*n[2]*n[3]]);const o=s!=null&&Math.max(...s)>r&&Math.min(...s)<=(e?2:1)&&Math.min(...s)>0;if(s==null||o)if(e){const i=da(n);let u=2,l=2;n.length&&([u,l]=fa(n)),a=i*(u/2)*(l/2),s=Ei(a).map(c=>c*2)}else s=Ei(a);return s}function Xs(n){return n%2===0}function lo(n,e){if(n=n.slice(-2),e=e.slice(-2),qe(n,e)||!n.length||!e.length||n[0]===0||n[1]===0||e[0]===0||e[1]===0)return!0;if(n.length!==e.length){const t=n.slice(-1)[0],r=e.slice(-1)[0];if(t===r||Xs(t)&&Xs(r)&&(n[0]===1||e[0]===1))return!0}return n[1]===e[1]&&Xs(n[0])&&Xs(e[0])}let ci,pi;function P6(n){if(ci==null){const e=pn(n);ci=e.getParameter(e.MAX_TEXTURE_SIZE)}return ci}function B6(n){if(pi==null){const e=pn(n);pi=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,pi)}function U6(n){if(n===0)return 0;let e;const t=pn(n);return Zt(t,"EXT_disjoint_timer_query_webgl2")&&n===2?e=2:Zt(t,"EXT_disjoint_timer_query")?e=1:e=0,e}function Zt(n,e){return n.getExtension(e)!=null}function Xl(n){try{if(pn(n)!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function V6(n){if(n===0)return!1;const e=pn(n);if(n===1){if(!Zt(e,"OES_texture_float"))return!1}else if(!Zt(e,"EXT_color_buffer_float"))return!1;return iu(e)}function W6(n){if(n===0)return!1;const e=pn(n);if(n===1){if(!Zt(e,"OES_texture_float")||!Zt(e,"WEBGL_color_buffer_float"))return!1}else{if(Zt(e,"EXT_color_buffer_float"))return iu(e);const t="EXT_color_buffer_half_float";if(Zt(e,t)){const r=e.getExtension(t);return z6(e,r)}return!1}return iu(e)}function iu(n){const e=rl(n),t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texImage2D(n.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const r=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,r),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0);const a=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(t),n.deleteFramebuffer(r),a}function z6(n,e){const t=rl(n,e),r=n.createTexture();n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,t.internalFormatHalfFloat,1,1,0,t.textureFormatFloat,t.textureTypeHalfFloat,null);const a=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,a),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,r,0);const s=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(r),n.deleteFramebuffer(a),s}function G6(n){return n!==2?!1:pn(n).fenceSync!=null}
4482function ys(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>{t!=null&&R(t.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the WebGL backend.`)})}/** 4483 * @license 4484 * Copyright 2019 Google LLC. All Rights Reserved. 4485 * Licensed under the Apache License, Version 2.0 (the "License"); 4486 * you may not use this file except in compliance with the License. 4487 * You may obtain a copy of the License at 4488 * 4489 * http://www.apache.org/licenses/LICENSE-2.0 4490 * 4491 * Unless required by applicable law or agreed to in writing, software 4492 * distributed under the License is distributed on an "AS IS" BASIS, 4493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4494 * See the License for the specific language governing permissions and 4495 * limitations under the License. 4496 * ============================================================================= 4497 */const he=H();he.registerFlag("HAS_WEBGL",()=>he.getNumber("WEBGL_VERSION")>0);he.registerFlag("WEBGL_VERSION",()=>Xl(2)?2:Xl(1)?1:0);he.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);he.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>he.get("WEBGL_VERSION")===2);he.registerFlag("WEBGL_CPU_FORWARD",()=>!0);he.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);he.registerFlag("WEBGL_PACK",()=>he.getBool("HAS_WEBGL"));he.registerFlag("WEBGL_PACK_NORMALIZATION",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_PACK_CLIP",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_PACK_REDUCE",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_LAZILY_UNPACK",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_CONV_IM2COL",()=>he.getBool("WEBGL_PACK"));he.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>P6(he.getNumber("WEBGL_VERSION")));he.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>B6(he.getNumber("WEBGL_VERSION")));he.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const n=he.getNumber("WEBGL_VERSION");return n===0?0:U6(n)});he.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>he.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Bd());he.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>V6(he.getNumber("WEBGL_VERSION")));he.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>he.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:he.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));he.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>W6(he.getNumber("WEBGL_VERSION")));he.registerFlag("WEBGL_FENCE_API_ENABLED",()=>G6(he.getNumber("WEBGL_VERSION")));he.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>he.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);he.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,n=>{if(n<0&&n!==-1)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${n}.`)});he.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>Bd()?1:-1,n=>{if(n<0&&n!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${n}.`)});he.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);he.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1);he.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5);he.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128);he.registerFlag("WEBGL_EXP_CONV",()=>!1);he.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>he.getBool("IS_TEST"));he.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0);he.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1);he.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1);/** 4498 * @license 4499 * Copyright 2018 Google LLC. All Rights Reserved. 4500 * Licensed under the Apache License, Version 2.0 (the "License"); 4501 * you may not use this file except in compliance with the License. 4502 * You may obtain a copy of the License at 4503 * 4504 * http://www.apache.org/licenses/LICENSE-2.0 4505 * 4506 * Unless required by applicable law or agreed to in writing, softw
4506are 4507 * distributed under the License is distributed on an "AS IS" BASIS, 4508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4509 * See the License for the specific language governing permissions and 4510 * limitations under the License. 4511 * ============================================================================= 4512 */function xt(){let n,e,t,r,a,s,o,i,u,l;return H().getNumber("WEBGL_VERSION")===2?(n="#version 300 es",e="in",t="out",r="in",a="texture",s="outputColor",o="out vec4 outputColor;",i=H().getBool("WEBGL2_ISNAN_CUSTOM")?` 4513 bool isnan_custom(float val) { 4514 uint floatToUint = floatBitsToUint(val); 4515 return (floatToUint & 0x7fffffffu) > 0x7f800000u; 4516 } 4517 4518 bvec4 isnan_custom(vec4 val) { 4519 return bvec4(isnan_custom(val.x), 4520 isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w)); 4521 } 4522 4523 #define isnan(value) isnan_custom(value) 4524 `:"",u="",l=` 4525 #define round(value) newRound(value) 4526 int newRound(float value) { 4527 return int(floor(value + 0.5)); 4528 } 4529 4530 ivec4 newRound(vec4 value) { 4531 return ivec4(floor(value + vec4(0.5))); 4532 } 4533 `):(n="",e="attribute",t="varying",r="varying",a="texture2D",s="gl_FragColor",o="",i=` 4534 #define isnan(value) isnan_custom(value) 4535 bool isnan_custom(float val) { 4536 return (val > 0. || val < 1. || val == 0.) ? false : true; 4537 } 4538 bvec4 isnan_custom(vec4 val) { 4539 return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w)); 4540 } 4541 `,u=` 4542 uniform float INFINITY; 4543 4544 bool isinf(float val) { 4545 return abs(val) == INFINITY; 4546 } 4547 bvec4 isinf(vec4 val) { 4548 return equal(abs(val), vec4(INFINITY)); 4549 } 4550 `,l=` 4551 int round(float value) { 4552 return int(floor(value + 0.5)); 4553 } 4554 4555 ivec4 round(vec4 value) { 4556 return ivec4(floor(value + vec4(0.5))); 4557 } 4558 `),{version:n,attribute:e,varyingVs:t,varyingFs:r,texture2D:a,output:s,defineOutput:o,defineSpecialNaN:i,defineSpecialInf:u,defineRound:l}}/** 4559 * @license 4560 * Copyright 2018 Google LLC. All Rights Reserved. 4561 * Licensed under the Apache License, Version 2.0 (the "License"); 4562 * you may not use this file except in compliance with the License. 4563 * You may obtain a copy of the License at 4564 * 4565 * http://www.apache.org/licenses/LICENSE-2.0 4566 * 4567 * Unless required by applicable law or agreed to in writing, software 4568 * distributed under the License is distributed on an "AS IS" BASIS, 4569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4570 * See the License for the specific language governing permissions and 4571 * limitations under the License. 4572 * ============================================================================= 4573 */function Ur(n,e,t="index"){const r=ot(e);return r.map((a,s)=>{const o=`int ${n[s]} = ${t} / ${a}`,i=s===r.length-1?`int ${n[s+1]} = ${t} - ${n[s]} * ${a}`:`index -= ${n[s]} * ${a}`;return`${o}; ${i};`}).join("")}function Mo(n,e,t="index"){const r=ot(e);return r.map((a,s)=>{const o=`int ${n[s]} = ${t} / outShapeStrides[${s}]`,i=s===r.length-1?`int ${n[s+1]} = ${t} - ${n[s]} * outShapeStrides[${s}]`:`index -= ${n[s]} * outShapeStrides[${s}]`;return`${o}; ${i};`}).join("")}function j6(n,e){const t=n.length,r=n.map(s=>`${e}[${s}]`),a=new Array(t-1);a[t-2]=r[t-1];for(let s=t-3;s>=0;--s)a[s]=`(${a[s+1]} * ${r[s+1]})`;return a}function H6(n,e,t="index"){const r=n.map((s,o)=>o),a=j6(r,e);return a.map((s,o)=>{const i=`int ${n[o]} = ${t} / ${a[o]}`,u=o===a.length-1?`int ${n[o+1]} = ${t} - ${n[o]} * ${a[o]}`:`index -= ${n[o]} * ${a[o]}`;return`${i}; ${u};`}).join("")}function al(n){const e=ot(n).map(t=>t.toString());return` 4574 int getFlatIndex(ivec3 coords) { 4575 return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z; 4576 } 4577`}function sl(){return` 4578 int getFlatIndex(ivec3 coords) { 4579 return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z; 4580 } 4581`}const J1=` 4582 const float FLOAT_MAX = 1.70141184e38; 4583 const float FLOAT_MIN = 1.17549435e-38; 4584 4585 lowp vec4 encode_float(highp float v) { 4586 if (isnan(v)) { 4587 return vec4(255, 255, 255, 255); 4588 } 4589 4590 highp float av = abs(v); 4591 4592 if(av < FLOAT_MIN) { 4593 return vec4(0.0, 0.0, 0.0, 0.0); 4594 } else if(v > FLOAT_MAX) { 4595 return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; 4596 } else if(v < -FLOAT_MAX) { 4597 return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; 4598 } 4599 4600 highp vec4 c = vec4(0,0,0,0); 4601 4602 highp float e = floor(log2(av)); 4603 highp float m = exp2(fract(log2(av))) - 1.0; 4604 4605 c[2] = floor(128.0 * m); 4606 m -= c[2] / 128.0; 4607 c[1] = floor(32768.0 * m); 4608 m -= c[1] / 32768.0; 4609 c[0] = floor(8388608.0 * m); 4610 4611 highp float ebias = e + 127.0; 4612 c[3] = floor(ebias / 2.0); 4613 ebias -= c[3] * 2.0; 4614 c[2] += floor(ebias) * 128.0; 4615 4616 c[3] += 128.0 * step(0.0, -v); 4617 4618 return c / 255.0; 4619 } 4620`;/** 4621 * @license 4622 * Copyright 2017 Google LLC. All Rights Reserved. 4623 * Licensed under the Apache License, Version 2.0 (the "License");
4624 * you may not use this file except in compliance with the License. 4625 * You may obtain a copy of the License at 4626 * 4627 * http://www.apache.org/licenses/LICENSE-2.0 4628 * 4629 * Unless required by applicable law or agreed to in writing, software 4630 * distributed under the License is distributed on an "AS IS" BASIS, 4631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4632 * See the License for the specific language governing permissions and 4633 * limitations under the License. 4634 * ============================================================================= 4635 */const{getBroadcastDims:Q1}=c6;function X6(n,e,t){const r=[];if(n.forEach(h=>{const d=ae(h.shapeInfo.logicalShape);if(h.shapeInfo.isUniform?r.push(`uniform float ${h.name}${d>1?`[${d}]`:""};`):(r.push(`uniform sampler2D ${h.name};`),r.push(`uniform int offset${h.name};`)),t.enableShapeUniforms){const{uniformShape:m}=ol(t.packedInputs,h.shapeInfo.logicalShape,h.shapeInfo.texShape);switch(m.length){case 1:r.push(`uniform int ${h.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${h.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${h.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${h.name}Shape;`);break}r.push(`uniform ivec2 ${h.name}TexShape;`)}}),t.enableShapeUniforms){switch(e.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;");break}r.push("uniform ivec2 outTexShape;")}
vendor: 5,104 bytes, lines 4635-4770
4635t.customUniforms&&t.customUniforms.forEach(h=>{r.push(`uniform ${h.type} ${h.name}${h.arrayIndex?`[${h.arrayIndex}]`:""};`)});const a=r.join(` 4636`),s=n.map(h=>q6(h,e,t.packedInputs,t.enableShapeUniforms)).join(` 4637`),o=e.texShape,i=xt(),u=Z6(i);let l,c,p=eS(i);return e.isPacked?(l=K6(e.logicalShape,o,t.enableShapeUniforms),c=Q6(i)):(l=Y6(e.logicalShape,o,t.enableShapeUniforms),c=J6(i)),t.packedInputs&&(p+=aS),[p,u,c,a,l,s,t.userCode].join(` 4638`)}function Sa(n,e=!1){const t=n.shapeInfo.logicalShape;switch(t.length){case 0:return gS(n,e);case 1:return xS(n,e);case 2:return vS(n,e);case 3:return SS(n,e);case 4:return TS(n,e);case 5:return ES(n);case 6:return CS(n);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function em(n,e){switch(n.shapeInfo.logicalShape.length){case 0:return mS(n);case 1:return yS(n,e);case 2:return bS(n,e);case 3:return wS(n,e);default:return kS(n,e)}}function q6(n,e,t=!1,r){let a="";t?a+=em(n,r):a+=Sa(n,r);const s=n.shapeInfo.logicalShape,o=e.logicalShape;return s.length<=o.length&&(t?a+=IS(n,e):a+=NS(n,e)),a}function K6(n,e,t){switch(n.length){case 0:return tm();case 1:return sS(n,e,t);case 2:return dS(n,e,t);case 3:return iS(n,e,t);default:return lS(n,e,t)}}function Y6(n,e,t){switch(n.length){case 0:return tm();case 1:return oS(n,e,t);case 2:return fS(n,e,t);case 3:return uS(n,e,t);case 4:return cS(n,e,t);case 5:return pS(n,e);case 6:return hS(n,e);default:throw new Error(`${n.length}-D output sampling is not yet supported`)}}function Z6(n){return` 4639 float sampleTexture(sampler2D textureSampler, vec2 uv) { 4640 return ${n.texture2D}(textureSampler, uv).r; 4641 } 4642 `}function J6(n){return` 4643 void setOutput(float val) { 4644 ${n.output} = vec4(val, 0, 0, 0); 4645 } 4646 `}function Q6(n){return` 4647 void setOutput(vec4 val) { 4648 ${n.output} = val; 4649 } 4650 `}function eS(n){return`${n.version} 4651 precision highp float; 4652 precision highp int; 4653 precision highp sampler2D; 4654 ${n.varyingFs} vec2 resultUV; 4655 ${n.defineOutput} 4656 const vec2 halfCR = vec2(0.5, 0.5); 4657 4658 struct ivec5 4659 { 4660 int x; 4661 int y; 4662 int z; 4663 int w; 4664 int u; 4665 }; 4666 4667 struct ivec6 4668 { 4669 int x; 4670 int y; 4671 int z; 4672 int w; 4673 int u; 4674 int v; 4675 }; 4676 4677 uniform float NAN; 4678 ${n.defineSpecialNaN} 4679 ${n.defineSpecialInf} 4680 ${n.defineRound} 4681 4682 int imod(int x, int y) { 4683 return x - y * (x / y); 4684 } 4685 4686 int idiv(int a, int b, float sign) { 4687 int res = a / b; 4688 int mod = imod(a, b); 4689 if (sign < 0. && mod != 0) { 4690 res -= 1; 4691 } 4692 return res; 4693 } 4694 4695 //Based on the work of Dave Hoskins 4696 //https://www.shadertoy.com/view/4djSRW 4697 #define HASHSCALE1 443.8975 4698 float random(float seed){ 4699 vec2 p = resultUV * seed; 4700 vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1); 4701 p3 += dot(p3, p3.yzx + 19.19); 4702 return fract((p3.x + p3.y) * p3.z); 4703 } 4704 4705 ${tS} 4706 ${nS} 4707 ${rS} 4708 `}const tS=` 4709vec2 uvFromFlat(int texNumR, int texNumC, int index) { 4710 int texR = index / texNumC; 4711 int texC = index - texR * texNumC; 4712 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 4713} 4714vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { 4715 int texelIndex = index / 2; 4716 int texR = texelIndex / texNumC; 4717 int texC = texelIndex - texR * texNumC; 4718 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 4719} 4720`,nS=` 4721vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, 4722 int texNumC, int row, int col) { 4723 int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); 4724 int texR = texelIndex / texNumC; 4725 int texC = texelIndex - texR * texNumC; 4726 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 4727} 4728`,rS=` 4729vec2 packedUVfrom3D(int texNumR, int texNumC, 4730 int texelsInBatch, int texelsInLogicalRow, int b, 4731 int row, int col) { 4732 int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); 4733 int texR = index / texNumC; 4734 int texC = index - texR * texNumC; 4735 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 4736} 4737`,aS=` 4738 float getChannel(vec4 frag, vec2 innerDims) { 4739 vec2 modCoord = mod(innerDims, 2.); 4740 return modCoord.x == 0. ? 4741 (modCoord.y == 0. ? frag.r : frag.g) : 4742 (modCoord.y == 0. ? frag.b : frag.a); 4743 } 4744 float getChannel(vec4 frag, int dim) { 4745 float modCoord = mod(float(dim), 2.); 4746 return modCoord == 0. ? frag.r : frag.g; 4747 } 4748`;function tm(){return` 4749 int getOutputCoords() { 4750 return 0; 4751 } 4752 `}function sS(n,e,t){const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return r[0]===1?t?` 4753 int getOutputCoords() { 4754 return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0)); 4755 } 4756 `:` 4757 int getOutputCoords() { 4758 return 2 * int(resultUV.x * ${r[1]}.0); 4759 } 4760 `:r[1]===1?t?` 4761 int getOutputCoords() { 4762 return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0)); 4763 } 4764 `:` 4765 int getOutputCoords() { 4766 return 2 * int(resultUV.y * ${r[0]}.0); 4767 } 4768 `:t?` 4769 int getOutputCoords() { 4770 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
4771 ivec2 resTexRC = ivec2(resultUV.yx * 4772 vec2(packedTexShape[0], packedTexShape[1])); 4773 return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y); 4774 } 4775 `:` 4776 int getOutputCoords() { 4777 ivec2 resTexRC = ivec2(resultUV.yx * 4778 vec2(${r[0]}, ${r[1]})); 4779 return 2 * (resTexRC.x * ${r[1]} + resTexRC.y); 4780 } 4781 `}function oS(n,e,t){return e[0]===1?t?` 4782 int getOutputCoords() { 4783 return int(resultUV.x * float(outTexShape[1])); 4784 } 4785 `:` 4786 int getOutputCoords() { 4787 return int(resultUV.x * ${e[1]}.0); 4788 } 4789 `:e[1]===1?t?` 4790 int getOutputCoords() { 4791 return int(resultUV.y * float(outTexShape[0])); 4792 } 4793 `:` 4794 int getOutputCoords() { 4795 return int(resultUV.y * ${e[0]}.0); 4796 } 4797 `:t?` 4798 int getOutputCoords() { 4799 ivec2 resTexRC = ivec2(resultUV.yx * 4800 vec2(outTexShape[0], outTexShape[1])); 4801 return resTexRC.x * outTexShape[1] + resTexRC.y; 4802 } 4803 `:` 4804 int getOutputCoords() { 4805 ivec2 resTexRC = ivec2(resultUV.yx * 4806 vec2(${e[0]}, ${e[1]})); 4807 return resTexRC.x * ${e[1]} + resTexRC.y; 4808 } 4809 `}function iS(n,e,t){if(t)return` 4810 ivec3 getOutputCoords() { 4811 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 4812 int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0)); 4813 int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0)); 4814 ivec2 resTexRC = ivec2(resultUV.yx * 4815 vec2(packedTexShape[0], packedTexShape[1])); 4816 int index = resTexRC.x * packedTexShape[1] + resTexRC.y; 4817 4818 int b = index / texelsInBatch; 4819 index -= b * texelsInBatch; 4820 4821 int r = 2 * (index / texelsInLogicalRow); 4822 int c = imod(index, texelsInLogicalRow) * 2; 4823 4824 return ivec3(b, r, c); 4825 } 4826 `;const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],a=Math.ceil(n[2]/2),s=a*Math.ceil(n[1]/2);return` 4827 ivec3 getOutputCoords() { 4828 ivec2 resTexRC = ivec2(resultUV.yx * 4829 vec2(${r[0]}, ${r[1]})); 4830 int index = resTexRC.x * ${r[1]} + resTexRC.y; 4831 4832 int b = index / ${s}; 4833 index -= b * ${s}; 4834 4835 int r = 2 * (index / ${a}); 4836 int c = imod(index, ${a}) * 2; 4837 4838 return ivec3(b, r, c); 4839 } 4840 `}function uS(n,e,t){if(t)return` 4841 ivec3 getOutputCoords() { 4842 ivec2 resTexRC = ivec2(resultUV.yx * 4843 vec2(outTexShape[0], outTexShape[1])); 4844 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 4845 ${Mo(["r","c","d"],n)} 4846 return ivec3(r, c, d); 4847 } 4848`;const r=Ur(["r","c","d"],n);return` 4849 ivec3 getOutputCoords() { 4850 ivec2 resTexRC = ivec2(resultUV.yx * 4851 vec2(${e[0]}, ${e[1]})); 4852 int index = resTexRC.x * ${e[1]} + resTexRC.y; 4853 ${r} 4854 return ivec3(r, c, d); 4855 } 4856 `}function lS(n,e,t){if(t)return` 4857 ivec4 getOutputCoords() { 4858 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 4859 ivec2 resTexRC = ivec2(resultUV.yx * 4860 vec2(packedTexShape[0], packedTexShape[1])); 4861 int index = resTexRC.x * packedTexShape[1] + resTexRC.y; 4862 4863 int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0)); 4864 int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0)); 4865 int texelsInBatchN = texelsInBatch * outShape[1]; 4866 4867 int b2 = index / texelsInBatchN; 4868 index -= b2 * texelsInBatchN; 4869 4870 int b = index / texelsInBatch; 4871 index -= b * texelsInBatch; 4872 4873 int r = 2 * (index / texelsInLogicalRow); 4874 int c = imod(index, texelsInLogicalRow) * 2; 4875 4876 return ivec4(b2, b, r, c); 4877 } 4878 `;const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],a=Math.ceil(n[n.length-1]/2),s=a*Math.ceil(n[n.length-2]/2);let o=s,i="",u="b, r, c";for(let l=2;l<n.length-1;l++)o*=n[n.length-l-1],i=` 4879 int b${l} = index / ${o}; 4880 index -= b${l} * ${o}; 4881 `+i,u=`b${l}, `+u;return` 4882 ivec${n.length} getOutputCoords() {
4883 ivec2 resTexRC = ivec2(resultUV.yx * 4884 vec2(${r[0]}, ${r[1]})); 4885 int index = resTexRC.x * ${r[1]} + resTexRC.y; 4886 4887 ${i} 4888 4889 int b = index / ${s}; 4890 index -= b * ${s}; 4891 4892 int r = 2 * (index / ${a}); 4893 int c = imod(index, ${a}) * 2; 4894 4895 return ivec${n.length}(${u}); 4896 } 4897 `}function cS(n,e,t){if(t)return` 4898 ivec4 getOutputCoords() { 4899 ivec2 resTexRC = ivec2(resultUV.yx * 4900 vec2(outTexShape[0], outTexShape[1])); 4901 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 4902 ${Mo(["r","c","d","d2"],n)} 4903 return ivec4(r, c, d, d2); 4904 } 4905 `;const r=Ur(["r","c","d","d2"],n);return` 4906 ivec4 getOutputCoords() { 4907 ivec2 resTexRC = ivec2(resultUV.yx * 4908 vec2(${e[0]}, ${e[1]})); 4909 int index = resTexRC.x * ${e[1]} + resTexRC.y; 4910 ${r} 4911 return ivec4(r, c, d, d2); 4912 } 4913 `}function pS(n,e){const t=Ur(["r","c","d","d2","d3"],n);return` 4914 ivec5 getOutputCoords() { 4915 ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, 4916 ${e[1]})); 4917 4918 int index = resTexRC.x * ${e[1]} + resTexRC.y; 4919 4920 ${t} 4921 4922 ivec5 outShape = ivec5(r, c, d, d2, d3); 4923 return outShape; 4924 } 4925 `}function hS(n,e){const t=Ur(["r","c","d","d2","d3","d4"],n);return` 4926 ivec6 getOutputCoords() { 4927 ivec2 resTexRC = ivec2(resultUV.yx * 4928 vec2(${e[0]}, ${e[1]})); 4929 int index = resTexRC.x * ${e[1]} + resTexRC.y; 4930 4931 ${t} 4932 4933 ivec6 result = ivec6(r, c, d, d2, d3, d4); 4934 return result; 4935 } 4936 `}function dS(n,e,t){const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(qe(n,e))return t?` 4937 ivec2 getOutputCoords() { 4938 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 4939 return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1])); 4940 } 4941 `:` 4942 ivec2 getOutputCoords() { 4943 return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]})); 4944 } 4945 `;const a=Math.ceil(n[1]/2);return t?` 4946 ivec2 getOutputCoords() { 4947 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 4948 int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0)); 4949 ivec2 resTexRC = ivec2(resultUV.yx * 4950 vec2(packedTexShape[0], packedTexShape[1])); 4951 4952 int index = resTexRC.x * packedTexShape[1] + resTexRC.y; 4953 int r = 2 * (index / texelsInLogicalRow); 4954 int c = imod(index, texelsInLogicalRow) * 2; 4955 4956 return ivec2(r, c); 4957 } 4958 `:` 4959 ivec2 getOutputCoords() { 4960 ivec2 resTexRC = ivec2(resultUV.yx * 4961 vec2(${r[0]}, ${r[1]})); 4962 4963 int index = resTexRC.x * ${r[1]} + resTexRC.y; 4964 int r = 2 * (index / ${a}); 4965 int c = imod(index, ${a}) * 2; 4966 4967 return ivec2(r, c); 4968 } 4969 `}function fS(n,e,t){return qe(n,e)?t?` 4970 ivec2 getOutputCoords() { 4971 return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); 4972 } 4973 `:` 4974 ivec2 getOutputCoords() { 4975 return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); 4976 } 4977 `:n[1]===1?t?` 4978 ivec2 getOutputCoords() { 4979 ivec2 resTexRC = ivec2(resultUV.yx * 4980 vec2(outTexShape[0], outTexShape[1])); 4981 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 4982 return ivec2(index, 0); 4983 } 4984 `:` 4985 ivec2 getOutputCoords() { 4986 ivec2 resTexRC = ivec2(resultUV.yx * 4987 vec2(${e[0]}, ${e[1]})); 4988 int index = resTexRC.x * ${e[1]} + resTexRC.y; 4989 return ivec2(index, 0); 4990 } 4991 `:n[0]===1?t?` 4992 ivec2 getOutputCoords() { 4993 ivec2 resTexRC = ivec2(resultUV.yx * 4994 vec2(outTexShape[0], outTexShape[1])); 4995 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 4996 return ivec2(0, index); 4997 } 4998 `:` 4999 ivec2 getOutputCoords() { 5000 ivec2 resTexRC = ivec2(resultUV.yx * 5001 vec2(${e[0]}, ${e[1]})); 5002 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5003 return ivec2(0, index); 5004 } 5005 `:t?` 5006 ivec2 getOutputCoords() {
5007 ivec2 resTexRC = ivec2(resultUV.yx * 5008 vec2(outTexShape[0], outTexShape[1])); 5009 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 5010 int r = index / outShape[1]; 5011 int c = index - r * outShape[1]; 5012 return ivec2(r, c); 5013 } 5014 `:` 5015 ivec2 getOutputCoords() { 5016 ivec2 resTexRC = ivec2(resultUV.yx * 5017 vec2(${e[0]}, ${e[1]})); 5018 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5019 int r = index / ${n[1]}; 5020 int c = index - r * ${n[1]}; 5021 return ivec2(r, c); 5022 } 5023 `}function Vr(n){return`offset${n}`}function mS(n){const e=n.name,t="get"+e.charAt(0).toUpperCase()+e.slice(1),r=xt();return` 5024 vec4 ${t}() { 5025 return ${r.texture2D}(${e}, halfCR); 5026 } 5027 `}function gS(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return`float ${r}() {return ${t};}`;const[a,s]=n.shapeInfo.texShape;if(a===1&&s===1)return` 5028 float ${r}() { 5029 return sampleTexture(${t}, halfCR); 5030 } 5031 `;const o=Vr(t);if(e)return` 5032 float ${r}() { 5033 vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], ${o}); 5034 return sampleTexture(${t}, uv); 5035 } 5036 `;const[i,u]=n.shapeInfo.texShape;return` 5037 float ${r}() { 5038 vec2 uv = uvFromFlat(${i}, ${u}, ${o}); 5039 return sampleTexture(${t}, uv); 5040 } 5041 `}function yS(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),a=n.shapeInfo.texShape,s=xt();if(e)return` 5042 vec4 ${r}(int index) { 5043 ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0)); 5044 vec2 uv = packedUVfrom1D( 5045 packedTexShape[0], packedTexShape[1], index); 5046 return ${s.texture2D}(${t}, uv); 5047 } 5048 `;const o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];return` 5049 vec4 ${r}(int index) { 5050 vec2 uv = packedUVfrom1D( 5051 ${o[0]}, ${o[1]}, index); 5052 return ${s.texture2D}(${t}, uv); 5053 } 5054 `}function xS(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return` 5055 float ${r}(int index) { 5056 ${ka(n)} 5057 } 5058 `;const a=n.shapeInfo.texShape,s=a[0],o=a[1];if(o===1&&s===1)return` 5059 float ${r}(int index) { 5060 return sampleTexture(${t}, halfCR); 5061 } 5062 `;const i=Vr(t);return o===1?e?` 5063 float ${r}(int index) { 5064 vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${t}TexShape[0])); 5065 return sampleTexture(${t}, uv); 5066 } 5067 `:` 5068 float ${r}(int index) { 5069 vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${s}.0); 5070 return sampleTexture(${t}, uv); 5071 } 5072 `:s===1?e?` 5073 float ${r}(int index) { 5074 vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${t}TexShape[1]), 0.5); 5075 return sampleTexture(${t}, uv); 5076 } 5077 `:` 5078 float ${r}(int index) { 5079 vec2 uv = vec2((float(index + ${i}) + 0.5) / ${o}.0, 0.5); 5080 return sampleTexture(${t}, uv); 5081 } 5082 `:e?` 5083 float ${r}(int index) { 5084 vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], index + ${i}); 5085 return sampleTexture(${t}, uv); 5086 } 5087 `:` 5088 float ${r}(int index) { 5089 vec2 uv = uvFromFlat(${s}, ${o}, index + ${i}); 5090 return sampleTexture(${t}, uv); 5091 } 5092 `}function bS(n,e){const t=n.shapeInfo.logicalShape,r=n.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),s=n.shapeInfo.texShape,o=s[0],i=s[1],u=xt();if(s!=null&&qe(t,s))return e?` 5093 vec4 ${a}(int row, int col) { 5094 vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]); 5095 5096 return ${u.texture2D}(${r}, uv); 5097 } 5098 `:` 5099 vec4 ${a}(int row, int col) { 5100 vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}.0, ${o}.0); 5101 5102 return ${u.texture2D}(${r}, uv); 5103 } 5104 `;if(e)return` 5105 vec4 ${a}(int row, int col) { 5106 ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0)); 5107 int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0)); 5108 vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col); 5109 return ${u.texture2D}(${r}, uv); 5110 } 5111 `;const l=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],c=Math.ceil(t[1]/2);return` 5112 vec4 ${a}(int row, int col) { 5113 vec2 uv = packedUVfrom2D(${c}, ${l[0]}, ${l[1]}
5113, row, col); 5114 return ${u.texture2D}(${r}, uv); 5115 } 5116 `}function vS(n,e){const t=n.shapeInfo.logicalShape,r=n.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),s=n.shapeInfo.texShape;if(s!=null&&qe(t,s)){if(e)return` 5117 float ${a}(int row, int col) { 5118 vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]); 5119 return sampleTexture(${r}, uv); 5120 } 5121 `;const h=s[0],d=s[1];return` 5122 float ${a}(int row, int col) { 5123 vec2 uv = (vec2(col, row) + halfCR) / vec2(${d}.0, ${h}.0); 5124 return sampleTexture(${r}, uv); 5125 } 5126 `}const{newShape:o,keptDims:i}=rr(t),u=o;if(u.length<t.length){const h=Ta(n,u),d=["row","col"];return` 5127 ${Sa(h,e)} 5128 float ${a}(int row, int col) { 5129 return ${a}(${Ea(d,i)}); 5130 } 5131 `}if(n.shapeInfo.isUniform)return` 5132 float ${a}(int row, int col) { 5133 int index = round(dot(vec2(row, col), vec2(${t[1]}, 1))); 5134 ${ka(n)} 5135 } 5136 `;const l=s[0],c=s[1],p=Vr(r);return c===1?e?` 5137 float ${a}(int row, int col) { 5138 float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1)); 5139 vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0])); 5140 return sampleTexture(${r}, uv); 5141 } 5142 `:` 5143 float ${a}(int row, int col) { 5144 float index = dot(vec3(row, col, ${p}), vec3(${t[1]}, 1, 1)); 5145 vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0); 5146 return sampleTexture(${r}, uv); 5147 } 5148 `:l===1?e?` 5149 float ${a}(int row, int col) { 5150 float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1)); 5151 vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5); 5152 return sampleTexture(${r}, uv); 5153 } 5154 `:` 5155 float ${a}(int row, int col) { 5156 float index = dot(vec3(row, col, ${p}), vec3(${t[1]}, 1, 1)); 5157 vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5); 5158 return sampleTexture(${r}, uv); 5159 } 5160 `:e?` 5161 float ${a}(int row, int col) { 5162 // Explicitly use integer operations as dot() only works on floats. 5163 int index = row * ${r}Shape[1] + col + ${p}; 5164 vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index); 5165 return sampleTexture(${r}, uv); 5166 } 5167 `:` 5168 float ${a}(int row, int col) { 5169 // Explicitly use integer operations as dot() only works on floats. 5170 int index = row * ${t[1]} + col + ${p}; 5171 vec2 uv = uvFromFlat(${l}, ${c}, index); 5172 return sampleTexture(${r}, uv); 5173 } 5174`}function wS(n,e){const t=n.shapeInfo.logicalShape,r=n.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),s=n.shapeInfo.texShape,o=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];if(t[0]===1){const h=t.slice(1),d=[1,2],m=Ta(n,h),y=["b","row","col"];return` 5175 ${em(m,e)} 5176 vec4 ${a}(int b, int row, int col) { 5177 return ${a}(${Ea(y,d)}); 5178 } 5179 `}const i=xt();if(e)return` 5180 vec4 ${a}(int b, int row, int col) { 5181 ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0)); 5182 int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0)); 5183 int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0)); 5184 vec2 uv = packedUVfrom3D( 5185 packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col); 5186 return ${i.texture2D}(${r}, uv); 5187 } 5188 `;const u=o[0],l=o[1],c=Math.ceil(t[2]/2),p=c*Math.ceil(t[1]/2);return` 5189 vec4 ${a}(int b, int row, int col) { 5190 vec2 uv = packedUVfrom3D( 5191 ${u}, ${l}, ${p}, ${c}, b, row, col); 5192 return ${i.texture2D}(${r}, uv); 5193 } 5194 `}function SS(n,e){const t=n.shapeInfo.logicalShape,r=n.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),s=t[1]*t[2],o=t[2],{newShape:i,keptDims:u}=rr(t),l=i;if(l.length<t.length){const y=Ta(n,l),b=["row","col","depth"];return` 5195 ${Sa(y,e)} 5196 float ${a}(int row, int col, int depth) { 5197 return ${a}(${Ea(b,u)}); 5198 } 5199 `}if(n.shapeInfo.isUniform)return` 5200 float ${a}(int row, int col, int depth) { 5201 int index = round(dot(vec3(row, col, depth), 5202 vec3(${s}, ${o}, 1))); 5203 ${ka(n)} 5204 } 5205 `;const c=n.shapeInfo.texShape,p=c[0],h=c[1],d=n.shapeInfo.flatOffset;if(h===s&&d==null)return e?` 5206 float ${a}(int row, int col, int depth) {
5207 int stride1 = ${r}Shape[2]; 5208 float texR = float(row); 5209 float texC = dot(vec2(col, depth), vec2(stride1, 1)); 5210 vec2 uv = (vec2(texC, texR) + halfCR) / 5211 vec2(${r}TexShape[1], ${r}TexShape[0]); 5212 return sampleTexture(${r}, uv); 5213 } 5214 `:` 5215 float ${a}(int row, int col, int depth) { 5216 float texR = float(row); 5217 float texC = dot(vec2(col, depth), vec2(${o}, 1)); 5218 vec2 uv = (vec2(texC, texR) + halfCR) / 5219 vec2(${h}.0, ${p}.0); 5220 return sampleTexture(${r}, uv); 5221 } 5222 `;if(h===o&&d==null)return e?` 5223 float ${a}(int row, int col, int depth) { 5224 float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1)); 5225 float texC = float(depth); 5226 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]); 5227 return sampleTexture(${r}, uv); 5228 } 5229 `:` 5230 float ${a}(int row, int col, int depth) { 5231 float texR = dot(vec2(row, col), vec2(${t[1]}, 1)); 5232 float texC = float(depth); 5233 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${h}.0, ${p}.0); 5234 return sampleTexture(${r}, uv); 5235 } 5236 `;const m=Vr(r);return e?` 5237 float ${a}(int row, int col, int depth) { 5238 // Explicitly use integer operations as dot() only works on floats. 5239 int stride0 = ${r}Shape[1] * ${r}Shape[2]; 5240 int stride1 = ${r}Shape[2]; 5241 int index = row * stride0 + col * stride1 + depth + ${m}; 5242 vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index); 5243 return sampleTexture(${r}, uv); 5244 } 5245 `:` 5246 float ${a}(int row, int col, int depth) { 5247 // Explicitly use integer operations as dot() only works on floats. 5248 int index = row * ${s} + col * ${o} + depth + ${m}; 5249 vec2 uv = uvFromFlat(${p}, ${h}, index); 5250 return sampleTexture(${r}, uv); 5251 } 5252 `}function kS(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),a=xt();if(e)return` 5253 vec4 ${r}(int b2, int b, int row, int col) { 5254 int valuesPerRow = int(ceil(float(${t}Shape[3]) / 2.0)); 5255 int texelsInBatch = valuesPerRow * int(ceil(float(${t}Shape[2]) / 2.0)); 5256 int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2); 5257 texelsInBatch *= ${t}Shape[1]; 5258 index = b2 * texelsInBatch + index; 5259 ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0)); 5260 int texR = index / packedTexShape[1]; 5261 int texC = index - texR * packedTexShape[1]; 5262 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${a.texture2D}(${t}, uv); 5263 } 5264 `;const s=n.shapeInfo.logicalShape,o=s.length,i=n.shapeInfo.texShape,u=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],l=u[0],c=u[1],p=Math.ceil(s[o-1]/2);let h=p*Math.ceil(s[o-2]/2),d="int b, int row, int col",m=`b * ${h} + (row / 2) * ${p} + (col / 2)`;for(let y=2;y<o-1;y++)d=`int b${y}, `+d,h*=s[o-y-1],m=`b${y} * ${h} + `+m;return` 5265 vec4 ${r}(${d}) { 5266 int index = ${m}; 5267 int texR = index / ${c}; 5268 int texC = index - texR * ${c}; 5269 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${l}); 5270 return ${a.texture2D}(${t}, uv); 5271 } 5272 `}function TS(n,e){const t=n.shapeInfo.logicalShape,r=n.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),s=t[3],o=t[2]*s,i=t[1]*o,{newShape:u,keptDims:l}=rr(t);if(u.length<t.length){const T=Ta(n,u),$=["row","col","depth","depth2"];return` 5273 ${Sa(T,e)} 5274 float ${a}(int row, int col, int depth, int depth2) { 5275 return ${a}(${Ea($,l)}); 5276 } 5277 `}if(n.shapeInfo.isUniform)return` 5278 float ${a}(int row, int col, int depth, int depth2) { 5279 int index = round(dot(vec4(row, col, depth, depth2), 5280 vec4(${i}, ${o}, ${s}, 1))); 5281 ${ka(n)} 5282 } 5283 `;const c=n.shapeInfo.flatOffset,p=n.shapeInfo.texShape,h=p[0],d=p[1],m=`int stride2 = ${r}Shape[3];`,y=`int stride1 = ${r}Shape[2] * stride2;`,b=`int stride0 = ${r}Shape[1] * stride1;`;if(d===i&&c==null)return e?` 5284 float ${a}(int row, int col, int depth, int depth2) { 5285 ${m} 5286 ${y} 5287 float texR = float(row); 5288 float texC = 5289 dot(vec3(col, depth, depth2),
5290 vec3(stride1, stride2, 1)); 5291 vec2 uv = (vec2(texC, texR) + halfCR) / 5292 vec2(${r}TexShape[1], ${r}TexShape[0]); 5293 return sampleTexture(${r}, uv); 5294 } 5295 `:` 5296 float ${a}(int row, int col, int depth, int depth2) { 5297 float texR = float(row); 5298 float texC = 5299 dot(vec3(col, depth, depth2), 5300 vec3(${o}, ${s}, 1)); 5301 vec2 uv = (vec2(texC, texR) + halfCR) / 5302 vec2(${d}.0, ${h}.0); 5303 return sampleTexture(${r}, uv); 5304 } 5305 `;if(d===s&&c==null)return e?` 5306 float ${a}(int row, int col, int depth, int depth2) { 5307 float texR = dot(vec3(row, col, depth), 5308 vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1)); 5309 float texC = float(depth2); 5310 vec2 uv = (vec2(texC, texR) + halfCR) / 5311 vec2(${r}TexShape[1], ${r}TexShape[0]); 5312 return sampleTexture(${r}, uv); 5313 } 5314 `:` 5315 float ${a}(int row, int col, int depth, int depth2) { 5316 float texR = dot(vec3(row, col, depth), 5317 vec3(${t[1]*t[2]}, ${t[2]}, 1)); 5318 float texC = float(depth2); 5319 vec2 uv = (vec2(texC, texR) + halfCR) / 5320 vec2(${d}.0, ${h}.0); 5321 return sampleTexture(${r}, uv); 5322 } 5323 `;const x=Vr(r);return e?` 5324 float ${a}(int row, int col, int depth, int depth2) { 5325 // Explicitly use integer operations as dot() only works on floats. 5326 ${m} 5327 ${y} 5328 ${b} 5329 int index = row * stride0 + col * stride1 + 5330 depth * stride2 + depth2; 5331 vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${x}); 5332 return sampleTexture(${r}, uv); 5333 } 5334 `:` 5335 float ${a}(int row, int col, int depth, int depth2) { 5336 // Explicitly use integer operations as dot() only works on floats. 5337 int index = row * ${i} + col * ${o} + 5338 depth * ${s} + depth2; 5339 vec2 uv = uvFromFlat(${h}, ${d}, index + ${x}); 5340 return sampleTexture(${r}, uv); 5341 } 5342 `}function ES(n){const e=n.shapeInfo.logicalShape,t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),a=e[4],s=e[3]*a,o=e[2]*s,i=e[1]*o,{newShape:u,keptDims:l}=rr(e);if(u.length<e.length){const y=Ta(n,u),b=["row","col","depth","depth2","depth3"];return` 5343 ${Sa(y)} 5344 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5345 return ${r}(${Ea(b,l)}); 5346 } 5347 `}if(n.shapeInfo.isUniform)return` 5348 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5349 float index = dot( 5350 vec4(row, col, depth, depth2), 5351 vec4(${i}, ${o}, ${s}, ${a})) + 5352 depth3; 5353 ${ka(n)} 5354 } 5355 `;const c=n.shapeInfo.flatOffset,p=n.shapeInfo.texShape,h=p[0],d=p[1];if(d===i&&c==null)return` 5356 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5357 int texR = row; 5358 float texC = dot(vec4(col, depth, depth2, depth3), 5359 vec4(${o}, ${s}, ${a}, 1)); 5360 vec2 uv = (vec2(texC, texR) + halfCR) / 5361 vec2(${d}.0, ${h}.0); 5362 return sampleTexture(${t}, uv); 5363 } 5364 `;if(d===a&&c==null)return` 5365 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5366 float texR = dot( 5367 vec4(row, col, depth, depth2), 5368 vec4(${e[1]*e[2]*e[3]}, 5369 ${e[2]*e[3]}, ${e[3]}, 1)); 5370 int texC = depth3; 5371 vec2 uv = (vec2(texC, texR) + halfCR) / 5372 vec2(${d}.0, ${h}.0); 5373 return sampleTexture(${t}, uv); 5374 } 5375 `;const m=Vr(t);return` 5376 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5377 // Explicitly use integer operations as dot() only works on floats. 5378 int index = row * ${i} + col * ${o} + depth * ${s} + 5379 depth2 * ${a} + depth3 + ${m}; 5380 vec2 uv = uvFromFlat(${h}, ${d}, index); 5381 return sampleTexture(${t}, uv); 5382 } 5383 `}function CS(n){const e=n.shapeInfo.logicalShape,t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),{newShape:a,keptDims:s}=rr(e);if(a.length<e.length){const b=Ta(n,a),x=["row","col","depth","depth2","depth3","depth4"];return` 5384 ${Sa(b)} 5385 float ${r}(int row, int col, int depth, 5386 int depth2, int depth3, int depth4) { 5387 return ${r}(${Ea(x,s)}); 5388 } 5389 `}const o=e[5],i=e[4]*o,u=e[3]*i,l=e[2]*u,c=e[1]*l;if(n.shapeInfo.isUniform)return` 5390 float ${r}(int row, int col, int depth, 5391 int depth2, int depth3, int depth4) { 5392 int index = round(dot( 5393 vec4(row, col, depth, depth2), 5394 vec4(${c}, ${l}, ${u}, ${i})) + 5395 dot( 5396 vec2(depth3, depth4), 5397 vec2(${o}, 1))); 5398 ${ka(n)} 5399 } 5400 `;const p=n.shapeInfo.flatOffset,h=n.shapeInfo.texShape,d=h[0],m=h[1];if(m===c&&p==null)return` 5401 float ${r}(int row, int col, int depth, 5402 int depth2, int depth3, int depth4) { 5403 int texR = row; 5404 float texC = dot(vec4(col, depth, depth2, depth3), 5405 vec4(${l}, ${u}, ${i}, ${o})) + 5406 float(depth4); 5407 vec2 uv = (vec2(texC, texR) + halfCR) / 5408 vec2(${m}.0, ${d}.0); 5409 return sampleTexture(${t}, uv); 5410 } 5411 `;if(m===o&&p==null)return` 5412 float ${r}(int row, int col, int depth, 5413 int depth2, int depth3, int depth4) {
5414 float texR = dot(vec4(row, col, depth, depth2), 5415 vec4(${e[1]*e[2]*e[3]*e[4]}, 5416 ${e[2]*e[3]*e[4]}, 5417 ${e[3]*e[4]}, 5418 ${e[4]})) + float(depth3); 5419 int texC = depth4; 5420 vec2 uv = (vec2(texC, texR) + halfCR) / 5421 vec2(${m}.0, ${d}.0); 5422 return sampleTexture(${t}, uv); 5423 } 5424 `;const y=Vr(t);return` 5425 float ${r}(int row, int col, int depth, 5426 int depth2, int depth3, int depth4) { 5427 // Explicitly use integer operations as dot() only works on floats. 5428 int index = row * ${c} + col * ${l} + depth * ${u} + 5429 depth2 * ${i} + depth3 * ${o} + depth4 + ${y}; 5430 vec2 uv = uvFromFlat(${d}, ${m}, index); 5431 return sampleTexture(${t}, uv); 5432 } 5433 `}function ka(n){const e=n.name,t=ae(n.shapeInfo.logicalShape);return t<2?`return ${e};`:` 5434 for (int i = 0; i < ${t}; i++) { 5435 if (i == index) { 5436 return ${e}[i]; 5437 } 5438 } 5439 `}function IS(n,e){const t=n.name,r=t.charAt(0).toUpperCase()+t.slice(1),a="get"+r+"AtOutCoords",s=n.shapeInfo.logicalShape.length,o=e.logicalShape.length,i=Q1(n.shapeInfo.logicalShape,e.logicalShape),u=Be(o),l=o-s;let c;const p=["x","y","z","w","u","v"];s===0?c="":o<2&&i.length>=1?c="coords = 0;":c=i.map(b=>`coords.${p[b+l]} = 0;`).join(` 5440`);let h="";o<2&&s>0?h="coords":h=n.shapeInfo.logicalShape.map((b,x)=>`coords.${p[x+l]}`).join(", ");let d="return outputValue;";const m=ae(n.shapeInfo.logicalShape)===1,y=ae(e.logicalShape)===1;if(s===1&&!m&&!y)d=` 5441 return vec4(outputValue.xy, outputValue.xy); 5442 `;else if(m&&!y)o===1?d=` 5443 return vec4(outputValue.x, outputValue.x, 0., 0.); 5444 `:d=` 5445 return vec4(outputValue.x); 5446 `;else if(i.length){const b=s-2,x=s-1;i.indexOf(b)>-1&&i.indexOf(x)>-1?d="return vec4(outputValue.x);":i.indexOf(b)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":i.indexOf(x)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);")}return` 5447 vec4 ${a}() { 5448 ${u} coords = getOutputCoords(); 5449 ${c} 5450 vec4 outputValue = get${r}(${h}); 5451 ${d} 5452 } 5453 `}function NS(n,e){const t=n.name,r=t.charAt(0).toUpperCase()+t.slice(1),a="get"+r+"AtOutCoords",s=e.texShape,o=n.shapeInfo.texShape,i=n.shapeInfo.logicalShape.length,u=e.logicalShape.length;if(!n.shapeInfo.isUniform&&i===u&&n.shapeInfo.flatOffset==null&&qe(o,s))return` 5454 float ${a}() { 5455 return sampleTexture(${t}, resultUV); 5456 } 5457 `;const l=Be(u),c=Q1(n.shapeInfo.logicalShape,e.logicalShape),p=u-i;let h;const d=["x","y","z","w","u","v"];i===0?h="":u<2&&c.length>=1?h="coords = 0;":h=c.map(y=>`coords.${d[y+p]} = 0;`).join(` 5458`);let m="";return u<2&&i>0?m="coords":m=n.shapeInfo.logicalShape.map((y,b)=>`coords.${d[b+p]}`).join(", "),` 5459 float ${a}() { 5460 ${l} coords = getOutputCoords(); 5461 ${h} 5462 return get${r}(${m}); 5463 } 5464 `}function Be(n){if(n<=1)return"int";if(n===2)return"ivec2";if(n===3)return"ivec3";if(n===4)return"ivec4";if(n===5)return"ivec5";if(n===6)return"ivec6";throw Error(`GPU for rank ${n} is not yet supported`)}function ol(n,e,t){const{newShape:r,keptDims:a}=rr(e),s=e.length,o=n&&s===3&&e[0]===1,i=o?e.slice(1):r,u=!n&&s>1&&!qe(e,t)&&r.length<s||o;return{useSqueezeShape:u,uniformShape:u?i:e,keptDims:a}}function Ta(n,e){const t=JSON.parse(JSON.stringify(n));return t.shapeInfo.logicalShape=e,t}function Ea(n,e){return e.map(t=>n[t]).join(", ")}/** 5465 * @license 5466 * Copyright 2017 Google LLC. All Rights Reserved. 5467 * Licensed under the Apache License, Version 2.0 (the "License"); 5468 * you may not use this file except in compliance with the License. 5469 * You may obtain a copy of the License at 5470 * 5471 * http://www.apache.org/licenses/LICENSE-2.0 5472 * 5473 * Unless required by applicable law or agreed to in writing, software 5474 * distributed under the License is distributed on an "AS IS" BASIS, 5475 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5476 * See the License for the specific language governing permissions and 5477 * limitations under the License. 5478 * ============================================================================= 5479 */function $S(n,e,t,r){const a=t.map((c,p)=>{const h={logicalShape:c.shape,texShape:c.isUniform?null:c.texData.texShape,isUniform:c.isUniform,isPacked:c.isUniform?!1:c.texData.isPacked,flatOffset:null};return c.texData!=null&&c.texData.slice!=null&&c.texData.slice.flatOffset>0&&(h.flatOffset=c.texData.slice.flatOffset),{name:e.variableNames[p],shapeInfo:h}}),s=a.map(c=>c.shapeInfo),o={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},i=X6(a,o,e),u=S6(n.gl,i),l=n.createProgram(u);return H().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:u,source:i,webGLProgram:l,inShapeInfos:s,outShapeInfo:o,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexS
5479hapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:e,fragmentShader:u,source:i,webGLProgram:l,inShapeInfos:s,outShapeInfo:o},nm(n,e,l))}function nm(n,e,t){const r={},a={},s={},o=[];let i,u,l,c=null,p=null;p=n.getUniformLocation(t,"NAN",!1),H().getNumber("WEBGL_VERSION")===1&&(c=n.getUniformLocation(t,"INFINITY",!1));const h=!1;for(let d=0;d<e.variableNames.length;d++){const m=e.variableNames[d];r[m]=n.getUniformLocation(t,m,h),r[`offset${m}`]=n.getUniformLocation(t,`offset${m}`,h),e.enableShapeUniforms&&(a[`${m}Shape`]=n.getUniformLocation(t,`${m}Shape`,h),s[`${m}TexShape`]=n.getUniformLocation(t,`${m}TexShape`,h))}return e.enableShapeUniforms&&(i=n.getUniformLocation(t,"outShape",h),l=n.getUniformLocation(t,"outShapeStrides",h),u=n.getUniformLocation(t,"outTexShape",h)),e.customUniforms&&e.customUniforms.forEach((d,m)=>{o[m]=n.getUniformLocation(t,d.name,h)}),{uniformLocations:r,customUniformLocations:o,infLoc:c,nanLoc:p,inShapesLocations:a,inTexShapesLocations:s,outShapeLocation:i,outShapeStridesLocation:l,outTexShapeLocation:u}}function ql(n,e){if(n.length!==e.length)throw Error(`Binary was compiled with ${n.length} inputs, but was executed with ${e.length} inputs`);n.forEach((t,r)=>{const a=t.logicalShape,s=e[r],o=s.shape;if(!qe(a,o))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${a} and ${o} must match`);if(t.isUniform&&s.isUniform)return;const i=t.texShape,u=s.isUniform?null:s.texData.texShape;if(!qe(i,u))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${i} and ${u} must match`)})}function RS(n,e,t,r,a){e.program.enableShapeUniforms||(ql(e.inShapeInfos,t),ql([e.outShapeInfo],[r]));const s=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?n.setOutputPackedMatrixTexture(s.texture,o[0],o[1]):n.setOutputMatrixTexture(s.texture,o[0],o[1]),n.setProgram(e.webGLProgram),H().getNumber("WEBGL_VERSION")===1&&e.infLoc!==null&&n.gl.uniform1f(e.infLoc,1/0),e.nanLoc!==null&&n.gl.uniform1f(e.nanLoc,NaN),t.forEach((u,l)=>{const c=e.program.variableNames[l],p=e.uniformLocations[c],h=e.uniformLocations[`offset${c}`],d=e.inShapesLocations[`${c}Shape`],m=e.inTexShapesLocations[`${c}TexShape`];if(d){const{uniformShape:y}=ol(e.program.packedInputs,u.shape,u.texData.texShape);switch(y.length){case 1:n.gl.uniform1iv(d,new Int32Array(y));break;case 2:n.gl.uniform2iv(d,new Int32Array(y));break;case 3:n.gl.uniform3iv(d,new Int32Array(y));break;case 4:n.gl.uniform4iv(d,new Int32Array(y));break}}if(m&&n.gl.uniform2i(m,u.texData.texShape[0],u.texData.texShape[1]),p!=null){if(u.isUniform){if(ae(u.shape)<2)n.gl.uniform1f(p,u.uniformValues[0]);else{let y=u.uniformValues;y instanceof Float32Array||(y=new Float32Array(y)),n.gl.uniform1fv(p,y)}return}u.texData.slice!=null&&h!=null&&n.gl.uniform1i(h,u.texData.slice.flatOffset),n.setInputMatrixTexture(u.texData.texture.texture,p,l)}});const i=e.outShapeLocation;if(i)switch(r.shape.length){case 1:n.gl.uniform1iv(i,new Int32Array(r.shape));break;case 2:n.gl.uniform2iv(i,new Int32Array(r.shape));break;case 3:n.gl.uniform3iv(i,new Int32Array(r.shape));break;case 4:n.gl.uniform4iv(i,new Int32Array(r.shape));break}if(e.outShapeStridesLocation){const u=ot(r.shape);switch(r.shape.length){case 2:n.gl.uniform1iv(e.outShapeStridesLocation,new Int32Array(u));break;case 3:n.gl.uniform2iv(e.outShapeStridesLocation,new Int32Array(u));break;case 4:n.gl.uniform3iv(e.outShapeStridesLocation,new Int32Array(u));break}}e.outTexShapeLocation&&n.gl.uniform2i(e.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),e.program.customUniforms&&a&&e.program.customUniforms.forEac
vendor: 4,320 bytes, lines 5479-5535
5479h((u,l)=>{const c=e.customUniformLocations[l],p=a[l];if(u.type==="float")n.gl.uniform1fv(c,p);else if(u.type==="vec2")n.gl.uniform2fv(c,p);else if(u.type==="vec3")n.gl.uniform3fv(c,p);else if(u.type==="vec4")n.gl.uniform4fv(c,p);else if(u.type==="int")n.gl.uniform1iv(c,p);else if(u.type==="ivec2")n.gl.uniform2iv(c,p);else if(u.type==="ivec3")n.gl.uniform3iv(c,p);else if(u.type==="ivec4")n.gl.uniform4iv(c,p);else throw Error(`uniform type ${u.type} is not supported yet.`)}),n.executeProgram()}function _S(n,e,t){let r="";e.concat(t).forEach(o=>{const i=o.texData!=null&&o.texData.slice!=null&&o.texData.slice.flatOffset>0;if(n.enableShapeUniforms&&!o.isUniform){const u=o.texData.texShape,{useSqueezeShape:l,uniformShape:c,keptDims:p}=ol(n.packedInputs,o.shape,u);let h="",d="",m="";if(c.length===1&&n.packedInputs){const M=[Math.ceil(u[0]/2),Math.ceil(u[1]/2)];h=`${M[0]>1}_${M[1]>1}`}else if(c.length===2&&!n.packedInputs)d=`${c[0]>1}_${c[1]>1}`;else if(c.length>2&&!n.packedInputs){const M=ot(c);m=`${M[0]===u[1]}_${M[M.length-1]===u[1]}`}const y=o.shape.length,b=c.length===2&&qe(o.shape,u),x=ae(o.shape)===1,T=ao(o.shape,t.shape),$=!n.packedInputs&&y===t.shape.length&&qe(u,t.texData.texShape),F=n.packedInputs||c.length>2?"":`${u[0]>1}_${u[1]>1}`;r+=`${y}_${$}_${l?p:""}_${c.length}_${x}_${T}_${b}_${h}_${d}_${m}_${F}_${i}`}else{const u=o.isUniform?"uniform":o.texData.texShape;r+=`${o.shape}_${u}_${i}`}});const a=n.userCode;let s=n.constructor.name;return s+="_"+r+"_"+a+`${H().getNumber("WEBGL_VERSION")}`,s}function bt(n){return H().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&n<=4}/** 5480 * @license 5481 * Copyright 2019 Google LLC. All Rights Reserved. 5482 * Licensed under the Apache License, Version 2.0 (the "License"); 5483 * you may not use this file except in compliance with the License. 5484 * You may obtain a copy of the License at 5485 * 5486 * http://www.apache.org/licenses/LICENSE-2.0 5487 * 5488 * Unless required by applicable law or agreed to in writing, software 5489 * distributed under the License is distributed on an "AS IS" BASIS, 5490 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5491 * See the License for the specific language governing permissions and 5492 * limitations under the License. 5493 * ============================================================================= 5494 */class AS{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=us.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=xt();this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length),this.userCode=` 5495 ivec3 outCoordsFromFlatIndex(int index) { 5496 ${this.enableShapeUniforms?Mo(["r","c","d"],e):Ur(["r","c","d"],e)} 5497 return ivec3(r, c, d); 5498 } 5499 5500 void main() { 5501 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 5502 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 5503 5504 vec4 result = vec4(0.); 5505 5506 for (int i=0; i<4; i++) { 5507 int flatIndex = index + i; 5508 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 5509 result[i] = getA(rc.x, rc.y, rc.z); 5510 } 5511 5512 ${t.output} = result; 5513 } 5514 `}}/** 5515 * @license 5516 * Copyright 2019 Google LLC. All Rights Reserved. 5517 * Licensed under the Apache License, Version 2.0 (the "License"); 5518 * you may not use this file except in compliance with the License. 5519 * You may obtain a copy of the License at 5520 * 5521 * http://www.apache.org/licenses/LICENSE-2.0 5522 * 5523 * Unless required by applicable law or agreed to in writing, software 5524 * distributed under the License is distributed on an "AS IS" BASIS, 5525 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5526 * See the License for the specific language governing permissions and 5527 * limitations under the License. 5528 * ============================================================================= 5529 */class OS{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=us.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=xt();this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length),this.userCode=` 5530 ivec3 outCoordsFromFlatIndex(int index) { 5531 ${this.enableShapeUniforms?Mo(["r","c","d"],e):Ur(["r","c","d"],e)} 5532 return ivec3(r, c, d); 5533 } 5534 5535 void main() {
5536 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 5537 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 5538 5539 vec4 result = vec4(0.); 5540 5541 for (int i=0; i<4; i++) { 5542 int flatIndex = index + i; 5543 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 5544 result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z)); 5545 } 5546 5547 ${t.output} = result; 5548 } 5549 `}}/** 5550 * @license 5551 * Copyright 2018 Google LLC. All Rights Reserved. 5552 * Licensed under the Apache License, Version 2.0 (the "License"); 5553 * you may not use this file except in compliance with the License. 5554 * You may obtain a copy of the License at 5555 * 5556 * http://www.apache.org/licenses/LICENSE-2.0 5557 * 5558 * Unless required by applicable law or agreed to in writing, software 5559 * distributed under the License is distributed on an "AS IS" BASIS, 5560 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5561 * See the License for the specific language governing permissions and 5562 * limitations under the License. 5563 * ============================================================================= 5564 */class FS{constructor(e){this.variableNames=["A"],this.outTexUsage=Mt.DOWNLOAD;const t=xt();this.outputShape=e,this.userCode=` 5565 ${J1} 5566 5567 void main() { 5568 float x = getAAtOutCoords(); 5569 ${t.output} = encode_float(x); 5570 } 5571 `}}/** 5572 * @license 5573 * Copyright 2018 Google LLC. All Rights Reserved. 5574 * Licensed under the Apache License, Version 2.0 (the "License"); 5575 * you may not use this file except in compliance with the License. 5576 * You may obtain a copy of the License at 5577 * 5578 * http://www.apache.org/licenses/LICENSE-2.0 5579 * 5580 * Unless required by applicable law or agreed to in writing, software 5581 * distributed under the License is distributed on an "AS IS" BASIS, 5582 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5583 * See the License for the specific language governing permissions and 5584 * limitations under the License. 5585 * ============================================================================= 5586 */class DS{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Mt.DOWNLOAD;const t=xt();this.outputShape=e,this.userCode=` 5587 ${J1} 5588 5589 void main() { 5590 ivec3 coords = getOutputCoords(); 5591 float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z)); 5592 ${t.output} = encode_float(x); 5593 } 5594 `}}/** 5595 * @license 5596 * Copyright 2018 Google LLC. All Rights Reserved. 5597 * Licensed under the Apache License, Version 2.0 (the "License"); 5598 * you may not use this file except in compliance with the License. 5599 * You may obtain a copy of the License at 5600 * 5601 * http://www.apache.org/licenses/LICENSE-2.0 5602 * 5603 * Unless required by applicable law or agreed to in writing, software 5604 * distributed under the License is distributed on an "AS IS" BASIS, 5605 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5606 * See the License for the specific language governing permissions and 5607 * limitations under the License. 5608 * ============================================================================= 5609 */class MS{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=xt();this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length);let a="result";t&&(a="floor(result * 255. + 0.5)"),this.userCode=` 5610 ${this.enableShapeUniforms?sl():al(e)} 5611 5612 void main() { 5613 ivec3 coords = getOutputCoords(); 5614 5615 int flatIndex = getFlatIndex(coords); 5616 int offset = imod(flatIndex, 4); 5617 5618 flatIndex = idiv(flatIndex, 4, 1.); 5619 5620 int r = flatIndex / texShape[1]; 5621 int c = imod(flatIndex, texShape[1]); 5622 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 5623 vec4 values = ${r.texture2D}(A, uv); 5624 5625 float result; 5626 5627 if(offset == 0) { 5628 result = values[0]; 5629 } else if(offset == 1) { 5630 result = values[1]; 5631 } else if(offset == 2) { 5632 result = values[2]; 5633 } else { 5634 result = values[3]; 5635 } 5636 5637 ${r.output} = vec4(${a}, 0., 0., 0.); 5638 } 5639 `}}/** 5640 * @license 5641 * Copyright 2018 Google LLC. All Rights Reserved. 5642 * Licensed under the Apache License, Version 2.0 (the "License");
5643 * you may not use this file except in compliance with the License. 5644 * You may obtain a copy of the License at 5645 * 5646 * http://www.apache.org/licenses/LICENSE-2.0 5647 * 5648 * Unless required by applicable law or agreed to in writing, software 5649 * distributed under the License is distributed on an "AS IS" BASIS, 5650 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5651 * See the License for the specific language governing permissions and 5652 * limitations under the License. 5653 * ============================================================================= 5654 */class LS{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=xt();this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length);let a="",s="result";t&&(s="floor(result * 255. + 0.5)");for(let o=0;o<=1;o++)for(let i=0;i<=1;i++){const u=o*2+i;a+=` 5655 localCoords = coords; 5656 if(localCoords[2] + ${i} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) { 5657 localCoords[2] += ${i}; 5658 if (localCoords[1] + ${o} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) { 5659 localCoords[1] += ${o}; 5660 5661 flatIndex = getFlatIndex(localCoords); 5662 offset = imod(flatIndex, 4); 5663 5664 flatIndex = idiv(flatIndex, 4, 1.); 5665 5666 int r = flatIndex / texShape[1]; 5667 int c = imod(flatIndex, texShape[1]); 5668 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 5669 values = ${r.texture2D}(A, uv); 5670 5671 if (offset == 0) { 5672 result[${u}] = values[0]; 5673 } else if (offset == 1) { 5674 result[${u}] = values[1]; 5675 } else if (offset == 2) { 5676 result[${u}] = values[2]; 5677 } else { 5678 result[${u}] = values[3]; 5679 } 5680 } 5681 } 5682 `}this.userCode=` 5683 ${this.enableShapeUniforms?sl():al(e)} 5684 5685 void main() { 5686 ivec3 coords = getOutputCoords(); 5687 5688 vec4 result = vec4(0.); 5689 int flatIndex, r, c, offset; 5690 ivec3 localCoords; 5691 vec2 uv; 5692 vec4 values; 5693 5694 ${a} 5695 5696 ${r.output} = ${s}; 5697 } 5698 `}}/** 5699 * @license 5700 * Copyright 2017 Google LLC. All Rights Reserved. 5701 * Licensed under the Apache License, Version 2.0 (the "License"); 5702 * you may not use this file except in compliance with the License. 5703 * You may obtain a copy of the License at 5704 * 5705 * http://www.apache.org/licenses/LICENSE-2.0 5706 * 5707 * Unless required by applicable law or agreed to in writing, software 5708 * distributed under the License is distributed on an "AS IS" BASIS, 5709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5710 * See the License for the specific language governing permissions and 5711 * limitations under the License. 5712 * ============================================================================= 5713 */function PS(n){const e=xt(),t=`${e.version} 5714 precision highp float; 5715 ${e.attribute} vec3 clipSpacePos; 5716 ${e.attribute} vec2 uv; 5717 ${e.varyingVs} vec2 resultUV; 5718 5719 void main() { 5720 gl_Position = vec4(clipSpacePos, 1); 5721 resultUV = uv; 5722 }`;return w6(n,t)}function BS(n){const e=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return C6(n,e)}function US(n){const e=new Uint16Array([0,1,2,2,1,3]);return I6(n,e)}function xs(n,e,t,r,a,s){$6(e,t);const o=N6(n),i=n.TEXTURE_2D;return ce(n,()=>n.bindTexture(i,o)),ce(n,()=>n.texParameteri(i,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE)),ce(n,()=>n.texParameteri(i,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),ce(n,()=>n.texParameteri(i,n.TEXTURE_MIN_FILTER,n.NEAREST)),ce(n,()=>n.texParameteri(i,n.TEXTURE_MAG_FILTER,n.NEAREST)),H().getNumber("WEBGL_VERSION")===1?ce(n,()=>n.texImage2D(i,0,r,e,t,0,a,s,null)):ce(n,()=>n.texStorage2D(i,1,r,e,t)),ce(n,()=>n.bindTexture(n.TEXTURE_2D,null)),{texture:o,texShape:[t,e]}}function rm(n){return n.internalFormatFloat}function VS(n,e,t,r){const[a,s]=gs(e,t);return xs(n,a,s,rm(r),r.textureFormatFloat,n.FLOAT)}function am(n){return n.internalFormatHalfFloat}function WS(n,e,t,r){const[a,s]=gs(e,t);return xs(n,a,s,am(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function sm(n){return n.downloadTextureFormat}function zS(n,e,t,r){const[a,s]=gs(e,t);return xs(n,a,s,sm(r),n.RGBA,n.UNSIGNED_BYTE)}function om(n){return n.internalFormatPackedFloat}function GS(n,e,t,r){const[a,s]=wa(e,t);return xs(n,a,s,om(r),n.RGBA,n.FLOAT)}function im(n){return n.internalFormatPackedHalfFloat}function jS(n,e,t,r){const[a,s]=wa(e,t);return xs(n,a,s,im(r),n.RGBA,r.textureTypeHalfFloat)}function HS(n,e,t){return ce(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),jl(n,e,"clipSpacePos",t,3,20,0)&&jl(n,e,"uv",t,2,20,12)}function XS(n,e,t,r,a,s){ce(n,()=>n.bindTexture(n.TEXTURE_2D,e));let o,i,u;
vendor: 11,902 bytes, lines 5722-5740
5722a instanceof Uint8Array?(o=new Uint8Array(t*r*4),i=n.UNSIGNED_BYTE,u=n.RGBA):(o=new Float32Array(t*r*4),i=n.FLOAT,u=s.internalFormatPackedFloat),o.set(a),H().getNumber("WEBGL_VERSION")===2?ce(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t,r,n.RGBA,i,o)):ce(n,()=>n.texImage2D(n.TEXTURE_2D,0,u,t,r,0,n.RGBA,i,o)),ce(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function qS(n,e,t){ce(n,()=>n.bindTexture(n.TEXTURE_2D,e)),t.data instanceof Uint8Array?H().getNumber("WEBGL_VERSION")===2?ce(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,t.data)):ce(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t.width,t.height,0,n.RGBA,n.UNSIGNED_BYTE,t.data)):H().getNumber("WEBGL_VERSION")===2?ce(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,t)):ce(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)),ce(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function KS(n,e,t,r){const a=n.createBuffer();ce(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,a));const s=16*e*t;return ce(n,()=>n.bufferData(n.PIXEL_PACK_BUFFER,s,n.STREAM_READ)),ce(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,0)),ce(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,null)),a}function YS(n,e,t){const r=n,a=new Float32Array(t);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}function ZS(n,e,t,r){const[a,s]=gs(e,t),o=4,i=new Uint8Array(f6(e*t,o));return ce(n,()=>n.readPixels(0,0,a,s,r.downloadTextureFormat,n.UNSIGNED_BYTE,i)),new Float32Array(i.buffer)}function JS(n,e,t,r,a,s,o,i){const u=n,l=new Float32Array(m6(s,o));return u.bindBuffer(u.PIXEL_PACK_BUFFER,e),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}function QS(n,e,t){const r=new Float32Array(e*t*4);return ce(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,r)),r}/** 5723 * @license 5724 * Copyright 2017 Google LLC. All Rights Reserved. 5725 * Licensed under the Apache License, Version 2.0 (the "License"); 5726 * you may not use this file except in compliance with the License. 5727 * You may obtain a copy of the License at 5728 * 5729 * http://www.apache.org/licenses/LICENSE-2.0 5730 * 5731 * Unless required by applicable law or agreed to in writing, software 5732 * distributed under the License is distributed on an "AS IS" BASIS, 5733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5734 * See the License for the specific language governing permissions and 5735 * limitations under the License. 5736 * ============================================================================= 5737 */class hi{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=H().getNumber("WEBGL_VERSION");e!=null?(this.gl=e,p6(t,e)):this.gl=pn(t);let r="WEBGL_color_buffer_float";const a="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),H().getNumber("WEBGL_VERSION")===1){const s="OES_texture_float",o="OES_texture_half_float";if(this.textureFloatExtension=js(this.gl,s),Zt(this.gl,o))this.textureHalfFloatExtension=js(this.gl,o);else if(H().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(r),Zt(this.gl,a))this.colorBufferHalfFloatExtension=js(this.gl,a);else if(H().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(r="EXT_color_buffer_float",Zt(this.gl,r))this.colorBufferFloatExtension=this.gl.getExtension(r);else if(Zt(this.gl,a))this.colorBufferHalfFloatExtension=this.gl.getExtension(a);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=BS(this.gl),this.indexBuffer=US(this.gl),this.framebuffer=R6(this.gl),this.textureConfig=rl(this.gl,this.textureHalfFloatExtension)}get debug(){return H().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program!=null&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),this.outputTexture!=null&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;ce(e,()=>e.finish()),ce(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),ce(e,()=>e.deleteFramebuffer(this.framebuffer)),ce(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),ce(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),ce(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),VS(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),WS(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),zS(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),qS(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,r,a){this.throwIfDisposed(),XS(this.gl,e,t,r,a,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),jS(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),GS(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(Hl(this.gl,this.framebuffer),this.outputTexture=null),ce(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,r){return this.downloadMatrixDriver(e,()=>ZS(this.gl,t,r,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,r,a,s,o){return JS(this.gl,e,t,r,a,s,o,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return YS(this.gl,e,t)}createBufferFromTexture(e,t,r){this.bindTextureToFrameBuffer(e);const a=KS(this.gl,t,r,this.textureConfig);return this.unbindTextureToFrameBuffer(),a}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,r;if(H().getBool("WEBGL_FENCE_API_ENABLED")){const a=e,s=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),r=()=>{const o=a.clientWaitSync(s,0,0);return o===a.ALREADY_SIGNALED||o===a.CONDITION_SATISFIED},t=s}else H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),r=()=>this.isQueryAvailable(t,H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):r=()=>!0;return{query:t,isFencePassed:r}}downloadMatrixFromPackedTexture(e,t,r){return this.downloadMatrixDriver(e,()=>QS(this.gl,t,r))}createProgram(e){this.throwIfDisposed();const t=this.gl;this.vertexShader==null&&(this.vertexShader=PS(t));const r=T6(t);return ce(t,()=>t.attachShader(r,this.vertexShader)),ce(t,()=>t.attachShader(r,e)),E6(t,r),this.debug&&ii(t,r),this.vertexAttrsAreBound||(this.setProgram(r),this.vertexAttrsAreBound=HS(t,this.program,this.vertexBuffer)),r}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&ce(this.gl,()=>this.gl.deleteProgram(e))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&ii(this.gl,this.program),ce(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,r=!0){return this.throwIfDisposed(),r?A6(this.gl,e,t):O6(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),ce(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,r){this.throwIfDisposed(),this.throwIfNoProgram(),F6(this.gl,e,t,r)}setOutputMatrixTexture(e,t,r){this.setOutputMatrixTextureDriver(e,r,t)}setOutputPackedMatrixTexture(e,t,r){this.throwIfDisposed();const[a,s]=wa(t,r);this.setOutputMatrixTextureDriver(e,a,s)}setOutputMatrixWriteRegion(e,t,r,a){this.setOutputMatrixWriteRegionDriver(r,e,a,t)}setOutputPackedMatrixWriteRegion(e,t,r,a){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&ii(this.gl,this.program),Hs(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),ce(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),ce(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=js(this.gl,H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const r=this.gl,a=this.getQueryTimerExtensionWebGL2(),s=r.createQuery();return r.beginQuery(a.TIME_ELAPSED_EXT,s),s}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const t=this.gl,r=this.getQueryTimerExtensionWebGL2();t.endQuery(r.TIME_ELAPSED_EXT);return}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await yl(()=>this.disposed||this.isQueryAvailable(e,H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(t===0)return null;if(t===2){const r=this.gl;return r.getQueryParameter(e,r.QUERY_RESULT)/1e6}else{const r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(t===0)return!0;if(t===2){const r=this.gl,a=this.getQueryTimerExtensionWebGL2(),s=r.getQueryParameter(e,r.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(a.GPU_DISJOINT_EXT)),s&&!this.disjoint}else{const r=this.getQueryTimerExtensionWebGL1(),a=r.getQueryObjectEXT(e,r.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),a&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){const e=e5(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=e;++t){const{resolveFn:r}=this.itemsToPoll[t];r()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let r;"setTimeoutCustom"in H().platform&&(r=H().platform.setTimeoutCustom.bind(H().platform)),yl(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,r)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),ui(this.gl,e,this.framebuffer),this.debug&&Hs(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(ui(this.gl,this.outputTexture,this.framebuffer),this.debug&&Hs(this.gl)):Hl(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const r=t();return this.unbindTextureToFrameBuffer(),r}setOutputMatrixTextureDriver(e,t,r){this.throwIfDisposed();const a=this.gl;ui(a,e,this.framebuffer),this.debug&&Hs(a),this.outputTexture=e,ce(a,()=>a.viewport(0,0,t,r)),ce(a,()=>a.scissor(0,0,t,r))}setOutputMatrixWriteRegionDriver(e,t,r,a){this.throwIfDisposed(),ce(this.gl,()=>this.gl.scissor(e,t,r,a))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}}function e5(n){let e=0;for(;e<n.length&&n[e]();++e);return e-1}/** 5738 * @license 5739 * Copyright 2020 Google LLC. All Rights Reserved. 5740 * Licensed under the Apache License, Version 2.0 (the License);
5741 * you may not use this file except in compliance with the License. 5742 * You may obtain a copy of the License at 5743 * 5744 * http://www.apache.org/licenses/LICENSE-2.0 5745 * 5746 * Unless required by applicable law or agreed to in writing, software 5747 * distributed under the License is distributed on an AS IS BASIS, 5748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5749 * See the License for the specific language governing permissions and 5750 * limitations under the License. 5751 * ============================================================================= 5752 */function t5(n){const e=new Float32Array(n.length);for(let t=0;t<n.length;++t)e[t]=Math.abs(n[t]);return e}/** 5753 * @license 5754 * Copyright 2020 Google LLC. All Rights Reserved. 5755 * Licensed under the Apache License, Version 2.0 (the "License"); 5756 * you may not use this file except in compliance with the License. 5757 * You may obtain a copy of the License at 5758 * 5759 * http://www.apache.org/licenses/LICENSE-2.0 5760 * 5761 * Unless required by applicable law or agreed to in writing, software 5762 * distributed under the License is distributed on an "AS IS" BASIS, 5763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5764 * See the License for the specific language governing permissions and 5765 * limitations under the License. 5766 * ============================================================================= 5767 */function Ut(n){return(e,t,r,a,s)=>{const o=$e(e,t),i=o.length,u=ot(o),l=ae(o),c=On(s,l),p=e.length,h=t.length,d=ot(e),m=ot(t),y=ao(e,o),b=ao(t,o);if(y.length+b.length===0)for(let x=0;x<c.length;++x)c[x]=n(r[x%r.length],a[x%a.length]);else for(let x=0;x<c.length;++x){const T=Tu(x,i,u),$=T.slice(-p);y.forEach(X=>$[X]=0);const F=$i($,p,d),M=T.slice(-h);b.forEach(X=>M[X]=0);const U=$i(M,h,m);c[x]=n(r[F],a[U])}return[c,o]}}/** 5768 * @license 5769 * Copyright 2020 Google LLC. All Rights Reserved. 5770 * Licensed under the Apache License, Version 2.0 (the "License"); 5771 * you may not use this file except in compliance with the License. 5772 * You may obtain a copy of the License at 5773 * 5774 * http://www.apache.org/licenses/LICENSE-2.0 5775 * 5776 * Unless required by applicable law or agreed to in writing, software 5777 * distributed under the License is distributed on an "AS IS" BASIS, 5778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5779 * See the License for the specific language governing permissions and 5780 * limitations under the License. 5781 * ============================================================================= 5782 */function n5(n,e,t,r){if(r==="int32"){const a=Int32Array.from(n);return[e,"int32",a]}if(r==="bool"){const a=So([0],t),[s,o]=Ut((i,u)=>i!==u?1:0)(e,[],n,a,"bool");return[o,"bool",s]}throw new Error(`Error in Cast: failed to cast ${t} to ${r}`)}/** 5783 * @license 5784 * Copyright 2020 Google LLC. All Rights Reserved. 5785 * Licensed under the Apache License, Version 2.0 (the "License"); 5786 * you may not use this file except in compliance with the License. 5787 * You may obtain a copy of the License at 5788 * 5789 * http://www.apache.org/licenses/LICENSE-2.0 5790 * 5791 * Unless required by applicable law or agreed to in writing, software 5792 * distributed under the License is distributed on an "AS IS" BASIS, 5793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5794 * See the License for the specific language governing permissions and 5795 * limitations under the License. 5796 * ============================================================================= 5797 */const r5=Ut(((n,e)=>n+e));/** 5798 * @license 5799 * Copyright 2020 Google LLC. All Rights Reserved. 5800 * Licensed under the Apache License, Version 2.0 (the "License"); 5801 * you may not use this file except in compliance with the License. 5802 * You may obtain a copy of the License at 5803 * 5804 * http://www.apache.org/licenses/LICENSE-2.0 5805 * 5806 * Unless required by applicable law or agreed to in writing, software 5807 * distributed under the License is distributed on an "AS IS" BASIS, 5808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5809 * See the License for the specific language governing permissions and 5810 * limitations under the License. 5811 * ============================================================================= 5812 */function a5(n,e,t,r,a){const s=ae(r),o=er(a,t);for(let i=0;i<n.length;i++){const u=n[i];if(u<0)throw new Error("Input x must be non-negative!");u>=a||(s>0?o[u]+=e[i]:o[u]+=1)}return o}function s5(n,e,t,r=!1){const a=n.shape[0],s=n.shape[1],o=He([a,t],e.dtype);for(let i=0;i<a;i++)for(let u=0;u<s;u++){const l=n.get(i,u);if(l<0)throw new Error("Input x must be non-negative!");l>=t||(r?o.set(1,i,l):e.size>0?o.set(o.get(i,l)+e.get(i,u),i,l):o.set(o.get(i,l)+1,i,l))}return o}/** 5813 * @license 5814 * Copyright 2020 Google LLC. All Rights Reserved. 5815 * Licensed under the Apache License, Version 2.0 (the "License");
5816 * you may not use this file except in compliance with the License. 5817 * You may obtain a copy of the License at 5818 * 5819 * http://www.apache.org/licenses/LICENSE-2.0 5820 * 5821 * Unless required by applicable law or agreed to in writing, software 5822 * distributed under the License is distributed on an "AS IS" BASIS, 5823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5824 * See the License for the specific language governing permissions and 5825 * limitations under the License. 5826 * ============================================================================= 5827 */function or(n){return(e,t,r)=>{const a=On(t,e.length);for(let s=0;s<e.length;++s)a[s]=n(e[s],r);return a}}/** 5828 * @license 5829 * Copyright 2020 Google LLC. All Rights Reserved. 5830 * Licensed under the Apache License, Version 2.0 (the License); 5831 * you may not use this file except in compliance with the License. 5832 * You may obtain a copy of the License at 5833 * 5834 * http://www.apache.org/licenses/LICENSE-2.0 5835 * 5836 * Unless required by applicable law or agreed to in writing, software 5837 * distributed under the License is distributed on an AS IS BASIS, 5838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5839 * See the License for the specific language governing permissions and 5840 * limitations under the License. 5841 * ============================================================================= 5842 */const o5=or(n=>Math.ceil(n));/** 5843 * @license 5844 * Copyright 2020 Google LLC. All Rights Reserved. 5845 * Licensed under the Apache License, Version 2.0 (the "License"); 5846 * you may not use this file except in compliance with the License. 5847 * You may obtain a copy of the License at 5848 * 5849 * http://www.apache.org/licenses/LICENSE-2.0 5850 * 5851 * Unless required by applicable law or agreed to in writing, software 5852 * distributed under the License is distributed on an "AS IS" BASIS, 5853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5854 * See the License for the specific language governing permissions and 5855 * limitations under the License. 5856 * ============================================================================= 5857 */function i5(n,e,t,r){const a=kt(t,ae(e));if(r&&t!=="string"){let s=0;n.forEach(o=>{const i=ae(o.shape);a.set(o.vals,s),s+=i})}else{let s=0;n.forEach(o=>{const i=t==="string"?is(o.vals):o.vals;let u=0;for(let l=0;l<o.shape[0];++l){const c=l*e[1]+s;for(let p=0;p<o.shape[1];++p)a[c+p]=i[u++]}s+=o.shape[1]})}return a}/** 5858 * @license 5859 * Copyright 2020 Google LLC. All Rights Reserved. 5860 * Licensed under the Apache License, Version 2.0 (the "License"); 5861 * you may not use this file except in compliance with the License. 5862 * You may obtain a copy of the License at 5863 * 5864 * http://www.apache.org/licenses/LICENSE-2.0 5865 * 5866 * Unless required by applicable law or agreed to in writing, software 5867 * distributed under the License is distributed on an "AS IS" BASIS, 5868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5869 * See the License for the specific language governing permissions and 5870 * limitations under the License. 5871 * ============================================================================= 5872 */const u5=Ut((n,e)=>n===e?1:0);/** 5873 * @license 5874 * Copyright 2020 Google LLC. All Rights Reserved. 5875 * Licensed under the Apache License, Version 2.0 (the License); 5876 * you may not use this file except in compliance with the License. 5877 * You may obtain a copy of the License at 5878 * 5879 * http://www.apache.org/licenses/LICENSE-2.0 5880 * 5881 * Unless required by applicable law or agreed to in writing, software 5882 * distributed under the License is distributed on an AS IS BASIS, 5883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5884 * See the License for the specific language governing permissions and 5885 * limitations under the License. 5886 * ============================================================================= 5887 */const l5=or(n=>Math.exp(n));/** 5888 * @license 5889 * Copyright 2020 Google LLC. All Rights Reserved. 5890 * Licensed under the Apache License, Version 2.0 (the License); 5891 * you may not use this file except in compliance with the License. 5892 * You may obtain a copy of the License at 5893 * 5894 * http://www.apache.org/licenses/LICENSE-2.0 5895 * 5896 * Unless required by applicable law or agreed to in writing, softw
5896are 5897 * distributed under the License is distributed on an AS IS BASIS, 5898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5899 * See the License for the specific language governing permissions and 5900 * limitations under the License. 5901 * ============================================================================= 5902 */const c5=or(n=>Math.expm1(n));/** 5903 * @license 5904 * Copyright 2020 Google LLC. All Rights Reserved. 5905 * Licensed under the Apache License, Version 2.0 (the License); 5906 * you may not use this file except in compliance with the License. 5907 * You may obtain a copy of the License at 5908 * 5909 * http://www.apache.org/licenses/LICENSE-2.0 5910 * 5911 * Unless required by applicable law or agreed to in writing, software 5912 * distributed under the License is distributed on an AS IS BASIS, 5913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5914 * See the License for the specific language governing permissions and 5915 * limitations under the License. 5916 * ============================================================================= 5917 */const p5=or(n=>Math.floor(n));/** 5918 * @license 5919 * Copyright 2021 Google LLC. All Rights Reserved. 5920 * Licensed under the Apache License, Version 2.0 (the "License"); 5921 * you may not use this file except in compliance with the License. 5922 * You may obtain a copy of the License at 5923 * 5924 * http://www.apache.org/licenses/LICENSE-2.0 5925 * 5926 * Unless required by applicable law or agreed to in writing, software 5927 * distributed under the License is distributed on an "AS IS" BASIS, 5928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5929 * See the License for the specific language governing permissions and 5930 * limitations under the License. 5931 * ============================================================================= 5932 */function h5(n,e,t,r,a,s,o,i,u){const l=He([r,s],t);for(let c=0;c<r;c++){const p=[];let h=0;for(let d=0;d<a;d++){const m=n[c*a+d];h+=m*o[d],p.push(m)}if(h<0||h>=u/s)throw new Error(`Invalid indices: ${p} does not index into ${i}`);for(let d=0;d<s;d++)l.values[c*s+d]=e.get(...e.indexToLoc(h*s+d))}return l}/** 5933 * @license 5934 * Copyright 2020 Google LLC. All Rights Reserved. 5935 * Licensed under the Apache License, Version 2.0 (the "License"); 5936 * you may not use this file except in compliance with the License. 5937 * You may obtain a copy of the License at 5938 * 5939 * http://www.apache.org/licenses/LICENSE-2.0 5940 * 5941 * Unless required by applicable law or agreed to in writing, software 5942 * distributed under the License is distributed on an "AS IS" BASIS, 5943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5944 * See the License for the specific language governing permissions and 5945 * limitations under the License. 5946 * ============================================================================= 5947 */function d5(n,e,t){const r=He(t,n.dtype);for(let a=0;a<r.size;++a){const s=r.indexToLoc(a).slice(),o=s[0],i=s[2],u=e.locToIndex([o,i]);s[2]=e.values[u];const l=n.locToIndex(s);0<=l&&l<n.values.length&&(r.values[a]=n.values[l])}return r}/** 5948 * @license 5949 * Copyright 2020 Google LLC. All Rights Reserved. 5950 * Licensed under the Apache License, Version 2.0 (the "License"); 5951 * you may not use this file except in compliance with the License. 5952 * You may obtain a copy of the License at 5953 * 5954 * http://www.apache.org/licenses/LICENSE-2.0 5955 * 5956 * Unless required by applicable law or agreed to in writing, software 5957 * distributed under the License is distributed on an "AS IS" BASIS, 5958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5959 * See the License for the specific language governing permissions and 5960 * limitations under the License. 5961 * ============================================================================= 5962 */const f5=Ut((n,e)=>n>e?1:0);/** 5963 * @license 5964 * Copyright 2020 Google LLC. All Rights Reserved. 5965 * Licensed under the Apache License, Version 2.0 (the "License"); 5966 * you may not use this file except in compliance with the License. 5967 * You may obtain a copy of the License at 5968 * 5969 * http://www.apache.org/licenses/LICENSE-2.0 5970 * 5971 * Unless required by applicable law or agreed to in writing, softw
5971are 5972 * distributed under the License is distributed on an "AS IS" BASIS, 5973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5974 * See the License for the specific language governing permissions and 5975 * limitations under the License. 5976 * ============================================================================= 5977 */const m5=Ut((n,e)=>n>=e?1:0);/** 5978 * @license 5979 * Copyright 2020 Google LLC. All Rights Reserved. 5980 * Licensed under the Apache License, Version 2.0 (the "License"); 5981 * you may not use this file except in compliance with the License. 5982 * You may obtain a copy of the License at 5983 * 5984 * http://www.apache.org/licenses/LICENSE-2.0 5985 * 5986 * Unless required by applicable law or agreed to in writing, software 5987 * distributed under the License is distributed on an "AS IS" BASIS, 5988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5989 * See the License for the specific language governing permissions and 5990 * limitations under the License. 5991 * ============================================================================= 5992 */const g5=Ut((n,e)=>n<e?1:0);/** 5993 * @license 5994 * Copyright 2020 Google LLC. All Rights Reserved. 5995 * Licensed under the Apache License, Version 2.0 (the "License"); 5996 * you may not use this file except in compliance with the License. 5997 * You may obtain a copy of the License at 5998 * 5999 * http://www.apache.org/licenses/LICENSE-2.0 6000 * 6001 * Unless required by applicable law or agreed to in writing, software 6002 * distributed under the License is distributed on an "AS IS" BASIS, 6003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6004 * See the License for the specific language governing permissions and 6005 * limitations under the License. 6006 * ============================================================================= 6007 */const y5=Ut((n,e)=>n<=e?1:0);/** 6008 * @license 6009 * Copyright 2020 Google LLC. All Rights Reserved. 6010 * Licensed under the Apache License, Version 2.0 (the "License"); 6011 * you may not use this file except in compliance with the License. 6012 * You may obtain a copy of the License at 6013 * 6014 * http://www.apache.org/licenses/LICENSE-2.0 6015 * 6016 * Unless required by applicable law or agreed to in writing, software 6017 * distributed under the License is distributed on an "AS IS" BASIS, 6018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6019 * See the License for the specific language governing permissions and 6020 * limitations under the License. 6021 * ============================================================================= 6022 */function x5(n,e,t){const r=(e-n)/(t-1),a=er(t,"float32");a[0]=n;for(let s=1;s<a.length;s++)a[s]=a[s-1]+r;return a}/** 6023 * @license 6024 * Copyright 2020 Google LLC. All Rights Reserved. 6025 * Licensed under the Apache License, Version 2.0 (the License); 6026 * you may not use this file except in compliance with the License. 6027 * You may obtain a copy of the License at 6028 * 6029 * http://www.apache.org/licenses/LICENSE-2.0 6030 * 6031 * Unless required by applicable law or agreed to in writing, software 6032 * distributed under the License is distributed on an AS IS BASIS, 6033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6034 * See the License for the specific language governing permissions and 6035 * limitations under the License. 6036 * ============================================================================= 6037 */const b5=or(n=>Math.log(n));/** 6038 * @license 6039 * Copyright 2020 Google LLC. All Rights Reserved. 6040 * Licensed under the Apache License, Version 2.0 (the "License"); 6041 * you may not use this file except in compliance with the License. 6042 * You may obtain a copy of the License at 6043 * 6044 * http://www.apache.org/licenses/LICENSE-2.0 6045 * 6046 * Unless required by applicable law or agreed to in writing, software 6047 * distributed under the License is distributed on an "AS IS" BASIS, 6048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6049 * See the License for the specific language governing permissions and 6050 * limitations under the License. 6051 * ============================================================================= 6052 */function v5(n,e,t,r){const a=On(r,ae(t));for(let s=0;s<a.length;++s){const o=s*e;let i=n[o];for(let u=0;u<e;++u){const l=n[o+u];(Number.isNaN(l)||l>i)&&(i=l)}a[s]=i}return a}/** 6053 * @license 6054 * Copyright 2020 Google LLC. All Rights Reserved. 6055 * Licensed under the Apache License, Version 2.0 (the "License");
6056 * you may not use this file except in compliance with the License. 6057 * You may obtain a copy of the License at 6058 * 6059 * http://www.apache.org/licenses/LICENSE-2.0 6060 * 6061 * Unless required by applicable law or agreed to in writing, software 6062 * distributed under the License is distributed on an "AS IS" BASIS, 6063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6064 * See the License for the specific language governing permissions and 6065 * limitations under the License. 6066 * ============================================================================= 6067 */const w5=Ut(((n,e)=>Math.max(n,e)));/** 6068 * @license 6069 * Copyright 2020 Google LLC. All Rights Reserved. 6070 * Licensed under the Apache License, Version 2.0 (the "License"); 6071 * you may not use this file except in compliance with the License. 6072 * You may obtain a copy of the License at 6073 * 6074 * http://www.apache.org/licenses/LICENSE-2.0 6075 * 6076 * Unless required by applicable law or agreed to in writing, software 6077 * distributed under the License is distributed on an "AS IS" BASIS, 6078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6079 * See the License for the specific language governing permissions and 6080 * limitations under the License. 6081 * ============================================================================= 6082 */const S5=Ut(((n,e)=>Math.min(n,e)));/** 6083 * @license 6084 * Copyright 2020 Google LLC. All Rights Reserved. 6085 * Licensed under the Apache License, Version 2.0 (the "License"); 6086 * you may not use this file except in compliance with the License. 6087 * You may obtain a copy of the License at 6088 * 6089 * http://www.apache.org/licenses/LICENSE-2.0 6090 * 6091 * Unless required by applicable law or agreed to in writing, software 6092 * distributed under the License is distributed on an "AS IS" BASIS, 6093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6094 * See the License for the specific language governing permissions and 6095 * limitations under the License. 6096 * ============================================================================= 6097 */const um=Ut(((n,e)=>n*e));/** 6098 * @license 6099 * Copyright 2020 Google LLC. All Rights Reserved. 6100 * Licensed under the Apache License, Version 2.0 (the "License"); 6101 * you may not use this file except in compliance with the License. 6102 * You may obtain a copy of the License at 6103 * 6104 * http://www.apache.org/licenses/LICENSE-2.0 6105 * 6106 * Unless required by applicable law or agreed to in writing, software 6107 * distributed under the License is distributed on an "AS IS" BASIS, 6108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6109 * See the License for the specific language governing permissions and 6110 * limitations under the License. 6111 * ============================================================================= 6112 */function k5(n,e,t){const r=ya(-1,t);return um([],e,r,n,t)}/** 6113 * @license 6114 * Copyright 2020 Google LLC. All Rights Reserved. 6115 * Licensed under the Apache License, Version 2.0 (the "License"); 6116 * you may not use this file except in compliance with the License. 6117 * You may obtain a copy of the License at 6118 * 6119 * http://www.apache.org/licenses/LICENSE-2.0 6120 * 6121 * Unless required by applicable law or agreed to in writing, software 6122 * distributed under the License is distributed on an "AS IS" BASIS, 6123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6124 * See the License for the specific language governing permissions and 6125 * limitations under the License. 6126 * ============================================================================= 6127 */const T5=Ut(((n,e)=>n!==e?1:0));/** 6128 * @license 6129 * Copyright 2020 Google LLC. All Rights Reserved. 6130 * Licensed under the Apache License, Version 2.0 (the "License"); 6131 * you may not use this file except in compliance with the License. 6132 * You may obtain a copy of the License at 6133 * 6134 * http://www.apache.org/licenses/LICENSE-2.0 6135 * 6136 * Unless required by applicable law or agreed to in writing, software 6137 * distributed under the License is distributed on an "AS IS" BASIS, 6138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6139 * See the License for the specific language governing permissions and 6140 * limitations under the License. 6141 * ============================================================================= 6142 */function E5(n,e,t,r,a){const s=e.length,o=ae(e),i=ot(e),u=ot(a),l=On(t,ae(a));for(let c=0;c<o;++c){const p=Tu(c,s,i),h=new Array(p.length);for(let m=0;m<h.length;m++)h[m]=p[r[m]];const d=$i(h,s,u);l[d]=n[c]}return l}/** 6143 * @license 6144 * Copyright 2020 Google LLC. All Rights Reserved. 6145 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 13,081 bytes, lines 6146-6256
6146 * you may not use this file except in compliance with the License. 6147 * You may obtain a copy of the License at 6148 * 6149 * http://www.apache.org/licenses/LICENSE-2.0 6150 * 6151 * Unless required by applicable law or agreed to in writing, software 6152 * distributed under the License is distributed on an "AS IS" BASIS, 6153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6154 * See the License for the specific language governing permissions and 6155 * limitations under the License. 6156 * ============================================================================= 6157 */function C5(n,e,t,r){const[a,s]=kn(n,r),o=Sn(e,"int32"),i=er(ae(a),o),u=ae(s);for(let l=0;l<i.length;++l){const c=l*u;let p=1;for(let h=0;h<u;++h)p*=t[c+h];i[l]=p}return{outVals:i,outShape:a,outDtype:o}}/** 6158 * @license 6159 * Copyright 2022 Google LLC. All Rights Reserved. 6160 * Licensed under the Apache License, Version 2.0 (the "License"); 6161 * you may not use this file except in compliance with the License. 6162 * You may obtain a copy of the License at 6163 * 6164 * http://www.apache.org/licenses/LICENSE-2.0 6165 * 6166 * Unless required by applicable law or agreed to in writing, software 6167 * distributed under the License is distributed on an "AS IS" BASIS, 6168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6169 * See the License for the specific language governing permissions and 6170 * limitations under the License. 6171 * ============================================================================= 6172 */function I5(n,e,t){n.forEach((r,a)=>{if(r<0||r>=t){const s=Tu(a,e.length,ot(e)).join(",");throw new Error(`indices[${s}] = ${r} is not in [0, ${t})`)}})}function N5(n,e){for(let t=0;t<n.length;++t){const r=n[t],a=t===n.length-1?e:n[t+1].length;if(r.length===0)throw new Error("Ragged splits may not be empty");if(r[0]<0)throw new Error("Ragged splits must be non-negative");if(r[r.length-1]>a)throw new Error("Ragged splits must not point past values");for(let s=1;s<r.length;++s)if(r[s-1]>r[s])throw new Error("Ragged splits must be sorted in ascending order")}}function $5(n,e,t,r){const a=[];let s=0;const o=e.length-1+t.length,i=new Array(o).fill(null).map(()=>[0]);N5(t,r);let u=1;for(let l=0;l<e.length-1;++l){u*=e[l];const c=e[l+1];for(let p=1;p<u+1;++p)i[l].push(p*c)}for(let l=0;l<n.length;++l){let c=n[l],p=n[l]+1;for(let h=0;h<t.length;++h){const d=t[h],m=h+e.length-1;if(m>=0){const y=i[m],b=y[y.length-1]-d[c];for(let x=c;x<p;++x)i[m].push(d[x+1]+b)}c=d[c],p=d[p]}p!==c&&(a.push([c,p]),s+=p-c)}return{outSplits:i,valueSlices:a,numValues:s}}function R5(n){const e=[];for(let t=0;t<n.length;++t){const r=n[t].length,a=kt("int32",r);e.push(a),n[t].forEach((s,o)=>a[o]=s)}return e}function Kl(n,e){const t=n.slice(0,e);for(;t.length<e;)t.push(1);for(let r=e;r<n.length;r++)t[e-1]*=n[r];return t}function _5(n,e,t,r,a,s){const o=Kl(e,2)[1],i=Kl(s,2)[1];let u=0;for(const l of t)for(let c=l[0];c<l[1];++c){for(let p=0;p<r;++p)a[u*i+p]=n[c*o+p];++u}}function A5(n,e,t,r,a){const s=e.slice();s[0]=a;const o=kt(t,ae(s)),i=n.length,u=i===0?0:i/e[0];return _5(n,e,r,u,o,s),[o,s]}function O5(n,e,t,r,a,s,o,i){if(n.length===0)throw new Error("paramsNestedSplits must be non empty");if(e[0].length===0)throw new Error("Split tensors must not be scalars");const u=e[0][0]-1;if(I5(s,o,u),r.length===0)throw new Error("params.rank must be nonzero");const l=r[0],{outSplits:c,valueSlices:p,numValues:h}=$5(s,o,n,l),d=R5(c),m=A5(t,r,a,p,h);return[d,m[0],m[1]]}/** 6173 * @license 6174 * Copyright 2022 Google LLC. All Rights Reserved. 6175 * Licensed under the Apache License, Version 2.0 (the "License"); 6176 * you may not use this file except in compliance with the License. 6177 * You may obtain a copy of the License at 6178 * 6179 * http://www.apache.org/licenses/LICENSE-2.0 6180 * 6181 * Unless required by applicable law or agreed to in writing, software 6182 * distributed under the License is distributed on an "AS IS" BASIS, 6183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6184 * See the License for the specific language governing permissions and 6185 * limitations under the License. 6186 * ============================================================================= 6187 */var Xt=un;class co{constructor(e,t,r,a,s,o,i,u,l,c){this.shape=e,this.shapeShape=t,this.values=r,this.valuesShape=a,this.valuesDType=s,this.defaultValue=o,this.defaultValueShape=i,this.rowPartitionValues=u,this.rowPartitionValuesShapes=l,this.rowPartitionTypes=g1(c),this.raggedRank=y1(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===Xt.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===Xt.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case Xt.VALUE_ROWIDS:return co.getMaxWidthValueRowID(t);case Xt.ROW_SPLITS:return co.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${Xt[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(t===0||t===1)return 0;let r=0;for(let a=0;a<t-1;++a){const s=e[a+1]-e[a];s>r&&(r=s)}return r}static getMaxWidthValueRowID(e){const t=e.length;if(t===0)return 0;let r=0,a=e[0],s=0;for(let o=1;o<t;++o){const i=e[o];i!==a&&(a=i,s=Math.max(o-r,s),r=o)}return Math.max(t-r,s)}tensorShapeFromTensor(e,t,r=!0){if(t.length===0){if(e[0]===-1)return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return Zl(e,r)}calculateOutputSize(e){const t=this.valuesShape,r=this.defaultValueShape;x1(r,t);const a=this.tensorShapeFromTensor(this.shape,this.shapeShape),s=m1(this.raggedRank,a,t);s[0]<0&&(s[0]=e);for(let o=1;o<=this.raggedRank;++o)s[o]<0&&(s[o]=this.getMaxWidth(o));return s}calculateFirstParentOutputIndex(e,t,r){const a=Math.min(e,r),s=[];let o=0;for(let i=0;i<a;++i,o+=t)s.push(o);for(let i=a;i<e;++i)s.push(-1);return R(s.length===e,()=>"Final length of result must be equal to firstDimension."),s}calculateOutputIndexRowSplit(e,t,r,a){const s=e.length,o=[];for(let i=0;i<s-1;++i){const u=e[i+1]-e[i];let l=Math.min(a,u),c=t[i];c===-1&&(l=0);for(let p=0;p<l;++p)o.push(c),c+=r;for(let p=0;p<u-l;++p)o.push(-1)}if(s>0&&o.length!==e[s-1])throw new Error("Invalid row split size.");return o}calculateOutputIndexValueRowID(e,t,r,a){const s=e.length,o=[];if(s===0)return[];let i=0,u=e[0];if(u>=t.length)throw new Error(`Got currentValueRowId=${u}, which is not less than ${t.length}`);let l=t[u];o.push(l);for(let c=1;c<s;++c){const p=e[c];if(p===u)l>=0&&(++i,i<a?l+=r:l=-1);else{if(i=0,u=p,p>=t.length)throw new Error(`Got nextValueRowId=${p} which is not less than ${t.length}`);l=t[p]}o.push(l)}if(o.length!==e.length)throw new Error("Invalid row ids.");return o}calculateOutputIndex(e,t,r,a){const s=this.getRowPartitionTensor(e),o=this.getRowPartitionTypeByDimension(e);switch(o){case Xt.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(s,t,r,a);case Xt.ROW_SPLITS:if(s.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${s.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(s,t,r,a);default:throw new Error(`Unsupported partition type: ${Xt[o]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(this.rowPartitionTypes.length===0)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case Xt.FIRST_DIM_SIZE:return e[0];case Xt.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case Xt.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${Xt[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),r=new Array(this.raggedRank+1);r[r.length-1]=1;for(let o=r.length-2;o>=0;--o)r[o]=r[o+1]*t[o+1];const a=Zl(t,!1),s=kt(this.valuesDType,ae(a));if(r[0]*t[0]>0){let o=this.calculateFirstParentOutputIndex(e,r[0],t[0]);for(let i=1;i<=this.raggedRank;++i)o=this.calculateOutputIndex(i-1,o,r[i],t[i]);this.setOutput(this.raggedRank,o,s,a)}return[a,s]}setOutput(e,t,r,a){if(r.length===0)return;const s=this.values,o=r;let i=a.slice();i=i.slice(e+1);const u=ae(i),l=t.length;let c=this.defaultValue;if(c.length!==u&&c.length!==1){const m=this.defaultValueShape;Xe(()=>{const y=Z(c,m);c=Qa(y,i).dataSync()})}let p=0,h=0,d=0;for(let m=0;m<=l;++m){let y=m<l?t[m]:-1;if(y===d){++d;continue}if(h<d){const b=s.subarray(p*u),x=o.subarray(h*u),T=(d-h)*u;Yl(x,b,T)}if(m>=l){const b=r.length;y=Math.floor(b/u)}if(y>d)if(this.defaultValue.length===1)o.subarray(d*u,y*u).fill(this.defaultValue[0]),d=y;else for(;y>d;){const b=o.slice(d*u);Yl(b,c,u),++d}y<0?(p=m+1,h=d):(p=m,h=d,d=h+1)}}}function Yl(n,e,t){for(let r=0;r<t;r++)n[r]=e[r]}function Zl(n,e){const t=[];for(let r of n){if(r<0){if(!e)throw new Error(`Dimension ${r} must be >= 0`);if(r<-1)throw new Error(`Dimension ${r} must be >= -1`);r=-1}t.push(r)}return t}function F5(n,e,t,r,a,s,o,i,u,l){return new co(n,e,t,r,a,s,o,i,u,l).compute()}/** 6188 * @license 6189 * Copyright 2020 Google LLC. All Rights Reserved. 6190 * Licensed under the Apache License, Version 2.0 (the "License"); 6191 * you may not use this file except in compliance with the License. 6192 * You may obtain a copy of the License at 6193 * 6194 * http://www.apache.org/licenses/LICENSE-2.0 6195 * 6196 * Unless required by applicable law or agreed to in writing, software 6197 * distributed under the License is distributed on an "AS IS" BASIS, 6198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6199 * See the License for the specific language governing permissions and 6200 * limitations under the License. 6201 * ============================================================================= 6202 */function D5(n,e,t,r){const a=n===e,s=n<e&&t<0,o=e<n&&t>1;if(a||s||o)return er(0,r);const i=Math.abs(Math.ceil((e-n)/t)),u=er(i,r);e<n&&t===1&&(t=-1),u[0]=n;for(let l=1;l<u.length;l++)u[l]=u[l-1]+t;return u}/** 6203 * @license 6204 * Copyright 2020 Google LLC. All Rights Reserved. 6205 * Licensed under the Apache License, Version 2.0 (the License); 6206 * you may not use this file except in compliance with the License. 6207 * You may obtain a copy of the License at 6208 * 6209 * http://www.apache.org/licenses/LICENSE-2.0 6210 * 6211 * Unless required by applicable law or agreed to in writing, software 6212 * distributed under the License is distributed on an AS IS BASIS, 6213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6214 * See the License for the specific language governing permissions and 6215 * limitations under the License. 6216 * ============================================================================= 6217 */const M5=or(n=>1/Math.sqrt(n));/** 6218 * @license 6219 * Copyright 2020 Google LLC. All Rights Reserved. 6220 * Licensed under the Apache License, Version 2.0 (the "License"); 6221 * you may not use this file except in compliance with the License. 6222 * You may obtain a copy of the License at 6223 * 6224 * http://www.apache.org/licenses/LICENSE-2.0 6225 * 6226 * Unless required by applicable law or agreed to in writing, software 6227 * distributed under the License is distributed on an "AS IS" BASIS, 6228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6229 * See the License for the specific language governing permissions and 6230 * limitations under the License. 6231 * ============================================================================= 6232 */function L5(n,e,t,r,a,s,o,i,u,l){const c=[r/a,a],p=n.values,h=e.values;if(r===0)return He(t,e.dtype);const d=He(c,e.dtype);typeof u=="string"||typeof u=="number"?d.values.fill(u):typeof u=="boolean"&&d.values.fill(+u);for(let m=0;m<s;m++){const y=[];let b=0;for(let x=0;x<o;x++){const T=p[m*o+x];y.push(T),b+=T*i[x]}if(b<0||b>=r/a)throw new Error(`Invalid indices: ${y} does not index into ${t}`);for(let x=0;x<a;x++)l?d.values[b*a+x]+=h[m*a+x]:d.values[b*a+x]=e.rank===0?h[0]:h[m*a+x]}return d}/** 6233 * @license 6234 * Copyright 2020 Google LLC. All Rights Reserved. 6235 * Licensed under the Apache License, Version 2.0 (the License); 6236 * you may not use this file except in compliance with the License. 6237 * You may obtain a copy of the License at 6238 * 6239 * http://www.apache.org/licenses/LICENSE-2.0 6240 * 6241 * Unless required by applicable law or agreed to in writing, software 6242 * distributed under the License is distributed on an AS IS BASIS, 6243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6244 * See the License for the specific language governing permissions and 6245 * limitations under the License. 6246 * ============================================================================= 6247 */const P5=or(n=>1/(1+Math.exp(-n)));/** 6248 * @license 6249 * Copyright 2020 Google LLC. All Rights Reserved. 6250 * Licensed under the Apache License, Version 2.0 (the "License"); 6251 * you may not use this file except in compliance with the License. 6252 * You may obtain a copy of the License at 6253 * 6254 * http://www.apache.org/licenses/LICENSE-2.0 6255 * 6256 * Unless required by applicable law or agreed to in writing, softw
6256are 6257 * distributed under the License is distributed on an "AS IS" BASIS, 6258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6259 * See the License for the specific language governing permissions and 6260 * limitations under the License. 6261 * ============================================================================= 6262 */function B5(n,e,t,r,a){const s=Lu(r,e,t),o=ae(t),i=ot(r);if(s){const p=Pu(e,i);return a==="string"?n.slice(p,p+o):n.subarray(p,p+o)}const u=a==="string"?is(n):n,l=He(r,a,u),c=He(t,a);for(let p=0;p<c.size;++p){const h=c.indexToLoc(p),d=h.map((m,y)=>m+e[y]);c.set(l.get(...d),...h)}return a==="string"?Y1(c.values):c.values}/** 6263 * @license 6264 * Copyright 2021 Google LLC. All Rights Reserved. 6265 * Licensed under the Apache License, Version 2.0 (the "License"); 6266 * you may not use this file except in compliance with the License. 6267 * You may obtain a copy of the License at 6268 * 6269 * http://www.apache.org/licenses/LICENSE-2.0 6270 * 6271 * Unless required by applicable law or agreed to in writing, software 6272 * distributed under the License is distributed on an "AS IS" BASIS, 6273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6274 * See the License for the specific language governing permissions and 6275 * limitations under the License. 6276 * ============================================================================= 6277 */function U5(n,e,t,r,a,s,o){const i=e[0],u=s[0],l=new Array(u),c=new Array(i),p=e[1];if(u===0){if(i!==0)throw new Error(M1(i));const b=kt(t,0),x=kt(a,0);return[b,[0,p],x,l,c]}let h=!0,d=0;const m=new Array(u).fill(0);for(let b=0;b<i;++b){const x=n[b*p];if(x<0)throw new Error(L1(b,x));if(x>=u)throw new Error(P1(b,x,u));++m[x],h=h&&x>=d,d=x}let y=!0;for(let b=0;b<u;++b){const x=m[b]===0;l[b]=x,y=y&&!x,m[b]=Math.max(m[b],1),b>0&&(m[b]+=m[b-1])}if(y&&h){const b=n,x=r;for(let T=0;T<i;++T)c[T]=T;return[b,[i,p],x,l,c]}else{const b=m[u-1],x=kt(t,b*p),T=kt(a,b),$=new Array(u).fill(0);for(let F=0;F<i;++F){const M=n[F*p],U=$[M],X=(M===0?0:m[M-1])+U;$[M]++;for(let z=0;z<p;++z)x[X*p+z]=n[F*p+z];T[X]=r[F],c[F]=X}for(let F=0;F<u;++F)if($[F]===0){const M=F===0?0:m[F-1];x[M*p+0]=F;for(let U=1;U<p;++U)x[M*p+U]=0;T[M]=o}return[x,[b,p],T,l,c]}}/** 6278 * @license 6279 * Copyright 2021 Google LLC. All Rights Reserved. 6280 * Licensed under the Apache License, Version 2.0 (the "License"); 6281 * you may not use this file except in compliance with the License. 6282 * You may obtain a copy of the License at 6283 * 6284 * http://www.apache.org/licenses/LICENSE-2.0 6285 * 6286 * Unless required by applicable law or agreed to in writing, software 6287 * distributed under the License is distributed on an "AS IS" BASIS, 6288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6289 * See the License for the specific language governing permissions and 6290 * limitations under the License. 6291 * ============================================================================= 6292 */function V5(n,e,t,r,a){const s=ae(r),o=e[0],i=a.length,u=[];let l=1,c=-1;for(let y=0;y<i;++y){const b=a[y];if(b===-1){if(c!==-1)throw new Error(B1(c,y));c=y,u.push(1)}else{if(b<0)throw new Error(U1(y,b));l*=b,u.push(b)}}if(c!==-1){if(l<=0)throw new Error(V1());const y=Math.trunc(s/l);if(l*y!==s)throw new Error(W1(r,u));u[c]=y}if(ae(u)!==s)throw new Error(z1(r,u));const p=r.length,h=[];if(p>0){h[p-1]=1;for(let y=p-2;y>=0;--y)h[y]=h[y+1]*r[y+1]}const d=[];if(i>0){d[i-1]=1;for(let y=i-2;y>=0;--y)d[y]=d[y+1]*u[y+1]}const m=kt(t,o*i);for(let y=0;y<o;++y){let b=0;for(let x=0;x<p;++x)b+=n[y*p+x]*h[x];for(let x=0;x<i;++x)m[y*i+x]=Math.trunc(b/d[x]),b%=d[x]}return[m,[o,i],u]}/** 6293 * @license 6294 * Copyright 2021 Google LLC. All Rights Reserved. 6295 * Licensed under the Apache License, Version 2.0 (the "License"); 6296 * you may not use this file except in compliance with the License. 6297 * You may obtain a copy of the License at 6298 * 6299 * http://www.apache.org/licenses/LICENSE-2.0 6300 * 6301 * Unless required by applicable law or agreed to in writing, software 6302 * distributed under the License is distributed on an "AS IS" BASIS, 6303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6304 * See the License for the specific language governing permissions and 6305 * limitations under the License. 6306 * ============================================================================= 6307 */function W5(n,e,t,r,a,s=!1,o=0){const i=r.length,u=[e[0],n.length/e[0]],l=u[1],c=i>0?a[i-1]+1:0;if(c<0)throw new Error(ou());const p=e.slice();p[0]=c;const h=p.reduce((T,$)=>T*$,1),d=kt(t,h);if(i===0)return c>0&&d.fill(o),[d,p];if(c<=0)throw new Error(ou());let m=0,y=1,b=0,x=a[m];for(;;){let T=0;if(y<i){if(T=a[y],x===T){++y;continue}if(x>=T)throw new Error(G1())}if(x<0||x>=c)throw new Error(j1(x,c));x>b&&d.fill(o,b*l,x*l);for(let $=m;$<y;++$){const F=r[$];if(F<0||F>=u[0])throw new Error(H1($,r[$],u[0]));for(let M=0;M<l;M++)d[x*l+M]+=n[F*l+M]}if(s)for(let $=0;$<l;$++)d[x*l+$]/=y-m;if(m=y,++y,b=x+1,x=T,y>i)break}return b<c&&d.fill(o,b*l,c*l),[d,p]}/** 6308 * @license 6309 * Copyright 2020 Google LLC. All Rights Reserved. 6310 * Licensed under the Apache License, Version 2.0 (the License);
6311 * you may not use this file except in compliance with the License. 6312 * You may obtain a copy of the License at 6313 * 6314 * http://www.apache.org/licenses/LICENSE-2.0 6315 * 6316 * Unless required by applicable law or agreed to in writing, software 6317 * distributed under the License is distributed on an AS IS BASIS, 6318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6319 * See the License for the specific language governing permissions and 6320 * limitations under the License. 6321 * ============================================================================= 6322 */const z5=or(n=>Math.sqrt(n));/** 6323 * @license 6324 * Copyright 2020 Google LLC. All Rights Reserved. 6325 * Licensed under the Apache License, Version 2.0 (the "License"); 6326 * you may not use this file except in compliance with the License. 6327 * You may obtain a copy of the License at 6328 * 6329 * http://www.apache.org/licenses/LICENSE-2.0 6330 * 6331 * Unless required by applicable law or agreed to in writing, software 6332 * distributed under the License is distributed on an "AS IS" BASIS, 6333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6334 * See the License for the specific language governing permissions and 6335 * limitations under the License. 6336 * ============================================================================= 6337 */const G5=Ut(((n,e)=>{const t=n-e;return t*t}));/** 6338 * @license 6339 * Copyright 2020 Google LLC. All Rights Reserved. 6340 * Licensed under the Apache License, Version 2.0 (the "License"); 6341 * you may not use this file except in compliance with the License. 6342 * You may obtain a copy of the License at 6343 * 6344 * http://www.apache.org/licenses/LICENSE-2.0 6345 * 6346 * Unless required by applicable law or agreed to in writing, software 6347 * distributed under the License is distributed on an "AS IS" BASIS, 6348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6349 * See the License for the specific language governing permissions and 6350 * limitations under the License. 6351 * ============================================================================= 6352 */function j5(n,e,t,r){const a=He(n,e.dtype);for(let s=0;s<a.size;s++){const o=a.indexToLoc(s),i=new Array(o.length);for(let u=0;u<i.length;u++)i[u]=o[u]*t[u]+r[u];a.set(e.get(...i),...o)}return a}/** 6353 * @license 6354 * Copyright 2021 Google LLC. All Rights Reserved. 6355 * Licensed under the Apache License, Version 2.0 (the "License"); 6356 * you may not use this file except in compliance with the License. 6357 * You may obtain a copy of the License at 6358 * 6359 * http://www.apache.org/licenses/LICENSE-2.0 6360 * 6361 * Unless required by applicable law or agreed to in writing, software 6362 * distributed under the License is distributed on an "AS IS" BASIS, 6363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6364 * See the License for the specific language governing permissions and 6365 * limitations under the License. 6366 * ============================================================================= 6367 */class H5{constructor(e,t,r,a,s,o){this.separator=Nr(e),this.nGramWidths=t,this.leftPad=Nr(r),this.rightPad=Nr(a),this.padWidth=s,this.preserveShort=o}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const r=this.getPadWidth(t);return Math.max(0,e+2*r-t+1)}createNGrams(e,t,r,a,s,o){for(let i=0;i<s;++i){const u=this.getPadWidth(o),l=Math.max(0,u-i),c=Math.max(0,u-(s-(i+1))),p=o-(l+c),h=t+(l>0?0:i-u);let d=0;d+=l*this.leftPad.length;for(let T=0;T<p;++T)d+=e[h+T].length;d+=c*this.rightPad.length;const m=l+c+p-1;d+=m*this.separator.length,r[a+i]=new Uint8Array(d);const y=r[a+i];let b=0;const x=T=>T.forEach($=>y[b++]=$);for(let T=0;T<l;++T)x(this.leftPad),x(this.separator);for(let T=0;T<p-1;++T)x(e[h+T]),x(this.separator);if(p>0){x(e[h+p-1]);for(let T=0;T<c;++T)x(this.separator),x(this.rightPad)}else{for(let T=0;T<c-1;++T)x(this.rightPad),x(this.separator);x(this.rightPad)}}}compute(e,t){const r=e.length,a=t.length;if(a>0){let u=t[0];if(u!==0)throw new Error(`First split value must be 0, got ${u}`);for(let l=1;l<a;++l){let c=t[l]>=u;if(c=c&&t[l]<=r,!c)throw new Error(`Invalid split value ${t[l]}, must be in [${u}, ${r}]`);u=t[l]}if(u!==r)throw new Error(`Last split value must be data size. Expected ${r}, got ${u}`)}const s=a-1,o=kt("int32",a);if(r===0||a===0){const u=new Array(r);for(let l=0;l<=s;++l)o[l]=0;return[u,o]}o[0]=0;for(let u=1;u<=s;++u){const l=t[u]-t[u-1];let c=0;this.nGramWidths.forEach(p=>{c+=this.getNumNGrams(l,p)}),this.preserveShort&&l>0&&c===0&&(c=1),o[u]=o[u-1]+c}const i=new Array(o[s]);for(let u=0;u<s;++u){const l=t[u];let c=o[u];if(this.nGramWidths.forEach(p=>{const h=t[u+1]-t[u],d=this.getNumNGrams(h,p);this.createNGrams(e,l,i,c,d,p),c+=d}),this.preserveShort&&c===o[u]){const p=t[u+1]-t[u];
vendor: 4,312 bytes, lines 6367-6430
6367if(p===0)continue;const h=p+2*this.padWidth;this.createNGrams(e,l,i,c,1,h)}}return[i,o]}}function X5(n,e,t,r,a,s,o,i){return new H5(t,r,a,s,o,i).compute(n,e)}/** 6368 * @license 6369 * Copyright 2021 Google LLC. All Rights Reserved. 6370 * Licensed under the Apache License, Version 2.0 (the "License"); 6371 * you may not use this file except in compliance with the License. 6372 * You may obtain a copy of the License at 6373 * 6374 * http://www.apache.org/licenses/LICENSE-2.0 6375 * 6376 * Unless required by applicable law or agreed to in writing, software 6377 * distributed under the License is distributed on an "AS IS" BASIS, 6378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6379 * See the License for the specific language governing permissions and 6380 * limitations under the License. 6381 * ============================================================================= 6382 */function q5(n,e,t,r){if(!n.length)return;if(e.length===0){for(let s=0;s<n.length;++s)r.push(n.subarray(s,s+1));return}if(e.length===1){const s=e[0];let o=n.indexOf(s);for(;o!==-1;){const i=n.subarray(0,o);(!t||i.length!==0)&&r.push(i),n=n.subarray(o+1),o=n.indexOf(s)}(!t||n.length!==0)&&r.push(n);return}let a=0;for(let s=0;s<n.length+1;s++)if(s===n.length||e.indexOf(n[s])!==-1){const o=n.subarray(a,s);(!t||o.length!==0)&&r.push(o),a=s+1}}function K5(n,e,t){const r=n.length,a=[];let s=0,o=0;const i=new Array(r);for(let h=0;h<r;++h){const d=a.length;q5(n[h],e,t,a);const m=a.length-d;i[h]=m,s+=m,o=Math.max(o,m)}const u=kt("int32",s*2),l=new Array(s),c=[r,o];let p=0;for(let h=0;h<r;++h)for(let d=0;d<i[h];++d)u[p*2]=h,u[p*2+1]=d,l[p]=a[p],++p;return[u,l,c]}/** 6383 * @license 6384 * Copyright 2021 Google LLC. All Rights Reserved. 6385 * Licensed under the Apache License, Version 2.0 (the "License"); 6386 * you may not use this file except in compliance with the License. 6387 * You may obtain a copy of the License at 6388 * 6389 * http://www.apache.org/licenses/LICENSE-2.0 6390 * 6391 * Unless required by applicable law or agreed to in writing, software 6392 * distributed under the License is distributed on an "AS IS" BASIS, 6393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6394 * See the License for the specific language governing permissions and 6395 * limitations under the License. 6396 * ============================================================================= 6397 */function Y5(n,e){const t=kt("int32",n.length);for(let r=0;r<n.length;++r)t[r]=q2(n[r]).modulo(e).getLowBitsUnsigned();return t}/** 6398 * @license 6399 * Copyright 2020 Google LLC. All Rights Reserved. 6400 * Licensed under the Apache License, Version 2.0 (the "License"); 6401 * you may not use this file except in compliance with the License. 6402 * You may obtain a copy of the License at 6403 * 6404 * http://www.apache.org/licenses/LICENSE-2.0 6405 * 6406 * Unless required by applicable law or agreed to in writing, software 6407 * distributed under the License is distributed on an "AS IS" BASIS, 6408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6409 * See the License for the specific language governing permissions and 6410 * limitations under the License. 6411 * ============================================================================= 6412 */const Z5=Ut(((n,e)=>n-e));/** 6413 * @license 6414 * Copyright 2019 Google LLC. All Rights Reserved. 6415 * Licensed under the Apache License, Version 2.0 (the "License"); 6416 * you may not use this file except in compliance with the License. 6417 * You may obtain a copy of the License at 6418 * 6419 * http://www.apache.org/licenses/LICENSE-2.0 6420 * 6421 * Unless required by applicable law or agreed to in writing, software 6422 * distributed under the License is distributed on an "AS IS" BASIS, 6423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6424 * See the License for the specific language governing permissions and 6425 * limitations under the License. 6426 * ============================================================================= 6427 */function J5(n,e){const t=new Array(n.rank);for(let a=0;a<t.length;a++)t[a]=n.shape[a]*e[a];const r=He(t,n.dtype);for(let a=0;a<r.values.length;++a){const s=r.indexToLoc(a),o=new Array(n.rank);for(let u=0;u<o.length;u++)o[u]=s[u]%n.shape[u];const i=n.locToIndex(o);r.values[a]=n.values[i]}return r}/** 6428 * @license 6429 * Copyright 2020 Google LLC. All Rights Reserved. 6430 * Licensed under the Apache License, Version 2.0 (the "License");
6431 * you may not use this file except in compliance with the License. 6432 * You may obtain a copy of the License at 6433 * 6434 * http://www.apache.org/licenses/LICENSE-2.0 6435 * 6436 * Unless required by applicable law or agreed to in writing, software 6437 * distributed under the License is distributed on an "AS IS" BASIS, 6438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6439 * See the License for the specific language governing permissions and 6440 * limitations under the License. 6441 * ============================================================================= 6442 */const Za=(n,e)=>{const t=e.value-n.value;return t===0?n.index-e.index:t};function lm(n,e,t=0,r=n.length-1){for(;r>t;){if(r-t>600){const i=r-t+1,u=e-t+1,l=Math.log(i),c=.5*Math.exp(2*l/3),p=.5*Math.sqrt(l*c*(i-c)/i)*Math.sign(u-i/2),h=Math.max(t,Math.floor(e-u*c/i+p)),d=Math.min(r,Math.floor(e+(i-u)*c/i+p));lm(n,e,h,d)}const a=n[e];let s=t,o=r;for(Ha(n,t,e),Za(n[r],a)>0&&Ha(n,t,r);s<o;){for(Ha(n,s,o),s++,o--;Za(n[s],a)<0;)s=s+1;for(;Za(n[o],a)>0;)o=o-1}Za(n[t],a)===0?Ha(n,t,o):(o=o+1,Ha(n,o,r)),o<=e&&(t=o+1),e<=o&&(r=o-1)}}function Q5(n,e,t,r,a){const s=e[e.length-1],[o,i]=[n.length/s,s],u=On(t,o*r),l=On("int32",o*r);for(let p=0;p<o;p++){const h=p*i,d=n.subarray(h,h+i);let m=new Array(d.length);d.forEach((T,$)=>m[$]={value:T,index:$}),r<m.length&&(lm(m,r),m=m.slice(0,r)),a&&m.sort(Za);const y=p*r,b=u.subarray(y,y+r),x=l.subarray(y,y+r);for(let T=0;T<r;T++)b[T]=m[T].value,x[T]=m[T].index}const c=e.slice();return c[c.length-1]=r,[He(c,t,u),He(c,"int32",l)]}/** 6443 * @license 6444 * Copyright 2020 Google LLC. All Rights Reserved. 6445 * Licensed under the Apache License, Version 2.0 (the "License"); 6446 * you may not use this file except in compliance with the License. 6447 * You may obtain a copy of the License at 6448 * 6449 * http://www.apache.org/licenses/LICENSE-2.0 6450 * 6451 * Unless required by applicable law or agreed to in writing, software 6452 * distributed under the License is distributed on an "AS IS" BASIS, 6453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6454 * See the License for the specific language governing permissions and 6455 * limitations under the License. 6456 * ============================================================================= 6457 */function ek(n,e,t,r){const a=rt(e,t)[0],s=[1,t[0],1];for(let m=0;m<a;m++)s[0]*=t[m];s[1]=t[a];for(let m=a+1;m<t.length;m++)s[2]*=t[m];const o={},i=new Int32Array(t[a]),u=new ts(s,r,n),l=[],c=s[0]===1&&s[2]===1;for(let m=0;m<t[a];m++){let y;if(c)y=n[m].toString();else{const b=[];for(let x=0;x<s[0];x++)for(let T=0;T<s[2];T++)b.push(u.get(x,m,T));y=b.join(",")}if(o[y]!==void 0)i[m]=o[y];else{const b=Object.keys(o).length;o[y]=b,i[m]=b,l.push(m)}}const p=s.slice();p[1]=Object.keys(o).length;const h=new ts(p,r);l.forEach((m,y)=>{for(let b=0;b<s[0];b++)for(let x=0;x<s[2];x++)h.set(u.get(b,m,x),b,y,x)});const d=t.slice();return d[a]=p[1],{outputValues:h.values,outputShape:d,indices:i}}/** 6458 * @license 6459 * Copyright 2020 Google LLC. All Rights Reserved. 6460 * Licensed under the Apache License, Version 2.0 (the "License"); 6461 * you may not use this file except in compliance with the License. 6462 * You may obtain a copy of the License at 6463 * 6464 * http://www.apache.org/licenses/LICENSE-2.0 6465 * 6466 * Unless required by applicable law or agreed to in writing, software 6467 * distributed under the License is distributed on an "AS IS" BASIS, 6468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6469 * See the License for the specific language governing permissions and 6470 * limitations under the License. 6471 * ============================================================================= 6472 */const tk=Object.freeze(Object.defineProperty({__proto__:null,addImpl:r5,bincountImpl:a5,bincountReduceImpl:s5,castImpl:n5,ceilImpl:o5,concatImpl:i5,equalImpl:u5,expImpl:l5,expm1Impl:c5,floorImpl:p5,gatherNdImpl:h5,gatherV2Impl:d5,greaterEqualImpl:m5,greaterImpl:f5,lessEqualImpl:y5,lessImpl:g5,linSpaceImpl:x5,logImpl:b5,maxImpl:v5,maximumImpl:w5,minimumImpl:S5,multiplyImpl:um,negImpl:k5,notEqualImpl:T5,prodImpl:C5,raggedGatherImpl:O5,raggedTensorToTensorImpl:F5,rangeImpl:D5,rsqrtImpl:M5,scatterImpl:L5,sigmoidImpl:P5,simpleAbsImpl:t5,sliceImpl:B5,sparseFillEmptyRowsImpl:U5,sparseReshapeImpl:V5,sparseSegmentReductionImpl:W5,sqrtImpl:z5,squaredDifferenceImpl:G5,stridedSliceImpl:j5,stringNGramsImpl:X5,stringSplitImpl:K5,stringToHashBucketFastImpl:Y5,subImpl:Z5,tileImpl:J5,topKImpl:Q5,transposeImpl:E5,uniqueImpl:ek},Symbol.toStringTag,{value:"Module"}));/** 6473 * @license 6474 * Copyright 2020 Google LLC. All Rights Reserved. 6475 * Licensed under the Apache License, Version 2.0 (the "License");
6476 * you may not use this file except in compliance with the License. 6477 * You may obtain a copy of the License at 6478 * 6479 * http://www.apache.org/licenses/LICENSE-2.0 6480 * 6481 * Unless required by applicable law or agreed to in writing, software 6482 * distributed under the License is distributed on an "AS IS" BASIS, 6483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6484 * See the License for the specific language governing permissions and 6485 * limitations under the License. 6486 * ============================================================================= 6487 */const{addImpl:nk,bincountImpl:cm,bincountReduceImpl:rk,castImpl:ak,ceilImpl:sk,concatImpl:ok,equalImpl:ik,expImpl:uk,expm1Impl:lk,floorImpl:ck,gatherNdImpl:pk,gatherV2Impl:hk,greaterImpl:dk,greaterEqualImpl:fk,lessImpl:mk,lessEqualImpl:gk,linSpaceImpl:yk,logImpl:xk,maxImpl:bk,maximumImpl:vk,minimumImpl:wk,multiplyImpl:Sk,negImpl:kk,notEqualImpl:Tk,prodImpl:Ek,raggedGatherImpl:Ck,raggedTensorToTensorImpl:Ik,rangeImpl:Nk,rsqrtImpl:$k,scatterImpl:Rk,sigmoidImpl:_k,simpleAbsImpl:pm,sliceImpl:Ak,sparseFillEmptyRowsImpl:Ok,sparseReshapeImpl:Fk,sparseSegmentReductionImpl:hm,sqrtImpl:Dk,stridedSliceImpl:Mk,stringNGramsImpl:Lk,stringSplitImpl:Pk,stringToHashBucketFastImpl:Bk,subImpl:Uk,tileImpl:Vk,topKImpl:Wk,transposeImpl:il,uniqueImpl:zk}=tk;/** 6488 * @license 6489 * Copyright 2018 Google LLC. All Rights Reserved. 6490 * Licensed under the Apache License, Version 2.0 (the "License"); 6491 * you may not use this file except in compliance with the License. 6492 * You may obtain a copy of the License at 6493 * 6494 * http://www.apache.org/licenses/LICENSE-2.0 6495 * 6496 * Unless required by applicable law or agreed to in writing, software 6497 * distributed under the License is distributed on an "AS IS" BASIS, 6498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6499 * See the License for the specific language governing permissions and 6500 * limitations under the License. 6501 * ============================================================================= 6502 */function dm(n,e){return["x","y","z","w","u","v"].slice(0,e).map(t=>`${n}.${t}`)}function ft(n,e){return e===1?[n]:dm(n,e)}function Gk(n,e){if(n===1)return"rc";let t="";for(let r=0;r<n;r++)t+=e[r],r<n-1&&(t+=",");return t}/** 6503 * @license 6504 * Copyright 2018 Google LLC. All Rights Reserved. 6505 * Licensed under the Apache License, Version 2.0 (the "License"); 6506 * you may not use this file except in compliance with the License. 6507 * You may obtain a copy of the License at 6508 * 6509 * http://www.apache.org/licenses/LICENSE-2.0 6510 * 6511 * Unless required by applicable law or agreed to in writing, software 6512 * distributed under the License is distributed on an "AS IS" BASIS, 6513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6514 * See the License for the specific language governing permissions and 6515 * limitations under the License. 6516 * ============================================================================= 6517 */class jk{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=bt(this.outputShape.length),this.rank===0)this.userCode=` 6518 void main() { 6519 setOutput(vec4(getA(), 0., 0., 0.)); 6520 } 6521 `;else{const t=ft("rc",this.rank),r=Be(this.rank),a=this.getOutOfBoundsCondition(t),s=this.getSetup(t),o=this.getOutput(t);this.userCode=` 6522 void main() { 6523 ${r} rc = getOutputCoords(); 6524 6525 if(${a}) { 6526 setOutput(vec4(0)); 6527 } else { 6528 ${s} 6529 6530 setOutput(vec4(${o})); 6531 } 6532 } 6533 `}}getSourceCoordsArr(e){const t=[];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 o=2;o<this.rank;o++)s=`${e[e.length-1-o]},`+s;t.push(s)}return t}getOutOfBoundsCondition(e){if(this.rank===1)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let r=this.rank-2;r<this.rank;r++)t+=`${e[r]} >= ${this.enableShapeUniforms?`outShape[${r}]`:this.outputShape[r]}`,r<this.rank-1&&(t+="||");return t}getSetup(e){if(this.rank===1)return"";const t=e.slice(-2),r=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],a=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return` 6534 int r = ${t[0]}; 6535 int c = ${t[1]}; 6536 int rp1 = r + 1; 6537 int cp1 = c + 1; 6538 6539 bool cEdge = cp1 >= ${r}; 6540 bool rEdge = rp1 >= ${a}; 6541 `}getOutput(e){const t=this.getSourceCoordsArr(e);return this.rank===1?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}), 6542 cEdge ? 0. : getA(${t[1]}),
6543 rEdge ? 0. : getA(${t[2]}), 6544 rEdge || cEdge ? 0. : getA(${t[3]})`}}/** 6545 * @license 6546 * Copyright 2018 Google LLC. All Rights Reserved. 6547 * Licensed under the Apache License, Version 2.0 (the "License"); 6548 * you may not use this file except in compliance with the License. 6549 * You may obtain a copy of the License at 6550 * 6551 * http://www.apache.org/licenses/LICENSE-2.0 6552 * 6553 * Unless required by applicable law or agreed to in writing, software 6554 * distributed under the License is distributed on an "AS IS" BASIS, 6555 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6556 * See the License for the specific language governing permissions and 6557 * limitations under the License. 6558 * ============================================================================= 6559 */class fm{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length);let r="";for(let a=0;a<4;a++){let s="thisRC = rc;";a%2===1&&(s+="thisRC.z += 1;"),a>1&&(s+="thisRC.y += 1;"),r+=` 6560 ${s} 6561 ${a>0?"if(thisRC.y < rows && thisRC.z < cols){":""} 6562 int flatIndex = getFlatIndex(thisRC); 6563 6564 ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex); 6565 vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z)); 6566 6567 result[${a}] = 6568 getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); 6569 ${a>0?"}":""} 6570 `}this.userCode=` 6571 ${Hk(t,this.enableShapeUniforms)} 6572 ${this.enableShapeUniforms?sl():al(e)} 6573 6574 void main() { 6575 ivec3 rc = getOutputCoords(); 6576 6577 vec4 result = vec4(0.); 6578 6579 ivec3 thisRC; 6580 int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]}; 6581 int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]}; 6582 6583 ${r} 6584 6585 setOutput(result); 6586 } 6587 `}}function Hk(n,e){return` 6588 ivec3 inputCoordsFromReshapedOutCoords(int index) { 6589 ${e?H6(["r","c","d"],"inputShape"):Ur(["r","c","d"],n)} 6590 return ivec3(r, c, d); 6591 } 6592 `}/** 6593 * @license 6594 * Copyright 2017 Google LLC. All Rights Reserved. 6595 * Licensed under the Apache License, Version 2.0 (the "License"); 6596 * you may not use this file except in compliance with the License. 6597 * You may obtain a copy of the License at 6598 * 6599 * http://www.apache.org/licenses/LICENSE-2.0 6600 * 6601 * Unless required by applicable law or agreed to in writing, software 6602 * distributed under the License is distributed on an "AS IS" BASIS, 6603 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6604 * See the License for the specific language governing permissions and 6605 * limitations under the License. 6606 * ============================================================================= 6607 */class Xk{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,r){const a=Ql(t,r),s=ec(e,a,r);s in this.freeTextures||(this.freeTextures[s]=[]),s in this.usedTextures||(this.usedTextures[s]=[]);const o=Jl(e,a,this.gpgpu.gl,this.gpgpu.textureConfig,r);if(this.freeTextures[s].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();const u=this.freeTextures[s].shift();return this.usedTextures[s].push(u),u}let i;return a===st.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):a===st.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):a===st.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):a===st.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):a===st.PACKED_4X1_UNSIGNED_BYTE&&(i=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[s].push(i),this.numUsedTextures++,this._numBytesAllocated+=o,this.log(),i}releaseTexture(e,t,r,a){if(this.freeTextures==null)return;const s=Ql(r,a),o=ec(t,s,a);o in this.freeTextures||(this.freeTextures[o]=[]);const i=Jl(t,s,this.gpgpu.gl,this.gpgpu.textureConfig,a),u=H().get("WEBGL_DELET
6607E_TEXTURE_THRESHOLD");u!==-1&&this._numBytesAllocated>u?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=i):(this.freeTextures[o].push(e),this.numFreeTextures++,this._numBytesFree+=i),this.numUsedTextures--;const l=this.usedTextures[o],c=l.indexOf(e);if(c<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(c,1),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const 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(const e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});for(const e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function qk(n,e){const t=n;if(e===t.R32F)return 4;if(e===t.R16F)return 2;if(e===t.RGBA32F||e===n.RGBA)return 16;if(e===t.RGBA16F)return 8;if(e===t.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}function Jl(n,e,t,r,a){const s=Kk(e,r);let o;if(a){const[u,l]=wa(n[0],n[1]);o=u*l}else{const[u,l]=gs(n[0],n[1]);o=u*l}const i=qk(t,s);return o*i}function Kk(n,e){switch(n){case st.PACKED_2X2_FLOAT32:return om(e);case st.PACKED_2X2_FLOAT16:return im(e);case st.UNPACKED_FLOAT32:return rm(e);case st.UNPACKED_FLOAT16:return am(e);case st.PACKED_4X1_UNSIGNED_BYTE:return sm(e);default:throw new Error(`Unknown physical texture type ${n}`)}}function Yk(n){return H().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?st.PACKED_2X2_FLOAT32:st.UNPACKED_FLOAT32:n?st.PACKED_2X2_FLOAT16:st.UNPACKED_FLOAT16}function Ql(n,e){if(n===Mt.UPLOAD)return st.PACKED_2X2_FLOAT32;if(n===Mt.RENDER||n==null)return Yk(e);if(n===Mt.DOWNLOAD||n===Mt.PIXELS)return st.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${n}`)}function ec(n,e,t){return`${n[0]}_${n[1]}_${e}_${t}`}/** 6608 * @license 6609 * Copyright 2017 Google LLC. All Rights Reserved. 6610 * Licensed under the Apache License, Version 2.0 (the "License"); 6611 * you may not use this file except in compliance with the License. 6612 * You may obtain a copy of the License at 6613 * 6614 * http://www.apache.org/licenses/LICENSE-2.0 6615 * 6616 * Unless required by applicable law or agreed to in writing, software 6617 * distributed under the License is distributed on an "AS IS" BASIS, 6618 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6619 * See the License for the specific language governing permissions and 6620 * limitations under the License. 6621 * ============================================================================= 6622 */class $n{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length),this.userCode=` 6623 float unaryOperation(float x) { 6624 ${t} 6625 } 6626 6627 void main() { 6628 float x = getAAtOutCoords(); 6629 float y = unaryOperation(x); 6630 6631 setOutput(y); 6632 } 6633 `}}const tn="if (isnan(x)) return x;",Zk="return x;",tc="return abs(x);",Jk="return (x >= 0.0) ? x : (exp(x) - 1.0);",Qk=tn+` 6634 return (x < 0.0) ? 0.0 : x; 6635`,eT=tn+` 6636 return (x < 0.0) ? 0.0 : min(6.0, x); 6637`,Qr="return x;",tT="return 1.0 / (1.0 + exp(-1.0 * x));";/** 6638 * @license 6639 * Copyright 2018 Google LLC. All Rights Reserved. 6640 * Licensed under the Apache License, Version 2.0 (the "License"); 6641 * you may not use this file except in compliance with the License. 6642 * You may obtain a copy of the License at 6643 * 6644 * http://www.apache.org/licenses/LICENSE-2.0 6645 * 6646 * Unless required by applicable law or agreed to in writing, software 6647 * distributed under the License is distributed on an "AS IS" BASIS, 6648 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6649 * See the License for the specific language governing permissions and 6650 * limitations under the License. 6651 * ============================================================================= 6652 */const nT="return x;",rT=` 6653 vec4 result; 6654 6655 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 6656 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 6657 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 6658 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 6659 6660 return result; 6661`,aT=` 6662 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 6663 bvec4 isNaN = isnan(x); 6664 6665 result.r = isNaN.r ? x.r : result.r; 6666 result.g = isNaN.g ? x.g : result.g; 6667 result.b = isNaN.b ? x.b : result.b; 6668 result.a = isNaN.a ? x.a : result.a; 6669 6670 return result; 6671`,sT=` 6672 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 6673 bvec4 isNaN = isnan(x); 6674 6675 result.r = isNaN.r ? x.r : result.r; 6676 result.g = isNaN.g ? x.g : result.g; 6677 result.b = isNaN.b ? x.b : result.b; 6678 result.a = isNaN.a ? x.a : result.a; 6679 6680 return result; 6681`,oT="return 1.0 / (1.0 + exp(-1.0 * x));";class Ir{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length),this.userCode=` 6682 vec4 unaryOperation(vec4 x) { 6683 ${t} 6684 } 6685 6686 void main() { 6687 vec4 x = getAAtOutCoords(); 6688 vec4 y = unaryOperation(x); 6689 6690 setOutput(y); 6691 } 6692 `}}/** 6693 * @license 6694 * Copyright 2018 Google LLC. All Rights Reserved. 6695 * Licensed under the Apache License, Version 2.0 (the "License");
6696 * you may not use this file except in compliance with the License. 6697 * You may obtain a copy of the License at 6698 * 6699 * http://www.apache.org/licenses/LICENSE-2.0 6700 * 6701 * Unless required by applicable law or agreed to in writing, software 6702 * distributed under the License is distributed on an "AS IS" BASIS, 6703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6704 * See the License for the specific language governing permissions and 6705 * limitations under the License. 6706 * ============================================================================= 6707 */class iT{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length);const t=e.length,r=ft("rc",t),a=Be(t),s=Gk(t,r),o=r.slice(-2),i=t<=1?"rc":`vec2(${o.join(",")})`;this.userCode=` 6708 void main() { 6709 ${a} rc = getOutputCoords(); 6710 vec4 packedInput = getA(${s}); 6711 6712 setOutput(getChannel(packedInput, ${i})); 6713 } 6714 `}}/** 6715 * @license 6716 * Copyright 2017 Google LLC. All Rights Reserved. 6717 * Licensed under the Apache License, Version 2.0 (the "License"); 6718 * you may not use this file except in compliance with the License. 6719 * You may obtain a copy of the License at 6720 * 6721 * http://www.apache.org/licenses/LICENSE-2.0 6722 * 6723 * Unless required by applicable law or agreed to in writing, software 6724 * distributed under the License is distributed on an "AS IS" BASIS, 6725 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6726 * See the License for the specific language governing permissions and 6727 * limitations under the License. 6728 * ============================================================================= 6729 */const uT=o1,lT=1e-7,cT=1e-4,di={};function pT(n){return n in di||(di[n]={}),di[n]}const hT=H().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),dT=600;function fT(){return H().global.screen==null?1024:H().global.screen.height*H().global.screen.width*window.devicePixelRatio*dT/1024/1024}class Lo extends Bc{constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!H().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(e!=null){if(e instanceof hi)t=e;else{const r=pn(H().getNumber("WEBGL_VERSION"),e);t=new hi(r)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const r=pn(H().getNumber("WEBGL_VERSION"));t=new hi(r),this.binaryCache=pT(H().getNumber("WEBGL_VERSION")),this.gpgpuCreatedLocally=!0}this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new Xk(this.gpgpu),this.numMBBeforeWarning=fT(),this.texData=new f2(this,Jr())}nextDataId(){return Lo.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}write(e,t,r){if((H().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||H().getBool("DEBUG"))&&this.checkNumericalProblems(e),r==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const a={id:this.nextDataId()};return this.texData.set(a,{shape:t,dtype:r,values:e,usage:Mt.UPLOAD,refCount:1}),a}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){const t=this.texData.get(e);t.refCount++}decRef(e){if(this.texData.has(e)){const t=this.texData.get(e);t.refCount--}}move(e,t,r,a,s){if(H().getBool("DEBUG")&&this.checkNumericalProblems(t),a==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:r,dtype:a,values:t,usage:Mt.UPLOAD,refCount:s})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:r,dtype:a,complexTensorInfos:s,slice:o,shape:i,isPacked:u}=t;if(o!=null){let h;u?h=new Ir(i,Qr):h=new $n(i,Qr);const d=this.runWebGLProgram(h,[{dataId:e,shape:i,dtype:a}],a),m=this.readSync(d.dataId);return this.disposeIntermediateTensorInfo(d),m}if(r!=null)return this.convertAndCacheOnCPU(e);
vendor: 19,008 bytes, lines 6729-6839
6729if(a==="string")return r;const l=this.activeTimers!=null;let c;l&&(c=an());let p;if(a==="complex64"){const h=this.readSync(s.real.dataId),d=this.readSync(s.imag.dataId);p=su(h,d)}else p=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=an()-c),this.convertAndCacheOnCPU(e,p)}async read(e){if(this.pendingRead.has(e)){const m=this.pendingRead.get(e);return new Promise(y=>m.push(y))}const t=this.texData.get(e),{values:r,shape:a,slice:s,dtype:o,complexTensorInfos:i,isPacked:u}=t;if(s!=null){let m;u?m=new Ir(a,Qr):m=new $n(a,Qr);const y=this.runWebGLProgram(m,[{dataId:e,shape:a,dtype:o}],o),b=this.read(y.dataId);return this.disposeIntermediateTensorInfo(y),b}if(r!=null)return this.convertAndCacheOnCPU(e);if(H().getBool("DEBUG")&&!H().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&H().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,c;if(o!=="complex64"&&H().get("WEBGL_BUFFER_SUPPORTED")){c=this.decode(e);const m=this.texData.get(c.dataId);l=this.gpgpu.createBufferFromTexture(m.texture.texture,...Gs(a))}this.pendingRead.set(e,[]),o!=="complex64"&&await this.gpgpu.createAndWaitForFence();let p;if(o==="complex64"){const m=await Promise.all([this.read(i.real.dataId),this.read(i.imag.dataId)]),y=m[0],b=m[1];p=su(y,b)}else if(l==null)p=this.getValuesFromTexture(e);else{const m=ae(a);p=this.gpgpu.downloadFloat32MatrixFromBuffer(l,m)}if(c!=null&&this.disposeIntermediateTensorInfo(c),l!=null){const m=this.gpgpu.gl;ce(m,()=>m.deleteBuffer(l))}const h=this.convertAndCacheOnCPU(e,p),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach(m=>m(h)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&Jr().removeDataId(e,this),this.pendingDeletes--),h}readToGPU(e,t={}){const r=this.texData.get(e),{values:a,shape:s,slice:o,dtype:i,isPacked:u,texture:l}=r;if(i==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(o!=null){let d;u?d=new Ir(s,Qr):d=new $n(s,Qr);const m=this.runWebGLProgram(d,[{dataId:e,shape:s,dtype:i}],i),y=this.readToGPU(m,t);return this.disposeIntermediateTensorInfo(m),y}if(l==null)throw a!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const c=this.decode(e,t.customTexShape),p=Jr().makeTensorFromTensorInfo(c),h=this.texData.get(c.dataId);return Object.assign({tensorRef:p},h.texture)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const r=t.map(a=>ca(a));return He(e.shape,e.dtype,r)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return He(e.shape,e.dtype,t)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){const r=e[t];if(!b6(r))throw H().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")?Error(`The value ${r} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`):Error(`The value ${r} cannot be represented on this device.`)}}getValuesFromTexture(e){const{shape:t,dtype:r,isPacked:a}=this.texData.get(e),s=ae(t);if(H().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const h=this.decode(e),d=this.texData.get(h.dataId),m=this.gpgpu.downloadMatrixFromPackedTexture(d.texture.texture,...Gs(t)).subarray(0,s);return this.disposeIntermediateTensorInfo(h),m}const o=H().getBool("WEBGL_PACK")&&a===!0,i=o?li(t):t,u=o?new DS(i):new FS(i),l=this.runWebGLProgram(u,[{shape:i,dtype:r,dataId:e}],"float32"),c=this.texData.get(l.dataId),p=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(c.texture.texture,c.texShape[0],c.texShape[1]).subarray(0,s);return this.disposeIntermediateTensorInfo(l),p}timerAvailable(){return H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(e){const t=this.activeTimers,r=[];let a=!1;this.programTimersStack==null?(this.programTimersStack=r,a=!0):this.activeTimers.push(r),this.activeTimers=r,e();const s=ia(this.activeTimers.map(u=>u.query)).filter(u=>u!=null),o=ia(this.activeTimers.map(u=>u.name)).filter(u=>u!=null);this.activeTimers=t,a&&(this.programTimersStack=null);const i={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const u=await Promise.all(s);i.kernelMs=m2(u),i.getExtraProfileInfo=()=>u.map((l,c)=>({name:o[c],ms:l})).map(l=>`${l.name}: ${l.ms}`).join(", ")}else i.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,i})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:an(),endMs:null}}endTimer(e){return H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=an(),e)}async getQueryTime(e){if(H().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:r}=this.texData.get(e);return r!=null&&(this.disposeData(r.real.dataId,t),this.disposeData(r.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:r,texShape:a,usage:s,isPacked:o,slice:i}=this.texData.get(e),u=i&&i.origDataId||e,l=this.dataRefCount.get(u);l>1?this.dataRefCount.set(u,l-1):(this.dataRefCount.delete(u),t!=null&&(this.numBytesInGPU-=this.computeBytes(a,r),this.textureManager.releaseTexture(t,a,s,o)));const c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=hT){return H().getBool("WEBGL_CPU_FORWARD")&&e.every(r=>this.texData.get(r.dataId).texture==null&&ae(r.shape)<t)}getGPGPUContext(){return this.gpgpu}where(e){ln("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return uT(e.shape,t)}packedUnaryOp(e,t,r){const a=new Ir(e.shape,t),s=this.compileAndRun(a,[e],r);return Jr().makeTensorFromTensorInfo(s)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){const a=pm(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,a)}if(H().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,tc,e.dtype);const t=new $n(e.shape,tc),r=this.compileAndRun(t,[e]);return Jr().makeTensorFromTensorInfo(r)}makeTensorInfo(e,t,r){let a;if(t==="string"&&r!=null&&r.length>0&&bo(r[0])){const s=r.map(o=>Nr(o));a=this.write(s,e,t)}else a=this.write(r,e,t);return this.texData.get(a).usage=null,{dataId:a,shape:e,dtype:t}}makeOutput(e,t,r){return Jr().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,r),this)}unpackTensor(e){const t=new iT(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new jk(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const r=[da(e.shape),...fa(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},s=[da(t),...fa(t)],o=new fm(s,r),i=!0,u=[r],l=this.runWebGLProgram(o,[a],e.dtype,u,i);return{dataId:l.dataId,shape:t,dtype:l.dtype}}decode(e,t){const r=this.texData.get(e),{isPacked:a,shape:s,dtype:o}=r;if(t!=null){const h=ae(s),d=t[0]*t[1]*4;R(h<=d,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const i=li(s);let u;a?u=new OS(i):u=new AS(i);const l=!0,c=[t??Gs(i)],p=this.runWebGLProgram(u,[{shape:i,dtype:o,dataId:e}],o,c,l,t);return{dtype:o,shape:s,dataId:p.dataId}}runWebGLProgram(e,t,r,a,s=!1,o){const i=this.makeTensorInfo(e.outputShape,r),u=this.texData.get(i.dataId);if(e.packedOutput&&(u.isPacked=!0),e.outPackingScheme===us.DENSE){const x=o??Gs(e.outputShape);u.texShape=x.map(T=>T*2)}if(e.outTexUsage!=null&&(u.usage=e.outTexUsage),ae(i.shape)===0)return u.values=On(i.dtype,0),i;const l=[],c=t.map(x=>{if(x.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let T=this.texData.get(x.dataId);if(T.texture==null){if(!e.packedInputs&&ae(x.shape)<=H().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:x.shape,texData:null,isUniform:!0,uniformValues:T.values};e.packedInputs&&(T.isPacked=!0,T.shape=x.shape)}if(this.uploadToGPU(x.dataId),!!T.isPacked!=!!e.packedInputs)x=T.isPacked?this.unpackTensor(x):this.packTensor(x),l.push(x),T=this.texData.get(x.dataId);else if(T.isPacked&&!lo(T.shape,x.shape)){const $=x,F=x.shape;x.shape=T.shape,x=this.packedReshape(x,F),l.push(x),T=this.texData.get(x.dataId),$.shape=F}return{shape:x.shape,texData:T,isUniform:!1}});this.uploadToGPU(i.dataId);const p={shape:i.shape,texData:u,isUniform:!1},h=_S(e,c,p),d=this.getAndSaveBinary(h,()=>$S(this.gpgpu,e,c,p)),m=this.activeTimers!=null;let y;m&&(y=this.startTimer()),H().get("ENGINE_COMPILE_ONLY")||RS(this.gpgpu,d,c,p,a),l.forEach(x=>this.disposeIntermediateTensorInfo(x)),m&&(y=this.endTimer(y),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(y)}));const b=H().get("WEBGL_FLUSH_THRESHOLD");if(b>0){const x=an();x-this.lastGlFlushTime>b&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=x)}if(!H().getBool("WEBGL_LAZILY_UNPACK")&&u.isPacked&&s===!1){const x=this.unpackTensor(i);return this.disposeIntermediateTensorInfo(i),x}return i}compileAndRun(e,t,r,a,s=!1){return r=r||t[0].dtype,this.runWebGLProgram(e,t,r,a,s)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(H().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=Xe(()=>{if(!H().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=H().getBool("DEBUG");H().set("DEBUG",!1);const t=this.abs(Ae(1e-8)).dataSync()[0];if(H().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?lT:cT}uploadToGPU(e){const t=this.texData.get(e),{shape:r,dtype:a,values:s,texture:o,usage:i,isPacked:u}=t;if(o!=null)return;const l=this.activeTimers!=null;let c;l&&(c=an());let p=t.texShape;if(p==null&&(p=L6(r,u),t.texShape=p),s!=null){const h=li(r);let d,m=p[1],y=p[0];const b=s instanceof Uint8Array||s instanceof Uint8ClampedArray;(u||!b)&&([m,y]=wa(p[0],p[1])),u?d=new LS(h,b):d=new MS(h,b);const x=b?[y,m]:p,T=this.makeTensorInfo(x,a),$=this.texData.get(T.dataId);b?$.usage=Mt.PIXELS:$.usage=Mt.UPLOAD,$.texShape=x,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(T.dataId),m,y,s);const F=[[y,m]],M=this.runWebGLProgram(d,[T],a,F,!0),U=this.texData.get(M.dataId);t.texShape=U.texShape,t.isPacked=U.isPacked,t.usage=U.usage,H().get("ENGINE_COMPILE_ONLY")?this.disposeData(M.dataId):(t.texture=U.texture,t.values=null,this.texData.delete(M.dataId)),this.disposeIntermediateTensorInfo(T),l&&(this.uploadWaitMs+=an()-c)}else{const h=this.acquireTexture(p,i,a,u);t.texture=h}}convertAndCacheOnCPU(e,t){const r=this.texData.get(e),{dtype:a}=r;return this.releaseGPUData(e),t!=null&&(r.values=mT(t,a)),r.values}acquireTexture(e,t,r,a){if(this.numBytesInGPU+=this.computeBytes(e,r),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){const s=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${s} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,a)}computeBytes(e,t){return e[0]*e[1]*Ci(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}else{for(const[,t]of Object.entries(this.binaryCache)){const r=new Promise(a=>{try{this.checkCompletion_(t),a(!0)}catch(s){throw s}});e.push(r)}return Promise.all(e)}}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await Qw(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)===!1)throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS)===!1?(Z1(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.")):new Error("Failed to link vertex and fragment shaders.");return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:r,infLoc:a,nanLoc:s,inShapesLocations:o,inTexShapesLocations:i,outShapeLocation:u,outShapeStridesLocation:l,outTexShapeLocation:c}=nm(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=r,e.infLoc=a,e.nanLoc=s,e.inShapesLocations=o,e.inTexShapesLocations=i,e.outShapeLocation=u,e.outShapeStridesLocation=l,e.outTexShapeLocation=c}}}Lo.nextDataId=0;function mT(n,e){if(e==="float32"||e==="complex64")return n;if(e==="int32"||e==="bool"){const t=e==="int32"?new Int32Array(n.length):new Uint8Array(n.length);for(let r=0;r<t.length;++r)t[r]=Math.round(n[r]);return t}else throw new Error(`Unknown dtype ${e}`)}/** 6730 * @license 6731 * Copyright 2020 Google Inc. All Rights Reserved. 6732 * Licensed under the Apache License, Version 2.0 (the "License"); 6733 * you may not use this file except in compliance with the License. 6734 * You may obtain a copy of the License at 6735 * 6736 * http://www.apache.org/licenses/LICENSE-2.0 6737 * 6738 * Unless required by applicable law or agreed to in writing, software 6739 * distributed under the License is distributed on an "AS IS" BASIS, 6740 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6741 * See the License for the specific language governing permissions and 6742 * limitations under the License. 6743 * ============================================================================= 6744 */Ud()&&p0("webgl",()=>new Lo,2);/** 6745 * @license 6746 * Copyright 2017 Google LLC. All Rights Reserved. 6747 * Licensed under the Apache License, Version 2.0 (the "License"); 6748 * you may not use this file except in compliance with the License. 6749 * You may obtain a copy of the License at 6750 * 6751 * http://www.apache.org/licenses/LICENSE-2.0 6752 * 6753 * Unless required by applicable law or agreed to in writing, software 6754 * distributed under the License is distributed on an "AS IS" BASIS, 6755 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6756 * See the License for the specific language governing permissions and 6757 * limitations under the License. 6758 * ============================================================================= 6759 */const ul=` 6760 if (isnan(a)) return a; 6761 if (isnan(b)) return b; 6762`;class ma{constructor(e,t,r){this.variableNames=["A","B"],this.outputShape=$e(t,r),this.enableShapeUniforms=bt(this.outputShape.length),this.userCode=` 6763 float binaryOperation(float a, float b) { 6764 ${e} 6765 } 6766 6767 void main() { 6768 float a = getAAtOutCoords(); 6769 float b = getBAtOutCoords(); 6770 setOutput(binaryOperation(a, b)); 6771 } 6772 `}}/** 6773 * @license 6774 * Copyright 2018 Google LLC. All Rights Reserved. 6775 * Licensed under the Apache License, Version 2.0 (the "License"); 6776 * you may not use this file except in compliance with the License. 6777 * You may obtain a copy of the License at 6778 * 6779 * http://www.apache.org/licenses/LICENSE-2.0 6780 * 6781 * Unless required by applicable law or agreed to in writing, software 6782 * distributed under the License is distributed on an "AS IS" BASIS, 6783 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6784 * See the License for the specific language governing permissions and 6785 * limitations under the License. 6786 * ============================================================================= 6787 */const bs=` 6788 result.r = isNaN.r ? NAN : result.r; 6789 result.g = isNaN.g ? NAN : result.g; 6790 result.b = isNaN.b ? NAN : result.b; 6791 result.a = isNaN.a ? NAN : result.a; 6792`;class vs{constructor(e,t,r,a=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=$e(t,r);const s=this.outputShape.length;this.enableShapeUniforms=bt(s);let o="";if(a)if(s===0||ae(this.outputShape)===1)o=` 6793 result.y = 0.; 6794 result.z = 0.; 6795 result.w = 0.; 6796 `;else if(o=` 6797 ${Be(s)} coords = getOutputCoords(); 6798 `,s===1)this.enableShapeUniforms?o+=` 6799 result.y = (coords + 1) >= outShape ? 0. : result.y; 6800 result.z = 0.; 6801 result.w = 0.; 6802 `:o+=` 6803 result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y; 6804 result.z = 0.; 6805 result.w = 0.; 6806 `;else{const i=ft("coords",s);this.enableShapeUniforms?o+=` 6807 bool nextRowOutOfBounds = 6808 (${i[s-2]} + 1) >= outShape[${s} - 2]; 6809 bool nextColOutOfBounds = 6810 (${i[s-1]} + 1) >= outShape[${s} - 1]; 6811 result.y = nextColOutOfBounds ? 0. : result.y; 6812 result.z = nextRowOutOfBounds ? 0. : result.z; 6813 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 6814 `:o+=` 6815 bool nextRowOutOfBounds = 6816 (${i[s-2]} + 1) >= ${this.outputShape[s-2]}; 6817 bool nextColOutOfBounds = 6818 (${i[s-1]} + 1) >= ${this.outputShape[s-1]}; 6819 result.y = nextColOutOfBounds ? 0. : result.y; 6820 result.z = nextRowOutOfBounds ? 0. : result.z; 6821 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 6822 `}this.userCode=` 6823 vec4 binaryOperation(vec4 a, vec4 b) { 6824 ${e} 6825 } 6826 6827 void main() { 6828 vec4 a = getAAtOutCoords(); 6829 vec4 b = getBAtOutCoords(); 6830 6831 vec4 result = binaryOperation(a, b); 6832 ${o} 6833 6834 setOutput(result); 6835 } 6836 `}}/** 6837 * @license 6838 * Copyright 2020 Google LLC. All Rights Reserved. 6839 * Licensed under the Apache License, Version 2.0 (the "License");
6840 * you may not use this file except in compliance with the License. 6841 * You may obtain a copy of the License at 6842 * 6843 * http://www.apache.org/licenses/LICENSE-2.0 6844 * 6845 * Unless required by applicable law or agreed to in writing, software 6846 * distributed under the License is distributed on an "AS IS" BASIS, 6847 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6848 * See the License for the specific language governing permissions and 6849 * limitations under the License. 6850 * ============================================================================= 6851 */function Rt(n){const{inputs:e,backend:t}=n,{x:r}=e;return t.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const gT={kernelName:Nu,backendName:"webgl",kernelFunc:Rt};/** 6852 * @license 6853 * Copyright 2020 Google LLC. All Rights Reserved. 6854 * Licensed under the Apache License, Version 2.0 (the "License"); 6855 * you may not use this file except in compliance with the License. 6856 * You may obtain a copy of the License at 6857 * 6858 * http://www.apache.org/licenses/LICENSE-2.0 6859 * 6860 * Unless required by applicable law or agreed to in writing, software 6861 * distributed under the License is distributed on an "AS IS" BASIS, 6862 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6863 * See the License for the specific language governing permissions and 6864 * limitations under the License. 6865 * ============================================================================= 6866 */function ir(n){const{inputs:e,backend:t}=n,{real:r,imag:a}=e,s=t.makeTensorInfo(r.shape,"complex64"),o=t.texData.get(s.dataId),i=Rt({inputs:{x:r},backend:t}),u=Rt({inputs:{x:a},backend:t});return o.complexTensorInfos={real:i,imag:u},s}const yT={kernelName:hp,backendName:"webgl",kernelFunc:ir};/** 6867 * @license 6868 * Copyright 2020 Google LLC. All Rights Reserved. 6869 * Licensed under the Apache License, Version 2.0 (the "License"); 6870 * you may not use this file except in compliance with the License. 6871 * You may obtain a copy of the License at 6872 * 6873 * http://www.apache.org/licenses/LICENSE-2.0 6874 * 6875 * Unless required by applicable law or agreed to in writing, software 6876 * distributed under the License is distributed on an "AS IS" BASIS, 6877 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6878 * See the License for the specific language governing permissions and 6879 * limitations under the License. 6880 * ============================================================================= 6881 */const mm="return (a < 0.) ? b * a : a;",gm=` 6882 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
6883 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 6884`;function xT(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{alpha:s}=r,o=t.makeTensorInfo([],"float32",ya(s,"float32")),i=H().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vs(gm,a.shape,o.shape):new ma(mm,a.shape,o.shape),u=t.runWebGLProgram(i,[a,o],"float32");return t.disposeIntermediateTensorInfo(o),u}const bT={kernelName:th,backendName:"webgl",kernelFunc:xT};/** 6885 * @license 6886 * Copyright 2020 Google LLC. All Rights Reserved. 6887 * Licensed under the Apache License, Version 2.0 (the "License"); 6888 * you may not use this file except in compliance with the License. 6889 * You may obtain a copy of the License at 6890 * 6891 * http://www.apache.org/licenses/LICENSE-2.0 6892 * 6893 * Unless required by applicable law or agreed to in writing, software 6894 * distributed under the License is distributed on an "AS IS" BASIS, 6895 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6896 * See the License for the specific language governing permissions and 6897 * limitations under the License. 6898 * ============================================================================= 6899 */const ym="return (a < 0.) ? b * a : a;",xm=` 6900 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
6901 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 6902`;function vT(n){const{inputs:e,backend:t}=n,{x:r,alpha:a}=e,s=H().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vs(xm,r.shape,a.shape):new ma(ym,r.shape,a.shape);return t.runWebGLProgram(s,[r,a],"float32")}const wT={kernelName:Oh,backendName:"webgl",kernelFunc:vT};/** 6903 * @license 6904 * Copyright 2020 Google LLC. All Rights Reserved. 6905 * Licensed under the Apache License, Version 2.0 (the "License"); 6906 * you may not use this file except in compliance with the License. 6907 * You may obtain a copy of the License at 6908 * 6909 * http://www.apache.org/licenses/LICENSE-2.0 6910 * 6911 * Unless required by applicable law or agreed to in writing, software 6912 * distributed under the License is distributed on an "AS IS" BASIS, 6913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6914 * See the License for the specific language governing permissions and 6915 * limitations under the License. 6916 * ============================================================================= 6917 */const Ca="if (isnan(x)) return x;";function Ie({opSnippet:n,packedOpSnippet:e,cpuKernelImpl:t,dtype:r}){return({inputs:a,backend:s})=>{const{x:o}=a,i=s,u=r||o.dtype;if(i.shouldExecuteOnCPU([o])&&t!=null){const p=i.texData.get(o.dataId),h=t(p.values,u);return i.makeTensorInfo(o.shape,u,h)}const l=H().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let c;return l?c=new Ir(o.shape,e):c=new $n(o.shape,n),i.runWebGLProgram(c,[o],u)}}function ut({opSnippet:n,packedOpSnippet:e,checkOutOfBounds:t=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:s}){return({inputs:o,backend:i})=>{const{a:u,b:l}=o,c=i;
vendor: 3,555 bytes, lines 6917-6953
6917if(r&&u.dtype==="complex64"){const m=c.texData.get(u.dataId),y=c.texData.get(l.dataId),[b,x]=[[m.complexTensorInfos.real,y.complexTensorInfos.real],[m.complexTensorInfos.imag,y.complexTensorInfos.imag]].map($=>{const[F,M]=$,U={dataId:F.dataId,dtype:F.dtype,shape:u.shape},X={dataId:M.dataId,dtype:M.dtype,shape:l.shape},z=new ma(n,u.shape,l.shape);return c.runWebGLProgram(z,[U,X],Sn(F.dtype,M.dtype))}),T=ir({inputs:{real:b,imag:x},backend:c});return c.disposeIntermediateTensorInfo(b),c.disposeIntermediateTensorInfo(x),T}const p=s||Sn(u.dtype,l.dtype);if((u.dtype==="string"||l.dtype==="string"||c.shouldExecuteOnCPU([u,l]))&&a!=null){const m=c.texData.get(u.dataId).values,y=c.texData.get(l.dataId).values,b=u.dtype==="string"?is(m):m,x=u.dtype==="string"?is(y):y,[T,$]=a(u.shape,l.shape,b,x,p),F=c.makeTensorInfo($,p),M=c.texData.get(F.dataId);return M.values=T,F}const h=H().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let d;return h?d=new vs(e,u.shape,l.shape,t):d=new ma(n,u.shape,l.shape),c.runWebGLProgram(d,[u,l],p)}}function ls(n,e=!1){if(n==="linear")return e?nT:Zk;if(n==="relu")return e?aT:Qk;if(n==="elu")return e?rT:Jk;if(n==="relu6")return e?sT:eT;if(n==="prelu")return e?xm:ym;if(n==="leakyrelu")return e?gm:mm;if(n==="sigmoid")return e?oT:tT;throw new Error(`Activation ${n} has not been implemented for the WebGL backend.`)}/** 6918 * @license 6919 * Copyright 2018 Google LLC. All Rights Reserved. 6920 * Licensed under the Apache License, Version 2.0 (the "License"); 6921 * you may not use this file except in compliance with the License. 6922 * You may obtain a copy of the License at 6923 * 6924 * http://www.apache.org/licenses/LICENSE-2.0 6925 * 6926 * Unless required by applicable law or agreed to in writing, software 6927 * distributed under the License is distributed on an "AS IS" BASIS, 6928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6929 * See the License for the specific language governing permissions and 6930 * limitations under the License. 6931 * ============================================================================= 6932 */class bm{constructor(e,t,r,a=!1,s=!1,o=!1,i=null,u=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r,this.enableShapeUniforms=bt(this.outputShape.length);const c=a?e[1]:e[2],p=Math.ceil(c/2),h=a?"i * 2, rc.y":"rc.y, i * 2",d=s?"rc.z, i * 2":"i * 2, rc.z",m=a?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],y=s?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let b="",x="";i&&(u?b=`vec4 activation(vec4 a) { 6933 vec4 b = getPreluActivationWeightsAtOutCoords(); 6934 ${i} 6935 }`:l?b=`vec4 activation(vec4 a) { 6936 vec4 b = getLeakyreluAlphaAtOutCoords(); 6937 ${i} 6938 }`:b=`vec4 activation(vec4 x) { 6939 ${i} 6940 }`,x="result = activation(result);");const T=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),u&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let $="rc.x",F="rc.x";e[0]<t[0]?$=`int(min(float(rc.x), ${e[0]-1}.))`:t[0]<e[0]&&(F=`int(min(float(rc.x), ${t[0]-1}.))`),this.userCode=` 6941 ${b} 6942 // Don't use uniform for sharedDimensionPacked for performance. 6943 const float sharedDimension = ${p}.0; 6944 6945 vec4 dot2x2ARowBCol(ivec3 rc) { 6946 vec4 result = vec4(0); 6947 for (int i = 0; i < ${p}; i++) { 6948 int batchA = ${$}; 6949 int batchB = ${F}; 6950 vec4 a = getMatrixA(batchA, ${h}); 6951 vec4 b = getMatrixB(batchB, ${d}); 6952 6953 // These swizzled products need to be separately added.
6954 // See: https://github.com/tensorflow/tfjs/issues/1735 6955 result += (${m[0]} * ${y[0]}); 6956 result += (${m[1]} * ${y[1]}); 6957 } 6958 return result; 6959 } 6960 6961 void main() { 6962 ivec3 rc = getOutputCoords(); 6963 vec4 result = dot2x2ARowBCol(rc); 6964 6965 ${T} 6966 6967 ${x} 6968 6969 setOutput(result); 6970 } 6971 `}}/** 6972 * @license 6973 * Copyright 2018 Google LLC. All Rights Reserved. 6974 * Licensed under the Apache License, Version 2.0 (the "License"); 6975 * you may not use this file except in compliance with the License. 6976 * You may obtain a copy of the License at 6977 * 6978 * http://www.apache.org/licenses/LICENSE-2.0 6979 * 6980 * Unless required by applicable law or agreed to in writing, software 6981 * distributed under the License is distributed on an "AS IS" BASIS, 6982 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6983 * See the License for the specific language governing permissions and 6984 * limitations under the License. 6985 * ============================================================================= 6986 */const nc={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class rc{constructor(e,t,r){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=$e(t,r),this.userCode=` 6987 float binaryOpComplex( 6988 float areal, float aimag, float breal, float bimag) { 6989 ${e} 6990 } 6991 6992 void main() { 6993 float areal = getARealAtOutCoords(); 6994 float aimag = getAImagAtOutCoords(); 6995 float breal = getBRealAtOutCoords(); 6996 float bimag = getBImagAtOutCoords(); 6997 setOutput(binaryOpComplex(areal, aimag, breal, bimag)); 6998 } 6999 `}}/** 7000 * @license 7001 * Copyright 2020 Google LLC. All Rights Reserved. 7002 * Licensed under the Apache License, Version 2.0 (the "License"); 7003 * you may not use this file except in compliance with the License. 7004 * You may obtain a copy of the License at 7005 * 7006 * http://www.apache.org/licenses/LICENSE-2.0 7007 * 7008 * Unless required by applicable law or agreed to in writing, software 7009 * distributed under the License is distributed on an "AS IS" BASIS, 7010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7011 * See the License for the specific language governing permissions and 7012 * limitations under the License. 7013 * ============================================================================= 7014 */const ac="return a * b;";function ll(n){const{inputs:e,backend:t}=n,{a:r,b:a}=e,s=Sn(r.dtype,a.dtype);if(r.dtype==="complex64"){const i=t.texData.get(r.dataId),u=t.texData.get(a.dataId),l=new rc(nc.REAL,r.shape,a.shape),c=new rc(nc.IMAG,r.shape,a.shape),p=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:r.shape},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:u.complexTensorInfos.real.dataId,dtype:u.complexTensorInfos.real.dtype,shape:a.shape},{dataId:u.complexTensorInfos.imag.dataId,dtype:u.complexTensorInfos.imag.dtype,shape:a.shape}],h=t.runWebGLProgram(l,p,"float32"),d=t.runWebGLProgram(c,p,"float32"),m=ir({inputs:{real:h,imag:d},backend:t});return t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),m}if(t.shouldExecuteOnCPU([r,a])){const i=t.texData.get(r.dataId),u=t.texData.get(a.dataId),[l,c]=Sk(r.shape,a.shape,i.values,u.values,s),p=t.makeTensorInfo(c,s),h=t.texData.get(p.dataId);return h.values=l,p}let o;return H().getBool("WEBGL_PACK_BINARY_OPERATIONS")?o=new vs(ac,r.shape,a.shape):o=new ma(ac,r.shape,a.shape),t.runWebGLProgram(o,[r,a],s)}const ST={kernelName:Sh,backendName:"webgl",kernelFunc:ll};/** 7015 * @license 7016 * Copyright 2020 Google LLC. All Rights Reserved. 7017 * Licensed under the Apache License, Version 2.0 (the "License"); 7018 * you may not use this file except in compliance with the License. 7019 * You may obtain a copy of the License at 7020 * 7021 * http://www.apache.org/licenses/LICENSE-2.0 7022 * 7023 * Unless required by applicable law or agreed to in writing, software 7024 * distributed under the License is distributed on an "AS IS" BASIS, 7025 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7026 * See the License for the specific language governing permissions and 7027 * limitations under the License. 7028 * ============================================================================= 7029 */function kT(n,e,t){const r=[da(n.shape),...fa(n.shape)],a={dtype:n.dtype,shape:r,dataId:n.dataId},s=[da(e),...fa(e)],o=new fm(s,r),i=!0,u=[r],l=t.runWebGLProgram(o,[a],n.dtype,u,i);return{dataId:l.dataId,shape:e,dtype:l.dtype}}/** 7030 * @license 7031 * Copyright 2020 Google LLC. All Rights Reserved. 7032 * Licensed under the Apache License, Version 2.0 (the "License");
7033 * you may not use this file except in compliance with the License. 7034 * You may obtain a copy of the License at 7035 * 7036 * http://www.apache.org/licenses/LICENSE-2.0 7037 * 7038 * Unless required by applicable law or agreed to in writing, software 7039 * distributed under the License is distributed on an "AS IS" BASIS, 7040 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7041 * See the License for the specific language governing permissions and 7042 * limitations under the License. 7043 * ============================================================================= 7044 */function oe(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{shape:s}=r,o=t,i=ae(a.shape),u=g2(s,i),l=ae(u);R(i===l,()=>`The new shape (${u}) has ${l} elements and the old shape (${a.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);const c=o.texData.get(a.dataId);return c.isPacked&&!lo(a.shape,u)&&!(c.texture!==null&&lo(c.shape,u))?kT(a,u,o):(o.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype})}const TT={kernelName:Vh,backendName:"webgl",kernelFunc:oe};/** 7045 * @license 7046 * Copyright 2020 Google LLC. All Rights Reserved. 7047 * Licensed under the Apache License, Version 2.0 (the "License"); 7048 * you may not use this file except in compliance with the License. 7049 * You may obtain a copy of the License at 7050 * 7051 * http://www.apache.org/licenses/LICENSE-2.0 7052 * 7053 * Unless required by applicable law or agreed to in writing, software 7054 * distributed under the License is distributed on an "AS IS" BASIS, 7055 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7056 * See the License for the specific language governing permissions and 7057 * limitations under the License. 7058 * ============================================================================= 7059 */class sc{constructor(e,t){this.variableNames=["x"];const{windowSize:r,batchSize:a,inSize:s,outSize:o}=e;this.outputShape=[a,o];const i=Math.floor(r/4)*4,u=r%4;let l="sumValue += dot(values, ones);";if(t!=null){const p=1/t;l=`sumValue += dot(values * ${ua(p)?p.toPrecision(2):p}, ones);`}let c="";s%r>0&&(c=` 7060 if (inIdx < 0 || inIdx >= ${s}) { 7061 return 0.0; 7062 } 7063 `),this.userCode=` 7064 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 7065 7066 float getValue(int batch, int inIdx) { 7067 ${c} 7068 return getX(batch, inIdx); 7069 } 7070 7071 void main() { 7072 ivec2 coords = getOutputCoords(); 7073 int batch = coords[0]; 7074 int outIdx = coords[1]; 7075 int inOffset = outIdx * ${r}; 7076 7077 float sumValue = 0.0; 7078 7079 for (int i = 0; i < ${i}; i += 4) { 7080 int inIdx = inOffset + i; 7081 vec4 values = vec4( 7082 getValue(batch, inIdx), 7083 getValue(batch, inIdx + 1), 7084 getValue(batch, inIdx + 2), 7085 getValue(batch, inIdx + 3) 7086 ); 7087 7088 ${l} 7089 } 7090 7091 int inIdx = inOffset + ${i}; 7092 if (${u===1}) { 7093 vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0); 7094 7095 ${l} 7096 } else if (${u===2}) { 7097 vec4 values = vec4( 7098 getValue(batch, inIdx), 7099 getValue(batch, inIdx + 1), 0.0, 0.0); 7100 7101 ${l} 7102 } else if (${u===3}) { 7103 vec4 values = vec4( 7104 getValue(batch, inIdx), 7105 getValue(batch, inIdx + 1), 7106 getValue(batch, inIdx + 2), 0.0); 7107 7108 ${l} 7109 } 7110 setOutput(sumValue); 7111 } 7112 `}}/** 7113 * @license 7114 * Copyright 2017 Google LLC. All Rights Reserved. 7115 * Licensed under the Apache License, Version 2.0 (the "License"); 7116 * you may not use this file except in compliance with the License. 7117 * You may obtain a copy of the License at 7118 * 7119 * http://www.apache.org/licenses/LICENSE-2.0 7120 * 7121 * Unless required by applicable law or agreed to in writing, software 7122 * distributed under the License is distributed on an "AS IS" BASIS, 7123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7124 * See the License for the specific language governing permissions and 7125 * limitations under the License. 7126 * ============================================================================= 7127 */class ET{constructor(e,t){this.variableNames=["x"];const{windowSize:r,batchSize:a,inSize:s,outSize:o}=e;this.outputShape=[a,o];let i="0.0",u="";t==="prod"?i="1.0":t==="min"?(i="1.0 / 1e-20",u="min"):t==="max"&&(i="-1.0 / 1e-20",u="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");const c=Math.floor(r/4)*4,p=r%4;let h=` 7128 if (${t==="sum"}) { 7129 sumValue += dot(values, ones); 7130 } else if (${t==="prod"}) { 7131 vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]); 7132 prodValue *= tmp[0] * tmp[1]; 7133 } else { 7134 minMaxValue = ${u}(values, minMaxValue); 7135 if (${t==="min"} || ${t==="max"}) { 7136 minMaxValue = ${u}(values, minMaxValue); 7137 bvec4 isNaN = isnan(values); 7138 if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) { 7139 minMaxValue = vec4(NAN); 7140 } 7141 } 7142 } 7143 `,d="vec4";t==="all"?(i="1.0",h=` 7144 bool reducedAllValue = all(values); 7145 float floatedReducedAllValue = float(reducedAllValue); 7146 allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0); 7147 `,d="bvec4"):t==="any"&&(i="0.0",h=` 7148 bool reducedAnyValue = any(values); 7149 float floatedReducedAnyValue = float(reducedAnyValue); 7150 anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0); 7151 `,d="bvec4");let m="";s%r>0&&(m=` 7152 if (inIdx < 0 || inIdx >= ${s}) { 7153 return initializationValue; 7154 } 7155 `),this.userCode=` 7156 const float initializationValue = ${i}; 7157 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 7158 7159 float getValue(int batch, int inIdx) { 7160 ${m} 7161 return getX(batch, inIdx); 7162 } 7163 7164 void main() { 7165 ivec2 coords = getOutputCoords(); 7166 int batch = coords[0]; 7167 int outIdx = coords[1]; 7168 int inOffset = outIdx * ${r}; 7169 7170 vec4 minMaxValue = vec4(${i}); 7171 float prodValue = 1.0; 7172 float sumValue = 0.0; 7173 float allValue = 1.0; 7174 float anyValue = 0.0; 7175 7176 for (int i = 0; i < ${c}; i += 4) { 7177 int inIdx = inOffset + i; 7178 ${d} values = ${d}( 7179 getValue(batch, inIdx), 7180 getValue(batch, inIdx + 1), 7181 getValue(batch, inIdx + 2), 7182 getValue(batch, inIdx + 3) 7183 ); 7184 7185 ${h} 7186 } 7187 7188 int inIdx = inOffset + ${c}; 7189 if (${p===1}) { 7190 ${d} values = ${d}( 7191 getValue(batch, inIdx), 7192 initializationValue, 7193 initializationValue, 7194 initializationValue 7195 ); 7196 7197 ${h} 7198 } else if (${p===2}) { 7199 ${d} values = ${d}( 7200 getValue(batch, inIdx), 7201 getValue(batch, inIdx + 1), 7202 initializationValue, 7203 initializationValue 7204 ); 7205 7206 ${h} 7207 } else if (${p===3}) { 7208 ${d} values = ${d}( 7209 getValue(batch, inIdx), 7210 getValue(batch, inIdx + 1), 7211 getValue(batch, inIdx + 2), 7212 initializationValue 7213 ); 7214 7215 ${h} 7216 } 7217 setOutput(${l}); 7218 } 7219 `}}/** 7220 * @license 7221 * Copyright 2020 Google LLC. All Rights Reserved. 7222 * Licensed under the Apache License, Version 2.0 (the "License");
7223 * you may not use this file except in compliance with the License. 7224 * You may obtain a copy of the License at 7225 * 7226 * http://www.apache.org/licenses/LICENSE-2.0 7227 * 7228 * Unless required by applicable law or agreed to in writing, software 7229 * distributed under the License is distributed on an "AS IS" BASIS, 7230 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7231 * See the License for the specific language governing permissions and 7232 * limitations under the License. 7233 * ============================================================================= 7234 */function CT(n){const e=[];for(;e.length===0||e[e.length-1].outSize!==1;){const t=e.length?e[e.length-1].outSize:n[1],r=Do(t);e.push({inSize:t,windowSize:r,outSize:Math.ceil(t/r)})}return e}function Wr(n,e,t,r){const a=CT(n.shape);let s=n;for(let o=0;o<a.length;o++){const{inSize:i,windowSize:u,outSize:l}=a[o];let c,p;t==="mean"?c=o===0?new sc({windowSize:u,inSize:i,batchSize:n.shape[0],outSize:l},i):new sc({windowSize:u,inSize:i,batchSize:n.shape[0],outSize:l}):c=new ET({windowSize:u,inSize:i,batchSize:n.shape[0],outSize:l},t),p=s,s=r.runWebGLProgram(c,[s],e),p.dataId!==n.dataId&&r.disposeIntermediateTensorInfo(p)}return s}/** 7235 * @license 7236 * Copyright 2017 Google LLC. All Rights Reserved. 7237 * Licensed under the Apache License, Version 2.0 (the "License"); 7238 * you may not use this file except in compliance with the License. 7239 * You may obtain a copy of the License at 7240 * 7241 * http://www.apache.org/licenses/LICENSE-2.0 7242 * 7243 * Unless required by applicable law or agreed to in writing, software 7244 * distributed under the License is distributed on an "AS IS" BASIS, 7245 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7246 * See the License for the specific language governing permissions and 7247 * limitations under the License. 7248 * ============================================================================= 7249 */class IT{constructor(e,t){this.variableNames=["A"];const r=new Array(e.length);for(let o=0;o<r.length;o++)r[o]=e[t[o]];this.outputShape=r,this.rank=r.length;const a=Be(this.rank),s=NT(t);this.userCode=` 7250 void main() { 7251 ${a} resRC = getOutputCoords(); 7252 setOutput(getA(${s})); 7253 } 7254 `}}function NT(n){const e=n.length;if(e>6)throw Error(`Transpose for rank ${e} is not yet supported`);const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(e);for(let a=0;a<n.length;a++)r[n[a]]=t[a];return r.join()}/** 7255 * @license 7256 * Copyright 2019 Google LLC. All Rights Reserved. 7257 * Licensed under the Apache License, Version 2.0 (the "License"); 7258 * you may not use this file except in compliance with the License. 7259 * You may obtain a copy of the License at 7260 * 7261 * http://www.apache.org/licenses/LICENSE-2.0 7262 * 7263 * Unless required by applicable law or agreed to in writing, software 7264 * distributed under the License is distributed on an "AS IS" BASIS, 7265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7266 * See the License for the specific language governing permissions and 7267 * limitations under the License. 7268 * ============================================================================= 7269 */class $T{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const r=new Array(e.length);for(let c=0;c<r.length;c++)r[c]=e[t[c]];if(this.outputShape=r,this.rank=r.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const a=Be(this.rank),s=dm("rc",this.rank),o=new Array(this.rank);for(let c=0;c<t.length;c++)o[t[c]]=s[c];const i=`vec2(${o.slice(-2).join()})`,u=`++${s[this.rank-1]} < ${r[this.rank-1]}`,l=`getChannel(getA(${o.join()}), ${i})`;this.userCode=` 7270 void main() { 7271 ${a} rc = getOutputCoords(); 7272 vec4 result = vec4(0.); 7273 result[0] = ${l}; 7274 if(${u}) { 7275 result[1] = ${l}; 7276 } 7277 --${s[this.rank-1]}; 7278 if(++${s[this.rank-2]} < ${r[this.rank-2]}) { 7279 result[2] = ${l}; 7280 if(${u}) { 7281 result[3] = ${l}; 7282 } 7283 } 7284 setOutput(result); 7285 } 7286 `}}/** 7287 * @license 7288 * Copyright 2020 Google LLC. All Rights Reserved. 7289 * Licensed under the Apache License, Version 2.0 (the "License");
7290 * you may not use this file except in compliance with the License. 7291 * You may obtain a copy of the License at 7292 * 7293 * http://www.apache.org/licenses/LICENSE-2.0 7294 * 7295 * Unless required by applicable law or agreed to in writing, software 7296 * distributed under the License is distributed on an "AS IS" BASIS, 7297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7298 * See the License for the specific language governing permissions and 7299 * limitations under the License. 7300 * ============================================================================= 7301 */function Po(n,e,t){const r=H().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new $T(n.shape,e):new IT(n.shape,e);return t.runWebGLProgram(r,[n],n.dtype)}/** 7302 * @license 7303 * Copyright 2020 Google LLC. All Rights Reserved. 7304 * Licensed under the Apache License, Version 2.0 (the "License"); 7305 * you may not use this file except in compliance with the License. 7306 * You may obtain a copy of the License at 7307 * 7308 * http://www.apache.org/licenses/LICENSE-2.0 7309 * 7310 * Unless required by applicable law or agreed to in writing, software 7311 * distributed under the License is distributed on an "AS IS" BASIS, 7312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7313 * See the License for the specific language governing permissions and 7314 * limitations under the License. 7315 * ============================================================================= 7316 */function RT(n,e,t,r){const a=e,s=n.shape.length,o=rt(a,n.shape);let i=o;const u=Qt(i,s),l=u!=null;let c=n;l&&(c=Po(n,u,r),i=en(i.length,s)),hn("sum",i,s);const[p,h]=kn(c.shape,i);let d=p;t&&(d=Bt(p,o));const m=ae(h),y=ae(n.shape)/m,b=oe({inputs:{x:c},attrs:{shape:[y,m]},backend:r}),x=Ru(n.dtype),T=Wr(b,x,"sum",r),$=oe({inputs:{x:T},attrs:{shape:d},backend:r});return r.disposeIntermediateTensorInfo(b),r.disposeIntermediateTensorInfo(T),l&&r.disposeIntermediateTensorInfo(c),$}/** 7317 * @license 7318 * Copyright 2020 Google LLC. All Rights Reserved. 7319 * Licensed under the Apache License, Version 2.0 (the "License"); 7320 * you may not use this file except in compliance with the License. 7321 * You may obtain a copy of the License at 7322 * 7323 * http://www.apache.org/licenses/LICENSE-2.0 7324 * 7325 * Unless required by applicable law or agreed to in writing, software 7326 * distributed under the License is distributed on an "AS IS" BASIS, 7327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7328 * See the License for the specific language governing permissions and 7329 * limitations under the License. 7330 * ============================================================================= 7331 */function Bo(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s,keepDims:o}=r;return RT(a,s,o,t)}const _T={kernelName:sd,backendName:"webgl",kernelFunc:Bo};/** 7332 * @license 7333 * Copyright 2020 Google LLC. All Rights Reserved. 7334 * Licensed under the Apache License, Version 2.0 (the "License"); 7335 * you may not use this file except in compliance with the License. 7336 * You may obtain a copy of the License at 7337 * 7338 * http://www.apache.org/licenses/LICENSE-2.0 7339 * 7340 * Unless required by applicable law or agreed to in writing, software 7341 * distributed under the License is distributed on an "AS IS" BASIS, 7342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7343 * See the License for the specific language governing permissions and 7344 * limitations under the License. 7345 * ============================================================================= 7346 */function yt(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{perm:s}=r,o=t,i=a.shape.length,u=new Array(i);for(let c=0;c<u.length;c++)u[c]=a.shape[s[c]];let l;if(o.shouldExecuteOnCPU([a])){const c=o.texData.get(a.dataId).values,p=il(c,a.shape,a.dtype,s,u);l=o.makeTensorInfo(u,a.dtype);const h=o.texData.get(l.dataId);h.values=p}else l=Po(a,s,o);return l}const AT={kernelName:Ks,backendName:"webgl",kernelFunc:yt};/** 7347 * @license 7348 * Copyright 2020 Google LLC. All Rights Reserved. 7349 * Licensed under the Apache License, Version 2.0 (the "License"); 7350 * you may not use this file except in compliance with the License. 7351 * You may obtain a copy of the License at 7352 * 7353 * http://www.apache.org/licenses/LICENSE-2.0 7354 * 7355 * Unless required by applicable law or agreed to in writing, softw
7355are 7356 * distributed under the License is distributed on an "AS IS" BASIS, 7357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7358 * See the License for the specific language governing permissions and 7359 * limitations under the License. 7360 * ============================================================================= 7361 */const vm=1e3;function po({a:n,b:e,transposeA:t,transposeB:r,backend:a,bias:s=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:u=null}){const l=n.shape.length,c=e.shape.length,p=t?n.shape[l-2]:n.shape[l-1],h=r?e.shape[c-1]:e.shape[c-2],d=t?n.shape[l-1]:n.shape[l-2],m=r?e.shape[c-2]:e.shape[c-1],y=n.shape.slice(0,-2),b=e.shape.slice(0,-2),x=ae(y),T=ae(b),$=$e(n.shape.slice(0,-2),e.shape.slice(0,-2)).concat([d,m]);R(p===h,()=>`Error in matMul: inner shapes (${p}) and (${h}) of Tensors with shapes ${n.shape} and ${e.shape} and transposeA=${t} and transposeB=${r} must match.`);const F=t?[x,p,d]:[x,d,p],M=r?[T,m,h]:[T,h,m],U=oe({inputs:{x:n},backend:a,attrs:{shape:F}}),X=oe({inputs:{x:e},backend:a,attrs:{shape:M}}),z=[U,X],L=Math.max(x,T),C=t?U.shape[1]:U.shape[2],q=s!=null,ee=o!=null,te=u==="leakyrelu",le=u!=null?ls(u,!0):null,de=q||ee||te||le!=null;let fe;if((d===1||m===1)&&C>vm&&de===!1){let ge=U,Te=X;t&&(ge=yt({inputs:{x:U},backend:a,attrs:{perm:[0,2,1]}}),z.push(ge)),r&&(Te=yt({inputs:{x:X},backend:a,attrs:{perm:[0,2,1]}}),z.push(Te));const We=m!==1,Ne=m===1;let Ye=ge;We&&(Ye=oe({inputs:{x:ge},backend:a,attrs:{shape:[L,C,1]}}),z.push(Ye));const Vt=m===1?2:1;let Vn=Te;Ne&&(Vn=oe({inputs:{x:Te},backend:a,attrs:{shape:[L,1,C]}}),z.push(Vn));const ur=ll({inputs:{a:Ye,b:Vn},backend:a});fe=Bo({inputs:{x:ur},backend:a,attrs:{axis:Vt,keepDims:!0}}),z.push(ur)}else{const ge=Sn(n.dtype,e.dtype),Te=new bm(F,M,[L,d,m],t,r,q,le,ee,te),We=[U,X];if(s!=null&&We.push(s),ee&&We.push(o),te){const Ne=a.makeTensorInfo([],"float32",ya(i,"float32"));We.push(Ne),z.push(Ne)}fe=a.runWebGLProgram(Te,We,ge)}const Re=oe({inputs:{x:fe},backend:a,attrs:{shape:$}});z.push(fe);for(const ge of z)a.disposeIntermediateTensorInfo(ge);return Re}/** 7362 * @license 7363 * Copyright 2020 Google LLC. All Rights Reserved. 7364 * Licensed under the Apache License, Version 2.0 (the License); 7365 * you may not use this file except in compliance with the License. 7366 * You may obtain a copy of the License at 7367 * 7368 * http://www.apache.org/licenses/LICENSE-2.0 7369 * 7370 * Unless required by applicable law or agreed to in writing, software 7371 * distributed under the License is distributed on an AS IS BASIS, 7372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7373 * See the License for the specific language governing permissions and 7374 * limitations under the License. 7375 * ============================================================================= 7376 */function OT(n){const{inputs:e,backend:t,attrs:r}=n,{a,b:s,bias:o,preluActivationWeights:i}=e,{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:p}=r;return po({a,b:s,transposeA:u,transposeB:l,backend:t,bias:o,preluActivationWeights:i,leakyreluAlpha:p,activation:c})}const FT={kernelName:_i,backendName:"webgl",kernelFunc:OT};/** 7377 * @license 7378 * Copyright 2020 Google LLC. All Rights Reserved. 7379 * Licensed under the Apache License, Version 2.0 (the "License"); 7380 * you may not use this file except in compliance with the License. 7381 * You may obtain a copy of the License at 7382 * 7383 * http://www.apache.org/licenses/LICENSE-2.0 7384 * 7385 * Unless required by applicable law or agreed to in writing, software 7386 * distributed under the License is distributed on an "AS IS" BASIS, 7387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7388 * See the License for the specific language governing permissions and 7389 * limitations under the License. 7390 * ============================================================================= 7391 */const oc="return abs(x);";function DT(n){const{inputs:e,backend:t}=n,{x:r}=e;if(t.shouldExecuteOnCPU([r])&&r.dtype!=="complex64"){const s=t.texData.get(r.dataId),o=pm(s.values);return t.makeTensorInfo(r.shape,r.dtype,o)}let a;return H().getBool("WEBGL_PACK_UNARY_OPERATIONS")?a=new Ir(r.shape,oc):a=new $n(r.shape,oc),t.runWebGLProgram(a,[r],r.dtype)}const MT={kernelName:jc,backendName:"webgl",kernelFunc:DT};/** 7392 * @license 7393 * Copyright 2020 Google LLC. All Rights Reserved. 7394 * Licensed under the Apache License, Version 2.0 (the "License");
7395 * you may not use this file except in compliance with the License. 7396 * You may obtain a copy of the License at 7397 * 7398 * http://www.apache.org/licenses/LICENSE-2.0 7399 * 7400 * Unless required by applicable law or agreed to in writing, software 7401 * distributed under the License is distributed on an "AS IS" BASIS, 7402 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7403 * See the License for the specific language governing permissions and 7404 * limitations under the License. 7405 * ============================================================================= 7406 */const LT=tn+` 7407 if (abs(x) > 1.) { 7408 return NAN; 7409 } 7410 return acos(x); 7411`,PT=Ie({opSnippet:LT}),BT={kernelName:Hc,backendName:"webgl",kernelFunc:PT};/** 7412 * @license 7413 * Copyright 2020 Google LLC. All Rights Reserved. 7414 * Licensed under the Apache License, Version 2.0 (the "License"); 7415 * you may not use this file except in compliance with the License. 7416 * You may obtain a copy of the License at 7417 * 7418 * http://www.apache.org/licenses/LICENSE-2.0 7419 * 7420 * Unless required by applicable law or agreed to in writing, software 7421 * distributed under the License is distributed on an "AS IS" BASIS, 7422 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7423 * See the License for the specific language governing permissions and 7424 * limitations under the License. 7425 * ============================================================================= 7426 */const UT=tn+` 7427 if (x < 1.0) return NAN; 7428return log(x + sqrt(x * x - 1.0));`,VT=Ie({opSnippet:UT}),WT={kernelName:Xc,backendName:"webgl",kernelFunc:VT};/** 7429 * @license 7430 * Copyright 2020 Google LLC. All Rights Reserved. 7431 * Licensed under the Apache License, Version 2.0 (the "License"); 7432 * you may not use this file except in compliance with the License. 7433 * You may obtain a copy of the License at 7434 * 7435 * http://www.apache.org/licenses/LICENSE-2.0 7436 * 7437 * Unless required by applicable law or agreed to in writing, software 7438 * distributed under the License is distributed on an "AS IS" BASIS, 7439 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7440 * See the License for the specific language governing permissions and 7441 * limitations under the License. 7442 * ============================================================================= 7443 */const ic="return a + b;",zT=ut({opSnippet:ic,packedOpSnippet:ic,supportsComplex:!0,cpuKernelImpl:nk}),GT={kernelName:Cu,backendName:"webgl",kernelFunc:zT};/** 7444 * @license 7445 * Copyright 2019 Google LLC. All Rights Reserved. 7446 * Licensed under the Apache License, Version 2.0 (the "License"); 7447 * you may not use this file except in compliance with the License. 7448 * You may obtain a copy of the License at 7449 * 7450 * http://www.apache.org/licenses/LICENSE-2.0 7451 * 7452 * Unless required by applicable law or agreed to in writing, software 7453 * distributed under the License is distributed on an "AS IS" BASIS, 7454 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7455 * See the License for the specific language governing permissions and 7456 * limitations under the License. 7457 * ============================================================================= 7458 */class jT{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((s,o)=>`T${o}`);const r=[];this.variableNames.forEach(s=>{r.push(`float v${s} = get${s}AtOutCoords();`)});const a=this.variableNames.map(s=>`v${s}`).join(" + ");this.userCode=` 7459 void main() { 7460 ${r.join(` 7461 `)} 7462 7463 float result = ${a}; 7464 setOutput(result); 7465 } 7466 `}}/** 7467 * @license 7468 * Copyright 2019 Google LLC. All Rights Reserved. 7469 * Licensed under the Apache License, Version 2.0 (the "License"); 7470 * you may not use this file except in compliance with the License. 7471 * You may obtain a copy of the License at 7472 * 7473 * http://www.apache.org/licenses/LICENSE-2.0 7474 * 7475 * Unless required by applicable law or agreed to in writing, software 7476 * distributed under the License is distributed on an "AS IS" BASIS, 7477 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7478 * See the License for the specific language governing permissions and 7479 * limitations under the License. 7480 * ============================================================================= 7481 */class HT{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((s,o)=>`T${o}`);const r=[];
vendor: 9,750 bytes, lines 7481-7649
7481this.variableNames.forEach(s=>{r.push(`vec4 v${s} = get${s}AtOutCoords();`)});const a=this.variableNames.map(s=>`v${s}`).join(" + ");this.userCode=` 7482 void main() { 7483 ${r.join(` 7484 `)} 7485 7486 vec4 result = ${a}; 7487 setOutput(result); 7488 } 7489 `}}/** 7490 * @license 7491 * Copyright 2020 Google LLC. All Rights Reserved. 7492 * Licensed under the Apache License, Version 2.0 (the "License"); 7493 * you may not use this file except in compliance with the License. 7494 * You may obtain a copy of the License at 7495 * 7496 * http://www.apache.org/licenses/LICENSE-2.0 7497 * 7498 * Unless required by applicable law or agreed to in writing, software 7499 * distributed under the License is distributed on an "AS IS" BASIS, 7500 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7501 * See the License for the specific language governing permissions and 7502 * limitations under the License. 7503 * ============================================================================= 7504 */function Js(n){const{inputs:e,backend:t}=n,r=e;if(r.length===1)return Rt({inputs:{x:r[0]},backend:t});if(r.length>H().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const i=Math.floor(r.length/2),u=Js({inputs:r.slice(0,i),backend:t}),l=Js({inputs:r.slice(i),backend:t});return Js({inputs:[u,l],backend:t})}const a=r.map(i=>i.dtype).reduce((i,u)=>Sn(i,u)),s=r.map(i=>i.shape),o=H().getBool("WEBGL_PACK")?new HT(r[0].shape,s):new jT(r[0].shape,s);return t.runWebGLProgram(o,r,a)}const XT={kernelName:qc,backendName:"webgl",kernelFunc:Js};/** 7505 * @license 7506 * Copyright 2020 Google LLC. All Rights Reserved. 7507 * Licensed under the Apache License, Version 2.0 (the "License"); 7508 * you may not use this file except in compliance with the License. 7509 * You may obtain a copy of the License at 7510 * 7511 * http://www.apache.org/licenses/LICENSE-2.0 7512 * 7513 * Unless required by applicable law or agreed to in writing, software 7514 * distributed under the License is distributed on an "AS IS" BASIS, 7515 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7516 * See the License for the specific language governing permissions and 7517 * limitations under the License. 7518 * ============================================================================= 7519 */function qT(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s,keepDims:o}=r,i=a.shape.length,u=rt(s,a.shape);let l=u;const c=Qt(l,i);let p=a;c!=null&&(p=yt({inputs:{x:a},backend:t,attrs:{perm:c}}),l=en(l.length,i)),hn("all",l,i);const[h,d]=kn(p.shape,l),m=ae(d),y=oe({inputs:{x:p},backend:t,attrs:{shape:[-1,m]}}),b=Wr(y,y.dtype,"all",t);let x;if(o){const T=Bt(h,u);x=oe({inputs:{x:b},backend:t,attrs:{shape:T}})}else x=oe({inputs:{x:b},backend:t,attrs:{shape:h}});return t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(b),c!=null&&t.disposeIntermediateTensorInfo(p),x}const KT={kernelName:Kc,backendName:"webgl",kernelFunc:qT};/** 7520 * @license 7521 * Copyright 2020 Google LLC. All Rights Reserved. 7522 * Licensed under the Apache License, Version 2.0 (the "License"); 7523 * you may not use this file except in compliance with the License. 7524 * You may obtain a copy of the License at 7525 * 7526 * http://www.apache.org/licenses/LICENSE-2.0 7527 * 7528 * Unless required by applicable law or agreed to in writing, software 7529 * distributed under the License is distributed on an "AS IS" BASIS, 7530 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7531 * See the License for the specific language governing permissions and 7532 * limitations under the License. 7533 * ============================================================================= 7534 */function YT(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s,keepDims:o}=r,i=a.shape.length,u=rt(s,a.shape);let l=u;const c=Qt(l,i);let p=a;c!=null&&(p=yt({inputs:{x:a},backend:t,attrs:{perm:c}}),l=en(l.length,i)),hn("any",l,i);const[h,d]=kn(p.shape,l),m=ae(d),y=oe({inputs:{x:p},backend:t,attrs:{shape:[-1,m]}}),b=Wr(y,y.dtype,"any",t);let x;if(o){const T=Bt(h,u);x=oe({inputs:{x:b},backend:t,attrs:{shape:T}})}else x=oe({inputs:{x:b},backend:t,attrs:{shape:h}});return t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(b),c!=null&&t.disposeIntermediateTensorInfo(p),x}const ZT={kernelName:Yc,backendName:"webgl",kernelFunc:YT};/** 7535 * @license 7536 * Copyright 2017 Google LLC. All Rights Reserved. 7537 * Licensed under the Apache License, Version 2.0 (the "License"); 7538 * you may not use this file except in compliance with the License. 7539 * You may obtain a copy of the License at 7540 * 7541 * http://www.apache.org/licenses/LICENSE-2.0 7542 * 7543 * Unless required by applicable law or agreed to in writing, software 7544 * distributed under the License is distributed on an "AS IS" BASIS, 7545 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7546 * See the License for the specific language governing permissions and 7547 * limitations under the License. 7548 * ============================================================================= 7549 */class JT{constructor(e,t,r){this.variableNames=["A"];const{windowSize:a,batchSize:s,outSize:o}=e;r||this.variableNames.push("bestIndicesA"),this.outputShape=[s,o];const i=t==="max"?">":"<",u=r?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=` 7550 void main() { 7551 ivec2 coords = getOutputCoords(); 7552 int batch = coords[0]; 7553 int outIdx = coords[1]; 7554 int inOffset = outIdx * ${a}; 7555 7556 int bestIndex = inOffset; 7557 float bestValue = getA(batch, bestIndex); 7558 7559 for (int i = 0; i < ${a}; i++) { 7560 int inIdx = ${u}; 7561 float candidate = getA(batch, inIdx); 7562 if (candidate ${i} bestValue) { 7563 bestValue = candidate; 7564 bestIndex = inIdx; 7565 } 7566 } 7567 setOutput(float(bestIndex)); 7568 } 7569 `}}/** 7570 * @license 7571 * Copyright 2019 Google LLC. All Rights Reserved. 7572 * Licensed under the Apache License, Version 2.0 (the "License"); 7573 * you may not use this file except in compliance with the License. 7574 * You may obtain a copy of the License at 7575 * 7576 * http://www.apache.org/licenses/LICENSE-2.0 7577 * 7578 * Unless required by applicable law or agreed to in writing, software 7579 * distributed under the License is distributed on an "AS IS" BASIS, 7580 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7581 * See the License for the specific language governing permissions and 7582 * limitations under the License. 7583 * ============================================================================= 7584 */class QT{constructor(e,t,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,R(e.length>2,()=>`Packed arg${r.charAt(0).toUpperCase()+r.slice(1)} supports only inputs with rank above 2.`);const s=e[e.length-1],o=Math.ceil(s/t);this.outputShape=e.slice(0,-1),o>1&&this.outputShape.push(o),a||this.variableNames.push("bestIndicesA");const i=this.outputShape,u=i.length,l=Be(u),c=ft("coords",u);let p,h;if(o===1){h=u+1;const z=Be(h);p=` 7585 ${z} sourceLocR = ${z}(${c.join()}, 0); 7586 ++${c[u-1]}; 7587 ${z} sourceLocG = ${z}(${c.join()}, 0); 7588 ++${c[u-2]}; 7589 ${z} sourceLocA = ${z}(${c.join()}, 0); 7590 --${c[u-1]}; 7591 ${z} sourceLocB = ${z}(${c.join()}, 0); 7592 --${c[u-2]};`}else h=u,p=` 7593 ${l} sourceLocR = coords; 7594 ++${c[u-1]}; 7595 ${l} sourceLocG = coords; 7596 ++${c[u-2]}; 7597 ${l} sourceLocA = coords; 7598 --${c[u-1]}; 7599 ${l} sourceLocB = coords; 7600 --${c[u-2]};`;const d=["x","y","z","w","u","v"].slice(0,h),m="."+d[h-1],y=d.map(z=>"int "+z),b=ft("sourceLocR",h-1).concat("inIdx.r"),x=ft("sourceLocG",h-1).concat("inIdx.g"),T=ft("sourceLocB",h-1).concat("inIdx.b"),$=ft("sourceLocA",h-1).concat("inIdx.a"),F=r==="max"?"greaterThan":"lessThan",M=a?"":` 7601 inIdx = round(vec4(getBestIndicesAChannel(${b.join()}), 7602 getBestIndicesAChannel(${x.join()}), 7603 getBestIndicesAChannel(${T.join()}), 7604 getBestIndicesAChannel(${$.join()})));`,U=`vec4( 7605 getAChannel(${b.join()}), 7606 hasNextCol ? getAChannel(${x.join()}) : 0., 7607 hasNextRow ? getAChannel(${T.join()}) : 0., 7608 hasNextRow && hasNextCol ? getAChannel(${$.join()}) : 0.)`,X=a?"":` 7609 float getBestIndicesAChannel(${y.join()}) { 7610 return getChannel(getBestIndicesA(${d.join()}), 7611 vec2(${d.slice(-2).join()})); 7612 }`;this.userCode=` 7613 float getAChannel(${y.join()}) { 7614 return getChannel(getA(${d.join()}), 7615 vec2(${d.slice(-2).join()})); 7616 } 7617 ${X} 7618 void main() { 7619 ${l} coords = getOutputCoords(); 7620 bool hasNextCol = ${c[u-1]} < ${i[u-1]-1}; 7621 bool hasNextRow = ${c[u-2]} < ${i[u-2]-1}; 7622 ${p} 7623 ivec4 srcIdx = ivec4(sourceLocR${m}, sourceLocG${m}, 7624 sourceLocB${m}, sourceLocA${m}) * ${t}; 7625 ivec4 inIdx = srcIdx; 7626 vec4 bestIndex = vec4(inIdx); 7627 vec4 bestValue = ${U}; 7628 7629 for (int i = 0; i < ${t}; i++) { 7630 inIdx = srcIdx; 7631 ${M} 7632 vec4 candidate = ${U}; 7633 bvec4 nan = isnan(candidate); 7634 bvec4 replace = bvec4( 7635 vec4(${F}(candidate, bestValue)) * (vec4(1.0) - vec4(nan))); 7636 7637 bestValue = vec4(replace.x ? candidate.x : bestValue.x, 7638 replace.y ? candidate.y : bestValue.y, 7639 replace.z ? candidate.z : bestValue.z, 7640 replace.w ? candidate.w : bestValue.w); 7641 bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace)); 7642 srcIdx++; 7643 } 7644 setOutput(bestIndex); 7645 } 7646 `}}/** 7647 * @license 7648 * Copyright 2020 Google LLC. All Rights Reserved. 7649 * Licensed under the Apache License, Version 2.0 (the "License");
7650 * you may not use this file except in compliance with the License. 7651 * You may obtain a copy of the License at 7652 * 7653 * http://www.apache.org/licenses/LICENSE-2.0 7654 * 7655 * Unless required by applicable law or agreed to in writing, software 7656 * distributed under the License is distributed on an "AS IS" BASIS, 7657 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7658 * See the License for the specific language governing permissions and 7659 * limitations under the License. 7660 * ============================================================================= 7661 */function wm(n,e,t,r=null){let a=e.shape[0],s=e.shape[1];r!=null&&(a=r.shape[0],s=r.shape[1]);const o=Do(s),i={windowSize:o,inSize:s,batchSize:a,outSize:Math.ceil(s/o)},u=new JT(i,t,r==null),l=[e];r!=null&&l.push(r);const c=n.runWebGLProgram(u,l,"int32");if(c.shape[1]===1)return c;const p=wm(n,e,t,c);return n.disposeIntermediateTensorInfo(c),p}function Sm(n,e,t,r=null){const a=r!=null?r.shape:e.shape,s=a[a.length-1],o=Do(s),i=new QT(a,o,t,r==null),u=r==null?[e]:[e,r],l=n.runWebGLProgram(i,u,"int32");if(l.shape.length===e.shape.length){const c=Sm(n,e,t,l);return n.disposeIntermediateTensorInfo(l),c}return l}function km(n,e,t,r){const a=[t];if(hn("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,e.shape.length),!H().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const s=[],o=n.texData.get(e.dataId),i=o!==null&&o.isPacked;let u=e;i&&(u=n.unpackTensor(e),s.push(u));const[l,c]=kn(u.shape,a),p=ae(c),h=oe({inputs:{x:u},backend:n,attrs:{shape:[-1,p]}});s.push(h);const d=wm(n,h,r);s.push(d);const m=oe({inputs:{x:d},backend:n,attrs:{shape:l}});return s.forEach(y=>n.disposeIntermediateTensorInfo(y)),m}return Sm(n,e,r)}/** 7662 * @license 7663 * Copyright 2020 Google LLC. All Rights Reserved. 7664 * Licensed under the Apache License, Version 2.0 (the "License"); 7665 * you may not use this file except in compliance with the License. 7666 * You may obtain a copy of the License at 7667 * 7668 * http://www.apache.org/licenses/LICENSE-2.0 7669 * 7670 * Unless required by applicable law or agreed to in writing, software 7671 * distributed under the License is distributed on an "AS IS" BASIS, 7672 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7673 * See the License for the specific language governing permissions and 7674 * limitations under the License. 7675 * ============================================================================= 7676 */function eE(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s}=r;let o=rt(s,a.shape);const i=Qt(o,a.shape.length);let u=a;const l=[];i!=null&&(u=yt({inputs:{x:a},backend:t,attrs:{perm:i}}),l.push(u),o=en(o.length,u.shape.length)),hn("argMax",[o[0]],u.shape.length);const c=km(t,u,o[0],"max");return l.forEach(p=>t.disposeIntermediateTensorInfo(p)),c}const tE={kernelName:Zc,backendName:"webgl",kernelFunc:eE};/** 7677 * @license 7678 * Copyright 2020 Google LLC. All Rights Reserved. 7679 * Licensed under the Apache License, Version 2.0 (the "License"); 7680 * you may not use this file except in compliance with the License. 7681 * You may obtain a copy of the License at 7682 * 7683 * http://www.apache.org/licenses/LICENSE-2.0 7684 * 7685 * Unless required by applicable law or agreed to in writing, software 7686 * distributed under the License is distributed on an "AS IS" BASIS, 7687 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7688 * See the License for the specific language governing permissions and 7689 * limitations under the License. 7690 * ============================================================================= 7691 */function nE(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s}=r;let o=rt(s,a.shape);const i=Qt(o,a.shape.length);let u=a;const l=[];i!=null&&(u=yt({inputs:{x:a},backend:t,attrs:{perm:i}}),l.push(u),o=en(o.length,u.shape.length)),hn("argMin",[o[0]],u.shape.length);const c=km(t,u,o[0],"min");return l.forEach(p=>t.disposeIntermediateTensorInfo(p)),c}const rE={kernelName:Jc,backendName:"webgl",kernelFunc:nE};/** 7692 * @license 7693 * Copyright 2020 Google LLC. All Rights Reserved. 7694 * Licensed under the Apache License, Version 2.0 (the "License"); 7695 * you may not use this file except in compliance with the License. 7696 * You may obtain a copy of the License at 7697 * 7698 * http://www.apache.org/licenses/LICENSE-2.0 7699 * 7700 * Unless required by applicable law or agreed to in writing, softw
7700are 7701 * distributed under the License is distributed on an "AS IS" BASIS, 7702 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7703 * See the License for the specific language governing permissions and 7704 * limitations under the License. 7705 * ============================================================================= 7706 */const aE=tn+` 7707 if (abs(x) > 1.) { 7708 return NAN; 7709 } 7710 return asin(x); 7711`,sE=Ie({opSnippet:aE}),oE={kernelName:Qc,backendName:"webgl",kernelFunc:sE};/** 7712 * @license 7713 * Copyright 2020 Google LLC. All Rights Reserved. 7714 * Licensed under the Apache License, Version 2.0 (the "License"); 7715 * you may not use this file except in compliance with the License. 7716 * You may obtain a copy of the License at 7717 * 7718 * http://www.apache.org/licenses/LICENSE-2.0 7719 * 7720 * Unless required by applicable law or agreed to in writing, software 7721 * distributed under the License is distributed on an "AS IS" BASIS, 7722 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7723 * See the License for the specific language governing permissions and 7724 * limitations under the License. 7725 * ============================================================================= 7726 */const iE=tn+"return log(x + sqrt(x * x + 1.0));",uE=Ie({opSnippet:iE}),lE={kernelName:ep,backendName:"webgl",kernelFunc:uE};/** 7727 * @license 7728 * Copyright 2020 Google LLC. All Rights Reserved. 7729 * Licensed under the Apache License, Version 2.0 (the "License"); 7730 * you may not use this file except in compliance with the License. 7731 * You may obtain a copy of the License at 7732 * 7733 * http://www.apache.org/licenses/LICENSE-2.0 7734 * 7735 * Unless required by applicable law or agreed to in writing, software 7736 * distributed under the License is distributed on an "AS IS" BASIS, 7737 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7738 * See the License for the specific language governing permissions and 7739 * limitations under the License. 7740 * ============================================================================= 7741 */const cE=tn+` 7742 return atan(x); 7743`,pE=Ie({opSnippet:cE}),hE={kernelName:tp,backendName:"webgl",kernelFunc:pE};/** 7744 * @license 7745 * Copyright 2020 Google LLC. All Rights Reserved. 7746 * Licensed under the Apache License, Version 2.0 (the "License"); 7747 * you may not use this file except in compliance with the License. 7748 * You may obtain a copy of the License at 7749 * 7750 * http://www.apache.org/licenses/LICENSE-2.0 7751 * 7752 * Unless required by applicable law or agreed to in writing, software 7753 * distributed under the License is distributed on an "AS IS" BASIS, 7754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7755 * See the License for the specific language governing permissions and 7756 * limitations under the License. 7757 * ============================================================================= 7758 */const dE=ul+` 7759 return atan(a, b); 7760`,fE=` 7761 vec4 result = atan(a, b); 7762 bvec4 isNaNA = isnan(a); 7763 bvec4 isNaNB = isnan(b); 7764 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 7765 `+bs+` 7766 return result; 7767`,mE=ut({opSnippet:dE,packedOpSnippet:fE}),gE={kernelName:rp,backendName:"webgl",kernelFunc:mE};/** 7768 * @license 7769 * Copyright 2020 Google LLC. All Rights Reserved. 7770 * Licensed under the Apache License, Version 2.0 (the "License"); 7771 * you may not use this file except in compliance with the License. 7772 * You may obtain a copy of the License at 7773 * 7774 * http://www.apache.org/licenses/LICENSE-2.0 7775 * 7776 * Unless required by applicable law or agreed to in writing, software 7777 * distributed under the License is distributed on an "AS IS" BASIS, 7778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7779 * See the License for the specific language governing permissions and 7780 * limitations under the License. 7781 * ============================================================================= 7782 */const yE=tn+` 7783 if ((x < -1.0) || (x > 1.0)) return NAN; 7784return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,xE=Ie({opSnippet:yE}),bE={kernelName:np,backendName:"webgl",kernelFunc:xE};/** 7785 * @license 7786 * Copyright 2017 Google LLC. All Rights Reserved. 7787 * Licensed under the Apache License, Version 2.0 (the "License");
7788 * you may not use this file except in compliance with the License. 7789 * You may obtain a copy of the License at 7790 * 7791 * http://www.apache.org/licenses/LICENSE-2.0 7792 * 7793 * Unless required by applicable law or agreed to in writing, software 7794 * distributed under the License is distributed on an "AS IS" BASIS, 7795 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7796 * See the License for the specific language governing permissions and 7797 * limitations under the License. 7798 * ============================================================================= 7799 */class cs{constructor(e,t,r,a=!1,s=!1){if(this.variableNames=["x"],t==="avg"&&r)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,i=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=e.padInfo.top,m=e.padInfo.left;this.outputShape=e.outShape;const y=t==="avg",b=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,x=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let T="0.0";if(y||(T="-1.0 / 1e-20"),r){this.userCode=` 7800 const ivec2 strides = ivec2(${i}, ${u}); 7801 const ivec2 pads = ivec2(${d}, ${m}); 7802 7803 void main() { 7804 ivec4 coords = getOutputCoords(); 7805 int batch = coords[0]; 7806 int d = coords[3]; 7807 7808 ivec2 xRCCorner = coords.yz * strides - pads; 7809 int xRCorner = xRCCorner.x; 7810 int xCCorner = xRCCorner.y; 7811 7812 // max/min x(?, ?, d) to get y(yR, yC, d). 7813 // ? = to be determined 7814 float minMaxValue = 0.0; 7815 float minMaxValueFound = 0.0; 7816 int minMaxPosition = 0; 7817 float avgValue = 0.0; 7818 7819 for (int wR = 0; wR < ${p}; 7820 wR += ${l}) { 7821 int xR = xRCorner + wR; 7822 7823 if (xR < 0 || xR >= ${e.inHeight}) { 7824 continue; 7825 } 7826 7827 for (int wC = 0; wC < ${h}; 7828 wC += ${c}) { 7829 int xC = xCCorner + wC; 7830 7831 if (xC < 0 || xC >= ${e.inWidth}) { 7832 continue; 7833 } 7834 7835 float value = getX(batch, xR, xC, d); 7836 7837 // If a min / max value has already been found, use it. If not, 7838 // use the current value. 7839 float currMinMaxValue = mix( 7840 value, minMaxValue, minMaxValueFound); 7841 if (value >= currMinMaxValue) { 7842 minMaxValue = value; 7843 minMaxValueFound = 1.0; 7844 minMaxPosition = ${a?s?b:x:`wR * ${h} + wC`}; 7845 } 7846 } 7847 } 7848 setOutput(float(minMaxPosition)); 7849 } 7850 `;return}const $="max";let F=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(F="avgValue / count");const M=Math.floor(o/4)*4,U=o%4,X=` 7851 if (${y}) { 7852 avgValue += dot(values, ones); 7853 } else { 7854 minMaxValue = ${$}(values, minMaxValue); 7855 } 7856 `;this.userCode=` 7857 const ivec2 strides = ivec2(${i}, ${u}); 7858 const ivec2 pads = ivec2(${d}, ${m}); 7859 const float initializationValue = ${T}; 7860 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 7861 7862 float count = 0.0; 7863 7864 float getValue(int batch, int xR, int xC, int d) { 7865 if (xC < 0 || xC >= ${e.inWidth}) { 7866 return initializationValue; 7867 } 7868 count += 1.0; 7869 return getX(batch, xR, xC, d); 7870 } 7871 7872 void main() { 7873 ivec4 coords = getOutputCoords(); 7874 int batch = coords[0]; 7875 int d = coords[3]; 7876 7877 ivec2 xRCCorner = coords.yz * strides - pads; 7878 int xRCorner = xRCCorner.x; 7879 int xCCorner = xRCCorner.y; 7880 7881 // max/min x(?, ?, d) to get y(yR, yC, d). 7882 // ? = to be determined 7883 vec4 minMaxValue = vec4(${T}); 7884 float avgValue = 0.0; 7885 count = 0.0; 7886 7887 for (int wR = 0; wR < ${p}; 7888 wR += ${l}) { 7889 int xR = xRCorner + wR; 7890 7891 if (xR < 0 || xR >= ${e.inHeight}) { 7892 continue; 7893 } 7894 7895 for (int wC = 0; wC < ${M}; wC += 4) { 7896 int xC = xCCorner + wC * ${c}; 7897 7898 vec4 values = vec4( 7899 getValue(batch, xR, xC, d), 7900 getValue(batch, xR, xC + ${c}, d), 7901 getValue(batch, xR, xC + 2 * ${c}, d), 7902 getValue(batch, xR, xC + 3 * ${c}, d) 7903 ); 7904 7905 ${X} 7906 } 7907 7908 int xC = xCCorner + ${M}; 7909 if (${U===1}) { 7910 vec4 values = vec4( 7911 getValue(batch, xR, xC, d), 7912 initializationValue, 7913 initializationValue, 7914 initializationValue 7915 ); 7916 7917 ${X} 7918 } else if (${U===2}) { 7919 vec4 values = vec4( 7920 getValue(batch, xR, xC, d), 7921 getValue(batch, xR, xC + ${c}, d), 7922 initializationValue, 7923 initializationValue 7924 ); 7925 7926 ${X} 7927 } else if (${U===3}) { 7928 vec4 values = vec4( 7929 getValue(batch, xR, xC, d), 7930 getValue(batch, xR, xC + ${c}, d), 7931 getValue(batch, xR, xC + 2 * ${c}, d), 7932 initializationValue 7933 ); 7934 7935 ${X} 7936 } 7937 } 7938 setOutput(${F}); 7939 } 7940 `}}class cl{constructor(e,t,r,a=!1,s=!1){if(this.variableNames=["x"],t==="avg"&&r)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,i=e.strideDepth,u=e.strideHeight,l=e.strideWidth,c=e.dilationDepth,p=e.dilationHeight,h=e.dilationWidth,d=e.effectiveFilterDepth,m=e.effectiveFilterHeight,y=e.effectiveFilterWidth,b=e.padInfo.front,x=e.padInfo.top,T=e.padInfo.left;this.outputShape=e.outShape;const $=t==="avg";let F="0.0";if($||(F="-1.0 / 1e-20"),r){this.userCode=` 7941 const ivec3 strides = 7942 ivec3(${i}, ${u}, ${l}); 7943 const ivec3 pads = ivec3(${b}, ${x}, ${T}); 7944 7945 void main() { 7946 ivec5 coords = getOutputCoords(); 7947 int batch = coords.x; 7948 int ch = coords.u; 7949 7950 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 7951 int xDCorner = xCorner.x; 7952 int xRCorner = xCorner.y; 7953 int xCCorner = xCorner.z; 7954 7955 // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch). 7956 // ? = to be determined 7957 float minMaxValue = 0.0; 7958 float minMaxValueFound = 0.0; 7959 int minMaxPosition = 0; 7960 7961 for (int wD = 0; wD < ${d}; 7962 wD += ${c}) { 7963 int xD = xDCorner + wD; 7964 7965 if (xD < 0 || xD >= ${e.inDepth}) { 7966 continue; 7967 } 7968 7969 for (int wR = 0; wR < ${m}; 7970 wR += ${p}) { 7971 int xR = xRCorner + wR; 7972 7973 if (xR < 0 || xR >= ${e.inHeight}) { 7974 continue; 7975 } 7976 7977 for (int wC = 0; wC < ${y}; 7978 wC += ${h}) { 7979 int xC = xCCorner + wC; 7980 7981 if (xC < 0 || xC >= ${e.inWidth}) { 7982 continue; 7983 } 7984 7985 float value = getX(batch, xD, xR, xC, ch); 7986 7987 // If a min / max value has already been found, use it. If not, 7988 // use the current value. 7989 float currMinMaxValue = mix( 7990 value, minMaxValue, minMaxValueFound); 7991 if (value >= currMinMaxValue) { 7992 minMaxValue = value; 7993 minMaxValueFound = 1.0; 7994 minMaxPosition = ${a?s?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${m} * ${y} + 7995 wR * ${y} + wC`}; 7996 } 7997 } 7998 } 7999 } 8000 setOutput(float(minMaxPosition)); 8001 } 8002 `;return}const M="max";let U=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(U="avgValue / count");const X=Math.floor(o/4)*4,z=o%4,L=` 8003 if (${$}) { 8004 avgValue += dot(values, ones); 8005 } else { 8006 minMaxValue = ${M}(values, minMaxValue); 8007 } 8008 `;this.userCode=` 8009 const ivec3 strides = 8010 ivec3(${i}, ${u}, ${l}); 8011 const ivec3 pads = ivec3(${b}, ${x}, ${T}); 8012 const float initializationValue = ${F}; 8013 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 8014 8015 float count = 0.0; 8016 8017 float getValue(int batch, int xD, int xR, int xC, int ch) { 8018 if (xC < 0 || xC >= ${e.inWidth}) { 8019 return initializationValue; 8020 } 8021 count += 1.0; 8022 return getX(batch, xD, xR, xC, ch); 8023 } 8024 8025 void main() { 8026 ivec5 coords = getOutputCoords(); 8027 int batch = coords.x; 8028 int ch = coords.u; 8029 8030 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 8031 int xDCorner = xCorner.x; 8032 int xRCorner = xCorner.y; 8033 int xCCorner = xCorner.z; 8034 8035 // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch). 8036 // ? = to be determined 8037 vec4 minMaxValue = vec4(${F}); 8038 float avgValue = 0.0; 8039 count = 0.0; 8040 8041 for (int wD = 0; wD < ${d}; 8042 wD += ${c}) { 8043 int xD = xDCorner + wD; 8044 8045 if (xD < 0 || xD >= ${e.inDepth}) { 8046 continue; 8047 } 8048 8049 for (int wR = 0; wR < ${m}; 8050 wR += ${p}) { 8051 int xR = xRCorner + wR; 8052 8053 if (xR < 0 || xR >= ${e.inHeight}) { 8054 continue; 8055 } 8056 8057 for (int wC = 0; wC < ${X}; wC += 4) { 8058 int xC = xCCorner + wC * ${h}; 8059 8060 vec4 values = vec4( 8061 getValue(batch, xD, xR, xC, ch), 8062 getValue(batch, xD, xR, xC + ${h}, ch), 8063 getValue(batch, xD, xR, xC + 2 * ${h}, ch), 8064 getValue(batch, xD, xR, xC + 3 * ${h}, ch) 8065 ); 8066 8067 ${L} 8068 } 8069 8070 int xC = xCCorner + ${X}; 8071 if (${z===1}) { 8072 vec4 values = vec4( 8073 getValue(batch, xD, xR, xC, ch), 8074 initializationValue, 8075 initializationValue, 8076 initializationValue 8077 ); 8078 8079 ${L} 8080 } else if (${z===2}) { 8081 vec4 values = vec4( 8082 getValue(batch, xD, xR, xC, ch), 8083 getValue(batch, xD, xR, xC + ${h}, ch), 8084 initializationValue, 8085 initializationValue 8086 ); 8087 8088 ${L} 8089 } else if (${z===3}) { 8090 vec4 values = vec4( 8091 getValue(batch, xD, xR, xC, ch), 8092 getValue(batch, xD, xR, xC + ${h}, ch), 8093 getValue(batch, xD, xR, xC + 2 * ${h}, ch), 8094 initializationValue 8095 ); 8096 8097 ${L} 8098 } 8099 } 8100 setOutput(${U}); 8101 } 8102 } 8103 `}}/** 8104 * @license 8105 * Copyright 2020 Google LLC. All Rights Reserved. 8106 * Licensed under the Apache License, Version 2.0 (the "License");
8107 * you may not use this file except in compliance with the License. 8108 * You may obtain a copy of the License at 8109 * 8110 * http://www.apache.org/licenses/LICENSE-2.0 8111 * 8112 * Unless required by applicable law or agreed to in writing, software 8113 * distributed under the License is distributed on an "AS IS" BASIS, 8114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8115 * See the License for the specific language governing permissions and 8116 * limitations under the License. 8117 * ============================================================================= 8118 */function vE(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e;ys(a,"avgPool");const{filterSize:s,strides:o,pad:i,dimRoundingMode:u}=r,l=1;R(_t(o,l),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${l}'`);const c=Pr(a.shape,s,o,l,i,u);if(c.filterWidth===1&&c.filterHeight===1&&qe(c.inShape,c.outShape))return Rt({inputs:{x:a},backend:t});const p=new cs(c,"avg",!1);return t.runWebGLProgram(p,[a],"float32")}const wE={kernelName:ap,backendName:"webgl",kernelFunc:vE};/** 8119 * @license 8120 * Copyright 2020 Google LLC. All Rights Reserved. 8121 * Licensed under the Apache License, Version 2.0 (the "License"); 8122 * you may not use this file except in compliance with the License. 8123 * You may obtain a copy of the License at 8124 * 8125 * http://www.apache.org/licenses/LICENSE-2.0 8126 * 8127 * Unless required by applicable law or agreed to in writing, software 8128 * distributed under the License is distributed on an "AS IS" BASIS, 8129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8130 * See the License for the specific language governing permissions and 8131 * limitations under the License. 8132 * ============================================================================= 8133 */function SE(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{filterSize:s,strides:o,pad:i,dimRoundingMode:u,dataFormat:l}=r,c=[1,1,1],p=ds(a.shape,s,o,c,i,u,l),h=new cl(p,"avg",!1);return t.runWebGLProgram(h,[a],"float32")}const kE={kernelName:sp,backendName:"webgl",kernelFunc:SE};/** 8134 * @license 8135 * Copyright 2017 Google LLC. All Rights Reserved. 8136 * Licensed under the Apache License, Version 2.0 (the "License"); 8137 * you may not use this file except in compliance with the License. 8138 * You may obtain a copy of the License at 8139 * 8140 * http://www.apache.org/licenses/LICENSE-2.0 8141 * 8142 * Unless required by applicable law or agreed to in writing, software 8143 * distributed under the License is distributed on an "AS IS" BASIS, 8144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8145 * See the License for the specific language governing permissions and 8146 * limitations under the License. 8147 * ============================================================================= 8148 */class TE{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,a=e.strideHeight,s=e.strideWidth,o=e.dilationHeight,i=e.dilationWidth,u=e.effectiveFilterHeight,l=e.effectiveFilterWidth,c=u-1-e.padInfo.top,p=l-1-e.padInfo.left,h=1/(t*r);this.userCode=` 8149 const ivec2 pads = ivec2(${c}, ${p}); 8150 const float avgMultiplier = float(${h}); 8151 8152 void main() { 8153 ivec4 coords = getOutputCoords(); 8154 int b = coords[0]; 8155 int d = coords[3]; 8156 8157 ivec2 dyRCCorner = coords.yz - pads; 8158 int dyRCorner = dyRCCorner.x; 8159 int dyCCorner = dyRCCorner.y; 8160 8161 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 8162 // ? = to be determined. : = across all values in that axis. 8163 float dotProd = 0.0; 8164 for (int wR = 0; wR < ${u}; 8165 wR += ${o}) { 8166 float dyR = float(dyRCorner + wR) / ${a}.0; 8167 8168 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 8169 continue; 8170 } 8171 int idyR = int(dyR); 8172 8173 for (int wC = 0; wC < ${l}; 8174 wC+= ${i}) { 8175 float dyC = float(dyCCorner + wC) / ${s}.0; 8176 8177 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 8178 fract(dyC) > 0.0) { 8179 continue; 8180 } 8181 int idyC = int(dyC); 8182 8183 float dyValue = getDy(b, idyR, idyC, d); 8184 8185 dotProd += dyValue * avgMultiplier; 8186 } 8187 } 8188 setOutput(dotProd); 8189 } 8190 `}}class EE{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,r=e.filterHeight,a=e.filterWidth,s=e.strideDepth,o=e.strideHeight,i=e.strideWidth,u=e.dilationDepth,l=e.dilationHeight,c=e.dilationWidth,p=e.effectiveFilterDepth,h=e.effectiveFilterHeight,d=e.effectiveFilterWidth,m=p-1-e.padInfo.front,y=h-1-e.padInfo.top,b=d-1-e.padInfo.left,x=1/(t*r*a);this.userCode=` 8191 const ivec3 pads = ivec3(${m}, ${y}, ${b}); 8192 const float avgMultiplier = float(${x}); 8193 8194 void main() { 8195 ivec5 coords = getOutputCoords(); 8196 int batch = coords.x; 8197 int ch = coords.u; 8198 8199 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 8200 int dyDCorner = dyCorner.x; 8201 int dyRCorner = dyCorner.y; 8202 int dyCCorner = dyCorner.z; 8203 8204 // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
8205 // dx(xD, xR, xC, ch). 8206 // ? = to be determined. : = across all values in that axis. 8207 float dotProd = 0.0; 8208 8209 for (int wD = 0; wD < ${p}; 8210 wD += ${u}) { 8211 float dyD = float(dyDCorner + wD) / ${s}.0; 8212 8213 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 8214 continue; 8215 } 8216 int idyD = int(dyD); 8217 8218 for (int wR = 0; wR < ${h}; 8219 wR += ${l}) { 8220 float dyR = float(dyRCorner + wR) / ${o}.0; 8221 8222 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 8223 fract(dyR) > 0.0) { 8224 continue; 8225 } 8226 int idyR = int(dyR); 8227 8228 for (int wC = 0; wC < ${d}; 8229 wC += ${c}) { 8230 float dyC = float(dyCCorner + wC) / ${i}.0; 8231 8232 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 8233 fract(dyC) > 0.0) { 8234 continue; 8235 } 8236 int idyC = int(dyC); 8237 8238 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 8239 8240 dotProd += dyValue * avgMultiplier; 8241 } 8242 } 8243 } 8244 setOutput(dotProd); 8245 } 8246 `}}/** 8247 * @license 8248 * Copyright 2020 Google LLC. All Rights Reserved. 8249 * Licensed under the Apache License, Version 2.0 (the "License"); 8250 * you may not use this file except in compliance with the License. 8251 * You may obtain a copy of the License at 8252 * 8253 * http://www.apache.org/licenses/LICENSE-2.0 8254 * 8255 * Unless required by applicable law or agreed to in writing, software 8256 * distributed under the License is distributed on an "AS IS" BASIS, 8257 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8258 * See the License for the specific language governing permissions and 8259 * limitations under the License. 8260 * ============================================================================= 8261 */function CE(n){const{inputs:e,backend:t,attrs:r}=n,{dy:a,input:s}=e,o=s,{filterSize:i,strides:u,pad:l,dimRoundingMode:c}=r,p=[1,1,1],h=ds(o.shape,i,u,p,l,c),d=new EE(h);return t.runWebGLProgram(d,[a],o.dtype)}const IE={kernelName:R2,backendName:"webgl",kernelFunc:CE};/** 8262 * @license 8263 * Copyright 2020 Google LLC. All Rights Reserved. 8264 * Licensed under the Apache License, Version 2.0 (the "License"); 8265 * you may not use this file except in compliance with the License. 8266 * You may obtain a copy of the License at 8267 * 8268 * http://www.apache.org/licenses/LICENSE-2.0 8269 * 8270 * Unless required by applicable law or agreed to in writing, software 8271 * distributed under the License is distributed on an "AS IS" BASIS, 8272 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8273 * See the License for the specific language governing permissions and 8274 * limitations under the License. 8275 * ============================================================================= 8276 */function NE(n){const{inputs:e,backend:t,attrs:r}=n,{dy:a,input:s}=e,o=s;ys([a,s],"avgPoolGrad");const{filterSize:i,strides:u,pad:l}=r,c=Pr(o.shape,i,u,1,l),p=new TE(c);return t.runWebGLProgram(p,[a],o.dtype)}const $E={kernelName:$2,backendName:"webgl",kernelFunc:NE};/** 8277 * @license 8278 * Copyright 2020 Google LLC. All Rights Reserved. 8279 * Licensed under the Apache License, Version 2.0 (the "License"); 8280 * you may not use this file except in compliance with the License. 8281 * You may obtain a copy of the License at 8282 * 8283 * http://www.apache.org/licenses/LICENSE-2.0 8284 * 8285 * Unless required by applicable law or agreed to in writing, software 8286 * distributed under the License is distributed on an "AS IS" BASIS, 8287 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8288 * See the License for the specific language governing permissions and 8289 * limitations under the License. 8290 * ============================================================================= 8291 */function RE(n){const{inputs:e,backend:t,attrs:r}=n,{a,b:s}=e,{transposeA:o,transposeB:i}=r;return po({a,b:s,transposeA:o,transposeB:i,backend:t})}const _E={kernelName:op,backendName:"webgl",kernelFunc:RE};/** 8292 * @license 8293 * Copyright 2017 Google LLC. All Rights Reserved. 8294 * Licensed under the Apache License, Version 2.0 (the "License");
8295 * you may not use this file except in compliance with the License. 8296 * You may obtain a copy of the License at 8297 * 8298 * http://www.apache.org/licenses/LICENSE-2.0 8299 * 8300 * Unless required by applicable law or agreed to in writing, software 8301 * distributed under the License is distributed on an "AS IS" BASIS, 8302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8303 * See the License for the specific language governing permissions and 8304 * limitations under the License. 8305 * ============================================================================= 8306 */class AE{constructor(e,t,r,a,s,o){this.outputShape=[],this.variableNames=["x","mean","variance"],$e(e,t),$e(e,r);let i="0.0";a!=null&&($e(e,a),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let u="1.0";s!=null&&($e(e,s),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 8307 void main() { 8308 float x = getXAtOutCoords(); 8309 float mean = getMeanAtOutCoords(); 8310 float variance = getVarianceAtOutCoords(); 8311 float offset = ${i}; 8312 float scale = ${u}; 8313 float inv = scale * inversesqrt(variance + float(${o})); 8314 setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1))); 8315 } 8316 `}}/** 8317 * @license 8318 * Copyright 2018 Google LLC. All Rights Reserved. 8319 * Licensed under the Apache License, Version 2.0 (the "License"); 8320 * you may not use this file except in compliance with the License. 8321 * You may obtain a copy of the License at 8322 * 8323 * http://www.apache.org/licenses/LICENSE-2.0 8324 * 8325 * Unless required by applicable law or agreed to in writing, software 8326 * distributed under the License is distributed on an "AS IS" BASIS, 8327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8328 * See the License for the specific language governing permissions and 8329 * limitations under the License. 8330 * ============================================================================= 8331 */class OE{constructor(e,t,r,a,s,o){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],$e(e,t),$e(e,r);let i="vec4(0.0)";a!=null&&($e(e,a),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let u="vec4(1.0)";s!=null&&($e(e,s),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 8332 void main() { 8333 vec4 offset = ${i}; 8334 vec4 scale = ${u}; 8335 8336 vec4 x = getXAtOutCoords(); 8337 vec4 mean = getMeanAtOutCoords(); 8338 vec4 variance = getVarianceAtOutCoords(); 8339 8340 vec4 inv = scale * inversesqrt(variance + vec4(${o})); 8341 8342 setOutput((x - mean) * inv + offset); 8343 } 8344 `}}/** 8345 * @license 8346 * Copyright 2020 Google LLC. All Rights Reserved. 8347 * Licensed under the Apache License, Version 2.0 (the "License"); 8348 * you may not use this file except in compliance with the License. 8349 * You may obtain a copy of the License at 8350 * 8351 * http://www.apache.org/licenses/LICENSE-2.0 8352 * 8353 * Unless required by applicable law or agreed to in writing, software 8354 * distributed under the License is distributed on an "AS IS" BASIS, 8355 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8356 * See the License for the specific language governing permissions and 8357 * limitations under the License. 8358 * =============================================================================
8359 */const FE=({inputs:n,backend:e,attrs:t})=>{const{x:r,mean:a,variance:s,offset:o,scale:i}=n;R(a.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),R(o==null||a.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),R(i==null||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:u}=t;u==null&&(u=.001);const l=[r,a,s];let c=null;o!=null&&(c=o.shape,l.push(o));let p=null;i!=null&&(p=i.shape,l.push(i));const h=H().getBool("WEBGL_PACK_NORMALIZATION")?new OE(r.shape,a.shape,s.shape,c,p,u):new AE(r.shape,a.shape,s.shape,c,p,u);return e.runWebGLProgram(h,l,l[0].dtype)},DE={kernelName:jp,backendName:"webgl",kernelFunc:FE};/** 8360 * @license 8361 * Copyright 2017 Google LLC. All Rights Reserved. 8362 * Licensed under the Apache License, Version 2.0 (the "License"); 8363 * you may not use this file except in compliance with the License. 8364 * You may obtain a copy of the License at 8365 * 8366 * http://www.apache.org/licenses/LICENSE-2.0 8367 * 8368 * Unless required by applicable law or agreed to in writing, software 8369 * distributed under the License is distributed on an "AS IS" BASIS, 8370 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8371 * See the License for the specific language governing permissions and 8372 * limitations under the License. 8373 * ============================================================================= 8374 */class ME{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=Be(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const r=LE(this.rank);let a;const s=e.map((o,i)=>`sourceLoc.${uu[i]} = start[${i}] + coords.${uu[i]};`);a=` 8375 ${t} sourceLoc; 8376 ${t} coords = getOutputCoords(); 8377 ${s.join(` 8378`)} 8379 `,this.userCode=` 8380 void main() { 8381 ${a} 8382 setOutput(getSource(${r})); 8383 } 8384 `}}const uu=["x","y","z","w","u","v"];function LE(n){if(n===1)return"sourceLoc";if(n<=6)return uu.slice(0,n).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${n} is not yet supported`)}/** 8385 * @license 8386 * Copyright 2019 Google LLC. All Rights Reserved. 8387 * Licensed under the Apache License, Version 2.0 (the "License"); 8388 * you may not use this file except in compliance with the License. 8389 * You may obtain a copy of the License at 8390 * 8391 * http://www.apache.org/licenses/LICENSE-2.0 8392 * 8393 * Unless required by applicable law or agreed to in writing, software 8394 * distributed under the License is distributed on an "AS IS" BASIS, 8395 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8396 * See the License for the specific language governing permissions and 8397 * limitations under the License. 8398 * ============================================================================= 8399 */class PE{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=Be(this.rank),r=ft("coords",this.rank),a=ft("sourceLoc",this.rank),s=this.rank===1?"sourceLoc":`vec2(${a.slice(-2).join()})`,o=`getChannel(getSource(${a.join()}), ${s})`,i=` 8400 result.x = ${o}; 8401 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 8402 ++${a[this.rank-1]}; 8403 result.y = ${o}; 8404 --${a[this.rank-1]}; 8405 } 8406 `,u=this.rank===1?"":` 8407 --${r[this.rank-1]}; 8408 if (++${r[this.rank-2]} < ${e[this.rank-2]}) { 8409 ++${a[this.rank-2]}; 8410 result.z = ${o}; 8411 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 8412 ++${a[this.rank-1]}; 8413 result.w = ${o}; 8414 } 8415 } 8416 `,l=this.rank<=4?`sourceLoc = coords + 8417 ${t}(${e.map((c,p)=>`start[${p}]`).join()});`:e.map((c,p)=>`${a[p]} = ${r[p]} + start[${p}];`).join(` 8418`);this.userCode=` 8419 void main() { 8420 ${t} coords = getOutputCoords(); 8421 ${t} sourceLoc; 8422 ${l} 8423 vec4 result = vec4(0.); 8424 ${i} 8425 ${u} 8426 setOutput(result); 8427 } 8428 `}}/** 8429 * @license 8430 * Copyright 2020 Google LLC. All Rights Reserved. 8431 * Licensed under the Apache License, Version 2.0 (the "License");
8432 * you may not use this file except in compliance with the License. 8433 * You may obtain a copy of the License at 8434 * 8435 * http://www.apache.org/licenses/LICENSE-2.0 8436 * 8437 * Unless required by applicable law or agreed to in writing, software 8438 * distributed under the License is distributed on an "AS IS" BASIS, 8439 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8440 * See the License for the specific language governing permissions and 8441 * limitations under the License. 8442 * ============================================================================= 8443 */function BE(n,e,t,r){const a=r.texData.get(n.dataId),s=r.makeTensorInfo(t,n.dtype),o=r.texData.get(s.dataId);Object.assign(o,a),o.refCount=1,o.shape=t,o.dtype=n.dtype;let i=Pu(e,ot(n.shape));a.slice&&(i+=a.slice.flatOffset),o.slice={flatOffset:i,origDataId:a.slice&&a.slice.origDataId||n.dataId};const u=r.dataRefCount.get(o.slice.origDataId)||1;return r.dataRefCount.set(o.slice.origDataId,u+1),s}function Ia(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{begin:s,size:o}=r,[i,u]=Ef(a,s,o);if(mf(a,i,u),ae(u)===0)return t.makeTensorInfo(u,a.dtype,[]);if(t.shouldExecuteOnCPU([a])||a.dtype==="string"){const p=t.texData.get(a.dataId),h=Ak(p.values,i,u,a.shape,a.dtype);return t.makeTensorInfo(u,a.dtype,h)}const{isPacked:l}=t.texData.get(a.dataId),c=Lu(a.shape,i,u);if(l||!c){const p=H().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new PE(u):new ME(u),h=[i];return t.runWebGLProgram(p,[a],a.dtype,h)}return t.uploadToGPU(a.dataId),BE(a,i,u,t)}const UE={kernelName:Jh,backendName:"webgl",kernelFunc:Ia};/** 8444 * @license 8445 * Copyright 2020 Google LLC. All Rights Reserved. 8446 * Licensed under the Apache License, Version 2.0 (the "License"); 8447 * you may not use this file except in compliance with the License. 8448 * You may obtain a copy of the License at 8449 * 8450 * http://www.apache.org/licenses/LICENSE-2.0 8451 * 8452 * Unless required by applicable law or agreed to in writing, software 8453 * distributed under the License is distributed on an "AS IS" BASIS, 8454 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8455 * See the License for the specific language governing permissions and 8456 * limitations under the License. 8457 * ============================================================================= 8458 */const VE=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{blockShape:s,crops:o}=r;R(a.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const i=s.reduce((T,$)=>T*$),u=el(a.shape,s,i),l=tl(u.length,s.length),c=nl(a.shape,s,i),p=v1(o,s.length),h=w1(c,o,s.length),d=[],m=oe({inputs:{x:a},backend:t,attrs:{shape:u}}),y=yt({inputs:{x:m},backend:t,attrs:{perm:l}}),b=oe({inputs:{x:y},backend:t,attrs:{shape:c}}),x=Ia({inputs:{x:b},backend:t,attrs:{begin:p,size:h}});return d.push(m),d.push(y),d.push(b),d.forEach(T=>t.disposeIntermediateTensorInfo(T)),x},WE={kernelName:ip,backendName:"webgl",kernelFunc:VE};/** 8459 * @license 8460 * Copyright 2020 Google LLC. All Rights Reserved. 8461 * Licensed under the Apache License, Version 2.0 (the "License"); 8462 * you may not use this file except in compliance with the License. 8463 * You may obtain a copy of the License at 8464 * 8465 * http://www.apache.org/licenses/LICENSE-2.0 8466 * 8467 * Unless required by applicable law or agreed to in writing, software 8468 * distributed under the License is distributed on an "AS IS" BASIS, 8469 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8470 * See the License for the specific language governing permissions and 8471 * limitations under the License. 8472 * ============================================================================= 8473 */function zE(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,weights:s}=e,{size:o}=r,i=t.readSync(a.dataId),u=t.readSync(s.dataId),l=cm(i,u,s.dtype,s.shape,o);return t.makeTensorInfo([o],s.dtype,l)}const GE={kernelName:up,backendName:"webgl",kernelFunc:zE};/** 8474 * @license 8475 * Copyright 2021 Google LLC. All Rights Reserved. 8476 * Licensed under the Apache License, Version 2.0 (the "License"); 8477 * you may not use this file except in compliance with the License. 8478 * You may obtain a copy of the License at 8479 * 8480 * http://www.apache.org/licenses/LICENSE-2.0 8481 * 8482 * Unless required by applicable law or agreed to in writing, softw
8482are 8483 * distributed under the License is distributed on an "AS IS" BASIS, 8484 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8485 * See the License for the specific language governing permissions and 8486 * limitations under the License. 8487 * ============================================================================= 8488 */function jE(n){const{inputs:e,backend:t}=n,{s0:r,s1:a}=e,s=t.readSync(r.dataId),o=t.readSync(a.dataId),i=$e(Array.from(s),Array.from(o));return t.makeTensorInfo([i.length],"int32",Int32Array.from(i))}const HE={kernelName:lp,backendName:"webgl",kernelFunc:jE};/** 8489 * @license 8490 * Copyright 2020 Google LLC. All Rights Reserved. 8491 * Licensed under the Apache License, Version 2.0 (the "License"); 8492 * you may not use this file except in compliance with the License. 8493 * You may obtain a copy of the License at 8494 * 8495 * http://www.apache.org/licenses/LICENSE-2.0 8496 * 8497 * Unless required by applicable law or agreed to in writing, software 8498 * distributed under the License is distributed on an "AS IS" BASIS, 8499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8500 * See the License for the specific language governing permissions and 8501 * limitations under the License. 8502 * ============================================================================= 8503 */const XE="return float(a != b);",Tm=ut({opSnippet:XE,cpuKernelImpl:Tk,dtype:"bool"}),qE={kernelName:Th,backendName:"webgl",kernelFunc:Tm};/** 8504 * @license 8505 * Copyright 2020 Google LLC. All Rights Reserved. 8506 * Licensed under the Apache License, Version 2.0 (the "License"); 8507 * you may not use this file except in compliance with the License. 8508 * You may obtain a copy of the License at 8509 * 8510 * http://www.apache.org/licenses/LICENSE-2.0 8511 * 8512 * Unless required by applicable law or agreed to in writing, software 8513 * distributed under the License is distributed on an "AS IS" BASIS, 8514 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8515 * See the License for the specific language governing permissions and 8516 * limitations under the License. 8517 * ============================================================================= 8518 */function ws(n){const{inputs:e,backend:t}=n,{input:r}=e,a=t.texData.get(r.dataId);return Rt({inputs:{x:a.complexTensorInfos.real},backend:t})}const KE={kernelName:Ph,backendName:"webgl",kernelFunc:ws};/** 8519 * @license 8520 * Copyright 2020 Google LLC. All Rights Reserved. 8521 * Licensed under the Apache License, Version 2.0 (the "License"); 8522 * you may not use this file except in compliance with the License. 8523 * You may obtain a copy of the License at 8524 * 8525 * http://www.apache.org/licenses/LICENSE-2.0 8526 * 8527 * Unless required by applicable law or agreed to in writing, software 8528 * distributed under the License is distributed on an "AS IS" BASIS, 8529 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8530 * See the License for the specific language governing permissions and 8531 * limitations under the License. 8532 * ============================================================================= 8533 */const YE="return float(int(x));";function ZE(n,e){const t=new $n(n.shape,YE),r=e.runWebGLProgram(t,[n],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}/** 8534 * @license 8535 * Copyright 2020 Google LLC. All Rights Reserved. 8536 * Licensed under the Apache License, Version 2.0 (the "License"); 8537 * you may not use this file except in compliance with the License. 8538 * You may obtain a copy of the License at 8539 * 8540 * http://www.apache.org/licenses/LICENSE-2.0 8541 * 8542 * Unless required by applicable law or agreed to in writing, software 8543 * distributed under the License is distributed on an "AS IS" BASIS, 8544 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8545 * See the License for the specific language governing permissions and 8546 * limitations under the License. 8547 * ============================================================================= 8548 */function lu(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{dtype:s}=r;if(s==="complex64"){if(a.dtype==="complex64")return Rt({inputs:{x:a},backend:t});const o=Fr(a.shape),i=lu({inputs:{x:a},backend:t,attrs:{dtype:"float32"}}),u=ir({inputs:{real:i,imag:o},backend:t});
vendor: 4,162 bytes, lines 8548-8624
8548return o.dispose(),t.disposeIntermediateTensorInfo(i),u}if(a.dtype==="complex64"){const o=ws({inputs:{input:a},backend:t}),i=lu({inputs:{x:o},backend:t,attrs:{dtype:s}});return t.disposeIntermediateTensorInfo(o),i}if(!b2(a.dtype,s)){const o=Rt({inputs:{x:a},backend:t});return{dataId:o.dataId,shape:o.shape,dtype:s}}if(t.shouldExecuteOnCPU([a])){const o=t.texData.get(a.dataId).values,[i,u,l]=ak(o,a.shape,a.dtype,s);return t.makeTensorInfo(i,u,l)}if(s==="int32")return ZE(a,t);if(s==="bool"){const o=t.makeTensorInfo([],"bool",On("bool",1)),i=Tm({inputs:{a,b:o},backend:t});return t.disposeIntermediateTensorInfo(o),i}throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${s}`)}const JE={kernelName:Iu,backendName:"webgl",kernelFunc:lu};/** 8549 * @license 8550 * Copyright 2020 Google LLC. All Rights Reserved. 8551 * Licensed under the Apache License, Version 2.0 (the "License"); 8552 * you may not use this file except in compliance with the License. 8553 * You may obtain a copy of the License at 8554 * 8555 * http://www.apache.org/licenses/LICENSE-2.0 8556 * 8557 * Unless required by applicable law or agreed to in writing, software 8558 * distributed under the License is distributed on an "AS IS" BASIS, 8559 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8560 * See the License for the specific language governing permissions and 8561 * limitations under the License. 8562 * ============================================================================= 8563 */const uc="return ceil(x);",QE=Ie({opSnippet:uc,packedOpSnippet:uc,cpuKernelImpl:sk}),eC={kernelName:cp,backendName:"webgl",kernelFunc:QE};/** 8564 * @license 8565 * Copyright 2017 Google LLC. All Rights Reserved. 8566 * Licensed under the Apache License, Version 2.0 (the "License"); 8567 * you may not use this file except in compliance with the License. 8568 * You may obtain a copy of the License at 8569 * 8570 * http://www.apache.org/licenses/LICENSE-2.0 8571 * 8572 * Unless required by applicable law or agreed to in writing, software 8573 * distributed under the License is distributed on an "AS IS" BASIS, 8574 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8575 * See the License for the specific language governing permissions and 8576 * limitations under the License. 8577 * ============================================================================= 8578 */class tC{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` 8579 8580 void main() { 8581 float value = getAAtOutCoords(); 8582 if (isnan(value)) { 8583 setOutput(value); 8584 return; 8585 } 8586 8587 setOutput(clamp(value, minVal, maxVal)); 8588 } 8589 `}}/** 8590 * @license 8591 * Copyright 2018 Google LLC. All Rights Reserved. 8592 * Licensed under the Apache License, Version 2.0 (the "License"); 8593 * you may not use this file except in compliance with the License. 8594 * You may obtain a copy of the License at 8595 * 8596 * http://www.apache.org/licenses/LICENSE-2.0 8597 * 8598 * Unless required by applicable law or agreed to in writing, software 8599 * distributed under the License is distributed on an "AS IS" BASIS, 8600 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8601 * See the License for the specific language governing permissions and 8602 * limitations under the License. 8603 * ============================================================================= 8604 */class nC{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` 8605 void main() { 8606 vec4 value = getAAtOutCoords(); 8607 8608 if (any(isnan(value))) { 8609 setOutput(value); 8610 return; 8611 } 8612 8613 setOutput(clamp(value, vec4(minVal), vec4(maxVal))); 8614 } 8615 `}}/** 8616 * @license 8617 * Copyright 2020 Google LLC. All Rights Reserved. 8618 * Licensed under the Apache License, Version 2.0 (the "License"); 8619 * you may not use this file except in compliance with the License. 8620 * You may obtain a copy of the License at 8621 * 8622 * http://www.apache.org/licenses/LICENSE-2.0 8623 * 8624 * Unless required by applicable law or agreed to in writing, softw
8624are 8625 * distributed under the License is distributed on an "AS IS" BASIS, 8626 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8627 * See the License for the specific language governing permissions and 8628 * limitations under the License. 8629 * ============================================================================= 8630 */function rC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{clipValueMin:s,clipValueMax:o}=r;let i;H().getBool("WEBGL_PACK_CLIP")?i=new nC(a.shape):i=new tC(a.shape);const u=[[s],[o]];return t.runWebGLProgram(i,[a],a.dtype,u)}const aC={kernelName:pp,backendName:"webgl",kernelFunc:rC};/** 8631 * @license 8632 * Copyright 2018 Google LLC. All Rights Reserved. 8633 * Licensed under the Apache License, Version 2.0 (the "License"); 8634 * you may not use this file except in compliance with the License. 8635 * You may obtain a copy of the License at 8636 * 8637 * http://www.apache.org/licenses/LICENSE-2.0 8638 * 8639 * Unless required by applicable law or agreed to in writing, software 8640 * distributed under the License is distributed on an "AS IS" BASIS, 8641 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8642 * See the License for the specific language governing permissions and 8643 * limitations under the License. 8644 * ============================================================================= 8645 */class sC{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` 8646 void main() { 8647 float re = abs(getRealAtOutCoords()); 8648 float im = abs(getImagAtOutCoords()); 8649 float mx = max(re, im); 8650 8651 // sadly the length function in glsl is not underflow-safe 8652 // (at least not on Intel GPUs). So the safe solution is 8653 // to ensure underflow-safety in all cases. 8654 setOutput( 8655 mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx)) 8656 ); 8657 } 8658 `}}/** 8659 * @license 8660 * Copyright 2020 Google LLC. All Rights Reserved. 8661 * Licensed under the Apache License, Version 2.0 (the "License"); 8662 * you may not use this file except in compliance with the License. 8663 * You may obtain a copy of the License at 8664 * 8665 * http://www.apache.org/licenses/LICENSE-2.0 8666 * 8667 * Unless required by applicable law or agreed to in writing, software 8668 * distributed under the License is distributed on an "AS IS" BASIS, 8669 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8670 * See the License for the specific language governing permissions and 8671 * limitations under the License. 8672 * ============================================================================= 8673 */function lc(n,e){return{dataId:e.dataId,dtype:e.dtype,shape:n.shape}}function oC(n){const{inputs:e,backend:t}=n,{x:r}=e,a=t.texData.get(r.dataId),s=new sC(r.shape),o=[lc(r,a.complexTensorInfos.real),lc(r,a.complexTensorInfos.imag)];return t.runWebGLProgram(s,o,o[0].dtype)}const iC={kernelName:dp,backendName:"webgl",kernelFunc:oC};/** 8674 * @license 8675 * Copyright 2017 Google LLC. All Rights Reserved. 8676 * Licensed under the Apache License, Version 2.0 (the "License"); 8677 * you may not use this file except in compliance with the License. 8678 * You may obtain a copy of the License at 8679 * 8680 * http://www.apache.org/licenses/LICENSE-2.0 8681 * 8682 * Unless required by applicable law or agreed to in writing, software 8683 * distributed under the License is distributed on an "AS IS" BASIS, 8684 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8685 * See the License for the specific language governing permissions and 8686 * limitations under the License. 8687 * ============================================================================= 8688 */class uC{constructor(e){this.outputShape=[],this.outputShape=Mr(e,1),this.variableNames=e.map((o,i)=>`T${i}`);const t=new Array(e.length-1);t[0]=e[0][1];for(let o=1;o<t.length;o++)t[o]=t[o-1]+e[o][1];const r=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let o=1;o<t.length;o++){const i=t[o-1];r.push(`else if (yC < ${t[o]}) setOutput(getT${o}(yR, yC-${i}));`)}const a=t.length,s=t[t.length-1];r.push(`else setOutput(getT${a}(yR, yC-${s}));`),this.userCode=` 8689 void main() { 8690 ivec2 coords = getOutputCoords(); 8691 int yR = coords.x; 8692 int yC = coords.y; 8693 8694 ${r.join(` 8695 `)} 8696 } 8697 `}}/** 8698 * @license 8699 * Copyright 2019 Google LLC. All Rights Reserved. 8700 * Licensed under the Apache License, Version 2.0 (the "License");
8701 * you may not use this file except in compliance with the License. 8702 * You may obtain a copy of the License at 8703 * 8704 * http://www.apache.org/licenses/LICENSE-2.0 8705 * 8706 * Unless required by applicable law or agreed to in writing, software 8707 * distributed under the License is distributed on an "AS IS" BASIS, 8708 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8709 * See the License for the specific language governing permissions and 8710 * limitations under the License. 8711 * ============================================================================= 8712 */class lC{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=Mr(e,t);const r=this.outputShape,a=r.length,s=Be(a),o=ft("coords",a),i=["x","y","z","w","u","v"].slice(0,a);this.variableNames=e.map((y,b)=>`T${b}`);const u=new Array(e.length-1);u[0]=e[0][t];for(let y=1;y<u.length;y++)u[y]=u[y-1]+e[y][t];const l=i[t],c=i.slice(-2),p=i.join();let h=`if (${l} < ${u[0]}) { 8713 return getChannel( 8714 getT0(${p}), vec2(${c.join()})); 8715 }`;for(let y=1;y<u.length;y++){const b=u[y-1];h+=` 8716 if (${l} < ${u[y]} && ${l} >= ${u[y-1]}) { 8717 return getChannel( 8718 getT${y}(${qs(i,l,b)}), 8719 vec2(${qs(c,l,b)})); 8720 }`}const d=u.length,m=u[u.length-1];h+=` 8721 return getChannel( 8722 getT${d}(${qs(i,l,m)}), 8723 vec2(${qs(c,l,m)}));`,this.userCode=` 8724 float getValue(${i.map(y=>"int "+y)}) { 8725 ${h} 8726 } 8727 8728 void main() { 8729 ${s} coords = getOutputCoords(); 8730 vec4 result = vec4(getValue(${o}), 0., 0., 0.); 8731 8732 ${o[a-1]} = ${o[a-1]} + 1; 8733 if (${o[a-1]} < ${r[a-1]}) { 8734 result.g = getValue(${o}); 8735 } 8736 8737 ${o[a-2]} = ${o[a-2]} + 1; 8738 if (${o[a-2]} < ${r[a-2]}) { 8739 result.a = getValue(${o}); 8740 } 8741 8742 ${o[a-1]} = ${o[a-1]} - 1; 8743 if (${o[a-2]} < ${r[a-2]} && 8744 ${o[a-1]} < ${r[a-1]}) { 8745 result.b = getValue(${o}); 8746 } 8747 setOutput(result); 8748 } 8749 `}}function qs(n,e,t){const r=n.indexOf(e);return n.map((a,s)=>s===r?`${a} - ${t}`:a).join()}/** 8750 * @license 8751 * Copyright 2020 Google LLC. All Rights Reserved. 8752 * Licensed under the Apache License, Version 2.0 (the "License"); 8753 * you may not use this file except in compliance with the License. 8754 * You may obtain a copy of the License at 8755 * 8756 * http://www.apache.org/licenses/LICENSE-2.0 8757 * 8758 * Unless required by applicable law or agreed to in writing, software 8759 * distributed under the License is distributed on an "AS IS" BASIS, 8760 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8761 * See the License for the specific language governing permissions and 8762 * limitations under the License. 8763 * ============================================================================= 8764 */function Uo(n){const{inputs:e,backend:t}=n,{input:r}=e,a=t.texData.get(r.dataId);return Rt({inputs:{x:a.complexTensorInfos.imag},backend:t})}const cC={kernelName:Zp,backendName:"webgl",kernelFunc:Uo};/** 8765 * @license 8766 * Copyright 2020 Google LLC. All Rights Reserved. 8767 * Licensed under the Apache License, Version 2.0 (the "License"); 8768 * you may not use this file except in compliance with the License. 8769 * You may obtain a copy of the License at 8770 * 8771 * http://www.apache.org/licenses/LICENSE-2.0 8772 * 8773 * Unless required by applicable law or agreed to in writing, software 8774 * distributed under the License is distributed on an "AS IS" BASIS, 8775 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8776 * See the License for the specific language governing permissions and 8777 * limitations under the License. 8778 * ============================================================================= 8779 */function Ja(n,e,t){const r=n[0].dtype;if(r==="complex64"){const p=n.map(b=>ws({inputs:{input:b},backend:t})),h=n.map(b=>Uo({inputs:{input:b},backend:t})),d=Ja(p,e,t),m=Ja(h,e,t),y=ir({inputs:{real:d,imag:m},backend:t});return p.forEach(b=>t.disposeIntermediateTensorInfo(b)),h.forEach(b=>t.disposeIntermediateTensorInfo(b)),t.disposeIntermediateTensorInfo(d),t.dis
vendor: 10,961 bytes, lines 8779-9034
8779poseIntermediateTensorInfo(m),y}let a=t.shouldExecuteOnCPU(n);if(r==="string"&&(a=!0),a){const p=n.map(T=>{const $=[-1,ae(T.shape.slice(e))];return oe({inputs:{x:T},backend:t,attrs:{shape:$}})}),h=p.map(T=>({vals:t.readSync(T.dataId),shape:T.shape})),d=Mr(p.map(T=>T.shape),1),m=p[0].shape[0]===1,y=ok(h,d,r,m),b=Mr(n.map(T=>T.shape),e),x=t.makeTensorInfo(b,r,y);return p.forEach(T=>t.disposeIntermediateTensorInfo(T)),x}const s=H().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(n.length>s){const p=[];for(let d=0;d<n.length;d+=s){const m=n.slice(d,d+s);p.push(Ja(m,e,t))}const h=Ja(p,e,t);for(const d of p)t.disposeIntermediateTensorInfo(d);return h}if(H().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&n[0].shape.length>1){const p=new lC(n.map(h=>h.shape),e);return t.runWebGLProgram(p,n,r)}const{tensors2D:o,outShape:i}=pC(n,e,t),u=new uC(o.map(p=>p.shape)),l=t.runWebGLProgram(u,o,r);o.forEach(p=>t.disposeIntermediateTensorInfo(p));const c=oe({inputs:{x:l},attrs:{shape:i},backend:t});return t.disposeIntermediateTensorInfo(l),c}function pC(n,e,t){const r=Mr(n.map(a=>a.shape),e);return{tensors2D:n.map(a=>oe({inputs:{x:a},attrs:{shape:[-1,ae(a.shape.slice(e))]},backend:t})),outShape:r}}/** 8780 * @license 8781 * Copyright 2020 Google LLC. All Rights Reserved. 8782 * Licensed under the Apache License, Version 2.0 (the "License"); 8783 * you may not use this file except in compliance with the License. 8784 * You may obtain a copy of the License at 8785 * 8786 * http://www.apache.org/licenses/LICENSE-2.0 8787 * 8788 * Unless required by applicable law or agreed to in writing, software 8789 * distributed under the License is distributed on an "AS IS" BASIS, 8790 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8791 * See the License for the specific language governing permissions and 8792 * limitations under the License. 8793 * ============================================================================= 8794 */function Em(n){const{inputs:e,backend:t,attrs:r}=n,{axis:a}=r,s=rt(a,e[0].shape)[0],o=e.map(l=>l.shape);f1(o,s);const i=Mr(e.map(l=>l.shape),s);if(ae(i)===0)return t.makeTensorInfo(i,e[0].dtype,[]);const u=e.filter(l=>ae(l.shape)>0);return u.length===1?Rt({inputs:{x:u[0]},backend:t}):Ja(u,s,t)}const hC={kernelName:fp,backendName:"webgl",kernelFunc:Em};/** 8795 * @license 8796 * Copyright 2017 Google LLC. All Rights Reserved. 8797 * Licensed under the Apache License, Version 2.0 (the "License"); 8798 * you may not use this file except in compliance with the License. 8799 * You may obtain a copy of the License at 8800 * 8801 * http://www.apache.org/licenses/LICENSE-2.0 8802 * 8803 * Unless required by applicable law or agreed to in writing, software 8804 * distributed under the License is distributed on an "AS IS" BASIS, 8805 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8806 * See the License for the specific language governing permissions and 8807 * limitations under the License. 8808 * ============================================================================= 8809 */class Cm{constructor(e,t=!1,r=null,a=!1,s=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const o=e.padInfo.top,i=e.padInfo.left,u=e.strideHeight,l=e.strideWidth,c=e.dilationHeight,p=e.dilationWidth,h=e.filterHeight,d=e.filterWidth,m=Math.floor(e.inChannels/4)*4,y=e.inChannels%4,b=e.dataFormat==="channelsLast",x=b?1:2,T=b?2:3,$=b?3:1;let F="",M="";r&&(a?F=`float activation(float a) { 8810 float b = getPreluActivationWeightsAtOutCoords(); 8811 ${r} 8812 }`:s?F=`float activation(float a) { 8813 float b = getLeakyreluAlphaAtOutCoords(); 8814 ${r} 8815 }`:F=` 8816 float activation(float x) { 8817 ${r} 8818 } 8819 `,M="result = activation(result);");const U=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 8820 ${F} 8821 8822 const ivec2 strides = ivec2(${u}, ${l}); 8823 const ivec2 pads = ivec2(${o}, ${i}); 8824 8825 void main() { 8826 ivec4 coords = getOutputCoords(); 8827 int batch = coords[0]; 8828 int d2 = coords[${$}]; 8829 8830 ivec2 xRCCorner = 8831 ivec2(coords[${x}], coords[${T}]) * strides - pads; 8832 int xRCorner = xRCCorner.x; 8833 int xCCorner = xRCCorner.y; 8834 8835 // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2). 8836 // ? = to be determined. : = across all values in that axis. 8837 float dotProd = 0.0; 8838 for (int wR = 0; wR < ${h}; wR++) { 8839 int xR = xRCorner + wR * ${c}; 8840 8841 if (xR < 0 || xR >= ${e.inHeight}) { 8842 continue; 8843 } 8844 8845 for (int wC = 0; wC < ${d}; wC++) { 8846 int xC = xCCorner + wC * ${p}; 8847 8848 if (xC < 0 || xC >= ${e.inWidth}) { 8849 continue; 8850 } 8851 8852 for (int d1 = 0; d1 < ${m}; d1 += 4) { 8853 vec4 wValues = vec4( 8854 getW(wR, wC, d1, d2), 8855 getW(wR, wC, d1 + 1, d2), 8856 getW(wR, wC, d1 + 2, d2), 8857 getW(wR, wC, d1 + 3, d2) 8858 ); 8859 8860 if (${b}) { 8861 vec4 xValues = vec4( 8862 getX(batch, xR, xC, d1), 8863 getX(batch, xR, xC, d1 + 1), 8864 getX(batch, xR, xC, d1 + 2), 8865 getX(batch, xR, xC, d1 + 3) 8866 ); 8867 dotProd += dot(xValues, wValues); 8868 } else { 8869 vec4 xValues = vec4( 8870 getX(batch, d1, xR, xC), 8871 getX(batch, d1 + 1, xR, xC), 8872 getX(batch, d1 + 2, xR, xC), 8873 getX(batch, d1 + 3, xR, xC) 8874 ); 8875 dotProd += dot(xValues, wValues); 8876 } 8877 } 8878 8879 if (${y===1}) { 8880 8881 if (${b}) { 8882 dotProd += 8883 getX(batch, xR, xC, ${m}) * 8884 getW(wR, wC, ${m}, d2); 8885 } else { 8886 dotProd += 8887 getX(batch, ${m}, xR, xC) * 8888 getW(wR, wC, ${m}, d2); 8889 } 8890 8891 } else if (${y===2}) { 8892 vec2 wValues = vec2( 8893 getW(wR, wC, ${m}, d2), 8894 getW(wR, wC, ${m} + 1, d2) 8895 ); 8896 8897 if (${b}) { 8898 vec2 xValues = vec2( 8899 getX(batch, xR, xC, ${m}), 8900 getX(batch, xR, xC, ${m} + 1) 8901 ); 8902 dotProd += dot(xValues, wValues); 8903 } else { 8904 vec2 xValues = vec2( 8905 getX(batch, ${m}, xR, xC), 8906 getX(batch, ${m} + 1, xR, xC) 8907 ); 8908 dotProd += dot(xValues, wValues); 8909 } 8910 8911 } else if (${y===3}) { 8912 vec3 wValues = vec3( 8913 getW(wR, wC, ${m}, d2), 8914 getW(wR, wC, ${m} + 1, d2), 8915 getW(wR, wC, ${m} + 2, d2) 8916 ); 8917 8918 if (${b}) { 8919 vec3 xValues = vec3( 8920 getX(batch, xR, xC, ${m}), 8921 getX(batch, xR, xC, ${m} + 1), 8922 getX(batch, xR, xC, ${m} + 2) 8923 ); 8924 dotProd += dot(xValues, wValues); 8925 } else { 8926 vec3 xValues = vec3( 8927 getX(batch, ${m}, xR, xC), 8928 getX(batch, ${m} + 1, xR, xC), 8929 getX(batch, ${m} + 2, xR, xC) 8930 ); 8931 dotProd += dot(xValues, wValues); 8932 } 8933 8934 } 8935 } 8936 } 8937 8938 float result = dotProd; 8939 ${U} 8940 ${M} 8941 setOutput(result); 8942 } 8943 `}}class dC{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,r=e.padInfo.top,a=e.padInfo.left,s=e.strideDepth,o=e.strideHeight,i=e.strideWidth,u=e.dilationDepth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterDepth,h=e.filterHeight,d=e.filterWidth,m=Math.floor(e.inChannels/4)*4,y=e.inChannels%4;this.userCode=` 8944 const ivec3 strides = ivec3(${s}, ${o}, ${i}); 8945 const ivec3 pads = ivec3(${t}, ${r}, ${a}); 8946 8947 void main() { 8948 ivec5 coords = getOutputCoords(); 8949 int batch = coords.x; 8950 int d2 = coords.u; 8951 8952 ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 8953 int xFCorner = xFRCCorner.x; 8954 int xRCorner = xFRCCorner.y; 8955 int xCCorner = xFRCCorner.z; 8956 8957 // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get 8958 // y(yF, yR, yC, d2). ? = to be determined. : = across all 8959 // values in that axis. 8960 float dotProd = 0.0; 8961 for (int wF = 0; wF < ${p}; wF++) { 8962 int xF = xFCorner + wF * ${u}; 8963 8964 if (xF < 0 || xF >= ${e.inDepth}) { 8965 continue; 8966 } 8967 8968 for (int wR = 0; wR < ${h}; wR++) { 8969 int xR = xRCorner + wR * ${l}; 8970 8971 if (xR < 0 || xR >= ${e.inHeight}) { 8972 continue; 8973 } 8974 8975 for (int wC = 0; wC < ${d}; wC++) { 8976 int xC = xCCorner + wC * ${c}; 8977 8978 if (xC < 0 || xC >= ${e.inWidth}) { 8979 continue; 8980 } 8981 8982 for (int d1 = 0; d1 < ${m}; d1 += 4) { 8983 vec4 xValues = vec4( 8984 getX(batch, xF, xR, xC, d1), 8985 getX(batch, xF, xR, xC, d1 + 1), 8986 getX(batch, xF, xR, xC, d1 + 2), 8987 getX(batch, xF, xR, xC, d1 + 3) 8988 ); 8989 vec4 wValues = vec4( 8990 getW(wF, wR, wC, d1, d2), 8991 getW(wF, wR, wC, d1 + 1, d2), 8992 getW(wF, wR, wC, d1 + 2, d2), 8993 getW(wF, wR, wC, d1 + 3, d2) 8994 ); 8995 8996 dotProd += dot(xValues, wValues); 8997 } 8998 8999 if (${y===1}) { 9000 dotProd += 9001 getX(batch, xF, xR, xC, ${m}) * 9002 getW(wF, wR, wC, ${m}, d2); 9003 } else if (${y===2}) { 9004 vec2 xValues = vec2( 9005 getX(batch, xF, xR, xC, ${m}), 9006 getX(batch, xF, xR, xC, ${m} + 1) 9007 ); 9008 vec2 wValues = vec2( 9009 getW(wF, wR, wC, ${m}, d2), 9010 getW(wF, wR, wC, ${m} + 1, d2) 9011 ); 9012 dotProd += dot(xValues, wValues); 9013 } else if (${y===3}) { 9014 vec3 xValues = vec3( 9015 getX(batch, xF, xR, xC, ${m}), 9016 getX(batch, xF, xR, xC, ${m} + 1), 9017 getX(batch, xF, xR, xC, ${m} + 2) 9018 ); 9019 vec3 wValues = vec3( 9020 getW(wF, wR, wC, ${m}, d2), 9021 getW(wF, wR, wC, ${m} + 1, d2), 9022 getW(wF, wR, wC, ${m} + 2, d2) 9023 ); 9024 dotProd += dot(xValues, wValues); 9025 } 9026 } 9027 } 9028 } 9029 setOutput(dotProd); 9030 } 9031 `}}/** 9032 * @license 9033 * Copyright 2022 Google LLC. All Rights Reserved. 9034 * Licensed under the Apache License, Version 2.0 (the "License");
9035 * you may not use this file except in compliance with the License. 9036 * You may obtain a copy of the License at 9037 * 9038 * http://www.apache.org/licenses/LICENSE-2.0 9039 * 9040 * Unless required by applicable law or agreed to in writing, software 9041 * distributed under the License is distributed on an "AS IS" BASIS, 9042 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9043 * See the License for the specific language governing permissions and 9044 * limitations under the License. 9045 * ============================================================================= 9046 */class Im{constructor(e,t=!1,r=null,a=!1,s=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=bt(this.outputShape.length);const o=e.padInfo.left,i=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=c;let h=` 9047 int xR; int xC; int xCOffset; 9048 vec4 wTexel; vec4 previous; vec4 final;`;for(let b=0;b<c;b++)h+=` 9049 vec4 xTexelC${b*2}; 9050 int xTexelC${b*2}Ready; 9051 vec4 xTexelC${b*2+1}; 9052 int xTexelC${b*2+1}Ready; 9053 vec4 xC${b};`;h+=` 9054 for (int r = 0; r < ${l}; r++) { 9055 for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) { 9056 `;for(let b=0;b<c;b++)h+=` 9057 xTexelC${b*2} = vec4(0.0); 9058 xTexelC${b*2}Ready = 0; 9059 xTexelC${b*2+1} = vec4(0.0); 9060 xTexelC${b*2+1}Ready = 0; 9061 xC${b} = vec4(0.0);`;h+=` 9062 xR = xRCorner + r * dilations[0]; 9063 if (xR >=0 && xR < inDims[0]) { 9064 `;for(let b=0;b<(p+1)/2;b++){const x=b*2;if(h+=` 9065 xC = xCCorner + ${x*u}; 9066 `,i===1){if(x<c&&(o%2===1?(h+=` 9067 xCOffset = xC + 1; 9068 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x}Ready == 0) { 9069 xTexelC${x} = getX(batch, xR, xCOffset, d1); 9070 9071 // Need to manually clear unused channels in case 9072 // we're reading from recycled texture. 9073 if (xCOffset + 1 >= inDims[1]) { 9074 xTexelC${x}.zw = vec2(0.0); 9075 } 9076 xTexelC${x}Ready = 1; 9077 } 9078 `,u===1&&x>0?h+=` 9079 xC${x} = vec4(xTexelC${x-2}.zw, xTexelC${x}.xy); 9080 `:h+=` 9081 xCOffset = xC + 1 - 2; 9082 9083 if (xCOffset >= 0 && xCOffset < inDims[1]) { 9084 previous = getX(batch, xR, xCOffset, d1); 9085 9086 // Need to manually clear unused channels in case 9087 // we're reading from recycled texture. 9088 if (xCOffset + 1 >= inDims[1]) { 9089 previous.zw = vec2(0.0); 9090 } 9091 9092 xC${x} = vec4(previous.zw, xTexelC${x}.xy); 9093 } else { 9094 xC${x} = vec4(0.0, 0.0, xTexelC${x}.xy); 9095 } 9096 `):h+=` 9097 if (xC >= 0 && xC < inDims[1] && xTexelC${x}Ready == 0) { 9098 xTexelC${x} = getX(batch, xR, xC, d1); 9099 if (xC + 1 >= inDims[1]) { 9100 xTexelC${x}.zw = vec2(0.0); 9101 } 9102 xTexelC${x}Ready = 1; 9103 } 9104 9105 xC${x} = xTexelC${x}; 9106 `,x+1<c)){const T=o%2===0?ku(u):u;u%2===0&&o%2===1||u%2!==0&&o%2!==1?(h+=` 9107 xCOffset = xC + imod(pads[1], 2) + ${T}; 9108 9109 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x+1}Ready == 0) { 9110 xTexelC${x+1} = getX(batch, xR, xCOffset, d1); 9111 9112 // Need to manually clear unused channels in case 9113 // we're reading from recycled texture. 9114 if (xCOffset + 1 >= inDims[1]) { 9115 xTexelC${x+1}.zw = vec2(0.0); 9116 } 9117 xTexelC${x+1}Ready = 1; 9118 } 9119 `,u>1?h+=` 9120 xCOffset -= 2; 9121 if (xCOffset >= 0 && xCOffset < inDims[1]) { 9122 previous = getX(batch, xR, xCOffset, d1); 9123 xC${x+1} = vec4(previous.zw, xTexelC${x+1}.xy); 9124 } else { 9125 xC${x+1} = vec4(0.0, 0.0, xTexelC${x+1}.xy); 9126 } 9127 `:h+=` 9128 xC${x+1} = vec4(xTexelC${x}.zw, xTexelC${x+1}.xy); 9129 `):T===1?h+=` 9130 xC${x+1} = xTexelC${x}; 9131 `:h+=` 9132 xCOffset = xC + ${T}; 9133 9134 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x+1}Ready == 0) { 9135 xTexelC${x+1} = getX(batch, xR, xCOffset, d1); 9136 if (xCOffset + 1 >= inDims[1]) { 9137 xTexelC${x+1}.zw = vec2(0.0); 9138 } 9139 xTexelC${x+1}Ready = 1; 9140 } 9141 9142 xC${x+1} = xTexelC${x+1}; 9143 `}}else x<c&&(o%2===1?(h+=` 9144 xCOffset = xC + 1 - strides[1]; 9145 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x}Ready == 0) { 9146 xTexelC${x} = getX(batch, xR, xCOffset, d1); 9147 // Need to manually clear unused channels in case 9148 // we're reading from recycled texture. 9149 if (xCOffset + 1 >= inDims[1]) { 9150 xTexelC${x}.zw = vec2(0.0); 9151 } 9152 xTexelC${x}Ready = 1; 9153 } 9154 9155 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${x+1}Ready == 0) { 9156 xTexelC${x+1} = getX(batch, xR, xC + 1, d1); 9157 // Need to manually clear unused channels in case 9158 // we're reading from recycled texture. 9159 if (xC + 2 >= inDims[1]) { 9160 xTexelC${x+1}.zw = vec2(0.0); 9161 } 9162 xTexelC${x+1}Ready = 1; 9163 } 9164 9165 xC${x} = vec4(xTexelC${x}.zw, xTexelC${x+1}.zw); 9166 `,x+1<c&&(h+=` 9167 final = vec4(0.0); 9168 xCOffset = xC + 1 + strides[1]; 9169 if(xCOffset >= 0 && xCOffset < inDims[1]) { 9170 final = getX(batch, xR, xCOffset, d1); 9171 } 9172 xC${x+1} = vec4(xTexelC${x+1}.xy, final.xy); 9173 `)):(h+=` 9174 if(xC >= 0 && xC < inDims[1] && xTexelC${x}Ready == 0) { 9175 xTexelC${x} = getX(batch, xR, xC, d1); 9176 if (xC + 1 >= inDims[1]) { 9177 xTexelC${x}.zw = vec2(0.0); 9178 } 9179 xTexelC${x}Ready = 1; 9180 } 9181 9182 xCOffset = xC + strides[1]; 9183 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x+1}Ready == 0) { 9184 xTexelC${x+1} = getX(batch, xR, xCOffset, d1); 9185 if (xCOffset + 1 >= inDims[1]) { 9186 xTexelC${x+1}.zw = vec2(0.); 9187 } 9188 xTexelC${x+1}Ready = 1; 9189 } 9190 9191 xC${x} = vec4( 9192 xTexelC${x}.xy, xTexelC${x+1}.xy); 9193 `,x+1<c&&(h+=` 9194 xC${x+1} = vec4(xTexelC${x}.zw, xTexelC${x+1}.zw); 9195 `)));x<c&&(h+=` 9196 wTexel = getW(r, ${x}, d1, d2); 9197 dotProd += xC${x}.xxzz * vec4(wTexel.xy, wTexel.xy); 9198 if(d1 + 1 < ${e.inChannels}) { 9199 dotProd += xC${x}.yyww * vec4(wTexel.zw, wTexel.zw); 9200 } 9201 `,x+1<c&&(h+=` 9202 wTexel = getW(r, ${x+1}, d1, d2); 9203 dotProd += xC${x+1}.xxzz * vec4(wTexel.xy, wTexel.xy); 9204 if(d1 + 1 < ${e.inChannels}) { 9205 dotProd += xC${x+1}.yyww * vec4(wTexel.zw, wTexel.zw); 9206 } 9207 `))}h+=` 9208 } 9209 `,h+=` 9210 } 9211 `,h+=` 9212 } 9213 `;let d="",m="";r&&(a?d=`vec4 activation(vec4 a) { 9214 vec4 b = getPreluActivationWeightsAtOutCoords(); 9215 ${r} 9216 }`:s?d=`vec4 activation(vec4 a) { 9217 vec4 b = getLeakyreluAlphaAtOutCoords(); 9218 ${r} 9219 }`:d=`vec4 activation(vec4 x) { 9220 ${r} 9221 }`,m="result = activation(result);");const y=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 9222 ${d} 9223 9224 void main() { 9225 ivec4 coords = getOutputCoords(); 9226 int batch = coords.x; 9227 ivec2 xRCCorner = coords.yz * strides - pads; 9228 int d2 = coords.w; 9229 int xRCorner = xRCCorner.x; 9230 int xCCorner = xRCCorner.y; 9231 9232 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 9233 vec4 dotProd = vec4(0.000000000000001); 9234 9235 ${h} 9236 9237 vec4 result = dotProd - vec4(0.000000000000001); 9238 ${y} 9239 ${m} 9240 setOutput(result); 9241 } 9242 `}}/** 9243 * @license 9244 * Copyright 2019 Google LLC. All Rights Reserved. 9245 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 6,765 bytes, lines 9246-9322
9246 * you may not use this file except in compliance with the License. 9247 * You may obtain a copy of the License at 9248 * 9249 * http://www.apache.org/licenses/LICENSE-2.0 9250 * 9251 * Unless required by applicable law or agreed to in writing, software 9252 * distributed under the License is distributed on an "AS IS" BASIS, 9253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9254 * See the License for the specific language governing permissions and 9255 * limitations under the License. 9256 * ============================================================================= 9257 */class fC{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=bt(this.outputShape.length);const{dataFormat:r}=t,a=xt(),s=r==="channelsLast",o=s?1:2,i=s?2:3,u=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let l="";for(let c=0;c<=1;c++)for(let p=0;p<=1;p++)l+=` 9258 blockIndex = rc.z + ${p}; 9259 pos = rc.y + ${c}; 9260 9261 ${u} 9262 offsetY = int(blockIndex / outWidth) * stride[0] - pad[0]; 9263 d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow); 9264 9265 if(d0 < inputShape[${o}] && d0 >= 0) { 9266 // Use custom imod instead mod. On Intel GPU, mod may generate 9267 // unexpected value. 9268 // https://github.com/tensorflow/tfjs/issues/5447 9269 offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1]; 9270 d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) / 9271 inChannels); 9272 9273 if(d1 < inputShape[${i}] && d1 >= 0) { 9274 9275 ch = imod(pos, inChannels); 9276 9277 if (${s}) { 9278 innerDims = vec2(d1, ch); 9279 result[${c*2+p}] = getChannel( 9280 getA(rc.x, d0, int(innerDims.x), 9281 int(innerDims.y)), innerDims); 9282 } else { 9283 innerDims = vec2(d0, d1); 9284 result[${c*2+p}] = getChannel( 9285 getA(rc.x, ch, int(innerDims.x), 9286 int(innerDims.y)), innerDims); 9287 } 9288 } 9289 } 9290 } 9291 `;this.userCode=` 9292 void main() { 9293 ivec3 rc = getOutputCoords(); 9294 9295 vec4 result = vec4(0); 9296 9297 int blockIndex, pos, offsetY, d0, offsetX, d1, ch; 9298 vec2 innerDims; 9299 9300 ${l} 9301 9302 ${a.output} = result; 9303 } 9304 `}}/** 9305 * @license 9306 * Copyright 2020 Google LLC. All Rights Reserved. 9307 * Licensed under the Apache License, Version 2.0 (the "License"); 9308 * you may not use this file except in compliance with the License. 9309 * You may obtain a copy of the License at 9310 * 9311 * http://www.apache.org/licenses/LICENSE-2.0 9312 * 9313 * Unless required by applicable law or agreed to in writing, software 9314 * distributed under the License is distributed on an "AS IS" BASIS, 9315 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9316 * See the License for the specific language governing permissions and 9317 * limitations under the License. 9318 * ============================================================================= 9319 */function ho(n,e){const t=n.length;return t>=3?e?[...n.slice(0,-3),n[t-3]*n[t-2],n[t-1]]:[...n.slice(0,-3),n[t-3],n[t-2]*n[t-1]]:!e&&t===1&&n[0]>1?[n[0],1]:null}function Nm({x:n,filter:e,convInfo:t,backend:r,bias:a=null,preluActivationWeights:s=null,leakyreluAlpha:o=0,activation:i=null}){const u=n.shape,l=r.texData.get(n.dataId),c=t.inChannels,p=u[0]*u[1]*u[2],h=t.outChannels,d=t.dataFormat==="channelsLast",m=!1,y=!1;let b;const x=[];if(s!=null){const T=ho(s.shape,d);T!=null&&(s=oe({inputs:{x:s},backend:r,attrs:{shape:T}}),x.push(s))}if(a!=null){const T=ho(a.shape,d);T!=null&&(a=oe({inputs:{x:a},backend:r,attrs:{shape:T}}),x.push(a))}if(!((p===1||h===1)&&c>vm)&&l.isPacked&&d&&l.texture!=null&&u[2]%2!==0&&qe(l.shape.slice(-3),u.slice(-3))){const T=u[0]*u[1]*(u[2]+1),$={dataId:n.dataId,shape:[1,T,t.inChannels],dtype:n.dtype},F=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,R(lo(l.shape,$.shape),()=>`packed reshape ${l.shape} to ${$.shape} isn't free`);const M=oe({inputs:{x:e},backend:r,attrs:{shape:[1,t.inChannels,t.outChannels]}});x.push(M);const U=po({a:$,b:M,backend:r,transposeA:m,transposeB:y,bias:a,activation:i,preluActivationWeights:s,leakyreluAlpha:o}),X=r.texData.get(U.dataId);R(X.isPacked,()=>"batchMatMul result is expected to be packed"),l.shape=F,X.shape=t.outShape,b=Rt({inputs:{x:U},backend:r}),b.shape=t.outShape,x.push(U)}else{const T=t.outHeight*t.outWidth,$=oe({inputs:{x:n},backend:r,attrs:{shape:d?[t.batchSize,T,t.inChannels]:[t.batchSize,t.inChannels,T]}}),F=oe({inputs:{x:e},backend:r,attrs:{shape:[1,t.inChannels,t.outChannels]}}),M=po({a:d?$:F,b:d?F:$,transposeA:!d,transposeB:y,backend:r,bias:a,activation:i,preluActivationWeights:s,leakyreluAlpha:o});b=oe({inputs:{x:M},backend:r,attrs:{shape:t.outShape}}),x.push($),x.push(F),x.push(M)}for(const T of x)r.disposeIntermediateTensorInfo(T);return b}function $m({x:n,filter:e,convInfo:t,backend:r,bias:a=null,preluActivationWeights:s=null,leakyreluAlpha:o=0,activation:i=null}){const{filterWidth:u,filterHeight:l,inChannels:c,outWidth:p,outHeight:h,dataFormat:d}=t,m=d==="channelsLast",y=u*l*c,b=h*p,x=[t.batchSize,y,b],T=!0,$=!1,F=[];if(s!=null){const ge=ho(s.shape,m);ge!=null&&(s=oe({inputs:{x:s},backend:r,attrs:{shape:ge}}),F.push(s))}if(a!=null){const ge=ho(a.shape,m);ge!=null&&(a=oe({inputs:{x:a},backend:r,attrs:{shape:ge}}),F.push(a))}const M=oe({inputs:{x:e},backend:r,attrs:{shape:[1,y,ae(e.shape)/y]}});F.push(M);const U=new fC(x,t),X=[n.shape,[t.padInfo.top,t.padInfo.left],[t.strideHeight,t.strideWidth],[t.dilationHeight,t.dilationWidth],[t.inChannels],[t.filterWidth*t.inChannels],[t.outWidth]],z=r.runWebGLProgram(U,[n],"float32",X),L=oe({inputs:{x:z},backend:r,attrs:{shape:x}});F.push(z),F.push(L);const C=a!=null,q=s!=null,ee=i==="leakyrelu",te=i?ls(i,!0):null,le=new bm(m?L.shape:M.shape,m?M.shape:L.shape,m?[t.batchSize,b,t.outChannels]:[t.batchSize,t.outChannels,b],T,$,C,te,q,ee),de=m?[L,M]:[M,L];if(a&&de.push(a),q&&de.push(s),ee){const ge=r.makeTensorInfo([],"float32",ya(o,"float32"));de.push(ge),F.push(ge)}const fe=r.runWebGLProgram(le,de,"float32"),Re=oe({inputs:{x:fe},backend:r,attrs:{shape:t.outShape}});F.push(fe);for(const ge of F)r.disposeIntermediateTensorInfo(ge);return Re}/** 9320 * @license 9321 * Copyright 2020 Google LLC. All Rights Reserved. 9322 * Licensed under the Apache License, Version 2.0 (the "License");
9323 * you may not use this file except in compliance with the License. 9324 * You may obtain a copy of the License at 9325 * 9326 * http://www.apache.org/licenses/LICENSE-2.0 9327 * 9328 * Unless required by applicable law or agreed to in writing, software 9329 * distributed under the License is distributed on an "AS IS" BASIS, 9330 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9331 * See the License for the specific language governing permissions and 9332 * limitations under the License. 9333 * ============================================================================= 9334 */function mC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,filter:s}=e,{strides:o,pad:i,dataFormat:u,dilations:l,dimRoundingMode:c}=r,p=xa(u),h=Pt(a.shape,s.shape,o,l,i,c,!1,p);let d;if(h.filterHeight===1&&h.filterWidth===1&&h.dilationHeight===1&&h.dilationWidth===1&&h.strideHeight===1&&h.strideWidth===1&&(h.padInfo.type==="SAME"||h.padInfo.type==="VALID"))d=Nm({x:a,filter:s,convInfo:h,backend:t});else if(h.strideWidth<=2&&p==="channelsLast"&&H().getBool("WEBGL_EXP_CONV")){const y=new Im(h),b=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth]];d=t.runWebGLProgram(y,[a,s],"float32",b)}else if(H().getBool("WEBGL_CONV_IM2COL"))d=$m({x:a,filter:s,convInfo:h,backend:t});else{const y=new Cm(h);d=t.runWebGLProgram(y,[a,s],"float32")}const m=oe({inputs:{x:d},backend:t,attrs:{shape:h.outShape}});return t.disposeIntermediateTensorInfo(d),m}const gC={kernelName:mp,backendName:"webgl",kernelFunc:mC};/** 9335 * @license 9336 * Copyright 2017 Google LLC. All Rights Reserved. 9337 * Licensed under the Apache License, Version 2.0 (the "License"); 9338 * you may not use this file except in compliance with the License. 9339 * You may obtain a copy of the License at 9340 * 9341 * http://www.apache.org/licenses/LICENSE-2.0 9342 * 9343 * Unless required by applicable law or agreed to in writing, software 9344 * distributed under the License is distributed on an "AS IS" BASIS, 9345 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9346 * See the License for the specific language governing permissions and 9347 * limitations under the License. 9348 * ============================================================================= 9349 */class yC{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,r=e.strideWidth,a=e.padInfo.top,s=e.padInfo.left,o=e.dataFormat==="channelsLast";this.userCode=` 9350 void main() { 9351 ivec4 coords = getOutputCoords(); 9352 int wR = coords.x; 9353 int wC = coords.y; 9354 int d1 = coords.z; 9355 int d2 = coords.w; 9356 9357 // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2). 9358 // ? = to be determined. : = across all values in that axis. 9359 float dotProd = 0.0; 9360 9361 for (int b = 0; b < ${e.batchSize}; b++) { 9362 for (int yR = 0; yR < ${e.outHeight}; yR++) { 9363 int xR = wR + yR * ${t} - ${a}; 9364 9365 if (xR < 0 || xR >= ${e.inHeight}) { 9366 continue; 9367 } 9368 9369 for (int yC = 0; yC < ${e.outWidth}; yC++) { 9370 int xC = wC + yC * ${r} - ${s}; 9371 9372 if (xC < 0 || xC >= ${e.inWidth}) { 9373 continue; 9374 } 9375 9376 if (${o}) { 9377 float dyValue = getDy(b, yR, yC, d2); 9378 float xValue = getX(b, xR, xC, d1); 9379 dotProd += (xValue * dyValue); 9380 } else { 9381 float dyValue = getDy(b, d2, yR, yC); 9382 float xValue = getX(b, d1, xR, xC); 9383 dotProd += (xValue * dyValue); 9384 } 9385 9386 } 9387 } 9388 } 9389 setOutput(dotProd); 9390 } 9391 `}}class xC{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,a=e.strideHeight,s=e.strideWidth,o=e.dataFormat==="channelsLast",i=t-1-e.padInfo.top,u=r-1-e.padInfo.left,l=o?1:2,c=o?2:3,p=o?3:1;this.userCode=` 9392 const ivec2 pads = ivec2(${i}, ${u}); 9393 9394 void main() { 9395 ivec4 coords = getOutputCoords(); 9396 int batch = coords[0]; 9397 int d1 = coords[${p}]; 9398 9399 ivec2 dyCorner = ivec2(coords[${l}], coords[${c}]) - pads; 9400 int dyRCorner = dyCorner.x; 9401 int dyCCorner = dyCorner.y; 9402 9403 // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). 9404 // ? = to be determined. : = across all values in that axis. 9405 float dotProd = 0.0; 9406 for (int wR = 0; wR < ${t}; wR++) { 9407 float dyR = float(dyRCorner + wR) / ${a}.0; 9408 9409 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 9410 continue; 9411 } 9412 int idyR = int(dyR); 9413 9414 int wRPerm = ${t} - 1 - wR; 9415 9416 for (int wC = 0; wC < ${r}; wC++) { 9417 float dyC = float(dyCCorner + wC) / ${s}.0; 9418 9419 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 9420 fract(dyC) > 0.0) { 9421 continue; 9422 } 9423 int idyC = int(dyC); 9424 9425 int wCPerm = ${r} - 1 - wC; 9426 9427 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 9428 9429 if (${o}) { 9430 float xValue = getDy(batch, idyR, idyC, d2); 9431 float wValue = getW(wRPerm, wCPerm, d1, d2); 9432 dotProd += xValue * wValue; 9433 } else { 9434 float xValue = getDy(batch, d2, idyR, idyC); 9435 float wValue = getW(wRPerm, wCPerm, d1, d2); 9436 dotProd += xValue * wValue; 9437 } 9438 9439 } 9440 } 9441 } 9442 setOutput(dotProd); 9443 } 9444 `}}class bC{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,r=e.strideHeight,a=e.strideWidth,s=e.padInfo.front,o=e.padInfo.top,i=e.padInfo.left;this.userCode=` 9445 void main() { 9446 ivec5 coords = getOutputCoords(); 9447 int wF = coords.x; 9448 int wR = coords.y; 9449 int wC = coords.z; 9450 int d1 = coords.w; 9451 int d2 = coords.u; 9452 9453 float dotProd = 0.0; 9454 9455 for (int b = 0; b < ${e.batchSize}; b++) { 9456 for (int yF = 0; yF < ${e.outDepth}; yF++) { 9457 int xF = wF + yF * ${t} - ${s}; 9458 9459 if (xF < 0 || xF >= ${e.inDepth}) { 9460 continue; 9461 } 9462 9463 for (int yR = 0; yR < ${e.outHeight}; yR++) { 9464 int xR = wR + yR * ${r} - ${o}; 9465 9466 if (xR < 0 || xR >= ${e.inHeight}) { 9467 continue; 9468 } 9469 9470 for (int yC = 0; yC < ${e.outWidth}; yC++) { 9471 int xC = wC + yC * ${a} - ${i}; 9472 9473 if (xC < 0 || xC >= ${e.inWidth}) { 9474 continue; 9475 } 9476 9477 float dyValue = getDy(b, yF, yR, yC, d2); 9478 float xValue = getX(b, xF, xR, xC, d1); 9479 dotProd += (xValue * dyValue); 9480 } 9481 } 9482 } 9483 } 9484 setOutput(dotProd); 9485 } 9486 `}}class vC{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,r=e.filterHeight,a=e.filterWidth,s=e.strideDepth,o=e.strideHeight,i=e.strideWidth,u=t-1-e.padInfo.front,l=r-1-e.padInfo.top,c=a-1-e.padInfo.left;this.userCode=` 9487 const ivec3 pads = ivec3(${u}, ${l}, ${c}); 9488 9489 void main() { 9490 ivec5 coords = getOutputCoords(); 9491 int batch = coords.x; 9492 int d1 = coords.u; 9493 9494 9495 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 9496 int dyFCorner = dyCorner.x; 9497 int dyRCorner = dyCorner.y; 9498 int dyCCorner = dyCorner.z; 9499 9500 float dotProd = 0.0; 9501 for (int wF = 0; wF < ${t}; wF++) { 9502 float dyF = float(dyFCorner + wF) / ${s}.0; 9503 9504 if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) { 9505 continue; 9506 } 9507 int idyF = int(dyF); 9508 9509 int wFPerm = ${t} - 1 - wF; 9510 9511 for (int wR = 0; wR < ${r}; wR++) { 9512 float dyR = float(dyRCorner + wR) / ${o}.0; 9513 9514 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 9515 fract(dyR) > 0.0) { 9516 continue; 9517 } 9518 int idyR = int(dyR); 9519 9520 int wRPerm = ${r} - 1 - wR; 9521 9522 for (int wC = 0; wC < ${a}; wC++) { 9523 float dyC = float(dyCCorner + wC) / ${i}.0; 9524 9525 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 9526 fract(dyC) > 0.0) { 9527 continue; 9528 } 9529 int idyC = int(dyC); 9530 9531 int wCPerm = ${a} - 1 - wC; 9532 9533 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 9534 float xValue = getDy(batch, idyF, idyR, idyC, d2); 9535 float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); 9536 dotProd += xValue * wValue; 9537 } 9538 } 9539 } 9540 } 9541 setOutput(dotProd); 9542 } 9543 `}}/** 9544 * @license 9545 * Copyright 2020 Google LLC. All Rights Reserved. 9546 * Licensed under the Apache License, Version 2.0 (the "License");
9547 * you may not use this file except in compliance with the License. 9548 * You may obtain a copy of the License at 9549 * 9550 * http://www.apache.org/licenses/LICENSE-2.0 9551 * 9552 * Unless required by applicable law or agreed to in writing, software 9553 * distributed under the License is distributed on an "AS IS" BASIS, 9554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9555 * See the License for the specific language governing permissions and 9556 * limitations under the License. 9557 * ============================================================================= 9558 */function wC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,dy:s}=e,{strides:o,pad:i,dataFormat:u,dimRoundingMode:l,filterShape:c}=r,p=xa(u),h=Pt(a.shape,c,o,1,i,l,!1,p),d=new yC(h);return t.runWebGLProgram(d,[a,s],"float32")}const SC={kernelName:gp,backendName:"webgl",kernelFunc:wC};/** 9559 * @license 9560 * Copyright 2020 Google LLC. All Rights Reserved. 9561 * Licensed under the Apache License, Version 2.0 (the "License"); 9562 * you may not use this file except in compliance with the License. 9563 * You may obtain a copy of the License at 9564 * 9565 * http://www.apache.org/licenses/LICENSE-2.0 9566 * 9567 * Unless required by applicable law or agreed to in writing, software 9568 * distributed under the License is distributed on an "AS IS" BASIS, 9569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9570 * See the License for the specific language governing permissions and 9571 * limitations under the License. 9572 * ============================================================================= 9573 */function kC(n){const{inputs:e,backend:t,attrs:r}=n,{dy:a,filter:s}=e,{inputShape:o,strides:i,pad:u,dataFormat:l,dimRoundingMode:c}=r,p=xa(l),h=Pt(o,s.shape,i,1,u,c,!1,p),d=new xC(h);return t.runWebGLProgram(d,[a,s],"float32")}const TC={kernelName:yp,backendName:"webgl",kernelFunc:kC};/** 9574 * @license 9575 * Copyright 2020 Google LLC. All Rights Reserved. 9576 * Licensed under the Apache License, Version 2.0 (the "License"); 9577 * you may not use this file except in compliance with the License. 9578 * You may obtain a copy of the License at 9579 * 9580 * http://www.apache.org/licenses/LICENSE-2.0 9581 * 9582 * Unless required by applicable law or agreed to in writing, software 9583 * distributed under the License is distributed on an "AS IS" BASIS, 9584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9585 * See the License for the specific language governing permissions and 9586 * limitations under the License. 9587 * ============================================================================= 9588 */function EC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,filter:s}=e,{strides:o,pad:i,dilations:u}=r,l=fs(a.shape,s.shape,o,u,i),c=new dC(l);return t.runWebGLProgram(c,[a,s],"float32")}const CC={kernelName:xp,backendName:"webgl",kernelFunc:EC};/** 9589 * @license 9590 * Copyright 2020 Google LLC. All Rights Reserved. 9591 * Licensed under the Apache License, Version 2.0 (the "License"); 9592 * you may not use this file except in compliance with the License. 9593 * You may obtain a copy of the License at 9594 * 9595 * http://www.apache.org/licenses/LICENSE-2.0 9596 * 9597 * Unless required by applicable law or agreed to in writing, software 9598 * distributed under the License is distributed on an "AS IS" BASIS, 9599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9600 * See the License for the specific language governing permissions and 9601 * limitations under the License. 9602 * ============================================================================= 9603 */function IC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,dy:s}=e,{strides:o,pad:i,filterShape:u}=r,l=fs(a.shape,u,o,1,i),c=new bC(l);return t.runWebGLProgram(c,[a,s],"float32")}const NC={kernelName:_2,backendName:"webgl",kernelFunc:IC};/** 9604 * @license 9605 * Copyright 2020 Google LLC. All Rights Reserved. 9606 * Licensed under the Apache License, Version 2.0 (the "License"); 9607 * you may not use this file except in compliance with the License. 9608 * You may obtain a copy of the License at 9609 * 9610 * http://www.apache.org/licenses/LICENSE-2.0 9611 * 9612 * Unless required by applicable law or agreed to in writing, software 9613 * distributed under the License is distributed on an "AS IS" BASIS, 9614 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9615 * See the License for the specific language governing permissions and 9616 * limitations under the License. 9617 * ============================================================================= 9618 */function $C(n){const{inputs:e,backend:t,attrs:r}=n,{dy:a,filter:s}
vendor: 5,217 bytes, lines 9618-9732
9618=e,{pad:o,strides:i,inputShape:u}=r,l=fs(u,s.shape,i,1,o),c=new vC(l);return t.runWebGLProgram(c,[a,s],"float32")}const RC={kernelName:bp,backendName:"webgl",kernelFunc:$C};/** 9619 * @license 9620 * Copyright 2020 Google LLC. All Rights Reserved. 9621 * Licensed under the Apache License, Version 2.0 (the "License"); 9622 * you may not use this file except in compliance with the License. 9623 * You may obtain a copy of the License at 9624 * 9625 * http://www.apache.org/licenses/LICENSE-2.0 9626 * 9627 * Unless required by applicable law or agreed to in writing, software 9628 * distributed under the License is distributed on an "AS IS" BASIS, 9629 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9630 * See the License for the specific language governing permissions and 9631 * limitations under the License. 9632 * ============================================================================= 9633 */const _C=Ca+` 9634 return cos(x); 9635`,AC=Ie({opSnippet:_C}),OC={kernelName:vp,backendName:"webgl",kernelFunc:AC};/** 9636 * @license 9637 * Copyright 2020 Google LLC. All Rights Reserved. 9638 * Licensed under the Apache License, Version 2.0 (the "License"); 9639 * you may not use this file except in compliance with the License. 9640 * You may obtain a copy of the License at 9641 * 9642 * http://www.apache.org/licenses/LICENSE-2.0 9643 * 9644 * Unless required by applicable law or agreed to in writing, software 9645 * distributed under the License is distributed on an "AS IS" BASIS, 9646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9647 * See the License for the specific language governing permissions and 9648 * limitations under the License. 9649 * ============================================================================= 9650 */const FC=` 9651 float e2x = exp(-x); 9652 return (e2x + 1.0 / e2x) / 2.0; 9653`,DC=Ie({opSnippet:FC}),MC={kernelName:wp,backendName:"webgl",kernelFunc:DC};/** 9654 * @license 9655 * Copyright 2017 Google LLC. All Rights Reserved. 9656 * Licensed under the Apache License, Version 2.0 (the "License"); 9657 * you may not use this file except in compliance with the License. 9658 * You may obtain a copy of the License at 9659 * 9660 * http://www.apache.org/licenses/LICENSE-2.0 9661 * 9662 * Unless required by applicable law or agreed to in writing, software 9663 * distributed under the License is distributed on an "AS IS" BASIS, 9664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9665 * See the License for the specific language governing permissions and 9666 * limitations under the License. 9667 * ============================================================================= 9668 */class LC{constructor(e,t,r,a,s){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[o,i,u,l]=e,[c]=t,[p,h]=r;this.outputShape=[c,p,h,l];const d=a==="bilinear"?1:0,[m,y]=[`${i-1}.0`,`${u-1}.0`],[b,x,T]=p>1?[`${(i-1)/(p-1)}`,"(y2-y1) * height_ratio",`y1*${m} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${m}`],[$,F,M]=h>1?[`${(u-1)/(h-1)}`,"(x2-x1) * width_ratio",`x1*${y} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${y}`];this.userCode=` 9669 const float height_ratio = float(${b}); 9670 const float width_ratio = float(${$}); 9671 void main() { 9672 ivec4 coords = getOutputCoords(); 9673 int b = coords[0]; 9674 int y = coords[1]; 9675 int x = coords[2]; 9676 int d = coords[3]; 9677 9678 // get box vals 9679 float y1 = getBoxes(b,0); 9680 float x1 = getBoxes(b,1); 9681 float y2 = getBoxes(b,2); 9682 float x2 = getBoxes(b,3); 9683 9684 // get image in batch index 9685 int bInd = round(getBoxInd(b)); 9686 if(bInd < 0 || bInd >= ${o}) { 9687 return; 9688 } 9689 9690 float height_scale = ${x}; 9691 float width_scale = ${F}; 9692 9693 float in_y = ${T}; 9694 if( in_y < 0.0 || in_y > ${m} ) { 9695 setOutput(float(${s})); 9696 return; 9697 } 9698 float in_x = ${M}; 9699 if( in_x < 0.0 || in_x > ${y} ) { 9700 setOutput(float(${s})); 9701 return; 9702 } 9703 9704 vec2 sourceFracIndexCR = vec2(in_x,in_y); 9705 if(${d} == 1) { 9706 // Compute the four integer indices. 9707 ivec2 sourceFloorCR = ivec2(sourceFracIndexCR); 9708 ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR)); 9709 9710 float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d); 9711 float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d); 9712 float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d); 9713 float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d); 9714 9715 vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR); 9716 9717 float top = topLeft + (topRight - topLeft) * fracCR.x; 9718 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x; 9719 float newValue = top + (bottom - top) * fracCR.y; 9720 setOutput(newValue); 9721 } else { 9722 // Compute the coordinators of nearest neighbor point. 9723 ivec2 sourceNearestCR = ivec2(floor( 9724 sourceFracIndexCR + vec2(0.5,0.5))); 9725 float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d); 9726 setOutput(newValue); 9727 } 9728 } 9729 `}}/** 9730 * @license 9731 * Copyright 2020 Google LLC. All Rights Reserved. 9732 * Licensed under the Apache License, Version 2.0 (the "License");
9733 * you may not use this file except in compliance with the License. 9734 * You may obtain a copy of the License at 9735 * 9736 * http://www.apache.org/licenses/LICENSE-2.0 9737 * 9738 * Unless required by applicable law or agreed to in writing, software 9739 * distributed under the License is distributed on an "AS IS" BASIS, 9740 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9741 * See the License for the specific language governing permissions and 9742 * limitations under the License. 9743 * ============================================================================= 9744 */const PC=n=>{const{inputs:e,backend:t,attrs:r}=n,{image:a,boxes:s,boxInd:o}=e,{cropSize:i,method:u,extrapolationValue:l}=r,c=new LC(a.shape,s.shape,i,u,l);return t.runWebGLProgram(c,[a,s,o],"float32")},BC={kernelName:Tp,backendName:"webgl",kernelFunc:PC};var ps;(function(n){n.Prod="*",n.Sum="+"})(ps||(ps={}));class cc{constructor(e,t,r,a){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const s=this.outputShape.length,o=this.op===ps.Prod?"1.0":"0.0",i=r?o:`getX(${pc(s,"coords",this.op)})`,u=this.outputShape[this.outputShape.length-1];let l="",c="";r?(l=a?`end != ${u-1}`:"end != 0",c=a?"end + 1":"end - 1"):(l=a?`end + pow2 < ${u}`:"end >= pow2",c=a?"end + pow2":"end - pow2"),this.userCode=` 9745 void main() { 9746 ${Be(s)} coords = getOutputCoords(); 9747 int end = ${hc(s,"coords",this.op)}; 9748 float val = ${i}; 9749 int pow2 = int(pow(2.0, index)); 9750 if (${l}) { 9751 int idx = ${c}; 9752 ${hc(s,"coords",this.op)} = idx; 9753 val ${this.op}= getX(${pc(s,"coords",this.op)}); 9754 } 9755 setOutput(val); 9756 } 9757 `}}function pc(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.x, ${e}.y`;if(n===3)return`${e}.x, ${e}.y, ${e}.z`;if(n===4)return`${e}.x, ${e}.y, ${e}.z, ${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}function hc(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.y`;if(n===3)return`${e}.z`;if(n===4)return`${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}/** 9758 * @license 9759 * Copyright 2022 Google LLC. All Rights Reserved. 9760 * Licensed under the Apache License, Version 2.0 (the "License"); 9761 * you may not use this file except in compliance with the License. 9762 * You may obtain a copy of the License at 9763 * 9764 * http://www.apache.org/licenses/LICENSE-2.0 9765 * 9766 * Unless required by applicable law or agreed to in writing, software 9767 * distributed under the License is distributed on an "AS IS" BASIS, 9768 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9769 * See the License for the specific language governing permissions and 9770 * limitations under the License. 9771 * ============================================================================= 9772 */function Rm(n,e,t,r,a,s){const o=e.shape.length,i=Qt([r],o);let u=e;i!=null&&(u=yt({inputs:{x:e},backend:t,attrs:{perm:i}}));const l=en(1,o)[0];if(l!==o-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length-1} but got axis=${r}`);const c=u.shape[l];let p=Rt({inputs:{x:u},backend:t});for(let h=0;h<=Math.ceil(Math.log2(c))-1;h++){const d=new cc(n,u.shape,!1,s),m=[[h]],y=p;p=t.runWebGLProgram(d,[p],p.dtype,m),t.disposeIntermediateTensorInfo(y)}if(a){const h=new cc(n,u.shape,a,s),d=p;p=t.runWebGLProgram(h,[p],p.dtype),t.disposeIntermediateTensorInfo(d)}if(i!=null){const h=zu(i),d=yt({inputs:{x:p},backend:t,attrs:{perm:h}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(u),d}return p}/** 9773 * @license 9774 * Copyright 2022 Google LLC. All Rights Reserved. 9775 * Licensed under the Apache License, Version 2.0 (the "License"); 9776 * you may not use this file except in compliance with the License. 9777 * You may obtain a copy of the License at 9778 * 9779 * http://www.apache.org/licenses/LICENSE-2.0 9780 * 9781 * Unless required by applicable law or agreed to in writing, software 9782 * distributed under the License is distributed on an "AS IS" BASIS, 9783 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9784 * See the License for the specific language governing permissions and 9785 * limitations under the License. 9786 * ============================================================================= 9787 */function UC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s,exclusive:o,reverse:i}
vendor: 8,069 bytes, lines 9787-9937
9787=r;return Rm(ps.Prod,a,t,s,o,i)}const VC={kernelName:Sp,backendName:"webgl",kernelFunc:UC};/** 9788 * @license 9789 * Copyright 2022 Google LLC. All Rights Reserved. 9790 * Licensed under the Apache License, Version 2.0 (the "License"); 9791 * you may not use this file except in compliance with the License. 9792 * You may obtain a copy of the License at 9793 * 9794 * http://www.apache.org/licenses/LICENSE-2.0 9795 * 9796 * Unless required by applicable law or agreed to in writing, software 9797 * distributed under the License is distributed on an "AS IS" BASIS, 9798 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9799 * See the License for the specific language governing permissions and 9800 * limitations under the License. 9801 * ============================================================================= 9802 */function WC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s,exclusive:o,reverse:i}=r;return Rm(ps.Sum,a,t,s,o,i)}const zC={kernelName:kp,backendName:"webgl",kernelFunc:WC};/** 9803 * @license 9804 * Copyright 2020 Google LLC. All Rights Reserved. 9805 * Licensed under the Apache License, Version 2.0 (the "License"); 9806 * you may not use this file except in compliance with the License. 9807 * You may obtain a copy of the License at 9808 * 9809 * http://www.apache.org/licenses/LICENSE-2.0 9810 * 9811 * Unless required by applicable law or agreed to in writing, software 9812 * distributed under the License is distributed on an "AS IS" BASIS, 9813 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9814 * See the License for the specific language governing permissions and 9815 * limitations under the License. 9816 * ============================================================================= 9817 */function GC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,weights:s}=e,{size:o,binaryOutput:i}=r;if(a.shape.length===1){const u=t.readSync(a.dataId),l=t.readSync(s.dataId),c=cm(u,l,s.dtype,s.shape,o);return t.makeTensorInfo([o],s.dtype,c)}else if(a.shape.length===2){const u=t.bufferSync(a),l=t.bufferSync(s),c=rk(u,l,o,i);return t.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}.`)}const jC={kernelName:Ep,backendName:"webgl",kernelFunc:GC};/** 9818 * @license 9819 * Copyright 2018 Google LLC. All Rights Reserved. 9820 * Licensed under the Apache License, Version 2.0 (the "License"); 9821 * you may not use this file except in compliance with the License. 9822 * You may obtain a copy of the License at 9823 * 9824 * http://www.apache.org/licenses/LICENSE-2.0 9825 * 9826 * Unless required by applicable law or agreed to in writing, software 9827 * distributed under the License is distributed on an "AS IS" BASIS, 9828 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9829 * See the License for the specific language governing permissions and 9830 * limitations under the License. 9831 * ============================================================================= 9832 */class HC{constructor(e,t,r){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=r,this.userCode=` 9833 void main() { 9834 ivec4 coords = getOutputCoords(); 9835 int b = coords[0]; 9836 int h = ${this.getHeightCoordString()}; 9837 int w = ${this.getWidthCoordString()}; 9838 int d = ${this.getDepthCoordString()}; 9839 9840 int in_h = h / ${t}; 9841 int offset_h = imod(h, ${t}); 9842 int in_w = w / ${t}; 9843 int offset_w = imod(w, ${t}); 9844 int offset_d = (offset_h * ${t} + offset_w) * 9845 ${this.getOutputDepthSize()}; 9846 int in_d = d + offset_d; 9847 9848 float result = ${this.getInputSamplingString()}; 9849 setOutput(result); 9850 } 9851 `}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)"}}/** 9852 * @license 9853 * Copyright 2020 Google LLC. All Rights Reserved. 9854 * Licensed under the Apache License, Version 2.0 (the "License"); 9855 * you may not use this file except in compliance with the License. 9856 * You may obtain a copy of the License at 9857 * 9858 * http://www.apache.org/licenses/LICENSE-2.0 9859 * 9860 * Unless required by applicable law or agreed to in writing, software 9861 * distributed under the License is distributed on an "AS IS" BASIS, 9862 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9863 * See the License for the specific language governing permissions and 9864 * limitations under the License. 9865 * ============================================================================= 9866 */function XC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{blockSize:s,dataFormat:o}=r,i=a.shape[0],u=o==="NHWC"?a.shape[1]:a.shape[2],l=o==="NHWC"?a.shape[2]:a.shape[3],c=o==="NHWC"?a.shape[3]:a.shape[1],p=u*s,h=l*s,d=c/(s*s),m=o==="NHWC"?[i,p,h,d]:[i,d,p,h],y=new HC(m,s,o);return t.runWebGLProgram(y,[a],a.dtype)}const qC={kernelName:Cp,backendName:"webgl",kernelFunc:XC};/** 9867 * @license 9868 * Copyright 2017 Google LLC. All Rights Reserved. 9869 * Licensed under the Apache License, Version 2.0 (the "License"); 9870 * you may not use this file except in compliance with the License. 9871 * You may obtain a copy of the License at 9872 * 9873 * http://www.apache.org/licenses/LICENSE-2.0 9874 * 9875 * Unless required by applicable law or agreed to in writing, software 9876 * distributed under the License is distributed on an "AS IS" BASIS, 9877 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9878 * See the License for the specific language governing permissions and 9879 * limitations under the License. 9880 * ============================================================================= 9881 */class _m{constructor(e,t=!1,r=null,a=!1,s=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=bt(this.outputShape.length);const o=e.filterHeight,i=e.filterWidth,u=e.outChannels/e.inChannels;let l="",c="";r&&(a?l=`float activation(float a) { 9882 float b = getPreluActivationWeightsAtOutCoords(); 9883 ${r} 9884 }`:s?l=`float activation(float a) { 9885 float b = getLeakyreluAlphaAtOutCoords(); 9886 ${r} 9887 }`:l=` 9888 float activation(float x) { 9889 ${r} 9890 } 9891 `,c="result = activation(result);");const p=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 9892 ${l} 9893 9894 void main() { 9895 ivec4 coords = getOutputCoords(); 9896 int batch = coords.x; 9897 ivec2 xRCCorner = coords.yz * strides - pads; 9898 int d2 = coords.w; 9899 int d1 = d2 / ${u}; 9900 int q = d2 - d1 * ${u}; 9901 9902 int xRCorner = xRCCorner.x; 9903 int xCCorner = xRCCorner.y; 9904 9905 // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2). 9906 // ? = to be determined. : = across all values in that axis. 9907 float dotProd = 0.0; 9908 // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations. 9909 for (int wR = 0; wR < ${o}; wR++) { 9910 int xR = xRCorner + wR * dilations[0]; 9911 9912 if (xR < 0 || xR >= inDims[0]) { 9913 continue; 9914 } 9915 9916 for (int wC = 0; wC < ${i}; wC++) { 9917 int xC = xCCorner + wC * dilations[1]; 9918 9919 if (xC < 0 || xC >= inDims[1]) { 9920 continue; 9921 } 9922 9923 float xVal = getX(batch, xR, xC, d1); 9924 float wVal = getW(wR, wC, d1, q); 9925 dotProd += xVal * wVal; 9926 } 9927 } 9928 9929 float result = dotProd; 9930 ${p} 9931 ${c} 9932 setOutput(result); 9933 } 9934 `}}/** 9935 * @license 9936 * Copyright 2018 Google LLC. All Rights Reserved. 9937 * Licensed under the Apache License, Version 2.0 (the "License");
9938 * you may not use this file except in compliance with the License. 9939 * You may obtain a copy of the License at 9940 * 9941 * http://www.apache.org/licenses/LICENSE-2.0 9942 * 9943 * Unless required by applicable law or agreed to in writing, software 9944 * distributed under the License is distributed on an "AS IS" BASIS, 9945 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9946 * See the License for the specific language governing permissions and 9947 * limitations under the License. 9948 * ============================================================================= 9949 */class Am{constructor(e,t=!1,r=null,a=!1,s=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=bt(this.outputShape.length);const o=e.outChannels/e.inChannels,i=e.padInfo.left,u=e.strideWidth,l=e.dilationWidth,c=e.filterHeight,p=e.filterWidth,h=p;let d=` 9950 int xR; int xC; int xCOffset; 9951 vec4 wTexel; vec4 previous; vec4 final;`;for(let x=0;x<p;x++)d+=` 9952 vec4 xTexelC${x*2}; 9953 int xTexelC${x*2}Ready; 9954 vec4 xTexelC${x*2+1}; 9955 int xTexelC${x*2+1}Ready; 9956 vec4 xC${x};`;d+=` 9957 for (int r = 0; r < ${c}; r++) { 9958 `;for(let x=0;x<p;x++)d+=` 9959 xTexelC${x*2} = vec4(0.0); 9960 xTexelC${x*2}Ready = 0; 9961 xTexelC${x*2+1} = vec4(0.0); 9962 xTexelC${x*2+1}Ready = 0; 9963 xC${x} = vec4(0.0);`;d+=` 9964 xR = xRCorner + r * dilations[0]; 9965 if (xR >=0 && xR < inDims[0]) { 9966 `;for(let x=0;x<(h+1)/2;x++){const T=x*2;if(d+=` 9967 xC = xCCorner + ${T*l}; 9968 `,u===1){if(T<p&&(i%2===1?(d+=` 9969 xCOffset = xC + 1; 9970 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${T}Ready == 0) { 9971 xTexelC${T} = getX(batch, xR, xCOffset, d1); 9972 9973 // Need to manually clear unused channels in case 9974 // we're reading from recycled texture. 9975 if (xCOffset + 1 >= inDims[1]) { 9976 xTexelC${T}.zw = vec2(0.0); 9977 } 9978 xTexelC${T}Ready = 1; 9979 } 9980 `,l===1&&T>0?d+=` 9981 xC${T} = vec4(xTexelC${T-2}.zw, xTexelC${T}.xy); 9982 `:d+=` 9983 xCOffset = xC + 1 - 2; 9984 9985 if (xCOffset >= 0 && xCOffset < inDims[1]) { 9986 previous = getX(batch, xR, xCOffset, d1); 9987 9988 // Need to manually clear unused channels in case 9989 // we're reading from recycled texture. 9990 if (xCOffset + 1 >= inDims[1]) { 9991 previous.zw = vec2(0.0); 9992 } 9993 9994 xC${T} = vec4(previous.zw, xTexelC${T}.xy); 9995 } else { 9996 xC${T} = vec4(0.0, 0.0, xTexelC${T}.xy); 9997 } 9998 `):d+=` 9999 if (xC >= 0 && xC < inDims[1] && xTexelC${T}Ready == 0) { 10000 xTexelC${T} = getX(batch, xR, xC, d1); 10001 if (xC + 1 >= inDims[1]) { 10002 xTexelC${T}.zw = vec2(0.0); 10003 } 10004 xTexelC${T}Ready = 1; 10005 } 10006 10007 xC${T} = xTexelC${T}; 10008 `,T+1<p)){const $=i%2===0?ku(l):l;l%2===0&&i%2===1||l%2!==0&&i%2!==1?(d+=` 10009 xCOffset = xC + imod(pads[1], 2) + ${$}; 10010 10011 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${T+1}Ready == 0) { 10012 xTexelC${T+1} = getX(batch, xR, xCOffset, d1); 10013 10014 // Need to manually clear unused channels in case 10015 // we're reading from recycled texture. 10016 if (xCOffset + 1 >= inDims[1]) { 10017 xTexelC${T+1}.zw = vec2(0.0); 10018 } 10019 xTexelC${T+1}Ready = 1; 10020 } 10021 `,l>1?d+=` 10022 xCOffset -= 2; 10023 if (xCOffset >= 0 && xCOffset < inDims[1]) { 10024 previous = getX(batch, xR, xCOffset, d1); 10025 xC${T+1} = vec4(previous.zw, xTexelC${T+1}.xy); 10026 } else { 10027 xC${T+1} = vec4(0.0, 0.0, xTexelC${T+1}.xy); 10028 } 10029 `:d+=` 10030 xC${T+1} = vec4(xTexelC${T}.zw, xTexelC${T+1}.xy); 10031 `):$===1?d+=` 10032 xC${T+1} = xTexelC${T}; 10033 `:d+=` 10034 xCOffset = xC + ${$}; 10035 10036 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${T+1}Ready == 0) { 10037 xTexelC${T+1} = getX(batch, xR, xCOffset, d1); 10038 if (xCOffset + 1 >= inDims[1]) { 10039 xTexelC${T+1}.zw = vec2(0.0); 10040 } 10041 xTexelC${T+1}Ready = 1; 10042 } 10043 10044 xC${T+1} = xTexelC${T+1}; 10045 `}}else T<p&&(i%2===1?(d+=` 10046 xCOffset = xC + 1 - strides[1]; 10047 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${T}Ready == 0) { 10048 xTexelC${T} = getX(batch, xR, xCOffset, d1); 10049 // Need to manually clear unused channels in case 10050 // we're reading from recycled texture. 10051 if (xCOffset + 1 >= inDims[1]) { 10052 xTexelC${T}.zw = vec2(0.0); 10053 } 10054 xTexelC${T}Ready = 1; 10055 } 10056 10057 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${T+1}Ready == 0) { 10058 xTexelC${T+1} = getX(batch, xR, xC + 1, d1); 10059 // Need to manually clear unused channels in case 10060 // we're reading from recycled texture. 10061 if (xC + 2 >= inDims[1]) { 10062 xTexelC${T+1}.zw = vec2(0.0); 10063 } 10064 xTexelC${T+1}Ready = 1; 10065 } 10066 10067 xC${T} = vec4(xTexelC${T}.zw, xTexelC${T+1}.zw); 10068 `,T+1<p&&(d+=` 10069 final = vec4(0.0); 10070 xCOffset = xC + 1 + strides[1]; 10071 if(xCOffset >= 0 && xCOffset < inDims[1]) { 10072 final = getX(batch, xR, xCOffset, d1); 10073 } 10074 xC${T+1} = vec4(xTexelC${T+1}.xy, final.xy); 10075 `)):(d+=` 10076 if(xC >= 0 && xC < inDims[1] && xTexelC${T}Ready == 0) { 10077 xTexelC${T} = getX(batch, xR, xC, d1); 10078 if (xC + 1 >= inDims[1]) { 10079 xTexelC${T}.zw = vec2(0.0); 10080 } 10081 xTexelC${T}Ready = 1; 10082 } 10083 10084 xCOffset = xC + strides[1]; 10085 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${T+1}Ready == 0) { 10086 xTexelC${T+1} = getX(batch, xR, xCOffset, d1); 10087 if (xCOffset + 1 >= inDims[1]) { 10088 xTexelC${T+1}.zw = vec2(0.); 10089 } 10090 xTexelC${T+1}Ready = 1; 10091 } 10092 10093 xC${T} = vec4( 10094 xTexelC${T}.xy, xTexelC${T+1}.xy); 10095 `,T+1<p&&(d+=` 10096 xC${T+1} = vec4(xTexelC${T}.zw, xTexelC${T+1}.zw); 10097 `)));T<p&&(d+=` 10098 wTexel = getW(r, ${T}, d1, q); 10099 dotProd += xC${T} * vec4(wTexel.xz, wTexel.xz); 10100 `,T+1<p&&(d+=` 10101 wTexel = getW(r, ${T+1}, d1, q); 10102 dotProd += xC${T+1} * vec4(wTexel.xz, wTexel.xz); 10103 `))}d+=` 10104 } 10105 `,d+=` 10106 } 10107 `;let m="",y="";r&&(a?m=`vec4 activation(vec4 a) { 10108 vec4 b = getPreluActivationWeightsAtOutCoords(); 10109 ${r} 10110 }`:s?m=`vec4 activation(vec4 a) { 10111 vec4 b = getLeakyreluAlphaAtOutCoords(); 10112 ${r} 10113 }`:m=`vec4 activation(vec4 x) { 10114 ${r} 10115 }`,y="result = activation(result);");const b=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 10116 ${m} 10117 10118 void main() { 10119 ivec4 coords = getOutputCoords(); 10120 int batch = coords.x; 10121 ivec2 xRCCorner = coords.yz * strides - pads; 10122 int d2 = coords.w; 10123 int d1 = d2 / ${o}; 10124 int q = d2 - d1 * ${o}; 10125 int xRCorner = xRCCorner.x; 10126 int xCCorner = xRCCorner.y; 10127 10128 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 10129 vec4 dotProd = vec4(0.000000000000001); 10130 10131 ${d} 10132 10133 vec4 result = dotProd - vec4(0.000000000000001); 10134 ${b} 10135 ${y} 10136 setOutput(result); 10137 } 10138 `}}/** 10139 * @license 10140 * Copyright 2020 Google LLC. All Rights Reserved. 10141 * Licensed under the Apache License, Version 2.0 (the "License");
10142 * you may not use this file except in compliance with the License. 10143 * You may obtain a copy of the License at 10144 * 10145 * http://www.apache.org/licenses/LICENSE-2.0 10146 * 10147 * Unless required by applicable law or agreed to in writing, software 10148 * distributed under the License is distributed on an "AS IS" BASIS, 10149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10150 * See the License for the specific language governing permissions and 10151 * limitations under the License. 10152 * ============================================================================= 10153 */function KC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,filter:s}=e,{strides:o,pad:i,dilations:u,dimRoundingMode:l}=r;let c=u;c==null&&(c=[1,1]),R(_t(o,c),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);const p=Pt(a.shape,s.shape,o,c,i,l,!0);let h;H().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels===1?h=new Am(p):h=new _m(p);const d=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return t.runWebGLProgram(h,[a,s],"float32",d)}const YC={kernelName:Ip,backendName:"webgl",kernelFunc:KC};/** 10154 * @license 10155 * Copyright 2018 Google LLC. All Rights Reserved. 10156 * Licensed under the Apache License, Version 2.0 (the "License"); 10157 * you may not use this file except in compliance with the License. 10158 * You may obtain a copy of the License at 10159 * 10160 * http://www.apache.org/licenses/LICENSE-2.0 10161 * 10162 * Unless required by applicable law or agreed to in writing, software 10163 * distributed under the License is distributed on an "AS IS" BASIS, 10164 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10165 * See the License for the specific language governing permissions and 10166 * limitations under the License. 10167 * ============================================================================= 10168 */class ZC{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,r=e.strideWidth,a=e.padInfo.top,s=e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=` 10169 void main() { 10170 ivec4 coords = getOutputCoords(); 10171 int wR = coords.x; 10172 int wC = coords.y; 10173 int d1 = coords.z; 10174 int dm = coords.w; 10175 int d2 = d1 * ${o} + dm; 10176 10177 float dotProd = 0.0; 10178 10179 // TO DO: Vec4 over the batch size 10180 for (int b = 0; b < ${e.batchSize}; b++) { 10181 for (int yR = 0; yR < ${e.outHeight}; yR++) { 10182 int xR = wR + yR * ${t} - ${a}; 10183 10184 if (xR < 0 || xR >= ${e.inHeight}) { 10185 continue; 10186 } 10187 10188 for (int yC = 0; yC < ${e.outWidth}; yC++) { 10189 int xC = wC + yC * ${r} - ${s}; 10190 10191 if (xC < 0 || xC >= ${e.inWidth}) { 10192 continue; 10193 } 10194 10195 float dyValue = getDy(b, yR, yC, d2); 10196 float xValue = getX(b, xR, xC, d1); 10197 dotProd += (xValue * dyValue); 10198 } 10199 } 10200 } 10201 setOutput(dotProd); 10202 } 10203 `}}class JC{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,a=e.strideHeight,s=e.strideWidth,o=t-1-e.padInfo.top,i=r-1-e.padInfo.left,u=e.outChannels/e.inChannels;this.userCode=` 10204 const ivec2 pads = ivec2(${o}, ${i}); 10205 10206 void main() { 10207 ivec4 coords = getOutputCoords(); 10208 int batch = coords[0]; 10209 int d1 = coords[3]; 10210 ivec2 dyCorner = coords.yz - pads; 10211 int dyRCorner = dyCorner.x; 10212 int dyCCorner = dyCorner.y; 10213 10214 float dotProd = 0.0; 10215 10216 for (int wR = 0; wR < ${t}; wR++) { 10217 float dyR = float(dyRCorner + wR) / ${a}.0; 10218 10219 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 10220 continue; 10221 } 10222 int idyR = int(dyR); 10223 10224 int wRPerm = ${t} - 1 - wR; 10225 10226 for (int wC = 0; wC < ${r}; wC++) { 10227 float dyC = float(dyCCorner + wC) / ${s}.0; 10228 10229 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 10230 fract(dyC) > 0.0) { 10231 continue; 10232 } 10233 int idyC = int(dyC); 10234 10235 int wCPerm = ${r} - 1 - wC; 10236 10237 // TO DO: Vec4 over the channelMul 10238 for (int dm = 0; dm < ${u}; dm++) { 10239 int d2 = d1 * ${u} + dm; 10240 float xValue = getDy(batch, idyR, idyC, d2); 10241 float wValue = getW(wRPerm, wCPerm, d1, dm); 10242 dotProd += xValue * wValue; 10243 } 10244 } 10245 } 10246 setOutput(dotProd); 10247 } 10248 `}}/** 10249 * @license 10250 * Copyright 2020 Google LLC. All Rights Reserved. 10251 * Licensed under the Apache License, Version 2.0 (the "License");
10252 * you may not use this file except in compliance with the License. 10253 * You may obtain a copy of the License at 10254 * 10255 * http://www.apache.org/licenses/LICENSE-2.0 10256 * 10257 * Unless required by applicable law or agreed to in writing, software 10258 * distributed under the License is distributed on an "AS IS" BASIS, 10259 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10260 * See the License for the specific language governing permissions and 10261 * limitations under the License. 10262 * ============================================================================= 10263 */function QC(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,dy:s}=e,{strides:o,dilations:i,pad:u,dimRoundingMode:l,filterShape:c}=r,p=Pt(a.shape,c,o,i,u,l,!0),h=new ZC(p);return t.runWebGLProgram(h,[a,s],"float32")}const eI={kernelName:Np,backendName:"webgl",kernelFunc:QC};/** 10264 * @license 10265 * Copyright 2020 Google LLC. All Rights Reserved. 10266 * Licensed under the Apache License, Version 2.0 (the "License"); 10267 * you may not use this file except in compliance with the License. 10268 * You may obtain a copy of the License at 10269 * 10270 * http://www.apache.org/licenses/LICENSE-2.0 10271 * 10272 * Unless required by applicable law or agreed to in writing, software 10273 * distributed under the License is distributed on an "AS IS" BASIS, 10274 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10275 * See the License for the specific language governing permissions and 10276 * limitations under the License. 10277 * ============================================================================= 10278 */function tI(n){const{inputs:e,backend:t,attrs:r}=n,{dy:a,filter:s}=e,{strides:o,dilations:i,pad:u,dimRoundingMode:l,inputShape:c}=r,p=Pt(c,s.shape,o,i,u,l,!0),h=new JC(p);return t.runWebGLProgram(h,[a,s],"float32")}const nI={kernelName:$p,backendName:"webgl",kernelFunc:tI};/** 10279 * @license 10280 * Copyright 2019 Google LLC. All Rights Reserved. 10281 * Licensed under the Apache License, Version 2.0 (the "License"); 10282 * you may not use this file except in compliance with the License. 10283 * You may obtain a copy of the License at 10284 * 10285 * http://www.apache.org/licenses/LICENSE-2.0 10286 * 10287 * Unless required by applicable law or agreed to in writing, software 10288 * distributed under the License is distributed on an "AS IS" BASIS, 10289 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10290 * See the License for the specific language governing permissions and 10291 * limitations under the License. 10292 * ============================================================================= 10293 */class rI{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` 10294 void main() { 10295 ivec2 coords = getOutputCoords(); 10296 float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; 10297 setOutput(val); 10298 } 10299 `}}/** 10300 * @license 10301 * Copyright 2020 Google LLC. All Rights Reserved. 10302 * Licensed under the Apache License, Version 2.0 (the "License"); 10303 * you may not use this file except in compliance with the License. 10304 * You may obtain a copy of the License at 10305 * 10306 * http://www.apache.org/licenses/LICENSE-2.0 10307 * 10308 * Unless required by applicable law or agreed to in writing, software 10309 * distributed under the License is distributed on an "AS IS" BASIS, 10310 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10311 * See the License for the specific language governing permissions and 10312 * limitations under the License. 10313 * ============================================================================= 10314 */function aI(n){const{inputs:e,backend:t}=n,{x:r}=e,a=[...r.shape,...r.shape],s=ae(r.shape),o=oe({inputs:{x:r},backend:t,attrs:{shape:[s]}}),i=new rI(s),u=t.runWebGLProgram(i,[o],o.dtype),l=oe({inputs:{x:u},backend:t,attrs:{shape:a}});return t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(u),l}const sI={kernelName:Rp,backendName:"webgl",kernelFunc:aI};/** 10315 * @license 10316 * Copyright 2017 Google LLC. All Rights Reserved. 10317 * Licensed under the Apache License, Version 2.0 (the "License"); 10318 * you may not use this file except in compliance with the License. 10319 * You may obtain a copy of the License at 10320 * 10321 * http://www.apache.org/licenses/LICENSE-2.0 10322 * 10323 * Unless required by applicable law or agreed to in writing, softw
10323are 10324 * distributed under the License is distributed on an "AS IS" BASIS, 10325 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10326 * See the License for the specific language governing permissions and 10327 * limitations under the License. 10328 * ============================================================================= 10329 */class oI{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:r,padInfo:a,strideHeight:s,strideWidth:o,filterHeight:i,filterWidth:u,dilationHeight:l,dilationWidth:c}=e,{top:p,left:h}=a;this.userCode=` 10330 const ivec2 strides = ivec2(${s}, ${o}); 10331 const ivec2 pads = ivec2(${p}, ${h}); 10332 const float neg_infinity = -3.4e38; 10333 10334 void main() { 10335 ivec4 coords = getOutputCoords(); 10336 int batch = coords.x; 10337 int d1 = coords.w; 10338 ivec2 outTopLeftCorner = 10339 coords.yz * strides - pads; 10340 int hBeg = outTopLeftCorner.x; 10341 int wBeg = outTopLeftCorner.y; 10342 10343 float curVal = neg_infinity; 10344 for (int h = 0; h < ${i}; h++) { 10345 int hIn = hBeg + h * ${l}; 10346 10347 if (hIn >= 0 && hIn < ${t}) { 10348 for (int w = 0; w < ${u}; w++) { 10349 int wIn = wBeg + w * ${c}; 10350 10351 if (wIn >= 0 && wIn < ${r}) { 10352 float xVal = getX(batch, hIn, wIn, d1); 10353 float wVal = getW(h, w, d1); 10354 10355 float val = xVal + wVal; 10356 if (val > curVal) { 10357 curVal = val; 10358 } 10359 } 10360 } 10361 } 10362 } 10363 10364 float result = curVal; 10365 setOutput(result); 10366 } 10367 `}}/** 10368 * @license 10369 * Copyright 2020 Google LLC. All Rights Reserved. 10370 * Licensed under the Apache License, Version 2.0 (the "License"); 10371 * you may not use this file except in compliance with the License. 10372 * You may obtain a copy of the License at 10373 * 10374 * http://www.apache.org/licenses/LICENSE-2.0 10375 * 10376 * Unless required by applicable law or agreed to in writing, software 10377 * distributed under the License is distributed on an "AS IS" BASIS, 10378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10379 * See the License for the specific language governing permissions and 10380 * limitations under the License. 10381 * ============================================================================= 10382 */function iI(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,filter:s}=e,{strides:o,pad:i,dilations:u}=r,l=Nf(a.shape,s.shape,o,i,"NHWC",u);let c;const p=new oI(l);c=t.runWebGLProgram(p,[a,s],"float32");const h=oe({inputs:{x:c},backend:t,attrs:{shape:l.outShape}});return t.disposeIntermediateTensorInfo(c),h}const uI={kernelName:_p,backendName:"webgl",kernelFunc:iI};/** 10383 * @license 10384 * Copyright 2021 Google LLC. All Rights Reserved. 10385 * Licensed under the Apache License, Version 2.0 (the "License"); 10386 * you may not use this file except in compliance with the License. 10387 * You may obtain a copy of the License at 10388 * 10389 * http://www.apache.org/licenses/LICENSE-2.0 10390 * 10391 * Unless required by applicable law or agreed to in writing, software 10392 * distributed under the License is distributed on an "AS IS" BASIS, 10393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10394 * See the License for the specific language governing permissions and 10395 * limitations under the License. 10396 * ============================================================================= 10397 */function lI(n){const{inputs:e,backend:t,attrs:r}=n,{equation:a}=r,s=e,{allDims:o,summedDims:i,idDims:u}=R1(a,s.length);A1(o.length,u,s);const{path:l,steps:c}=O1(i,u),p=c.length;let h=null,d=o.length;const m=[];for(let y=0;y<p;++y){for(const b of c[y]){const{permutationIndices:x,expandDims:T}=_1(d,u[b]);let $;F1(x)?$=s[b]:($=yt({inputs:{x:s[b]},backend:t,attrs:{perm:x}}),m.push($));const F=$.shape.slice();for(let M=0;M<T.length;++M)F.splice(T[M],0,1);qe($.shape,F)||($=oe({inputs:{x:$},backend:t,attrs:{shape:F}}),m.push($)),h===null?h=$:(h=ll({inputs:{a:$,b:h},backend:t}),m.push(h))}y<p-1&&(l[y]>=0&&(h=Bo({inputs:{x:h},backend:t,attrs:{axis:l[y]-(o.length-d),keepDims:!1}}),m.push(h)),d--)}for(const y of m)y!==h&&t.disposeIntermediateTensorInfo(y);return h}const cI={kernelName:Op,backendName:"webgl",kernelFunc:lI};/** 10398 * @license 10399 * Copyright 2020 Google LLC. All Rights Reserved. 10400 * Licensed under the Apache License, Version 2.0 (the "License");
10401 * you may not use this file except in compliance with the License. 10402 * You may obtain a copy of the License at 10403 * 10404 * http://www.apache.org/licenses/LICENSE-2.0 10405 * 10406 * Unless required by applicable law or agreed to in writing, software 10407 * distributed under the License is distributed on an "AS IS" BASIS, 10408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10409 * See the License for the specific language governing permissions and 10410 * limitations under the License. 10411 * ============================================================================= 10412 */const pI="return (x >= 0.0) ? x : (exp(x) - 1.0);",hI=` 10413 vec4 result; 10414 10415 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 10416 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 10417 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 10418 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 10419 10420 return result; 10421`,dI=Ie({opSnippet:pI,packedOpSnippet:hI}),fI={kernelName:Fp,backendName:"webgl",kernelFunc:dI};/** 10422 * @license 10423 * Copyright 2020 Google LLC. All Rights Reserved. 10424 * Licensed under the Apache License, Version 2.0 (the "License"); 10425 * you may not use this file except in compliance with the License. 10426 * You may obtain a copy of the License at 10427 * 10428 * http://www.apache.org/licenses/LICENSE-2.0 10429 * 10430 * Unless required by applicable law or agreed to in writing, software 10431 * distributed under the License is distributed on an "AS IS" BASIS, 10432 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10433 * See the License for the specific language governing permissions and 10434 * limitations under the License. 10435 * ============================================================================= 10436 */const mI="return (b >= 1.0) ? a : a * (b + 1.0);",gI=` 10437 vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
10438 return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); 10439`,yI=n=>{const{inputs:e,backend:t}=n,{dy:r,y:a}=e,s=H().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new vs(gI,r.shape,a.shape):new ma(mI,r.shape,a.shape);return t.runWebGLProgram(s,[r,a],r.dtype)},xI={kernelName:A2,backendName:"webgl",kernelFunc:yI};/** 10440 * @license 10441 * Copyright 2020 Google LLC. All Rights Reserved. 10442 * Licensed under the Apache License, Version 2.0 (the "License"); 10443 * you may not use this file except in compliance with the License. 10444 * You may obtain a copy of the License at 10445 * 10446 * http://www.apache.org/licenses/LICENSE-2.0 10447 * 10448 * Unless required by applicable law or agreed to in writing, software 10449 * distributed under the License is distributed on an "AS IS" BASIS, 10450 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10451 * See the License for the specific language governing permissions and 10452 * limitations under the License. 10453 * ============================================================================= 10454 */const bI=` 10455 return vec4(equal(a, b)); 10456`,vI="return float(a == b);",wI=ut({opSnippet:vI,packedOpSnippet:bI,dtype:"bool",cpuKernelImpl:ik}),SI={kernelName:Mp,backendName:"webgl",kernelFunc:wI};/** 10457 * @license 10458 * Copyright 2020 Google LLC. All Rights Reserved. 10459 * Licensed under the Apache License, Version 2.0 (the "License"); 10460 * you may not use this file except in compliance with the License. 10461 * You may obtain a copy of the License at 10462 * 10463 * http://www.apache.org/licenses/LICENSE-2.0 10464 * 10465 * Unless required by applicable law or agreed to in writing, software 10466 * distributed under the License is distributed on an "AS IS" BASIS, 10467 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10468 * See the License for the specific language governing permissions and 10469 * limitations under the License. 10470 * ============================================================================= 10471 */const kI=` 10472 // Error function is calculated approximately with elementary function. 10473 // See "Handbook of Mathematical Functions with Formulas, 10474 // Graphs, and Mathematical Tables", Abramowitz and Stegun. 10475 float p = ${T1}; 10476 float a1 = ${E1}; 10477 float a2 = ${C1}; 10478 float a3 = ${I1}; 10479 float a4 = ${N1}; 10480 float a5 = ${$1}; 10481 10482 float sign = sign(x); 10483 x = abs(x); 10484 float t = 1.0 / (1.0 + p * x); 10485 return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); 10486`,TI=Ie({opSnippet:kI}),EI={kernelName:Dp,backendName:"webgl",kernelFunc:TI};/** 10487 * @license 10488 * Copyright 2020 Google LLC. All Rights Reserved. 10489 * Licensed under the Apache License, Version 2.0 (the "License"); 10490 * you may not use this file except in compliance with the License. 10491 * You may obtain a copy of the License at 10492 * 10493 * http://www.apache.org/licenses/LICENSE-2.0 10494 * 10495 * Unless required by applicable law or agreed to in writing, software 10496 * distributed under the License is distributed on an "AS IS" BASIS, 10497 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10498 * See the License for the specific language governing permissions and 10499 * limitations under the License. 10500 * ============================================================================= 10501 */const CI=Ca+` 10502 return exp(x); 10503`,II=` 10504 vec4 result = exp(x); 10505 bvec4 isNaN = isnan(x); 10506 result.r = isNaN.r ? x.r : result.r; 10507 result.g = isNaN.g ? x.g : result.g; 10508 result.b = isNaN.b ? x.b : result.b; 10509 result.a = isNaN.a ? x.a : result.a; 10510 10511 return result; 10512`,Om=Ie({opSnippet:CI,packedOpSnippet:II,cpuKernelImpl:uk,dtype:"float32"}),NI={kernelName:Lp,backendName:"webgl",kernelFunc:Om};/** 10513 * @license 10514 * Copyright 2020 Google LLC. All Rights Reserved. 10515 * Licensed under the Apache License, Version 2.0 (the License); 10516 * you may not use this file except in compliance with the License. 10517 * You may obtain a copy of the License at 10518 * 10519 * http://www.apache.org/licenses/LICENSE-2.0 10520 * 10521 * Unless required by applicable law or agreed to in writing, software 10522 * distributed under the License is distributed on an AS IS BASIS, 10523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10524 * See the License for the specific language governing permissions and 10525 * limitations under the License. 10526 * ============================================================================= 10527 */function cu(n){const{inputs:e,attrs:t,backend:r}=n,{dim:a}=t,{input:s}=e,o=s.shape.length,i=s.shape.slice();let u=a;return a<0&&(R(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),u=o+a+1),i.splice(u,0,1),oe({inputs:{x:s},backend:r,attrs:{shape:i}})}const $I={kernelName:Pp,backendName:"webgl",kernelFunc:cu};/** 10528 * @license 10529 * Copyright 2020 Google LLC. All Rights Reserved. 10530 * Licensed under the Apache License, Version 2.0 (the "License");
10531 * you may not use this file except in compliance with the License. 10532 * You may obtain a copy of the License at 10533 * 10534 * http://www.apache.org/licenses/LICENSE-2.0 10535 * 10536 * Unless required by applicable law or agreed to in writing, software 10537 * distributed under the License is distributed on an "AS IS" BASIS, 10538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10539 * See the License for the specific language governing permissions and 10540 * limitations under the License. 10541 * ============================================================================= 10542 */const dc="return exp(x) - 1.0;",RI=Ie({opSnippet:dc,packedOpSnippet:dc,cpuKernelImpl:lk}),_I={kernelName:Bp,backendName:"webgl",kernelFunc:RI};/** 10543 * @license 10544 * Copyright 2018 Google LLC. All Rights Reserved. 10545 * Licensed under the Apache License, Version 2.0 (the "License"); 10546 * you may not use this file except in compliance with the License. 10547 * You may obtain a copy of the License at 10548 * 10549 * http://www.apache.org/licenses/LICENSE-2.0 10550 * 10551 * Unless required by applicable law or agreed to in writing, software 10552 * distributed under the License is distributed on an "AS IS" BASIS, 10553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10554 * See the License for the specific language governing permissions and 10555 * limitations under the License. 10556 * ============================================================================= 10557 */class fc{constructor(e,t,r){this.variableNames=["real","imag"];const a=t[1];this.outputShape=t;const s=r?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,o=r?`${a}.0`:"1.0";let 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=` 10558 const float exponentMultiplier = ${s}; 10559 10560 float unaryOpComplex(float real, float expR, float imag, float expI) { 10561 ${i} 10562 } 10563 10564 float mulMatDFT(int batch, int index) { 10565 float indexRatio = float(index) / float(${a}); 10566 float exponentMultiplierTimesIndexRatio = 10567 exponentMultiplier * indexRatio; 10568 10569 float result = 0.0; 10570 10571 for (int i = 0; i < ${a}; i++) { 10572 // x = (-2|2 * PI / N) * index * i; 10573 float x = exponentMultiplierTimesIndexRatio * float(i); 10574 float expR = cos(x); 10575 float expI = sin(x); 10576 float real = getReal(batch, i); 10577 float imag = getImag(batch, i); 10578 10579 result += 10580 unaryOpComplex(real, expR, imag, expI) / ${o}; 10581 } 10582 10583 return result; 10584 } 10585 10586 void main() { 10587 ivec2 coords = getOutputCoords(); 10588 setOutput(mulMatDFT(coords[0], coords[1])); 10589 } 10590 `}}/** 10591 * @license 10592 * Copyright 2020 Google LLC. All Rights Reserved. 10593 * Licensed under the Apache License, Version 2.0 (the "License"); 10594 * you may not use this file except in compliance with the License. 10595 * You may obtain a copy of the License at 10596 * 10597 * http://www.apache.org/licenses/LICENSE-2.0 10598 * 10599 * Unless required by applicable law or agreed to in writing, software 10600 * distributed under the License is distributed on an "AS IS" BASIS, 10601 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10602 * See the License for the specific language governing permissions and 10603 * limitations under the License. 10604 * ============================================================================= 10605 */function Fm(n,e,t){const r=t.texData.get(n.dataId),a=ae(n.shape),s=n.shape[n.shape.length-1],o=a/s,i=oe({inputs:{x:n},backend:t,attrs:{shape:[o,s]}}),u=i.shape,l=new fc("real",u,e),c=new fc("imag",u,e),p=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:u},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:u}],h=t.runWebGLProgram(l,p,"float32"),d=t.runWebGLProgram(c,p,"float32"),m=ir({inputs:{real:h,imag:d},backend:t});t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d);const y=oe({inputs:{x:m},backend:t,attrs:{shape:n.shape}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(m),y}/** 10606 * @license 10607 * Copyright 2020 Google LLC. All Rights Reserved. 10608 * Licensed under the Apache License, Version 2.0 (the "License");
10609 * you may not use this file except in compliance with the License. 10610 * You may obtain a copy of the License at 10611 * 10612 * http://www.apache.org/licenses/LICENSE-2.0 10613 * 10614 * Unless required by applicable law or agreed to in writing, software 10615 * distributed under the License is distributed on an "AS IS" BASIS, 10616 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10617 * See the License for the specific language governing permissions and 10618 * limitations under the License. 10619 * ============================================================================= 10620 */function AI(n){const{inputs:e,backend:t}=n,{input:r}=e;return Fm(r,!1,t)}const OI={kernelName:Up,backendName:"webgl",kernelFunc:AI};/** 10621 * @license 10622 * Copyright 2019 Google LLC. All Rights Reserved. 10623 * Licensed under the Apache License, Version 2.0 (the "License"); 10624 * you may not use this file except in compliance with the License. 10625 * You may obtain a copy of the License at 10626 * 10627 * http://www.apache.org/licenses/LICENSE-2.0 10628 * 10629 * Unless required by applicable law or agreed to in writing, software 10630 * distributed under the License is distributed on an "AS IS" BASIS, 10631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10632 * See the License for the specific language governing permissions and 10633 * limitations under the License. 10634 * ============================================================================= 10635 */class FI{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` 10636 void main() { 10637 // Input can be obtained from uniform value. 10638 setOutput(value); 10639 } 10640 `}}/** 10641 * @license 10642 * Copyright 2020 Google LLC. All Rights Reserved. 10643 * Licensed under the Apache License, Version 2.0 (the "License"); 10644 * you may not use this file except in compliance with the License. 10645 * You may obtain a copy of the License at 10646 * 10647 * http://www.apache.org/licenses/LICENSE-2.0 10648 * 10649 * Unless required by applicable law or agreed to in writing, software 10650 * distributed under the License is distributed on an "AS IS" BASIS, 10651 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10652 * See the License for the specific language governing permissions and 10653 * limitations under the License. 10654 * ============================================================================= 10655 */function Ss(n){const{backend:e,attrs:t}=n,{shape:r,value:a}=t;let{dtype:s}=t;if(s=s||vo(a),s==="string"){const o=kt(s,ae(r));return o.fill(a),e.makeTensorInfo(r,s,o)}else{const o=new FI(r,a),i=[[a]];return e.runWebGLProgram(o,[],s,i)}}const DI={kernelName:Vp,backendName:"webgl",kernelFunc:Ss};/** 10656 * @license 10657 * Copyright 2020 Google LLC. All Rights Reserved. 10658 * Licensed under the Apache License, Version 2.0 (the "License"); 10659 * you may not use this file except in compliance with the License. 10660 * You may obtain a copy of the License at 10661 * 10662 * http://www.apache.org/licenses/LICENSE-2.0 10663 * 10664 * Unless required by applicable law or agreed to in writing, software 10665 * distributed under the License is distributed on an "AS IS" BASIS, 10666 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10667 * See the License for the specific language governing permissions and 10668 * limitations under the License. 10669 * ============================================================================= 10670 */class MI{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=` 10671 void main() { 10672 ivec4 coords = getOutputCoords(); 10673 int x = coords[2]; 10674 10675 int coordX = ${t} - x - 1; 10676 float outputValue; 10677 if(coordX >= 0 && coordX < ${t}) { 10678 outputValue = getImage(coords[0], coords[1], coordX, coords[3]); 10679 } else { 10680 outputValue = getImage(coords[0], coords[1], coords[2], coords[3]); 10681 } 10682 setOutput(outputValue); 10683 } 10684 `}}/** 10685 * @license 10686 * Copyright 2020 Google LLC. All Rights Reserved. 10687 * Licensed under the Apache License, Version 2.0 (the "License"); 10688 * you may not use this file except in compliance with the License. 10689 * You may obtain a copy of the License at 10690 * 10691 * http://www.apache.org/licenses/LICENSE-2.0 10692 * 10693 * Unless required by applicable law or agreed to in writing, softw
10693are 10694 * distributed under the License is distributed on an "AS IS" BASIS, 10695 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10696 * See the License for the specific language governing permissions and 10697 * limitations under the License. 10698 * ============================================================================= 10699 */const LI={kernelName:Wp,backendName:"webgl",kernelFunc:({inputs:n,backend:e})=>{const{image:t}=n,r=e,a=new MI(t.shape);return r.runWebGLProgram(a,[t],t.dtype)}};/** 10700 * @license 10701 * Copyright 2020 Google LLC. All Rights Reserved. 10702 * Licensed under the Apache License, Version 2.0 (the "License"); 10703 * you may not use this file except in compliance with the License. 10704 * You may obtain a copy of the License at 10705 * 10706 * http://www.apache.org/licenses/LICENSE-2.0 10707 * 10708 * Unless required by applicable law or agreed to in writing, software 10709 * distributed under the License is distributed on an "AS IS" BASIS, 10710 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10711 * See the License for the specific language governing permissions and 10712 * limitations under the License. 10713 * ============================================================================= 10714 */const mc="return floor(x);",PI=Ie({opSnippet:mc,packedOpSnippet:mc,cpuKernelImpl:ck}),BI={kernelName:zp,backendName:"webgl",kernelFunc:PI};/** 10715 * @license 10716 * Copyright 2020 Google LLC. All Rights Reserved. 10717 * Licensed under the Apache License, Version 2.0 (the "License"); 10718 * you may not use this file except in compliance with the License. 10719 * You may obtain a copy of the License at 10720 * 10721 * http://www.apache.org/licenses/LICENSE-2.0 10722 * 10723 * Unless required by applicable law or agreed to in writing, software 10724 * distributed under the License is distributed on an "AS IS" BASIS, 10725 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10726 * See the License for the specific language governing permissions and 10727 * limitations under the License. 10728 * ============================================================================= 10729 */const UI=` 10730 float s = sign(a) * sign(b); 10731 int ia = round(a); 10732 int ib = round(b); 10733 if (ib != 0) { 10734 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 10735 return float(idiv(ia, ib, s)); 10736 } else { 10737 return NAN; 10738 } 10739`,VI=` 10740 ivec4 ia = round(a); 10741 ivec4 ib = round(b); 10742 bvec4 cond = notEqual(ib, ivec4(0)); 10743 ivec4 result = ivec4(0); 10744 vec4 s = sign(a) * sign(b); 10745 10746 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 10747 if (cond[0]) { 10748 result[0] = idiv(ia[0], ib[0], s[0]); 10749 } 10750 if (cond[1]) { 10751 result[1] = idiv(ia[1], ib[1], s[1]); 10752 } 10753 if (cond[2]) { 10754 result[2] = idiv(ia[2], ib[2], s[2]); 10755 } 10756 if (cond[3]) { 10757 result[3] = idiv(ia[3], ib[3], s[3]); 10758 } 10759 return vec4(result); 10760`,WI=ut({opSnippet:UI,packedOpSnippet:VI,dtype:"int32"}),zI={kernelName:Gp,backendName:"webgl",kernelFunc:WI};/** 10761 * @license 10762 * Copyright 2018 Google LLC. All Rights Reserved. 10763 * Licensed under the Apache License, Version 2.0 (the "License"); 10764 * you may not use this file except in compliance with the License. 10765 * You may obtain a copy of the License at 10766 * 10767 * http://www.apache.org/licenses/LICENSE-2.0 10768 * 10769 * Unless required by applicable law or agreed to in writing, software 10770 * distributed under the License is distributed on an "AS IS" BASIS, 10771 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10772 * See the License for the specific language governing permissions and 10773 * limitations under the License. 10774 * ============================================================================= 10775 */class GI{constructor(e){this.variableNames=["A"];const t=xt(),[r,a]=e;this.outputShape=e,this.userCode=` 10776 void main() { 10777 ivec3 coords = getOutputCoords(); 10778 int texR = coords[0]; 10779 int texC = coords[1]; 10780 int depth = coords[2]; 10781 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${a}.0, ${r}.0); 10782 10783 vec4 values = ${t.texture2D}(A, uv); 10784 float value; 10785 if (depth == 0) { 10786 value = values.r; 10787 } else if (depth == 1) { 10788 value = values.g; 10789 } else if (depth == 2) { 10790 value = values.b; 10791 } else if (depth == 3) { 10792 value = values.a; 10793 } 10794 10795 setOutput(floor(value * 255.0 + 0.5)); 10796 } 10797 `}}/** 10798 * @license 10799 * Copyright 2018 Google LLC. All Rights Reserved. 10800 * Licensed under the Apache License, Version 2.0 (the "License");
10801 * you may not use this file except in compliance with the License. 10802 * You may obtain a copy of the License at 10803 * 10804 * http://www.apache.org/licenses/LICENSE-2.0 10805 * 10806 * Unless required by applicable law or agreed to in writing, software 10807 * distributed under the License is distributed on an "AS IS" BASIS, 10808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10809 * See the License for the specific language governing permissions and 10810 * limitations under the License. 10811 * ============================================================================= 10812 */class jI{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=xt(),[r,a]=e;this.outputShape=e,this.userCode=` 10813 void main() { 10814 ivec3 coords = getOutputCoords(); 10815 int texR = coords[0]; 10816 int texC = coords[1]; 10817 int depth = coords[2]; 10818 10819 vec4 result = vec4(0.); 10820 10821 for(int row=0; row<=1; row++) { 10822 for(int col=0; col<=1; col++) { 10823 texC = coords[1] + row; 10824 depth = coords[2] + col; 10825 10826 vec2 uv = (vec2(texC, texR) + halfCR) / 10827 vec2(${a}.0, ${r}.0); 10828 vec4 values = ${t.texture2D}(A, uv); 10829 float value; 10830 if (depth == 0) { 10831 value = values.r; 10832 } else if (depth == 1) { 10833 value = values.g; 10834 } else if (depth == 2) { 10835 value = values.b; 10836 } else if (depth == 3) { 10837 value = values.a; 10838 } 10839 10840 result[row * 2 + col] = floor(value * 255.0 + 0.5); 10841 } 10842 } 10843 10844 ${t.output} = result; 10845 } 10846 `}}/** 10847 * @license 10848 * Copyright 2019 Google LLC. All Rights Reserved. 10849 * Licensed under the Apache License, Version 2.0 (the "License"); 10850 * you may not use this file except in compliance with the License. 10851 * You may obtain a copy of the License at 10852 * 10853 * http://www.apache.org/licenses/LICENSE-2.0 10854 * 10855 * Unless required by applicable law or agreed to in writing, software 10856 * distributed under the License is distributed on an "AS IS" BASIS, 10857 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10858 * See the License for the specific language governing permissions and 10859 * limitations under the License. 10860 * ============================================================================= 10861 */const HI={kernelName:Ri,backendName:"webgl",kernelFunc:XI};let ea,fi=H().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function XI(n){const{inputs:e,backend:t,attrs:r}=n;let{pixels:a}=e;const{numChannels:s}=r,o=typeof HTMLVideoElement<"u"&&a instanceof HTMLVideoElement,i=typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement,[u,l]=o?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=[l,u],p=[l,u,s];if(i||o){const y=H().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(ea==null||y!==fi)&&(fi=y,ea=document.createElement("canvas").getContext("2d",{willReadFrequently:fi})),ea.canvas.width=u,ea.canvas.height=l,ea.drawImage(a,0,0,u,l),a=ea.canvas}const h=t.makeTensorInfo(c,"int32");t.texData.get(h.dataId).usage=Mt.PIXELS,t.gpgpu.uploadPixelDataToTexture(t.getTexture(h.dataId),a);const d=H().getBool("WEBGL_PACK")?new jI(p):new GI(p),m=t.runWebGLProgram(d,[h],"int32");return t.disposeData(h.dataId),m}/** 10862 * @license 10863 * Copyright 2020 Google LLC. All Rights Reserved. 10864 * Licensed under the Apache License, Version 2.0 (the "License"); 10865 * you may not use this file except in compliance with the License. 10866 * You may obtain a copy of the License at 10867 * 10868 * http://www.apache.org/licenses/LICENSE-2.0 10869 * 10870 * Unless required by applicable law or agreed to in writing, software 10871 * distributed under the License is distributed on an "AS IS" BASIS, 10872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10873 * See the License for the specific language governing permissions and 10874 * limitations under the License. 10875 * ============================================================================= 10876 */function qI(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,filter:s,bias:o,preluActivationWeights:i}=e,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h,activation:d,leakyreluAlpha:m}=r,y=xa(c),b=Pt(a.shape,s.shape,u,p,l,h,!1,y);let x;const T=[],$=o!=null,F=i!=null,M=d==="leakyrelu",U=()=>{const z=[a,s],L=(C,q)=>
vendor: 9,086 bytes, lines 10876-10978
10876{if(q==="NCHW"&&C.shape.length===1&&C.shape[0]!==1){const ee=oe({inputs:{x:C},backend:t,attrs:{shape:[C.shape[0],1,1]}});return T.push(ee),ee}return C};if($&&z.push(L(o,c)),F&&z.push(L(i,c)),M){const C=t.makeTensorInfo([],"float32",ya(m,"float32"));z.push(C),T.push(C)}return z};if(b.filterHeight===1&&b.filterWidth===1&&b.dilationHeight===1&&b.dilationWidth===1&&b.strideHeight===1&&b.strideWidth===1&&(b.padInfo.type==="SAME"||b.padInfo.type==="VALID"))x=Nm({x:a,filter:s,convInfo:b,backend:t,bias:o,activation:d,preluActivationWeights:i,leakyreluAlpha:m});else if(b.strideWidth<=2&&y==="channelsLast"&&H().getBool("WEBGL_EXP_CONV")){const z=d?ls(d,!0):null,L=new Im(b,$,z,F,M),C=[[b.padInfo.top,b.padInfo.left],[b.strideHeight,b.strideWidth],[b.dilationHeight,b.dilationWidth],[b.inHeight,b.inWidth]],q=U();x=t.runWebGLProgram(L,q,"float32",C)}else if(H().getBool("WEBGL_CONV_IM2COL"))x=$m({x:a,filter:s,convInfo:b,backend:t,bias:o,activation:d,preluActivationWeights:i,leakyreluAlpha:m});else{const z=d?ls(d,!1):null,L=new Cm(b,$,z,F,M),C=U();x=t.runWebGLProgram(L,C,"float32")}const X=oe({inputs:{x},backend:t,attrs:{shape:b.outShape}});return T.push(x),T.forEach(z=>t.disposeIntermediateTensorInfo(z)),X}const KI={kernelName:Ai,backendName:"webgl",kernelFunc:qI};/** 10877 * @license 10878 * Copyright 2020 Google LLC. All Rights Reserved. 10879 * Licensed under the Apache License, Version 2.0 (the "License"); 10880 * you may not use this file except in compliance with the License. 10881 * You may obtain a copy of the License at 10882 * 10883 * http://www.apache.org/licenses/LICENSE-2.0 10884 * 10885 * Unless required by applicable law or agreed to in writing, software 10886 * distributed under the License is distributed on an "AS IS" BASIS, 10887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10888 * See the License for the specific language governing permissions and 10889 * limitations under the License. 10890 * ============================================================================= 10891 */function YI(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,filter:s,bias:o,preluActivationWeights:i}=e,{strides:u,pad:l,dilations:c,dimRoundingMode:p,activation:h,leakyreluAlpha:d}=r,m=[];let y=c;y==null&&(y=[1,1]),R(_t(u,y),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${y}'`);const b=Pt(a.shape,s.shape,u,y,l,p,!0),x=H().getBool("WEBGL_PACK_DEPTHWISECONV")&&b.strideWidth<=2&&b.outChannels/b.inChannels===1,T=h?ls(h,x):null,$=[a,s],F=o!=null,M=i!=null,U=h==="leakyrelu";if(F&&$.push(o),M&&$.push(i),U){const C=t.makeTensorInfo([],"float32",ya(d,"float32"));$.push(C),m.push(C)}let X;x?X=new Am(b,F,T,M,U):X=new _m(b,F,T,M,U);const z=[[b.padInfo.top,b.padInfo.left],[b.strideHeight,b.strideWidth],[b.dilationHeight,b.dilationWidth],[b.inHeight,b.inWidth]],L=t.runWebGLProgram(X,$,"float32",z);return m.forEach(C=>t.disposeIntermediateTensorInfo(C)),L}const ZI={kernelName:Oi,backendName:"webgl",kernelFunc:YI};class JI{constructor(e,t,r,a){this.sliceDim=e,this.strides=t,this.paramsShape=a,this.variableNames=["x","indices"],this.outputShape=r;const s=Be(r.length);let o=` 10892 int index;`;for(let i=0;i<this.sliceDim;i++)o+=` 10893 index = round(getIndices(coords[0], ${i})); 10894 out_of_bounds = out_of_bounds || index < 0; 10895 out_of_bounds = out_of_bounds || index >= ${this.paramsShape[i]}; 10896 flattenIndex += index * ${this.strides[i]};`;this.userCode=` 10897 void main() { 10898 ${s} coords = getOutputCoords(); 10899 int flattenIndex = 0; 10900 bool out_of_bounds = false; 10901 10902 ${o} 10903 10904 setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1])); 10905 } 10906 `}}/** 10907 * @license 10908 * Copyright 2020 Google LLC. All Rights Reserved. 10909 * Licensed under the Apache License, Version 2.0 (the "License"); 10910 * you may not use this file except in compliance with the License. 10911 * You may obtain a copy of the License at 10912 * 10913 * http://www.apache.org/licenses/LICENSE-2.0 10914 * 10915 * Unless required by applicable law or agreed to in writing, software 10916 * distributed under the License is distributed on an "AS IS" BASIS, 10917 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10918 * See the License for the specific language governing permissions and 10919 * limitations under the License. 10920 * ============================================================================= 10921 */function QI(n){const{inputs:e,backend:t}=n,{params:r,indices:a}=e,s=a.shape,o=s[s.length-1],i=ae(r.shape),[u,l,c,p]=hf(r,a),h=oe({inputs:{x:a},backend:t,attrs:{shape:[l,o]}}),d=oe({inputs:{x:r},backend:t,attrs:{shape:[ae(r.shape)/c,c]}});if(t.shouldExecuteOnCPU([r,a])||r.dtype==="string"){const x=t.readSync(a.dataId),T=t.bufferSync(r),$=pk(x,T,r.dtype,l,o,c,p,r.shape,i);return t.makeTensorInfo(u,r.dtype,$.values)}const m=new JI(o,p,[l,c],r.shape),y=t.runWebGLProgram(m,[d,h],d.dtype),b=oe({inputs:{x:y},backend:t,attrs:{shape:u}});return t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(y),b}const eN={kernelName:Xp,backendName:"webgl",kernelFunc:QI};/** 10922 * @license 10923 * Copyright 2017 Google LLC. All Rights Reserved. 10924 * Licensed under the Apache License, Version 2.0 (the "License"); 10925 * you may not use this file except in compliance with the License. 10926 * You may obtain a copy of the License at 10927 * 10928 * http://www.apache.org/licenses/LICENSE-2.0 10929 * 10930 * Unless required by applicable law or agreed to in writing, software 10931 * distributed under the License is distributed on an "AS IS" BASIS, 10932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10933 * See the License for the specific language governing permissions and 10934 * limitations under the License. 10935 * ============================================================================= 10936 */class tN{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const r=Be(this.rank),a=nN(e);this.userCode=` 10937 void main() { 10938 ${r} resRC = getOutputCoords(); 10939 int index = int(getIndices(resRC.x, resRC.z)); 10940 float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0; 10941 setOutput(inBounds * getA(${a})); 10942 } 10943 `}}function nN(n,e){const t=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let a=0;a<n.length;a++)a===2?r.push("index"):r.push(`${t[a]}`);return r.join()}/** 10944 * @license 10945 * Copyright 2020 Google LLC. All Rights Reserved. 10946 * Licensed under the Apache License, Version 2.0 (the "License"); 10947 * you may not use this file except in compliance with the License. 10948 * You may obtain a copy of the License at 10949 * 10950 * http://www.apache.org/licenses/LICENSE-2.0 10951 * 10952 * Unless required by applicable law or agreed to in writing, software 10953 * distributed under the License is distributed on an "AS IS" BASIS, 10954 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10955 * See the License for the specific language governing permissions and 10956 * limitations under the License. 10957 * ============================================================================= 10958 */function Dm(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,indices:s}=e,{axis:o,batchDims:i}=r,u=rt(o,a.shape)[0];if(H().get("DEBUG")){const T=t.readSync(s.dataId),$=a.shape[u];for(let F=0;F<T.length;++F){const M=T[F];R(M<=$-1&&M>=0,()=>`GatherV2: the index value ${M} is not in [0, ${$-1}]`)}}const l=K1(a,s,u,i),c=ae(s.shape),p=[],h=oe({inputs:{x:a},backend:t,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),d=oe({inputs:{x:s},backend:t,attrs:{shape:[l.batchSize,c/l.batchSize]}});p.push(h),p.push(d);const m=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(t.shouldExecuteOnCPU([a,s])||a.dtype==="string"){const T=t.bufferSync(d),$=t.bufferSync(h),F=hk($,T,m);return p.forEach(M=>t.disposeIntermediateTensorInfo(M)),t.makeTensorInfo(l.outputShape,F.dtype,F.values)}const y=new tN(h.shape,m),b=t.runWebGLProgram(y,[h,d],h.dtype);p.push(b);const x=oe({inputs:{x:b},backend:t,attrs:{shape:l.outputShape}});return p.forEach(T=>t.disposeIntermediateTensorInfo(T)),x}const rN={kernelName:Hp,backendName:"webgl",kernelFunc:Dm};/** 10959 * @license 10960 * Copyright 2020 Google LLC. All Rights Reserved. 10961 * Licensed under the Apache License, Version 2.0 (the "License"); 10962 * you may not use this file except in compliance with the License. 10963 * You may obtain a copy of the License at 10964 * 10965 * http://www.apache.org/licenses/LICENSE-2.0 10966 * 10967 * Unless required by applicable law or agreed to in writing, software 10968 * distributed under the License is distributed on an "AS IS" BASIS, 10969 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10970 * See the License for the specific language governing permissions and 10971 * limitations under the License. 10972 * ============================================================================= 10973 */const aN="return float(a > b);",sN=` 10974 return vec4(greaterThan(a, b)); 10975`,oN=ut({opSnippet:aN,packedOpSnippet:sN,cpuKernelImpl:dk,dtype:"bool"}),iN={kernelName:qp,backendName:"webgl",kernelFunc:oN};/** 10976 * @license 10977 * Copyright 2020 Google LLC. All Rights Reserved. 10978 * Licensed under the Apache License, Version 2.0 (the "License");
10979 * you may not use this file except in compliance with the License. 10980 * You may obtain a copy of the License at 10981 * 10982 * http://www.apache.org/licenses/LICENSE-2.0 10983 * 10984 * Unless required by applicable law or agreed to in writing, software 10985 * distributed under the License is distributed on an "AS IS" BASIS, 10986 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10987 * See the License for the specific language governing permissions and 10988 * limitations under the License. 10989 * ============================================================================= 10990 */const uN="return float(a >= b);",lN=` 10991 return vec4(greaterThanEqual(a, b)); 10992`,cN=ut({opSnippet:uN,packedOpSnippet:lN,dtype:"bool",cpuKernelImpl:fk}),pN={kernelName:Kp,backendName:"webgl",kernelFunc:cN};/** 10993 * @license 10994 * Copyright 2020 Google LLC. All Rights Reserved. 10995 * Licensed under the Apache License, Version 2.0 (the "License"); 10996 * you may not use this file except in compliance with the License. 10997 * You may obtain a copy of the License at 10998 * 10999 * http://www.apache.org/licenses/LICENSE-2.0 11000 * 11001 * Unless required by applicable law or agreed to in writing, software 11002 * distributed under the License is distributed on an "AS IS" BASIS, 11003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11004 * See the License for the specific language governing permissions and 11005 * limitations under the License. 11006 * ============================================================================= 11007 */function hN(n){const{inputs:e,backend:t}=n,{input:r}=e;return Fm(r,!0,t)}const dN={kernelName:Yp,backendName:"webgl",kernelFunc:hN};/** 11008 * @license 11009 * Copyright 2020 Google LLC. All Rights Reserved. 11010 * Licensed under the Apache License, Version 2.0 (the "License"); 11011 * you may not use this file except in compliance with the License. 11012 * You may obtain a copy of the License at 11013 * 11014 * http://www.apache.org/licenses/LICENSE-2.0 11015 * 11016 * Unless required by applicable law or agreed to in writing, software 11017 * distributed under the License is distributed on an "AS IS" BASIS, 11018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11019 * See the License for the specific language governing permissions and 11020 * limitations under the License. 11021 * ============================================================================= 11022 */const fN="return float(!isnan(x) && !isinf(x));",mN=Ie({opSnippet:fN,dtype:"bool"}),gN={kernelName:Jp,backendName:"webgl",kernelFunc:mN};/** 11023 * @license 11024 * Copyright 2020 Google LLC. All Rights Reserved. 11025 * Licensed under the Apache License, Version 2.0 (the "License"); 11026 * you may not use this file except in compliance with the License. 11027 * You may obtain a copy of the License at 11028 * 11029 * http://www.apache.org/licenses/LICENSE-2.0 11030 * 11031 * Unless required by applicable law or agreed to in writing, software 11032 * distributed under the License is distributed on an "AS IS" BASIS, 11033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11034 * See the License for the specific language governing permissions and 11035 * limitations under the License. 11036 * ============================================================================= 11037 */const yN="return float(isinf(x));",xN=Ie({opSnippet:yN,dtype:"bool"}),bN={kernelName:Qp,backendName:"webgl",kernelFunc:xN};/** 11038 * @license 11039 * Copyright 2020 Google LLC. All Rights Reserved. 11040 * Licensed under the Apache License, Version 2.0 (the "License"); 11041 * you may not use this file except in compliance with the License. 11042 * You may obtain a copy of the License at 11043 * 11044 * http://www.apache.org/licenses/LICENSE-2.0 11045 * 11046 * Unless required by applicable law or agreed to in writing, software 11047 * distributed under the License is distributed on an "AS IS" BASIS, 11048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11049 * See the License for the specific language governing permissions and 11050 * limitations under the License. 11051 * ============================================================================= 11052 */const vN="return float(isnan(x));",wN=Ie({opSnippet:vN,dtype:"bool"}),SN={kernelName:eh,backendName:"webgl",kernelFunc:wN};/** 11053 * @license 11054 * Copyright 2020 Google LLC. All Rights Reserved. 11055 * Licensed under the Apache License, Version 2.0 (the "License");
11056 * you may not use this file except in compliance with the License. 11057 * You may obtain a copy of the License at 11058 * 11059 * http://www.apache.org/licenses/LICENSE-2.0 11060 * 11061 * Unless required by applicable law or agreed to in writing, software 11062 * distributed under the License is distributed on an "AS IS" BASIS, 11063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11064 * See the License for the specific language governing permissions and 11065 * limitations under the License. 11066 * ============================================================================= 11067 */const kN="return float(a < b);",TN=` 11068 return vec4(lessThan(a, b)); 11069`,EN=ut({opSnippet:kN,packedOpSnippet:TN,cpuKernelImpl:mk,dtype:"bool"}),CN={kernelName:nh,backendName:"webgl",kernelFunc:EN};/** 11070 * @license 11071 * Copyright 2020 Google LLC. All Rights Reserved. 11072 * Licensed under the Apache License, Version 2.0 (the "License"); 11073 * you may not use this file except in compliance with the License. 11074 * You may obtain a copy of the License at 11075 * 11076 * http://www.apache.org/licenses/LICENSE-2.0 11077 * 11078 * Unless required by applicable law or agreed to in writing, software 11079 * distributed under the License is distributed on an "AS IS" BASIS, 11080 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11081 * See the License for the specific language governing permissions and 11082 * limitations under the License. 11083 * ============================================================================= 11084 */const IN="return float(a <= b);",NN=` 11085 return vec4(lessThanEqual(a, b)); 11086`,$N=ut({opSnippet:IN,packedOpSnippet:NN,cpuKernelImpl:gk,dtype:"bool"}),RN={kernelName:rh,backendName:"webgl",kernelFunc:$N};/** 11087 * @license 11088 * Copyright 2020 Google LLC. All Rights Reserved. 11089 * Licensed under the Apache License, Version 2.0 (the "License"); 11090 * you may not use this file except in compliance with the License. 11091 * You may obtain a copy of the License at 11092 * 11093 * http://www.apache.org/licenses/LICENSE-2.0 11094 * 11095 * Unless required by applicable law or agreed to in writing, software 11096 * distributed under the License is distributed on an "AS IS" BASIS, 11097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11098 * See the License for the specific language governing permissions and 11099 * limitations under the License. 11100 * ============================================================================= 11101 */function _N(n){const{backend:e,attrs:t}=n,{start:r,stop:a,num:s}=t,o=yk(r,a,s);return e.makeTensorInfo([o.length],"float32",o)}const AN={kernelName:ah,backendName:"webgl",kernelFunc:_N};/** 11102 * @license 11103 * Copyright 2020 Google LLC. All Rights Reserved. 11104 * Licensed under the Apache License, Version 2.0 (the "License"); 11105 * you may not use this file except in compliance with the License. 11106 * You may obtain a copy of the License at 11107 * 11108 * http://www.apache.org/licenses/LICENSE-2.0 11109 * 11110 * Unless required by applicable law or agreed to in writing, software 11111 * distributed under the License is distributed on an "AS IS" BASIS, 11112 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11113 * See the License for the specific language governing permissions and 11114 * limitations under the License. 11115 * ============================================================================= 11116 */const ON=Ca+` 11117 return x < 0.0 ? 0./0. : log(x); 11118`,FN=` 11119 vec4 result = log(x); 11120 bvec4 isNaN = isnan(x); 11121 result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r); 11122 result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g); 11123 result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b); 11124 result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a); 11125 return result; 11126`,DN=Ie({opSnippet:ON,packedOpSnippet:FN,cpuKernelImpl:xk}),MN={kernelName:sh,backendName:"webgl",kernelFunc:DN};/** 11127 * @license 11128 * Copyright 2020 Google LLC. All Rights Reserved. 11129 * Licensed under the Apache License, Version 2.0 (the "License"); 11130 * you may not use this file except in compliance with the License. 11131 * You may obtain a copy of the License at 11132 * 11133 * http://www.apache.org/licenses/LICENSE-2.0 11134 * 11135 * Unless required by applicable law or agreed to in writing, softw
11135are 11136 * distributed under the License is distributed on an "AS IS" BASIS, 11137 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11138 * See the License for the specific language governing permissions and 11139 * limitations under the License. 11140 * ============================================================================= 11141 */const LN=Ca+` 11142 return log(1.0 + x); 11143`,PN=Ie({opSnippet:LN}),BN={kernelName:oh,backendName:"webgl",kernelFunc:PN};/** 11144 * @license 11145 * Copyright 2020 Google LLC. All Rights Reserved. 11146 * Licensed under the Apache License, Version 2.0 (the "License"); 11147 * you may not use this file except in compliance with the License. 11148 * You may obtain a copy of the License at 11149 * 11150 * http://www.apache.org/licenses/LICENSE-2.0 11151 * 11152 * Unless required by applicable law or agreed to in writing, software 11153 * distributed under the License is distributed on an "AS IS" BASIS, 11154 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11155 * See the License for the specific language governing permissions and 11156 * limitations under the License. 11157 * ============================================================================= 11158 */const UN="return float(a >= 1.0 && b >= 1.0);",VN=` 11159 return vec4( 11160 vec4(greaterThanEqual(a, vec4(1.0))) * 11161 vec4(greaterThanEqual(b, vec4(1.0)))); 11162`,WN=ut({opSnippet:UN,packedOpSnippet:VN,dtype:"bool"}),zN={kernelName:ih,backendName:"webgl",kernelFunc:WN};/** 11163 * @license 11164 * Copyright 2020 Google LLC. All Rights Reserved. 11165 * Licensed under the Apache License, Version 2.0 (the "License"); 11166 * you may not use this file except in compliance with the License. 11167 * You may obtain a copy of the License at 11168 * 11169 * http://www.apache.org/licenses/LICENSE-2.0 11170 * 11171 * Unless required by applicable law or agreed to in writing, software 11172 * distributed under the License is distributed on an "AS IS" BASIS, 11173 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11174 * See the License for the specific language governing permissions and 11175 * limitations under the License. 11176 * ============================================================================= 11177 */const GN="return float(!(x >= 1.0));",jN=Ie({opSnippet:GN}),HN={kernelName:uh,backendName:"webgl",kernelFunc:jN};/** 11178 * @license 11179 * Copyright 2020 Google LLC. All Rights Reserved. 11180 * Licensed under the Apache License, Version 2.0 (the "License"); 11181 * you may not use this file except in compliance with the License. 11182 * You may obtain a copy of the License at 11183 * 11184 * http://www.apache.org/licenses/LICENSE-2.0 11185 * 11186 * Unless required by applicable law or agreed to in writing, software 11187 * distributed under the License is distributed on an "AS IS" BASIS, 11188 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11189 * See the License for the specific language governing permissions and 11190 * limitations under the License. 11191 * ============================================================================= 11192 */const XN="return float(a >= 1.0 || b >= 1.0);",qN=` 11193 return min( 11194 vec4(greaterThanEqual(a, vec4(1.0))) + 11195 vec4(greaterThanEqual(b, vec4(1.0))), 11196 vec4(1.0)); 11197`,KN=ut({opSnippet:XN,packedOpSnippet:qN,dtype:"bool"}),YN={kernelName:lh,backendName:"webgl",kernelFunc:KN};/** 11198 * @license 11199 * Copyright 2017 Google LLC. All Rights Reserved. 11200 * Licensed under the Apache License, Version 2.0 (the "License"); 11201 * you may not use this file except in compliance with the License. 11202 * You may obtain a copy of the License at 11203 * 11204 * http://www.apache.org/licenses/LICENSE-2.0 11205 * 11206 * Unless required by applicable law or agreed to in writing, software 11207 * distributed under the License is distributed on an "AS IS" BASIS, 11208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11209 * See the License for the specific language governing permissions and 11210 * limitations under the License. 11211 * ============================================================================= 11212 */class ZN{constructor(e,t,r,a,s){this.variableNames=["x"],this.outputShape=[];const o=t,i=e[3]-1;this.outputShape=e;let u;const l=`float(${r}) + float(${a}) * sum`;s===.5?u=`inversesqrt(${l})`:s===1?u=`1.0/(${l})`:u=`exp(log(${l}) * float(-${s}));`,this.userCode=` 11213 void main() { 11214 ivec4 coords = getOutputCoords(); 11215 int b = coords[0]; 11216 int r = coords[1]; 11217 int c = coords[2]; 11218 int d = coords[3]; 11219 float x = getX(b, r, c, d); 11220 float sum = 0.0;
11221 for (int j = -${o}; j <= ${o}; j++) { 11222 int idx = d + j; 11223 if (idx >= 0 && idx <= ${i}) { 11224 float z = getX(b, r, c, idx); 11225 sum += z * z; 11226 } 11227 } 11228 float val = x * ${u}; 11229 setOutput(val); 11230 } 11231 `}}/** 11232 * @license 11233 * Copyright 2019 Google LLC. All Rights Reserved. 11234 * Licensed under the Apache License, Version 2.0 (the "License"); 11235 * you may not use this file except in compliance with the License. 11236 * You may obtain a copy of the License at 11237 * 11238 * http://www.apache.org/licenses/LICENSE-2.0 11239 * 11240 * Unless required by applicable law or agreed to in writing, software 11241 * distributed under the License is distributed on an "AS IS" BASIS, 11242 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11243 * See the License for the specific language governing permissions and 11244 * limitations under the License. 11245 * ============================================================================= 11246 */class JN{constructor(e,t,r,a,s){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const o=t,i=e[3]-1;this.outputShape=e;let u;const l=`float(${r}) + float(${a}) * sum`;s===.5?u=`inversesqrt(${l})`:s===1?u=`1.0/(${l})`:u=`exp(log(${l}) * float(-${s}));`,this.userCode=` 11247 void main() { 11248 ivec4 coords = getOutputCoords(); 11249 int b = coords.x; 11250 int r = coords.y; 11251 int c = coords.z; 11252 int d = coords.w; 11253 11254 bool hasNextCol = d < ${this.outputShape[3]}; 11255 bool hasNextRow = c < ${this.outputShape[2]}; 11256 11257 vec4 sum = vec4(0.); 11258 vec4 xFragAtOutputCoords = getX(b, r, c, d); 11259 11260 vec4 xAtOutputCoords = vec4( 11261 getChannel(xFragAtOutputCoords, vec2(c, d)), 11262 hasNextCol ? 11263 getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0, 11264 hasNextRow ? 11265 getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0, 11266 (hasNextRow && hasNextCol) ? 11267 getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0 11268 ); 11269 11270 int firstChannel = d - ${o}; 11271 vec2 cache = vec2(0.); 11272 if(firstChannel >= 0){ 11273 vec4 firstChannelFrag = getX(b, r, c, firstChannel); 11274 cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel)); 11275 if(hasNextRow){ 11276 cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel)); 11277 } 11278 } 11279 11280 ivec2 depth = ivec2(d, d + 1); 11281 for (int j = - ${o}; j <= ${o}; j++) { 11282 ivec2 idx = depth + j; 11283 bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0)); 11284 bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${i})); 11285 11286 bool depthInRange = aboveLowerBound.x && belowUpperBound.x; 11287 bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y; 11288 11289 if(depthInRange || depthPlusOneInRange){ 11290 vec4 z = vec4(0.); 11291 vec4 xFragAtCurrentDepth; 11292 z.xz = cache.xy; 11293 if(depthPlusOneInRange && hasNextCol){ 11294 xFragAtCurrentDepth = idx.y != d ? 11295 getX(b, r, c, idx.y) : xFragAtOutputCoords; 11296 z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y)); 11297 if(hasNextRow){ 11298 z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y)); 11299 } 11300 } 11301 cache.xy = z.yw; 11302 sum += z * z; 11303 } 11304 } 11305 vec4 result = xAtOutputCoords * ${u}; 11306 setOutput(result); 11307 } 11308 `}}/** 11309 * @license 11310 * Copyright 2020 Google LLC. All Rights Reserved. 11311 * Licensed under the Apache License, Version 2.0 (the "License"); 11312 * you may not use this file except in compliance with the License. 11313 * You may obtain a copy of the License at 11314 * 11315 * http://www.apache.org/licenses/LICENSE-2.0 11316 * 11317 * Unless required by applicable law or agreed to in writing, software 11318 * distributed under the License is distributed on an "AS IS" BASIS, 11319 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11320 * See the License for the specific language governing permissions and 11321 * limitations under the License. 11322 * ============================================================================= 11323 */const QN=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:a}
vendor: 4,765 bytes, lines 11323-11426
11323=e,{depthRadius:s,bias:o,alpha:i,beta:u}=r,l=H().getBool("WEBGL_PACK_NORMALIZATION")?new JN(a.shape,s,o,i,u):new ZN(a.shape,s,o,i,u);return t.runWebGLProgram(l,[a],a.dtype)},e$={kernelName:ch,backendName:"webgl",kernelFunc:QN};/** 11324 * @license 11325 * Copyright 2018 Google LLC. All Rights Reserved. 11326 * Licensed under the Apache License, Version 2.0 (the "License"); 11327 * you may not use this file except in compliance with the License. 11328 * You may obtain a copy of the License at 11329 * 11330 * http://www.apache.org/licenses/LICENSE-2.0 11331 * 11332 * Unless required by applicable law or agreed to in writing, software 11333 * distributed under the License is distributed on an "AS IS" BASIS, 11334 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11335 * See the License for the specific language governing permissions and 11336 * limitations under the License. 11337 * ============================================================================= 11338 */class t${constructor(e,t,r,a,s){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=r,this.alpha=a,this.beta=s,this.userCode=` 11339 void main() { 11340 ivec4 coords = getOutputCoords(); 11341 int b = coords[0]; 11342 int r = coords[1]; 11343 int c = coords[2]; 11344 11345 float result = 0.0; 11346 for (int d = 0; d < ${this.depth}; ++d) { 11347 int depthBegin = int(max(0.0, float(d - ${t}))); 11348 int depthEnd = int(min(float(${this.depth}), 11349 float(d + ${t} + 1))); 11350 11351 const int MIN_DEPTH_BEGIN = 0; 11352 const int MAX_DEPTH_END = ${this.depth}; 11353 11354 float norm = 0.0; 11355 for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) { 11356 if (k < depthBegin){ 11357 continue; 11358 } 11359 else if (k >= depthBegin && k < depthEnd) { 11360 norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k); 11361 } 11362 else { 11363 break; 11364 } 11365 } 11366 11367 norm = float(${a}) * norm + float(${r}); 11368 11369 for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){ 11370 if (k < depthBegin){ 11371 continue; 11372 } 11373 else if (k >= depthBegin && k < depthEnd){ 11374 float dyi = -2.0 * float(${a}) 11375 * float(${s}) 11376 * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d) 11377 / norm; 11378 if (k == d) { 11379 dyi += pow(norm, -1.0 * ${s}); 11380 } 11381 if (k == coords[3]) { 11382 dyi *= getDy(b, r, c, d); 11383 result += dyi; 11384 } 11385 } 11386 else { 11387 break; 11388 } 11389 } 11390 } 11391 setOutput(result); 11392 } 11393 `}}/** 11394 * @license 11395 * Copyright 2020 Google LLC. All Rights Reserved. 11396 * Licensed under the Apache License, Version 2.0 (the "License"); 11397 * you may not use this file except in compliance with the License. 11398 * You may obtain a copy of the License at 11399 * 11400 * http://www.apache.org/licenses/LICENSE-2.0 11401 * 11402 * Unless required by applicable law or agreed to in writing, software 11403 * distributed under the License is distributed on an "AS IS" BASIS, 11404 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11405 * See the License for the specific language governing permissions and 11406 * limitations under the License. 11407 * ============================================================================= 11408 */const n$=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:a,y:s,dy:o}=e,{depthRadius:i,bias:u,alpha:l,beta:c}=r,p=new t$(a.shape,i,u,l,c);return t.runWebGLProgram(p,[a,s,o],a.dtype)},r$={kernelName:O2,backendName:"webgl",kernelFunc:n$};/** 11409 * @license 11410 * Copyright 2020 Google LLC. All Rights Reserved. 11411 * Licensed under the Apache License, Version 2.0 (the "License"); 11412 * you may not use this file except in compliance with the License. 11413 * You may obtain a copy of the License at 11414 * 11415 * http://www.apache.org/licenses/LICENSE-2.0 11416 * 11417 * Unless required by applicable law or agreed to in writing, software 11418 * distributed under the License is distributed on an "AS IS" BASIS, 11419 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11420 * See the License for the specific language governing permissions and 11421 * limitations under the License. 11422 * ============================================================================= 11423 */function a$(n,e,t,r){const a=ae(e),s=ae(n.shape)/a,o=oe({inputs:{x:n},attrs:{shape:[s,a]},backend:r}),i=Wr(o,n.dtype,"max",r),u=oe({inputs:{x:i},attrs:{shape:t},backend:r});return r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(i),u}/** 11424 * @license 11425 * Copyright 2020 Google LLC. All Rights Reserved. 11426 * Licensed under the Apache License, Version 2.0 (the "License");
11427 * you may not use this file except in compliance with the License. 11428 * You may obtain a copy of the License at 11429 * 11430 * http://www.apache.org/licenses/LICENSE-2.0 11431 * 11432 * Unless required by applicable law or agreed to in writing, software 11433 * distributed under the License is distributed on an "AS IS" BASIS, 11434 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11435 * See the License for the specific language governing permissions and 11436 * limitations under the License. 11437 * ============================================================================= 11438 */function Mm(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{reductionIndices:s,keepDims:o}=r,i=a.shape.length,u=rt(s,a.shape);let l=u;const c=Qt(l,i),p=c!=null,h=t.shouldExecuteOnCPU([a]);let d=a;if(p){if(h){const T=t.texData.get(d.dataId).values,$=new Array(i);for(let U=0;U<$.length;U++)$[U]=a.shape[c[U]];const F=il(T,a.shape,a.dtype,c,$);d=t.makeTensorInfo($,a.dtype);const M=t.texData.get(d.dataId);M.values=F}else d=Po(a,c,t);l=en(l.length,i)}hn("max",l,i);const[m,y]=kn(d.shape,l);let b=m;o&&(b=Bt(m,u));let x;if(h){const T=t.texData.get(d.dataId).values,$=bk(T,ae(y),b,a.dtype);x=t.makeTensorInfo(b,a.dtype);const F=t.texData.get(x.dataId);F.values=$}else x=a$(d,y,b,t);return p&&t.disposeIntermediateTensorInfo(d),x}const s$={kernelName:ph,backendName:"webgl",kernelFunc:Mm};/** 11439 * @license 11440 * Copyright 2020 Google LLC. All Rights Reserved. 11441 * Licensed under the Apache License, Version 2.0 (the "License"); 11442 * you may not use this file except in compliance with the License. 11443 * You may obtain a copy of the License at 11444 * 11445 * http://www.apache.org/licenses/LICENSE-2.0 11446 * 11447 * Unless required by applicable law or agreed to in writing, software 11448 * distributed under the License is distributed on an "AS IS" BASIS, 11449 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11450 * See the License for the specific language governing permissions and 11451 * limitations under the License. 11452 * ============================================================================= 11453 */const o$=ul+` 11454 return max(a, b); 11455`,i$=` 11456 vec4 result = vec4(max(a, b)); 11457 bvec4 isNaNA = isnan(a); 11458 bvec4 isNaNB = isnan(b); 11459 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 11460 `+bs+` 11461 return result; 11462`,u$=ut({opSnippet:o$,packedOpSnippet:i$,cpuKernelImpl:vk}),l$={kernelName:hh,backendName:"webgl",kernelFunc:u$};/** 11463 * @license 11464 * Copyright 2020 Google LLC. All Rights Reserved. 11465 * Licensed under the Apache License, Version 2.0 (the "License"); 11466 * you may not use this file except in compliance with the License. 11467 * You may obtain a copy of the License at 11468 * 11469 * http://www.apache.org/licenses/LICENSE-2.0 11470 * 11471 * Unless required by applicable law or agreed to in writing, software 11472 * distributed under the License is distributed on an "AS IS" BASIS, 11473 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11474 * See the License for the specific language governing permissions and 11475 * limitations under the License. 11476 * ============================================================================= 11477 */function c$(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e;ys(a,"maxPool");const{filterSize:s,strides:o,pad:i,dimRoundingMode:u}=r,l=1;R(_t(o,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${l}'`);const c=Pr(a.shape,s,o,l,i,u);if(c.filterWidth===1&&c.filterHeight===1&&qe(c.inShape,c.outShape))return Rt({inputs:{x:a},backend:t});const p=new cs(c,"max",!1);return t.runWebGLProgram(p,[a],a.dtype)}const p$={kernelName:dh,backendName:"webgl",kernelFunc:c$};/** 11478 * @license 11479 * Copyright 2020 Google LLC. All Rights Reserved. 11480 * Licensed under the Apache License, Version 2.0 (the "License"); 11481 * you may not use this file except in compliance with the License. 11482 * You may obtain a copy of the License at 11483 * 11484 * http://www.apache.org/licenses/LICENSE-2.0 11485 * 11486 * Unless required by applicable law or agreed to in writing, software 11487 * distributed under the License is distributed on an "AS IS" BASIS, 11488 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11489 * See the License for the specific language governing permissions and 11490 * limitations under the License. 11491 * ============================================================================= 11492 */function h$(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{filterSize:s,strides:o,pad:i,dataFormat:u,dimRoundingMode:l}=r,c=[1,1,1],p=ds(a.shape,s,o,c,i,l,u),h=new cl(p,"max",!1);return t.runWebGLProgram(h,[a],a.dtype)}const d$={kernelName:fh,backendName:"webgl",kernelFunc:h$};/** 11493 * @license 11494 * Copyright 2017 Google LLC. All Rights Reserved. 11495 * Licensed under the Apache License, Version 2.0 (the "License");
11496 * you may not use this file except in compliance with the License. 11497 * You may obtain a copy of the License at 11498 * 11499 * http://www.apache.org/licenses/LICENSE-2.0 11500 * 11501 * Unless required by applicable law or agreed to in writing, software 11502 * distributed under the License is distributed on an "AS IS" BASIS, 11503 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11504 * See the License for the specific language governing permissions and 11505 * limitations under the License. 11506 * ============================================================================= 11507 */class f${constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,r=e.strideWidth,a=e.dilationHeight,s=e.effectiveFilterHeight,o=e.effectiveFilterWidth,i=s-1-e.padInfo.top,u=o-1-e.padInfo.left,l=s*o-1;this.userCode=` 11508 const ivec2 pads = ivec2(${i}, ${u}); 11509 11510 void main() { 11511 ivec4 coords = getOutputCoords(); 11512 int b = coords[0]; 11513 int d = coords[3]; 11514 11515 ivec2 dyRCCorner = coords.yz - pads; 11516 int dyRCorner = dyRCCorner.x; 11517 int dyCCorner = dyRCCorner.y; 11518 11519 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 11520 // ? = to be determined. : = across all values in that axis. 11521 float dotProd = 0.0; 11522 for (int wR = 0; wR < ${s}; 11523 wR += ${a}) { 11524 float dyR = float(dyRCorner + wR) / ${t}.0; 11525 11526 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 11527 continue; 11528 } 11529 int idyR = int(dyR); 11530 11531 for (int wC = 0; wC < ${o}; wC++) { 11532 float dyC = float(dyCCorner + wC) / ${r}.0; 11533 11534 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 11535 fract(dyC) > 0.0) { 11536 continue; 11537 } 11538 int idyC = int(dyC); 11539 11540 float dyValue = getDy(b, idyR, idyC, d); 11541 int maxPosValue = ${l} - int(getMaxPos(b, idyR, idyC, d)); 11542 11543 // Get the current value, check it against the value from the 11544 // position matrix. 11545 int curPosValue = wR * ${o} + wC; 11546 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 11547 11548 dotProd += dyValue * mask; 11549 } 11550 } 11551 setOutput(dotProd); 11552 } 11553 `}}class m${constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,r=e.strideHeight,a=e.strideWidth,s=e.dilationDepth,o=e.dilationHeight,i=e.dilationWidth,u=e.effectiveFilterDepth,l=e.effectiveFilterHeight,c=e.effectiveFilterWidth,p=u-1-e.padInfo.front,h=l-1-e.padInfo.top,d=c-1-e.padInfo.left,m=u*l*c-1;this.userCode=` 11554 const ivec3 pads = ivec3(${p}, ${h}, ${d}); 11555 11556 void main() { 11557 ivec5 coords = getOutputCoords(); 11558 int batch = coords.x; 11559 int ch = coords.u; 11560 11561 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 11562 int dyDCorner = dyCorner.x; 11563 int dyRCorner = dyCorner.y; 11564 int dyCCorner = dyCorner.z; 11565 11566 // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get 11567 // dx(xD, xR, xC, ch). 11568 // ? = to be determined. : = across all values in that axis. 11569 float dotProd = 0.0; 11570 11571 for (int wD = 0; wD < ${u}; 11572 wD += ${s}) { 11573 float dyD = float(dyDCorner + wD) / ${t}.0; 11574 11575 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 11576 continue; 11577 } 11578 int idyD = int(dyD); 11579 11580 for (int wR = 0; wR < ${l}; 11581 wR += ${o}) { 11582 float dyR = float(dyRCorner + wR) / ${r}.0; 11583 11584 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 11585 fract(dyR) > 0.0) { 11586 continue; 11587 } 11588 int idyR = int(dyR); 11589 11590 for (int wC = 0; wC < ${c}; 11591 wC += ${i}) { 11592 float dyC = float(dyCCorner + wC) / ${a}.0; 11593 11594 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 11595 fract(dyC) > 0.0) { 11596 continue; 11597 } 11598 int idyC = int(dyC); 11599 11600 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 11601 int maxPosValue = ${m} - 11602 int(getMaxPos(batch, idyD, idyR, idyC, ch)); 11603 11604 // Get the current value, check it against the value from the 11605 // position matrix. 11606 int curPosValue = 11607 wD * ${l} * ${c} + 11608 wR * ${c} + wC; 11609 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 11610 11611 dotProd += dyValue * mask; 11612 } 11613 } 11614 } 11615 setOutput(dotProd); 11616 } 11617 `}}/** 11618 * @license 11619 * Copyright 2020 Google LLC. All Rights Reserved. 11620 * Licensed under the Apache License, Version 2.0 (the "License");
11621 * you may not use this file except in compliance with the License. 11622 * You may obtain a copy of the License at 11623 * 11624 * http://www.apache.org/licenses/LICENSE-2.0 11625 * 11626 * Unless required by applicable law or agreed to in writing, software 11627 * distributed under the License is distributed on an "AS IS" BASIS, 11628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11629 * See the License for the specific language governing permissions and 11630 * limitations under the License. 11631 * ============================================================================= 11632 */function g$(n){const{inputs:e,backend:t,attrs:r}=n,{dy:a,input:s}=e,o=s,{filterSize:i,strides:u,pad:l,dimRoundingMode:c}=r,p=[1,1,1],h=ds(o.shape,i,u,p,l,c),d=new cl(h,"max",!0),m=t.runWebGLProgram(d,[o],o.dtype),y=new m$(h),b=t.runWebGLProgram(y,[a,m],o.dtype);return t.disposeIntermediateTensorInfo(m),b}const y$={kernelName:D2,backendName:"webgl",kernelFunc:g$};/** 11633 * @license 11634 * Copyright 2020 Google LLC. All Rights Reserved. 11635 * Licensed under the Apache License, Version 2.0 (the "License"); 11636 * you may not use this file except in compliance with the License. 11637 * You may obtain a copy of the License at 11638 * 11639 * http://www.apache.org/licenses/LICENSE-2.0 11640 * 11641 * Unless required by applicable law or agreed to in writing, software 11642 * distributed under the License is distributed on an "AS IS" BASIS, 11643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11644 * See the License for the specific language governing permissions and 11645 * limitations under the License. 11646 * ============================================================================= 11647 */function x$(n){const{inputs:e,backend:t,attrs:r}=n,{dy:a,input:s,output:o}=e,i=s;ys([s,o],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,h=Pr(i.shape,u,l,1,c,p),d=!0,m=new cs(h,"max",d),y=t.runWebGLProgram(m,[i],i.dtype),b=new f$(h),x=t.runWebGLProgram(b,[a,y],i.dtype);return t.disposeIntermediateTensorInfo(y),x}const b$={kernelName:F2,backendName:"webgl",kernelFunc:x$};/** 11648 * @license 11649 * Copyright 2020 Google LLC. All Rights Reserved. 11650 * Licensed under the Apache License, Version 2.0 (the "License"); 11651 * you may not use this file except in compliance with the License. 11652 * You may obtain a copy of the License at 11653 * 11654 * http://www.apache.org/licenses/LICENSE-2.0 11655 * 11656 * Unless required by applicable law or agreed to in writing, software 11657 * distributed under the License is distributed on an "AS IS" BASIS, 11658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11659 * See the License for the specific language governing permissions and 11660 * limitations under the License. 11661 * ============================================================================= 11662 */function v$(n,e,t,r){let a=new cs(t,"max",!1);const s=r.runWebGLProgram(a,[n],"float32");a=new cs(t,"max",!0,!0,e);const o=r.runWebGLProgram(a,[n],"float32");return[s,o]}/** 11663 * @license 11664 * Copyright 2020 Google LLC. All Rights Reserved. 11665 * Licensed under the Apache License, Version 2.0 (the "License"); 11666 * you may not use this file except in compliance with the License. 11667 * You may obtain a copy of the License at 11668 * 11669 * http://www.apache.org/licenses/LICENSE-2.0 11670 * 11671 * Unless required by applicable law or agreed to in writing, software 11672 * distributed under the License is distributed on an "AS IS" BASIS, 11673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11674 * See the License for the specific language governing permissions and 11675 * limitations under the License. 11676 * ============================================================================= 11677 */const w$={kernelName:mh,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:r}=n,{filterSize:a,strides:s,pad:o,includeBatchInIndex:i}=e,u=t;R(r.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`);const l=[1,1];R(_t(s,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '${l}'`);const c=Pr(r.shape,a,s,l,o),[p,h]=v$(r,i,c,u);return[p,h]}};/** 11678 * @license 11679 * Copyright 2020 Google LLC. All Rights Reserved. 11680 * Licensed under the Apache License, Version 2.0 (the "License");
11681 * you may not use this file except in compliance with the License. 11682 * You may obtain a copy of the License at 11683 * 11684 * http://www.apache.org/licenses/LICENSE-2.0 11685 * 11686 * Unless required by applicable law or agreed to in writing, software 11687 * distributed under the License is distributed on an "AS IS" BASIS, 11688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11689 * See the License for the specific language governing permissions and 11690 * limitations under the License. 11691 * ============================================================================= 11692 */function S$(n,e,t,r){const a=ae(e),s=ae(n.shape)/a,o=oe({inputs:{x:n},attrs:{shape:[s,a]},backend:r}),i=Wr(o,"float32","mean",r),u=oe({inputs:{x:i},attrs:{shape:t},backend:r});return r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(i),u}/** 11693 * @license 11694 * Copyright 2020 Google LLC. All Rights Reserved. 11695 * Licensed under the Apache License, Version 2.0 (the "License"); 11696 * you may not use this file except in compliance with the License. 11697 * You may obtain a copy of the License at 11698 * 11699 * http://www.apache.org/licenses/LICENSE-2.0 11700 * 11701 * Unless required by applicable law or agreed to in writing, software 11702 * distributed under the License is distributed on an "AS IS" BASIS, 11703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11704 * See the License for the specific language governing permissions and 11705 * limitations under the License. 11706 * ============================================================================= 11707 */const k$={kernelName:gh,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:r}=n,{keepDims:a,axis:s}=e,o=t,i=r.shape.length,u=rt(s,r.shape);let l=u;const c=Qt(l,i),p=c!=null,h=o.shouldExecuteOnCPU([r]),d=[];let m=r;if(p){if(h){const $=o.texData.get(m.dataId).values,F=new Array(i);for(let X=0;X<F.length;X++)F[X]=r.shape[c[X]];const M=il($,r.shape,r.dtype,c,F);m=o.makeTensorInfo(F,r.dtype);const U=o.texData.get(m.dataId);U.values=M}else m=Po(r,c,o);d.push(m),l=en(l.length,i)}hn("sum",l,i);const[y,b]=kn(m.shape,l);let x=y;a&&(x=Bt(y,u));const T=S$(m,b,x,o);for(const $ of d)o.disposeIntermediateTensorInfo($);return T}};/** 11708 * @license 11709 * Copyright 2020 Google LLC. All Rights Reserved. 11710 * Licensed under the Apache License, Version 2.0 (the "License"); 11711 * you may not use this file except in compliance with the License. 11712 * You may obtain a copy of the License at 11713 * 11714 * http://www.apache.org/licenses/LICENSE-2.0 11715 * 11716 * Unless required by applicable law or agreed to in writing, software 11717 * distributed under the License is distributed on an "AS IS" BASIS, 11718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11719 * See the License for the specific language governing permissions and 11720 * limitations under the License. 11721 * ============================================================================= 11722 */function T$(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s,keepDims:o}=r,i=a.shape.length,u=rt(s,a.shape);let l=u;const c=Qt(l,i);let p=a;c!=null&&(p=yt({inputs:{x:a},backend:t,attrs:{perm:c}}),l=en(l.length,a.shape.length)),hn("min",l,i);const[h,d]=kn(p.shape,l),m=ae(d),y=oe({inputs:{x:p},backend:t,attrs:{shape:[-1,m]}}),b=Wr(y,y.dtype,"min",t);let x;if(o){const T=Bt(h,u);x=oe({inputs:{x:b},backend:t,attrs:{shape:T}})}else x=oe({inputs:{x:b},backend:t,attrs:{shape:h}});return t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(b),c!=null&&t.disposeIntermediateTensorInfo(p),x}const E$={kernelName:yh,backendName:"webgl",kernelFunc:T$};/** 11723 * @license 11724 * Copyright 2020 Google LLC. All Rights Reserved. 11725 * Licensed under the Apache License, Version 2.0 (the "License"); 11726 * you may not use this file except in compliance with the License. 11727 * You may obtain a copy of the License at 11728 * 11729 * http://www.apache.org/licenses/LICENSE-2.0 11730 * 11731 * Unless required by applicable law or agreed to in writing, software 11732 * distributed under the License is distributed on an "AS IS" BASIS, 11733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11734 * See the License for the specific language governing permissions and 11735 * limitations under the License. 11736 * ============================================================================= 11737 */const C$=ul+` 11738 return min(a, b); 11739`,I$=` 11740 vec4 result = vec4(min(a, b)); 11741 bvec4 isNaNA = isnan(a); 11742 bvec4 isNaNB = isnan(b); 11743 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 11744 `+bs+` 11745 return result; 11746`,N$=ut({opSnippet:C$,packedOpSnippet:I$,cpuKernelImpl:wk}),$$={kernelName:xh,backendName:"webgl",kernelFunc:N$};/** 11747 * @license 11748 * Copyright 2020 Google LLC. All Rights Reserved. 11749 * Licensed under the Apache License, Version 2.0 (the "License");
11750 * you may not use this file except in compliance with the License. 11751 * You may obtain a copy of the License at 11752 * 11753 * http://www.apache.org/licenses/LICENSE-2.0 11754 * 11755 * Unless required by applicable law or agreed to in writing, software 11756 * distributed under the License is distributed on an "AS IS" BASIS, 11757 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11758 * See the License for the specific language governing permissions and 11759 * limitations under the License. 11760 * ============================================================================= 11761 */class R${constructor(e,t,r){this.variableNames=["x"],this.outputShape=t.map((c,p)=>c[0]+e[p]+c[1]);const a=e.length,s=Be(a),o=t.map(c=>c[0]).join(","),i=t.map((c,p)=>c[0]+e[p]).join(","),u=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a),l=r==="reflect"?0:1;if(a===1){this.userCode=` 11762 int start = ${o}; 11763 int end = ${i}; 11764 11765 void main() { 11766 int outC = getOutputCoords(); 11767 if (outC < start) { 11768 outC = start * 2 - outC - ${l}; 11769 } else if(outC >= end) { 11770 outC = (end - 1) * 2 - outC + ${l}; 11771 } 11772 setOutput(getX(outC - start)); 11773 } 11774 `;return}this.userCode=` 11775 ${s} start = ${s}(${o}); 11776 ${s} end = ${s}(${i}); 11777 11778 void main() { 11779 ${s} outC = getOutputCoords(); 11780 for (int i = 0; i < ${a}; i++) { 11781 if (outC[i] < start[i]) { 11782 outC[i] = start[i] * 2 - outC[i] - ${l}; 11783 } else if(outC[i] >= end[i]) { 11784 outC[i] = (end[i] - 1) * 2 - outC[i] + ${l}; 11785 } 11786 } 11787 ${s} coords = outC - start; 11788 setOutput(getX(${u})); 11789 } 11790 `}}/** 11791 * @license 11792 * Copyright 2020 Google LLC. All Rights Reserved. 11793 * Licensed under the Apache License, Version 2.0 (the "License"); 11794 * you may not use this file except in compliance with the License. 11795 * You may obtain a copy of the License at 11796 * 11797 * http://www.apache.org/licenses/LICENSE-2.0 11798 * 11799 * Unless required by applicable law or agreed to in writing, software 11800 * distributed under the License is distributed on an "AS IS" BASIS, 11801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11802 * See the License for the specific language governing permissions and 11803 * limitations under the License. 11804 * ============================================================================= 11805 */class _${constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((m,y)=>m[0]+e[y]+m[1]);const a=e.length,s=Be(a),o=t.map(m=>m[0]).join(","),i=t.map((m,y)=>m[0]+e[y]).join(","),u=ft("rc",a),l=ft("source",a),c=`${u[a-1]} < ${this.outputShape[a-1]}`,p=a===1?"source":`vec2(${l.slice(-2).join()})`,h=r==="reflect"?0:1;let d="";if(a===1){const m=` 11806 ${s} source = rc; 11807 if (source < start) { 11808 source = start * 2 - source - ${h}; 11809 } else if (source >= end) { 11810 source = (end - 1) * 2 - source + ${h}; 11811 } 11812 source -= start; 11813 `;d=` 11814 ${s} rc = outputLoc; 11815 ${m} 11816 result[0] = getChannel(getX(${l.join()}), ${p}); 11817 ${u[a-1]} += 1; 11818 if(${c}) { 11819 ${m} 11820 result[1] = getChannel(getX(${l.join()}), ${p}); 11821 } 11822 `}else{const m=` 11823 ${s} source = rc; 11824 ${s} lt = ${s}(lessThan(source, start)); 11825 ${s} gte = ${s}(greaterThanEqual(source, end)); 11826 ${s} orig = 1 - (lt + gte); 11827 source = orig * source + 11828 lt * (start * 2 - source - ${h}) + 11829 gte * ((end - 1) * 2 - source + ${h}); 11830 source -= start; 11831 `;d=` 11832 ${s} rc = outputLoc; 11833 ${m} 11834 result[0] = getChannel(getX(${l.join()}), ${p}); 11835 ${u[a-1]} += 1; 11836 if(${c}) { 11837 ${m} 11838 result[1] = getChannel(getX(${l.join()}), ${p}); 11839 } 11840 rc = outputLoc; 11841 ${u[a-2]} += 1; 11842 if(${u[a-2]} < ${this.outputShape[a-2]}) { 11843 ${m} 11844 result[2] = getChannel(getX(${l.join()}), ${p}); 11845 ${u[a-1]} += 1; 11846 if(${c}) { 11847 ${m} 11848 result[3] = getChannel(getX(${l.join()}), ${p}); 11849 } 11850 } 11851 `}this.userCode=` 11852 const ${s} start = ${s}(${o}); 11853 const ${s} end = ${s}(${i}); 11854 11855 void main() { 11856 ${s} outputLoc = getOutputCoords(); 11857 vec4 result = vec4(0.); 11858 ${d} 11859 setOutput(result); 11860 } 11861 `}}/** 11862 * @license 11863 * Copyright 2020 Google LLC. All Rights Reserved. 11864 * Licensed under the Apache License, Version 2.0 (the "License");
11865 * you may not use this file except in compliance with the License. 11866 * You may obtain a copy of the License at 11867 * 11868 * http://www.apache.org/licenses/LICENSE-2.0 11869 * 11870 * Unless required by applicable law or agreed to in writing, software 11871 * distributed under the License is distributed on an "AS IS" BASIS, 11872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11873 * See the License for the specific language governing permissions and 11874 * limitations under the License. 11875 * ============================================================================= 11876 */const A$=({inputs:n,backend:e,attrs:t})=>{const{x:r}=n,{paddings:a,mode:s}=t,o=H().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new _$(r.shape,a,s):new R$(r.shape,a,s);return e.runWebGLProgram(o,[r],r.dtype)},O$={kernelName:bh,backendName:"webgl",kernelFunc:A$};/** 11877 * @license 11878 * Copyright 2020 Google LLC. All Rights Reserved. 11879 * Licensed under the Apache License, Version 2.0 (the "License"); 11880 * you may not use this file except in compliance with the License. 11881 * You may obtain a copy of the License at 11882 * 11883 * http://www.apache.org/licenses/LICENSE-2.0 11884 * 11885 * Unless required by applicable law or agreed to in writing, software 11886 * distributed under the License is distributed on an "AS IS" BASIS, 11887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11888 * See the License for the specific language governing permissions and 11889 * limitations under the License. 11890 * ============================================================================= 11891 */const F$=`if (b == 0.0) return NAN; 11892 return mod(a, b);`,D$=` 11893 vec4 result = mod(a, b); 11894 bvec4 isNaN = equal(b, vec4(0.0)); 11895 `+bs+` 11896 return result; 11897`,M$=ut({opSnippet:F$,packedOpSnippet:D$}),L$={kernelName:vh,backendName:"webgl",kernelFunc:M$};/** 11898 * @license 11899 * Copyright 2017 Google LLC. All Rights Reserved. 11900 * Licensed under the Apache License, Version 2.0 (the "License"); 11901 * you may not use this file except in compliance with the License. 11902 * You may obtain a copy of the License at 11903 * 11904 * http://www.apache.org/licenses/LICENSE-2.0 11905 * 11906 * Unless required by applicable law or agreed to in writing, software 11907 * distributed under the License is distributed on an "AS IS" BASIS, 11908 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11909 * See the License for the specific language governing permissions and 11910 * limitations under the License. 11911 * ============================================================================= 11912 */class P${constructor(e,t,r){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,r],this.userCode=` 11913 void main() { 11914 ivec2 coords = getOutputCoords(); 11915 int batch = coords[0]; 11916 11917 float r = random(seed); 11918 float cdf = 0.0; 11919 11920 for (int i = 0; i < ${t-1}; i++) { 11921 cdf += getProbs(batch, i); 11922 11923 if (r < cdf) { 11924 setOutput(float(i)); 11925 return; 11926 } 11927 } 11928 11929 // If no other event happened, last event happened. 11930 setOutput(float(${t-1})); 11931 } 11932 `}}/** 11933 * @license 11934 * Copyright 2020 Google LLC. All Rights Reserved. 11935 * Licensed under the Apache License, Version 2.0 (the "License"); 11936 * you may not use this file except in compliance with the License. 11937 * You may obtain a copy of the License at 11938 * 11939 * http://www.apache.org/licenses/LICENSE-2.0 11940 * 11941 * Unless required by applicable law or agreed to in writing, software 11942 * distributed under the License is distributed on an "AS IS" BASIS, 11943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11944 * See the License for the specific language governing permissions and 11945 * limitations under the License. 11946 * ============================================================================= 11947 */const B$=` 11948if (a == b) { 11949 return 1.0; 11950}; 11951return a / b;`,U$=` 11952 // vec4 one = vec4(equal(a, b)); 11953 // return one + (vec4(1.0) - one) * a / b; 11954 vec4 result = a / b; 11955 if(a.x == b.x) { 11956 result.x = 1.; 11957 } 11958 if(a.y == b.y) { 11959 result.y = 1.; 11960 } 11961 if(a.z == b.z) { 11962 result.z = 1.; 11963 } 11964 if(a.w == b.w) { 11965 result.w = 1.; 11966 } 11967 11968 return result; 11969`,Lm=ut({opSnippet:B$,packedOpSnippet:U$,checkOutOfBounds:!0}),V$={kernelName:Ap,backendName:"webgl",kernelFunc:Lm};/** 11970 * @license 11971 * Copyright 2020 Google LLC. All Rights Reserved. 11972 * Licensed under the Apache License, Version 2.0 (the "License");
11973 * you may not use this file except in compliance with the License. 11974 * You may obtain a copy of the License at 11975 * 11976 * http://www.apache.org/licenses/LICENSE-2.0 11977 * 11978 * Unless required by applicable law or agreed to in writing, software 11979 * distributed under the License is distributed on an "AS IS" BASIS, 11980 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11981 * See the License for the specific language governing permissions and 11982 * limitations under the License. 11983 * ============================================================================= 11984 */const gc="return a - b;",Pm=ut({opSnippet:gc,packedOpSnippet:gc,supportsComplex:!0,cpuKernelImpl:Uk}),W$={kernelName:bd,backendName:"webgl",kernelFunc:Pm};/** 11985 * @license 11986 * Copyright 2020 Google LLC. All Rights Reserved. 11987 * Licensed under the Apache License, Version 2.0 (the "License"); 11988 * you may not use this file except in compliance with the License. 11989 * You may obtain a copy of the License at 11990 * 11991 * http://www.apache.org/licenses/LICENSE-2.0 11992 * 11993 * Unless required by applicable law or agreed to in writing, software 11994 * distributed under the License is distributed on an "AS IS" BASIS, 11995 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11996 * See the License for the specific language governing permissions and 11997 * limitations under the License. 11998 * ============================================================================= 11999 */function Bm(n){const{inputs:e,backend:t,attrs:r}=n,{logits:a}=e,{dim:s}=r,o=rt([s],a.shape),i=Mm({inputs:{x:a},backend:t,attrs:{reductionIndices:o,keepDims:!1}}),u=Bt(i.shape,o),l=oe({inputs:{x:i},backend:t,attrs:{shape:u}}),c=Pm({inputs:{a,b:l},backend:t}),p=Om({inputs:{x:c},backend:t}),h=Bo({inputs:{x:p},backend:t,attrs:{axis:o,keepDims:!1}}),d=oe({inputs:{x:h},backend:t,attrs:{shape:u}}),m=Lm({inputs:{a:p,b:d},backend:t});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(l),t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),m}const z$={kernelName:ud,backendName:"webgl",kernelFunc:Bm};/** 12000 * @license 12001 * Copyright 2020 Google LLC. All Rights Reserved. 12002 * Licensed under the Apache License, Version 2.0 (the "License"); 12003 * you may not use this file except in compliance with the License. 12004 * You may obtain a copy of the License at 12005 * 12006 * http://www.apache.org/licenses/LICENSE-2.0 12007 * 12008 * Unless required by applicable law or agreed to in writing, software 12009 * distributed under the License is distributed on an "AS IS" BASIS, 12010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12011 * See the License for the specific language governing permissions and 12012 * limitations under the License. 12013 * ============================================================================= 12014 */function G$(n){const{inputs:e,backend:t,attrs:r}=n,{logits:a}=e,{numSamples:s,seed:o,normalized:i}=r,u=i?a:Bm({inputs:{logits:a},backend:t,attrs:{dim:a.shape.length-1}}),l=u.shape[0],c=u.shape[1],p=new P$(l,c,s),h=[[o]],d=t.runWebGLProgram(p,[u],"int32",h);return i||t.disposeIntermediateTensorInfo(u),d}const j$={kernelName:wh,backendName:"webgl",kernelFunc:G$};/** 12015 * @license 12016 * Copyright 2020 Google LLC. All Rights Reserved. 12017 * Licensed under the Apache License, Version 2.0 (the "License"); 12018 * you may not use this file except in compliance with the License. 12019 * You may obtain a copy of the License at 12020 * 12021 * http://www.apache.org/licenses/LICENSE-2.0 12022 * 12023 * Unless required by applicable law or agreed to in writing, software 12024 * distributed under the License is distributed on an "AS IS" BASIS, 12025 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12026 * See the License for the specific language governing permissions and 12027 * limitations under the License. 12028 * ============================================================================= 12029 */const H$=tn+` 12030 return -x; 12031`,X$=` 12032 vec4 result = -x; 12033 bvec4 isNaN = isnan(x); 12034 12035 result.r = isNaN.r ? x.r : result.r; 12036 result.g = isNaN.g ? x.g : result.g; 12037 result.b = isNaN.b ? x.b : result.b; 12038 result.a = isNaN.a ? x.a : result.a; 12039 12040 return result; 12041`;function q$(n){const{inputs:e,backend:t}=n,{x:r}=e;if(t.shouldExecuteOnCPU([r])){const s=t.texData.get(r.dataId),[o,i]=kk(s.values,r.shape,r.dtype);return t.makeTensorInfo(i,r.dtype,o)}let a;return H().getBool("WEBGL_PACK_UNARY_OPERATIONS")?a=new Ir(r.shape,X$):a=new $n(r.shape,H$),t.runWebGLProgram(a,[r],r.dtype)}const K$={kernelName:kh,backendName:"webgl",kernelFunc:q$};/** 12042 * @license 12043 * Copyright 2020 Google LLC. All Rights Reserved. 12044 * Licensed under the Apache License, Version 2.0 (the "License");
12045 * you may not use this file except in compliance with the License. 12046 * You may obtain a copy of the License at 12047 * 12048 * http://www.apache.org/licenses/LICENSE-2.0 12049 * 12050 * Unless required by applicable law or agreed to in writing, software 12051 * distributed under the License is distributed on an "AS IS" BASIS, 12052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12053 * See the License for the specific language governing permissions and 12054 * limitations under the License. 12055 * ============================================================================= 12056 */const Y$=p1;function Z$(n){ln("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:a,scores:s}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:u}=r,l=t.readSync(a.dataId),c=t.readSync(s.dataId),{selectedIndices:p}=Y$(l,c,o,i,u);return t.makeTensorInfo([p.length],"int32",new Int32Array(p))}const J$={kernelName:Eh,backendName:"webgl",kernelFunc:Z$};/** 12057 * @license 12058 * Copyright 2020 Google LLC. All Rights Reserved. 12059 * Licensed under the Apache License, Version 2.0 (the "License"); 12060 * you may not use this file except in compliance with the License. 12061 * You may obtain a copy of the License at 12062 * 12063 * http://www.apache.org/licenses/LICENSE-2.0 12064 * 12065 * Unless required by applicable law or agreed to in writing, software 12066 * distributed under the License is distributed on an "AS IS" BASIS, 12067 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12068 * See the License for the specific language governing permissions and 12069 * limitations under the License. 12070 * ============================================================================= 12071 */const Q$=h1;function e7(n){ln("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:a,scores:s}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:u,padToMaxOutputSize:l}=r,c=t.readSync(a.dataId),p=t.readSync(s.dataId),{selectedIndices:h,validOutputs:d}=Q$(c,p,o,i,u,l);return[t.makeTensorInfo([h.length],"int32",new Int32Array(h)),t.makeTensorInfo([],"int32",new Int32Array([d]))]}const t7={kernelName:Ch,backendName:"webgl",kernelFunc:e7};/** 12072 * @license 12073 * Copyright 2020 Google LLC. All Rights Reserved. 12074 * Licensed under the Apache License, Version 2.0 (the "License"); 12075 * you may not use this file except in compliance with the License. 12076 * You may obtain a copy of the License at 12077 * 12078 * http://www.apache.org/licenses/LICENSE-2.0 12079 * 12080 * Unless required by applicable law or agreed to in writing, software 12081 * distributed under the License is distributed on an "AS IS" BASIS, 12082 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12083 * See the License for the specific language governing permissions and 12084 * limitations under the License. 12085 * ============================================================================= 12086 */const n7=d1;function r7(n){ln("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:a,scores:s}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:u,softNmsSigma:l}=r,c=t.readSync(a.dataId),p=t.readSync(s.dataId),h=o,d=i,m=u,y=l,{selectedIndices:b,selectedScores:x}=n7(c,p,h,d,m,y);return[t.makeTensorInfo([b.length],"int32",new Int32Array(b)),t.makeTensorInfo([x.length],"float32",new Float32Array(x))]}const a7={kernelName:Ih,backendName:"webgl",kernelFunc:r7};/** 12087 * @license 12088 * Copyright 2017 Google LLC. All Rights Reserved. 12089 * Licensed under the Apache License, Version 2.0 (the "License"); 12090 * you may not use this file except in compliance with the License. 12091 * You may obtain a copy of the License at 12092 * 12093 * http://www.apache.org/licenses/LICENSE-2.0 12094 * 12095 * Unless required by applicable law or agreed to in writing, software 12096 * distributed under the License is distributed on an "AS IS" BASIS, 12097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12098 * See the License for the specific language governing permissions and 12099 * limitations under the License. 12100 * ============================================================================= 12101 */class s7{constructor(e,t,r,a){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=` 12102 void main() { 12103 ivec2 coords = getOutputCoords(); 12104 int index = round(getIndices(coords.x)); 12105 setOutput(mix(float(${a}), float(${r}), 12106 float(index == coords.y))); 12107 } 12108 `}}/** 12109 * @license 12110 * Copyright 2020 Google LLC. All Rights Reserved. 12111 * Licensed under the Apache License, Version 2.0 (the "License");
12112 * you may not use this file except in compliance with the License. 12113 * You may obtain a copy of the License at 12114 * 12115 * http://www.apache.org/licenses/LICENSE-2.0 12116 * 12117 * Unless required by applicable law or agreed to in writing, software 12118 * distributed under the License is distributed on an "AS IS" BASIS, 12119 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12120 * See the License for the specific language governing permissions and 12121 * limitations under the License. 12122 * ============================================================================= 12123 */const o7=n=>{const{inputs:e,backend:t,attrs:r}=n,{indices:a}=e,{dtype:s,depth:o,onValue:i,offValue:u}=r,l=ae(a.shape),c=new s7(l,o,i,u),p=oe({inputs:{x:a},backend:t,attrs:{shape:[l]}}),h=t.runWebGLProgram(c,[p],s);t.disposeIntermediateTensorInfo(p);const d=[...a.shape,o],m=oe({inputs:{x:h},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(h),m},i7={kernelName:$h,backendName:"webgl",kernelFunc:o7};/** 12124 * @license 12125 * Copyright 2020 Google LLC. All Rights Reserved. 12126 * Licensed under the Apache License, Version 2.0 (the "License"); 12127 * you may not use this file except in compliance with the License. 12128 * You may obtain a copy of the License at 12129 * 12130 * http://www.apache.org/licenses/LICENSE-2.0 12131 * 12132 * Unless required by applicable law or agreed to in writing, software 12133 * distributed under the License is distributed on an "AS IS" BASIS, 12134 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12135 * See the License for the specific language governing permissions and 12136 * limitations under the License. 12137 * ============================================================================= 12138 */function fo(n){const{inputs:e,backend:t}=n,{x:r}=e;
12138if(r.dtype==="complex64"){const a=ws({inputs:{input:r},backend:t}),s=fo({inputs:{x:a},backend:t}),o=Uo({inputs:{input:r},backend:t}),i=fo({inputs:{x:o},backend:t}),u=ir({inputs:{real:s,imag:i},backend:t});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),u}else return Ss({attrs:{shape:r.shape,dtype:r.dtype,value:r.dtype==="string"?"":0},backend:t})}const u7={kernelName:Id,backendName:"webgl",kernelFunc:fo};/** 12139 * @license 12140 * Copyright 2020 Google LLC. All Rights Reserved. 12141 * Licensed under the Apache License, Version 2.0 (the "License"); 12142 * you may not use this file except in compliance with the License. 12143 * You may obtain a copy of the License at 12144 * 12145 * http://www.apache.org/licenses/LICENSE-2.0 12146 * 12147 * Unless required by applicable law or agreed to in writing, software 12148 * distributed under the License is distributed on an "AS IS" BASIS, 12149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12150 * See the License for the specific language governing permissions and 12151 * limitations under the License. 12152 * ============================================================================= 12153 */function Um(n){const{inputs:e,backend:t}=n,{x:r}=e;if(r.dtype==="string")throw new Error("onesLike is not supported under string dtype");
vendor: 7,326 bytes, lines 12153-12284
12153if(r.dtype==="complex64"){const a=ws({inputs:{input:r},backend:t}),s=Um({inputs:{x:a},backend:t}),o=Uo({inputs:{input:r},backend:t}),i=fo({inputs:{x:o},backend:t}),u=ir({inputs:{real:s,imag:i},backend:t});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),u}else return Ss({attrs:{shape:r.shape,dtype:r.dtype,value:1},backend:t})}const l7={kernelName:Nh,backendName:"webgl",kernelFunc:Um};/** 12154 * @license 12155 * Copyright 2020 Google LLC. All Rights Reserved. 12156 * Licensed under the Apache License, Version 2.0 (the "License"); 12157 * you may not use this file except in compliance with the License. 12158 * You may obtain a copy of the License at 12159 * 12160 * http://www.apache.org/licenses/LICENSE-2.0 12161 * 12162 * Unless required by applicable law or agreed to in writing, software 12163 * distributed under the License is distributed on an "AS IS" BASIS, 12164 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12165 * See the License for the specific language governing permissions and 12166 * limitations under the License. 12167 * ============================================================================= 12168 */function c7(n){const{inputs:e,backend:t,attrs:r}=n,{axis:a}=r;if(e.length===1)return cu({inputs:{input:e[0]},backend:t,attrs:{dim:a}});const s=e[0].shape,o=e[0].dtype;e.forEach(c=>{Lt(s,c.shape,"All tensors passed to stack must have matching shapes"),R(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});const i=[],u=e.map(c=>{const p=cu({inputs:{input:c},backend:t,attrs:{dim:a}});return i.push(p),p}),l=Em({inputs:u,backend:t,attrs:{axis:a}});return i.forEach(c=>t.disposeIntermediateTensorInfo(c)),l}const p7={kernelName:Rh,backendName:"webgl",kernelFunc:c7};/** 12169 * @license 12170 * Copyright 2017 Google LLC. All Rights Reserved. 12171 * Licensed under the Apache License, Version 2.0 (the "License"); 12172 * you may not use this file except in compliance with the License. 12173 * You may obtain a copy of the License at 12174 * 12175 * http://www.apache.org/licenses/LICENSE-2.0 12176 * 12177 * Unless required by applicable law or agreed to in writing, software 12178 * distributed under the License is distributed on an "AS IS" BASIS, 12179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12180 * See the License for the specific language governing permissions and 12181 * limitations under the License. 12182 * ============================================================================= 12183 */class h7{constructor(e,t,r){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((l,c)=>l[0]+e[c]+l[1]);const a=e.length,s=Be(a),o=t.map(l=>l[0]).join(","),i=t.map((l,c)=>l[0]+e[c]).join(","),u=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a);if(a===1){this.userCode=` 12184 int start = ${o}; 12185 int end = ${i}; 12186 12187 void main() { 12188 int outC = getOutputCoords(); 12189 if (outC < start || outC >= end) { 12190 setOutput(value); 12191 } else { 12192 setOutput(getX(outC - start)); 12193 } 12194 } 12195 `;return}this.userCode=` 12196 ${s} start = ${s}(${o}); 12197 ${s} end = ${s}(${i}); 12198 12199 void main() { 12200 ${s} outC = getOutputCoords(); 12201 if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { 12202 setOutput(value); 12203 } else { 12204 ${s} coords = outC - start; 12205 setOutput(getX(${u})); 12206 } 12207 } 12208 `}}/** 12209 * @license 12210 * Copyright 2019 Google LLC. All Rights Reserved. 12211 * Licensed under the Apache License, Version 2.0 (the "License"); 12212 * you may not use this file except in compliance with the License. 12213 * You may obtain a copy of the License at 12214 * 12215 * http://www.apache.org/licenses/LICENSE-2.0 12216 * 12217 * Unless required by applicable law or agreed to in writing, software 12218 * distributed under the License is distributed on an "AS IS" BASIS, 12219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12220 * See the License for the specific language governing permissions and 12221 * limitations under the License. 12222 * ============================================================================= 12223 */class d7{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((y,b)=>y[0]+e[b]+y[1]);const a=e.length,s=Be(a),o=t.map(y=>y[0]).join(","),i=t.map((y,b)=>y[0]+e[b]).join(","),u=ft("rc",a),l=ft("source",a),c=`${u[a-1]} < ${this.outputShape[a-1]}`,p=a===1?"source":`vec2(${l.slice(-2).join()})`,h=[`${s} rc = outputLoc;`,`${u[a-1]} += 1; 12224 if(${c}) { 12225 `,a===1?"":`} 12226 rc = outputLoc; 12227 ${u[a-2]} += 1; 12228 if(${u[a-2]} < ${this.outputShape[a-2]}) {`,a===1?"":` ${u[a-1]} += 1; 12229 if(${c}) {`],d=a===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let m="";for(let y=0,b=a===1?2:4;y<b;y++)m+=` 12230 ${h[y]} 12231 if (${d}) { 12232 result[${y}] = float(value); 12233 } else { 12234 ${s} source = rc - start; 12235 result[${y}] = getChannel(getX(${l.join()}), ${p}); 12236 } 12237 `;m+=a===1?"} ":"}}",this.userCode=` 12238 const ${s} start = ${s}(${o}); 12239 const ${s} end = ${s}(${i}); 12240 12241 void main() { 12242 ${s} outputLoc = getOutputCoords(); 12243 vec4 result = vec4(0.); 12244 ${m} 12245 setOutput(result); 12246 } 12247 `}}/** 12248 * @license 12249 * Copyright 2020 Google LLC. All Rights Reserved. 12250 * Licensed under the Apache License, Version 2.0 (the "License"); 12251 * you may not use this file except in compliance with the License. 12252 * You may obtain a copy of the License at 12253 * 12254 * http://www.apache.org/licenses/LICENSE-2.0 12255 * 12256 * Unless required by applicable law or agreed to in writing, software 12257 * distributed under the License is distributed on an "AS IS" BASIS, 12258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12259 * See the License for the specific language governing permissions and 12260 * limitations under the License. 12261 * ============================================================================= 12262 */const Vm=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{paddings:s,constantValue:o}=r;if(ae(a.shape)===0){const l=s.map((c,p)=>c[0]+a.shape[p]+c[1]);return Ss({backend:t,attrs:{shape:l,value:o,dtype:a.dtype}})}const i=H().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new d7(a.shape,s,o):new h7(a.shape,s,o),u=[[o]];return t.runWebGLProgram(i,[a],a.dtype,u)},f7={kernelName:_h,backendName:"webgl",kernelFunc:Vm};/** 12263 * @license 12264 * Copyright 2020 Google LLC. All Rights Reserved. 12265 * Licensed under the Apache License, Version 2.0 (the "License"); 12266 * you may not use this file except in compliance with the License. 12267 * You may obtain a copy of the License at 12268 * 12269 * http://www.apache.org/licenses/LICENSE-2.0 12270 * 12271 * Unless required by applicable law or agreed to in writing, software 12272 * distributed under the License is distributed on an "AS IS" BASIS, 12273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12274 * See the License for the specific language governing permissions and 12275 * limitations under the License. 12276 * ============================================================================= 12277 */const m7=` 12278 if(a < 0.0 && floor(b) < b){ 12279 return NAN; 12280 } 12281 if (b == 0.0) { 12282 return 1.0; 12283 } 12284 return (round(mod(b, 2.0)) != 1) ?
12285 pow(abs(a), b) : sign(a) * pow(abs(a), b); 12286`,g7=` 12287 // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. 12288 vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); 12289 vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); 12290 vec4 result = multiplier * pow(abs(a), b); 12291 12292 // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS 12293 bvec4 isExpZero = equal(b, vec4(0.0)); 12294 result.r = isExpZero.r ? 1.0 : result.r; 12295 result.g = isExpZero.g ? 1.0 : result.g; 12296 result.b = isExpZero.b ? 1.0 : result.b; 12297 result.a = isExpZero.a ? 1.0 : result.a; 12298 12299 bvec4 isNaN1 = lessThan(a, vec4(0.0)); 12300 bvec4 isNaN2 = lessThan(floor(b), b); 12301 bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w); 12302 `+bs+` 12303 return result; 12304`,y7=ut({opSnippet:m7,packedOpSnippet:g7}),x7={kernelName:Ah,backendName:"webgl",kernelFunc:y7};/** 12305 * @license 12306 * Copyright 2020 Google LLC. All Rights Reserved. 12307 * Licensed under the Apache License, Version 2.0 (the "License"); 12308 * you may not use this file except in compliance with the License. 12309 * You may obtain a copy of the License at 12310 * 12311 * http://www.apache.org/licenses/LICENSE-2.0 12312 * 12313 * Unless required by applicable law or agreed to in writing, software 12314 * distributed under the License is distributed on an "AS IS" BASIS, 12315 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12316 * See the License for the specific language governing permissions and 12317 * limitations under the License. 12318 * ============================================================================= 12319 */function b7(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{axis:s,keepDims:o}=r,i=a.shape.length,u=[],l=rt(s,a.shape);let c=l;const p=Qt(c,i);let h=a;p!=null&&(h=yt({inputs:{x:a},backend:t,attrs:{perm:p}}),c=en(c.length,i),u.push(h)),hn("prod",c,i);let d;if(t.shouldExecuteOnCPU([h])){const m=t.texData.get(h.dataId).values,{outVals:y,outShape:b,outDtype:x}=Ek(h.shape,h.dtype,m,c);d=t.makeTensorInfo(b,x,y)}else{const[m,y]=kn(h.shape,c),b=ae(y),x=oe({inputs:{x:h},backend:t,attrs:{shape:[-1,b]}}),T=Ru(a.dtype),$=Wr(x,T,"prod",t);d=oe({inputs:{x:$},backend:t,attrs:{shape:m}}),u.push(x),u.push($)}if(o){u.push(d);const m=Bt(d.shape,l);d=oe({inputs:{x:d},backend:t,attrs:{shape:m}})}return u.forEach(m=>t.disposeIntermediateTensorInfo(m)),d}const v7={kernelName:Fh,backendName:"webgl",kernelFunc:b7};/** 12320 * @license 12321 * Copyright 2022 Google LLC. All Rights Reserved. 12322 * Licensed under the Apache License, Version 2.0 (the "License"); 12323 * you may not use this file except in compliance with the License. 12324 * You may obtain a copy of the License at 12325 * 12326 * http://www.apache.org/licenses/LICENSE-2.0 12327 * 12328 * Unless required by applicable law or agreed to in writing, software 12329 * distributed under the License is distributed on an "AS IS" BASIS, 12330 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12331 * See the License for the specific language governing permissions and 12332 * limitations under the License. 12333 * ============================================================================= 12334 */function w7(n){const{inputs:e,backend:t,attrs:r}=n,{paramsNestedSplits:a,paramsDenseValues:s,indices:o}=e,{outputRaggedRank:i}=r,u=a.map(x=>t.readSync(x.dataId)),l=a.map(x=>x.shape),c=t.readSync(s.dataId),p=t.readSync(o.dataId),[h,d,m]=Ck(u,l,c,s.shape,s.dtype,p,o.shape,i),y=h.map(x=>t.makeTensorInfo([x.length],"int32",x)),b=t.makeTensorInfo(m,s.dtype,d);return y.concat([b])}const S7={kernelName:Dh,backendName:"webgl",kernelFunc:w7};/** 12335 * @license 12336 * Copyright 2022 Google LLC. All Rights Reserved. 12337 * Licensed under the Apache License, Version 2.0 (the "License"); 12338 * you may not use this file except in compliance with the License. 12339 * You may obtain a copy of the License at 12340 * 12341 * http://www.apache.org/licenses/LICENSE-2.0 12342 * 12343 * Unless required by applicable law or agreed to in writing, software 12344 * distributed under the License is distributed on an "AS IS" BASIS, 12345 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12346 * See the License for the specific language governing permissions and 12347 * limitations under the License. 12348 * ============================================================================= 12349 */function k7(n){const{inputs:e,backend:t,attrs:r}=n,{shape:a,values:s,defaultValue:o,rowPartitionTensors:i}=e,{rowPartitionTypes:u}=r,l=t.readSync(a.dataId),c=t.readSync(s.dataId),p=t.readSync(o.dataId),h=i.map(b=>t.readSync(b.dataId)),d=i.map(b=>b.shape),[m,y]=Ik(l,a.shape,c,s.shape,s.dtype,p,o.shape,h,d,u);return t.makeTensorInfo(m,s.dtype,y)}const T7={kernelName:Mh,backendName:"webgl",kernelFunc:k7};/** 12350 * @license 12351 * Copyright 2020 Google LLC. All Rights Reserved. 12352 * Licensed under the Apache License, Version 2.0 (the "License");
12353 * you may not use this file except in compliance with the License. 12354 * You may obtain a copy of the License at 12355 * 12356 * http://www.apache.org/licenses/LICENSE-2.0 12357 * 12358 * Unless required by applicable law or agreed to in writing, software 12359 * distributed under the License is distributed on an "AS IS" BASIS, 12360 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12361 * See the License for the specific language governing permissions and 12362 * limitations under the License. 12363 * ============================================================================= 12364 */const Wm=n=>{const{backend:e,attrs:t}=n,{start:r,stop:a,step:s,dtype:o}=t,i=Nk(r,a,s,o);return e.makeTensorInfo([i.length],o,i)},E7={kernelName:Lh,backendName:"webgl",kernelFunc:Wm};/** 12365 * @license 12366 * Copyright 2020 Google LLC. All Rights Reserved. 12367 * Licensed under the Apache License, Version 2.0 (the "License"); 12368 * you may not use this file except in compliance with the License. 12369 * You may obtain a copy of the License at 12370 * 12371 * http://www.apache.org/licenses/LICENSE-2.0 12372 * 12373 * Unless required by applicable law or agreed to in writing, software 12374 * distributed under the License is distributed on an "AS IS" BASIS, 12375 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12376 * See the License for the specific language governing permissions and 12377 * limitations under the License. 12378 * ============================================================================= 12379 */const C7="return 1.0 / x;",I7=Ie({opSnippet:C7}),N7={kernelName:Bh,backendName:"webgl",kernelFunc:I7};/** 12380 * @license 12381 * Copyright 2020 Google LLC. All Rights Reserved. 12382 * Licensed under the Apache License, Version 2.0 (the "License"); 12383 * you may not use this file except in compliance with the License. 12384 * You may obtain a copy of the License at 12385 * 12386 * http://www.apache.org/licenses/LICENSE-2.0 12387 * 12388 * Unless required by applicable law or agreed to in writing, software 12389 * distributed under the License is distributed on an "AS IS" BASIS, 12390 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12391 * See the License for the specific language governing permissions and 12392 * limitations under the License. 12393 * ============================================================================= 12394 */const $7=tn+` 12395 return (x < 0.0) ? 0.0 : x; 12396`,R7=` 12397 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 12398 bvec4 isNaN = isnan(x); 12399 12400 result.r = isNaN.r ? x.r : result.r; 12401 result.g = isNaN.g ? x.g : result.g; 12402 result.b = isNaN.b ? x.b : result.b; 12403 result.a = isNaN.a ? x.a : result.a; 12404 12405 return result; 12406`,_7=Ie({opSnippet:$7,packedOpSnippet:R7}),A7={kernelName:Uh,backendName:"webgl",kernelFunc:_7};/** 12407 * @license 12408 * Copyright 2020 Google LLC. All Rights Reserved. 12409 * Licensed under the Apache License, Version 2.0 (the "License"); 12410 * you may not use this file except in compliance with the License. 12411 * You may obtain a copy of the License at 12412 * 12413 * http://www.apache.org/licenses/LICENSE-2.0 12414 * 12415 * Unless required by applicable law or agreed to in writing, software 12416 * distributed under the License is distributed on an "AS IS" BASIS, 12417 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12418 * See the License for the specific language governing permissions and 12419 * limitations under the License. 12420 * ============================================================================= 12421 */const O7=tn+` 12422 return (x < 0.0) ? 0.0 : min(6.0, x); 12423`,F7=` 12424 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 12425 bvec4 isNaN = isnan(x); 12426 12427 result.r = isNaN.r ? x.r : result.r; 12428 result.g = isNaN.g ? x.g : result.g; 12429 result.b = isNaN.b ? x.b : result.b; 12430 result.a = isNaN.a ? x.a : result.a; 12431 12432 return result; 12433`,D7=Ie({opSnippet:O7,packedOpSnippet:F7}),M7={kernelName:Gh,backendName:"webgl",kernelFunc:D7};/** 12434 * @license 12435 * Copyright 2017 Google LLC. All Rights Reserved. 12436 * Licensed under the Apache License, Version 2.0 (the "License"); 12437 * you may not use this file except in compliance with the License. 12438 * You may obtain a copy of the License at 12439 * 12440 * http://www.apache.org/licenses/LICENSE-2.0 12441 * 12442 * Unless required by applicable law or agreed to in writing, softw
12442are 12443 * distributed under the License is distributed on an "AS IS" BASIS, 12444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12445 * See the License for the specific language governing permissions and 12446 * limitations under the License. 12447 * ============================================================================= 12448 */class L7{constructor(e,t,r,a,s){this.variableNames=["A"],this.outputShape=[];const[o,i,u,l]=e;this.outputShape=[o,t,r,l];const c=[a&&t>1?i-1:i,a&&r>1?u-1:u],p=[a&&t>1?t-1:t,a&&r>1?r-1:r];let h;s?h="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":h="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 12449 const vec2 effectiveInputOverOutputRatioRC = vec2( 12450 ${c[0]/p[0]}, 12451 ${c[1]/p[1]}); 12452 const vec2 inputShapeRC = vec2(${i}.0, ${u}.0); 12453 12454 void main() { 12455 ivec4 coords = getOutputCoords(); 12456 int b = coords[0]; 12457 int d = coords[3]; 12458 ivec2 yRC = coords.yz; 12459 12460 // Fractional source index. 12461 vec2 sourceFracIndexRC = ${h}; 12462 12463 // Compute the four integer indices. 12464 ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0))); 12465 ivec2 sourceCeilRC = ivec2( 12466 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 12467 12468 float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d); 12469 float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d); 12470 float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d); 12471 float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d); 12472 12473 vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC); 12474 12475 float top = topLeft + (topRight - topLeft) * fracRC.y; 12476 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y; 12477 float newValue = top + (bottom - top) * fracRC.x; 12478 12479 setOutput(newValue); 12480 } 12481 `}}/** 12482 * @license 12483 * Copyright 2019 Google LLC. All Rights Reserved. 12484 * Licensed under the Apache License, Version 2.0 (the "License"); 12485 * you may not use this file except in compliance with the License. 12486 * You may obtain a copy of the License at 12487 * 12488 * http://www.apache.org/licenses/LICENSE-2.0 12489 * 12490 * Unless required by applicable law or agreed to in writing, software 12491 * distributed under the License is distributed on an "AS IS" BASIS, 12492 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12493 * See the License for the specific language governing permissions and 12494 * limitations under the License. 12495 * ============================================================================= 12496 */class P7{constructor(e,t,r,a,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,i,u,l]=e;this.outputShape=[o,t,r,l];const c=[a&&t>1?i-1:i,a&&r>1?u-1:u],p=[a&&t>1?t-1:t,a&&r>1?r-1:r];let h;s?h="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":h="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 12497 const vec3 effectiveInputOverOutputRatioRC = vec3( 12498 ${c[0]/p[0]}, 12499 ${c[1]/p[1]}, 12500 ${c[1]/p[1]}); 12501 const vec3 inputShapeRC = vec3(${i}.0, ${u}.0, 12502 ${u}.0); 12503 12504 float getAValue(int b, int r, int c, int d) { 12505 return getChannel(getA(b, r, c, d), vec2(c, d)); 12506 } 12507 12508 void main() { 12509 ivec4 coords = getOutputCoords(); 12510 int b = coords[0]; 12511 int d = coords[3]; 12512 // Calculate values for next column in yRC.z. 12513 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 12514 12515 // Fractional source index. 12516 vec3 sourceFracIndexRC = ${h}; 12517 12518 // Compute the four integer indices. 12519 ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0))); 12520 ivec3 sourceCeilRC = ivec3( 12521 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 12522 12523 // Should we calculate next column and row elements in 2x2 packed cell. 12524 bool hasNextCol = d < ${l-1}; 12525 bool hasNextRow = coords.z < ${r-1}
vendor: 2,018 bytes, lines 12525-12573
12525; 12526 12527 // In parallel, construct four corners for all four components in 12528 // packed 2x2 cell. 12529 vec4 topLeft = vec4( 12530 getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d), 12531 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1) 12532 : 0.0, 12533 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d) 12534 : 0.0, 12535 (hasNextRow && hasNextCol) ? 12536 getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0); 12537 12538 vec4 bottomLeft = vec4( 12539 getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d), 12540 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1) 12541 : 0.0, 12542 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d) 12543 : 0.0, 12544 (hasNextRow && hasNextCol) ? 12545 getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0); 12546 12547 vec4 topRight = vec4( 12548 getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d), 12549 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1) 12550 : 0.0, 12551 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d) 12552 : 0.0, 12553 (hasNextRow && hasNextCol) ? 12554 getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0); 12555 12556 vec4 bottomRight = vec4( 12557 getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d), 12558 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1) 12559 : 0.0, 12560 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d) 12561 : 0.0, 12562 (hasNextRow && hasNextCol) ? 12563 getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0); 12564 12565 vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC); 12566 12567 vec4 top = mix(topLeft, topRight, fracRC.yyzz); 12568 vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz); 12569 vec4 newValue = mix(top, bottom, fracRC.x); 12570 12571 setOutput(newValue); 12572 } 12573 `}
vendor: 4,806 bytes, lines 12573-12687
12573}/** 12574 * @license 12575 * Copyright 2020 Google LLC. All Rights Reserved. 12576 * Licensed under the Apache License, Version 2.0 (the "License"); 12577 * you may not use this file except in compliance with the License. 12578 * You may obtain a copy of the License at 12579 * 12580 * http://www.apache.org/licenses/LICENSE-2.0 12581 * 12582 * Unless required by applicable law or agreed to in writing, software 12583 * distributed under the License is distributed on an "AS IS" BASIS, 12584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12585 * See the License for the specific language governing permissions and 12586 * limitations under the License. 12587 * ============================================================================= 12588 */function B7(n){const{inputs:e,backend:t,attrs:r}=n,{images:a}=e,{alignCorners:s,halfPixelCenters:o,size:i}=r,[u,l]=i,c=H().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new P7(a.shape,u,l,s,o):new L7(a.shape,u,l,s,o);return t.runWebGLProgram(c,[a],"float32")}const U7={kernelName:zh,backendName:"webgl",kernelFunc:B7};/** 12589 * @license 12590 * Copyright 2018 Google LLC. All Rights Reserved. 12591 * Licensed under the Apache License, Version 2.0 (the "License"); 12592 * you may not use this file except in compliance with the License. 12593 * You may obtain a copy of the License at 12594 * 12595 * http://www.apache.org/licenses/LICENSE-2.0 12596 * 12597 * Unless required by applicable law or agreed to in writing, software 12598 * distributed under the License is distributed on an "AS IS" BASIS, 12599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12600 * See the License for the specific language governing permissions and 12601 * limitations under the License. 12602 * ============================================================================= 12603 */class V7{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,a,s]=t,[,o,i]=e,u=[r&&o>1?a-1:a,r&&i>1?s-1:s],l=[r&&o>1?o-1:o,r&&i>1?i-1:i],c=u[0]/l[0],p=u[1]/l[1],h=1/c,d=1/p,m=Math.ceil(h)*2+2,y=Math.ceil(d)*2+2;this.userCode=` 12604 void main() { 12605 ivec4 coords = getOutputCoords(); 12606 int b = coords[0]; 12607 int d = coords[3]; 12608 int r = coords[1]; 12609 int c = coords[2]; 12610 12611 float accumulator = 0.0; 12612 12613 const float heightScale = float(${c}); 12614 const float widthScale = float(${p}); 12615 12616 const float invHeightScale = float(${h}); 12617 const float invWidthScale = float(${d}); 12618 12619 const int winHeight = int(${m}); 12620 const int winWidth = int(${y}); 12621 12622 // Compute bounds for where in dy we will look 12623 float startRLerp = floor(float(r) * invHeightScale); 12624 int startDyR = int(startRLerp - float(winHeight / 2)); 12625 12626 float startCLerp = floor(float(c) * invWidthScale); 12627 int startDyC = int(startCLerp - float(winWidth / 2)); 12628 12629 // Loop over dy 12630 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 12631 int dyR = dyROffset + startDyR; 12632 12633 // Guard against the window exceeding the bounds of dy 12634 if (dyR < 0 || dyR >= ${o}) { 12635 continue; 12636 } 12637 12638 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 12639 int dyC = dyCOffset + startDyC; 12640 12641 // Guard against the window exceeding the bounds of dy 12642 if (dyC < 0 || dyC >= ${i}) { 12643 continue; 12644 } 12645 12646 float dxR = float(dyR) * heightScale; 12647 int topDxRIndex = int(floor(dxR)); 12648 int bottomDxRIndex = int(min(ceil(dxR), ${a-1}.0)); 12649 float dxRLerp = dxR - float(topDxRIndex); 12650 float inverseDxRLerp = 1.0 - dxRLerp; 12651 12652 float dxC = float(dyC) * widthScale; 12653 int leftDxCIndex = int(floor(dxC)); 12654 int rightDxCIndex = int(min(ceil(dxC), ${s-1}.0)); 12655 float dxCLerp = dxC - float(leftDxCIndex); 12656 float inverseDxCLerp = 1.0 - dxCLerp; 12657 12658 if (r == topDxRIndex && c == leftDxCIndex) { 12659 // topLeft 12660 accumulator += 12661 getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp; 12662 } 12663 12664 if (r == topDxRIndex && c == rightDxCIndex) { 12665 // topRight 12666 accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp; 12667 } 12668 12669 if (r == bottomDxRIndex && c == leftDxCIndex) { 12670 // bottomLeft 12671 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp; 12672 } 12673 12674 if (r == bottomDxRIndex && c == rightDxCIndex) { 12675 // bottomRight 12676 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp; 12677 } 12678 } 12679 } 12680 // End loop over dy 12681 12682 setOutput(accumulator); 12683 } 12684 `}}/** 12685 * @license 12686 * Copyright 2020 Google LLC. All Rights Reserved. 12687 * Licensed under the Apache License, Version 2.0 (the "License");
12688 * you may not use this file except in compliance with the License. 12689 * You may obtain a copy of the License at 12690 * 12691 * http://www.apache.org/licenses/LICENSE-2.0 12692 * 12693 * Unless required by applicable law or agreed to in writing, software 12694 * distributed under the License is distributed on an "AS IS" BASIS, 12695 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12696 * See the License for the specific language governing permissions and 12697 * limitations under the License. 12698 * ============================================================================= 12699 */function W7(n){const{inputs:e,backend:t,attrs:r}=n,{images:a,dy:s}=e,{alignCorners:o}=r,i=new V7(s.shape,a.shape,o);return t.runWebGLProgram(i,[s],s.dtype)}const z7={kernelName:L2,backendName:"webgl",kernelFunc:W7};/** 12700 * @license 12701 * Copyright 2018 Google LLC. All Rights Reserved. 12702 * Licensed under the Apache License, Version 2.0 (the "License"); 12703 * you may not use this file except in compliance with the License. 12704 * You may obtain a copy of the License at 12705 * 12706 * http://www.apache.org/licenses/LICENSE-2.0 12707 * 12708 * Unless required by applicable law or agreed to in writing, software 12709 * distributed under the License is distributed on an "AS IS" BASIS, 12710 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12711 * See the License for the specific language governing permissions and 12712 * limitations under the License. 12713 * ============================================================================= 12714 */class G7{constructor(e,t,r,a,s){this.variableNames=["A"],this.outputShape=[];const[o,i,u,l]=e;this.outputShape=[o,t,r,l];const c=[a&&t>1?i-1:i,a&&r>1?u-1:u],p=[a&&t>1?t-1:t,a&&r>1?r-1:r],h=a?"0.5":"0.0";let d;s?d="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 12715 const vec2 effectiveInputOverOutputRatioRC = vec2( 12716 ${c[0]/p[0]}, 12717 ${c[1]/p[1]}); 12718 const vec2 inputShapeRC = vec2(${i}.0, ${u}.0); 12719 12720 void main() { 12721 ivec4 coords = getOutputCoords(); 12722 int b = coords[0]; 12723 int d = coords[3]; 12724 ivec2 yRC = coords.yz; 12725 12726 // Fractional source index. 12727 vec2 sourceFracIndexRC = ${d}; 12728 12729 // Compute the coordinators of nearest neighbor point. 12730 ivec2 sourceNearestRC = ivec2( 12731 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${h}))); 12732 float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d); 12733 12734 setOutput(newValue); 12735 } 12736 `}}/** 12737 * @license 12738 * Copyright 2019 Google LLC. All Rights Reserved. 12739 * Licensed under the Apache License, Version 2.0 (the "License"); 12740 * you may not use this file except in compliance with the License. 12741 * You may obtain a copy of the License at 12742 * 12743 * http://www.apache.org/licenses/LICENSE-2.0 12744 * 12745 * Unless required by applicable law or agreed to in writing, software 12746 * distributed under the License is distributed on an "AS IS" BASIS, 12747 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12748 * See the License for the specific language governing permissions and 12749 * limitations under the License. 12750 * ============================================================================= 12751 */class j7{constructor(e,t,r,a,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,i,u,l]=e;this.outputShape=[o,t,r,l];const c=[a&&t>1?i-1:i,a&&r>1?u-1:u],p=[a&&t>1?t-1:t,a&&r>1?r-1:r],h=a?"0.5":"0.0";let d;s?d="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 12752 const vec3 effectiveInputOverOutputRatioRC = vec3( 12753 ${c[0]/p[0]}, 12754 ${c[1]/p[1]}, 12755 ${c[1]/p[1]}); 12756 const vec3 inputShapeRC = vec3(${i}.0, ${u}.0, 12757 ${u}.0); 12758 12759 float getAValue(int b, int r, int c, int d) { 12760 return getChannel(getA(b, r, c, d), vec2(c, d)); 12761 } 12762 12763 void main() { 12764 ivec4 coords = getOutputCoords(); 12765 int b = coords[0]; 12766 int d = coords[3]; 12767 // Calculate values for next column in yRC.z. 12768 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 12769 12770 // Fractional source index. 12771 vec3 sourceFracIndexRC = ${d}; 12772 12773 // Compute the coordinators of nearest neighbor point. 12774 ivec3 sourceNearestRC = ivec3( 12775 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${h}))); 12776 12777 // Should we calculate next column and row elements in 2x2 packed cell. 12778 bool hasNextCol = d < ${l-1}; 12779 bool hasNextRow = coords.z < ${r-1}; 12780 12781 vec4 newValue = vec4(
12782 getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d), 12783 hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1) 12784 : 0.0, 12785 hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d) 12786 : 0.0, 12787 (hasNextRow && hasNextCol) ? 12788 getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0); 12789 12790 setOutput(newValue); 12791 } 12792 `}}/** 12793 * @license 12794 * Copyright 2020 Google LLC. All Rights Reserved. 12795 * Licensed under the Apache License, Version 2.0 (the "License"); 12796 * you may not use this file except in compliance with the License. 12797 * You may obtain a copy of the License at 12798 * 12799 * http://www.apache.org/licenses/LICENSE-2.0 12800 * 12801 * Unless required by applicable law or agreed to in writing, software 12802 * distributed under the License is distributed on an "AS IS" BASIS, 12803 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12804 * See the License for the specific language governing permissions and 12805 * limitations under the License. 12806 * ============================================================================= 12807 */function H7(n){const{inputs:e,backend:t,attrs:r}=n,{images:a}=e,{alignCorners:s,halfPixelCenters:o,size:i}=r,[u,l]=i,c=H().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new j7(a.shape,u,l,s,o):new G7(a.shape,u,l,s,o);return t.runWebGLProgram(c,[a],a.dtype)}const X7={kernelName:Wh,backendName:"webgl",kernelFunc:H7};/** 12808 * @license 12809 * Copyright 2018 Google LLC. All Rights Reserved. 12810 * Licensed under the Apache License, Version 2.0 (the "License"); 12811 * you may not use this file except in compliance with the License. 12812 * You may obtain a copy of the License at 12813 * 12814 * http://www.apache.org/licenses/LICENSE-2.0 12815 * 12816 * Unless required by applicable law or agreed to in writing, software 12817 * distributed under the License is distributed on an "AS IS" BASIS, 12818 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12819 * See the License for the specific language governing permissions and 12820 * limitations under the License. 12821 * ============================================================================= 12822 */class q7{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,a,s]=t,[,o,i]=e,u=[r&&o>1?a-1:a,r&&i>1?s-1:s],l=[r&&o>1?o-1:o,r&&i>1?i-1:i],c=u[0]/l[0],p=u[1]/l[1],h=1/c,d=1/p,m=Math.ceil(h)*2+2,y=Math.ceil(d)*2+2;this.userCode=` 12823 void main() { 12824 ivec4 coords = getOutputCoords(); 12825 int b = coords[0]; 12826 int d = coords[3]; 12827 int r = coords[1]; 12828 int c = coords[2]; 12829 12830 float accumulator = 0.0; 12831 12832 const float heightScale = float(${c}); 12833 const float widthScale = float(${p}); 12834 12835 const float invHeightScale = float(${h}); 12836 const float invWidthScale = float(${d}); 12837 12838 const int winHeight = int(${m}); 12839 const int winWidth = int(${y}); 12840 12841 // Compute bounds for where in dy we will look 12842 float startRLerp = floor(float(r) * invHeightScale); 12843 int startDyR = int(floor(startRLerp - float(winHeight / 2))); 12844 12845 float startCLerp = floor(float(c) * invWidthScale); 12846 int startDyC = int(floor(startCLerp - float(winWidth / 2))); 12847 12848 // Loop over dy 12849 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 12850 int dyR = dyROffset + startDyR; 12851 12852 // Guard against the window exceeding the bounds of dy 12853 if (dyR < 0 || dyR >= ${o}) { 12854 continue; 12855 } 12856 12857 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 12858 int dyC = dyCOffset + startDyC; 12859 12860 // Guard against the window exceeding the bounds of dy 12861 if (dyC < 0 || dyC >= ${i}) { 12862 continue; 12863 } 12864 12865 float sourceFracRow = 12866 float(${u[0]}) * 12867 (float(dyR) / float(${l[0]})); 12868 12869 float sourceFracCol = 12870 float(${u[1]}) * 12871 (float(dyC) / float(${l[1]})); 12872 12873 int sourceNearestRow = int(min( 12874 float(int(${a}) - 1), 12875 ${r} ? float(round(sourceFracRow)) : 12876 float(floor(sourceFracRow)))); 12877 12878 int sourceNearestCol = int(min( 12879 float(int(${s}) - 1), 12880 ${r} ? float(round(sourceFracCol)) : 12881 float(floor(sourceFracCol)))); 12882 12883 if (r == sourceNearestRow && c == sourceNearestCol) { 12884 accumulator += getDy(b, dyR, dyC, d); 12885 } 12886 } 12887 } 12888 // End loop over dy 12889 12890 setOutput(accumulator); 12891 } 12892 `}}/** 12893 * @license 12894 * Copyright 2020 Google LLC. All Rights Reserved. 12895 * Licensed under the Apache License, Version 2.0 (the "License");
12896 * you may not use this file except in compliance with the License. 12897 * You may obtain a copy of the License at 12898 * 12899 * http://www.apache.org/licenses/LICENSE-2.0 12900 * 12901 * Unless required by applicable law or agreed to in writing, software 12902 * distributed under the License is distributed on an "AS IS" BASIS, 12903 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12904 * See the License for the specific language governing permissions and 12905 * limitations under the License. 12906 * ============================================================================= 12907 */function K7(n){const{inputs:e,backend:t,attrs:r}=n,{images:a,dy:s}=e,{alignCorners:o}=r,i=new q7(s.shape,a.shape,o);return t.runWebGLProgram(i,[s],s.dtype)}const Y7={kernelName:M2,backendName:"webgl",kernelFunc:K7};/** 12908 * @license 12909 * Copyright 2017 Google LLC. All Rights Reserved. 12910 * Licensed under the Apache License, Version 2.0 (the "License"); 12911 * you may not use this file except in compliance with the License. 12912 * You may obtain a copy of the License at 12913 * 12914 * http://www.apache.org/licenses/LICENSE-2.0 12915 * 12916 * Unless required by applicable law or agreed to in writing, software 12917 * distributed under the License is distributed on an "AS IS" BASIS, 12918 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12919 * See the License for the specific language governing permissions and 12920 * limitations under the License. 12921 * ============================================================================= 12922 */class Z7{constructor(e,t){this.variableNames=["x"];const r=e.length;if(r>4)throw new Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);if(this.outputShape=e,r===1){this.userCode=` 12923 void main() { 12924 int coord = getOutputCoords(); 12925 setOutput(getX(${e[0]} - coord - 1)); 12926 } 12927 `;return}const a=i=>t.indexOf(i)!==-1&&e[i]!==1?`${e[i]} - coords[${i}] - 1`:`coords[${i}]`,s=e.map((i,u)=>a(u)).join(","),o=Be(r);this.userCode=` 12928 void main() { 12929 ${o} coords = getOutputCoords(); 12930 setOutput(getX(${s})); 12931 } 12932 `}}/** 12933 * @license 12934 * Copyright 2019 Google LLC. All Rights Reserved. 12935 * Licensed under the Apache License, Version 2.0 (the "License"); 12936 * you may not use this file except in compliance with the License. 12937 * You may obtain a copy of the License at 12938 * 12939 * http://www.apache.org/licenses/LICENSE-2.0 12940 * 12941 * Unless required by applicable law or agreed to in writing, software 12942 * distributed under the License is distributed on an "AS IS" BASIS, 12943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12944 * See the License for the specific language governing permissions and 12945 * limitations under the License. 12946 * ============================================================================= 12947 */class J7{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const r=e.length;if(r>4)throw new Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);this.outputShape=e;const a=ft("rc",r),s=`${a[r-1]} + 1 < ${this.outputShape[r-1]}`,o=`${a[r-2]} + 1 < ${this.outputShape[r-2]}`,i=Be(r);r===1?this.userCode=` 12948 void main(){ 12949 int rc = getOutputCoords(); 12950 vec4 result = vec4(0.); 12951 result.r = getChannel(getX(${e[0]} - rc - 1), 12952 ${e[0]} - rc - 1); 12953 if(${s}){ 12954 result.g = getChannel(getX(${e[0]} - (rc + 1) - 1), 12955 ${e[0]} - (rc + 1) - 1); 12956 } 12957 setOutput(result); 12958 } 12959 `:this.userCode=` 12960 void main() { 12961 ${i} rc = getOutputCoords(); 12962 vec4 result = vec4(0.); 12963 result.r = ${u(a.slice())}; 12964 if(${s}){ 12965 result.g = ${l(a.slice())}; 12966 } 12967 if(${o}) { 12968 result.b = ${c(a.slice())}; 12969 if(${s}) { 12970 result.a = ${p(a.slice())}; 12971 } 12972 } 12973 setOutput(result); 12974 } 12975 `;function u(m){return h(m)}function l(m){return m[r-1]="("+m[r-1]+" + 1)",h(m)}function c(m){return m[r-2]="("+m[r-2]+" + 1)",h(m)}function p(m){return m[r-1]="("+m[r-1]+" + 1)",m[r-2]="("+m[r-2]+" + 1)",h(m)}function h(m){const y=e.map((T,$)=>d($,m)),b=y.join(","),x=y.slice(-2).join(",");return`getChannel(getX(${b}), vec2(${x}))`}function d(m,y){return t.indexOf(m)!==-1&&e[m]!==1?`${e[m]} - ${y[m]} - 1`:`${y[m]}`}}}/** 12976 * @license 12977 * Copyright 2020 Google LLC. All Rights Reserved. 12978 * Licensed under the Apache License, Version 2.0 (the "License");
12979 * you may not use this file except in compliance with the License. 12980 * You may obtain a copy of the License at 12981 * 12982 * http://www.apache.org/licenses/LICENSE-2.0 12983 * 12984 * Unless required by applicable law or agreed to in writing, software 12985 * distributed under the License is distributed on an "AS IS" BASIS, 12986 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12987 * See the License for the specific language governing permissions and 12988 * limitations under the License. 12989 * ============================================================================= 12990 */function Q7(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{dims:s}=r,o=a.shape.length,i=rt(s,a.shape);if(o===0)return Rt({inputs:{x:a},backend:t});const u=H().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new J7(a.shape,i):new Z7(a.shape,i);return t.runWebGLProgram(u,[a],a.dtype)}const e8={kernelName:jh,backendName:"webgl",kernelFunc:Q7};/** 12991 * @license 12992 * Copyright 2020 Google LLC. All Rights Reserved. 12993 * Licensed under the Apache License, Version 2.0 (the "License"); 12994 * you may not use this file except in compliance with the License. 12995 * You may obtain a copy of the License at 12996 * 12997 * http://www.apache.org/licenses/LICENSE-2.0 12998 * 12999 * Unless required by applicable law or agreed to in writing, software 13000 * distributed under the License is distributed on an "AS IS" BASIS, 13001 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13002 * See the License for the specific language governing permissions and 13003 * limitations under the License. 13004 * ============================================================================= 13005 */class t8{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const r=e[1],a=e[2];this.outputShape=e;let s="";typeof t=="number"?s=`float outputValue = ${t.toFixed(2)};`:s=` 13006 vec3 fill = vec3(${t.join(",")}); 13007 float outputValue = fill[coords[3]];`,this.userCode=` 13008 void main() { 13009 ivec4 coords = getOutputCoords(); 13010 int x = coords[2]; 13011 int y = coords[1]; 13012 float coordXFloat = (float(x) - params[0]) * params[3] - 13013 (float(y) - params[1]) * params[2]; 13014 float coordYFloat = (float(x) - params[0]) * params[2] + 13015 (float(y) - params[1]) * params[3];
13016 int coordX = int(round(coordXFloat + params[0])); 13017 int coordY = int(round(coordYFloat + params[1])); 13018 ${s} 13019 if(coordX >= 0 && coordX < ${a} && coordY >= 0 && coordY < ${r}) { 13020 outputValue = getImage(coords[0], coordY, coordX, coords[3]); 13021 } 13022 setOutput(outputValue); 13023 } 13024 `}}/** 13025 * @license 13026 * Copyright 2020 Google LLC. All Rights Reserved. 13027 * Licensed under the Apache License, Version 2.0 (the "License"); 13028 * you may not use this file except in compliance with the License. 13029 * You may obtain a copy of the License at 13030 * 13031 * http://www.apache.org/licenses/LICENSE-2.0 13032 * 13033 * Unless required by applicable law or agreed to in writing, software 13034 * distributed under the License is distributed on an "AS IS" BASIS, 13035 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13036 * See the License for the specific language governing permissions and 13037 * limitations under the License. 13038 * ============================================================================= 13039 */const n8={kernelName:$d,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:r}
vendor: 4,119 bytes, lines 13039-13128
13039=n,{radians:a,fillValue:s,center:o}=e,i=t,u=new t8(r.shape,s),[l,c]=b1(o,r.shape[1],r.shape[2]),p=[[l,c,Math.sin(a),Math.cos(a)]];return i.runWebGLProgram(u,[r],r.dtype,p)}};/** 13040 * @license 13041 * Copyright 2020 Google LLC. All Rights Reserved. 13042 * Licensed under the Apache License, Version 2.0 (the "License"); 13043 * you may not use this file except in compliance with the License. 13044 * You may obtain a copy of the License at 13045 * 13046 * http://www.apache.org/licenses/LICENSE-2.0 13047 * 13048 * Unless required by applicable law or agreed to in writing, software 13049 * distributed under the License is distributed on an "AS IS" BASIS, 13050 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13051 * See the License for the specific language governing permissions and 13052 * limitations under the License. 13053 * ============================================================================= 13054 */const r8=` 13055 // OpenGL ES does not support round function. 13056 // The algorithm is based on banker's rounding. 13057 float base = floor(x); 13058 if ((x - base) < 0.5) { 13059 return floor(x); 13060 } else if ((x - base) > 0.5) { 13061 return ceil(x); 13062 } else { 13063 if (mod(base, 2.0) == 0.0) { 13064 return base; 13065 } else { 13066 return base + 1.0; 13067 } 13068 } 13069`,a8=Ie({opSnippet:r8}),s8={kernelName:Hh,backendName:"webgl",kernelFunc:a8};/** 13070 * @license 13071 * Copyright 2020 Google LLC. All Rights Reserved. 13072 * Licensed under the Apache License, Version 2.0 (the "License"); 13073 * you may not use this file except in compliance with the License. 13074 * You may obtain a copy of the License at 13075 * 13076 * http://www.apache.org/licenses/LICENSE-2.0 13077 * 13078 * Unless required by applicable law or agreed to in writing, software 13079 * distributed under the License is distributed on an "AS IS" BASIS, 13080 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13081 * See the License for the specific language governing permissions and 13082 * limitations under the License. 13083 * ============================================================================= 13084 */const o8="return inversesqrt(x);",i8=Ie({opSnippet:o8,cpuKernelImpl:$k}),u8={kernelName:Xh,backendName:"webgl",kernelFunc:i8};/** 13085 * @license 13086 * Copyright 2018 Google LLC. All Rights Reserved. 13087 * Licensed under the Apache License, Version 2.0 (the "License"); 13088 * you may not use this file except in compliance with the License. 13089 * You may obtain a copy of the License at 13090 * 13091 * http://www.apache.org/licenses/LICENSE-2.0 13092 * 13093 * Unless required by applicable law or agreed to in writing, software 13094 * distributed under the License is distributed on an "AS IS" BASIS, 13095 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13096 * See the License for the specific language governing permissions and 13097 * limitations under the License. 13098 * ============================================================================= 13099 */class zm{constructor(e,t,r,a,s,o,i=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;const u=Be(s.length),l=Be(o.length);let c="";r===1?c="i":r===2&&(c="i, j");const p=`getIndices(${c})`;let h="";a===1?h="i":a===2&&(h="i, coords[1]");const d=`getUpdates(${h})`,m=t>1?"strides[j]":"strides";this.userCode=` 13100 ${u} strides = ${u}(${s}); 13101 13102 void main() { 13103 ${l} coords = getOutputCoords(); 13104 float sum = 0.0; 13105 bool found = false; 13106 for (int i = 0; i < ${e}; i++) { 13107 int flattenedIndex = 0; 13108 for (int j = 0; j < ${t}; j++) { 13109 int index = round(${p}); 13110 flattenedIndex += index * ${m}; 13111 } 13112 if (flattenedIndex == coords[0]) { 13113 sum += ${d}; 13114 found = true; 13115 } 13116 } 13117 setOutput(mix(getDefaultValue(), sum, float(found))); 13118 } 13119 `}}/** 13120 * @license 13121 * Copyright 2020 Google LLC. All Rights Reserved. 13122 * Licensed under the Apache License, Version 2.0 (the "License"); 13123 * you may not use this file except in compliance with the License. 13124 * You may obtain a copy of the License at 13125 * 13126 * http://www.apache.org/licenses/LICENSE-2.0 13127 * 13128 * Unless required by applicable law or agreed to in writing, softw
13128are 13129 * distributed under the License is distributed on an "AS IS" BASIS, 13130 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13131 * See the License for the specific language governing permissions and 13132 * limitations under the License. 13133 * ============================================================================= 13134 */function l8(n){const{inputs:e,backend:t,attrs:r}=n,{indices:a,updates:s}=e,{shape:o}=r,{sliceRank:i,numUpdates:u,sliceSize:l,strides:c,outputSize:p}=Mu(s,a,o),h=[p/l,l];if(p===0)return t.makeTensorInfo(o,a.dtype);const d=oe({inputs:{x:a},backend:t,attrs:{shape:[u,i]}}),m=oe({inputs:{x:s},backend:t,attrs:{shape:[u,l]}}),y=t.makeTensorInfo([],"float32",new Float32Array([0])),b=new zm(u,i,d.shape.length,m.shape.length,c,h),x=t.runWebGLProgram(b,[m,d,y],m.dtype),T=oe({inputs:{x},backend:t,attrs:{shape:o}});return t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(x),t.disposeIntermediateTensorInfo(y),T}const c8={kernelName:qh,backendName:"webgl",kernelFunc:l8};/** 13135 * @license 13136 * Copyright 2022 Google LLC. All Rights Reserved. 13137 * Licensed under the Apache License, Version 2.0 (the "License"); 13138 * you may not use this file except in compliance with the License. 13139 * You may obtain a copy of the License at 13140 * 13141 * http://www.apache.org/licenses/LICENSE-2.0 13142 * 13143 * Unless required by applicable law or agreed to in writing, software 13144 * distributed under the License is distributed on an "AS IS" BASIS, 13145 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13146 * See the License for the specific language governing permissions and 13147 * limitations under the License. 13148 * ============================================================================= 13149 */class p8{constructor(e,t,r,a){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,r];const s="while (left < right) {",o=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=H().getNumber("WEBGL_VERSION")===2?s:o,u=a==="left"?"<":"<=";this.userCode=` 13150 int findBound(int batch, float value) { 13151 int left = 0; 13152 int right = numInputs; 13153 int mid; 13154 ${i} 13155 mid = (left + right) / 2; 13156 if (getSortedSequence(batch, mid) ${u} value) { 13157 left = mid + 1; 13158 } else { 13159 right = mid; 13160 } 13161 } 13162 return right; 13163 } 13164 13165 void main() { 13166 ivec2 coords = getOutputCoords(); 13167 int batch = coords[0]; 13168 int valueIndex = coords[1]; 13169 13170 float value = getValues(batch, valueIndex); 13171 13172 setOutput(float(findBound(batch, value))); 13173 } 13174 `}}/** 13175 * @license 13176 * Copyright 2022 Google LLC. All Rights Reserved. 13177 * Licensed under the Apache License, Version 2.0 (the "License"); 13178 * you may not use this file except in compliance with the License. 13179 * You may obtain a copy of the License at 13180 * 13181 * http://www.apache.org/licenses/LICENSE-2.0 13182 * 13183 * Unless required by applicable law or agreed to in writing, software 13184 * distributed under the License is distributed on an "AS IS" BASIS, 13185 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13186 * See the License for the specific language governing permissions and 13187 * limitations under the License. 13188 * ============================================================================= 13189 */function h8(n){const{inputs:e,backend:t,attrs:r}=n,{sortedSequence:a,values:s}=e,{side:o}=r,i=new p8(a.shape[0],a.shape[1],s.shape[1],o),u=[[a.shape[1]]];return t.runWebGLProgram(i,[a,s],"int32",u)}const d8={kernelName:Kh,backendName:"webgl",kernelFunc:h8};/** 13190 * @license 13191 * Copyright 2017 Google LLC. All Rights Reserved. 13192 * Licensed under the Apache License, Version 2.0 (the "License"); 13193 * you may not use this file except in compliance with the License. 13194 * You may obtain a copy of the License at 13195 * 13196 * http://www.apache.org/licenses/LICENSE-2.0 13197 * 13198 * Unless required by applicable law or agreed to in writing, software 13199 * distributed under the License is distributed on an "AS IS" BASIS, 13200 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13201 * See the License for the specific language governing permissions and 13202 * limitations under the License. 13203 * ============================================================================= 13204 */class f8{constructor(e,t,r){this.variableNames=["c","a","b"],this.outputShape=t;let a,s;if(r>4)throw Error(`Where for rank ${r} is not yet supported`);if(r===1)s="resRC",a="resRC";else{const i=["resRC.x","resRC.y","resRC.z","resRC.w"],u=[],l=[];for(let c=0;c<t.length;
vendor: 4,368 bytes, lines 13204-13298
13204c++)l.push(`${i[c]}`),c<e&&u.push(`${i[c]}`);a=u.join(),s=l.join()}const o=Be(r);this.userCode=` 13205 void main() { 13206 ${o} resRC = getOutputCoords(); 13207 float cVal = getC(${a}); 13208 if (cVal >= 1.0) { 13209 setOutput(getA(${s})); 13210 } else { 13211 setOutput(getB(${s})); 13212 } 13213 } 13214 `}}/** 13215 * @license 13216 * Copyright 2020 Google LLC. All Rights Reserved. 13217 * Licensed under the Apache License, Version 2.0 (the "License"); 13218 * you may not use this file except in compliance with the License. 13219 * You may obtain a copy of the License at 13220 * 13221 * http://www.apache.org/licenses/LICENSE-2.0 13222 * 13223 * Unless required by applicable law or agreed to in writing, software 13224 * distributed under the License is distributed on an "AS IS" BASIS, 13225 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13226 * See the License for the specific language governing permissions and 13227 * limitations under the License. 13228 * ============================================================================= 13229 */function m8(n){const{inputs:e,backend:t}=n,{condition:r,t:a,e:s}=e,o=new f8(r.shape.length,a.shape,a.shape.length);return t.runWebGLProgram(o,[r,a,s],Sn(a.dtype,s.dtype))}const g8={kernelName:Yh,backendName:"webgl",kernelFunc:m8};/** 13230 * @license 13231 * Copyright 2020 Google LLC. All Rights Reserved. 13232 * Licensed under the Apache License, Version 2.0 (the "License"); 13233 * you may not use this file except in compliance with the License. 13234 * You may obtain a copy of the License at 13235 * 13236 * http://www.apache.org/licenses/LICENSE-2.0 13237 * 13238 * Unless required by applicable law or agreed to in writing, software 13239 * distributed under the License is distributed on an "AS IS" BASIS, 13240 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13241 * See the License for the specific language governing permissions and 13242 * limitations under the License. 13243 * ============================================================================= 13244 */const y8=` 13245 // Stable and Attracting Fixed Point (0, 1) for Normalized Weights. 13246 // see: https://arxiv.org/abs/1706.02515 13247 float scaleAlpha = ${S1}; 13248 float scale = ${k1}; 13249 return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); 13250`,x8=Ie({opSnippet:y8}),b8={kernelName:Zh,backendName:"webgl",kernelFunc:x8};/** 13251 * @license 13252 * Copyright 2020 Google LLC. All Rights Reserved. 13253 * Licensed under the Apache License, Version 2.0 (the "License"); 13254 * you may not use this file except in compliance with the License. 13255 * You may obtain a copy of the License at 13256 * 13257 * http://www.apache.org/licenses/LICENSE-2.0 13258 * 13259 * Unless required by applicable law or agreed to in writing, software 13260 * distributed under the License is distributed on an "AS IS" BASIS, 13261 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13262 * See the License for the specific language governing permissions and 13263 * limitations under the License. 13264 * ============================================================================= 13265 */const v8=Ca+` 13266 return 1.0 / (1.0 + exp(-1.0 * x)); 13267`,w8=` 13268 vec4 result = 1.0 / (1.0 + exp(-1.0 * x)); 13269 bvec4 isNaN = isnan(x); 13270 13271 result.r = isNaN.r ? x.r : result.r; 13272 result.g = isNaN.g ? x.g : result.g; 13273 result.b = isNaN.b ? x.b : result.b; 13274 result.a = isNaN.a ? x.a : result.a; 13275 13276 return result; 13277`,S8=Ie({opSnippet:v8,packedOpSnippet:w8,cpuKernelImpl:_k}),k8={kernelName:nd,backendName:"webgl",kernelFunc:S8};/** 13278 * @license 13279 * Copyright 2020 Google LLC. All Rights Reserved. 13280 * Licensed under the Apache License, Version 2.0 (the "License"); 13281 * you may not use this file except in compliance with the License. 13282 * You may obtain a copy of the License at 13283 * 13284 * http://www.apache.org/licenses/LICENSE-2.0 13285 * 13286 * Unless required by applicable law or agreed to in writing, software 13287 * distributed under the License is distributed on an "AS IS" BASIS, 13288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13289 * See the License for the specific language governing permissions and 13290 * limitations under the License. 13291 * ============================================================================= 13292 */const T8=` 13293 if (isnan(x)) { return 0.0; } 13294 return sign(x); 13295`,E8=Ie({opSnippet:T8}),C8={kernelName:td,backendName:"webgl",kernelFunc:E8};/** 13296 * @license 13297 * Copyright 2020 Google LLC. All Rights Reserved. 13298 * Licensed under the Apache License, Version 2.0 (the "License");
13299 * you may not use this file except in compliance with the License. 13300 * You may obtain a copy of the License at 13301 * 13302 * http://www.apache.org/licenses/LICENSE-2.0 13303 * 13304 * Unless required by applicable law or agreed to in writing, software 13305 * distributed under the License is distributed on an "AS IS" BASIS, 13306 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13307 * See the License for the specific language governing permissions and 13308 * limitations under the License. 13309 * ============================================================================= 13310 */const I8=Ca+` 13311 return sin(x); 13312`,N8=Ie({opSnippet:I8}),$8={kernelName:Qh,backendName:"webgl",kernelFunc:N8};/** 13313 * @license 13314 * Copyright 2020 Google LLC. All Rights Reserved. 13315 * Licensed under the Apache License, Version 2.0 (the "License"); 13316 * you may not use this file except in compliance with the License. 13317 * You may obtain a copy of the License at 13318 * 13319 * http://www.apache.org/licenses/LICENSE-2.0 13320 * 13321 * Unless required by applicable law or agreed to in writing, software 13322 * distributed under the License is distributed on an "AS IS" BASIS, 13323 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13324 * See the License for the specific language governing permissions and 13325 * limitations under the License. 13326 * ============================================================================= 13327 */const R8=` 13328 float e2x = exp(x); 13329 return (e2x - 1.0 / e2x) / 2.0; 13330`,_8=Ie({opSnippet:R8}),A8={kernelName:ed,backendName:"webgl",kernelFunc:_8};/** 13331 * @license 13332 * Copyright 2020 Google LLC. All Rights Reserved. 13333 * Licensed under the Apache License, Version 2.0 (the "License"); 13334 * you may not use this file except in compliance with the License. 13335 * You may obtain a copy of the License at 13336 * 13337 * http://www.apache.org/licenses/LICENSE-2.0 13338 * 13339 * Unless required by applicable law or agreed to in writing, software 13340 * distributed under the License is distributed on an "AS IS" BASIS, 13341 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13342 * See the License for the specific language governing permissions and 13343 * limitations under the License. 13344 * ============================================================================= 13345 */const O8=` 13346 float epsilon = 1.1920928955078125e-7; 13347 float threshold = log(epsilon) + 2.0; 13348 13349 bool too_large = x > -threshold; 13350 bool too_small = x < threshold; 13351 13352 float result; 13353 float exp_x = exp(x); 13354 13355 if (too_large){ 13356 result = x; 13357 } 13358 else if (too_small){ 13359 result = exp_x; 13360 } 13361 else{ 13362 result = log(exp_x + 1.0); 13363 } 13364 return result; 13365`,F8=Ie({opSnippet:O8}),D8={kernelName:rd,backendName:"webgl",kernelFunc:F8};/** 13366 * @license 13367 * Copyright 2020 Google LLC. All Rights Reserved. 13368 * Licensed under the Apache License, Version 2.0 (the "License"); 13369 * you may not use this file except in compliance with the License. 13370 * You may obtain a copy of the License at 13371 * 13372 * http://www.apache.org/licenses/LICENSE-2.0 13373 * 13374 * Unless required by applicable law or agreed to in writing, software 13375 * distributed under the License is distributed on an "AS IS" BASIS, 13376 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13377 * See the License for the specific language governing permissions and 13378 * limitations under the License. 13379 * ============================================================================= 13380 */const M8=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{blockShape:s,paddings:o}=r;R(a.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const i=s.reduce((x,T)=>x*T),u=[[0,0]];u.push(...o);for(let x=1+s.length;x<a.shape.length;++x)u.push([0,0]);const l=[],c=Vm({inputs:{x:a},backend:t,attrs:{paddings:u,constantValue:0}}),p=el(c.shape,s,i,!1),h=tl(p.length,s.length,!1),d=nl(c.shape,s,i,!1),m=oe({inputs:{x:c},backend:t,attrs:{shape:p}}),y=yt({inputs:{x:m},backend:t,attrs:{perm:h}}),b=oe({inputs:{x:y},backend:t,attrs:{shape:d}});return l.push(c),l.push(m),l.push(y),l.forEach(x=>t.disposeIntermediateTensorInfo(x)),b},L8={kernelName:od,backendName:"webgl",kernelFunc:M8};/** 13381 * @license 13382 * Copyright 2021 Google LLC. All Rights Reserved. 13383 * Licensed under the Apache License, Version 2.0 (the "License");
13384 * you may not use this file except in compliance with the License. 13385 * You may obtain a copy of the License at 13386 * 13387 * http://www.apache.org/licenses/LICENSE-2.0 13388 * 13389 * Unless required by applicable law or agreed to in writing, software 13390 * distributed under the License is distributed on an "AS IS" BASIS, 13391 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13392 * See the License for the specific language governing permissions and 13393 * limitations under the License. 13394 * ============================================================================= 13395 */function P8(n){const{inputs:e,backend:t}=n,{indices:r,values:a,denseShape:s,defaultValue:o}=e;if(s.shape.length!==1)throw new Error(`Dense shape must be a vector, saw: 13396 ${s.shape}`);if(r.shape.length!==2)throw new Error(`Indices must be a matrix, saw: 13397 ${r.shape}`);if(a.shape.length!==1)throw new Error(`Values must be a vector, saw: 13398 ${a.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw: 13399 ${o.shape}`);const i=t.readSync(r.dataId),u=t.readSync(a.dataId),l=t.readSync(s.dataId),c=t.readSync(o.dataId)[0],[p,h,d,m,y]=Ok(i,r.shape,r.dtype,u,a.dtype,l,c);return[t.makeTensorInfo(h,r.dtype,p),t.makeTensorInfo([h[0]],a.dtype,d),t.makeTensorInfo([m.length],"bool",new Uint8Array(m.map(b=>Number(b)))),t.makeTensorInfo([y.length],r.dtype,new Int32Array(y))]}const B8={kernelName:ld,backendName:"webgl",kernelFunc:P8};/** 13400 * @license 13401 * Copyright 2021 Google LLC. All Rights Reserved. 13402 * Licensed under the Apache License, Version 2.0 (the "License"); 13403 * you may not use this file except in compliance with the License. 13404 * You may obtain a copy of the License at 13405 * 13406 * http://www.apache.org/licenses/LICENSE-2.0 13407 * 13408 * Unless required by applicable law or agreed to in writing, software 13409 * distributed under the License is distributed on an "AS IS" BASIS, 13410 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13411 * See the License for the specific language governing permissions and 13412 * limitations under the License. 13413 * ============================================================================= 13414 */function U8(n){const{inputs:e,backend:t}=n,{inputIndices:r,inputShape:a,newShape:s}=e;if(r.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(a.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${a.shape}`);if(s.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${s.shape}`);const o=Array.from(t.readSync(a.dataId)),i=t.readSync(r.dataId),u=Array.from(t.readSync(s.dataId)),[l,c,p]=Fk(i,r.shape,r.dtype,o,u);return[t.makeTensorInfo(c,r.dtype,l),t.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}const V8={kernelName:cd,backendName:"webgl",kernelFunc:U8};/** 13415 * @license 13416 * Copyright 2021 Google LLC. All Rights Reserved. 13417 * Licensed under the Apache License, Version 2.0 (the "License"); 13418 * you may not use this file except in compliance with the License. 13419 * You may obtain a copy of the License at 13420 * 13421 * http://www.apache.org/licenses/LICENSE-2.0 13422 * 13423 * Unless required by applicable law or agreed to in writing, software 13424 * distributed under the License is distributed on an "AS IS" BASIS, 13425 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13426 * See the License for the specific language governing permissions and 13427 * limitations under the License. 13428 * ============================================================================= 13429 */function W8(n){const{inputs:e,backend:t}=n,{data:r,indices:a,segmentIds:s}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(a.shape.length!==1)throw new Error(`Indices should be a vector but received shape 13430 ${a.shape}`);if(s.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape 13431 ${s.shape}`);const o=t.readSync(r.dataId),i=t.readSync(a.dataId),u=t.readSync(s.dataId),[l,c]=hm(o,r.shape,r.dtype,i,u,!0);return t.makeTensorInfo(c,r.dtype,l)}const z8={kernelName:pd,backendName:"webgl",kernelFunc:W8};/** 13432 * @license 13433 * Copyright 2021 Google LLC. All Rights Reserved. 13434 * Licensed under the Apache License, Version 2.0 (the "License");
13435 * you may not use this file except in compliance with the License. 13436 * You may obtain a copy of the License at 13437 * 13438 * http://www.apache.org/licenses/LICENSE-2.0 13439 * 13440 * Unless required by applicable law or agreed to in writing, software 13441 * distributed under the License is distributed on an "AS IS" BASIS, 13442 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13443 * See the License for the specific language governing permissions and 13444 * limitations under the License. 13445 * ============================================================================= 13446 */function G8(n){const{inputs:e,backend:t}=n,{data:r,indices:a,segmentIds:s}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(a.shape.length!==1)throw new Error(`Indices should be a vector but received shape 13447 ${a.shape}`);if(s.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape 13448 ${s.shape}`);const o=t.readSync(r.dataId),i=t.readSync(a.dataId),u=t.readSync(s.dataId),[l,c]=hm(o,r.shape,r.dtype,i,u);return t.makeTensorInfo(c,r.dtype,l)}const j8={kernelName:hd,backendName:"webgl",kernelFunc:G8};/** 13449 * @license 13450 * Copyright 2020 Google LLC. All Rights Reserved. 13451 * Licensed under the Apache License, Version 2.0 (the "License"); 13452 * you may not use this file except in compliance with the License. 13453 * You may obtain a copy of the License at 13454 * 13455 * http://www.apache.org/licenses/LICENSE-2.0 13456 * 13457 * Unless required by applicable law or agreed to in writing, software 13458 * distributed under the License is distributed on an "AS IS" BASIS, 13459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13460 * See the License for the specific language governing permissions and 13461 * limitations under the License. 13462 * ============================================================================= 13463 */function H8(n){const{inputs:e,backend:t,attrs:r}=n,{sparseIndices:a,sparseValues:s,defaultValue:o}=e,{outputShape:i}=r,{sliceRank:u,numUpdates:l,sliceSize:c,strides:p,outputSize:h}=Mu(s,a,i),d=!1;if(s.dtype==="string"){const x=t.bufferSync(a),T=t.bufferSync(s),$=ca(t.readSync(o.dataId)[0]),F=Rk(x,T,i,h,c,l,u,p,$,d);return t.makeTensorInfo(i,F.dtype,F.values)}const m=new zm(l,u,a.shape.length,s.shape.length,p,[h,1],d),y=t.runWebGLProgram(m,[s,a,o],s.dtype),b=oe({inputs:{x:y},backend:t,attrs:{shape:i}});return t.disposeIntermediateTensorInfo(y),b}const X8={kernelName:dd,backendName:"webgl",kernelFunc:H8};/** 13464 * @license 13465 * Copyright 2020 Google LLC. All Rights Reserved. 13466 * Licensed under the Apache License, Version 2.0 (the "License"); 13467 * you may not use this file except in compliance with the License. 13468 * You may obtain a copy of the License at 13469 * 13470 * http://www.apache.org/licenses/LICENSE-2.0 13471 * 13472 * Unless required by applicable law or agreed to in writing, software 13473 * distributed under the License is distributed on an "AS IS" BASIS, 13474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13475 * See the License for the specific language governing permissions and 13476 * limitations under the License. 13477 * ============================================================================= 13478 */function q8(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{numOrSizeSplits:s,axis:o}=r,i=rt(o,a.shape)[0],u=D1(a,s,i),l=a.shape.length,c=new Array(l).fill(0),p=a.shape.slice();return u.map(h=>{const d=[...p];d[i]=h;const m=Ia({inputs:{x:a},backend:t,attrs:{begin:c,size:d}});return c[i]+=h,m})}const K8={kernelName:id,backendName:"webgl",kernelFunc:q8};/** 13479 * @license 13480 * Copyright 2020 Google LLC. All Rights Reserved. 13481 * Licensed under the Apache License, Version 2.0 (the "License"); 13482 * you may not use this file except in compliance with the License. 13483 * You may obtain a copy of the License at 13484 * 13485 * http://www.apache.org/licenses/LICENSE-2.0 13486 * 13487 * Unless required by applicable law or agreed to in writing, software 13488 * distributed under the License is distributed on an "AS IS" BASIS, 13489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13490 * See the License for the specific language governing permissions and 13491 * limitations under the License. 13492 * ============================================================================= 13493 */const yc="return sqrt(x);
13493",Y8=Ie({opSnippet:yc,packedOpSnippet:yc,cpuKernelImpl:Dk}),Z8={kernelName:ad,backendName:"webgl",kernelFunc:Y8};/** 13494 * @license 13495 * Copyright 2019 Google LLC. All Rights Reserved. 13496 * Licensed under the Apache License, Version 2.0 (the "License"); 13497 * you may not use this file except in compliance with the License. 13498 * You may obtain a copy of the License at 13499 * 13500 * http://www.apache.org/licenses/LICENSE-2.0 13501 * 13502 * Unless required by applicable law or agreed to in writing, software 13503 * distributed under the License is distributed on an "AS IS" BASIS, 13504 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13505 * See the License for the specific language governing permissions and 13506 * limitations under the License. 13507 * ============================================================================= 13508 */const J8="return x * x;",Q8=Ie({opSnippet:J8}),e9={kernelName:P2,backendName:"webgl",kernelFunc:Q8};/** 13509 * @license 13510 * Copyright 2020 Google LLC. All Rights Reserved. 13511 * Licensed under the Apache License, Version 2.0 (the "License"); 13512 * you may not use this file except in compliance with the License. 13513 * You may obtain a copy of the License at 13514 * 13515 * http://www.apache.org/licenses/LICENSE-2.0 13516 * 13517 * Unless required by applicable law or agreed to in writing, software 13518 * distributed under the License is distributed on an "AS IS" BASIS, 13519 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13520 * See the License for the specific language governing permissions and 13521 * limitations under the License. 13522 * ============================================================================= 13523 */const xc="return (a - b) * (a - b);",t9=ut({opSnippet:xc,packedOpSnippet:xc}),n9={kernelName:fd,backendName:"webgl",kernelFunc:t9};/** 13524 * @license 13525 * Copyright 2020 Google LLC. All Rights Reserved. 13526 * Licensed under the Apache License, Version 2.0 (the "License"); 13527 * you may not use this file except in compliance with the License. 13528 * You may obtain a copy of the License at 13529 * 13530 * http://www.apache.org/licenses/LICENSE-2.0 13531 * 13532 * Unless required by applicable law or agreed to in writing, software 13533 * distributed under the License is distributed on an "AS IS" BASIS, 13534 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13535 * See the License for the specific language governing permissions and 13536 * limitations under the License. 13537 * ============================================================================= 13538 */function r9({inputs:n,attrs:e,backend:t}){const{x:r}=n,a=tn+` 13539 return x > 0.0 ? 1.0 : float(${e.alpha}); 13540 `,s=new $n(r.shape,a);return t.runWebGLProgram(s,[r],r.dtype)}const a9={kernelName:Nd,backendName:"webgl",kernelFunc:r9};/** 13541 * @license 13542 * Copyright 2017 Google LLC. All Rights Reserved. 13543 * Licensed under the Apache License, Version 2.0 (the "License"); 13544 * you may not use this file except in compliance with the License. 13545 * You may obtain a copy of the License at 13546 * 13547 * http://www.apache.org/licenses/LICENSE-2.0 13548 * 13549 * Unless required by applicable law or agreed to in writing, software 13550 * distributed under the License is distributed on an "AS IS" BASIS, 13551 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13552 * See the License for the specific language governing permissions and 13553 * limitations under the License. 13554 * ============================================================================= 13555 */class s9{constructor(e,t,r){this.variableNames=["x"],this.outputShape=r;const a=r.length,s=Be(r.length),o=Be(r.length);let i="";if(a===1)i="coords * strides + begin";else{let u=0;i=r.map((l,c)=>(u++,r.length===1?`coords * strides[${c}] + begin[${c}]`:`coords[${u-1}] * strides[${c}] + begin[${c}]`)).join(",")}this.userCode=` 13556 ${s} begin = ${s}(${e}); 13557 ${s} strides = ${s}(${t}); 13558 13559 void main() { 13560 ${o} coords = getOutputCoords(); 13561 setOutput(getX(${i})); 13562 } 13563 `}}/** 13564 * @license 13565 * Copyright 2020 Google LLC. All Rights Reserved. 13566 * Licensed under the Apache License, Version 2.0 (the "License"); 13567 * you may not use this file except in compliance with the License. 13568 * You may obtain a copy of the License at 13569 * 13570 * http://www.apache.org/licenses/LICENSE-2.0 13571 * 13572 * Unless required by applicable law or agreed to in writing, softw
13572are 13573 * distributed under the License is distributed on an "AS IS" BASIS, 13574 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13575 * See the License for the specific language governing permissions and 13576 * limitations under the License. 13577 * ============================================================================= 13578 */function o9(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{begin:s,end:o,strides:i,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:h}=r,{finalShapeSparse:d,finalShape:m,isIdentity:y,sliceDim0:b,isSimpleSlice:x,begin:T,end:$,strides:F}=Cf(a.shape,s,o,i,u,l,c,p,h);let M;if(y)M=oe({inputs:{x:a},backend:t,attrs:{shape:m}});else if(b||x){R(a.shape.length>=1,()=>`Input must have rank at least 1, got: ${a.shape.length}`);const X=gf(T,$,F),z=Ia({inputs:{x:a},backend:t,attrs:{begin:T,size:X}});M=oe({inputs:{x:z},backend:t,attrs:{shape:m}}),t.disposeIntermediateTensorInfo(z)}else if(t.shouldExecuteOnCPU([a])){const X=t.readSync(a.dataId),z=He(a.shape,a.dtype,X),L=Mk(d,z,F,T);M=t.makeTensorInfo(m,a.dtype,L.values)}else{const X=new s9(T,F,d);M=t.runWebGLProgram(X,[a],a.dtype)}const U=oe({inputs:{x:M},backend:t,attrs:{shape:m}});return t.disposeIntermediateTensorInfo(M),U}const i9={kernelName:md,backendName:"webgl",kernelFunc:o9};/** 13579 * @license 13580 * Copyright 2021 Google LLC. All Rights Reserved. 13581 * Licensed under the Apache License, Version 2.0 (the "License"); 13582 * you may not use this file except in compliance with the License. 13583 * You may obtain a copy of the License at 13584 * 13585 * http://www.apache.org/licenses/LICENSE-2.0 13586 * 13587 * Unless required by applicable law or agreed to in writing, software 13588 * distributed under the License is distributed on an "AS IS" BASIS, 13589 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13590 * See the License for the specific language governing permissions and 13591 * limitations under the License. 13592 * ============================================================================= 13593 */function u9(n){const{inputs:e,backend:t,attrs:r}=n,{separator:a,nGramWidths:s,leftPad:o,rightPad:i,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=e,h=t.readSync(c.dataId),d=t.readSync(p.dataId),[m,y]=Lk(h,d,a,s,o,i,u,l);return[t.makeTensorInfo([m.length],"string",m),t.makeTensorInfo(p.shape,"int32",y)]}const l9={kernelName:gd,backendName:"webgl",kernelFunc:u9};/** 13594 * @license 13595 * Copyright 2021 Google LLC. All Rights Reserved. 13596 * Licensed under the Apache License, Version 2.0 (the "License"); 13597 * you may not use this file except in compliance with the License. 13598 * You may obtain a copy of the License at 13599 * 13600 * http://www.apache.org/licenses/LICENSE-2.0 13601 * 13602 * Unless required by applicable law or agreed to in writing, software 13603 * distributed under the License is distributed on an "AS IS" BASIS, 13604 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13605 * See the License for the specific language governing permissions and 13606 * limitations under the License. 13607 * ============================================================================= 13608 */function c9(n){const{inputs:e,backend:t,attrs:r}=n,{skipEmpty:a}=r,{input:s,delimiter:o}=e;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(s.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${s.shape}`);if(o.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`);const i=t.readSync(s.dataId),u=t.readSync(o.dataId)[0],[l,c,p]=Pk(i,u,a),h=c.length;return[t.makeTensorInfo([h,2],"int32",l),t.makeTensorInfo([h],"string",c),t.makeTensorInfo([2],"int32",new Int32Array(p))]}const p9={kernelName:yd,backendName:"webgl",kernelFunc:c9};/** 13609 * @license 13610 * Copyright 2021 Google LLC. All Rights Reserved. 13611 * Licensed under the Apache License, Version 2.0 (the "License"); 13612 * you may not use this file except in compliance with the License. 13613 * You may obtain a copy of the License at 13614 * 13615 * http://www.apache.org/licenses/LICENSE-2.0 13616 * 13617 * Unless required by applicable law or agreed to in writing, software 13618 * distributed under the License is distributed on an "AS IS" BASIS, 13619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13620 * See the License for the specific language governing permissions and 13621 * limitations under the License. 13622 * ============================================================================= 13623 */function h9(n){const{inputs:e,backend:t,attrs:r}=n,{numBuckets:a}=r,{input:s}=e;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(a<=0)throw new Error("Number of buckets must be at least 1");const o=t.readSync(s.dataId),i=Bk(o,a);return t.makeTensorInfo(s.shape,"int32",i)}const d9={kernelName:xd,backendName:"webgl",kernelFunc:h9};
vendor: 4,579 bytes, lines 13623-13698
13623/** 13624 * @license 13625 * Copyright 2020 Google LLC. All Rights Reserved. 13626 * Licensed under the Apache License, Version 2.0 (the "License"); 13627 * you may not use this file except in compliance with the License. 13628 * You may obtain a copy of the License at 13629 * 13630 * http://www.apache.org/licenses/LICENSE-2.0 13631 * 13632 * Unless required by applicable law or agreed to in writing, software 13633 * distributed under the License is distributed on an "AS IS" BASIS, 13634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13635 * See the License for the specific language governing permissions and 13636 * limitations under the License. 13637 * ============================================================================= 13638 */const f9="return tan(x);",m9=Ie({opSnippet:f9}),g9={kernelName:vd,backendName:"webgl",kernelFunc:m9};/** 13639 * @license 13640 * Copyright 2020 Google LLC. All Rights Reserved. 13641 * Licensed under the Apache License, Version 2.0 (the "License"); 13642 * you may not use this file except in compliance with the License. 13643 * You may obtain a copy of the License at 13644 * 13645 * http://www.apache.org/licenses/LICENSE-2.0 13646 * 13647 * Unless required by applicable law or agreed to in writing, software 13648 * distributed under the License is distributed on an "AS IS" BASIS, 13649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13650 * See the License for the specific language governing permissions and 13651 * limitations under the License. 13652 * ============================================================================= 13653 */const y9=` 13654 float e2x = exp(-2.0 * abs(x)); 13655 return sign(x) * (1.0 - e2x) / (1.0 + e2x); 13656`,x9=Ie({opSnippet:y9}),b9={kernelName:wd,backendName:"webgl",kernelFunc:x9};/** 13657 * @license 13658 * Copyright 2017 Google LLC. All Rights Reserved. 13659 * Licensed under the Apache License, Version 2.0 (the "License"); 13660 * you may not use this file except in compliance with the License. 13661 * You may obtain a copy of the License at 13662 * 13663 * http://www.apache.org/licenses/LICENSE-2.0 13664 * 13665 * Unless required by applicable law or agreed to in writing, software 13666 * distributed under the License is distributed on an "AS IS" BASIS, 13667 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13668 * See the License for the specific language governing permissions and 13669 * limitations under the License. 13670 * ============================================================================= 13671 */class v9{constructor(e,t){this.variableNames=["A"];const r=new Array(e.length);for(let o=0;o<r.length;o++)r[o]=e[o]*t[o];this.outputShape=r,this.rank=r.length;const a=Be(this.rank),s=w9(e);this.userCode=` 13672 void main() { 13673 ${a} resRC = getOutputCoords(); 13674 setOutput(getA(${s})); 13675 } 13676 `}}function w9(n){const e=n.length;if(e>5)throw Error(`Tile for rank ${e} is not yet supported`);if(e===1)return`imod(resRC, ${n[0]})`;const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let a=0;a<n.length;a++)r.push(`imod(${t[a]}, ${n[a]})`);return r.join()}/** 13677 * @license 13678 * Copyright 2020 Google LLC. All Rights Reserved. 13679 * Licensed under the Apache License, Version 2.0 (the "License"); 13680 * you may not use this file except in compliance with the License. 13681 * You may obtain a copy of the License at 13682 * 13683 * http://www.apache.org/licenses/LICENSE-2.0 13684 * 13685 * Unless required by applicable law or agreed to in writing, software 13686 * distributed under the License is distributed on an "AS IS" BASIS, 13687 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13688 * See the License for the specific language governing permissions and 13689 * limitations under the License. 13690 * ============================================================================= 13691 */function Gm(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{reps:s}=r;if(a.dtype==="string"||a.shape.length>5){const i=t.readSync(a.dataId),u=a.dtype==="string"?i.map(p=>ca(p)):i,l=He(a.shape,a.dtype,u),c=Vk(l,s);return t.makeTensorInfo(c.shape,c.dtype,c.values)}const o=new v9(a.shape,s);return t.runWebGLProgram(o,[a],a.dtype)}const S9={kernelName:$u,backendName:"webgl",kernelFunc:Gm};class k9{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode=` 13692 void main() { 13693 ivec2 coords = getOutputCoords(); 13694 int batch = coords[0]; 13695 int elemIdx = coords[1]; 13696 13697 // We compare elements pair-wise within a group of size 2 * inc. 13698 // The comparing rule for each group alternates between ascending
13699 // and descending. Within each group, we compare each pair at 13700 // positions i and i+inc. To decide whether an element at position i 13701 // is x0 or x1, we mod it by 2 * inc, if the result is smaller than 13702 // inc, it is in the first half of the group, we denote it as x0, 13703 // otherwise we denote it as x1. 13704 // For example, as shown in the Bitonic top K paper referenced above, 13705 // Figure5(a) shows that element[1] is in the 13706 // second half of the group when group size is 2, but it is in the 13707 // first half of the group when group size is 4. 13708 13709 bool isFirstInPair = imod(elemIdx, 2 * inc) < inc; 13710 int i = isFirstInPair ? elemIdx : elemIdx - inc; 13711 13712 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 13713 int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc)); 13714 float x0 = i0 < n ? getX(batch, i0) : negativeInf; 13715 float x1 = i1 < n ? getX(batch, i1) : negativeInf; 13716 13717 // Denotes which direction indices are in (ascending or descending). 13718 bool reverse = imod(elemIdx, 2 * dir) >= dir; 13719 bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0); 13720 if (reverse == isGreater) { // Elements in opposite order of direction 13721 int iTemp = i0; 13722 i0 = i1; 13723 i1 = iTemp; 13724 } 13725 if (isFirstInPair) { 13726 setOutput(float(i0)); 13727 } else { 13728 setOutput(float(i1)); 13729 } 13730 } 13731 `}}class T9{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode=` 13732 void main() { 13733 // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ... 13734 ivec2 coords = getOutputCoords(); 13735 int batch = coords[0]; 13736 int elemIdx = coords[1]; 13737 13738 // The output size is half of the previous size. 13739 // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4), 13740 // we only need to output the indices at positions |, the indices at 13741 // positions _ can be thrown away, see Figure5(b) After Phase 2 13742 // (Merge phase) in the Bitonic Top K paper referenced above. 13743 // For example, the paper shows we only need to output the orange bars. 13744 // The output sequence should look like this | | | | | | | |. 13745 // Because the sequence is halved, to map the output index back 13746 // to the previous sequence to find the corresponding value, 13747 // we need to double the index. When we double the index, 13748 // we basically interpolate a position, so 2i looks like 13749 // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position 13750 // of each 2k positions by - elemIdx % k. E.g. for output at 13751 // index 4,5,6,7, we want to get the corresponding element at 13752 // original index 8,9,10,11, for output at index 8,9,10,11, 13753 // we want to get the corresponding element at original index 13754 // 16,17,18,19, so on and so forth. 13755 13756 int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k)); 13757 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 13758 int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k)); 13759 13760 float x0 = getX(batch, i0); 13761 float x1 = i1 < n ? getX(batch, i1) : x0; 13762 13763 setOutput(x0 >= x1 ? float(i0) : float(i1)); 13764 } 13765 `}}/** 13766 * @license 13767 * Copyright 2020 Google LLC. All Rights Reserved. 13768 * Licensed under the Apache License, Version 2.0 (the "License"); 13769 * you may not use this file except in compliance with the License. 13770 * You may obtain a copy of the License at 13771 * 13772 * http://www.apache.org/licenses/LICENSE-2.0 13773 * 13774 * Unless required by applicable law or agreed to in writing, software 13775 * distributed under the License is distributed on an "AS IS" BASIS, 13776 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13777 * See the License for the specific language governing permissions and 13778 * limitations under the License. 13779 * ============================================================================= 13780 */function vr(n,e){e!==null&&n.disposeIntermediateTensorInfo(e)}function bc(n){let e=1;for(;e<n;)e*=2;return e}function E9(n){const{inputs:e,backend:t,attrs:r}=n,{x:a}=e,{k:s,sorted:o}=r,i=H().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),u=H().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),l=a.shape,c=l[l.length-1];if(t.shouldExecuteOnCPU([a])||c<i||s>u){const L=t.readSync(a.dataId),[C,q]=Wk(L,l,a.dtype,s,o);return[t.makeTensorInfo(C.shape,C.dtype,C.values),t.makeTensorInfo(q.shape,q.dtype,q.values)]}if(s===0)return l[l.length-1]=0,[t.makeTensorInfo(l,a.dtype,[]),t.makeTensorInfo(l,"int32",[])];if(c===1)return[a,Ss({attrs:{shape:l,dtype:"int32",value:0},backend:t})];const p=t.texData.get(a.dataId),h=p!==null&&p.isPacked,d=h?t.unpackTensor(a):a,m=ae(l)/c,y=oe({inputs:{x:d},attrs:{shape:[m,c]},backend:t});h&&vr(t,d);const b=bc(s),x=bc(c);let T=null;const $=()=>T===null?[y,y]:[y,T],F=(L,C,q)=>{const ee=$(),te=new k9(q),le=[[c],[T===null?1:0],[Number.NEGATIVE_INFINITY],[L],[C]],de=T;T=t.runWebGLProgram(te,ee,"int32",le),vr(t,de)};for(let L=1;L<b;L*=2){const C=L*2;for(let q=L;q>=1;q/=2)F(C,q,[m,x])}for(let L=x;L>b;L/=2){const C=$(),q=new T9([m,L/2]),ee=[[c],[T===null?1:0],[b]],te=T;T=t.runWebGLProgram(q,C,"int32",ee),vr(t,te);const le=b/2,de=le*2;
vendor: 4,867 bytes, lines 13780-13883
13780for(let fe=le;fe>=1;fe/=2)F(de,fe,T.shape)}let M=T;T=Ia({inputs:{x:T},backend:t,attrs:{begin:0,size:[m,s]}}),vr(t,M);let U=Dm({inputs:{x:y,indices:T},backend:t,attrs:{axis:1,batchDims:1}});vr(t,y);const X=l.slice(0,-1);X.push(s),M=T,T=oe({inputs:{x:T},attrs:{shape:X},backend:t}),vr(t,M);const z=U;return U=oe({inputs:{x:U},attrs:{shape:X},backend:t}),vr(t,z),[U,T]}const C9={kernelName:Sd,backendName:"webgl",kernelFunc:E9};/** 13781 * @license 13782 * Copyright 2021 Google LLC. All Rights Reserved. 13783 * Licensed under the Apache License, Version 2.0 (the "License"); 13784 * you may not use this file except in compliance with the License. 13785 * You may obtain a copy of the License at 13786 * 13787 * http://www.apache.org/licenses/LICENSE-2.0 13788 * 13789 * Unless required by applicable law or agreed to in writing, software 13790 * distributed under the License is distributed on an "AS IS" BASIS, 13791 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13792 * See the License for the specific language governing permissions and 13793 * limitations under the License. 13794 * ============================================================================= 13795 */class I9{constructor(e,t,r,a,s,o){this.variableNames=["Image","Transforms"],this.outputShape=o;const i=r==="nearest"?1:2;let u;switch(a){case"constant":u=1;break;case"reflect":u=2;break;case"wrap":u=3;break;case"nearest":u=4;break;default:u=1;break}this.userCode=` 13796 float mapCoord(float outCoord, float len) { 13797 float inCoord = outCoord; 13798 if(${u} == 2) { 13799 if (inCoord < 0.0) { 13800 if (len <= 1.0) { 13801 inCoord = 0.0; 13802 } else { 13803 float sz2 = 2.0 * len; 13804 if (inCoord < sz2) { 13805 inCoord = sz2 * float(int(float(-inCoord / sz2))) + 13806 inCoord; 13807 } 13808 inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0; 13809 } 13810 } else if (inCoord > len - 1.0) { 13811 if (len <= 1.0) { 13812 inCoord = 0.0; 13813 } else { 13814 float sz2 = 2.0 * len; 13815 inCoord -= sz2 * float(int(float(inCoord / sz2))); 13816 if (inCoord >= len) { 13817 inCoord = sz2 - inCoord - 1.0; 13818 } 13819 } 13820 } 13821 return clamp(inCoord, 0.0, len - 1.0); 13822 } else if (${u} == 3) { 13823 if (inCoord < 0.0) { 13824 if (len <= 1.0) { 13825 inCoord = 0.0; 13826 } else { 13827 float sz = len - 1.0; 13828 inCoord += len * (float(int(float(-inCoord / sz))) + 1.0); 13829 } 13830 } else if (inCoord > len - 1.0) { 13831 if (len <= 1.0) { 13832 inCoord = 0.0; 13833 } else { 13834 float sz = len - 1.0; 13835 inCoord -= len * float(int(float(inCoord / sz))); 13836 } 13837 } 13838 return clamp(inCoord, 0.0, len - 1.0); 13839 } else if (${u} == 4) { 13840 return clamp(outCoord, 0.0, len - 1.0); 13841 } else { 13842 return outCoord; 13843 } 13844 } 13845 13846 float readWithFillValue(int batch, int coordY, int coordX, 13847 int channel) { 13848 float outputValue; 13849 if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) { 13850 outputValue = getImage(batch, coordY, coordX, channel); 13851 } else { 13852 outputValue = float(${s}); 13853 } 13854 return outputValue; 13855 } 13856 13857 void main() { 13858 ivec4 coords = getOutputCoords(); 13859 float outputValue; 13860 int batch = coords[0]; 13861 int x = coords[2]; 13862 int y = coords[1]; 13863 int channel = coords[3]; 13864 float xf = float(x); 13865 float yf = float(y); 13866 float a1 = getTransforms(batch, 0); 13867 float a2 = getTransforms(batch, 1); 13868 float a3 = getTransforms(batch, 2); 13869 float b1 = getTransforms(batch, 3); 13870 float b2 = getTransforms(batch, 4); 13871 float b3 = getTransforms(batch, 5); 13872 float c1 = getTransforms(batch, 6); 13873 float c2 = getTransforms(batch, 7); 13874 float projection = c1 * xf + c2 * yf + 1.0; 13875 if (projection == 0.0) { 13876 outputValue = float(${s}); 13877 } else { 13878 float inX = (a1 * xf + a2 * yf + a3) / projection; 13879 float inY = (b1 * xf + b2 * yf + b3) / projection; 13880 float mapX = mapCoord(inX, float(${t})); 13881 float mapY = mapCoord(inY, float(${e})); 13882 13883 if (${i} == 1) {
13884 int coordY = int(round(mapY)); 13885 int coordX = int(round(mapX)); 13886 outputValue = readWithFillValue(batch, coordY, coordX, 13887 channel); 13888 } else { 13889 float yFloor = floor(mapY); 13890 float xFloor = floor(mapX); 13891 float yCeil = yFloor + 1.0; 13892 float xCeil = xFloor + 1.0; 13893 float valueYFloor = (xCeil - mapX) * 13894 readWithFillValue(batch, int(yFloor), int(xFloor), channel) + 13895 (mapX - xFloor) * 13896 readWithFillValue(batch, int(yFloor), int(xCeil), channel); 13897 float valueYCeil = (xCeil - mapX) * 13898 readWithFillValue(batch, int(yCeil), int(xFloor), channel) + 13899 (mapX - xFloor) * 13900 readWithFillValue(batch, int(yCeil), int(xCeil), channel); 13901 outputValue = (yCeil - mapY) * valueYFloor + 13902 (mapY - yFloor) * valueYCeil; 13903 } 13904 } 13905 setOutput(outputValue); 13906 } 13907 `}}/** 13908 * @license 13909 * Copyright 2021 Google LLC. All Rights Reserved. 13910 * Licensed under the Apache License, Version 2.0 (the "License"); 13911 * you may not use this file except in compliance with the License. 13912 * You may obtain a copy of the License at 13913 * 13914 * http://www.apache.org/licenses/LICENSE-2.0 13915 * 13916 * Unless required by applicable law or agreed to in writing, software 13917 * distributed under the License is distributed on an "AS IS" BASIS, 13918 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13919 * See the License for the specific language governing permissions and 13920 * limitations under the License. 13921 * ============================================================================= 13922 */function N9(n){const{inputs:e,backend:t,attrs:r}=n,{image:a,transforms:s}=e,{interpolation:o,fillMode:i,fillValue:u,outputShape:l}=r,[c,p,h,d]=a.shape,[m,y]=l??[p,h],b=[c,m,y,d],x=new I9(p,h,o,i,u,b);return t.runWebGLProgram(x,[a,s],"float32")}const $9={kernelName:kd,backendName:"webgl",kernelFunc:N9};/** 13923 * @license 13924 * Copyright 2020 Google LLC. All Rights Reserved. 13925 * Licensed under the Apache License, Version 2.0 (the License); 13926 * you may not use this file except in compliance with the License. 13927 * You may obtain a copy of the License at 13928 * 13929 * http://www.apache.org/licenses/LICENSE-2.0 13930 * 13931 * Unless required by applicable law or agreed to in writing, software 13932 * distributed under the License is distributed on an AS IS BASIS, 13933 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13934 * See the License for the specific language governing permissions and 13935 * limitations under the License. 13936 * ============================================================================= 13937 */function R9(n){const{inputs:e,attrs:t,backend:r}=n,{axis:a}=t,{x:s}=e;ys(s,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const o=r.readSync(s.dataId),{outputValues:i,outputShape:u,indices:l}=zk(o,a,s.shape,s.dtype);return[r.makeTensorInfo(u,s.dtype,i),r.makeTensorInfo([l.length],"int32",l)]}const _9={kernelName:Td,backendName:"webgl",kernelFunc:R9};/** 13938 * @license 13939 * Copyright 2020 Google LLC. All Rights Reserved. 13940 * Licensed under the Apache License, Version 2.0 (the "License"); 13941 * you may not use this file except in compliance with the License. 13942 * You may obtain a copy of the License at 13943 * 13944 * http://www.apache.org/licenses/LICENSE-2.0 13945 * 13946 * Unless required by applicable law or agreed to in writing, software 13947 * distributed under the License is distributed on an "AS IS" BASIS, 13948 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13949 * See the License for the specific language governing permissions and 13950 * limitations under the License. 13951 * ============================================================================= 13952 */function A9(n){const{inputs:e,backend:t,attrs:r}=n,{value:a}=e;let{axis:s}=r;s<0&&(s+=a.shape.length);const o=a,i=o.shape.length,u=a.shape[s],l=new Array(i-1);let c=0;for(let y=0;y<i;y++)y!==s&&(l[c++]=o.shape[y]);const p=[],h=new Array(i).fill(0),d=o.shape.slice();d[s]=1;const m=new Array(u);for(let y=0;y<m.length;y++){h[s]=y;const b=Ia({inputs:{x:o},backend:t,attrs:{begin:h,size:d}}),x=oe({inputs:{x:b},backend:t,attrs:{shape:l}});m[y]=x,p.push(b)}return p.forEach(y=>t.disposeIntermediateTensorInfo(y)),m}const O9={kernelName:Ed,backendName:"webgl",kernelFunc:A9};/** 13953 * @license 13954 * Copyright 2018 Google LLC. All Rights Reserved. 13955 * Licensed under the Apache License, Version 2.0 (the "License");
13956 * you may not use this file except in compliance with the License. 13957 * You may obtain a copy of the License at 13958 * 13959 * http://www.apache.org/licenses/LICENSE-2.0 13960 * 13961 * Unless required by applicable law or agreed to in writing, software 13962 * distributed under the License is distributed on an "AS IS" BASIS, 13963 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13964 * See the License for the specific language governing permissions and 13965 * limitations under the License. 13966 * ============================================================================= 13967 */class F9{constructor(e,t){this.variableNames=["x","segmentIds"];const r=e.windowSize,a=e.batchSize,s=e.inSize,o=e.numSegments,i=o*Math.ceil(s/r);this.outputShape=[a,i];const u="0.0",l="sumValue",c=Math.floor(r/4)*4,p=r%4,h=` 13968 sumValue += dot(values, segFilter); 13969 `;let d="";s%r>0&&(d=` 13970 if (inIdx < 0 || inIdx >= ${s}) { 13971 return initializationValue; 13972 } 13973 `);let m="";s%r>0&&(m=` 13974 if (inIdx < 0 || inIdx >= ${s}) { 13975 return -1.0; 13976 } 13977 `),this.userCode=` 13978 const float initializationValue = ${u}; 13979 13980 float getValue(int batch, int inIdx) { 13981 ${d} 13982 return getX(batch, inIdx); 13983 } 13984 13985 float getSegmentIdAtIndex(int inIdx) { 13986 ${m} 13987 return getSegmentIds(inIdx); 13988 } 13989 13990 void main() { 13991 ivec2 coords = getOutputCoords(); 13992 int batch = coords[0]; 13993 int outIdx = coords[1]; 13994 int inOffset = int(floor(float(outIdx) / float( 13995 ${o})) * float(${r})); 13996 int currentSeg = int(mod(float(outIdx), float(${o}))); 13997 13998 float sumValue = 0.0; 13999 14000 for (int i = 0; i < ${c}; i += 4) { 14001 int inIdx = inOffset + i; 14002 vec4 values = vec4( 14003 getValue(batch, inIdx), 14004 getValue(batch, inIdx + 1), 14005 getValue(batch, inIdx + 2), 14006 getValue(batch, inIdx + 3) 14007 ); 14008 14009 vec4 segFilter = vec4( 14010 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14011 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 14012 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 14013 int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0 14014 ); 14015 14016 ${h} 14017 } 14018 14019 int inIdx = inOffset + ${c}; 14020 if (${p===1}) { 14021 vec4 values = vec4( 14022 getValue(batch, inIdx), 14023 initializationValue, 14024 initializationValue, 14025 initializationValue 14026 ); 14027 14028 int inIdxSeg = int(getSegmentIdAtIndex(inIdx)); 14029 14030 vec4 segFilter = vec4( 14031 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14032 0, 14033 0, 14034 0 14035 ); 14036 14037 ${h} 14038 } else if (${p===2}) { 14039 vec4 values = vec4( 14040 getValue(batch, inIdx), 14041 getValue(batch, inIdx + 1), 14042 initializationValue, 14043 initializationValue 14044 ); 14045 14046 vec4 segFilter = vec4( 14047 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14048 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 14049 0, 14050 0 14051 ); 14052 14053 ${h} 14054 } else if (${p===3}) { 14055 vec4 values = vec4( 14056 getValue(batch, inIdx), 14057 getValue(batch, inIdx + 1), 14058 getValue(batch, inIdx + 2), 14059 initializationValue 14060 ); 14061 14062 vec4 segFilter = vec4( 14063 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14064 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 14065 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 14066 0 14067 ); 14068 14069 ${h} 14070 } 14071 setOutput(${l}); 14072 } 14073 `}}/** 14074 * @license 14075 * Copyright 2020 Google LLC. All Rights Reserved. 14076 * Licensed under the Apache License, Version 2.0 (the "License"); 14077 * you may not use this file except in compliance with the License. 14078 * You may obtain a copy of the License at 14079 * 14080 * http://www.apache.org/licenses/LICENSE-2.0 14081 * 14082 * Unless required by applicable law or agreed to in writing, softw
14082are 14083 * distributed under the License is distributed on an "AS IS" BASIS, 14084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14085 * See the License for the specific language governing permissions and 14086 * limitations under the License. 14087 * ============================================================================= 14088 */function D9(n){const{inputs:e,backend:t,attrs:r}=n,{x:a,segmentIds:s}=e,{numSegments:o}=r,i=a.shape.length,u=[];let l=0;const c=Qt([l],i);let p=a;c!=null&&(p=yt({inputs:{x:a},backend:t,attrs:{perm:c}}),u.push(p),l=en(1,i)[0]);const h=q1(p.shape,l,o),d=ae([p.shape[l]]),m=oe({inputs:{x:p},backend:t,attrs:{shape:[-1,d]}});u.push(m);const y=Ru(a.dtype),b=(F,M,U,X,z)=>{const L=F.shape[0],C=F.shape[1],q=X1(C,z),ee={windowSize:q,inSize:C,batchSize:L,numSegments:z},te=new F9(ee,M),le=t.compileAndRun(te,[F,U],X);if(u.push(le),le.shape[1]===z)return le;const de=Wm({backend:t,attrs:{start:0,stop:z,step:1,dtype:"float32"}}),fe=Gm({inputs:{x:de},backend:t,attrs:{reps:[C/q]}});return u.push(de),u.push(fe),b(le,M,fe,X,z)},x=b(m,"unsortedSegmentSum",s,y,o),T=oe({inputs:{x},backend:t,attrs:{shape:h}});let $=T;if(c!=null){u.push(T);const F=zu(c);$=yt({inputs:{x:$},backend:t,attrs:{perm:F}})}return u.forEach(F=>t.disposeIntermediateTensorInfo(F)),$}const M9={kernelName:Cd,backendName:"webgl",kernelFunc:D9};/** 14089 * @license 14090 * Copyright 2020 Google LLC. All Rights Reserved. 14091 * Licensed under the Apache License, Version 2.0 (the "License"); 14092 * you may not use this file except in compliance with the License. 14093 * You may obtain a copy of the License at 14094 * 14095 * http://www.apache.org/licenses/LICENSE-2.0 14096 * 14097 * Unless required by applicable law or agreed to in writing, software 14098 * distributed under the License is distributed on an "AS IS" BASIS, 14099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14100 * See the License for the specific language governing permissions and 14101 * limitations under the License. 14102 * ============================================================================= 14103 */const L9=[FT,MT,BT,WT,GT,XT,KT,ZT,tE,rE,oE,lE,hE,gE,bE,wE,kE,IE,$E,_E,DE,WE,GE,HE,JE,eC,aC,yT,iC,hC,gC,SC,TC,CC,NC,RC,OC,MC,BC,VC,zC,jC,qC,YC,eI,nI,sI,uI,cI,fI,xI,SI,EI,NI,$I,_I,OI,DI,LI,BI,zI,HI,KI,ZI,eN,rN,iN,pN,gT,dN,cC,gN,bN,SN,bT,CN,RN,AN,MN,BN,zN,HN,YN,e$,r$,s$,l$,p$,d$,y$,b$,w$,k$,E$,$$,O$,L$,j$,ST,K$,J$,t7,a7,qE,i7,l7,p7,f7,x7,wT,v7,S7,T7,E7,KE,V$,N7,A7,M7,TT,U7,z7,X7,Y7,e8,n8,s8,u8,c8,d8,g8,b8,k8,C8,$8,A8,UE,z$,D8,L8,B8,V8,z8,j8,X8,K8,Z8,e9,n9,a9,i9,l9,p9,d9,W$,_T,g9,b9,S9,C9,$9,AT,_9,O9,M9,u7];for(const n of L9)V2(n);/** 14104 * @license 14105 * Copyright 2021 Google LLC. All Rights Reserved. 14106 * Licensed under the Apache License, Version 2.0 (the "License"); 14107 * you may not use this file except in compliance with the License. 14108 * You may obtain a copy of the License at 14109 * 14110 * http://www.apache.org/licenses/LICENSE-2.0 14111 * 14112 * Unless required by applicable law or agreed to in writing, software 14113 * distributed under the License is distributed on an "AS IS" BASIS, 14114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14115 * See the License for the specific language governing permissions and 14116 * limitations under the License. 14117 * ============================================================================= 14118 */const P9=H();P9.registerFlag("KEEP_INTERMEDIATE_TENSORS",()=>!1,n=>{n&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")});/** 14119 * @license 14120 * Copyright 2019 Google LLC. All Rights Reserved. 14121 * Licensed under the Apache License, Version 2.0 (the "License"); 14122 * you may not use this file except in compliance with the License. 14123 * You may obtain a copy of the License at 14124 * 14125 * http://www.apache.org/licenses/LICENSE-2.0 14126 * 14127 * Unless required by applicable law or agreed to in writing, software 14128 * distributed under the License is distributed on an "AS IS" BASIS, 14129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14130 * See the License for the specific language governing permissions and 14131 * limitations under the License. 14132 * 14133 * ============================================================================= 14134 */var qt;(function(n){n[n.DT_INVALID=0]="DT_INVALID",n[n.DT_FLOAT=1]="DT_FLOAT",n[n.DT_DOUBLE=2]="DT_DOUBLE",n[n.DT_INT32=3]="DT_INT32",n[n.DT_UINT8=4]="DT_UINT8",n[n.DT_INT16=5]="DT_INT16",n[n.DT_INT8=6]="DT_INT8",n[n.DT_STRING=7]="DT_STRING",n[n.DT_COMPLEX64=8]="DT_COMPLEX64",n[n.DT_INT64=9]="DT_INT64",n[n.DT_BOOL=10]="DT_BOOL",n[n.DT_QINT8=11]="DT_QINT8",n[n.DT_QUINT8=12]="DT_QUINT8",n[n.DT_QINT32=13]="DT_QINT32",n[n.DT_BFLOAT16=14]="DT_BFLOAT16",n[n.DT_QINT16=15]="DT_QINT16",n[n.DT_QUINT16=16]="DT_QUINT16",n[n.DT_UINT16=17]="DT_UINT16",n[n.DT_COMPLEX128=18]="DT_COMPLEX128",n[n.DT_HALF=19]="DT_HALF",n[n.DT_RESOURCE=20]="DT_RESOURCE",n[n.DT_VARIANT=2
141341]="DT_VARIANT",n[n.DT_UINT32=22]="DT_UINT32",n[n.DT_UINT64=23]="DT_UINT64",n[n.DT_FLOAT_REF=101]="DT_FLOAT_REF",n[n.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",n[n.DT_INT32_REF=103]="DT_INT32_REF",n[n.DT_UINT8_REF=104]="DT_UINT8_REF",n[n.DT_INT16_REF=105]="DT_INT16_REF",n[n.DT_INT8_REF=106]="DT_INT8_REF",n[n.DT_STRING_REF=107]="DT_STRING_REF",n[n.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",n[n.DT_INT64_REF=109]="DT_INT64_REF",n[n.DT_BOOL_REF=110]="DT_BOOL_REF",n[n.DT_QINT8_REF=111]="DT_QINT8_REF",n[n.DT_QUINT8_REF=112]="DT_QUINT8_REF",n[n.DT_QINT32_REF=113]="DT_QINT32_REF",n[n.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",n[n.DT_QINT16_REF=115]="DT_QINT16_REF",n[n.DT_QUINT16_REF=116]="DT_QUINT16_REF",n[n.DT_UINT16_REF=117]="DT_UINT16_REF",n[n.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",n[n.DT_HALF_REF=119]="DT_HALF_REF",n[n.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",n[n.DT_VARIANT_REF=121]="DT_VARIANT_REF",n[n.DT_UINT32_REF=122]="DT_UINT32_REF",n[n.DT_UINT64_REF=123]="DT_UINT64_REF"})(qt||(qt={}));var vc;(function(n){(function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"})(n.CheckpointFormatVersion||(n.CheckpointFormatVersion={}))})(vc||(vc={}));/** 14135 * @license 14136 * Copyright 2019 Google LLC. All Rights Reserved. 14137 * Licensed under the Apache License, Version 2.0 (the "License"); 14138 * you may not use this file except in compliance with the License. 14139 * You may obtain a copy of the License at 14140 * 14141 * http://www.apache.org/licenses/LICENSE-2.0 14142 * 14143 * Unless required by applicable law or agreed to in writing, software 14144 * distributed under the License is distributed on an "AS IS" BASIS, 14145 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14146 * See the License for the specific language governing permissions and 14147 * limitations under the License. 14148 * ============================================================================= 14149 */const B9={};function jm(n){return B9[n]}/** 14150 * @license 14151 * Copyright 2018 Google LLC. All Rights Reserved. 14152 * Licensed under the Apache License, Version 2.0 (the "License"); 14153 * you may not use this file except in compliance with the License. 14154 * You may obtain a copy of the License at 14155 * 14156 * http://www.apache.org/licenses/LICENSE-2.0 14157 * 14158 * Unless required by applicable law or agreed to in writing, software 14159 * distributed under the License is distributed on an "AS IS" BASIS, 14160 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14161 * See the License for the specific language governing permissions and 14162 * limitations under the License. 14163 * ============================================================================= 14164 */function w(n,e,t,r,a){const s=e.inputParams[n];if(s&&s.inputIndexStart!==void 0){const i=s.inputIndexStart,u=s.inputIndexEnd===0?void 0:s.inputIndexEnd===void 0?i+1:s.inputIndexEnd;if(s.type==="tensor")return mt(e.inputNames[s.inputIndexStart],t,r,a);if(s.type==="tensors")return e.inputNames.slice(i,u).map(p=>mt(p,t,r,a));const l=mt(e.inputNames.slice(i)[0],t,r,a),c=l.dataSync();return s.type==="number"?c[0]:Ni(l.shape,c)}const o=e.attrParams[n];return o&&o.value}function mt(n,e,t,r){const[a,s]=Nt(n);if(r!=null){const i=r.getHashTableHandleByName(a);if(i!=null)return i}const o=t.currentContextIds.find(i=>!!e[mo(a,i)]);return o!==void 0?e[mo(a,o)][s]:void 0}function U9(n,e,t){return e[mo(n,t.currentContextId)]}function xn(n,e){const[t,r,a]=Nt(n);return[mo(t,e&&e.currentContextId),r,a]}function mo(n,e){return e?`${n}-${e}`:n}function Nt(n){const e=n.split(":");if(e.length===1)return[n,0,void 0];const t=e[0],r=e.length===3?e[1]:void 0,a=Number(e[e.length-1]);return[t,a,r]}function Qs(n,e,t){let r=w("pad",n,e,t);if(r==="explicit"){r=w("explicitPaddings",n,e,t);const a=[[0,0],[0,0],[0,0],[0,0]];for(let s=0;s<4;s++)a[s][0]=r[s*2],a[s][1]=r[s*2+1];return a}return r}function In(n){return n.kept?n:Jn(n)}/** 14165 * @license 14166 * Copyright 2022 Google LLC. All Rights Reserved. 14167 * Licensed under the Apache License, Version 2.0 (the "License"); 14168 * you may not use this file except in compliance with the License. 14169 * You may obtain a copy of the License at 14170 * 14171 * http://www.apache.org/licenses/LICENSE-2.0 14172 * 14173 * Unless required by applicable law or agreed to in writing, softw
14173are 14174 * distributed under the License is distributed on an "AS IS" BASIS, 14175 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14176 * See the License for the specific language governing permissions and 14177 * limitations under the License. 14178 * ============================================================================= 14179 */const V9=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],W9=Object.freeze(Object.defineProperty({__proto__:null,json:V9},Symbol.toStringTag,{value:"Module"}));/** 14180 * @license 14181 * Copyright 2022 Google LLC. All Rights Reserved. 14182 * Licensed under the Apache License, Version 2.0 (the "License"); 14183 * you may not use this file except in compliance with the License. 14184 * You may obtain a copy of the License at 14185 * 14186 * http://www.apache.org/licenses/LICENSE-2.0 14187 * 14188 * Unless required by applicable law or agreed to in writing, software 14189 * distributed under the License is distributed on an "AS IS" BASIS, 14190 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14191 * See the License for the specific language governing permissions and 14192 * limitations under the License. 14193 * ============================================================================= 14194 */const z9=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
14194]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
vendor: 4,087 bytes, lines 14194-14209
14194]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],G9=Object.freeze(Object.defineProperty({__proto__:null,json:z9},Symbol.toStringTag,{value:"Module"}));/** 14195 * @license 14196 * Copyright 2022 Google LLC. All Rights Reserved. 14197 * Licensed under the Apache License, Version 2.0 (the "License"); 14198 * you may not use this file except in compliance with the License. 14199 * You may obtain a copy of the License at 14200 * 14201 * http://www.apache.org/licenses/LICENSE-2.0 14202 * 14203 * Unless required by applicable law or agreed to in writing, software 14204 * distributed under the License is distributed on an "AS IS" BASIS, 14205 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14206 * See the License for the specific language governing permissions and 14207 * limitations under the License. 14208 * ============================================================================= 14209 */const j9=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]}
14209,{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]}
14209,{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],H9=Object.freeze(Object.defineProperty({__proto__:null,json:j9},Symbol.toStringTag,{value:"Module"}));/** 14210 * @license 14211 * Copyright 2022 Google LLC. All Rights Reserved. 14212 * Licensed under the Apache License, Version 2.0 (the "License"); 14213 * you may not use this file except in compliance with the License. 14214 * You may obtain a copy of the License at 14215 * 14216 * http://www.apache.org/licenses/LICENSE-2.0 14217 * 14218 * Unless required by applicable law or agreed to in writing, software 14219 * distributed under the License is distributed on an "AS IS" BASIS, 14220 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14221 * See the License for the specific language governing permissions and 14222 * limitations under the License. 14223 * ============================================================================= 14224 */const X9=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0}
14224,{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
vendor: 9,023 bytes, lines 14224-14272
14224,{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],q9=Object.freeze(Object.defineProperty({__proto__:null,json:X9},Symbol.toStringTag,{value:"Module"}));/** 14225 * @license 14226 * Copyright 2022 Google LLC. All Rights Reserved. 14227 * Licensed under the Apache License, Version 2.0 (the "License"); 14228 * you may not use this file except in compliance with the License. 14229 * You may obtain a copy of the License at 14230 * 14231 * http://www.apache.org/licenses/LICENSE-2.0 14232 * 14233 * Unless required by applicable law or agreed to in writing, software 14234 * distributed under the License is distributed on an "AS IS" BASIS, 14235 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14236 * See the License for the specific language governing permissions and 14237 * limitations under the License. 14238 * ============================================================================= 14239 */const K9=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],Y9=Object.freeze(Object.defineProperty({__proto__:null,json:K9},Symbol.toStringTag,{value:"Module"}));/** 14240 * @license 14241 * Copyright 2022 Google LLC. All Rights Reserved. 14242 * Licensed under the Apache License, Version 2.0 (the "License"); 14243 * you may not use this file except in compliance with the License. 14244 * You may obtain a copy of the License at 14245 * 14246 * http://www.apache.org/licenses/LICENSE-2.0 14247 * 14248 * Unless required by applicable law or agreed to in writing, software 14249 * distributed under the License is distributed on an "AS IS" BASIS, 14250 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14251 * See the License for the specific language governing permissions and 14252 * limitations under the License. 14253 * ============================================================================= 14254 */const Z9=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],J9=Object.freeze(Object.defineProperty({__proto__:null,json:Z9},Symbol.toStringTag,{value:"Module"}));/** 14255 * @license 14256 * Copyright 2022 Google LLC. All Rights Reserved. 14257 * Licensed under the Apache License, Version 2.0 (the "License"); 14258 * you may not use this file except in compliance with the License. 14259 * You may obtain a copy of the License at 14260 * 14261 * http://www.apache.org/licenses/LICENSE-2.0 14262 * 14263 * Unless required by applicable law or agreed to in writing, software 14264 * distributed under the License is distributed on an "AS IS" BASIS, 14265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14266 * See the License for the specific language governing permissions and 14267 * limitations under the License. 14268 * ============================================================================= 14269 */const Q9=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],eR=Object.freeze(Object.defineProperty({__proto__:null,json:Q9},Symbol.toStringTag,{value:"Module"}));/** 14270 * @license 14271 * Copyright 2022 Google LLC. All Rights Reserved. 14272 * Licensed under the Apache License, Version 2.0 (the "License");
14273 * you may not use this file except in compliance with the License. 14274 * You may obtain a copy of the License at 14275 * 14276 * http://www.apache.org/licenses/LICENSE-2.0 14277 * 14278 * Unless required by applicable law or agreed to in writing, software 14279 * distributed under the License is distributed on an "AS IS" BASIS, 14280 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14281 * See the License for the specific language governing permissions and 14282 * limitations under the License. 14283 * ============================================================================= 14284 */const tR=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],nR=Object.freeze(Object.defineProperty({__proto__:null,json:tR},Symbol.toStringTag,{value:"Module"}));/** 14285 * @license 14286 * Copyright 2022 Google LLC. All Rights Reserved. 14287 * Licensed under the Apache License, Version 2.0 (the "License"); 14288 * you may not use this file except in compliance with the License. 14289 * You may obtain a copy of the License at 14290 * 14291 * http://www.apache.org/licenses/LICENSE-2.0 14292 * 14293 * Unless required by applicable law or agreed to in writing, software 14294 * distributed under the License is distributed on an "AS IS" BASIS, 14295 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14296 * See the License for the specific language governing permissions and 14297 * limitations under the License. 14298 * ============================================================================= 14299 */const rR=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}
14299]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],aR=Object.freeze(Object.defineProperty({__proto__:null,json:rR},Symbol.toStringTag,{value:"Module"}));/** 14300 * @license 14301 * Copyright 2022 Google LLC. All Rights Reserved. 14302 * Licensed under the Apache License, Version 2.0 (the "License"); 14303 * you may not use this file except in compliance with the License. 14304 * You may obtain a copy of the License at 14305 * 14306 * http://www.apache.org/licenses/LICENSE-2.0 14307 * 14308 * Unless required by applicable law or agreed to in writing, software 14309 * distributed under the License is distributed on an "AS IS" BASIS, 14310 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14311 * See the License for the specific language governing permissions and 14312 * limitations under the License. 14313 * ============================================================================= 14314 */const sR=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],oR=Object.freeze(Object.defineProperty({__proto__:null,json:sR},Symbol.toStringTag,{value:"Module"}));/** 14315 * @license 14316 * Copyright 2022 Google LLC. All Rights Reserved. 14317 * Licensed under the Apache License, Version 2.0 (the "License"); 14318 * you may not use this file except in compliance with the License. 14319 * You may obtain a copy of the License at 14320 * 14321 * http://www.apache.org/licenses/LICENSE-2.0 14322 * 14323 * Unless required by applicable law or agreed to in writing, software 14324 * distributed under the License is distributed on an "AS IS" BASIS, 14325 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14326 * See the License for the specific language governing permissions and 14327 * limitations under the License. 14328 * ============================================================================= 14329 */const iR=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
vendor: 10,879 bytes, lines 14329-14377
14329]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],uR=Object.freeze(Object.defineProperty({__proto__:null,json:iR},Symbol.toStringTag,{value:"Module"}));/** 14330 * @license 14331 * Copyright 2022 Google LLC. All Rights Reserved. 14332 * Licensed under the Apache License, Version 2.0 (the "License"); 14333 * you may not use this file except in compliance with the License. 14334 * You may obtain a copy of the License at 14335 * 14336 * http://www.apache.org/licenses/LICENSE-2.0 14337 * 14338 * Unless required by applicable law or agreed to in writing, software 14339 * distributed under the License is distributed on an "AS IS" BASIS, 14340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14341 * See the License for the specific language governing permissions and 14342 * limitations under the License. 14343 * ============================================================================= 14344 */const lR=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}],cR=Object.freeze(Object.defineProperty({__proto__:null,json:lR},Symbol.toStringTag,{value:"Module"}));/** 14345 * @license 14346 * Copyright 2022 Google LLC. All Rights Reserved. 14347 * Licensed under the Apache License, Version 2.0 (the "License"); 14348 * you may not use this file except in compliance with the License. 14349 * You may obtain a copy of the License at 14350 * 14351 * http://www.apache.org/licenses/LICENSE-2.0 14352 * 14353 * Unless required by applicable law or agreed to in writing, software 14354 * distributed under the License is distributed on an "AS IS" BASIS, 14355 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14356 * See the License for the specific language governing permissions and 14357 * limitations under the License. 14358 * ============================================================================= 14359 */const pR=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}],hR=Object.freeze(Object.defineProperty({__proto__:null,json:pR},Symbol.toStringTag,{value:"Module"}));/** 14360 * @license 14361 * Copyright 2022 Google LLC. All Rights Reserved. 14362 * Licensed under the Apache License, Version 2.0 (the "License"); 14363 * you may not use this file except in compliance with the License. 14364 * You may obtain a copy of the License at 14365 * 14366 * http://www.apache.org/licenses/LICENSE-2.0 14367 * 14368 * Unless required by applicable law or agreed to in writing, software 14369 * distributed under the License is distributed on an "AS IS" BASIS, 14370 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14371 * See the License for the specific language governing permissions and 14372 * limitations under the License. 14373 * ============================================================================= 14374 */const dR=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],fR=Object.freeze(Object.defineProperty({__proto__:null,json:dR},Symbol.toStringTag,{value:"Module"}));/** 14375 * @license 14376 * Copyright 2022 Google LLC. All Rights Reserved. 14377 * Licensed under the Apache License, Version 2.0 (the "License");
14378 * you may not use this file except in compliance with the License. 14379 * You may obtain a copy of the License at 14380 * 14381 * http://www.apache.org/licenses/LICENSE-2.0 14382 * 14383 * Unless required by applicable law or agreed to in writing, software 14384 * distributed under the License is distributed on an "AS IS" BASIS, 14385 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14386 * See the License for the specific language governing permissions and 14387 * limitations under the License. 14388 * ============================================================================= 14389 */const mR=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],gR=Object.freeze(Object.defineProperty({__proto__:null,json:mR},Symbol.toStringTag,{value:"Module"}));/** 14390 * @license 14391 * Copyright 2022 Google LLC. All Rights Reserved. 14392 * Licensed under the Apache License, Version 2.0 (the "License");
14393 * you may not use this file except in compliance with the License. 14394 * You may obtain a copy of the License at 14395 * 14396 * http://www.apache.org/licenses/LICENSE-2.0 14397 * 14398 * Unless required by applicable law or agreed to in writing, software 14399 * distributed under the License is distributed on an "AS IS" BASIS, 14400 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14401 * See the License for the specific language governing permissions and 14402 * limitations under the License. 14403 * ============================================================================= 14404 */const yR=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],xR=Object.freeze(Object.defineProperty({__proto__:null,json:yR},Symbol.toStringTag,{value:"Module"}));/** 14405 * @license 14406 * Copyright 2022 Google LLC. All Rights Reserved. 14407 * Licensed under the Apache License, Version 2.0 (the "License"); 14408 * you may not use this file except in compliance with the License. 14409 * You may obtain a copy of the License at 14410 * 14411 * http://www.apache.org/licenses/LICENSE-2.0 14412 * 14413 * Unless required by applicable law or agreed to in writing, software 14414 * distributed under the License is distributed on an "AS IS" BASIS, 14415 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14416 * See the License for the specific language governing permissions and 14417 * limitations under the License. 14418 * ============================================================================= 14419 */const bR=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],vR=Object.freeze(Object.defineProperty({__proto__:null,json:bR},Symbol.toStringTag,{value:"Module"}));/** 14420 * @license 14421 * Copyright 2022 Google LLC. All Rights Reserved. 14422 * Licensed under the Apache License, Version 2.0 (the "License"); 14423 * you may not use this file except in compliance with the License. 14424 * You may obtain a copy of the License at 14425 * 14426 * http://www.apache.org/licenses/LICENSE-2.0 14427 * 14428 * Unless required by applicable law or agreed to in writing, software 14429 * distributed under the License is distributed on an "AS IS" BASIS, 14430 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14431 * See the License for the specific language governing permissions and 14432 * limitations under the License. 14433 * ============================================================================= 14434 */const wR=[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],SR=Object.freeze(Object.defineProperty({__proto__:null,json:wR},Symbol.toStringTag,{value:"Module"}));/** 14435 * @license 14436 * Copyright 2022 Google LLC. All Rights Reserved. 14437 * Licensed under the Apache License, Version 2.0 (the "License");
14438 * you may not use this file except in compliance with the License. 14439 * You may obtain a copy of the License at 14440 * 14441 * http://www.apache.org/licenses/LICENSE-2.0 14442 * 14443 * Unless required by applicable law or agreed to in writing, software 14444 * distributed under the License is distributed on an "AS IS" BASIS, 14445 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14446 * See the License for the specific language governing permissions and 14447 * limitations under the License. 14448 * ============================================================================= 14449 */const kR=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}],TR=Object.freeze(Object.defineProperty({__proto__:null,json:kR},Symbol.toStringTag,{value:"Module"}));/** 14450 * @license 14451 * Copyright 2018 Google LLC. All Rights Reserved. 14452 * Licensed under the Apache License, Version 2.0 (the "License"); 14453 * you may not use this file except in compliance with the License. 14454 * You may obtain a copy of the License at 14455 * 14456 * http://www.apache.org/licenses/LICENSE-2.0 14457 * 14458 * Unless required by applicable law or agreed to in writing, software 14459 * distributed under the License is distributed on an "AS IS" BASIS, 14460 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14461 * See the License for the specific language governing permissions and 14462 * limitations under the License. 14463 * ============================================================================= 14464 */class wc{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[W9,G9,H9,q9,Y9,J9,eR,nR,aR,oR,uR,cR,hR,fR,gR,xR,vR,SR,TR],t=[].concat(...e.map(r=>r.json));this.opMappers=t.reduce((r,a)=>(r[a.tfOpName]=a,r),{})}transformGraph(e,t={}){const r=e.node,a=[],s=[],o=[],i=r.reduce((y,b)=>(y[b.name]=this.mapNode(b),b.op.startsWith("Placeholder")?a.push(y[b.name]):b.op==="Const"?s.push(y[b.name]):(b.input==null||b.input.length===0)&&o.push(y[b.name]),y),{});let u=[];const l=[];let c={},p={};t!=null&&(c=this.mapSignatureEntries(t.inputs),p=this.mapSignatureEntries(t.outputs));const h=Object.keys(i);h.forEach(y=>{const b=i[y];
14464b.inputNames.forEach((x,T)=>{const[$,,F]=xn(x),M=i[$];if(M.outputs!=null){const U=M.outputs.indexOf(F);if(U!==-1){const X=`${$}:${U}`;b.inputNames[T]=X}}b.inputs.push(M),M.children.push(b)})}),Object.keys(p).length===0?h.forEach(y=>{const b=i[y];b.children.length===0&&l.push(b)}):Object.keys(p).forEach(y=>{const[b]=xn(y),x=i[b];x!=null&&(x.signatureKey=p[y],l.push(x))}),Object.keys(c).length>0?Object.keys(c).forEach(y=>{const[b]=xn(y),x=i[b];x&&(x.signatureKey=c[y],u.push(x))}):u=a;let d={};e.library!=null&&e.library.function!=null&&(d=e.library.function.reduce((y,b)=>(y[b.signature.name]=this.mapFunction(b),y),{}));const m={nodes:i,inputs:u,outputs:l,weights:s,placeholders:a,signature:t,functions:d};return o.length>0&&(m.initNodes=o),m}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,r)=>(t[e[r].name]=r,t),{})}mapNode(e){const t=jm(e.op)||this.opMappers[e.op]||{};e.attr==null&&(e.attr={});const r={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map(a=>a.startsWith("^")?a.slice(1):a),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return t.inputs!=null&&(r.inputParams=t.inputs.reduce((a,s)=>(a[s.name]={type:s.type,inputIndexStart:s.start,inputIndexEnd:s.end},a),{})),t.attrs!=null&&(r.attrParams=t.attrs.reduce((a,s)=>{const o=s.type;let i;switch(s.type){case"string":i=pu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=pu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"string[]":i=xu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=xu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"number":i=du(e.attr,s.tfName,s.defaultValue||0),i===void 0&&s.tfDeprecatedName&&(i=du(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"number[]":i=yu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=yu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"bool":i=hu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=hu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"bool[]":i=vu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=vu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"shape":i=gu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=gu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"shape[]":i=bu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=bu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"dtype":i=fu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=fu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"dtype[]":i=mu(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=mu(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"func":i=Sc(e.attr,s.tfName,s.defaultValue),i===void 0&&s.tfDeprecatedName&&(i=Sc(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${s.type} for op: ${e.op}`)}return a[s.name]={value:i,type:o},a},{})),r}mapFunction(e){const t=e.nodeDef,r=[],a=[];let s={};t!=null&&(s=t.reduce((c,p)=>(c[p.name]=this.mapNode(p),p.op==="Const"&&a.push(c[p.name]),c),{}));const o=[],i=[];e.signature.inputArg.forEach(c=>{const[p]=xn(c.name),h={name:p,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:pl(c.type),type:"dtype"}},children:[]};h.signatureKey=c.name,o.push(h),s[p]=h}),Object.keys(s).forEach(c=>{const p=s[c];p.inputNames.forEach((h,d)=>{const[m,,y]=xn(h),b=s[m];if(b.outputs!=null){const x=b.outputs.indexOf(y);if(x!==-1){const T=`${m}:${x}`;p.inputNames[d]=T}}p.inputs.push(b),b.children.push(p)})});const u=e.ret;e.signature.outputArg.forEach(c=>{const[p,h]=xn(u[c.name]),d=s[p];d!=null&&(d.defaultOutput=h,i.push(d))});const l=this.mapArgsToSignature(e);return{nodes:s,inputs:o,outputs:i,weights:a,placeholders:r,signature:l}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((t,r)=>(t[r.name]=this.mapArgToTensorInfo(r),t),{}),outputs:e.signature.outputArg.reduce((t,r)=>(t[r.name]=this.mapArgToTensorInfo(r,e.ret),t),{})}}mapArgToTensorInfo(e,t){let r=e.name;return t!=null&&(r=t[r]),{name:r,dtype:e.type}}}function ER(n){const e=H().global;if(typeof e.atob<"u")return e.atob(n);if(typeof Buffer<"u")return new Buffer(n,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}function Hm(n,e){const t=Array.isArray(n)?String.fromCharCode.apply(null,n):ER(n);return e?t:t.toLowerCase()}function pu(n,e,t,r=!1){const a=n[e];return a!=null?Hm(a.s,r):t}function hu(n,e,t){const r=n[e];return r?r.b:t}function du(n,e,t){const r=n[e]||{},a=r.i!=null?r.i:r.f!=null?r.f:t;return typeof a=="number"?a:parseInt(a,10)}function pl(n){switch(typeof n=="string"&&(n=qt[n]),n){case qt.DT_FLOAT:case qt.DT_HALF:return"float32";case qt.DT_INT32:case qt.DT_INT64:case qt.DT_INT8:case qt.DT_UINT8:return"int32";case qt.DT_BOOL:return"bool";case qt.DT_DOUBLE:return"float32";case qt.DT_STRING:return"string";default:return null}}function Sc(n,e,t){const r=n[e];return r&&r.func?r.func.name:t}function fu(n,e,t){const r=n[e];return r&&r.type?pl(r.type):t}function mu(n,e,t){const r=n[e];return r&&r.list&&r.list.type?r.list.type.map(a=>pl(a)):t}function Xm(n){if(!n.unknownRank)return n.dim!=null?n.dim.map(e=>typeof e.size=="number"?e.size:parseInt(e.size,10)):[]}function gu(n,e,t){const r=n[e];return r&&r.shape?Xm(r.shape):t}function yu(n,e,t){const r=n[e];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map(a=>typeof a=="number"?a:parseInt(a,10)):t}function xu(n,e,t,r=!1){const a=n[e];return a&&a.list&&a.list.s?a.list.s.map(s=>Hm(s,r)):t}function bu(n,e,t){const r=n[e];return r&&r.list&&r.list.shape?r.list.shape.map(a=>Xm(a)):t}function vu(n,e,t){const r=n[e];return r&&r.list&&r.list.b?r.list.b:t}/** 14465 * @license 14466 * Copyright 2019 Google LLC. All Rights Reserved. 14467 * Licensed under the Apache License, Version 2.0 (the "License");
14468 * you may not use this file except in compliance with the License. 14469 * You may obtain a copy of the License at 14470 * 14471 * http://www.apache.org/licenses/LICENSE-2.0 14472 * 14473 * Unless required by applicable law or agreed to in writing, software 14474 * distributed under the License is distributed on an "AS IS" BASIS, 14475 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14476 * See the License for the specific language governing permissions and 14477 * limitations under the License. 14478 * ============================================================================= 14479 */class CR{constructor(e,t,r){this.node=e,this.tensorMap=t,this.context=r,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(a=>this.getInput(a)),e.rawAttrs!=null&&(this.attrs=Object.keys(e.rawAttrs).reduce((a,s)=>(a[s]=this.getAttr(s),a),{}))}getInput(e){return mt(e,this.tensorMap,this.context)}getAttr(e,t){const r=this.node.rawAttrs[e];if(r.tensor!=null)return mt(e,this.tensorMap,this.context);if(r.i!=null||r.f!=null)return du(this.node.rawAttrs,e,t);if(r.s!=null)return pu(this.node.rawAttrs,e,t);if(r.b!=null)return hu(this.node.rawAttrs,e,t);if(r.shape!=null)return gu(this.node.rawAttrs,e,t);if(r.type!=null)return fu(this.node.rawAttrs,e,t);if(r.list!=null){if(r.list.i!=null||r.list.f!=null)return yu(this.node.rawAttrs,e,t);if(r.list.s!=null)return xu(this.node.rawAttrs,e,t);if(r.list.shape!=null)return bu(this.node.rawAttrs,e,t);if(r.list.b!=null)return vu(this.node.rawAttrs,e,t);if(r.list.type!=null)return mu(this.node.rawAttrs,e,t)}return t}}/** 14480 * @license 14481 * Copyright 2020 Google LLC. All Rights Reserved. 14482 * Licensed under the Apache License, Version 2.0 (the "License"); 14483 * you may not use this file except in compliance with the License. 14484 * You may obtain a copy of the License at 14485 * 14486 * http://www.apache.org/licenses/LICENSE-2.0 14487 * 14488 * Unless required by applicable law or agreed to in writing, software 14489 * distributed under the License is distributed on an "AS IS" BASIS, 14490 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14491 * See the License for the specific language governing permissions and 14492 * limitations under the License. 14493 * ============================================================================= 14494 */const pt=Object.freeze(Object.defineProperty({__proto__:null,OP_SCOPE_SUFFIX:Wd,abs:Kt,acos:N0,acosh:R0,add:Pe,addN:A0,all:F0,any:M0,argMax:P0,argMin:U0,asin:W0,asinh:G0,atan:H0,atan2:q0,atanh:Y0,avgPool:$f,avgPool3d:a3,basicLSTMCell:c3,batchNorm:To,batchNorm2d:m3,batchNorm3d:y3,batchNorm4d:b3,batchToSpaceND:Rf,bincount:_f,booleanMaskAsync:Hb,broadcastArgs:S3,broadcastTo:Qa,buffer:He,cast:je,ceil:E3,clipByValue:Af,clone:Jn,complex:tr,concat:it,concat1d:N3,concat2d:R3,concat3d:A3,concat4d:F3,conv1d:L3,conv2d:Co,conv2dTranspose:U3,conv3d:W3,conv3dTranspose:H3,cos:q3,cosh:Y3,cosineWindow:Zu,cumprod:J3,cumsum:ey,denseBincount:ny,depthToSpace:ay,depthwiseConv2d:Uu,diag:iy,dilation2d:ly,div:De,divNoNan:fy,dot:gy,dropout:av,einsum:xy,elu:Df,enclosingPowerOfTwo:u1,equal:Ff,erf:wy,euclideanNorm:Ry,exp:Fn,expandDims:on,expm1:Fy,eye:Pf,fft:Ku,fill:Eo,floor:Bf,floorDiv:If,fused:bv,gather:Uf,gatherND:tv,greater:$o,greaterEqual:Vf,ifft:uo,imag:ko,image:va,inTopKAsync:ov,irfft:r1,isFinite:Wy,isInf:Gy,isNaN:Hy,leakyRelu:Wf,less:Ky,lessEqual:ju,linalg:qw,linspace:Zy,localResponseNormalization:Qy,log:as,log1p:zf,logSigmoid:ax,logSoftmax:ix,logSumExp:jf,logicalAnd:oo,logicalNot:Hf,logicalOr:Xf,logicalXor:dx,losses:Kw,lowerBound:mx,matMul:Oe,max:oa,maxPool:qf,maxPool3d:xx,maxPoolWithArgmax:vx,maximum:Sx,mean:io,meshgrid:Tx,min:Yi,minimum:Kf,mirrorPad:Ix,mod:$x,moments:_x,movingAverage:qb,mul:me,multiRNNCell:Ox,multinomial:Dx,neg:An,norm:No,notEqual:Yf,oneHot:c0,ones:Cr,onesLike:Px,op:P,outerProduct:Ux,pad:ms,pad1d:zx,pad2d:jx,pad3d:Xx,pad4d:Kx,pool:e4,pow:Gu,prelu:Jf,print:ef,prod:r4,raggedGather:s4,raggedTensorToTensor:i4,rand:l4,randomGamma:N4,randomNormal:Qf,randomStandardNormal:_4,randomUniform:e1,range:ss,real:ns,reciprocal:F4,relu:Ro,relu6:t1,reshape:Z,reverse:Dr,reverse1d:B4,reverse2d:V4,reverse3d:z4,reverse4d:j4,rfft:Yu,round:n1,rsqrt:q4,scalar:Ae,scatterND:Yb,searchSorted:Hu,selu:Y4,separableConv2d:J4,setdiff1dAsync:eb,sigmoid:Rr,sign:nb,signal:Xw,sin:ab,sinh:ob,slice:we,slice1d:ub,slice2d:cb,slice3d:hb,slice4d:fb,softmax:gb,softplus:Gf,spaceToBatchND:Zf,sparse:Yw,sparseToDense:Qb,spectral:Hw,split:os,sqrt:Zi,square:Io,squaredDifference:a1,squeeze:tt,stack:Mn,step:s1,stridedSlice:Ib,string:Zw,sub:Ce,sum:Ve,tan:$b,tanh:Ki,tensor:vn,tensor1d:gt,tensor2d:Qn,tensor3d:lf,tensor4d:Rb,tensor5d:_b,tensor6d:Ab,tile:es,topk:Fb,transpose:Hi,truncatedNormal:Mb,unique:Pb,unsortedSegmentSum:Ub,unstack:Br,upperBound:Wb,variable:zb,where:ha,whereAsync:i1,zeros:Fr,zerosLike:Vu},Symbol.toStringTag,{value:"Module"}));/** 14495 * @license 14496 * Copyright 2018 Google LLC. All Rights Reserved. 14497 * Licensed under the Apache License, Version 2.0 (the "License");
14498 * you may not use this file except in compliance with the License. 14499 * You may obtain a copy of the License at 14500 * 14501 * http://www.apache.org/licenses/LICENSE-2.0 14502 * 14503 * Unless required by applicable law or agreed to in writing, software 14504 * distributed under the License is distributed on an "AS IS" BASIS, 14505 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14506 * See the License for the specific language governing permissions and 14507 * limitations under the License. 14508 * ============================================================================= 14509 */const IR=(n,e,t,r=pt)=>{switch(n.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(w("a",n,e,t),w("b",n,e,t))];case"AddN":return[r.addN(w("tensors",n,e,t))];case"FloorMod":case"Mod":return[r.mod(w("a",n,e,t),w("b",n,e,t))];case"Mul":return[r.mul(w("a",n,e,t),w("b",n,e,t))];case"RealDiv":case"Div":return[r.div(w("a",n,e,t),w("b",n,e,t))];case"DivNoNan":return[r.divNoNan(w("a",n,e,t),w("b",n,e,t))];case"FloorDiv":return[r.floorDiv(w("a",n,e,t),w("b",n,e,t))];case"Sub":return[r.sub(w("a",n,e,t),w("b",n,e,t))];case"Minimum":return[r.minimum(w("a",n,e,t),w("b",n,e,t))];case"Maximum":return[r.maximum(w("a",n,e,t),w("b",n,e,t))];case"Pow":return[r.pow(w("a",n,e,t),w("b",n,e,t))];case"SquaredDifference":return[r.squaredDifference(w("a",n,e,t),w("b",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14510 * @license 14511 * Copyright 2018 Google LLC. All Rights Reserved. 14512 * Licensed under the Apache License, Version 2.0 (the "License"); 14513 * you may not use this file except in compliance with the License. 14514 * You may obtain a copy of the License at 14515 * 14516 * http://www.apache.org/licenses/LICENSE-2.0 14517 * 14518 * Unless required by applicable law or agreed to in writing, software 14519 * distributed under the License is distributed on an "AS IS" BASIS, 14520 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14521 * See the License for the specific language governing permissions and 14522 * limitations under the License. 14523 * ============================================================================= 14524 */const NR=(n,e,t,r=pt)=>{switch(n.op){case"Abs":case"ComplexAbs":return[r.abs(w("x",n,e,t))];case"Acos":return[r.acos(w("x",n,e,t))];case"Acosh":return[r.acosh(w("x",n,e,t))];case"Asin":return[r.asin(w("x",n,e,t))];case"Asinh":return[r.asinh(w("x",n,e,t))];case"Atan":return[r.atan(w("x",n,e,t))];case"Atan2":return[r.atan2(w("x",n,e,t),w("y",n,e,t))];case"Atanh":return[r.atanh(w("x",n,e,t))];case"Ceil":return[r.ceil(w("x",n,e,t))];case"Complex":return[r.complex(w("real",n,e,t),w("imag",n,e,t))];case"Cos":return[r.cos(w("x",n,e,t))];case"Cosh":return[r.cosh(w("x",n,e,t))];case"Elu":return[r.elu(w("x",n,e,t))];case"Erf":return[r.erf(w("x",n,e,t))];case"Exp":return[r.exp(w("x",n,e,t))];case"Expm1":return[r.expm1(w("x",n,e,t))];case"Floor":return[r.floor(w("x",n,e,t))];case"Log":return[r.log(w("x",n,e,t))];case"Log1p":return[r.log1p(w("x",n,e,t))];case"Imag":return[r.imag(w("x",n,e,t))];case"Neg":return[r.neg(w("x",n,e,t))];case"Reciprocal":return[r.reciprocal(w("x",n,e,t))];case"Real":return[r.real(w("x",n,e,t))];case"Relu":return[r.relu(w("x",n,e,t))];case"Round":return[r.round(w("x",n,e,t))];case"Selu":return[r.selu(w("x",n,e,t))];case"Sigmoid":return[r.sigmoid(w("x",n,e,t))];case"Sin":return[r.sin(w("x",n,e,t))];case"Sign":return[r.sign(w("x",n,e,t))];case"Sinh":return[r.sinh(w("x",n,e,t))];case"Softplus":return[r.softplus(w("x",n,e,t))];case"Sqrt":return[r.sqrt(w("x",n,e,t))];case"Square":return[r.square(w("x",n,e,t))];case"Tanh":return[r.tanh(w("x",n,e,t))];case"Tan":return[r.tan(w("x",n,e,t))];case"ClipByValue":return[r.clipByValue(w("x",n,e,t),w("clipValueMin",n,e,t),w("clipValueMax",n,e,t))];case"Relu6":return[r.relu6(w("x",n,e,t))];case"Rsqrt":return[r.rsqrt(mt(n.inputNames[0],e,t))];case"Prod":return[r.prod(w("x",n,e,t),w("axes",n,e,t))];case"LeakyRelu":return[r.leakyRelu(w("x",n,e,t),w("alpha",n,e,t))];case"Prelu":return[r.prelu(w("x",n,e,t),w("alpha",n,e,t))];case"IsNan":return[r.isNaN(mt(n.inputNames[0],e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14525 * @license 14526 * Copyright 2020 Google LLC. All Rights Reserved. 14527 * Licensed under the Apache License, Version 2.0 (the "License");
14528 * you may not use this file except in compliance with the License. 14529 * You may obtain a copy of the License at 14530 * 14531 * http://www.apache.org/licenses/LICENSE-2.0 14532 * 14533 * Unless required by applicable law or agreed to in writing, software 14534 * distributed under the License is distributed on an "AS IS" BASIS, 14535 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14536 * See the License for the specific language governing permissions and 14537 * limitations under the License. 14538 * ============================================================================= 14539 */function Yt(n,e,t=""){if(!(typeof n=="number"||typeof e=="number")){R(n.length===e.length,()=>t+` Shapes ${n} and ${e} must match`);for(let r=0;r<n.length;r++){const a=n[r],s=e[r];R(a<0||s<0||a===s,()=>t+` Shapes ${n} and ${e} must match`)}}}function kc(n){return!(typeof n=="number"||n.some(e=>e<0))}function qa(n,e,t){let r=wu(n,t);const a=!kc(r);if(a&&e.length===0)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&e.forEach(s=>{r=wu(s.shape,r)}),!kc(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function wu(n,e){if(typeof n=="number")return e;if(typeof e=="number")return n;if(n.length!==e.length)throw new Error(`Incompatible ranks during merge: ${n} vs. ${e}`);const t=[];for(let r=0;r<n.length;++r){const a=n[r],s=e[r];if(a>=0&&s>=0&&a!==s)throw new Error(`Incompatible shape during merge: ${n} vs. ${e}`);t[r]=a>=0?a:s}return t}/** 14540 * @license 14541 * Copyright 2018 Google LLC. All Rights Reserved. 14542 * Licensed under the Apache License, Version 2.0 (the "License"); 14543 * you may not use this file except in compliance with the License. 14544 * You may obtain a copy of the License at 14545 * 14546 * http://www.apache.org/licenses/LICENSE-2.0 14547 * 14548 * Unless required by applicable law or agreed to in writing, software 14549 * distributed under the License is distributed on an "AS IS" BASIS, 14550 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14551 * See the License for the specific language governing permissions and 14552 * limitations under the License. 14553 * ============================================================================= 14554 */class $R{constructor(e,t,r,a,s,o,i){this.name=e,this.dtype=t,this.maxSize=r,this.elementShape=a,this.identicalElementShapes=s,this.dynamicSize=o,this.clearAfterRead=i,this.tensors=[],this.closed_=!1,this.idTensor=Ae(0),Yn(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach(t=>{(e==null||!e.has(t.tensor.id))&&t.tensor.dispose()}),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map(t=>this.read(t))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const r=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, 14555 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),Yt(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),r.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(r.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);r.tensor=t,Yn(t),r.written=!0,this.tensors[e]=r}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((r,a)=>this.write(r,t[a]))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let a=0;a<this.size();
14555a++)e.push(a)}if(e.length===0)return vn([],[0].concat(this.elementShape));const r=this.readMany(e);return Yt(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),Mn(r,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 vn([],[0].concat(this.elementShape));const t=[];for(let a=0;a<this.size();a++)t.push(a);const r=this.readMany(t);return Yt(this.elementShape,r[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${r[0].shape})`),it(r,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]}`);const r=Math.max(...e);if(!this.dynamicSize&&r>=this.maxSize)throw new Error(`Max index must be < array size (${r} vs. ${this.maxSize})`);this.writeMany(e,Br(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 r=0;const a=e.map(u=>(r+=u,r));if(r!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to 14556 tensor.shape[0], but sum of lengths is 14557 ${r}, 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`);const s=r===0?0:t.size/r,o=[];Xe(()=>{t=Z(t,[1,r,s]);for(let u=0;u<e.length;++u){const l=[0,u===0?0:a[u-1],0],c=[1,e[u],s];o[u]=Z(we(t,l,c),this.elementShape)}return o});const i=[];for(let u=0;u<e.length;u++)i[u]=u;this.writeMany(i,o)}}/** 14558 * @license 14559 * Copyright 2020 Google LLC. All Rights Reserved. 14560 * Licensed under the Apache License, Version 2.0 (the "License"); 14561 * you may not use this file except in compliance with the License. 14562 * You may obtain a copy of the License at 14563 * 14564 * http://www.apache.org/licenses/LICENSE-2.0 14565 * 14566 * Unless required by applicable law or agreed to in writing, software 14567 * distributed under the License is distributed on an "AS IS" BASIS, 14568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14569 * See the License for the specific language governing permissions and 14570 * limitations under the License. 14571 * ============================================================================= 14572 */class Lr{constructor(e,t,r,a=-1){this.tensors=e,this.elementShape=t,this.elementDtype=r,e!=null&&e.forEach(s=>{if(r!==s.dtype)throw new Error(`Invalid data types; op elements ${r}, but list elements ${s.dtype}`);Yt(t,s.shape,"TensorList shape mismatch: "),Yn(s)}),this.idTensor=Ae(0),this.maxNumElements=a,Yn(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Lr([...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,r=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(r!==-1&&this.tensors.length!==r)throw new Error(`Operation expected a list with ${r} elements but got a list with ${this.tensors.length} elements.`);Yt(e,this.elementShape,"TensorList shape mismatch: ");const a=qa(this.elementShape,this.tensors,e);return Xe(()=>{const s=this.tensors.map(o=>Z(o,a));return Mn(s,0)})}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(this.size()===0)throw new Error("Trying to pop from an empty list.");const r=qa(this.elementShape,this.tensors,e),a=this.tensors.pop();return a.kept=!1,Yt(a.shape,e,"TensorList shape mismatch: "),Z(a,r)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(Yt(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");Yn(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}.`);const t=new Lr([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let r=0;r<Math.min(this.tensors.length,e);++r)t.tensors[r]=this.tensors[r];return t}getItem(e,t,r){if(r!==this.elementDtype)throw new Error(`Invalid data types; op elements ${r}, 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.`);Yt(this.tensors[e].shape,t,"TensorList shape mismatch: ");const a=qa(this.elementShape,this.tensors,t);return Z(this.tensors[e],a)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||this.maxNumElements!==-1&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);Yt(this.elementShape,t.shape,"TensorList shape mismatch: "),Yn(t),this.tensors[e]!=null&&(this.tensors[e].kept=!1),this.tensors[e]=t}gather(e,t,r){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);Yt(this.elementShape,r,"TensorList shape mismatch: "),e=e.slice(0,this.size());const a=qa(this.elementShape,this.tensors,r);return e.length===0?vn([],[0].concat(a)):Xe(()=>{const s=e.map(o=>Z(this.tensors[o],a));return Mn(s,0)})}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);Yt(this.elementShape,t,"TensorList shape mismatch: ");const r=qa(this.elementShape,this.tensors,t);return this.size()===0?vn([],[0].concat(r)):Xe(()=>{const a=this.tensors.map(s=>Z(s,r));return it(a,0)})}}function RR(n,e,t){const r=n.dtype;if(n.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${n.shape}`);if(n.dtype!==t)throw new Error(`Invalid data types; op elements ${n.dtype}, but list elements ${t}`);const a=n.shape.slice(1);Yt(a,e,"TensorList shape mismatch: ");const s=Br(n);return new Lr(s,e,r)}function _R(n,e,t,r){return new Lr([],n,e,r)}function AR(n,e,t,r){if(e.length!==n.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${n.shape[0]}`);const a=Math.max(...e);if(r!=null&&r!==-1&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);
14572const s=new Lr([],t,n.dtype,r),o=Br(n,0);return e.forEach((i,u)=>{s.setItem(i,o[u])}),s}function OR(n,e,t){let r=0;const a=e.map(c=>(r+=c,r));if(r!==n.shape[0])throw new Error(`Expected sum of lengths to be equal to 14573 tensor.shape[0], but sum of lengths is 14574 ${r}, and tensor's shape is: ${n.shape}`);const s=n.shape.slice(1),o=wu(s,t),i=r===0?0:n.size/r,u=Xe(()=>{const c=[];n=Z(n,[1,r,i]);for(let p=0;p<e.length;++p){const h=[0,p===0?0:a[p-1],0],d=[1,e[p],i];c[p]=Z(we(n,h,d),o)}return n.dispose(),c}),l=new Lr([],t,n.dtype,e.length);for(let c=0;c<u.length;c++)l.setItem(c,u[c]);return l}/** 14575 * @license 14576 * Copyright 2018 Google LLC. All Rights Reserved. 14577 * Licensed under the Apache License, Version 2.0 (the "License"); 14578 * you may not use this file except in compliance with the License. 14579 * You may obtain a copy of the License at 14580 * 14581 * http://www.apache.org/licenses/LICENSE-2.0 14582 * 14583 * Unless required by applicable law or agreed to in writing, software 14584 * distributed under the License is distributed on an "AS IS" BASIS, 14585 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14586 * See the License for the specific language governing permissions and 14587 * limitations under the License. 14588 * ============================================================================= 14589 */const FR=async(n,e,t)=>{switch(n.op){case"If":case"StatelessIf":{const r=w("thenBranch",n,e,t),a=w("elseBranch",n,e,t),s=w("cond",n,e,t),o=w("args",n,e,t);return(await s.data())[0]?t.functionMap[r].executeFunctionAsync(o,t.tensorArrayMap,t.tensorListMap):t.functionMap[a].executeFunctionAsync(o,t.tensorArrayMap,t.tensorListMap)}case"While":case"StatelessWhile":{const r=w("body",n,e,t),a=w("cond",n,e,t),s=w("args",n,e,t),o=await t.functionMap[a].executeFunctionAsync(s,t.tensorArrayMap,t.tensorListMap),i=s.map(c=>c.id);let u=await o[0].data();o.forEach(c=>{!c.kept&&i.indexOf(c.id)===-1&&c.dispose()});let l=s;for(;u[0];){const c=l;l=await t.functionMap[r].executeFunctionAsync(l,t.tensorArrayMap,t.tensorListMap);const p=l.map(d=>d.id);c.forEach(d=>{!d.kept&&i.indexOf(d.id)===-1&&p.indexOf(d.id)===-1&&d.dispose()});const h=await t.functionMap[a].executeFunctionAsync(l,t.tensorArrayMap,t.tensorListMap);u=await h[0].data(),h.forEach(d=>{!d.kept&&i.indexOf(d.id)===-1&&p.indexOf(d.id)===-1&&d.dispose()})}return l}case"LoopCond":{const r=w("pred",n,e,t);return[In(r)]}case"Switch":{const r=w("pred",n,e,t);let a=w("data",n,e,t);return a.kept||(a=In(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=n.inputNames.find(a=>mt(a,e,t)!==void 0);if(r){const a=mt(r,e,t);return[In(a)]}return}case"Enter":{const r=w("frameName",n,e,t),a=w("tensor",n,e,t);return t.enterFrame(r),[In(a)]}case"Exit":{const r=w("tensor",n,e,t);return t.exitFrame(),[In(r)]}case"NextIteration":{const r=w("tensor",n,e,t);return t.nextIteration(),[In(r)]}case"TensorArrayV3":{const r=w("size",n,e,t),a=w("dtype",n,e,t),s=w("elementShape",n,e,t),o=w("dynamicSize",n,e,t),i=w("clearAfterRead",n,e,t),u=w("identicalElementShapes",n,e,t),l=w("name",n,e,t),c=new $R(l,a,r,s,u,o,i);return t.addTensorArray(c),[c.idTensor,Ae(1)]}case"TensorArrayWriteV3":{const r=w("tensorArrayId",n,e,t),a=w("index",n,e,t),s=w("tensor",n,e,t),o=t.getTensorArray(r.id);return o.write(a,s),[o.idTensor]}case"TensorArrayReadV3":{const r=w("tensorArrayId",n,e,t),a=w("index",n,e,t);return[t.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=w("tensorArrayId",n,e,t),a=w("indices",n,e,t),s=w("dtype",n,e,t);return[t.getTensorArray(r.id).gather(a,s)]}case"TensorArrayScatterV3":{const r=w("tensorArrayId",n,e,t),a=w("indices",n,e,t),s=w("tensor",n,e,t),o=t.getTensorArray(r.id);return o.scatter(a,s),[o.idTensor]}case"TensorArrayConcatV3":{const r=w("tensorArrayId",n,e,t),a=t.getTensorArray(r.id),s=w("dtype",n,e,t);return[a.concat(s)]}case"TensorArraySplitV3":{const r=w("tensorArrayId",n,e,t),a=w("tensor",n,e,t),s=w("lengths",n,e,t),o=t.getTensorArray(r.id);return o.split(s,a),[o.idTensor]}case"TensorArraySizeV3":{const r=w("tensorArrayId",n,e,t),a=t.getTensorArray(r.id);return[Ae(a.size(),"int32")]}case"TensorArrayCloseV3":{const r=w("tensorArrayId",n,e,t),a=t.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=w("tensorListId",n,e,t),a=w("index",n,e,t),s=w("tensor",n,e,t),o=t.getTensorList(r.id);return o.setItem(a,s),[o.idTensor]}case"TensorListGetItem":{const r=w("tensorListId",n,e,t),a=w("index",n,e,t),s=w("elementShape",n,e,t),o=w("elementDType",n,e,t);return[t.getTensorList(r.id).getItem(a,s,o)]}case"TensorListScatterV2":case"TensorListScatter":{const r=w("indices",n,e,t),a=w("tensor",n,e,t),s=w("elementShape",n,e,t),o=w("numElements",n,e,t),i=AR(a,r,s,o);return t.addTensorList(i),[i.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=w("elementShape",n,e,t),a=w("elementDType",n,e,t);let s;n.op==="TensorListReserve"?s="numElements":s="maxNumElements";const o=w(s,n,e,t),i=n.op==="TensorListReserve"?-1:o,u=_R(r,a,o,i);return t.addTensorList(u),[u.idTensor]}case"TensorListGather":{const r=w("tensorListId",n,e,t),a=w("indices",n,e,t),s=w("elementShape",n,e,t),o=w("elementDType",n,e,t);return[t.getTensorList(r.id).gather(a,o,s)]}case"TensorListStack":{const r=w("tensorListId",n,e,t),a=w("elementShape",n,e,t),s=w("elementDType",n,e,t),o=w("numElements",n,e,t);return[t.getTensorList(r.id).stack(a,s,o)]}case"TensorListFromTensor":{const r=w("tensor",n,e,t),a=w("elementShape",n,e,t),s=w("elementDType",n,e,t),o=RR(r,a,s);return t.addTensorList(o),[o.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=w("tensorListId",n,e,t),a=t.getTensorList(r.id),s=w("dtype",n,e,t),o=w("elementShape",n,e,t);return[a.concat(s,o)]}case"TensorListPushBack":{const r=w("tensorListId",n,e,t),a=w("tensor",n,e,t),s=t.getTensorList(r.id);return s.pushBack(a),[s.idTensor]}case"TensorListPopBack":{const r=w("tensorListId",n,e,t),a=w("elementShape",n,e,t),s=w("elementDType",n,e,t);return[t.getTensorList(r.id).popBack(a,s)]}case"TensorListSplit":{const r=w("tensor",n,e,t),a=w("elementShape",n,e,t),s=w("lengths",n,e,t),o=OR(r,s,a);return t.addTensorList(o),[o.idTensor]}case"TensorListLength":{const r=w("tensorListId",n,e,t),a=t.getTensorList(r.id);return[Ae(a.size(),"int32")]}case"TensorListResize":{const r=w("tensorListId",n,e,t),a=w("size",n,e,t),s=t.getTensorList(r.id).resize(a);return t.addTensorList(s),[s.idTensor]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14590 * @license 14591 * Copyright 2018 Google LLC. All Rights Reserved. 14592 * Licensed under the Apache License, Version 2.0 (the "License");
14593 * you may not use this file except in compliance with the License. 14594 * You may obtain a copy of the License at 14595 * 14596 * http://www.apache.org/licenses/LICENSE-2.0 14597 * 14598 * Unless required by applicable law or agreed to in writing, software 14599 * distributed under the License is distributed on an "AS IS" BASIS, 14600 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14601 * See the License for the specific language governing permissions and 14602 * limitations under the License. 14603 * ============================================================================= 14604 */function Tc(n,e,t){const[r,a]=w("fusedOps",n,e,t),s=r==="biasadd",o=!s,i=a==="prelu",u=r==="fusedbatchnorm",l=w("numArgs",n,e,t);if(s){if(i&&l!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&s&&l!==1)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=w("strides",n,e,t),p=Qs(n,e,t),h=w("dataFormat",n,e,t).toUpperCase(),d=w("dilations",n,e,t);let[m,y]=w("args",n,e,t);o&&(y=m,m=void 0);const b=w("leakyreluAlpha",n,e,t);return{stride:c,pad:p,dataFormat:h,dilations:d,biasArg:m,preluArg:y,activationFunc:a,leakyreluAlpha:b}}const DR=(n,e,t,r=pt)=>{switch(n.op){case"Conv1D":{const a=w("stride",n,e,t),s=w("pad",n,e,t),o=w("dataFormat",n,e,t).toUpperCase(),i=w("dilation",n,e,t);return[r.conv1d(w("x",n,e,t),w("filter",n,e,t),a,s,o,i)]}case"Conv2D":{const a=w("strides",n,e,t),s=Qs(n,e,t),o=w("dataFormat",n,e,t).toUpperCase(),i=w("dilations",n,e,t);return[r.conv2d(w("x",n,e,t),w("filter",n,e,t),[a[1],a[2]],s,o,[i[1],i[2]])]}case"_FusedConv2D":{const{stride:a,pad:s,dataFormat:o,dilations:i,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=Tc(n,e,t);return[r.fused.conv2d({x:w("x",n,e,t),filter:w("filter",n,e,t),strides:[a[1],a[2]],pad:s,dataFormat:o,dilations:[i[1],i[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:s,dataFormat:o,dilations:i,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=Tc(n,e,t);return[r.fused.depthwiseConv2d({x:w("x",n,e,t),filter:w("filter",n,e,t),strides:[a[1],a[2]],pad:s,dataFormat:o,dilations:[i[1],i[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=w("outputShape",n,e,t),s=w("strides",n,e,t),o=Qs(n,e,t);return[r.conv2dTranspose(w("x",n,e,t),w("filter",n,e,t),a,[s[1],s[2]],o)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=w("strides",n,e,t),s=Qs(n,e,t),o=w("dilations",n,e,t),i=w("dataFormat",n,e,t).toUpperCase();return[r.depthwiseConv2d(w("input",n,e,t),w("filter",n,e,t),[a[1],a[2]],s,i,[o[1],o[2]])]}case"Conv3D":{const a=w("strides",n,e,t),s=w("pad",n,e,t),o=w("dataFormat",n,e,t).toUpperCase(),i=w("dilations",n,e,t);return[r.conv3d(w("x",n,e,t),w("filter",n,e,t),[a[1],a[2],a[3]],s,o,[i[1],i[2],i[3]])]}case"AvgPool":{const a=w("strides",n,e,t),s=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[r.avgPool(w("x",n,e,t),[o[1],o[2]],[a[1],a[2]],s)]}case"MaxPool":{const a=w("strides",n,e,t),s=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[r.maxPool(w("x",n,e,t),[o[1],o[2]],[a[1],a[2]],s)]}case"MaxPoolWithArgmax":{const a=w("strides",n,e,t),s=w("pad",n,e,t),o=w("kernelSize",n,e,t),i=w("includeBatchInIndex",n,e,t),{result:u,indexes:l}=r.maxPoolWithArgmax(w("x",n,e,t),[o[1],o[2]],[a[1],a[2]],s,i);return[u,l]}case"AvgPool3D":{const a=w("strides",n,e,t),s=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[r.avgPool3d(w("x",n,e,t),[o[1],o[2],o[3]],[a[1],a[2],a[3]],s)]}case"MaxPool3D":{const a=w("strides",n,e,t),s=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[r.maxPool3d(w("x",n,e,t),[o[1],o[2],o[3]],[a[1],a[2],a[3]],s)]}case"Dilation2D":{const a=w("strides",n,e,t),s=w("pad",n,e,t),o=w("dilations",n,e,t),i=a[1],u=a[2],l=o[1],c=o[2];return[r.dilation2d(w("x",n,e,t),w("filter",n,e,t),[i,u],s,[l,c],"NHWC")]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14605 * @license 14606 * Copyright 2018 Google LLC. All Rights Reserved. 14607 * Licensed under the Apache License, Version 2.0 (the "License");
14608 * you may not use this file except in compliance with the License. 14609 * You may obtain a copy of the License at 14610 * 14611 * http://www.apache.org/licenses/LICENSE-2.0 14612 * 14613 * Unless required by applicable law or agreed to in writing, software 14614 * distributed under the License is distributed on an "AS IS" BASIS, 14615 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14616 * See the License for the specific language governing permissions and 14617 * limitations under the License. 14618 * ============================================================================= 14619 */const MR=(n,e,t,r=pt)=>{switch(n.op){case"Fill":{const a=w("shape",n,e,t),s=w("dtype",n,e,t),o=w("value",n,e,t);return[r.fill(a,o,s)]}case"LinSpace":{const a=w("start",n,e,t),s=w("stop",n,e,t),o=w("num",n,e,t);return[r.linspace(a,s,o)]}case"Multinomial":{const a=w("logits",n,e,t),s=w("numSamples",n,e,t),o=w("seed",n,e,t);return[r.multinomial(a,s,o)]}case"OneHot":{const a=w("indices",n,e,t),s=w("depth",n,e,t),o=w("onValue",n,e,t),i=w("offValue",n,e,t),u=w("dtype",n,e,t);return[r.oneHot(a,s,o,i,u)]}case"Ones":return[r.ones(w("shape",n,e,t),w("dtype",n,e,t))];case"OnesLike":return[r.onesLike(w("x",n,e,t))];case"RandomStandardNormal":return[r.randomStandardNormal(w("shape",n,e,t),w("dtype",n,e,t),w("seed",n,e,t))];case"RandomUniform":return[r.randomUniform(w("shape",n,e,t),w("minval",n,e,t),w("maxval",n,e,t),w("dtype",n,e,t))];case"Range":{const a=w("start",n,e,t),s=w("stop",n,e,t),o=w("step",n,e,t);return[r.range(a,s,o,w("dtype",n,e,t))]}case"TruncatedNormal":{const a=w("shape",n,e,t),s=w("mean",n,e,t),o=w("stdDev",n,e,t),i=w("seed",n,e,t);return[r.truncatedNormal(a,s,o,w("dtype",n,e,t),i)]}case"Zeros":return[r.zeros(w("shape",n,e,t),w("dtype",n,e,t))];case"ZerosLike":return[r.zerosLike(w("x",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14620 * @license 14621 * Copyright 2018 Google LLC. All Rights Reserved. 14622 * Licensed under the Apache License, Version 2.0 (the "License"); 14623 * you may not use this file except in compliance with the License. 14624 * You may obtain a copy of the License at 14625 * 14626 * http://www.apache.org/licenses/LICENSE-2.0 14627 * 14628 * Unless required by applicable law or agreed to in writing, software 14629 * distributed under the License is distributed on an "AS IS" BASIS, 14630 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14631 * See the License for the specific language governing permissions and 14632 * limitations under the License. 14633 * ============================================================================= 14634 */function mi(n,e,t){const r=w("boxes",n,e,t),a=w("scores",n,e,t),s=w("maxOutputSize",n,e,t),o=w("iouThreshold",n,e,t),i=w("scoreThreshold",n,e,t),u=w("softNmsSigma",n,e,t);return{boxes:r,scores:a,maxOutputSize:s,iouThreshold:o,scoreThreshold:i,softNmsSigma:u}}const LR=async(n,e,t,r,a=pt)=>{switch(n.op){case"NonMaxSuppressionV5":{const{boxes:s,scores:o,maxOutputSize:i,iouThreshold:u,scoreThreshold:l,softNmsSigma:c}=mi(n,e,t),p=await a.image.nonMaxSuppressionWithScoreAsync(s,o,i,u,l,c);return[p.selectedIndices,p.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:s,scores:o,maxOutputSize:i,iouThreshold:u,scoreThreshold:l}=mi(n,e,t),c=w("padToMaxOutputSize",n,e,t),p=await a.image.nonMaxSuppressionPaddedAsync(s,o,i,u,l,c);return[p.selectedIndices,p.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:s,scores:o,maxOutputSize:i,iouThreshold:u,scoreThreshold:l}=mi(n,e,t);return[await a.image.nonMaxSuppressionAsync(s,o,i,u,l)]}case"Where":{const s=a.cast(w("condition",n,e,t),"bool"),o=[await a.whereAsync(s)];return s.dispose(),o}case"ListDiff":return a.setdiff1dAsync(w("x",n,e,t),w("y",n,e,t));default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14635 * @license 14636 * Copyright 2018 Google LLC. All Rights Reserved. 14637 * Licensed under the Apache License, Version 2.0 (the "License"); 14638 * you may not use this file except in compliance with the License. 14639 * You may obtain a copy of the License at 14640 * 14641 * http://www.apache.org/licenses/LICENSE-2.0 14642 * 14643 * Unless required by applicable law or agreed to in writing, softw
14643are 14644 * distributed under the License is distributed on an "AS IS" BASIS, 14645 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14646 * See the License for the specific language governing permissions and 14647 * limitations under the License. 14648 * ============================================================================= 14649 */const PR=(n,e,t,r=pt)=>{switch(n.op){case"LowerBound":{const a=w("sortedSequence",n,e,t),s=w("values",n,e,t);return[r.lowerBound(a,s)]}case"TopKV2":{const a=w("x",n,e,t),s=w("k",n,e,t),o=w("sorted",n,e,t),i=r.topk(a,s,o);return[i.values,i.indices]}case"UpperBound":{const a=w("sortedSequence",n,e,t),s=w("values",n,e,t);return[r.upperBound(a,s)]}case"Unique":{const a=w("x",n,e,t),s=r.unique(a);return[s.values,s.indices]}case"UniqueV2":{const a=w("x",n,e,t),s=w("axis",n,e,t),o=r.unique(a,s);return[o.values,o.indices]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14650 * @license 14651 * Copyright 2018 Google LLC. All Rights Reserved. 14652 * Licensed under the Apache License, Version 2.0 (the "License"); 14653 * you may not use this file except in compliance with the License. 14654 * You may obtain a copy of the License at 14655 * 14656 * http://www.apache.org/licenses/LICENSE-2.0 14657 * 14658 * Unless required by applicable law or agreed to in writing, software 14659 * distributed under the License is distributed on an "AS IS" BASIS, 14660 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14661 * See the License for the specific language governing permissions and 14662 * limitations under the License. 14663 * ============================================================================= 14664 */const BR=(n,e,t,r=pt)=>{switch(n.op){case"Const":return e[n.name];case"PlaceholderWithDefault":const a=w("default",n,e,t);return[mt(n.name,e,t)||a];case"Placeholder":return[mt(n.name,e,t)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{const c=w("x",n,e,t);return[In(c)]}case"IdentityN":return w("x",n,e,t).map(c=>In(c));case"Snapshot":const s=w("x",n,e,t);return[In(s)];case"Shape":return[r.tensor1d(w("x",n,e,t).shape,"int32")];case"ShapeN":return w("x",n,e,t).map(c=>r.tensor1d(c.shape));case"Size":return[r.scalar(w("x",n,e,t).size,"int32")];case"Rank":return[r.scalar(w("x",n,e,t).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const o=w("x",n,e,t),i=w("data",n,e,t),u=w("message",n,e,t),l=w("summarize",n,e,t);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(u);for(let c=0;c<i.length;c++)console.log(Array.prototype.slice.call(i[c].dataSync()).slice(0,l));return[o];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14665 * @license 14666 * Copyright 2020 Google LLC. All Rights Reserved. 14667 * Licensed under the Apache License, Version 2.0 (the "License"); 14668 * you may not use this file except in compliance with the License. 14669 * You may obtain a copy of the License at 14670 * 14671 * http://www.apache.org/licenses/LICENSE-2.0 14672 * 14673 * Unless required by applicable law or agreed to in writing, software 14674 * distributed under the License is distributed on an "AS IS" BASIS, 14675 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14676 * See the License for the specific language governing permissions and 14677 * limitations under the License. 14678 * ============================================================================= 14679 */class UR{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Ae(0),this.tensorMap=new Map,Yn(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Ae(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const r=await e.data();return this.tensorMap.forEach(a=>a.dispose()),this.tensorMap.clear(),Xe(()=>{const a=Br(t),s=r.length,o=a.length;R(s===o,()=>`The number of elements doesn't match, keys has ${s} elements, the values has ${o} elements.`);for(let i=0;i<s;i++){const u=r[i],l=a[i];Yn(l),this.tensorMap.set(u,l)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);const r=await e.data();return Xe(()=>{const a=[];for(let s=0;s<r.length;s++){const o=r[s],i=this.findWithDefault(o,t);a.push(i)}return Mn(a)})}findWithDefault(e,t){return this.tensorMap.get(e)??t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}}/** 14680 * @license 14681 * Copyright 2020 Google LLC. All Rights Reserved. 14682 * Licensed under the Apache License, Version 2.0 (the "License");
14683 * you may not use this file except in compliance with the License. 14684 * You may obtain a copy of the License at 14685 * 14686 * http://www.apache.org/licenses/LICENSE-2.0 14687 * 14688 * Unless required by applicable law or agreed to in writing, software 14689 * distributed under the License is distributed on an "AS IS" BASIS, 14690 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14691 * See the License for the specific language governing permissions and 14692 * limitations under the License. 14693 * ============================================================================= 14694 */const VR=async(n,e,t,r)=>{switch(n.op){case"HashTable":case"HashTableV2":{const a=w("keyDType",n,e,t),s=w("valueDType",n,e,t),o=new UR(a,s);return r.addHashTable(n.name,o),[o.handle]}case"LookupTableImport":case"LookupTableImportV2":{const a=w("tableHandle",n,e,t,r),s=w("keys",n,e,t),o=w("values",n,e,t);return[await r.getHashTableById(a.id).import(s,o)]}case"LookupTableFind":case"LookupTableFindV2":{const a=w("tableHandle",n,e,t,r),s=w("keys",n,e,t),o=w("defaultValue",n,e,t);return[await r.getHashTableById(a.id).find(s,o)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=w("tableHandle",n,e,t,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14695 * @license 14696 * Copyright 2018 Google LLC. All Rights Reserved. 14697 * Licensed under the Apache License, Version 2.0 (the "License"); 14698 * you may not use this file except in compliance with the License. 14699 * You may obtain a copy of the License at 14700 * 14701 * http://www.apache.org/licenses/LICENSE-2.0 14702 * 14703 * Unless required by applicable law or agreed to in writing, software 14704 * distributed under the License is distributed on an "AS IS" BASIS, 14705 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14706 * See the License for the specific language governing permissions and 14707 * limitations under the License. 14708 * ============================================================================= 14709 */const WR=(n,e,t,r=pt)=>{switch(n.op){case"ResizeBilinear":{const a=w("images",n,e,t),s=w("size",n,e,t),o=w("alignCorners",n,e,t),i=w("halfPixelCenters",n,e,t);return[r.image.resizeBilinear(a,[s[0],s[1]],o,i)]}case"ResizeNearestNeighbor":{const a=w("images",n,e,t),s=w("size",n,e,t),o=w("alignCorners",n,e,t),i=w("halfPixelCenters",n,e,t);return[r.image.resizeNearestNeighbor(a,[s[0],s[1]],o,i)]}case"CropAndResize":{const a=w("image",n,e,t),s=w("boxes",n,e,t),o=w("boxInd",n,e,t),i=w("cropSize",n,e,t),u=w("method",n,e,t),l=w("extrapolationValue",n,e,t);return[r.image.cropAndResize(a,s,o,i,u,l)]}case"ImageProjectiveTransformV3":{const a=w("images",n,e,t),s=w("transforms",n,e,t),o=w("outputShape",n,e,t),i=w("fillValue",n,e,t),u=w("interpolation",n,e,t),l=w("fillMode",n,e,t);return[r.image.transform(a,s,u.toLowerCase(),l.toLowerCase(),i,o)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14710 * @license 14711 * Copyright 2018 Google LLC. All Rights Reserved. 14712 * Licensed under the Apache License, Version 2.0 (the "License"); 14713 * you may not use this file except in compliance with the License. 14714 * You may obtain a copy of the License at 14715 * 14716 * http://www.apache.org/licenses/LICENSE-2.0 14717 * 14718 * Unless required by applicable law or agreed to in writing, software 14719 * distributed under the License is distributed on an "AS IS" BASIS, 14720 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14721 * See the License for the specific language governing permissions and 14722 * limitations under the License. 14723 * ============================================================================= 14724 */const zR=(n,e,t,r=pt)=>{switch(n.op){case"Equal":return[r.equal(w("a",n,e,t),w("b",n,e,t))];case"NotEqual":return[r.notEqual(w("a",n,e,t),w("b",n,e,t))];case"Greater":return[r.greater(w("a",n,e,t),w("b",n,e,t))];case"GreaterEqual":return[r.greaterEqual(w("a",n,e,t),w("b",n,e,t))];case"Less":return[r.less(w("a",n,e,t),w("b",n,e,t))];case"LessEqual":return[r.lessEqual(w("a",n,e,t),w("b",n,e,t))];case"LogicalAnd":return[r.logicalAnd(w("a",n,e,t),w("b",n,e,t))];case"LogicalNot":return[r.logicalNot(w("a",n,e,t))];case"LogicalOr":return[r.logicalOr(w("a",n,e,t),w("b",n,e,t))];case"Select":case"SelectV2":return[r.where(w("condition",n,e,t),w("a",n,e,t),w("b",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14725 * @license 14726 * Copyright 2018 Google LLC. All Rights Reserved. 14727 * Licensed under the Apache License, Version 2.0 (the "License");
14728 * you may not use this file except in compliance with the License. 14729 * You may obtain a copy of the License at 14730 * 14731 * http://www.apache.org/licenses/LICENSE-2.0 14732 * 14733 * Unless required by applicable law or agreed to in writing, software 14734 * distributed under the License is distributed on an "AS IS" BASIS, 14735 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14736 * See the License for the specific language governing permissions and 14737 * limitations under the License. 14738 * ============================================================================= 14739 */const GR=(n,e,t,r=pt)=>{switch(n.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(w("a",n,e,t),w("b",n,e,t),w("transposeA",n,e,t),w("transposeB",n,e,t))];case"Einsum":return[r.einsum(w("equation",n,e,t),...w("tensors",n,e,t))];case"Transpose":return[r.transpose(w("x",n,e,t),w("perm",n,e,t))];case"_FusedMatMul":const[a,s]=w("fusedOps",n,e,t),o=a==="biasadd",i=s==="prelu",u=w("numArgs",n,e,t),l=w("leakyreluAlpha",n,e,t);if(o){if(i&&u!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&u!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[c,p]=w("args",n,e,t);return[r.fused.matMul({a:w("a",n,e,t),b:w("b",n,e,t),transposeA:w("transposeA",n,e,t),transposeB:w("transposeB",n,e,t),bias:c,activation:s,preluActivationWeights:p,leakyreluAlpha:l})];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14740 * @license 14741 * Copyright 2018 Google LLC. All Rights Reserved. 14742 * Licensed under the Apache License, Version 2.0 (the "License"); 14743 * you may not use this file except in compliance with the License. 14744 * You may obtain a copy of the License at 14745 * 14746 * http://www.apache.org/licenses/LICENSE-2.0 14747 * 14748 * Unless required by applicable law or agreed to in writing, software 14749 * distributed under the License is distributed on an "AS IS" BASIS, 14750 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14751 * See the License for the specific language governing permissions and 14752 * limitations under the License. 14753 * ============================================================================= 14754 */const jR=(n,e,t,r=pt)=>{switch(n.op){case"EuclideanNorm":return[r.euclideanNorm(w("x",n,e,t),w("axis",n,e,t),w("keepDims",n,e,t))];case"FusedBatchNorm":case"FusedBatchNormV2":return[r.batchNorm(w("x",n,e,t),w("mean",n,e,t),w("variance",n,e,t),w("offset",n,e,t),w("scale",n,e,t),w("epsilon",n,e,t))];case"FusedBatchNormV3":return[r.batchNorm(w("x",n,e,t),w("mean",n,e,t),w("variance",n,e,t),w("offset",n,e,t),w("scale",n,e,t),w("epsilon",n,e,t))];case"LRN":return[r.localResponseNormalization(w("x",n,e,t),w("radius",n,e,t),w("bias",n,e,t),w("alpha",n,e,t),w("beta",n,e,t))];case"Softmax":return[r.softmax(w("x",n,e,t))];case"LogSoftmax":return[r.logSoftmax(w("x",n,e,t))];case"SparseToDense":return[r.sparseToDense(w("sparseIndices",n,e,t),w("outputShape",n,e,t),w("sparseValues",n,e,t),w("defaultValue",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14755 * @license 14756 * Copyright 2018 Google LLC. All Rights Reserved. 14757 * Licensed under the Apache License, Version 2.0 (the "License"); 14758 * you may not use this file except in compliance with the License. 14759 * You may obtain a copy of the License at 14760 * 14761 * http://www.apache.org/licenses/LICENSE-2.0 14762 * 14763 * Unless required by applicable law or agreed to in writing, software 14764 * distributed under the License is distributed on an "AS IS" BASIS, 14765 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14766 * See the License for the specific language governing permissions and 14767 * limitations under the License. 14768 * ============================================================================= 14769 */const HR=(n,e,t,r=pt)=>{switch(n.op){case"Max":{const i=w("axis",n,e,t),u=w("keepDims",n,e,t);return[r.max(w("x",n,e,t),i,u)]}case"Mean":{const i=w("axis",n,e,t),u=w("keepDims",n,e,t);return[r.mean(w("x",n,e,t),i,u)]}case"Min":{const i=w("axis",n,e,t),u=w("keepDims",n,e,t);return[r.min(w("x",n,e,t),i,u)]}case"Sum":{const i=w("axis",n,e,t),u=w("keepDims",n,e,t);return[r.sum(w("x",n,e,t),i,u)]}case"All":{const i=w("axis",n,e,t),u=w("keepDims",n,e,t);return[r.all(w("x",n,e,t),i,u)]}case"Any":{const i=w("axis",n,e,t),u=w("keepDims",n,e,t);return[r.any(w("x",n,e,t),i,u)]}case"ArgMax":{const i=w("axis",n,e,t);return[r.argMax(w("x",n,e,t),i)]}case"ArgMin":{const i=w("axis",n,e,t);return[r.argMin(w("x",n,e,t),i)]}case"Prod":{const i=w("axis",n,e,t),u=w("keepDims",n,e,t);return[r.prod(w("x",n,e,t),i,u)]}case"Cumprod":{const i=w("axis",n,e,t),u=w("exclusive",n,e,t),l=w("reverse",n,e,t);return[r.cumprod(w("x",n,e,t),i,u,l)]}case"Cumsum":{const i=w("axis",n,e,t),u=w("exclusive",n,e,t),l=w("reverse",n,e,t);return[r.cumsum(w("x",n,e,t),i,u,l)]}case"Bincount":const a=w("x",n,e,t),s=w("weights",n,e,t),o=w("size",n,e,t);return[r.bincount(a,s,o)];case"DenseBincount":{const i=w("x",n,e,t),u=w("weights",n,e,t),l=w("size",n,e,t),c=w("binaryOutput",n,e,t);return[r.denseBincount(i,u,l,c)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14770 * @license 14771 * Copyright 2018 Google LLC. All Rights Reserved. 14772 * Licensed under the Apache License, Version 2.0 (the "License");
14773 * you may not use this file except in compliance with the License. 14774 * You may obtain a copy of the License at 14775 * 14776 * http://www.apache.org/licenses/LICENSE-2.0 14777 * 14778 * Unless required by applicable law or agreed to in writing, software 14779 * distributed under the License is distributed on an "AS IS" BASIS, 14780 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14781 * See the License for the specific language governing permissions and 14782 * limitations under the License. 14783 * ============================================================================= 14784 */const XR=(n,e,t,r=pt)=>{switch(n.op){case"ConcatV2":case"Concat":{const a=w("n",n,e,t),s=w("axis",n,e,t);let o=w("tensors",n,e,t);return o=o.slice(0,a),[r.concat(o,s)]}case"Gather":{const a=w("x",n,e,t),s=w("indices",n,e,t);return[r.gather(a,r.cast(s,"int32"),0)]}case"GatherV2":{const a=w("axis",n,e,t),s=w("batchDims",n,e,t),o=w("x",n,e,t),i=w("indices",n,e,t);return[r.gather(o,r.cast(i,"int32"),a,s)]}case"Reverse":{const a=w("dims",n,e,t),s=[];for(let i=0;i<a.length;i++)a[i]&&s.push(i);const o=w("x",n,e,t);return[r.reverse(o,s)]}case"ReverseV2":{const a=w("axis",n,e,t),s=w("x",n,e,t);return[r.reverse(s,a)]}case"Slice":{const a=w("begin",n,e,t),s=w("size",n,e,t);return[r.slice(w("x",n,e,t),a,s)]}case"StridedSlice":{const a=w("begin",n,e,t),s=w("end",n,e,t),o=w("strides",n,e,t),i=w("beginMask",n,e,t),u=w("endMask",n,e,t),l=w("ellipsisMask",n,e,t),c=w("newAxisMask",n,e,t),p=w("shrinkAxisMask",n,e,t),h=w("x",n,e,t);return[r.stridedSlice(h,a,s,o,i,u,l,c,p)]}case"Pack":return Xe(()=>{const a=w("axis",n,e,t),s=w("tensors",n,e,t),o=s[0].shape,i=r.squeeze(s[0]).shape,u=s.map(l=>{const c=qe(l.shape,o);if(!c&&!qe(r.squeeze(l).shape,i))throw new Error("the input tensors shape does not match");return c?l:r.reshape(l,o)});return[r.stack(u,a)]});case"Unpack":{const a=w("axis",n,e,t),s=w("tensor",n,e,t);return r.unstack(s,a)}case"Tile":{const a=w("reps",n,e,t);return[r.tile(w("x",n,e,t),a)]}case"Split":case"SplitV":{const a=w("axis",n,e,t),s=w("numOrSizeSplits",n,e,t),o=w("x",n,e,t);return r.split(o,s,a)}case"ScatterNd":{const a=w("indices",n,e,t),s=w("values",n,e,t),o=w("shape",n,e,t);return[r.scatterND(a,s,o)]}case"GatherNd":{const a=w("x",n,e,t),s=w("indices",n,e,t);return[r.gatherND(a,s)]}case"SparseToDense":{const a=w("sparseIndices",n,e,t),s=w("outputShape",n,e,t),o=w("sparseValues",n,e,t),i=w("defaultValue",n,e,t);return[r.sparseToDense(a,o,s,o.dtype===i.dtype?i:r.cast(i,o.dtype))]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14785 * @license 14786 * Copyright 2021 Google LLC. All Rights Reserved. 14787 * Licensed under the Apache License, Version 2.0 (the "License"); 14788 * you may not use this file except in compliance with the License. 14789 * You may obtain a copy of the License at 14790 * 14791 * http://www.apache.org/licenses/LICENSE-2.0 14792 * 14793 * Unless required by applicable law or agreed to in writing, software 14794 * distributed under the License is distributed on an "AS IS" BASIS, 14795 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14796 * See the License for the specific language governing permissions and 14797 * limitations under the License. 14798 * ============================================================================= 14799 */const qR=(n,e,t,r=pt)=>{switch(n.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:s,emptyRowIndicator:o,reverseIndexMap:i}=r.sparse.sparseFillEmptyRows(w("indices",n,e,t),w("values",n,e,t),w("denseShape",n,e,t),w("defaultValue",n,e,t));return[a,s,o,i]}case"SparseReshape":{const{outputIndices:a,outputShape:s}=r.sparse.sparseReshape(w("inputIndices",n,e,t),w("inputShape",n,e,t),w("newShape",n,e,t));return[a,s]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(w("data",n,e,t),w("indices",n,e,t),w("segmentIds",n,e,t))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(w("data",n,e,t),w("indices",n,e,t),w("segmentIds",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14800 * @license 14801 * Copyright 2018 Google LLC. All Rights Reserved. 14802 * Licensed under the Apache License, Version 2.0 (the "License");
14803 * you may not use this file except in compliance with the License. 14804 * You may obtain a copy of the License at 14805 * 14806 * http://www.apache.org/licenses/LICENSE-2.0 14807 * 14808 * Unless required by applicable law or agreed to in writing, software 14809 * distributed under the License is distributed on an "AS IS" BASIS, 14810 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14811 * See the License for the specific language governing permissions and 14812 * limitations under the License. 14813 * ============================================================================= 14814 */const KR=(n,e,t,r=pt)=>{switch(n.op){case"FFT":return[r.fft(w("x",n,e,t))];case"IFFT":return[r.ifft(w("x",n,e,t))];case"RFFT":return[r.rfft(w("x",n,e,t))];case"IRFFT":return[r.irfft(w("x",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14815 * @license 14816 * Copyright 2021 Google LLC. All Rights Reserved. 14817 * Licensed under the Apache License, Version 2.0 (the "License"); 14818 * you may not use this file except in compliance with the License. 14819 * You may obtain a copy of the License at 14820 * 14821 * http://www.apache.org/licenses/LICENSE-2.0 14822 * 14823 * Unless required by applicable law or agreed to in writing, software 14824 * distributed under the License is distributed on an "AS IS" BASIS, 14825 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14826 * See the License for the specific language governing permissions and 14827 * limitations under the License. 14828 * ============================================================================= 14829 */const YR=(n,e,t,r=pt)=>{switch(n.op){case"StringNGrams":{const{nGrams:a,nGramsSplits:s}=r.string.stringNGrams(w("data",n,e,t),w("dataSplits",n,e,t),w("separator",n,e,t),w("nGramWidths",n,e,t),w("leftPad",n,e,t),w("rightPad",n,e,t),w("padWidth",n,e,t),w("preserveShortSequences",n,e,t));return[a,s]}case"StringSplit":{const{indices:a,values:s,shape:o}=r.string.stringSplit(w("input",n,e,t),w("delimiter",n,e,t),w("skipEmpty",n,e,t));return[a,s,o]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(w("input",n,e,t),w("numBuckets",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14830 * @license 14831 * Copyright 2018 Google LLC. All Rights Reserved. 14832 * Licensed under the Apache License, Version 2.0 (the "License"); 14833 * you may not use this file except in compliance with the License. 14834 * You may obtain a copy of the License at 14835 * 14836 * http://www.apache.org/licenses/LICENSE-2.0 14837 * 14838 * Unless required by applicable law or agreed to in writing, software 14839 * distributed under the License is distributed on an "AS IS" BASIS, 14840 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14841 * See the License for the specific language governing permissions and 14842 * limitations under the License. 14843 * ============================================================================= 14844 */const ZR=(n,e,t,r=pt)=>{switch(n.op){case"Cast":return[r.cast(w("x",n,e,t),w("dtype",n,e,t))];case"ExpandDims":{const a=w("axis",n,e,t);return[r.expandDims(w("x",n,e,t),a)]}case"Squeeze":{const a=w("axis",n,e,t);return[r.squeeze(w("x",n,e,t),a)]}case"Reshape":return[r.reshape(w("x",n,e,t),w("shape",n,e,t))];case"MirrorPad":return[r.mirrorPad(w("x",n,e,t),w("padding",n,e,t),w("mode",n,e,t))];case"PadV2":case"Pad":return[r.pad(w("x",n,e,t),w("padding",n,e,t),w("constantValue",n,e,t))];case"SpaceToBatchND":{const a=w("blockShape",n,e,t),s=w("paddings",n,e,t);return[r.spaceToBatchND(w("x",n,e,t),a,s)]}case"BatchToSpaceND":{const a=w("blockShape",n,e,t),s=w("crops",n,e,t);return[r.batchToSpaceND(w("x",n,e,t),a,s)]}case"DepthToSpace":{const a=w("blockSize",n,e,t),s=w("dataFormat",n,e,t).toUpperCase();return[r.depthToSpace(w("x",n,e,t),a,s)]}case"BroadcastTo":return[r.broadcastTo(w("x",n,e,t),w("shape",n,e,t))];case"BroadcastArgs":return[r.broadcastArgs(w("s0",n,e,t),w("s1",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 14845 * @license 14846 * Copyright 2018 Google LLC. All Rights Reserved. 14847 * Licensed under the Apache License, Version 2.0 (the "License"); 14848 * you may not use this file except in compliance with the License. 14849 * You may obtain a copy of the License at 14850 * 14851 * http://www.apache.org/licenses/LICENSE-2.0 14852 * 14853 * Unless required by applicable law or agreed to in writing, softw
14853are 14854 * distributed under the License is distributed on an "AS IS" BASIS, 14855 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14856 * See the License for the specific language governing permissions and 14857 * limitations under the License. 14858 * ============================================================================= 14859 */function Ec(n,e,t,r,a=Xe){const s=((o,i,u)=>{switch(o.category){case"arithmetic":return a(()=>IR(o,i,u));case"basic_math":return a(()=>NR(o,i,u));case"control":return FR(o,i,u);case"convolution":return a(()=>DR(o,i,u));case"creation":return a(()=>MR(o,i,u));case"dynamic":return LR(o,i,u);case"evaluation":return a(()=>PR(o,i,u));case"image":return a(()=>WR(o,i,u));case"graph":return a(()=>BR(o,i,u));case"logical":return a(()=>zR(o,i,u));case"matrices":return a(()=>GR(o,i,u));case"normalization":return a(()=>jR(o,i,u));case"reduction":return a(()=>HR(o,i,u));case"slice_join":return a(()=>XR(o,i,u));case"sparse":return a(()=>qR(o,i,u));case"spectral":return a(()=>KR(o,i,u));case"string":return a(()=>YR(o,i,u));case"transformation":return a(()=>ZR(o,i,u));case"hash_table":return VR(o,i,u,r);case"custom":const l=jm(o.op);if(l&&l.customExecutor)return l.customExecutor(new CR(o,i,u));throw TypeError(`Custom op ${o.op} is not registered.`);default:throw TypeError(`Unknown op '${o.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(n,e,t);return la(s)?s.then(o=>[].concat(o)):[].concat(s)}class Cc{constructor(e={},t={},r={},a={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=r,this.functionMap=a,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t<this.contexts.length-1;t++){const r=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(r))}e.push(""),this._currentContextIds=e}contextIdforContexts(e){return e?e.map(t=>t.id===0&&t.iterationId===0?"":`${t.frameName}-${t.iterationId}`).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(this.contexts&&this.contexts.length>1)this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();else throw new Error("Cannot exit frame, the context is empty")}nextIteration(){if(this.contexts&&this.contexts.length>0){this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}else throw new Error("Cannot increase frame iteration, the context is empty")}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}/** 14860 * @license 14861 * Copyright 2019 Google LLC. All Rights Reserved. 14862 * Licensed under the Apache License, Version 2.0 (the "License"); 14863 * you may not use this file except in compliance with the License. 14864 * You may obtain a copy of the License at 14865 * 14866 * http://www.apache.org/licenses/LICENSE-2.0 14867 * 14868 * Unless required by applicable law or agreed to in writing, software 14869 * distributed under the License is distributed on an "AS IS" BASIS, 14870 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14871 * See the License for the specific language governing permissions and 14872 * limitations under the License. 14873 * ============================================================================= 14874 */function Ic(n,e,t,r){const a=new Set,s=[];let o=null,i=null;const u=new Set,l=Object.keys(n).map(h=>Nt(h)[0]);let c=[];r!=null&&(c=r.map(h=>Nt(h.name)[0]));const p=[...e];for(;p.length>0;){const h=p.pop();if((qm(h)||n_(h)||r_(h))&&o==null&&(o=h,i=o.children.map(d=>d.name).filter(d=>a.has(d))),a.add(h.name),t[h.name]==null&&l.indexOf(h.name)===-1&&c.indexOf(h.name)===-1){if(h.inputs.length===0){s.push(h.name);continue}
14874h.inputs.forEach(d=>{u.has(d.name)||(u.add(d.name),p.push(d))})}}return{inputs:n,outputs:e,usedNodes:a,missingInputs:s,dynamicNode:o,syncInputs:i}}function JR(n,e,t){const{usedNodes:r,inputs:a}=t,s=[],o=Object.keys(a).map(c=>Nt(c)[0]).map(c=>n.nodes[c]),i=n.initNodes;o.forEach(c=>{r.has(c.name)&&s.push(c)}),n.weights.forEach(c=>{r.has(c.name)&&s.push(c)}),i!=null&&i.forEach(c=>{r.has(c.name)&&s.push(c)});const u=new Set,l=[];for(;s.length>0;){const c=s.pop();u.add(c.name),e[c.name]||l.push(c),c.children.forEach(p=>{!u.has(p.name)&&r.has(p.name)&&p.inputs.every(h=>u.has(h.name))&&s.push(p)})}return l}const QR=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],e_=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],t_=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function qm(n){return QR.indexOf(n.op)>=0}function n_(n){return e_.indexOf(n.op)>=0}function r_(n){return t_.indexOf(n.op)>=0}/** 14875 * @license 14876 * Copyright 2018 Google LLC. All Rights Reserved. 14877 * Licensed under the Apache License, Version 2.0 (the "License"); 14878 * you may not use this file except in compliance with the License. 14879 * You may obtain a copy of the License at 14880 * 14881 * http://www.apache.org/licenses/LICENSE-2.0 14882 * 14883 * Unless required by applicable law or agreed to in writing, software 14884 * distributed under the License is distributed on an "AS IS" BASIS, 14885 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14886 * See the License for the specific language governing permissions and 14887 * limitations under the License. 14888 * ============================================================================= 14889 */class go{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.intermediateTensors={},this.keepTensorForDebug=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,e.functions!=null&&Object.keys(e.functions).forEach(r=>{this._functionExecutorMap[r]=new go(e.functions[r],this)})}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map(r=>e[r].map(a=>a.id));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get outputs(){return this._outputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get inputNodes(){return this._inputs.map(e=>e.signatureKey||e.name)}get outputNodes(){return this._outputs.map(e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t})}get functions(){return Object.keys(this._functions).reduce((e,t)=>(e[t]=this._functions[t].signature,e),{})}getCompilationKey(e,t){const r=e.map(s=>s.name).sort(),a=t.map(s=>s.name).sort();return r.join(this.SEPERATOR)+"--"+a.join(this.SEPERATOR)}compile(e,t){const r=Ic(e,t,this.weightMap,this._initNodes),{missingInputs:a,dynamicNode:s,syncInputs:o}=r;if(s!=null)throw new Error(`This execution contains the node '${s.name}', which has the dynamic op '${s.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${o}]`);if(a.length>0){const i=t.map(l=>l.name),u=Object.keys(e);throw new Error(`Cannot compute the outputs [${i}] from the provided inputs [${u}]. Missing the following inputs: [${a}]`)}return JR(this.graph,this.weightMap,r)}execute(e,t){e=this.mapInputs(e);const r=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const a=r.map(p=>this.graph.nodes[Nt(p)[0]]),s=t.map(p=>Nt(p)[0]);let o=s.map(p=>this.graph.nodes[p]);this.resetIntermediateTensors(),o.length===0&&(o=this._outputs);const i=this.getCompilationKey(a,o);let u=this.compiledMap.get(i);u==null&&(u=this.compile(e,o),this.compiledMap.set(i,u));const l={},c={};return Xe(()=>{const p=new Cc(this.weightMap,l,c,this.functionExecutorMap),h=Object.assign({},this.weightMap);Object.keys(e).forEach(y=>{const[b,x]=Nt(y),T=[];T[x]=e[y],h[b]=T});const d=this.getFrozenTensorIds(h),m={};for(let y=0;y<u.length;y++){const b=u[y];if(!h[b.name]){const x=Ec(b,h,p,this._resourceManager);
14889if(la(x))throw new Error(`The execution of the op '${b.op}' returned a promise. Please use model.executeAsync() instead.`);h[b.name]=x,this.checkTensorForDisposal(b.name,b,h,p,d,s,m)}}return this.parent==null&&p.dispose(d),t.map(y=>mt(y,h,p))})}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map(r=>e[r]).map(r=>r.map(a=>a.id)));return new Set(t)}checkTensorForDisposal(e,t,r,a,s,o,i){t.category==="control"||o.indexOf(e)!==-1||(r[e].forEach(u=>{u!=null&&(i[u.id]=(i[u.id]||0)+t.children.length)}),t.inputs.forEach(u=>{if(u.category!=="control"){const l=U9(u.name,r,a);l!=null&&l.forEach(c=>{if(c&&!c.kept&&!s.has(c.id)){const p=i[c.id];if(p===1){if(!this.keepTensorForDebug)c.dispose();else{const[h,d]=xn(t.name,a);this.intermediateTensors[h]?this.intermediateTensors[h][d]=c:(this.intermediateTensors[h]=[],this.intermediateTensors[h][d]=c)}delete i[c.id]}else p!=null&&i[c.id]--}})}}))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.intermediateTensors&&(Object.keys(this.intermediateTensors).forEach(e=>this.intermediateTensors[e].forEach(t=>t.dispose())),this.disposeTensorsMap())}disposeTensorsMap(){this.tensorsMap&&Object.keys(this.tensorsMap).forEach(e=>{this.tensorsMap[e].forEach(t=>{t&&!t.kept&&!t.isDisposed&&!this.keepIds.has(t.id)&&t.dispose()})})}getIntermediateTensors(){return this.tensorsMap}resetIntermediateTensors(){for(const e in this.intermediateTensors)this.intermediateTensors[e].forEach(t=>t.dispose()),delete this.intermediateTensors[e]}async _executeAsync(e,t,r=!1,a={},s={}){r||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepTensorForDebug=H().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(c){console.warn(c.message)}this.resetIntermediateTensors();const o=new Cc(this.weightMap,a,s,this.functionExecutorMap);this.tensorsMap=await this.executeWithControlFlow(e,o,t,r);const i=t.map(c=>mt(c,this.tensorsMap,o)),u=i.map(c=>c.id),l=Object.keys(e).map(c=>e[c].id);return this.keepIds=new Set([...u,...l,...this.weightIds]),this.keepTensorForDebug||this.disposeTensorsMap(),this.parent==null&&o.dispose(this.keepIds),i}async executeFunctionAsync(e,t,r){const a=e.reduce((s,o,i)=>(s[this.inputs[i].name]=o,s),{});return this._executeAsync(a,this.outputNodes,!0,t,r)}async executeWithControlFlow(e,t,r,a){const s=Object.keys(e),o=s.map($=>this.graph.nodes[Nt($)[0]]),i=r.map($=>Nt($)[0]);let u=i.map($=>this.graph.nodes[$]);u.length===0&&(u=this._outputs);const{usedNodes:l,missingInputs:c,dynamicNode:p,syncInputs:h}=Ic(e,u,this.weightMap,this._initNodes),d=[...o,...this.graph.weights,...this._initNodes||[]].map($=>({node:$,contexts:t.currentContext})),m=Object.assign({},this.weightMap);Object.keys(e).forEach($=>{const[F,M]=Nt($),U=[];U[M]=e[$],m[F]=U});const y={},b=this.getFrozenTensorIds(m),x={};for(;d.length>0;){const $=this.processStack(o,d,t,m,x,b,i,y,l);await Promise.all($)}p==null&&!a&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const T=u.filter($=>!qm($)&&!mt($.name,m,t)).map($=>$.name);if(T.length>0){let $="";throw p!=null&&($=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${h}]`),new Error(`Cannot compute the outputs [${T}] from the provided inputs [${s}]. Consider providing the following inputs: [${c}]. ${$}`)}return m}processStack(e,t,r,a,s,o,i,u,l){const c=[];for(;t.length>0;){const p=t.pop();r.currentContext=p.contexts;let h="";if(p.node.op==="Enter"&&w("isConstant",p.node,a,r)&&([h]=xn(p.node.name,r)),a[p.node.name]==null){const d=Ec(p.node,a,r,this._resourceManager);h||([h]=xn(p.node.name,r));const m=r.currentContext;la(d)?c.push(d.then(y=>(a[h]=y,r.currentContext=m,this.checkTensorForDisposal(h,p.node,a,r,o,i,u),this.processChildNodes(p.node,t,r,a,s,l),y))):(a[h]=d,this.checkTensorForDisposal(h,p.node,a,r,o,i,u),this.processChildNodes(p.node,t,r,a,s,l))}else this.processChildNodes(p.node,t,r,a,s,l)}return c}
14889processChildNodes(e,t,r,a,s,o){e.children.forEach(i=>{const[u]=xn(i.name,r);s[u]||!o.has(i.name)||(i.op==="Merge"?i.inputNames.some(l=>!!mt(l,a,r))&&(s[u]=!0,t.push({contexts:r.currentContext,node:i})):i.inputNames.every(l=>!!mt(l,a,r))&&(s[u]=!0,t.push({contexts:r.currentContext,node:i})))})}dispose(){Object.keys(this.weightMap).forEach(e=>this.weightMap[e].forEach(t=>t.dispose()))}checkInputShapeAndType(e){Object.keys(e).forEach(t=>{const r=e[t],[a]=Nt(t),s=this.graph.nodes[a];if(s.attrParams.shape&&s.attrParams.shape.value){const o=s.attrParams.shape.value,i=o.length===r.shape.length&&r.shape.every((u,l)=>o[l]===-1||o[l]===u);R(i,()=>`The shape of dict['${s.name}'] provided in model.execute(dict) must be [${o}], but was [${r.shape}]`)}s.attrParams.dtype&&s.attrParams.dtype.value&&R(r.dtype===s.attrParams.dtype.value,()=>`The dtype of dict['${s.name}'] provided in model.execute(dict) must be ${s.attrParams.dtype.value}, but was ${r.dtype}`)})}mapInputs(e){const t={};for(const r in e)if(this._signature!=null&&this._signature.inputs!=null&&this._signature.inputs[r]!=null){const a=this._signature.inputs[r];t[a.name]=e[r]}else t[r]=e[r];return t}checkInputs(e){const t=Object.keys(e).filter(r=>{const[a]=Nt(r);return this.graph.nodes[a]==null});if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map(t=>this._signature!=null&&this._signature.outputs!=null&&this._signature.outputs[t]!=null?this._signature.outputs[t].name:t,{})}checkOutputs(e){e.forEach(t=>{const[r]=Nt(t);if(!this.graph.nodes[r])throw new Error(`The output '${t}' is not found in the graph`)})}}class a_{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}/** 14890 * @license 14891 * Copyright 2018 Google LLC. All Rights Reserved. 14892 * Licensed under the Apache License, Version 2.0 (the "License"); 14893 * you may not use this file except in compliance with the License. 14894 * You may obtain a copy of the License at 14895 * 14896 * http://www.apache.org/licenses/LICENSE-2.0 14897 * 14898 * Unless required by applicable law or agreed to in writing, software 14899 * distributed under the License is distributed on an "AS IS" BASIS, 14900 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14901 * See the License for the specific language governing permissions and 14902 * limitations under the License. 14903 * ============================================================================= 14904 */const s_="?tfjs-format=file",o_="model.json";class i_{constructor(e,t={},r=of){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=r,t==null&&(this.loadOptions={}),this.resourceManager=new a_}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}findIOHandler(){const e=this.modelUrl;if(e.load!=null)this.handler=e;else if(this.loadOptions.requestInit!=null)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(t.length===0)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),this.handler.load==null)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return la(e)?e.then(t=>this.loadSync(t)):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let r=this.artifacts.signature;if(this.artifacts.userDefinedMetadata!=null){const s=this.artifacts.userDefinedMetadata;s.signature!=null&&(r=s.signature),s.structuredOutputKeys!=null&&(this.structuredOutputKeys=s.structuredOutputKeys)}this.signature=r,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const a=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new go(wc.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(a),this.executor.resourceManager=this.resourceManager,e.modelInitializer!=null&&e.modelInitializer.node!=null){const s=wc.Instance.transformGraph(e.modelInitializer);this.initializer=new go(s),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if(typeof e=="string"){const r=this.io.getSaveHandlers(e);if(r.length===0)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(r.length>1)throw new Error(`Found more than one (${r.length}) save handlers for URL '${e}'`);e=r[0]}if(e.save==null)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}predict(e,t){const r=this.execute(e,this.outputNodes);if(this.structuredOutputKeys){const a=r instanceof Ge?[r]:r,s={};return a.forEach((o,i)=>s[this.structuredOutputKeys[i]]=o),s}return r}normalizeInputs(e){if(!(e instanceof Ge)&&!Array.isArray(e))return e;if(e=Array.isArray(e)?e:[e],e.length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${e.length} input tensors.`);return this.inputNodes.reduce((t,r,a)=>(t[r]=e[a],t),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const r=this.executor.execute(e,t);return r.length>1?r:r[0]}async executeAsync(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const r=await this.executor.executeAsync(e,t);return r.length>1?r:r[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce((t,r)=>(t[r]=[e[r]],t),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function Km(n,e={}
14904,t=of){if(n==null)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");e==null&&(e={}),e.fromTFHub&&typeof n=="string"&&(n=u_(n));const r=new i_(n,e,t);return await r.load(),r}function u_(n){return n.endsWith("/")||(n=n+"/"),`${n}${o_}${s_}`}/** 14905 * @license 14906 * Copyright 2023 Google LLC. All Rights Reserved. 14907 * Licensed under the Apache License, Version 2.0 (the "License"); 14908 * you may not use this file except in compliance with the License. 14909 * You may obtain a copy of the License at 14910 * 14911 * http://www.apache.org/licenses/LICENSE-2.0 14912 * 14913 * Unless required by applicable law or agreed to in writing, software 14914 * distributed under the License is distributed on an "AS IS" BASIS, 14915 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14916 * See the License for the specific language governing permissions and 14917 * limitations under the License. 14918 * ============================================================================= 14919 */var cn=function(){return cn=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var a in e=arguments[t])Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n},cn.apply(this,arguments)};function Rn(n,e,t,r){return new(t||(t=Promise))((function(a,s){function o(l){try{u(r.next(l))}catch(c){s(c)}}function i(l){try{u(r.throw(l))}catch(c){s(c)}}function u(l){var c;l.done?a(l.value):(c=l.value,c instanceof t?c:new t((function(p){p(c)}))).then(o,i)}u((r=r.apply(n,[])).next())}))}function _n(n,e){var t,r,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(u){return function(l){return(function(c){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(a=o.trys,!((a=a.length>0&&a[a.length-1])||c[0]!==6&&c[0]!==2)){o=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(c[0]===6&&o.label<a[1]){o.label=a[1],a=c;break}
vendor: 14,705 bytes, line 14919
14919if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=e.call(n,o)}catch(p){c=[6,p],r=0}finally{t=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}})([u,l])}}}function qn(n){var e=n.map((function(t){return t[0]}));return e.push(n[n.length-1][1]),e}var l_={lips:qn([[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]]),leftEye:qn([[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]]),leftEyebrow:qn([[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]]),leftIris:qn([[474,475],[475,476],[476,477],[477,474]]),rightEye:qn([[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]]),rightEyebrow:qn([[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]]),rightIris:qn([[469,470],[470,471],[471,472],[472,469]]),faceOval:qn([[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]])},c_=Object.entries(l_).map((function(n){var e=n[0];return n[1].map((function(t){return[t,e]}))})).flat(),Ym=new Map(c_);function Su(n){for(var e={locationData:{relativeKeypoints:[]}},t=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,o=0;o<n.length;++o){var i=n[o];t=Math.min(t,i.x),r=Math.max(r,i.x),a=Math.min(a,i.y),s=Math.max(s,i.y),e.locationData.relativeKeypoints.push({x:i.x,y:i.y})}return e.locationData.relativeBoundingBox={xMin:t,yMin:a,xMax:r,yMax:s,width:r-t,height:s-a},e}var gi={runtime:"mediapipe",maxFaces:1,refineLandmarks:!1},p_=(function(){function n(e){var t=this;this.width=0,this.height=0,this.selfieMode=!1,this.faceMeshSolution=new p2.FaceMesh({locateFile:function(r,a){return e.solutionPath?e.solutionPath.replace(/\/+$/,"")+"/"+r:a+"/"+r}}),this.faceMeshSolution.setOptions({refineLandmarks:e.refineLandmarks,selfieMode:this.selfieMode,maxNumFaces:e.maxFaces}),this.faceMeshSolution.onResults((function(r){if(t.height=r.image.height,t.width=r.image.width,t.faces=[],r.multiFaceLandmarks!==null)for(var a=r.multiFaceLandmarks,s=0;s<a.length;s++){var o=t.translateOutput(a[s]);t.faces.push({keypoints:o,box:Su(o).locationData.relativeBoundingBox})}}))}return n.prototype.translateOutput=function(e){var t=this;return e.map((function(r,a){var s={x:r.x*t.width,y:r.y*t.height,z:r.z*t.width},o=Ym.get(a);return o!=null&&(s.name=o),s}))},n.prototype.estimateFaces=function(e,t){return Rn(this,void 0,void 0,(function(){var r,a;return _n(this,(function(s){switch(s.label){case 0:return t&&t.flipHorizontal&&t.flipHorizontal!==this.selfieMode&&(this.selfieMode=t.flipHorizontal,this.faceMeshSolution.setOptions({selfieMode:this.selfieMode})),e instanceof Ge?(a=ImageData.bind,[4,cf(e)]):[3,2];case 1:return r=new(a.apply(ImageData,[void 0,s.sent(),e.shape[1],e.shape[0]])),[3,3];case 2:r=e,s.label=3;case 3:return e=r,[4,this.faceMeshSolution.send({image:e})];case 4:return s.sent(),[2,this.faces]}}))}))},n.prototype.dispose=function(){this.faceMeshSolution.close()},n.prototype.reset=function(){this.faceMeshSolution.reset(),this.width=0,this.height=0,this.faces=null,this.selfieMode=!1},n.prototype.initialize=function(){return this.faceMeshSolution.initialize()},n})();function h_(n){return Rn(this,void 0,void 0,(function(){var e,t;return _n(this,(function(r){switch(r.label){case 0:return e=(function(a){if(a==null)return cn({},gi);var s=cn({},a);return s.runtime="mediapipe",s.maxFaces==null&&(s.maxFaces=gi.maxFaces),s.refineLandmarks==null&&(s.refineLandmarks=gi.refineLandmarks),s})(n),[4,(t=new p_(e)).initialize()];case 1:return r.sent(),[2,t]}}))}))}var yi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d_={};(function(){var n;function e(f){var S=0;return function(){return S<f.length?{done:!1,value:f[S++]}:{done:!0}}}var t=typeof Object.defineProperties=="function"?Object.defineProperty:function(f,S,E){return f==Array.prototype||f==Object.prototype||(f[S]=E.value),f},r=(function(f){f=[typeof globalThis=="object"&&globalThis,f,typeof window=="object"&&window,typeof self=="object"&&self,typeof yi=="object"&&yi];for(var S=0;S<f.length;++S){var E=f[S];if(E&&E.Math==Math)return E}throw Error("Cannot find global object")})(this);function a(f,S){if(S)e:{var E=r;f=f.split(".");for(var I=0;I<f.length-1;I++){var A=f[I];if(!(A in E))break e;E=E[A]}(S=S(I=E[f=f[f.length-1]]))!=I&&S!=null&&t(E,f,{configurable:!0,writable:!0,value:S})}}function s(f){return(f={next:f})[Symbol.iterator]=function(){return this},f}function o(f){var S=typeof Symbol<"u"&&Symbol.iterator&&f[Symbol.iterator];return S?S.call(f):{next:e(f)}}function i(f){if(!(f instanceof Array)){f=o(f);for(var S,E=[];!(S=f.next()).done;)E.push(S.value);f=E}return f}a("Symbol",(function(f){function S(A,_){this.g=A,t(this,"description",{configurable:!0,writable:!0,value:_})}if(f)return f;S.prototype.toString=function(){return this.g};var E="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",I=0;return function A(_){if(this instanceof A)throw new TypeError("Symbol is not a constructor");return new S(E+(_||"")+"_"+I++,_)}})),a("Symbol.iterator",(function(f){if(f)return f;f=Symbol("Symbol.iterator");for(var S="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),E=0;E<S.length;E++){var I=r[S[E]];typeof I=="function"&&typeof I.prototype[f]!="function"&&t(I.prototype,f,{configurable:!0,writable:!0,value:function(){return s(e(this))}})}return f}));var u,l=typeof Object.create=="function"?Object.create:function(f){function S(){}return S.prototype=f,new S};if(typeof Object.setPrototypeOf=="function")u=Object.setPrototypeOf;else{var c;e:{var p={};try{p.__proto__={a:!0},c=p.a;break e}catch{}c=!1}u=c?function(f,S){if(f.__proto__=S,f.__proto__!==S)throw new TypeError(f+" is not extensible");return f}:null}var h=u;function d(f,S){if(f.prototype=l(S.prototype),f.prototype.constructor=f,h)h(f,S);else for(var E in S)if(E!="prototype")if(Object.defineProperties){var I=Object.getOwnPropertyDescriptor(S,E);I&&Object.defineProperty(f,E,I)}else f[E]=S[E];f.na=S.prototype}function m(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.u=this.o=0,this.j=null}function y(f){if(f.l)throw new TypeError("Generator is already running");f.l=!0}function b(f,S){f.j={da:S,ea:!0},f.g=f.o||f.u}function x(f,S,E){return f.g=E,{value:S}}function T(f){this.g=new m,this.h=f}function $(f,S,E,I){try{var A=S.call(f.g.i,E);if(!(A instanceof Object))throw new TypeError("Iterator result "+A+" is not an object");if(!A.done)return f.g.l=!1,A;var _=A.value}catch(D){return f.g.i=null,b(f.g,D),F(f)}return f.g.i=null,I.call(f.g,_),F(f)}function F(f){for(;f.g.g;)try{var S=f.h(f.g);if(S)return f.g.l=!1,{value:S.value,done:!1}}catch(E){f.g.h=void 0,b(f.g,E)}if(f.g.l=!1,f.g.j){if(S=f.g.j,f.g.j=null,S.ea)throw S.da;return{value:S.return,done:!0}}return{value:void 0,done:!0}}function M(f){this.next=function(S){return y(f.g),f.g.i?S=$(f,f.g.i.next,S,f.g.s):(f.g.s(S),S=F(f)),S},this.throw=function(S){return y(f.g),f.g.i?S=$(f,f.g.i.throw,S,f.g.s):(b(f.g,S),S=F(f)),S},this.return=function(S){return(function(E,I){y(E.g);var A=E.g.i;return A?$(E,"return"in A?A.return:function(_){return{value:_,done:!0}},I,E.g.return):(E.g.return(I),F(E))})(f,S)},this[Symbol.iterator]=function(){return this}}function U(f){return(function(S){function E(A){return S.next(A)}function I(A){return S.throw(A)}return new Promise((function(A,_){(function D(B){B.done?A(B.value):Promise.resolve(B.value).then(E,I).then(D,_)})(S.next())}))})(new M(new T(f)))}m.prototype.s=function(f){this.h=f},m.prototype.return=function(f){this.j={return:f},this.g=this.u},a("Promise",(function(f){function S(D){this.h=0,this.i=void 0,this.g=[],this.s=!1;var B=this.j();try{D(B.resolve,B.reject)}catch(j){B.reject(j)}}function E(){this.g=null}function I(D){return D instanceof S?D:new S((function(B){B(D)}))}if(f)return f;E.prototype.h=function(D){if(this.g==null){this.g=[];var B=this;this.i((function(){B.l()}))}this.g.push(D)};var A=r.setTimeout;E.prototype.i=function(D){A(D,0)},E.prototype.l=function(){for(;this.g&&this.g.length;){var D=this.g;this.g=[];for(var B=0;B<D.length;++B){var j=D[B];D[B]=null;try{j()}catch(Y){this.j(Y)}}}this.g=null},E.prototype.j=function(D){this.i((function(){throw D}))},S.prototype.j=function(){function D(Y){return function(Q){j||(j=!0,Y.call(B,Q))}}var B=this,j=!1;return{resolve:D(this.D),reject:D(this.l)}},S.prototype.D=function(D){if(D===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(D instanceof S)this.H(D);else{e:switch(typeof D){case"object":var B=D!=null;break e;case"function":B=!0;break e;default:B=!1}B?this.A(D):this.o(D)}},S.prototype.A=function(D){var B=void 0;try{B=D.then}catch(j){return void this.l(j)}typeof B=="function"?this.I(B,D):this.o(D)},S.prototype.l=function(D){this.u(2,D)},S.prototype.o=function(D){this.u(1,D)},S.prototype.u=function(D,B){if(this.h!=0)throw Error("Cannot settle("+D+", "+B+"): Promise already settled in state"+this.h);this.h=D,this.i=B,this.h===2&&this.G(),this.B()},S.prototype.G=function(){var D=this;A((function(){if(D.C()){var B=r.console;B!==void 0&&B.error(D.i)}}),1)},S.prototype.C=function(){if(this.s)return!1;var D=r.CustomEvent,B=r.Event,j=r.dispatchEvent;return j===void 0||(typeof D=="function"?D=new D("unhandledrejection",{cancelable:!0}):typeof B=="function"?D=new B("unhandledrejection",{cancelable:!0}):(D=r.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,D),D.promise=this,D.reason=this.i,j(D))},S.prototype.B=function(){if(this.g!=null){for(var D=0;D<this.g.length;++D)_.h(this.g[D]);this.g=null}};var _=new E;return S.prototype.H=function(D){var B=this.j();D.M(B.resolve,B.reject)},S.prototype.I=function(D,B){var j=this.j();try{D.call(B,j.resolve,j.reject)}catch(Y){j.reject(Y)}},S.prototype.then=function(D,B){function j(se,ie){return typeof se=="function"?function(xe){try{Y(se(xe))}catch(ve){Q(ve)}}:ie}var Y,Q,re=new S((function(se,ie){Y=se,Q=ie}));return this.M(j(D,Y),j(B,Q)),re},S.prototype.catch=function(D){return this.then(void 0,D)},S.prototype.M=function(D,B){function j(){switch(Y.h){case 1:D(Y.i);break;case 2:B(Y.i);break;default:throw Error("Unexpected state: "+Y.h)}}var Y=this;this.g==null?_.h(j):this.g.push(j),this.s=!0},S.resolve=I,S.reject=function(D){return new S((function(B,j){j(D)}))},S.race=function(D){return new S((function(B,j){for(var Y=o(D),Q=Y.next();!Q.done;Q=Y.next())I(Q.value).M(B,j)}))},S.all=function(D){var B=o(D),j=B.next();return j.done?I([]):new S((function(Y,Q){function re(xe){return function(ve){se[xe]=ve,--ie==0&&Y(se)}}var se=[],ie=0;do se.push(void 0),ie++,I(j.value).M(re(se.length-1),Q),j=B.next();while(!j.done)}))},S}));var X=typeof Object.assign=="function"?Object.assign:function(f,S){for(var E=1;E<arguments.length;E++){var I=arguments[E];if(I)for(var A in I)Object.prototype.hasOwnProperty.call(I,A)&&(f[A]=I[A])}return f};a("Object.assign",(function(f){return f||X})),a("Object.is",(function(f){return f||function(S,E){return S===E?S!==0||1/S==1/E:S!=S&&E!=E}})),a("Array.prototype.includes",(function(f){return f||function(S,E){var I=this;I instanceof String&&(I=String(I));var A=I.length;for(0>(E=E||0)&&(E=Math.max(E+A,0));E<A;E++){var _=I[E];if(_===S||Object.is(_,S))return!0}return!1}})),a("String.prototype.includes",(function(f){return f||function(S,E){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(S instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(S,E||0)!==-1}})),a("Array.prototype.keys",(function(f){return f||function(){return(function(S,E){S instanceof String&&(S+="");var I=0,A=!1,_={next:function(){if(!A&&I<S.length){var D=I++;return{value:E(D,S[D]),done:!1}}return A=!0,{done:!0,value:void 0}}};return _[Symbol.iterator]=function(){return _},_})(this,(function(S){return S}))}}));var z=this||self;function L(f,S){f=f.split(".");var E,I=z;for((f[0]in I)||I.execScript===void 0||I.execScript("var "+f[0]);f.length&&(E=f.shift());)f.length||S===void 0?I=I[E]&&I[E]!==Object.prototype[E]?I[E]:I[E]={}:I[E]=S}function C(){throw Error("Invalid UTF8")}function q(f,S){return S=String.fromCharCode.apply(null,S),f==null?S:f+S}var ee,te,le=typeof TextDecoder<"u",de=typeof TextEncoder<"u",fe={},Re=null;function ge(f){var S;S===void 0&&(S=0),We(),S=fe[S];for(var E=Array(Math.floor(f.length/3)),I=S[64]||"",A=0,_=0;A<f.length-2;A+=3){var D=f[A],B=f[A+1],j=f[A+2],Y=S[D>>2];D=S[(3&D)<<4|B>>4],B=S[(15&B)<<2|j>>6],j=S[63&j],E[_++]=Y+D+B+j}switch(Y=0,j=I,f.length-A){case 2:j=S[(15&(Y=f[A+1]))<<2]||I;case 1:f=f[A],E[_]=S[f>>2]+S[(3&f)<<4|Y>>4]+j+I}return E.join("")}function Te(f){var S=f.length,E=3*S/4;E%3?E=Math.floor(E):"=.".indexOf(f[S-1])!=-1&&(E="=.".indexOf(f[S-2])!=-1?E-2:E-1);var I=new Uint8Array(E),A=0;return(function(_,D){function B(ie){for(;j<_.length;){var xe=_.charAt(j++),ve=Re[xe];if(ve!=null)return ve;if(!/^[\s\xa0]*$/.test(xe))throw Error("Unknown base64 encoding at char: "+xe)}return ie}We();for(var j=0;;){var Y=B(-1),Q=B(0),re=B(64),se=B(64);if(se===64&&Y===-1)break;D(Y<<2|Q>>4),re!=64&&(D(Q<<4&240|re>>2),se!=64&&D(re<<6&192|se))}})(f,(function(_){I[A++]=_})),A!==E?I.subarray(0,A):I}function We(){if(!Re){Re={};for(var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),S=["+/=","+/","-_=","-_.","-_"],E=0;5>E;E++){var I=f.concat(S[E].split(""));fe[E]=I;for(var A=0;A<I.length;A++){var _=I[A];Re[_]===void 0&&(Re[_]=A)}}}}var Ne,Ye=typeof Uint8Array=="function";function Vt(f){return Ye&&f!=null&&f instanceof Uint8Array}function Vn(f){if(this.L=f,f!==null&&f.length===0)throw Error("ByteString should be constructed with non-empty values")}var ur=typeof Uint8Array.prototype.slice=="function",dn=0;function Na(f,S){return Error("Invalid wire type: "+f+" (at position "+S+")")}function zr(){return Error("Failed to read varint, encoding is invali
14919d.")}function Wt(f,S){S=(S=S===void 0?{}:S).v!==void 0&&S.v,this.h=null,this.g=this.i=this.j=0,this.v=S,f&&zt(this,f)}function zt(f,S){f.h=(function(E,I){if(E.constructor===Uint8Array)return E;if(E.constructor===ArrayBuffer)return new Uint8Array(E);if(E.constructor===Array)return new Uint8Array(E);if(E.constructor===String)return Te(E);if(E.constructor===Vn)return!I&&(I=E.L)&&I.constructor===Uint8Array?I:(I=(I=E.L)==null||Vt(I)?I:typeof I=="string"?Te(I):null,(E=E.L=I)?new Uint8Array(E):Ne||(Ne=new Uint8Array(0)));if(E instanceof Uint8Array)return new Uint8Array(E.buffer,E.byteOffset,E.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")})(S,f.v),f.j=0,f.i=f.h.length,f.g=f.j}function Ze(f){if(f.g>f.i)throw Error("Tried to read past the end of the data "+f.g+" > "+f.i)}function Wn(f){var S=f.h,E=S[f.g],I=127&E;if(128>E)return f.g+=1,Ze(f),I;if(I|=(127&(E=S[f.g+1]))<<7,128>E)return f.g+=2,Ze(f),I;if(I|=(127&(E=S[f.g+2]))<<14,128>E)return f.g+=3,Ze(f),I;if(I|=(127&(E=S[f.g+3]))<<21,128>E)return f.g+=4,Ze(f),I;if(E=S[f.g+4],f.g+=5,I|=(15&E)<<28,128>E)return Ze(f),I;if(128<=S[f.g++]&&128<=S[f.g++]&&128<=S[f.g++]&&128<=S[f.g++]&&128<=S[f.g++])throw zr();return Ze(f),I}Wt.prototype.reset=function(){this.g=this.j};var lr=[];function Gr(){this.g=[]}function Gt(f,S){for(;127<S;)f.g.push(127&S|128),S>>>=7;f.g.push(S)}function nn(f){var S={},E=S.W!==void 0&&S.W;this.l={v:S.v!==void 0&&S.v},this.W=E,S=this.l,lr.length?(E=lr.pop(),S&&(E.v=S.v),f&&zt(E,f),f=E):f=new Wt(f,S),this.g=f,this.j=this.g.g,this.h=this.i=-1}function zn(f){var S=f.g;if(S.g==S.i)return!1;f.j=f.g.g;var E=Wn(f.g)>>>0;if(S=E>>>3,!(0<=(E&=7)&&5>=E))throw Na(E,f.j);if(1>S)throw Error("Invalid field number: "+S+" (at position "+f.j+")");return f.i=S,f.h=E,!0}function Tt(f){switch(f.h){case 0:if(f.h!=0)Tt(f);else e:{for(var S=(f=f.g).g,E=S+10;S<E;)if((128&f.h[S++])==0){f.g=S,Ze(f);break e}throw zr()}break;case 1:(f=f.g).g+=8,Ze(f);break;case 2:f.h!=2?Tt(f):(S=Wn(f.g)>>>0,(f=f.g).g+=S,Ze(f));break;case 5:(f=f.g).g+=4,Ze(f);break;case 3:for(S=f.i;;){if(!zn(f))throw Error("Unmatched start-group tag: stream EOF");if(f.h==4){if(f.i!=S)throw Error("Unmatched end-group tag");break}Tt(f)}break;default:throw Na(f.h,f.j)}}Gr.prototype.length=function(){return this.g.length},Gr.prototype.end=function(){var f=this.g;return this.g=[],f},nn.prototype.reset=function(){this.g.reset(),this.j=this.g.g,this.h=this.i=-1};var rn=[];function jr(){this.i=[],this.h=0,this.g=new Gr}function et(f,S){S.length!==0&&(f.i.push(S),f.h+=S.length)}var cr=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol(void 0):void 0;function $a(f,S){Object.isFrozen(f)||(cr?f[cr]|=S:f.N!==void 0?f.N|=S:Object.defineProperties(f,{N:{value:S,configurable:!0,writable:!0,enumerable:!1}}))}function Ra(f){var S;return(S=cr?f[cr]:f.N)==null?0:S}function Tn(f){return $a(f,1),f}function jt(f){return!!Array.isArray(f)&&!!(2&Ra(f))}function pr(f){if(!Array.isArray(f))throw Error("cannot mark non-array as immutable");$a(f,2)}function Et(f){return f!==null&&typeof f=="object"&&!Array.isArray(f)&&f.constructor===Object}var hr=Object.freeze(Tn([]));function _a(f){if(jt(f.m))throw Error("Cannot mutate an immutable Message")}var Aa,ks=typeof Symbol<"u"&&Symbol.hasInstance!==void 0;function Ts(f){return{value:f,configurable:!1,writable:!1,enumerable:!1}}function lt(f,S,E){return S===-1?null:S>=f.i?f.g?f.g[S]:void 0:E!==void 0&&E&&f.g&&(E=f.g[S])!=null?E:f.m[S+f.h]}function Je(f,S,E,I){I=I!==void 0&&I,_a(f),S<f.i&&!I?f.m[S+f.h]=E:(f.g||(f.g=f.m[f.i+f.h]={}))[S]=E}function Qe(f,S,E,I){E=E===void 0||E;var A=lt(f,S,I=I!==void 0&&I);return A==null&&(A=hr),jt(f.m)?E&&(pr(A),Object.freeze(A)):(A===hr||jt(A))&&Je(f,S,A=Tn(A.slice()),I),A}function vt(f,S,E){return(f=(f=lt(f,S))==null?f:+f)==null?E===void 0?0:E:f}function dr(f,S,E,I){f.j||(f.j={});var A=jt(f.m),_=f.j[E];if(!_){I=Qe(f,E,!0,I!==void 0&&I),_=[],A=A||jt(I);for(var D=0;D<I.length;D++)_[D]=new S(I[D]),A&&pr(_[D].m);A&&(pr(_),Object.freeze(_)),f.j[E]=_}return _}function Me(f,S,E,I,A){var _=_!==void 0&&_;return _a(f),_=dr(f,E,S,_),E=I||new E,f=Qe(f,S),A!=null?(_.splice(A,0,E),f.splice(A,0,E.m)):(_.push(E),f.push(E.m)),E}function fr(f,S){return(f=lt(f,S))==null?0:f}function Oa(f,S){return(f=lt(f,S))==null?"":f}function fn(f){var S=Es;return ke(f,S=S===void 0?Hr:S)}function At(f,S){if(f!=null){if(Array.isArray(f))f=ke(f,S);else if(Et(f)){var E,I={};for(E in f)I[E]=At(f[E],S);f=I}else f=S(f);return f}}function ke(f,S){for(var E=f.slice(),I=0;I<E.length;I++)E[I]=At(E[I],S);return Array.isArray(f)&&1&Ra(f)&&Tn(E),E}function Es(f){return f&&typeof f=="object"&&f.toJSON?f.toJSON():(f=(function(S){switch(typeof S){case"number":return isFinite(S)?S:String(S);case"object":if(S&&!Array.isArray(S)){if(Vt(S))return ge(S);if(S instanceof Vn){var E=S.L;return E=E==null||typeof E=="string"?E:Ye&&E instanceof Uint8Array?ge(E):null,(S.L=E)||""}}}return S})(f),Array.isArray(f)?fn(f):f)}function Hr(f){return Vt(f)?new Uint8Array(f):f}function mr(f,S,E){f||(f=Aa),Aa=null;var I=this.constructor.h;if(f||(f=I?[I]:[]),this.h=(I?0:-1)-(this.constructor.g||0),this.j=void 0,this.m=f,f=(I=this.m.length)-1,I&&Et(I=this.m[f])?(this.i=f-this.h,this.g=I):S!==void 0&&-1<S?(this.i=Math.max(S,f+1-this.h),this.g=void 0):this.i=Number.MAX_VALUE,E)for(S=0;S<E.length;S++)if((f=E[S])<this.i)f+=this.h,(I=this.m[f])?Array.isArray(I)&&Tn(I):this.m[f]=hr;else{var A=(I=this.g||(this.g=this.m[this.i+this.h]={}))[f];A?Array.isArray(A)&&Tn(A):I[f]=hr}}function gr(){mr.apply(this,arguments)}if(mr.prototype.toJSON=function(){return fn(this.m)},mr.prototype.toString=function(){return this.m.toString()},d(gr,mr),ks){var mn={};Object.defineProperties(gr,(mn[Symbol.hasInstance]=Ts((function(){throw Error("Cannot perform instanceof checks for MutableMessage")})),mn))}function Xr(f,S,E){if(E){var I,A={};for(I in E){var _=E[I],D=_.ha;D||(A.F=_.la||_.fa.P,_.aa?(A.U=Is(_.aa),D=(function(B){return function(j,Y,Q){return B.F(j,Y,Q,B.U)}})(A)):_.ca?(A.T=qr(_.X.g,_.ca),D=(function(B){return function(j,Y,Q){return B.F(j,Y,Q,B.T)}})(A)):D=A.F,_.ha=D),D(S,f,_.X),A={F:A.F,U:A.U,T:A.T}}}(function(B,j){if(j=j.ba){et(B,B.g.end());for(var Y=0;Y<j.length;Y++)et(B,j[Y])}})(S,f)}var Ot=Symbol();function gn(f,S,E){return f[Ot]||(f[Ot]=function(I,A){return S(I,A,E)})}function Cs(f){var S=f[Ot];if(!S){var E=As(f);S=function(I,A){return Fa(I,A,E)},f[Ot]=S}return S}function Vo(f){var S=(function(A){var _=A.aa;return _?Cs(_):(_=A.ka)?gn(A.X.g,_,A.ca):void 0})(f),E=f.X,I=f.fa.O;return S?function(A,_){return I(A,_,E,S)}:function(A,_){return I(A,_,E)}}function at(f,S,E,I,A,_){var D=0;for((f=f()).length&&typeof f[0]!="number"&&(E(S,f[0]),D++);D<f.length;){E=f[D++];for(var B=D+1;B<f.length&&typeof f[B]!="number";)B++;var j=f[D++];switch(B-=D){case 0:I(S,E,j);break;
vendor: 23,552 bytes, lines 14919-14936
14919case 1:I(S,E,j,f[D++]);break;case 2:A(S,E,j,f[D++],f[D++]);break;case 3:B=f[D++];var Y=f[D++],Q=f[D++];Array.isArray(Q)?A(S,E,j,B,Y,Q):_(S,E,j,B,Y,Q);break;case 4:_(S,E,j,f[D++],f[D++],f[D++],f[D++]);break;default:throw Error("unexpected number of binary field arguments: "+B)}}return S}var yn=Symbol();function Is(f){var S=f[yn];if(!S){var E=_s(f);S=function(I,A){return Ma(I,A,E)},f[yn]=S}return S}function qr(f,S){var E=f[yn];return E||(E=function(I,A){return Xr(I,A,S)},f[yn]=E),E}var Ns=Symbol();function Gn(f,S){f.push(S)}function Wo(f,S,E){f.push(S,E.P)}function $s(f,S,E,I,A){var _=Is(A),D=E.P;f.push(S,(function(B,j,Y){return D(B,j,Y,I,_)}))}function Rs(f,S,E,I,A,_){var D=qr(I,_),B=E.P;f.push(S,(function(j,Y,Q){return B(j,Y,Q,I,D)}))}function _s(f){var S=f[Ns];return S||at(f,f[Ns]=[],Gn,Wo,$s,Rs)}var Kr=Symbol();function En(f,S){f[0]=S}function zo(f,S,E,I){var A=E.O;f[S]=I?function(_,D,B){return A(_,D,B,I)}:A}function Go(f,S,E,I,A,_){var D=E.O,B=Cs(A);f[S]=function(j,Y,Q){return D(j,Y,Q,I,B,_)}}function Yr(f,S,E,I,A,_,D){var B=E.O,j=gn(I,A,_);f[S]=function(Y,Q,re){return B(Y,Q,re,I,j,D)}}function As(f){var S=f[Kr];return S||at(f,f[Kr]={},En,zo,Go,Yr)}function Fa(f,S,E){for(;zn(S)&&S.h!=4;){var I=S.i,A=E[I];if(!A){var _=E[0];_&&(_=_[I])&&(A=E[I]=Vo(_))}if(!(A&&A(S,f,I)||(A=S,I=f,_=A.j,Tt(A),A.W))){var D=A.g.h;A=_===(A=A.g.g)?Ne||(Ne=new Uint8Array(0)):ur?D.slice(_,A):new Uint8Array(D.subarray(_,A)),(_=I.ba)?_.push(A):I.ba=[A]}}return f}function Da(f,S,E){if(rn.length){var I=rn.pop();f&&(zt(I.g,f),I.i=-1,I.h=-1),f=I}else f=new nn(f);try{return Fa(new S,f,As(E))}finally{(S=f.g).h=null,S.j=0,S.i=0,S.g=0,S.v=!1,f.i=-1,f.h=-1,100>rn.length&&rn.push(f)}}function Ma(f,S,E){for(var I=E.length,A=I%2==1,_=A?1:0;_<I;_+=2)(0,E[_+1])(S,f,E[_]);Xr(f,S,A?E[0]:void 0)}function yr(f,S){var E=new jr;Ma(f,E,_s(S)),et(E,E.g.end()),f=new Uint8Array(E.h);for(var I=(S=E.i).length,A=0,_=0;_<I;_++){var D=S[_];f.set(D,A),A+=D.length}return E.i=[f],f}function jn(f,S){return{O:f,P:S}}var Ft=jn((function(f,S,E){if(f.h!==5)return!1;var I=(f=f.g).h[f.g],A=f.h[f.g+1],_=f.h[f.g+2],D=f.h[f.g+3];return f.g+=4,Ze(f),f=2*((A=(I<<0|A<<8|_<<16|D<<24)>>>0)>>31)+1,I=A>>>23&255,A&=8388607,Je(S,E,I==255?A?NaN:1/0*f:I==0?f*Math.pow(2,-149)*A:f*Math.pow(2,I-150)*(A+Math.pow(2,23))),!0}),(function(f,S,E){if((S=lt(S,E))!=null){Gt(f.g,8*E+5),f=f.g;var I=S;(I=(E=0>I?1:0)?-I:I)===0?0<1/I?dn=0:dn=2147483648:isNaN(I)?dn=2147483647:34028234663852886e22<I?dn=(E<<31|2139095040)>>>0:11754943508222875e-54>I?(I=Math.round(I/Math.pow(2,-149)),dn=(E<<31|I)>>>0):(S=Math.floor(Math.log(I)/Math.LN2),I*=Math.pow(2,-S),16777216<=(I=Math.round(8388608*I))&&++S,dn=(E<<31|S+127<<23|8388607&I)>>>0),E=dn,f.g.push(E>>>0&255),f.g.push(E>>>8&255),f.g.push(E>>>16&255),f.g.push(E>>>24&255)}})),jo=jn((function(f,S,E){if(f.h!==0)return!1;for(var I=f.g,A=128,_=0,D=f=0;4>D&&128<=A;D++)A=I.h[I.g++],Ze(I),_|=(127&A)<<7*D;if(128<=A&&(A=I.h[I.g++],Ze(I),_|=(127&A)<<28,f|=(127&A)>>4),128<=A)for(D=0;5>D&&128<=A;D++)A=I.h[I.g++],Ze(I),f|=(127&A)<<7*D+3;if(!(128>A))throw zr();return I=_>>>0,(f=2147483648&(A=f>>>0))&&(A=~A>>>0,(I=1+~I>>>0)==0&&(A=A+1>>>0)),I=4294967296*A+(I>>>0),Je(S,E,f?-I:I),!0}),(function(f,S,E){if((S=lt(S,E))!=null&&S!=null){Gt(f.g,8*E),f=f.g;var I=S;for(E=0>I,S=(I=Math.abs(I))>>>0,I=Math.floor((I-S)/4294967296),I>>>=0,E&&(I=~I>>>0,4294967295<(S=1+(~S>>>0))&&(S=0,4294967295<++I&&(I=0))),E=dn=S,S=I;0<S||127<E;)f.g.push(127&E|128),E=(E>>>7|S<<25)>>>0,S>>>=7;f.g.push(E)}})),Ho=jn((function(f,S,E){return f.h===0&&(Je(S,E,Wn(f.g)),!0)}),(function(f,S,E){if((S=lt(S,E))!=null&&S!=null)if(Gt(f.g,8*E),f=f.g,0<=(E=S))Gt(f,E);else{for(S=0;9>S;S++)f.g.push(127&E|128),E>>=7;f.g.push(1)}})),Os=jn((function(f,S,E){if(f.h!==2)return!1;var I,A=Wn(f.g)>>>0,_=(f=f.g).g;if(f.g+=A,Ze(f),f=f.h,le)(I=ee)||(I=ee=new TextDecoder("utf-8",{fatal:!0})),I=I.decode(f.subarray(_,_+A));else{A=_+A;for(var D,B,j,Y=[],Q=null;_<A;)128>(D=f[_++])?Y.push(D):224>D?_>=A?C():(B=f[_++],194>D||(192&B)!=128?(_--,C()):Y.push((31&D)<<6|63&B)):240>D?_>=A-1?C():(192&(B=f[_++]))!=128||D===224&&160>B||D===237&&160<=B||(192&(I=f[_++]))!=128?(_--,C()):Y.push((15&D)<<12|(63&B)<<6|63&I):244>=D?_>=A-2?C():(192&(B=f[_++]))!=128||B-144+(D<<28)>>30!=0||(192&(I=f[_++]))!=128||(192&(j=f[_++]))!=128?(_--,C()):(D=(7&D)<<18|(63&B)<<12|(63&I)<<6|63&j,D-=65536,Y.push(55296+(D>>10&1023),56320+(1023&D))):C(),8192<=Y.length&&(Q=q(Q,Y),Y.length=0);I=q(Q,Y)}return Je(S,E,I),!0}),(function(f,S,E){if((S=lt(S,E))!=null){var I=!1;if(I=I!==void 0&&I,de){if(I&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(S))throw Error("Found an unpaired surrogate");S=(te||(te=new TextEncoder)).encode(S)}else{for(var A=0,_=new Uint8Array(3*S.length),D=0;D<S.length;D++){var B=S.charCodeAt(D);if(128>B)_[A++]=B;else{if(2048>B)_[A++]=B>>6|192;else{if(55296<=B&&57343>=B){if(56319>=B&&D<S.length){var j=S.charCodeAt(++D);if(56320<=j&&57343>=j){B=1024*(B-55296)+j-56320+65536,_[A++]=B>>18|240,_[A++]=B>>12&63|128,_[A++]=B>>6&63|128,_[A++]=63&B|128;continue}D--}if(I)throw Error("Found an unpaired surrogate");B=65533}_[A++]=B>>12|224,_[A++]=B>>6&63|128}_[A++]=63&B|128}}S=_.subarray(0,A)}Gt(f.g,8*E+2),Gt(f.g,S.length),et(f,f.g.end()),et(f,S)}})),La=jn((function(f,S,E,I,A){if(f.h!==2)return!1;S=Me(S,E,I),E=f.g.i,I=Wn(f.g)>>>0;var _=f.g.g+I,D=_-E;if(0>=D&&(f.g.i=_,A(S,f),D=_-f.g.g),D)throw Error("Message parsing ended unexpectedly. Expected to read "+I+" bytes, instead read "+(I-D)+" bytes, either the data ended unexpectedly or the message misreported its own length");return f.g.g=_,f.g.i=E,!0}),(function(f,S,E,I,A){if((S=dr(S,I,E))!=null)for(I=0;I<S.length;I++){var _=f;Gt(_.g,8*E+2);var D=_.g.end();et(_,D),D.push(_.h),_=D,A(S[I],f),D=f;var B=_.pop();for(B=D.h+D.g.length()-B;127<B;)_.push(127&B|128),B>>>=7,D.h++;_.push(B),D.h++}}));function Ct(){gr.apply(this,arguments)}if(d(Ct,gr),ks){var Fs={};Object.defineProperties(Ct,(Fs[Symbol.hasInstance]=Ts(Object[Symbol.hasInstance]),Fs))}function Cn(f){Ct.call(this,f)}function Ds(){return[1,Ho,2,Ft,3,Os,4,Os]}function Pa(f){Ct.call(this,f,-1,qo)}function Xo(){return[1,La,Cn,Ds]}d(Cn,Ct),d(Pa,Ct),Pa.prototype.addClassification=function(f,S){return Me(this,1,Cn,f,S),this};var qo=[1];function Hn(f){Ct.call(this,f)}function Ms(){return[1,Ft,2,Ft,3,Ft,4,Ft,5,Ft]}function Ls(f){Ct.call(this,f,-1,Yo)}function Ko(){return[1,La,Hn,Ms]}d(Hn,Ct),d(Ls,Ct);var Yo=[1];function Ba(f){Ct.call(this,f)}function Ua(){return[1,Ft,2,Ft,3,Ft,4,Ft,5,Ft,6,jo]}d(Ba,Ct);var Va=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],Wa=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],za=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Ga=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],ja=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Ps=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],Bs=[].concat(i(Va),i(Wa),i(za),i(Ga),i(ja),i(Ps));function g(f,S,E){if(E=f.createShader(E===0?f.VERTEX_SHADER:f.FRAGMENT_SHADER),f.shaderSource(E,S),f.compileShader(E),!f.getShaderParameter(E,f.COMPILE_STATUS))throw Error(`Could not compile WebGL shader. 14920 14921`+f.getShaderInfoLog(E));return E}function v(f){return dr(f,Cn,1).map((function(S){return{index:fr(S,1),ga:vt(S,2),label:lt(S,3)!=null?Oa(S,3):void 0,displayName:lt(S,4)!=null?Oa(S,4):void 0}}))}function k(f){return{x:vt(f,1),y:vt(f,2),z:vt(f,3),visibility:lt(f,4)!=null?vt(f,4):void 0}}function O(f,S){this.h=f,this.g=S,this.l=0}function W(f,S,E){return(function(I,A){var _=I.g;if(I.o===void 0){var D=g(_,` 14922 attribute vec2 aVertex; 14923 attribute vec2 aTex; 14924 varying vec2 vTex; 14925 void main(void) { 14926 gl_Position = vec4(aVertex, 0.0, 1.0); 14927 vTex = aTex; 14928 }`,0),B=g(_,` 14929 precision mediump float; 14930 varying vec2 vTex; 14931 uniform sampler2D sampler0; 14932 void main(){ 14933 gl_FragColor = texture2D(sampler0, vTex); 14934 }`,1),j=_.createProgram();if(_.attachShader(j,D),_.attachShader(j,B),_.linkProgram(j),!_.getProgramParameter(j,_.LINK_STATUS))throw Error(`Could not compile WebGL program. 14935 14936`+_.getProgramInfoLog(j));D=I.o=j,_.useProgram(D),B=_.getUniformLocation(D,"sampler0"),I.j={K:_.getAttribLocation(D,"aVertex"),J:_.getAttribLocation(D,"aTex"),ma:B},I.u=_.createBuffer(),_.bindBuffer(_.ARRAY_BUFFER,I.u),_.enableVertexAttribArray(I.j.K),_.vertexAttribPointer(I.j.K,2,_.FLOAT,!1,0,0),_.bufferData(_.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),_.STATIC_DRAW),_.bindBuffer(_.ARRAY_BUFFER,null),I.s=_.createBuffer(),_.bindBuffer(_.ARRAY_BUFFER,I.s),_.enableVertexAttribArray(I.j.J),_.vertexAttribPointer(I.j.J,2,_.FLOAT,!1,0,0),_.bufferData(_.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),_.STATIC_DRAW),_.bindBuffer(_.ARRAY_BUFFER,null),_.uniform1i(B,0)}D=I.j,_.useProgram(I.o),_.canvas.width=A.width,_.canvas.height=A.height,_.viewport(0,0,A.width,A.height),_.activeTexture(_.TEXTURE0),I.h.bindTexture2d(A.glName),_.enableVertexAttribArray(D.K),_.bindBuffer(_.ARRAY_BUFFER,I.u),_.vertexAttribPointer(D.K,2,_.FLOAT,!1,0,0),_.enableVertexAttribArray(D.J),_.bindBuffer(_.ARRAY_BUFFER,I.s),_.vertexAttribPointer(D.J,2,_.FLOAT,!1,0,0),_.bindFramebuffer(_.DRAW_FRAMEBUFFER?_.DRAW_FRAMEBUFFER:_.FRAMEBUFFER,null),_.clearColor(0,0,0,0),_.clear(_.COLOR_BUFFER_BIT),_.colorMask(!0,!0,!0,!0),_.drawArrays(_.TRIANGLE_FAN,0,4),_.disableVertexAttribArray(D.K),_.disableVertexAttribArray(D.J),_.bindBuffer(_.ARRAY_BUFFER,null),I.h.bindTexture2d(0)})(f,S),typeof f.g.canvas.transferToImageBitmap=="function"?Promise.resolve(f.g.canvas.transferToImageBitmap()):E?Promise.resolve(f.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(f.g.canvas):(f.i===void 0&&(f.i=document.createElement("canvas")),new Promise((function(I){f.i.height=f.g.canvas.height,f.i.width=f.g.canvas.width,f.i.getContext("2d",{}).drawImage(f.g.canvas,0,0,f.g.canvas.width,f.g.canvas.height),I(f.i)})))}function K(f){this.g=f}var G=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function J(f,S){return S+f}function ne(f,S){window[f]=S}function ue(f){if(this.g=f,this.listeners={},this.j={},this.H={},this.o={},this.u={},this.I=this.s=this.Z=!0,this.D=Promise.resolve(),this.Y="",this.C={},this.locateFile=f&&f.locateFile||J,typeof window=="object")var S=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(typeof location>"u")throw Error("solutions can only be loaded on a web page or in a web worker");S=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.$=S,f.options)for(var E=(S=o(Object.keys(f.options))).next();!E.done;E=S.next()){E=E.value;var I=f.options[E].default;I!==void 0&&(this.j[E]=typeof I=="function"?I():I)}}function ye(f){var S,E,I,A,_,D,B,j,Y,Q,re;return U((function(se){switch(se.g){case 1:return f.Z?(S=f.g.files===void 0?[]:typeof f.g.files=="function"?f.g.files(f.j):f.g.files,x(se,U((function(ie){switch(ie.g){case 1:return ie.o=2,x(ie,WebAssembly.instantiate(G),4);case 4:ie.g=3,ie.o=0;break;case 2:return ie.o=0,ie.j=null,ie.return(!1);case 3:return ie.return(!0)}})),2)):se.return();case 2:if(E=se.h,typeof window=="object")return ne("createMediapipeSolutionsWasm",{locateFile:f.locateFile}),ne("createMediapipeSolutionsPackedAssets",{locateFile:f.locateFile}),D=S.filter((function(ie){return ie.data!==void 0})),B=S.filter((function(ie){return ie.data===void 0})),j=Promise.all(D.map((function(ie){var xe=Ee(f,ie.url);if(ie.path!==void 0){var ve=ie.path;xe=xe.then((function(Fe){return f.overrideFile(ve,Fe),Promise.resolve(Fe)}))}return xe}))),Y=Promise.all(B.map((function(ie){return ie.simd===void 0||ie.simd&&E||!ie.simd&&!E?(function(xe){var ve=document.createElement("script");return ve.setAttribute("src",xe),ve.setAttribute("crossorigin","anonymous"),new Promise((function(Fe){ve.addEventListener("load",(function(){Fe()}),!1),ve.addEventListener("error",(function(){Fe()}),!1),document.body.appendChild(ve)}))})(f.locateFile(ie.url,f.$)):Promise.resolve()}))).then((function(){var ie,xe,ve;return U((function(Fe){if(Fe.g==1)return ie=window.createMediapipeSolutionsWasm,xe=window.createMediapipeSolutionsPackedAssets,ve=f,x(Fe,ie(xe),2);ve.h=Fe.h,Fe.g=0}))})),Q=U((function(ie){return f.g.graph&&f.g.graph.url?ie=x(ie,Ee(f,f.g.graph.url),0):(ie.g=0,ie=void 0),ie})),x(se,Promise.all([Y,j,Q]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return I=S.filter((function(ie){return ie.simd===void 0||ie.simd&&E||!ie.simd&&!E})).map((function(ie){return f.locateFile(ie.url,f.$)})),importScripts.apply(null,i(I)),A=f,x(se,createMediapipeSolutionsWasm(Module),6);case 6:A.h=se.h,f.l=new OffscreenCanvas(1,1),f.h.canvas=f.l,_=f.h.GL.createContext(f.l,{antialias:!1,alpha:!1,ja:typeof WebGL2RenderingContext<"u"?2:1}),f.h.GL.makeContextCurrent(_),se.g=4;break;case 7:if(f.l=document.createElement("canvas"),!(re=f.l.getContext("webgl2",{}))&&!(re=f.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),se.return();f.G=re,f.h.canvas=f.l,f.h.createContext(f.l,!0,!0,{});case 4:f.i=new f.h.SolutionWasm,f.Z=!1,se.g=0}}))}function Ee(f,S){var E,I;return U((function(A){return S in f.H?A.return(f.H[S]):(E=f.locateFile(S,""),I=fetch(E).then((function(_){return _.arrayBuffer()})),f.H[S]=I,A.return(I))}))}function Se(f,S,E){var I,A,_,D,B,j,Y,Q,re,se,ie,xe,ve,Fe;return U((function(Ue){switch(Ue.g){case 1:if(!E)return Ue.return(S);for(I={},A=0,_=o(Object.keys(E)),D=_.next();!D.done;D=_.next())B=D.value,typeof(j=E[B])!="string"&&j.type==="texture"&&S[j.stream]!==void 0&&++A;1<A&&(f.I=!1),Y=o(Object.keys(E)),D=Y.next();case 2:if(D.done){Ue.g=4;break}if(Q=D.value,typeof(re=E[Q])=="string")return ve=I,Fe=Q,x(Ue,(function(xr,hl,Zr){var Us;return U((function(Zo){return typeof Zr=="number"||Zr instanceof Uint8Array||Zr instanceof xr.h.Uint8BlobList?Zo.return(Zr):Zr instanceof xr.h.Texture2dDataOut?((Us=xr.u[hl])||(Us=new O(xr.h,xr.G),xr.u[hl]=Us),Zo.return(W(Us,Zr,xr.I))):Zo.return(void 0)}))})(f,Q,S[re]),14);if(se=S[re.stream],re.type==="detection_list"){if(se){for(var wt=se.getRectList(),Ht=se.getLandmarksList(),It=se.getClassificationsList(),_e=[],ct=0;ct<wt.size();++ct){var Xn=Da(wt.get(ct),Ba,Ua);Xn={boundingBox:{xCenter:vt(Xn,1),yCenter:vt(Xn,2),height:vt(Xn,3),width:vt(Xn,4),rotation:vt(Xn,5,0),rectId:fr(Xn,6)},landmarks:dr(Da(Ht.get(ct),Ls,Ko),Hn,1).map(k),V:v(Da(It.get(ct),Pa,Xo))},_e.push(Xn)}wt=_e}else wt=[];I[Q]=wt,Ue.g=7;break}if(re.type==="proto_list"){if(se){for(wt=Array(se.size()),Ht=0;Ht<se.size();Ht++)wt[Ht]=se.get(Ht);se.delete()}else wt=[];I[Q]=wt,Ue.g=7;break}if(se===void 0){Ue.g=3;break}if(re.type==="float_list"){I[Q]=se,Ue.g=7;break}if(re.type==="proto"){I[Q]=se,Ue.g=7;break}if(re.type!=="texture")throw Error("Unknown output config type: '"+re.type+"'");return(ie=f.u[Q])||(ie=new O(f.h,f.G),f.u[Q]=ie),x(Ue,W(ie,se,f.I),13);case 13:xe=Ue.h,I[Q]=xe;case 7:re.transform&&I[Q]&&(I[Q]=re.transform(I[Q])),Ue.g=3;break;case 14:ve[Fe]=Ue.h;case 3:D=Y.next(),Ue.g=2;break;case 4:return Ue.return(I)}}))}function be(f,S){for(var E=S.name||"$",I=[].concat(i(S.wants)),A=new f.h.StringList,_=o(S.wants),D=_.next();!D.done;D=_.next())A.push_back(D.value);_=f.h.PacketListener.implement({onResults:function(B){for(var j={},Y=0;Y<S.wants.length;++Y)j[I[Y]]=B.get(Y);var Q=f.listeners[E];Q&&(f.D=Se(f,j,S.outs).then((function(re){re=Q(re);for(var se=0;se<S.wants.length;++se){var ie=j[I[se]];typeof ie=="object"&&ie.hasOwnProperty&&ie.hasOwnProperty("delete")&&ie.delete()}re&&(f.D=re)})))}}),f.i.attachMultiListener(A,_),A.delete()}function pe(f){var S=this;f=f||{};var E={url:"face_detection_short.binarypb"},I={type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}};this.g=new ue({locateFile:f.locateFile,files:[{data:!0,url:"face_detection_short.binarypb"},{data:!0,url:"face_detection_short_range.tflite"},{simd:!0,url:"face_detection_solution_simd_wasm_bin.js"},{simd:!1,url:"face_detection_solution_wasm_bin.js"}],graph:E,listeners:[{wants:["detections","image_transformed"],outs:{image:"image_transformed",detections:{type:"detection_list",stream:"detections"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:typeof window=="object"&&window.navigator!==void 0&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},model:{type:0,onChange:function(A){var _,D,B,j,Y;return U((function(Q){switch(Q.g){case 1:_=o(A==="short"?["face_detection_short_range.tflite"]:["face_detection_full_range_sparse.tflite"]),D=_.next();case 2:if(D.done){Q.g=4;break}return B=D.value,j="third_party/mediapipe/modules/face_detection/"+B,x(Q,Ee(S.g,B),5);case 5:Y=Q.h,S.g.overrideFile(j,Y),D=_.next(),Q.g=2;break;case 4:return E.url=A==="short"?"face_detection_short.binarypb":"face_detection_full.binarypb",I.graphOptionXref.calculatorName=A==="short"?"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator":"facedetectionfullrangegpu__facedetectionfullrangecommon__TensorsToDetectionsCalculator",Q.return(!0)}}))}},minDetectionConfidence:I}})}(n=ue.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},n.reset=function(){var f=this;return U((function(S){f.i&&(f.i.reset(),f.o={},f.u={}),S.g=0}))},n.setOptions=function(f,S){var E=this;if(S=S||this.g.options){for(var I=[],A=[],_={},D=o(Object.keys(f)),B=D.next();!B.done;_={R:_.R,S:_.S},B=D.next()){var j=B.value;j in this.j&&this.j[j]===f[j]||(this.j[j]=f[j],(B=S[j])!==void 0&&(B.onChange&&(_.R=B.onChange,_.S=f[j],I.push((function(Y){return function(){return U((function(Q){if(Q.g==1)return x(Q,Y.R(Y.S),2);Q.h===!0&&(E.s=!0),Q.g=0}))}})(_))),B.graphOptionXref&&(j={valueNumber:B.type===1?f[j]:0,valueBoolean:B.type===0&&f[j],valueString:B.type===2?f[j]:""},B=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),B.graphOptionXref),j),A.push(B))))}I.length===0&&A.length===0||(this.s=!0,this.B=(this.B===void 0?[]:this.B).concat(A),this.A=(this.A===void 0?[]:this.A).concat(I))}},n.initialize=function(){var f=this;return U((function(S){return S.g==1?x(S,ye(f),2):S.g!=3?x(S,(function(E){var I,A,_,D,B,j,Y,Q;return U((function(re){if(re.g==1)return E.g.graph&&E.g.graph.url&&E.Y===E.g.graph.url?re.return():(E.s=!0,E.g.graph&&E.g.graph.url?(E.Y=E.g.graph.url,x(re,Ee(E,E.g.graph.url),3)):void(re.g=2));for(re.g!=2&&(I=re.h,E.i.loadGraph(I)),A=o(Object.keys(E.C)),_=A.next();!_.done;_=A.next())D=_.value,E.i.overrideFile(D,E.C[D]);if(E.C={},E.g.listeners)for(B=o(E.g.listeners),j=B.next();!j.done;j=B.next())Y=j.value,be(E,Y);Q=E.j,E.j={},E.setOptions(Q),re.g=0}))})(f),3):x(S,(function(E){var I,A,_,D,B,j;return U((function(Y){switch(Y.g){case 1:if(!E.s)return Y.return();if(!E.A){Y.g=2;break}I=o(E.A),A=I.next();case 3:if(A.done){Y.g=5;break}return x(Y,(0,A.value)(),4);case 4:A=I.next(),Y.g=3;break;case 5:E.A=void 0;case 2:if(E.B){for(_=new E.h.GraphOptionChangeRequestList,D=o(E.B),B=D.next();!B.done;B=D.next())j=B.value,_.push_back(j);E.i.changeOptions(_),_.delete(),E.B=void 0}E.s=!1,Y.g=0}}))})(f),0)}))},n.overrideFile=function(f,S){this.i?this.i.overrideFile(f,S):this.C[f]=S},n.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},n.send=function(f,S){var E,I,A,_,D,B,j,Y,Q,re=this;return U((function(se){switch(se.g){case 1:return re.g.inputs?(E=1e3*(S??performance.now()),x(se,re.D,2)):se.return();case 2:return x(se,re.initialize(),3);case 3:for(I=new re.h.PacketDataList,A=o(Object.keys(f)),_=A.next();!_.done;_=A.next())if(D=_.value,B=re.g.inputs[D]){e:{var ie=f[D];switch(B.type){case"video":var xe=re.o[B.stream];if(xe||(xe=new O(re.h,re.G),re.o[B.stream]=xe),xe.l===0&&(xe.l=xe.h.createTexture()),typeof HTMLVideoElement<"u"&&ie instanceof HTMLVideoElement)var ve=ie.videoWidth,Fe=ie.videoHeight;else typeof HTMLImageElement<"u"&&ie instanceof HTMLImageElement?(ve=ie.naturalWidth,Fe=ie.naturalHeight):(ve=ie.width,Fe=ie.height);Fe={glName:xe.l,width:ve,height:Fe},(ve=xe.g).canvas.width=Fe.width,ve.canvas.height=Fe.height,ve.activeTexture(ve.TEXTURE0),xe.h.bindTexture2d(xe.l),ve.texImage2D(ve.TEXTURE_2D,0,ve.RGBA,ve.RGBA,ve.UNSIGNED_BYTE,ie),xe.h.bindTexture2d(0),xe=Fe;break e;case"detections":for((xe=re.o[B.stream])||(xe=new K(re.h),re.o[B.stream]=xe),xe.data||(xe.data=new xe.g.DetectionListData),xe.data.reset(ie.length),Fe=0;Fe<ie.length;++Fe){ve=ie[Fe];var Ue=xe.data,wt=Ue.setBoundingBox,Ht=Fe,It=ve.boundingBox,_e=new Ba;if(Je(_e,1,It.xCenter),Je(_e,2,It.yCenter),Je(_e,3,It.height),Je(_e,4,It.width),Je(_e,5,It.rotation),Je(_e,6,It.rectId),It=yr(_e,Ua),wt.call(Ue,Ht,It),ve.landmarks)for(Ue=0;Ue<ve.landmarks.length;++Ue){var ct=!!(_e=ve.landmarks[Ue]).visibility;Ht=(wt=xe.data).addNormalizedLandmark,It=Fe,_e=Object.assign(Object.assign({},_e),{visibility:ct?_e.visibility:0}),Je(ct=new Hn,1,_e.x),Je(ct,2,_e.y),Je(ct,3,_e.z),_e.visibility&&Je(ct,4,_e.visibility),_e=yr(ct,Ms),Ht.call(wt,It,_e)}if(ve.V)for(Ue=0;Ue<ve.V.length;++Ue)Ht=(wt=xe.data).addClassification,It=Fe,_e=ve.V[Ue],Je(ct=new Cn,2,_e.ga),_e.index&&Je(ct,1,_e.index),_e.label&&Je(ct,3,_e.label),_e.displayName&&Je(ct,4,_e.displayName),_e=yr(ct,Ds),Ht.call(wt,It,_e)}xe=xe.data;break e;default:xe={}}}switch(j=xe,Y=B.stream,B.type){case"video":I.pushTexture2d(Object.assign(Object.assign({},j),{stream:Y,timestamp:E}));break;case"detections":(Q=j).stream=Y,Q.timestamp=E,I.pushDetectionList(Q);break;default:throw Error("Unknown input config type: '"+B.type+"'")}}return re.i.send(I),x(se,re.D,4);case 4:I.delete(),se.g=0}}))},n.onResults=function(f,S){this.listeners[S||"$"]=f},L("Solution",ue),L("OptionType",{BOOL:0,NUMBER:1,ia:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(n=pe.prototype).close=function(){return this.g.close(),Promise.resolve()},n.onResults=function(f){this.g.onResults(f)},n.initialize=function(){var f=this;return U((function(S){return x(S,f.g.initialize(),0)}))},n.reset=function(){this.g.reset()},n.send=function(f){var S=this;return U((function(E){return x(E,S.g.send(f),0)}))},n.setOptions=function(f){this.g.setOptions(f)},L("FaceDetection",pe),L("FACEDETECTION_LIPS",Va),L("FACEDETECTION_LEFT_EYE",Wa),L("FACEDETECTION_LEFT_EYEBROW",za),L("FACEDETECTION_RIGHT_EYE",Ga),L("FACEDETECTION_RIGHT_EYEBROW",ja),L("FACEDETECTION_FACE_OVAL",Ps),L("FACEDETECTION_CONTOURS",Bs),L("FACEDETECTION_TESSELATION",[
vendor: 24,341 bytes, line 14936
14936[127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]
14936]),L("VERSION","0.4.1646425229")}).call(yi);var nr=function(){return nr=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var a in e=arguments[t])Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n},nr.apply(this,arguments)};function Ln(n,e,t,r){return new(t||(t=Promise))((function(a,s){function o(l){try{u(r.next(l))}catch(c){s(c)}}function i(l){try{u(r.throw(l))}catch(c){s(c)}}function u(l){var c;l.done?a(l.value):(c=l.value,c instanceof t?c:new t((function(p){p(c)}))).then(o,i)}u((r=r.apply(n,[])).next())}))}function Pn(n,e){var t,r,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(u){return function(l){return(function(c){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||c[0]!==6&&c[0]!==2)){o=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(c[0]===6&&o.label<a[1]){o.label=a[1],a=c;break}
vendor: 26,814 bytes, line 14936
14936if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=e.call(n,o)}catch(p){c=[6,p],r=0}finally{t=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}})([u,l])}}}var Zm=["rightEye","leftEye","noseTip","mouthCenter","rightEarTragion","leftEarTragion"],xi={modelType:"short",runtime:"mediapipe",maxFaces:1},f_=(function(){function n(e){var t=this;this.width=0,this.height=0,this.selfieMode=!1,this.faceDetectorSolution=new d_.FaceDetection({locateFile:function(r,a){return e.solutionPath?e.solutionPath.replace(/\/+$/,"")+"/"+r:a+"/"+r}}),this.faceDetectorSolution.setOptions({selfieMode:this.selfieMode,model:e.modelType}),this.faceDetectorSolution.onResults((function(r){if(t.height=r.image.height,t.width=r.image.width,t.faces=[],r.detections!==null)for(var a=0,s=r.detections;a<s.length;a++){var o=s[a];t.faces.push(t.normalizedToAbsolute(o.landmarks,{xMin:u=(i=o.boundingBox).xCenter-i.width/2,xMax:u+i.width,yMin:l=i.yCenter-i.height/2,yMax:l+i.height,width:i.width,height:i.height}))}var i,u,l}))}return n.prototype.normalizedToAbsolute=function(e,t){var r=this;return{keypoints:e.map((function(a,s){return{x:a.x*r.width,y:a.y*r.height,name:Zm[s]}})),box:{xMin:t.xMin*this.width,yMin:t.yMin*this.height,xMax:t.xMax*this.width,yMax:t.yMax*this.height,width:t.width*this.width,height:t.height*this.height}}},n.prototype.estimateFaces=function(e,t){return Ln(this,void 0,void 0,(function(){var r,a;return Pn(this,(function(s){switch(s.label){case 0:return t&&t.flipHorizontal&&t.flipHorizontal!==this.selfieMode&&(this.selfieMode=t.flipHorizontal,this.faceDetectorSolution.setOptions({selfieMode:this.selfieMode})),e instanceof Ge?(a=ImageData.bind,[4,cf(e)]):[3,2];case 1:return r=new(a.apply(ImageData,[void 0,s.sent(),e.shape[1],e.shape[0]])),[3,3];case 2:r=e,s.label=3;case 3:return e=r,[4,this.faceDetectorSolution.send({image:e})];case 4:return s.sent(),[2,this.faces]}}))}))},n.prototype.dispose=function(){this.faceDetectorSolution.close()},n.prototype.reset=function(){this.faceDetectorSolution.reset(),this.width=0,this.height=0,this.faces=null,this.selfieMode=!1},n.prototype.initialize=function(){return this.faceDetectorSolution.initialize()},n})();function m_(n){return Ln(this,void 0,void 0,(function(){var e,t;return Pn(this,(function(r){switch(r.label){case 0:return e=(function(a){if(a==null)return nr({},xi);var s=nr({},a);return s.runtime="mediapipe",s.modelType==null&&(s.modelType=xi.modelType),s.maxFaces==null&&(s.maxFaces=xi.maxFaces),s})(n),[4,(t=new f_(e)).initialize()];case 1:return r.sent(),[2,t]}}))}))}function Jm(n){return n instanceof Ge?{height:n.shape[0],width:n.shape[1]}:{height:n.height,width:n.width}}function Qm(n){return n instanceof Ge?n:pf(n)}function bi(n,e){R(n.width!==0,(function(){return e+" width cannot be 0."})),R(n.height!==0,(function(){return e+" height cannot be 0."}))}function g_(n,e,t){var r=e.outputTensorSize,a=e.keepAspectRatio,s=e.borderMode,o=e.outputTensorFloatRange,i=Jm(n),u=(function(h,d){return{xCenter:.5*h.width,yCenter:.5*h.height,width:h.width,height:h.height,rotation:0}})(i),l=(function(h,d,m){if(m===void 0&&(m=!1),!m)return{top:0,left:0,right:0,bottom:0};var y=d.height,b=d.width;bi(d,"targetSize"),bi(h,"roi");var x,T,$=y/b,F=h.height/h.width,M=0,U=0;return $>F?(x=h.width,T=h.width*$,U=(1-F/$)/2):(x=h.height/$,T=h.height,M=(1-$/F)/2),h.width=x,h.height=T,{top:U,left:M,right:M,bottom:U}})(u,r,a),c=(function(h,d,m,y){var b=h.width,x=h.height,T=1,$=Math.cos(h.rotation),F=Math.sin(h.rotation),M=h.xCenter,U=h.yCenter,X=1/d,z=1/m,L=new Array(16);return L[0]=b*$*T*X,L[1]=-x*F*X,L[2]=0,L[3]=(-.5*b*$*T+.5*x*F+M)*X,L[4]=b*F*T*z,L[5]=x*$*z,L[6]=0,L[7]=(-.5*x*$-.5*b*F*T+U)*z,L[8]=0,L[9]=0,L[10]=b*X,L[11]=0,L[12]=0,L[13]=0,L[14]=0,L[15]=1,(function(C){if(C.length!==16)throw new Error("Array length must be 16 but got "+C.length);return[[C[0],C[1],C[2],C[3]],[C[4],C[5],C[6],C[7]],[C[8],C[9],C[10],C[11]],[C[12],C[13],C[14],C[15]]]})(L)})(u,i.width,i.height),p=Xe((function(){var h=Qm(n),d=Qn((function(b,x,T){return bi(T,"inputResolution"),[1/T.width*b[0][0]*x.width,1/T.height*b[0][1]*x.width,b[0][3]*x.width,1/T.width*b[1][0]*x.height,1/T.height*b[1][1]*x.height,b[1][3]*x.height,0,0]})(c,i,r),[1,8]),m=s==="zero"?"constant":"nearest",y=va.transform(on(je(h,"float32")),d,"bilinear",m,0,[r.height,r.width]);return o!=null?(function(b,x){var T=(function($,F,M,U){var X=(U-M)/255;return{scale:X,offset:M-0*X}})(0,0,x[0],x[1]);return Xe((function(){return Pe(me(b,T.scale),T.offset)}))})(y,o):y}));return{imageTensor:p,padding:l,transformationMatrix:c}}function Nc(n){n.reduceBoxesInLowestLayer==null&&(n.reduceBoxesInLowestLayer=!1),n.interpolatedScaleAspectRatio==null&&(n.interpolatedScaleAspectRatio=1),n.fixedAnchorSize==null&&(n.fixedAnchorSize=!1);for(var e=[],t=0;t<n.numLayers;){for(var r=[],a=[],s=[],o=[],i=t;i<n.strides.length&&n.strides[i]===n.strides[t];){var u=$c(n.minScale,n.maxScale,i,n.strides.length);if(i===0&&n.reduceBoxesInLowestLayer)s.push(1),s.push(2),s.push(.5),o.push(.1),o.push(u),o.push(u);else{for(var l=0;l<n.aspectRatios.length;++l)s.push(n.aspectRatios[l]),o.push(u);if(n.interpolatedScaleAspectRatio>0){var c=i===n.strides.length-1?1:$c(n.minScale,n.maxScale,i+1,n.strides.length);o.push(Math.sqrt(u*c)),s.push(n.interpolatedScaleAspectRatio)}}i++}for(var p=0;p<s.length;++p){var h=Math.sqrt(s[p]);r.push(o[p]/h),a.push(o[p]*h)}var d=0,m=0;if(n.featureMapHeight.length>0)d=n.featureMapHeight[t],m=n.featureMapWidth[t];else{var y=n.strides[t];d=Math.ceil(n.inputSizeHeight/y),m=Math.ceil(n.inputSizeWidth/y)}for(var b=0;b<d;++b)for(var x=0;x<m;++x)for(var T=0;T<r.length;++T){var $={xCenter:(x+n.anchorOffsetX)/m,yCenter:(b+n.anchorOffsetY)/d,width:0,height:0};n.fixedAnchorSize?($.width=1,$.height=1):($.width=a[T],$.height=r[T]),e.push($)}t=i}return e}function $c(n,e,t,r){return r===1?.5*(n+e):n+(e-n)*t/(r-1)}function Rc(n,e){var t=e[0],r=e[1];return[t*n[0]+r*n[1]+n[3],t*n[4]+r*n[5]+n[7]]}function y_(n,e,t,r){return Ln(this,void 0,void 0,(function(){var a,s,o,i,u;return Pn(this,(function(l){switch(l.label){case 0:return n.sort((function(c,p){return Math.max.apply(Math,p.score)-Math.max.apply(Math,c.score)})),a=Qn(n.map((function(c){return[c.locationData.relativeBoundingBox.yMin,c.locationData.relativeBoundingBox.xMin,c.locationData.relativeBoundingBox.yMax,c.locationData.relativeBoundingBox.xMax]}))),s=gt(n.map((function(c){return c.score[0]}))),[4,va.nonMaxSuppressionAsync(a,s,e,t)];case 1:return[4,(o=l.sent()).array()];case 2:return i=l.sent(),u=n.filter((function(c,p){return i.indexOf(p)>-1})),bn([a,s,o]),[2,u]}}))}))}function x_(n,e,t){return Ln(this,void 0,void 0,(function(){var r,a,s,o,i;return Pn(this,(function(u){switch(u.label){case 0:return r=n[0],a=n[1],s=(function(l,c,p){return Xe((function(){var h,d,m,y;p.reverseOutputOrder?(d=tt(we(l,[0,p.boxCoordOffset+0],[-1,1])),h=tt(we(l,[0,p.boxCoordOffset+1],[-1,1])),y=tt(we(l,[0,p.boxCoordOffset+2],[-1,1])),m=tt(we(l,[0,p.boxCoordOffset+3],[-1,1]))):(h=tt(we(l,[0,p.boxCoordOffset+0],[-1,1])),d=tt(we(l,[0,p.boxCoordOffset+1],[-1,1])),m=tt(we(l,[0,p.boxCoordOffset+2],[-1,1])),y=tt(we(l,[0,p.boxCoordOffset+3],[-1,1]))),d=Pe(me(De(d,p.xScale),c.w),c.x),h=Pe(me(De(h,p.yScale),c.h),c.y),p.applyExponentialOnBoxSize?(m=me(Fn(De(m,p.hScale)),c.h),y=me(Fn(De(y,p.wScale)),c.w)):(m=me(De(m,p.hScale),c.h),y=me(De(y,p.wScale),c.h));var b=Ce(h,De(m,2)),x=Ce(d,De(y,2)),T=Pe(h,De(m,2)),$=Pe(d,De(y,2)),F=it([Z(b,[p.numBoxes,1]),Z(x,[p.numBoxes,1]),Z(T,[p.numBoxes,1]),Z($,[p.numBoxes,1])],1);if(p.numKeypoints)for(var M=0;M<p.numKeypoints;++M){var U=p.keypointCoordOffset+M*p.numValuesPerKeypoint,X=void 0,z=void 0;p.reverseOutputOrder?(X=tt(we(l,[0,U],[-1,1])),z=tt(we(l,[0,U+1],[-1,1]))):(z=tt(we(l,[0,U],[-1,1])),X=tt(we(l,[0,U+1],[-1,1])));var L=Pe(me(De(X,p.xScale),c.w),c.x),C=Pe(me(De(z,p.yScale),c.h),c.y);F=it([F,Z(L,[p.numBoxes,1]),Z(C,[p.numBoxes,1])],1)}return F}))})(a,e,t),o=Xe((function(){var l=r;return t.sigmoidScore?(t.scoreClippingThresh!=null&&(l=Af(r,-t.scoreClippingThresh,t.scoreClippingThresh)),l=Rr(l)):l})),[4,b_(s,o,t)];case 1:return i=u.sent(),bn([s,o]),[2,i]}}))}))}function b_(n,e,t){return Ln(this,void 0,void 0,(function(){var r,a,s,o,i,u,l,c,p,h,d,m;return Pn(this,(function(y){switch(y.label){case 0:return r=[],[4,n.data()];case 1:return a=y.sent(),[4,e.data()];case 2:for(s=y.sent(),o=0;o<t.numBoxes;++o)if(!(t.minScoreThresh!=null&&s[o]<t.minScoreThresh||(i=o*t.numCoords,u=v_(a[i+0],a[i+1],a[i+2],a[i+3],s[o],t.flipVertically,o),(l=u.locationData.relativeBoundingBox).width<0||l.height<0))){if(t.numKeypoints>0)for((c=u.locationData).relativeKeypoints=[],p=t.numKeypoints*t.numValuesPerKeypoint,h=0;h<p;h+=t.numValuesPerKeypoint)d=i+t.keypointCoordOffset+h,m={x:a[d+0],y:t.flipVertically?1-a[d+1]:a[d+1]},c.relativeKeypoints.push(m);r.push(u)}return[2,r]}}))}))}function v_(n,e,t,r,a,s,o){return{score:[a],ind:o,locationData:{relativeBoundingBox:{xMin:e,yMin:s?1-t:n,xMax:r,yMax:s?1-n:t,width:r-e,height:t-n}}}}var yo,w_={reduceBoxesInLowestLayer:!1,interpolatedScaleAspectRatio:1,featureMapHeight:[],featureMapWidth:[],numLayers:4,minScale:.1484375,maxScale:.75,inputSizeHeight:128,inputSizeWidth:128,anchorOffsetX:.5,anchorOffsetY:.5,strides:[8,16,16,16],aspectRatios:[1],fixedAnchorSize:!0},S_={reduceBoxesInLowestLayer:!1,interpolatedScaleAspectRatio:0,featureMapHeight:[],featureMapWidth:[],numLayers:1,minScale:.1484375,maxScale:.75,inputSizeHeight:192,inputSizeWidth:192,anchorOffsetX:.5,anchorOffsetY:.5,strides:[4],aspectRatios:[1],fixedAnchorSize:!0},vi={runtime:"tfjs",modelType:"short",maxFaces:1,detectorModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"},k_={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses:1,numBoxes:896,numCoords:16,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:6,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:128,yScale:128,hScale:128,wScale:128,minScoreThresh:.5},T_={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses:1,numBoxes:2304,numCoords:16,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:6,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:192,yScale:192,hScale:192,wScale:192,minScoreThresh:.6},E_={outputTensorSize:{width:128,height:128},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},C_={outputTensorSize:{width:192,height:192},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},I_=(function(){function n(e,t,r){this.detectorModel=t,this.maxFaces=r,e==="full"?(this.imageToTensorConfig=C_,this.tensorsToDetectionConfig=T_,this.anchors=Nc(S_)):(this.imageToTensorConfig=E_,this.tensorsToDetectionConfig=k_,this.anchors=Nc(w_));var a=gt(this.anchors.map((function(u){return u.width}))),s=gt(this.anchors.map((function(u){return u.height}))),o=gt(this.anchors.map((function(u){return u.xCenter}))),i=gt(this.anchors.map((function(u){return u.yCenter})));this.anchorTensor={x:o,y:i,w:a,h:s}}return n.prototype.dispose=function(){this.detectorModel.dispose(),bn([this.anchorTensor.x,this.anchorTensor.y,this.anchorTensor.w,this.anchorTensor.h])},n.prototype.reset=function(){},n.prototype.detectFaces=function(e,t){return t===void 0&&(t=!1),Ln(this,void 0,void 0,(function(){var r,a,s,o,i,u,l,c,p,h,d;return Pn(this,(function(m){switch(m.label){case 0:return e==null?(this.reset(),[2,[]]):(r=Xe((function(){var y=je(Qm(e),"float32");return t&&(y=tt(va.flipLeftRight(on(y,0)),[0])),y})),a=g_(r,this.imageToTensorConfig),s=a.imageTensor,o=a.transformationMatrix,i=this.detectorModel.execute(s,"Identity:0"),u=(function(y){return Xe((function(){var b=(function($){return Xe((function(){return[we($,[0,0,0],[1,-1,1]),we($,[0,0,1],[1,-1,-1])]}))})(y),x=b[0],T=b[1];return{boxes:tt(T),logits:tt(x)}}))})(i),l=u.boxes,[4,x_([c=u.logits,l],this.anchorTensor,this.tensorsToDetectionConfig)]);case 1:return(p=m.sent()).length===0?(bn([r,s,i,c,l]),[2,p]):[4,y_(p,this.maxFaces,.3)];case 2:return h=m.sent(),d=(function(y,b){y===void 0&&(y=[]);var x,T=(x=b,[].concat.apply([],x));return y.forEach((function($){var F=$.locationData;F.relativeKeypoints.forEach((function(C){var q=Rc(T,[C.x,C.y]),ee=q[0],te=q[1];C.x=ee,C.y=te}));var M=F.relativeBoundingBox,U=Number.MAX_VALUE,X=Number.MAX_VALUE,z=Number.MIN_VALUE,L=Number.MIN_VALUE;[[M.xMin,M.yMin],[M.xMin+M.width,M.yMin],[M.xMin+M.width,M.yMin+M.height],[M.xMin,M.yMin+M.height]].forEach((function(C){var q=Rc(T,C),ee=q[0],te=q[1];U=Math.min(U,ee),z=Math.max(z,ee),X=Math.min(X,te),L=Math.max(L,te)})),F.relativeBoundingBox={xMin:U,xMax:z,yMin:X,yMax:L,width:z-U,height:L-X}})),y})(h,o),bn([r,s,i,c,l]),[2,d]}}))}))},n.prototype.estimateFaces=function(e,t){return Ln(this,void 0,void 0,(function(){var r,a;return Pn(this,(function(s){return r=Jm(e),a=!!t&&t.flipHorizontal,[2,this.detectFaces(e,a).then((function(o){return o.map((function(i){for(var u=i.locationData.relativeKeypoints.map((function(m,y){return nr(nr({},m),{x:m.x*r.width,y:m.y*r.height,name:Zm[y]})})),l=i.locationData.relativeBoundingBox,c=0,p=["width","xMax","xMin"];c<p.length;c++)l[p[c]]*=r.width;for(var h=0,d=["height","yMax","yMin"];h<d.length;h++)l[d[h]]*=r.height;return{keypoints:u,box:l}}))}))]}))}))},n})();function N_(n){return Ln(this,void 0,void 0,(function(){var e,t,r;return Pn(this,(function(a){switch(a.label){case 0:return e=(function(s){if(s==null)return nr({},vi);var o=nr({},s);return o.modelType==null&&(o.modelType=vi.modelType),o.maxFaces==null&&(o.maxFaces=vi.maxFaces),o.detectorModelUrl==null&&(o.modelType==="full"?o.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/face_detection/full/1":o.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"),o})(n),t=typeof e.detectorModelUrl=="string"&&e.detectorModelUrl.indexOf("https://tfhub.dev")>-1,[4,Km(e.detectorModelUrl,{fromTFHub:t})];case 1:return r=a.sent(),[2,new I_(e.modelType,r,e.maxFaces)]}}))}))}function $_(n,e){return Ln(this,void 0,void 0,(function(){var t,r;return Pn(this,(function(a){if(n===yo.MediaPipeFaceDetector){if(r=void 0,(t=e)!=null){if(t.runtime==="tfjs")return[2,N_(t)];if(t.runtime==="mediapipe")return[2,m_(t)];r=t.runtime}throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got "+r)}throw new Error(n+" is not a supported model name.")}))}))}function wi(n){return n.width*n.height}function _c(n){var e=n.xCenter-n.width/2,t=e+n.width,r=n.yCenter-n.height/2;return{xMin:e,xMax:t,yMin:r,yMax:r+n.height,width:n.width,height:n.height}}function R_(n,e){var t=_c(n),r=_c(e);if(!(function(o,i){return!(o.xMax<i.xMin||i.xMax<o.xMin||o.yMax<i.yMin||i.yMax<o.yMin)})(t,r))return 0;var a=wi((function(o,i){var u=Math.max(o.xMin,i.xMin),l=Math.min(o.xMax,i.xMax),c=Math.max(o.yMin,i.yMin),p=Math.min(o.yMax,i.yMax);return{xMin:u,xMax:l,yMin:c,yMax:p,width:Math.max(l-u,0),height:Math.max(p-c,0)}})(t,r)),s=wi(t)+wi(r)-a;return s>0?a/s:0}function __(n,e,t,r){var a=n.width,s=n.height,o=1,i=Math.cos(n.rotation),u=Math.sin(n.rotation),l=n.xCenter,c=n.yCenter,p=1/e,h=1/t,d=new Array(16);return d[0]=a*i*o*p,d[1]=-s*u*p,d[2]=0,d[3]=(-.5*a*i*o+.5*s*u+l)*p,d[4]=a*u*o*h,d[5]=s*i*h,d[6]=0,d[7]=(-.5*s*i-.5*a*u*o+c)*h,d[8]=0,d[9]=0,d[10]=a*p,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,(function(m){if(m.length!==16)throw new Error("Array length must be 16 but got "+m.length);return[[m[0],m[1],m[2],m[3]],[m[4],m[5],m[6],m[7]],[m[8],m[9],m[10],m[11]],[m[12],m[13],m[14],m[15]]]})(d)}function e2(n){return n instanceof Ge?{height:n.shape[0],width:n.shape[1]}:{height:n.height,width:n.width}}function t2(n){return n-2*Math.PI*Math.floor((n+Math.PI)/(2*Math.PI))}function n2(n){return n instanceof Ge?n:pf(n)}function Si(n,e){R(n.width!==0,(function(){return e+" width cannot be 0."})),R(n.height!==0,(function(){return e+" height cannot be 0."}))}function A_(n,e){var t=(function(r,a,s,o){var i=a-r,u=o-s,l=u/i;return{scale:l,offset:s-r*l}})(0,255,e[0],e[1]);return Xe((function(){return Pe(me(n,t.scale),t.offset)}))}function O_(n,e,t){var r=e.outputTensorSize,a=e.keepAspectRatio,s=e.outputTensorFloatRange,o=e2(n),i=(function(p,h){return h?{xCenter:h.xCenter*p.width,yCenter:h.yCenter*p.height,width:h.width*p.width,height:h.height*p.height,rotation:h.rotation}:{xCenter:.5*p.width,yCenter:.5*p.height,width:p.width,height:p.height,rotation:0}})(o,t),u=(function(p,h,d){if(d===void 0&&(d=!1),!d)return{top:0,left:0,right:0,bottom:0};var m=h.height,y=h.width;Si(h,"targetSize"),Si(p,"roi");var b,x,T=m/y,$=p.height/p.width,F=0,M=0;return T>$?(b=p.width,x=p.width*T,M=(1-$/T)/2):(b=p.height/T,x=p.height,F=(1-T/$)/2),p.width=b,p.height=x,{top:M,left:F,right:F,bottom:M}})(i,r,a),l=__(i,o.width,o.height),c=Xe((function(){var p=n2(n),h=Qn((function(y,b,x){return Si(x,"inputResolution"),[1/x.width*y[0][0]*b.width,1/x.height*y[0][1]*b.width,y[0][3]*b.width,1/x.width*y[1][0]*b.height,1/x.height*y[1][1]*b.height,y[1][3]*b.height,0,0]})(l,o,r),[1,8]),d="nearest",m=va.transform(on(je(p,"float32")),h,"bilinear",d,0,[r.height,r.width]);return s!=null?A_(m,s):m}));return{imageTensor:c,padding:u,transformationMatrix:l}}function Ac(n){return{xCenter:n.xMin+n.width/2,yCenter:n.yMin+n.height/2,width:n.width,height:n.height}}function F_(n){var e=n.relativeKeypoints;if(e.length<=1)throw new Error("2 or more keypoints required to calculate a rect.");var t=Number.MAX_VALUE,r=Number.MAX_VALUE,a=Number.MIN_VALUE,s=Number.MIN_VALUE;return e.forEach((function(o){t=Math.min(t,o.x),a=Math.max(a,o.x),r=Math.min(r,o.y),s=Math.max(s,o.y)})),{xCenter:(t+a)/2,yCenter:(r+s)/2,width:a-t,height:s-r}}function Oc(n,e,t,r,a){var s=t==="rect"?(function(o,i,u){var l,c=o.locationData;return l=Ac(c.boundingBox),l})(n):(function(o,i){var u=o.locationData;return i==="boundingbox"?Ac(u.relativeBoundingBox):F_(u)})(n,e);return a&&(s.rotation=(function(o,i,u){var l,c=o.locationData,p=u.rotationVectorStartKeypointIndex,h=u.rotationVectorEndKeypointIndex;l=u.rotationVectorTargetAngle?u.rotationVectorTargetAngle:Math.PI*u.rotationVectorTargetAngleDegree/180;var d=c.relativeKeypoints[p].x*i.width,m=c.relativeKeypoints[p].y*i.height,y=c.relativeKeypoints[h].x*i.width,b=c.relativeKeypoints[h].y*i.height;return t2(l-Math.atan2(-(b-m),y-d))})(n,r,a)),s}function D_(n,e,t){for(var r=0;r<e.length;++r){var a=e[r],s=t[n[r]];s.x=a.x,s.y=a.y}}function M_(n,e,t,r){if(typeof e=="string"){if(e==="copy")for(var a=0;a<t.length;++a)r[n[a]].z=t[a].z}else{var s=(function(o,i){for(var u=0,l=0;l<i.length;++l)u+=o[i[l]].z;return u/i.length})(r,e);for(a=0;a<n.length;++a)r[n[a]].z=s}}function L_(n,e){for(var t=(function(i){var u=[].concat.apply([],i.map((function(d){return d.indexesMapping})));if(u.length===0)throw new Error("There should be at least one landmark in indexes mapping");var l=u[0],c=u[0],p=new Set(u);p.forEach((function(d){l=Math.min(l,d),c=Math.max(c,d)}));var h=p.size;if(l!==0)throw new Error("Indexes are expected to start with 0 instead of "+l);if(c+1!==h)throw new Error("Indexes should have no gaps but "+(c-h+1)+" indexes are missing");return h})(e),r=new Array(t).fill(null).map(Object),a=0;a<n.length;++a){var s=n[a],o=e[a];if(s.length!==o.indexesMapping.length)throw new Error("There are "+s.length+" refinement landmarks while mapping has "+o.indexesMapping.length);D_(o.indexesMapping,s,r),M_(o.indexesMapping,o.zRefinement,s,r)}return r}function P_(n,e){return n.map((function(t){var r=cn(cn({},t),{x:t.x*e.width,y:t.y*e.height});return t.z!=null&&(r.z=t.z*e.width),r}))}function B_(n,e){return n==="none"?e:(function(t){return 1/(1+Math.exp(-t))})(e)}function wr(n,e,t,r){return Rn(this,void 0,void 0,(function(){var a,s,o,i,u,l,c,p;return _n(this,(function(h){switch(h.label){case 0:return t=t||e.flipHorizontally||!1,r=r||e.flipVertically||!1,a=n.size,s=a/e.numLandmarks,[4,n.data()];case 1:for(o=h.sent(),i=[],u=0;u<e.numLandmarks;++u)l=u*s,(p={x:0,y:0}).x=t?e.inputImageWidth-o[l]:o[l],s>1&&(p.y=r?e.inputImageHeight-o[l+1]:o[l+1]),s>2&&(p.z=o[l+2]),s>3&&(p.score=B_(e.visibilityActivation,o[l+3])),i.push(p);for(c=0;c<i.length;++c)(p=i[c]).x=p.x/e.inputImageWidth,p.y=p.y/e.inputImageHeight,p.z=p.z/e.inputImageWidth/(e.normalizeZ||1);return[2,i]}}))}))}function Fc(n,e,t){var r=n.width,a=n.height,s=n.rotation;if(t.rotation==null&&t.rotationDegree==null||(s=(function(l,c){return c.rotation!=null?l+=c.rotation:c.rotationDegree!=null&&(l+=Math.PI*c.rotationDegree/180),t2(l)})(s,t)),s===0)n.xCenter=n.xCenter+r*t.shiftX,n.yCenter=n.yCenter+a*t.shiftY;else{var o=(e.width*r*t.shiftX*Math.cos(s)-e.height*a*t.shiftY*Math.sin(s))/e.width,i=(e.width*r*t.shiftX*Math.sin(s)+e.height*a*t.shiftY*Math.cos(s))/e.height;n.xCenter=n.xCenter+o,n.yCenter=n.yCenter+i}{var u=Math.max(r*e.width,a*e.height);r=u/e.width,a=u/e.height}return n.width=r*t.scaleX,n.height=a*t.scaleY,n}(yo||(yo={})).MediaPipeFaceDetector="MediaPipeFaceDetector";var ki={runtime:"tfjs",maxFaces:1,refineLandmarks:!1,landmarkModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1"},Ti={flipHorizontal:!1,staticImageMode:!1},Dc={shiftX:0,shiftY:0,scaleX:1.5,scaleY:1.5},U_={outputTensorSize:{width:192,height:192},outputTensorFloatRange:[0,1]},Mc={numLandmarks:468,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},V_={numLandmarks:80,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},Lc={numLandmarks:71,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},Pc={numLandmarks:5,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},W_={indexesMapping:Array.from(Array(468).keys()),zRefinement:"copy"},z_={indexesMapping:[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],zRefinement:"none"},G_={indexesMapping:[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],zRefinement:"none"},j_={indexesMapping:[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417],zRefinement:"none"},H_={indexesMapping:[468,469,470,471,472],zRefinement:[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173]},X_={indexesMapping:[473,474,475,476,477],zRefinement:[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398]},xo,q_=(function(){function n(e,t,r,a){this.detector=e,this.landmarkModel=t,this.maxFaces=r,this.withAttention=a,this.prevFaceRectsFromLandmarks=null}return n.prototype.estimateFaces=function(e,t){return Rn(this,void 0,void 0,(function(){var r,a,s,o,i,u,l,c,p,h,d,m,y,b=this;return _n(this,(function(x){switch(x.label){case 0:return r=(function(F){if(F==null)return cn({},Ti);var M=cn({},F);return M.flipHorizontal==null&&(M.flipHorizontal=Ti.flipHorizontal),M.staticImageMode==null&&(M.staticImageMode=Ti.staticImageMode),M})(t),e==null?(this.reset(),[2,[]]):(a=e2(e),s=Xe((function(){var F=je(n2(e),"float32");return r.flipHorizontal&&(F=tt(va.flipLeftRight(on(F,0)),[0])),F})),o=this.prevFaceRectsFromLandmarks,r.staticImageMode||o==null||o.length<this.maxFaces?[4,this.detector.detectFaces(s,!1)]:[3,2]);case 1:return(u=x.sent()).length===0?(this.reset(),s.dispose(),[2,[]]):(i=u.map((function(F){return b.faceDetectionFrontDetectionToRoi(F,a)})),[3,3]);case 2:i=[],x.label=3;case 3:return T=.5,$=[],[i,o||[]].forEach((function(F){return F.forEach((function(M){($=$.filter((function(U){return R_(M,U)<=T}))).push(M)}))})),l=$,[4,Promise.all(l.map((function(F){return b.faceLandmark(F,s)})))];case 4:for(c=x.sent(),p=[],this.prevFaceRectsFromLandmarks=[],h=0;h<c.length;++h)(d=c[h])!=null&&(this.prevFaceRectsFromLandmarks.push(this.faceLandmarksToRoi(d,a)),(m=P_(d,a))!=null&&m.forEach((function(F,M){var U=Ym.get(M);U!=null&&(F.name=U)})),y=Su(m),p.push({keypoints:m,box:y.locationData.relativeBoundingBox}));return s.dispose(),[2,p]}var T,$}))}))},n.prototype.dispose=function(){this.detector.dispose(),this.landmarkModel.dispose()},n.prototype.reset=function(){this.detector.reset(),this.prevFaceRectsFromLandmarks=null},n.prototype.faceDetectionFrontDetectionToRoi=function(e,t){return Fc(Oc(e,"boundingbox","normRect",t,{rotationVectorStartKeypointIndex:0,rotationVectorEndKeypointIndex:1,rotationVectorTargetAngleDegree:0}),t,Dc)},n.prototype.faceLandmark=function(e,t){return Rn(this,void 0,void 0,(function(){var r,a,s,o,i,u,l;return _n(this,(function(c){switch(c.label){case 0:return r=O_(t,U_,e).imageTensor,a=["output_faceflag"].concat(this.withAttention?["output_mesh_identity","output_lips","Identity_6:0","Identity_1:0","Identity_2:0","Identity_5:0"]:["output_mesh"]),s=this.landmarkModel.execute(r,a),o=s[0],i=s.slice(1),[4,o.data()];case 1:return c.sent()[0]<.5?(bn(s),bn(r),[2,null]):this.withAttention?[4,this.tensorsToFaceLandmarksWithAttention(i)]:[3,3];case 2:return u=c.sent(),[3,5];case 3:return[4,this.tensorsToFaceLandmarks(i)];case 4:u=c.sent(),c.label=5;case 5:return l=(function(p,h,d){d===void 0&&(d={ignoreRotation:!1});for(var m=[],y=0,b=p;y<b.length;y++){var x=b[y],T=x.x-.5,$=x.y-.5,F=d.ignoreRotation?0:h.rotation,M=Math.cos(F)*T-Math.sin(F)*$,U=Math.sin(F)*T+Math.cos(F)*$;M=M*h.width+h.xCenter,U=U*h.height+h.yCenter;var X=x.z*h.width,z=cn({},x);z.x=M,z.y=U,z.z=X,m.push(z)}return m})(u,e),bn(s),bn(r),[2,l]}}))}))},n.prototype.tensorsToFaceLandmarks=function(e){return Rn(this,void 0,void 0,(function(){return _n(this,(function(t){return[2,wr(e[0],Mc)]}))}))},n.prototype.tensorsToFaceLandmarksWithAttention=function(e){return Rn(this,void 0,void 0,(function(){var t,r,a,s,o,i;return _n(this,(function(u){switch(u.label){case 0:return[4,wr(e[0],Mc)];case 1:return t=u.sent(),[4,wr(e[1],V_)];case 2:return r=u.sent(),[4,wr(e[3],Lc)];case 3:return a=u.sent(),[4,wr(e[5],Lc)];case 4:return s=u.sent(),[4,wr(e[4],Pc)];case 5:return o=u.sent(),[4,wr(e[2],Pc)];case 6:return i=u.sent(),[2,L_([t,r,a,s,o,i],[W_,z_,G_,j_,H_,X_])]}}))}))},n.prototype.faceLandmarksToRoi=function(e,t){return Fc(Oc(Su(e),"boundingbox","normRect",t,{rotationVectorStartKeypointIndex:33,rotationVectorEndKeypointIndex:263,rotationVectorTargetAngleDegree:0}),t,Dc)},n})();function K_(n){return Rn(this,void 0,void 0,(function(){var e,t,r,a;return _n(this,(function(s){switch(s.label){case 0:return e=(function(o){if
14936(o==null)return cn({},ki);var i=cn({},o);return i.runtime="tfjs",i.maxFaces==null&&(i.maxFaces=ki.maxFaces),i.refineLandmarks==null&&(i.refineLandmarks=ki.refineLandmarks),i.landmarkModelUrl==null&&(i.landmarkModelUrl=i.refineLandmarks?"https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1":"https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1"),i})(n),t=typeof e.landmarkModelUrl=="string"&&e.landmarkModelUrl.indexOf("https://tfhub.dev")>-1,[4,Km(e.landmarkModelUrl,{fromTFHub:t})];case 1:return r=s.sent(),[4,$_(yo.MediaPipeFaceDetector,{modelType:"short",maxFaces:e.maxFaces,detectorModelUrl:e.detectorModelUrl,runtime:e.runtime})];case 2:return a=s.sent(),[2,new q_(a,r,e.maxFaces,e.refineLandmarks)]}}))}))}function Y_(n,e){return Rn(this,void 0,void 0,(function(){var t,r;return _n(this,(function(a){if(n===xo.MediaPipeFaceMesh){if(r=void 0,(t=e)!=null){if(t.runtime==="tfjs")return[2,K_(t)];if(t.runtime==="mediapipe")return[2,h_(t)];r=t.runtime}throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got "+r)}throw new Error(n+" is not a supported model name.")}))}))}(function(n){n.MediaPipeFaceMesh="MediaPipeFaceMesh"})(xo||(xo={}));class Q_{constructor(){fl(this,"detector"),fl(this,"modelLocation",Jo.CDN)}async loadModels(e){const t=xo.MediaPipeFaceMesh,r=e||this.modelLocation,a={runtime:"mediapipe",solutionPath:(()=>{switch(r){case Jo.CDN:return"https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh";case Jo.SelfHosted:const{protocol:o,host:i}=location;return`${o}//${i}/models/mediapipe/`}})(),refineLandmarks:!0},s=await Y_(t,a);this.detector=s}async _detect(e){if(this.detector===void 0)return;const t={flipHorizontal:!1},r=await this.detector.estimateFaces(e,t);return r.length===0?void 0:r[0].keypoints}async detect(e){let t=r2(e);if(t.width===0||t.height===0)return{faceBox:void 0,landmarks:[],videoFrame:t};const r=await this._detect(t);if(r===void 0)return{faceBox:void 0,landmarks:[],videoFrame:t};const{width:a,height:s}=t,o=r.map(i=>({x:i.x/a,y:i.y/s,z:i.z||0}));return{faceBox:a2(o),landmarks:o,videoFrame:t}}}export{Q_ as TFMediaPipeFaceDetector};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.