vendor: 11,199 bytes, lines 1-49
1import{c as Nn,g as k0}from"./vendor-highcharts.9b480a8e.js";function vl(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const a=Object.getOwnPropertyDescriptor(r,s);a&&Object.defineProperty(n,s,a.get?a:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}/** 2 * @license 3 * Copyright 2020 Google LLC. All Rights Reserved. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * ============================================================================= 16 */const E0=1e-7,R0=1e-4;class zf{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 Il{refCount(e){return Jt("refCount")}incRef(e){return Jt("incRef")}timerAvailable(){return!0}time(e){return Jt("time")}read(e){return Jt("read")}readSync(e){return Jt("readSync")}readToGPU(e,t){return Jt("readToGPU")}numDataIds(){return Jt("numDataIds")}disposeData(e,t){return Jt("disposeData")}write(e,t,r){return Jt("write")}move(e,t,r,s,a){return Jt("move")}createTensorFromGPUData(e,t,r){return Jt("createTensorFromGPUData")}memory(){return Jt("memory")}floatPrecision(){return Jt("floatPrecision")}epsilon(){return this.floatPrecision()===32?E0:R0}dispose(){return Jt("dispose")}}function Jt(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`)}/** 17 * @license 18 * Copyright 2020 Google LLC. All Rights Reserved. 19 * Licensed under the Apache License, Version 2.0 (the "License"); 20 * you may not use this file except in compliance with the License. 21 * You may obtain a copy of the License at 22 * 23 * http://www.apache.org/licenses/LICENSE-2.0 24 * 25 * Unless required by applicable law or agreed to in writing, software 26 * distributed under the License is distributed on an "AS IS" BASIS, 27 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 * See the License for the specific language governing permissions and 29 * limitations under the License. 30 * ============================================================================= 31 */function gi(n,e,t){return Math.max(n,Math.min(e,t))}function $l(n){return n%2===0?n:n+1}function Ja(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function A0(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function N(n,e){if(!n)throw new Error(typeof e=="string"?e:e())}function sn(n,e,t=""){N(st(n,e),()=>t+` Shapes ${n} and ${e} must match`)}function Ta(n){N(n!=null,()=>"The input to the tensor constructor must be a non-null value.")}function H(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 D0(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]!==null&&e[t]!==null&&n[t]!==e[t])return!1;return!0}function st(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 xa(n){return n%1===0}function kc(n){const e=Math.ceil(Math.sqrt(n));return[e,Math.ceil(n/e)]}function fa(n,e){return e<=n.length?n:n+" ".repeat(e-n.length)}function Ih(n,e=s=>0,t,r){return new Promise((s,a)=>{let o=0;const i=()=>{if(n()){s();return}o++;const c=e(o);if(t!=null&&o>=t){a();return}r!=null?r(i,c):setTimeout(i,c)};i()})}function Gf(n,e){let t=1,r=-1;for(let a=0;a<n.length;++a)if(n[a]>=0)t*=n[a];else if(n[a]===-1){if(r!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${a}`);r=a}else if(n[a]<0)throw Error(`Shapes can not be < 0. Found ${n[a]} at dim ${a}`);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 s=n.slice();return s[r]=e/t,s}function ot(n,e){const t=e.length;return n=n==null?e.map((r,s)=>s):[].concat(n),N(n.every(r=>r>=-t&&r<t),()=>`All values in axis param must be in range [-${t}, ${t}) but got axis ${n}`),N(n.every(r=>xa(r)),()=>`All values in axis param must be integers but got axis ${n}`),n.map(r=>r<0?t+r:r)}function jr(n,e){const t=[],r=[],s=e!=null&&Array.isArray(e)&&e.length===0,a=e==null||s?null:ot(e,n).sort();let o=0;for(let i=0;i<n.length;++i){if(a!=null){if(a[o]===i&&n[i]!==1)throw new Error(`Can't squeeze axis ${i} since its dim '${n[i]}' is not 1`);(a[o]==null||a[o]>i)&&n[i]===1&&(t.push(n[i]),r.push(i)),a[o]<=i&&o++}n[i]!==1&&(t.push(n[i]),r.push(i))}return{newShape:t,keptDims:r}}function Wr(n,e){return yt(n,e)}function yt(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 O0(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 F0(n){return n==="bool"||n==="complex64"||n==="float32"||n==="int32"||n==="string"}function P0(n,e){return!(e==="complex64"||e==="float32"&&n!=="complex64"||e==="int32"&&n!=="float32"&&n!=="complex64"||e==="bool"&&n==="bool")}function wa(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 L0(n){if(n==null)return 0;let e=0;return n.forEach(t=>e+=t.length),e}function Pi(n){return typeof n=="string"||n instanceof String}function M0(n){return typeof n=="boolean"}function B0(n){return typeof n=="number"}function ka(n){return Array.isArray(n)?ka(n[0]):n instanceof Float32Array?"float32":n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray?"int32":B0(n)?"float32":Pi(n)?"string":M0(n)?"bool":"float32"}function Ec(n){return!!(n&&n.constructor&&n.call&&n.apply)}function Rc(n,e){for(let t=e;t<n;++t)if(n%t===0)return t;return n}function Be(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 Hf(n,e,t,r=!1){const s=new Array;if(e.length===1){const a=e[0]*(r?2:1);for(let o=0;o<a;o++)s[o]=t[n+o]}else{const a=e[0],o=e.slice(1),i=o.reduce((c,l)=>c*l)*(r?2:1);for(let c=0;c<a;c++)s[c]=Hf(n+c*i,o,t,r)}return s}function Ac(n,e,t=!1){if(n.length===0)return e[0];const r=n.reduce((s,a)=>s*a)*(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 Hf(0,n,e,t)}function jf(n,e){const t=Ur(n,e);for(let r=0;r<t.length;r++)t[r]=1;return t}function Ur(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 fn(n){n.forEach(e=>{N(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${n}].`)})}function Dc(n,e,t){if(e===0)return 0;if(e===1)return n[0];let r=n[n.length-1];for(let s=0;s<n.length-1;++s)r+=t[s]*n[s];return r}function Sl(n,e,t){if(e===0)return[];if(e===1)return[n];const r=new Array(e);for(let s=0;s<r.length-1;++s)r[s]=Math.floor(n/t[s]),n-=r[s]*t[s];return r[r.length-1]=n,r}function Ss(n){return n&&n.then&&typeof n.then=="function"}/** 32 * @license 33 * Copyright 2017 Google LLC. All Rights Reserved. 34 * Licensed under the Apache License, Version 2.0 (the "License"); 35 * you may not use this file except in compliance with the License. 36 * You may obtain a copy of the License at 37 * 38 * http://www.apache.org/licenses/LICENSE-2.0 39 * 40 * Unless required by applicable law or agreed to in writing, software 41 * distributed under the License is distributed on an "AS IS" BASIS, 42 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 43 * See the License for the specific language governing permissions and 44 * limitations under the License. 45 * ============================================================================= 46 */const $h="tfjsflags";class V0{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=W0,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&(U().getBool("IS_TEST")||U().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 s=this.urlFlags[e];U().getBool("IS_TEST")||U().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${s}.`),this.set(e,s)}}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(Ss(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)}getString(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);$h in e&&e[$h].split(",").forEach(r=>{const[s,a]=r.split(":");this.urlFlags[s]=z0(s,a)})}}function W0(n){const e={};return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(t,...r)=>(U0(e,r[0],r[1]),r.join("="))),e}function U0(n,e,t){n[decodeURIComponent(e)]=decodeURIComponent(t||"")}function z0(n,e){const t=e.toLowerCase();return t==="true"||t==="false"?t==="true":`${+t}`===t?+t:e}function U(){return qf}let qf=null;function G0(n){qf=n}/** 47 * @license 48 * Copyright 2020 Google LLC. All Rights Reserved. 49 * Licensed under the Apache License, Version 2.0 (the "License");
50 * you may not use this file except in compliance with the License. 51 * You may obtain a copy of the License at 52 * 53 * http://www.apache.org/licenses/LICENSE-2.0 54 * 55 * Unless required by applicable law or agreed to in writing, software 56 * distributed under the License is distributed on an "AS IS" BASIS, 57 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 58 * See the License for the specific language governing permissions and 59 * limitations under the License. 60 * ============================================================================= 61 */let cc;function Kf(){if(cc==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");cc=n}return cc}function H0(){const n=Kf();return n._tfGlobals==null&&(n._tfGlobals=new Map),n._tfGlobals}function Cl(n,e){const t=H0();if(t.has(n))return t.get(n);{const r=e();return t.set(n,r),t.get(n)}}const _l="Abs",Nl="Acos",Tl="Acosh",Li="Add",Mi="AddN",Bi="All",Vi="Any",kl="ArgMax",El="ArgMin",Rl="Asin",Al="Asinh",Dl="Atan",Ol="Atanh",Fl="Atan2",Wi="AvgPool",Xf="AvgPoolGrad",Pl="AvgPool3D",Yf="AvgPool3DGrad",Ui="BatchMatMul",Ll="BatchToSpaceND",zi="Bincount",Ml="BitwiseAnd",Bl="BroadcastArgs",Gi="Cast",Vl="Ceil",Hi="ClipByValue",Qf="Complex",Zf="ComplexAbs",Wl="Concat",ji="Conv2D",Jf="Conv2DBackpropFilter",qi="Conv2DBackpropInput",Ki="Conv3D",Ul="Conv3DBackpropFilterV2",Xi="Conv3DBackpropInputV2",zl="Cos",Gl="Cosh",Yi="Cumprod",Qi="Cumsum",Zi="CropAndResize",Hl="DenseBincount",Ji="DepthToSpace",eu="DepthwiseConv2dNative",em="DepthwiseConv2dNativeBackpropFilter",tm="DepthwiseConv2dNativeBackpropInput",jl="Diag",tu="Dilation2D",nm="Dilation2DBackpropInput",rm="Dilation2DBackpropFilter",j0="Draw",ql="RealDiv",sm="Einsum",Kl="Elu",Xl="EluGrad",Yl="Erf",Ql="Equal",Zl="Exp",Jl="ExpandDims",ed="Expm1",am="FFT",td="Fill",nu="FlipLeftRight",nd="Floor",rd="FloorDiv",ru="FusedBatchNorm",sd="GatherV2",su="GatherNd",ad="Greater",od="GreaterEqual",au="Identity",om="IFFT",im="Imag",id="IsFinite",ud="IsInf",cd="IsNan",ou="LeakyRelu",ld="Less",dd="LessEqual",iu="LinSpace",pd="Log",hd="Log1p",fd="LogicalAnd",md="LogicalNot",gd="LogicalOr",q0="LogicalXor",uu="LRN",yd="LRNGrad",cu="Max",bd="Maximum",lu="MaxPool",um="MaxPoolGrad",xd="MaxPool3D",cm="MaxPool3DGrad",wd="MaxPoolWithArgmax",du="Mean",pu="Min",vd="Minimum",hu="MirrorPad",Id="Mod",fu="Multinomial",$d="Multiply",Sd="Neg",Cd="NotEqual",mu="NonMaxSuppressionV3",gu="NonMaxSuppressionV4",yu="NonMaxSuppressionV5",_d="OnesLike",bu="OneHot",Nd="Pack",xu="PadV2",Td="Pow",wu="Prelu",vu="Prod",lm="RaggedGather",dm="RaggedRange",pm="RaggedTensorToTensor",kd="Range",hm="Real",Ed="Reciprocal",Rd="Relu",Ad="Reshape",Iu="ResizeNearestNeighbor",Dd="ResizeNearestNeighborGrad",$u="ResizeBilinear",Od="ResizeBilinearGrad",Fd="Relu6",Su="Reverse",Pd="Round",Ld="Rsqrt",Cu="ScatterNd",_u="TensorScatterUpdate",Nu="SearchSorted",Md="Select",Bd="Selu",Vd="Slice",Wd="Sin",Ud="Sinh",zd="Sign",Gd="Sigmoid",Hd="Softplus",jd="Sqrt",Tu="Sum",qd="SpaceToBatchND",Kd="SplitV",ku="Softmax",Xd="SparseFillEmptyRows",Eu="SparseReshape",Yd="SparseSegmentMean",Qd="SparseSegmentSum",Ru="SparseToDense",Zd="SquaredDifference",fm="Square",mm="StaticRegexReplace",Au="StridedSlice",Jd="StringNGrams",ep="StringSplit",tp="StringToHashBucketFast",np="Sub",rp="Tan",sp="Tanh",_o="Tile",Du="TopK",Ou="Transform",ma="Transpose",ap="Unique",op="Unpack",gm="UnsortedSegmentSum",ip="ZerosLike",Fu="Step",Oc="FromPixels",Pu="RotateWithOffset",uo="_FusedMatMul",co="FusedConv2D",lo="FusedDepthwiseConv2D";/** 62 * @license 63 * Copyright 2018 Google LLC. All Rights Reserved. 64 * Licensed under the Apache License, Version 2.0 (the "License"); 65 * you may not use this file except in compliance with the License. 66 * You may obtain a copy of the License at 67 * 68 * http://www.apache.org/licenses/LICENSE-2.0 69 * 70 * Unless required by applicable law or agreed to in writing, software 71 * distributed under the License is distributed on an "AS IS" BASIS, 72 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 73 * See the License for the specific language governing permissions and 74 * limitations under the License. 75 * ============================================================================= 76 */function Un(...n){U().getBool("IS_TEST")||U().getBool("PROD")||console.warn(...n)}function K0(...n){U().getBool("IS_TEST")||U().getBool("PROD")||console.log(...n)}/** 77 * @license 78 * Copyright 2019 Google LLC. All Rights Reserved. 79 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 5,634 bytes, lines 80-106
80 * you may not use this file except in compliance with the License. 81 * You may obtain a copy of the License at 82 * 83 * http://www.apache.org/licenses/LICENSE-2.0 84 * 85 * Unless required by applicable law or agreed to in writing, software 86 * distributed under the License is distributed on an "AS IS" BASIS, 87 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 88 * See the License for the specific language governing permissions and 89 * limitations under the License. 90 * ============================================================================= 91 */const yi=Cl("kernelRegistry",()=>new Map),X0=Cl("gradRegistry",()=>new Map);function bi(n,e){const t=bm(n,e);return yi.get(t)}function Sh(n){return X0.get(n)}function Ch(n){const e=yi.entries(),t=[];for(;;){const{done:r,value:s}=e.next();if(r)break;const[a,o]=s,[i]=a.split("_");i===n&&t.push(o)}return t}function ym(n){const{kernelName:e,backendName:t}=n,r=bm(e,t);yi.has(r)&&Un(`The kernel '${e}' for backend '${t}' is already registered`),yi.set(r,n)}function bm(n,e){return`${e}_${n}`}/** 92 * @license 93 * Copyright 2023 Google LLC. 94 * Licensed under the Apache License, Version 2.0 (the "License"); 95 * you may not use this file except in compliance with the License. 96 * You may obtain a copy of the License at 97 * 98 * http://www.apache.org/licenses/LICENSE-2.0 99 * 100 * Unless required by applicable law or agreed to in writing, software 101 * distributed under the License is distributed on an "AS IS" BASIS, 102 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 103 * See the License for the specific language governing permissions and 104 * limitations under the License. 105 * ============================================================================= 106 */function xm(n){return n instanceof Float32Array||n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray}var Fc=Xe,$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 Xe(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}Xe.prototype.__isLong__;Object.defineProperty(Xe.prototype,"__isLong__",{value:!0});function an(n){return(n&&n.__isLong__)===!0}Xe.isLong=an;var _h={},Nh={};function Ps(n,e){var t,r,s;return e?(n>>>=0,(s=0<=n&&n<256)&&(r=Nh[n],r)?r:(t=Ye(n,(n|0)<0?-1:0,!0),s&&(Nh[n]=t),t)):(n|=0,(s=-128<=n&&n<128)&&(r=_h[n],r)?r:(t=Ye(n,n<0?-1:0,!1),s&&(_h[n]=t),t))}Xe.fromInt=Ps;function Sn(n,e){if(isNaN(n))return e?bs:Cn;if(e){if(n<0)return bs;if(n>=wm)return $m}else{if(n<=-kh)return nn;if(n+1>=kh)return Im}return n<0?Sn(-n,e).neg():Ye(n%va|0,n/va|0,e)}Xe.fromNumber=Sn;function Ye(n,e,t){return new Xe(n,e,t)}Xe.fromBits=Ye;var xi=Math.pow;function up(n,e,t){if(n.length===0)throw Error("empty string");if(n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return Cn;if(typeof e=="number"?(t=e,e=!1):e=!!e,t=t||10,t<2||36<t)throw RangeError("radix");var r;if((r=n.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return up(n.substring(1),e,t).neg();for(var s=Sn(xi(t,8)),a=Cn,o=0;o<n.length;o+=8){var i=Math.min(8,n.length-o),c=parseInt(n.substring(o,o+i),t);if(i<8){var l=Sn(xi(t,i));a=a.mul(l).add(Sn(c))}else a=a.mul(s),a=a.add(Sn(c))}return a.unsigned=e,a}Xe.fromString=up;function Kn(n,e){return typeof n=="number"?Sn(n,e):typeof n=="string"?up(n,e):Ye(n.low,n.high,typeof e=="boolean"?e:n.unsigned)}Xe.fromValue=Kn;var Th=1<<16,Y0=1<<24,va=Th*Th,wm=va*va,kh=wm/2,Eh=Ps(Y0),Cn=Ps(0);Xe.ZERO=Cn;var bs=Ps(0,!0);Xe.UZERO=bs;var ha=Ps(1);Xe.ONE=ha;var vm=Ps(1,!0);Xe.UONE=vm;var Pc=Ps(-1);Xe.NEG_ONE=Pc;var Im=Ye(-1,2147483647,!1);Xe.MAX_VALUE=Im;var $m=Ye(-1,-1,!0);Xe.MAX_UNSIGNED_VALUE=$m;var nn=Ye(0,-2147483648,!1);Xe.MIN_VALUE=nn;var re=Xe.prototype;re.toInt=function(){return this.unsigned?this.low>>>0:this.low};re.toNumber=function(){return this.unsigned?(this.high>>>0)*va+(this.low>>>0):this.high*va+(this.low>>>0)};re.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(nn)){var t=Sn(e),r=this.div(t),s=r.mul(t).sub(this);return r.toString(e)+s.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var a=Sn(xi(e,6),this.unsigned),o=this,i="";;){var c=o.div(a),l=o.sub(c.mul(a)).toInt()>>>0,u=l.toString(e);if(o=c,o.isZero())return u+i;for(;u.length<6;)u="0"+u;i=""+u+i}};re.getHighBits=function(){return this.high};re.getHighBitsUnsigned=function(){return this.high>>>0};re.getLowBits=function(){return this.low};re.getLowBitsUnsigned=function(){return this.low>>>0};re.getNumBitsAbs=function(){if(this.isNegative())return this.eq(nn)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&(e&1<<t)==0;t--);return this.high!=0?t+33:t+1};re.isZero=function(){return this.high===0&&this.low===0};
vendor: 7,293 bytes, lines 106-121
106re.eqz=re.isZero;re.isNegative=function(){return!this.unsigned&&this.high<0};re.isPositive=function(){return this.unsigned||this.high>=0};re.isOdd=function(){return(this.low&1)===1};re.isEven=function(){return(this.low&1)===0};re.equals=function(e){return an(e)||(e=Kn(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};re.eq=re.equals;re.notEquals=function(e){return!this.eq(e)};re.neq=re.notEquals;re.ne=re.notEquals;re.lessThan=function(e){return this.comp(e)<0};re.lt=re.lessThan;re.lessThanOrEqual=function(e){return this.comp(e)<=0};re.lte=re.lessThanOrEqual;re.le=re.lessThanOrEqual;re.greaterThan=function(e){return this.comp(e)>0};re.gt=re.greaterThan;re.greaterThanOrEqual=function(e){return this.comp(e)>=0};re.gte=re.greaterThanOrEqual;re.ge=re.greaterThanOrEqual;re.compare=function(e){if(an(e)||(e=Kn(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};re.comp=re.compare;re.negate=function(){return!this.unsigned&&this.eq(nn)?nn:this.not().add(ha)};re.neg=re.negate;re.add=function(e){an(e)||(e=Kn(e));var t=this.high>>>16,r=this.high&65535,s=this.low>>>16,a=this.low&65535,o=e.high>>>16,i=e.high&65535,c=e.low>>>16,l=e.low&65535,u=0,d=0,p=0,h=0;return h+=a+l,p+=h>>>16,h&=65535,p+=s+c,d+=p>>>16,p&=65535,d+=r+i,u+=d>>>16,d&=65535,u+=t+o,u&=65535,Ye(p<<16|h,u<<16|d,this.unsigned)};re.subtract=function(e){return an(e)||(e=Kn(e)),this.add(e.neg())};re.sub=re.subtract;re.multiply=function(e){if(this.isZero())return Cn;if(an(e)||(e=Kn(e)),$n){var t=$n.mul(this.low,this.high,e.low,e.high);return Ye(t,$n.get_high(),this.unsigned)}if(e.isZero())return Cn;if(this.eq(nn))return e.isOdd()?nn:Cn;if(e.eq(nn))return this.isOdd()?nn:Cn;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Eh)&&e.lt(Eh))return Sn(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,s=this.high&65535,a=this.low>>>16,o=this.low&65535,i=e.high>>>16,c=e.high&65535,l=e.low>>>16,u=e.low&65535,d=0,p=0,h=0,m=0;return m+=o*u,h+=m>>>16,m&=65535,h+=a*u,p+=h>>>16,h&=65535,h+=o*l,p+=h>>>16,h&=65535,p+=s*u,d+=p>>>16,p&=65535,p+=a*l,d+=p>>>16,p&=65535,p+=o*c,d+=p>>>16,p&=65535,d+=r*u+s*l+a*c+o*i,d&=65535,Ye(h<<16|m,d<<16|p,this.unsigned)};re.mul=re.multiply;re.divide=function(e){if(an(e)||(e=Kn(e)),e.isZero())throw Error("division by zero");if($n){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?$n.div_u:$n.div_s)(this.low,this.high,e.low,e.high);return Ye(t,$n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?bs:Cn;var r,s,a;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return bs;if(e.gt(this.shru(1)))return vm;a=bs}else{if(this.eq(nn)){if(e.eq(ha)||e.eq(Pc))return nn;if(e.eq(nn))return ha;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(Cn)?e.isNegative()?ha:Pc:(s=this.sub(e.mul(r)),a=r.add(s.div(e)),a)}else if(e.eq(nn))return this.unsigned?bs:Cn;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();a=Cn}for(s=this;s.gte(e);){r=Math.max(1,Math.floor(s.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(r)/Math.LN2),c=i<=48?1:xi(2,i-48),l=Sn(r),u=l.mul(e);u.isNegative()||u.gt(s);)r-=c,l=Sn(r,this.unsigned),u=l.mul(e);l.isZero()&&(l=ha),a=a.add(l),s=s.sub(u)}return a};re.div=re.divide;re.modulo=function(e){if(an(e)||(e=Kn(e)),$n){var t=(this.unsigned?$n.rem_u:$n.rem_s)(this.low,this.high,e.low,e.high);return Ye(t,$n.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};re.mod=re.modulo;re.rem=re.modulo;re.not=function(){return Ye(~this.low,~this.high,this.unsigned)};re.and=function(e){return an(e)||(e=Kn(e)),Ye(this.low&e.low,this.high&e.high,this.unsigned)};re.or=function(e){return an(e)||(e=Kn(e)),Ye(this.low|e.low,this.high|e.high,this.unsigned)};re.xor=function(e){return an(e)||(e=Kn(e)),Ye(this.low^e.low,this.high^e.high,this.unsigned)};re.shiftLeft=function(e){return an(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Ye(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Ye(0,this.low<<e-32,this.unsigned)};re.shl=re.shiftLeft;re.shiftRight=function(e){return an(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Ye(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Ye(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};re.shr=re.shiftRight;re.shiftRightUnsigned=function(e){if(an(e)&&(e=e.toInt()),e&=63,e===0)return this;var t=this.high;if(e<32){var r=this.low;return Ye(r>>>e|t<<32-e,t>>>e,this.unsigned)}else return e===32?Ye(t,0,this.unsigned):Ye(t>>>e-32,0,this.unsigned)};re.shru=re.shiftRightUnsigned;re.shr_u=re.shiftRightUnsigned;re.toSigned=function(){return this.unsigned?Ye(this.low,this.high,!1):this};re.toUnsigned=function(){return this.unsigned?this:Ye(this.low,this.high,!0)};re.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};re.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};re.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};Xe.fromBytes=function(e,t,r){return r?Xe.fromBytesLE(e,t):Xe.fromBytesBE(e,t)};Xe.fromBytesLE=function(e,t){return new Xe(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};Xe.fromBytesBE=function(e,t){return new Xe(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};const Q0=vl({__proto__:null,default:Fc},[Fc]);/** 107 * @license 108 * Copyright 2021 Google LLC. All Rights Reserved. 109 * Licensed under the Apache License, Version 2.0 (the "License"); 110 * you may not use this file except in compliance with the License. 111 * You may obtain a copy of the License at 112 * 113 * http://www.apache.org/licenses/LICENSE-2.0 114 * 115 * Unless required by applicable law or agreed to in writing, software 116 * distributed under the License is distributed on an "AS IS" BASIS, 117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 118 * See the License for the specific language governing permissions and 119 * limitations under the License. 120 * ============================================================================= 121 */const fs=Fc||Q0;function Lu(n){return fs.fromString(n,!0,16)}const Sm=Lu("c3a5c85c97cb3127"),hs=Lu("b492b66fbe98f273"),Lt=Lu("9ae16a3b2f90404f");function Lc(n){return n.xor(n.shru(47))}function Cm(n,e,t){const r=n.slice(e,e+t);return fs.fromBytes(Array.from(r),!0,!0)}function Ge(n,e){return Cm(n,e,8)}function Rh(n,e){return Cm(n,e,4)}function gt(n,e){return e===0?n:n.shru(e).or(n.shl(64-e))}function Mr(n,e,t=Lu("9ddfea08eb382d69")){let r=n.xor(e).mul(t);r=r.xor(r.shru(47));let s=e.xor(r).mul(t);return s=s.xor(s.shru(47)),s=s.mul(t),s}function Z0(n,e,t,r,s,a){s=s.add(n),a=gt(a.add(s).add(r),21);const o=s;return s=s.add(e),s=s.add(t),a=a.add(gt(s,44)),[s.add(r),a.add(o)]}function ti(n,e,t,r){return Z0(Ge(n,e),Ge(n,e+8),Ge(n,e+16),Ge(n,e+24),t,r)}function J0(n,e=n.length){if(e>=8){const t=Lt.add(e*2),r=Ge(n,0).add(Lt),s=Ge(n,e-8),a=gt(s,37).mul(t).add(r),o=gt(r,25).add(s).mul(t);return Mr(a,o,t)}if(e>
vendor: 18,469 bytes, lines 121-233
121=4){const t=Lt.add(e*2),r=Rh(n,0);return Mr(r.shl(3).add(e),Rh(n,e-4),t)}if(e>0){const t=n[0],r=n[e>>1],s=n[e-1],a=t+(r<<8),o=e+(s<<2);return Lc(Lt.mul(a).xor(Sm.mul(o))).mul(Lt)}return Lt}function ew(n,e=n.length){const t=Lt.add(e*2),r=Ge(n,0).mul(hs),s=Ge(n,8),a=Ge(n,e-8).mul(t),o=Ge(n,e-16).mul(Lt);return Mr(gt(r.add(s),43).add(gt(a,30)).add(o),r.add(gt(s.add(Lt),18)).add(a),t)}function tw(n,e=n.length){const t=Lt.add(e*2),r=Ge(n,0).mul(Lt),s=Ge(n,8),a=Ge(n,e-8).mul(t),o=Ge(n,e-16).mul(Lt),i=gt(r.add(s),43).add(gt(a,30)).add(o),c=Mr(i,r.add(gt(s.add(Lt),18)).add(a),t),l=Ge(n,16).mul(t),u=Ge(n,24),d=i.add(Ge(n,e-32)).mul(t),p=c.add(Ge(n,e-24)).mul(t);return Mr(gt(l.add(u),43).add(gt(d,30)).add(p),l.add(gt(u.add(r),18)).add(d),t)}function nw(n,e=n.length){const t=fs.fromNumber(81,!0);if(e<=32)return e<=16?J0(n,e):ew(n,e);if(e<=64)return tw(n,e);let r=t,s=t.mul(hs).add(113),a=Lc(s.mul(Lt).add(113)).mul(Lt),o=[fs.UZERO,fs.UZERO],i=[fs.UZERO,fs.UZERO];r=r.mul(Lt).add(Ge(n,0));let c=0;const l=(e-1>>6)*64,u=l+(e-1&63)-63;do r=gt(r.add(s).add(o[0]).add(Ge(n,c+8)),37).mul(hs),s=gt(s.add(o[1]).add(Ge(n,c+48)),42).mul(hs),r=r.xor(i[1]),s=s.add(o[0]).add(Ge(n,c+40)),a=gt(a.add(i[0]),33).mul(hs),o=ti(n,c,o[1].mul(hs),r.add(i[0])),i=ti(n,c+32,a.add(i[1]),s.add(Ge(n,c+16))),[a,r]=[r,a],c+=64;while(c!==l);const d=hs.add(a.and(255).shl(1));return c=u,i[0]=i[0].add(e-1&63),o[0]=o[0].add(i[0]),i[0]=i[0].add(o[0]),r=gt(r.add(s).add(o[0]).add(Ge(n,c+8)),37).mul(d),s=gt(s.add(o[1]).add(Ge(n,c+48)),42).mul(d),r=r.xor(i[1].mul(9)),s=s.add(o[0].mul(9).add(Ge(n,c+40))),a=gt(a.add(i[0]),33).mul(d),o=ti(n,c,o[1].mul(d),r.add(i[0])),i=ti(n,c+32,a.add(i[1]),s.add(Ge(n,c+16))),[a,r]=[r,a],Mr(Mr(o[0],i[0],d).add(Lc(s).mul(Sm)).add(a),Mr(o[1],i[1],d).add(r),d)}/** 122 * @license 123 * Copyright 2017 Google LLC. All Rights Reserved. 124 * Licensed under the Apache License, Version 2.0 (the "License"); 125 * you may not use this file except in compliance with the License. 126 * You may obtain a copy of the License at 127 * 128 * http://www.apache.org/licenses/LICENSE-2.0 129 * 130 * Unless required by applicable law or agreed to in writing, software 131 * distributed under the License is distributed on an "AS IS" BASIS, 132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133 * See the License for the specific language governing permissions and 134 * limitations under the License. 135 * ============================================================================= 136 */function Ea(n,e){return e==="string"?vs(n):Mu([n],e)}function rw(n,e){return n instanceof Float32Array&&e==="float32"||n instanceof Int32Array&&e==="int32"||n instanceof Uint8Array&&e==="bool"}function Mu(n,e){if(e==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(n)&&(n=Cs(n)),U().getBool("DEBUG")&&O0(n,e),rw(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 dn(){return U().platform.now()}function vs(n,e="utf-8"){return e=e||"utf-8",U().platform.encode(n,e)}function Ia(n,e="utf-8"){return e=e||"utf-8",U().platform.decode(n,e)}function Tn(n){return U().platform.isTypedArray!=null?U().platform.isTypedArray(n):xm(n)}function Cs(n,e=[],t=!1){if(e==null&&(e=[]),typeof n=="boolean"||typeof n=="number"||typeof n=="string"||Ss(n)||n==null||Tn(n)&&t)e.push(n);else if(Array.isArray(n)||Tn(n))for(let r=0;r<n.length;++r)Cs(n[r],e,t);else{let r=-1;for(const s of Object.keys(n))/^([1-9]+[0-9]*|0)$/.test(s)&&(r=Math.max(r,Number(s)));for(let s=0;s<=r;s++)Cs(n[s],e,t)}return e}/** 137 * @license 138 * Copyright 2018 Google LLC. All Rights Reserved. 139 * Licensed under the Apache License, Version 2.0 (the "License"); 140 * you may not use this file except in compliance with the License. 141 * You may obtain a copy of the License at 142 * 143 * http://www.apache.org/licenses/LICENSE-2.0 144 * 145 * Unless required by applicable law or agreed to in writing, software 146 * distributed under the License is distributed on an "AS IS" BASIS, 147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 148 * See the License for the specific language governing permissions and 149 * limitations under the License. 150 * ============================================================================= 151 */class sw{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new ow)}profileKernel(e,t,r){let s;const a=()=>{s=r()};let o;const i=dn();if(this.backendTimer.timerAvailable())o=this.backendTimer.time(a);else{a();for(const l of s)l.dataSync();o=Promise.resolve({kernelMs:dn()-i})}if(U().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l<s.length;l++){const u=s[l];u.data().then(d=>{aw(d,u.dtype,e)})}return{kernelName:e,outputs:s,inputs:t,timeMs:o.then(l=>l.kernelMs),extraInfo:o.then(l=>l.getExtraProfileInfo!=null?l.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:t,outputs:r,timeMs:s,inputs:a,extraInfo:o}=e;r.forEach(i=>{Promise.all([i.data(),s,o]).then(c=>{this.logger.logKernelProfile(t,i,c[0],c[1],a,c[2])})})}}function aw(n,e,t){if(e!=="float32")return!1;for(let r=0;r<n.length;r++){const s=n[r];if(isNaN(s)||!isFinite(s))return console.warn(`Found ${s} in the result of '${t}'`),!0}return!1}class ow{logKernelProfile(e,t,r,s,a,o){const i=typeof s=="number"?fa(`${s}ms`,9):s.error,c=fa(e,25),l=t.rank,u=t.size,d=fa(t.shape.toString(),14);let p="";for(const h in a){const m=a[h];if(m!=null){const g=m.shape||t.shape,y=g.length;p+=`${h}: ${y}D ${y>0?g:""} `}}console.log(`%c${c} %c${i} %c${l}D ${d} %c${u} %c${p} %c${o}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}/** 152 * @license 153 * Copyright 2017 Google LLC. All Rights Reserved. 154 * Licensed under the Apache License, Version 2.0 (the "License"); 155 * you may not use this file except in compliance with the License. 156 * You may obtain a copy of the License at 157 * 158 * http://www.apache.org/licenses/LICENSE-2.0 159 * 160 * Unless required by applicable law or agreed to in writing, software 161 * distributed under the License is distributed on an "AS IS" BASIS, 162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163 * See the License for the specific language governing permissions and 164 * limitations under the License. 165 * ============================================================================= 166 */function iw(n,e,t){const r={},s={};for(let c=0;c<e.length;c++)r[e[c].id]=!0;for(let c=0;c<n.length;c++){const l=n[c],u=l.inputs;for(const d in u){const p=u[d];let h=!1;for(let m=0;m<e.length;m++)if(r[p.id]){l.outputs.forEach(g=>r[g.id]=!0),h=!0,s[l.id]=!0;break}if(h)break}}const a={};a[t.id]=!0;const o={};for(let c=n.length-1;c>=0;c--){const l=n[c],u=l.inputs;for(let d=0;d<l.outputs.length;d++)if(a[l.outputs[d].id]){for(const p in u)a[u[p].id]=!0,o[l.id]=!0;break}}const i=[];for(let c=0;c<n.length;c++){const l=n[c];if(s[l.id]&&o[l.id]){const u={};for(const p in l.inputs){const h=l.inputs[p];r[h.id]&&(u[p]=h)}const d=Object.assign({},l);d.inputs=u,d.outputs=l.outputs,i.push(d)}}return i}function uw(n,e,t,r){for(let s=e.length-1;s>=0;s--){const a=e[s],o=[];if(a.outputs.forEach(c=>{const l=n[c.id];l!=null?o.push(l):o.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);const i=a.gradient(o);for(const c in a.inputs){if(!(c in i))throw new Error(`Cannot backprop through input ${c}. Available gradients found: ${Object.keys(i)}.`);const l=t(()=>i[c]());if(l.dtype!=="float32")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${c} must have 'float32' dtype, but has '${l.dtype}'`);const u=a.inputs[c];if(!st(l.shape,u.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${c}' has shape '${l.shape}', which does not match the shape of the input '${u.shape}'`);if(n[u.id]==null)n[u.id]=l;else{const d=n[u.id];n[u.id]=r(d,l),d.dispose()}}}}/** 167 * @license 168 * Copyright 2018 Google LLC. All Rights Reserved. 169 * Licensed under the Apache License, Version 2.0 (the "License"); 170 * you may not use this file except in compliance with the License. 171 * You may obtain a copy of the License at 172 * 173 * http://www.apache.org/licenses/LICENSE-2.0 174 * 175 * Unless required by applicable law or agreed to in writing, software 176 * distributed under the License is distributed on an "AS IS" BASIS, 177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 178 * See the License for the specific language governing permissions and 179 * limitations under the License. 180 * ============================================================================= 181 */const Ah=20,eo=3,lc=7;function cw(n,e,t,r){const s=Be(e),a=lw(n,e,t,s),o=e.length,i=pi(n,e,t,s,a),c=["Tensor"];return r&&(c.push(` dtype: ${t}`),c.push(` rank: ${o}`),c.push(` shape: [${e}]`),c.push(" values:")),c.push(i.map(l=>" "+l).join(` 182`)),c.join(` 183`)}function lw(n,e,t,r){const s=H(e),a=r[r.length-1],o=new Array(a).fill(0),i=e.length,c=t==="complex64"?ro(n):n;if(i>1)for(let l=0;l<s/a;l++){const u=l*a;for(let d=0;d<a;d++)o[d]=Math.max(o[d],no(c[u+d],0,t).length)}return o}function no(n,e,t){let r;return Array.isArray(n)?r=`${parseFloat(n[0].toFixed(lc))} + ${parseFloat(n[1].toFixed(lc))}j`:Pi(n)?r=`'${n}'`:t==="bool"?r=_m(n):r=parseFloat(n.toFixed(lc)).toString(),fa(r,e)}function _m(n){return n===0?"false":"true"}function pi(n,e,t,r,s,a=!0){const o=t==="complex64"?2:1,i=e[0],c=e.length;if(c===0){if(t==="complex64"){const g=ro(n);return[no(g[0],0,t)]}return t==="bool"?[_m(n[0])]:[n[0].toString()]}if(c===1){if(i>Ah){const y=eo*o;let b=Array.from(n.slice(0,y)),v=Array.from(n.slice((i-eo)*o,i*o));return t==="complex64"&&(b=ro(b),v=ro(v)),["["+b.map(($,S)=>no($,s[S],t)).join(", ")+", ..., "+v.map(($,S)=>no($,s[i-eo+S],t)).join(", ")+"]"]}return["["+(t==="complex64"?ro(n):Array.from(n)).map((y,b)=>no(y,s[b],t)).join(", ")+"]"]}const l=e.slice(1),u=r.slice(1),d=r[0]*o,p=[];if(i>Ah){for(let g=0;g<eo;g++){const y=g*d,b=y+d;p.push(...pi(n.slice(y,b),l,t,u,s,!1))}p.push("...");for(let g=i-eo;g<i;g++){const y=g*d,b=y+d;p.push(...pi(n.slice(y,b),l,t,u,s,g===i-1))}}else for(let g=0;g<i;g++){const y=g*d,b=y+d;p.push(...pi(n.slice(y,b),l,t,u,s,g===i-1))}const h=c===2?",":"";p[0]="["+(i>0?p[0]+h:"");for(let g=1;g<p.length-1;g++)p[g]=" "+p[g]+h;let m=`, 184`;for(let g=2;g<c;g++)m+=` 185`;return p[p.length-1]=" "+p[p.length-1]+"]"+(a?"":m),p}function ro(n){const e=[];for(let t=0;t<n.length;t+=2)e.push([n[t],n[t+1]]);return e}/** 186 * @license 187 * Copyright 2017 Google LLC. All Rights Reserved. 188 * Licensed under the Apache License, Version 2.0 (the "License"); 189 * you may not use this file except in compliance with the License. 190 * You may obtain a copy of the License at 191 * 192 * http://www.apache.org/licenses/LICENSE-2.0 193 * 194 * Unless required by applicable law or agreed to in writing, software 195 * distributed under the License is distributed on an "AS IS" BASIS, 196 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 197 * See the License for the specific language governing permissions and 198 * limitations under the License. 199 * ============================================================================= 200 */class $a{constructor(e,t,r){if(this.dtype=t,this.shape=e.slice(),this.size=H(e),r!=null){const s=r.length;N(s===this.size,()=>`Length of values '${s}' 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||yt(t,this.size),this.strides=Be(e)}set(e,...t){t.length===0&&(t=[0]),N(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 s of e){if(s<0||s>=this.shape[t]){const a=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(a)}t++}let r=e[e.length-1];for(let s=0;s<e.length-1;++s)r+=this.strides[s]*e[s];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 Vn().makeTensor(this.values,this.shape,this.dtype)}}let Vn=null,la=null;function dw(n){Vn=n}function pw(n){la=n}class dt{constructor(e,t,r,s){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=H(e),this.strides=Be(e),this.dataId=r,this.id=s,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return la.buffer(this.shape,this.dtype,e)}bufferSync(){return la.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return Ac(this.shape,e,this.dtype==="complex64")}arraySync(){return Ac(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();const e=Vn().read(this.dataId);if(this.dtype==="string"){const t=await e;try{return t.map(r=>Ia(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(),Vn().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Vn().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Ia(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 Vn().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),Vn().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return la.print(this,e)}clone(){return this.throwIfDisposed(),la.clone(this)}toString(e=!1){const t=this.dataSync();return cw(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),la.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),Vn().makeVariable(this,e,t,r)}}Object.defineProperty(dt,Symbol.hasInstance,{value:n=>!!n&&n.data!=null&&n.dataSync!=null&&n.throwIfDisposed!=null});function Nm(){return Cl("Tensor",()=>dt)}Nm();class wi extends dt{constructor(e,t,r,s){super(e.shape,e.dtype,e.dataId,s),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(!st(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Vn().disposeTensor(this),this.dataId=e.dataId,Vn().incRef(this,null)}dispose(){Vn().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(wi,Symbol.hasInstance,{value:n=>n instanceof dt&&n.assign!=null&&n.assign instanceof Function});/** 201 * @license 202 * Copyright 2017 Google LLC. All Rights Reserved. 203 * Licensed under the Apache License, Version 2.0 (the "License"); 204 * you may not use this file except in compliance with the License. 205 * You may obtain a copy of the License at 206 * 207 * http://www.apache.org/licenses/LICENSE-2.0 208 * 209 * Unless required by applicable law or agreed to in writing, software 210 * distributed under the License is distributed on an "AS IS" BASIS, 211 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 212 * See the License for the specific language governing permissions and 213 * limitations under the License. 214 * ============================================================================= 215 */var Dh;(function(n){n.R0="R0",n.R1="R1",n.R2="R2",n.R3="R3",n.R4="R4",n.R5="R5",n.R6="R6"})(Dh||(Dh={}));var Mc;(function(n){n.float32="float32",n.int32="int32",n.bool="int32",n.complex64="complex64"})(Mc||(Mc={}));var Bc;(function(n){n.float32="float32",n.int32="int32",n.bool="bool",n.complex64="complex64"})(Bc||(Bc={}));var Vc;(function(n){n.float32="float32",n.int32="float32",n.bool="float32",n.complex64="complex64"})(Vc||(Vc={}));var Wc;(function(n){n.float32="complex64",n.int32="complex64",n.bool="complex64",n.complex64="complex64"})(Wc||(Wc={}));const hw={float32:Vc,int32:Mc,bool:Bc,complex64:Wc};function ir(n,e){if(n==="string"||e==="string"){if(n==="string"&&e==="string")return"string";throw new Error(`Can not upcast ${n} with ${e}`)}return hw[n][e]}function cp(n){return ir(n,"int32")}function Tm(n){return n!=null&&typeof n=="object"&&"texture"in n&&n.texture instanceof WebGLTexture}function km(n){return typeof GPUBuffer<"u"&&n!=null&&typeof n=="object"&&"buffer"in n&&n.buffer instanceof GPUBuffer}/** 216 * @license 217 * Copyright 2018 Google LLC. All Rights Reserved. 218 * Licensed under the Apache License, Version 2.0 (the "License"); 219 * you may not use this file except in compliance with the License. 220 * You may obtain a copy of the License at 221 * 222 * http://www.apache.org/licenses/LICENSE-2.0 223 * 224 * Unless required by applicable law or agreed to in writing, software 225 * distributed under the License is distributed on an "AS IS" BASIS, 226 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 227 * See the License for the specific language governing permissions and 228 * limitations under the License. 229 * ============================================================================= 230 */function ut(n,e){if(n.dtype===e.dtype)return[n,e];const t=ir(n.dtype,e.dtype);return[n.cast(t),e.cast(t)]}function fw(n,e){N(n.dtype===e.dtype,()=>`The dtypes of the first(${n.dtype}) and second(${e.dtype}) input must match`)}function Em(n){const e=[];return Rm(n,e,new Set),e}function Rm(n,e,t){if(n==null)return;if(n instanceof dt){e.push(n);return}if(!mw(n))return;const r=n;for(const s in r){const a=r[s];t.has(a)||(t.add(a),Rm(a,e,t))}}function mw(n){return Array.isArray(n)||typeof n=="object"}/** 231 * @license 232 * Copyright 2018 Google LLC. All Rights Reserved. 233 * Licensed under the Apache License, Version 2.0 (the "License");
234 * you may not use this file except in compliance with the License. 235 * You may obtain a copy of the License at 236 * 237 * http://www.apache.org/licenses/LICENSE-2.0 238 * 239 * Unless required by applicable law or agreed to in writing, software 240 * distributed under the License is distributed on an "AS IS" BASIS, 241 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 242 * See the License for the specific language governing permissions and 243 * limitations under the License. 244 * ============================================================================= 245 */function dc(n){return n.kernelName!=null}class Oh{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 Sa{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Oh}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.")}get backend(){if(this.pendingBackendInit!=null)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(this.backendInstance==null){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?(Un(`${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`);
vendor: 13,534 bytes, lines 245-248
245if(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 sw(this.backendInstance),!0}setupRegisteredKernels(){Ch(this.backendName).forEach(t=>{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){Ch(e).forEach(r=>{r.disposeFunc!=null&&r.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 Il)&&typeof r.then=="function"){const s=++this.pendingBackendInitId,a=r.then(o=>s<this.pendingBackendInitId?!1:(this.registry[e]=o,this.pendingBackendInit=null,!0)).catch(o=>(s<this.pendingBackendInitId||(this.pendingBackendInit=null,Un(`Initialization of backend ${e} failed`),Un(o.stack||o.message)),!1));return this.pendingBackendInit=a,{success:a,asyncInit:!0}}else return this.registry[e]=r,{success:!0,asyncInit:!1}}catch(r){return Un(`Initialization of backend ${e} failed`),Un(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:s,asyncInit:a}=this.initializeBackend(r);if(a||s)return{name:r,asyncInit:a}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const r=this.state.tensorInfo.get(t),s=r.backend,a=this.readSync(t),o=s.refCount(t);s.disposeData(t,!0),r.backend=e,e.move(t,a,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 s;return this.scopedRun(()=>this.startScope(r),()=>this.endScope(s),()=>(s=t(),s instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),s))}scopedRun(e,t,r){e();try{const s=r();return t(),s}catch(s){throw t(),s}}nextTensorId(){return Sa.nextTensorId++}nextVariableId(){return Sa.nextVariableId++}clone(e){const t=F.runKernel(au,{x:e}),r={x:e},s=o=>({x:()=>{const i="float32",c={x:o},l={dtype:i};return F.runKernel(Gi,c,l)}}),a=[];return this.addTapeNode(this.state.activeScope.name,r,[t],s,a,{}),t}runKernel(e,t,r){if(this.backendName==null&&this.backend,!(bi(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 s=this.backend.numDataIds();let a=0;r.forEach(c=>{a+=c.dtype==="complex64"?3:1});const o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=s-t-a-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 s=this.isTapeOn(),a=this.state.numBytes,o=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let c;const l=dc(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(dc(e)){const{kernelName:m,inputs:g,attrs:y}=e;this.backendName==null&&this.backend;const b=bi(m,this.backendName);N(b!=null,()=>`Cannot find registered kernel '${m}' for backend '${this.backendName}'`),i=()=>{const v=this.backend.numDataIds();c=b.kernelFunc({inputs:g,attrs:y,backend:this.backend});const $=Array.isArray(c)?c:[c];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(m,v,$);const S=$.map(T=>T.rank!=null?T:this.makeTensorFromTensorInfo(T));if(s){const T=this.getTensorsForGradient(m,g,S);r=this.saveTensorsForBackwardMode(T)}return S}}else{const{forwardFunc:m}=e,g=y=>{!s||(r=y.map(b=>this.keep(this.clone(b))))};i=()=>{const y=this.backend.numDataIds();c=this.tidy(()=>m(this.backend,g));const b=Array.isArray(c)?c:[c];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,y,b),b}}const{inputs:u,attrs:d}=e,p=dc(e)?null:e.backwardsFunc;let h;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(h=this.profiler.profileKernel(l,u,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(h),t=h.outputs)}),s&&this.addTapeNode(l,u,t,p,r,d),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-o,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(m=>u[m]!=null?u[m].shape:null),outputShapes:t.map(m=>m.shape),kernelTimeMs:h.timeMs,extraInfo:h.extraInfo}),Array.isArray(c)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(r=>this.keep(this.clone(r)))}getTensorsForGradient(e,t,r){const s=Sh(e);if(s!=null){const a=s.inputsToSave||[],o=s.outputsToSave||[];let i;s.saveAllInputs?(N(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(l=>t[l])):i=a.map(l=>t[l]);const c=r.filter((l,u)=>o[u]);return i.concat(c)}return[]}makeTensor(e,t,r,s){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");r=r||"float32",s=s||this.backend;let a=e;r==="string"&&Pi(e[0])&&(a=e.map(c=>vs(c)));const o=s.write(a,t,r),i=new dt(t,r,o,this.nextTensorId());if(this.trackTensor(i,s),r==="string"){const c=this.state.tensorInfo.get(o),l=L0(a);this.state.numBytes+=l-c.bytes,c.bytes=l}return i}makeTensorFromDataId(e,t,r,s){r=r||"float32";const a={dataId:e,shape:t,dtype:r};return this.makeTensorFromTensorInfo(a,s)}makeTensorFromTensorInfo(e,t){const{dataId:r,shape:s,dtype:a}=e,o=new dt(s,a,r,this.nextTensorId());return this.trackTensor(o,t),o}makeVariable(e,t=!0,r,s){r=r||this.nextVariableId().toString(),s!=null&&s!==e.dtype&&(e=e.cast(s));const a=new wi(e,t,r,this.nextTensorId());if(this.state.registeredVariables[a.name]!=null)throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let r=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(r=e.size*wa(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 wi||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*wa(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(s=>s.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-r;for(const s of this.state.activeProfile.kernels)s.kernelTimeMs=await s.kernelTimeMs,s.extraInfo=await s.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,r,s,a,o){const i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:r,saved:a},c=Sh(e);c!=null&&(s=c.gradFunc),s!=null&&(i.gradient=l=>(l=l.map((u,d)=>{if(u==null){const p=r[d],h=Ur(p.size,p.dtype);return this.makeTensor(h,p.shape,p.dtype)}return u}),s(l.length>1?l:l[0],a,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=Em(e),r=new Set(t.map(a=>a.id));for(let a=0;a<this.state.activeScope.track.length;a++){const o=this.state.activeScope.track[a];!o.kept&&!r.has(o.id)&&o.dispose()}const s=this.state.scopeStack.pop();this.state.activeScope=this.state.scopeStack.length===0?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(a=>{!a.kept&&a.scopeId===s.id&&this.track(a)})}gradients(e,t,r,s=!1){if(N(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 a=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));N(a instanceof dt,()=>"The result y returned by f() must be a tensor.");const o=iw(this.state.activeTape,t,a);if(!s&&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[a.id]=r==null?gw(a.shape):r,uw(i,o,l=>this.tidy(l),yw);const c=t.map(l=>i[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(const u of l.saved)u.dispose()}),this.state.activeTape=null),{value:a,grads:c}})}customGrad(e){return N(Ec(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{N(t.every(i=>i instanceof dt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let r;const s={};t.forEach((i,c)=>{s[c]=i});const a=(i,c)=>(r=e(...t,c),N(r.value instanceof dt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),N(Ec(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),o=(i,c)=>{const l=r.gradFunc(i,c),u=Array.isArray(l)?l:[l];N(u.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),N(u.every(p=>p instanceof dt),()=>"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 d={};return u.forEach((p,h)=>{d[h]=()=>p}),d};return this.runKernelFunc({forwardFunc:a,backwardsFunc:o,inputs:s})}}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=dn(),r=await this.backend.time(e);return r.wallMs=dn()-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 Oh;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}}Sa.nextTensorId=0;Sa.nextVariableId=0;function gw(n){const e=jf(H(n),"float32");return F.makeTensor(e,n,"float32")}function Am(){const n=Kf();if(n._tfengine==null){const e=new V0(n);n._tfengine=new Sa(e)}return G0(n._tfengine.ENV),dw(()=>n._tfengine),n._tfengine}const F=Am();function yw(n,e){const t={a:n,b:e};return F.runKernel(Li,t)}/** 246 * @license 247 * Copyright 2017 Google LLC. All Rights Reserved. 248 * Licensed under the Apache License, Version 2.0 (the "License");
249 * you may not use this file except in compliance with the License. 250 * You may obtain a copy of the License at 251 * 252 * http://www.apache.org/licenses/LICENSE-2.0 253 * 254 * Unless required by applicable law or agreed to in writing, software 255 * distributed under the License is distributed on an "AS IS" BASIS, 256 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 257 * See the License for the specific language governing permissions and 258 * limitations under the License. 259 * ============================================================================= 260 */function bw(){return typeof navigator<"u"&&navigator!=null}function Dm(n){if(n||bw()){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 Om(){return typeof window<"u"&&window.document!=null||typeof WorkerGlobalScope<"u"}/** 261 * @license 262 * Copyright 2019 Google LLC. All Rights Reserved. 263 * Licensed under the Apache License, Version 2.0 (the "License"); 264 * you may not use this file except in compliance with the License. 265 * You may obtain a copy of the License at 266 * 267 * http://www.apache.org/licenses/LICENSE-2.0 268 * 269 * Unless required by applicable law or agreed to in writing, software 270 * distributed under the License is distributed on an "AS IS" BASIS, 271 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 272 * See the License for the specific language governing permissions and 273 * limitations under the License. 274 * ============================================================================= 275 */const qt=U();qt.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.")});qt.registerFlag("IS_BROWSER",()=>Om());qt.registerFlag("IS_NODE",()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u");qt.registerFlag("IS_CHROME",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));qt.registerFlag("IS_SAFARI",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor));qt.registerFlag("PROD",()=>!1);qt.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>qt.getBool("DEBUG"));qt.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);qt.registerFlag("IS_TEST",()=>!1);qt.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>qt.getBool("DEBUG"));qt.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);qt.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1);qt.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);/** 276 * @license 277 * Copyright 2018 Google LLC. All Rights Reserved. 278 * Licensed under the Apache License, Version 2.0 (the "License");
279 * you may not use this file except in compliance with the License. 280 * You may obtain a copy of the License at 281 * 282 * http://www.apache.org/licenses/LICENSE-2.0 283 * 284 * Unless required by applicable law or agreed to in writing, software 285 * distributed under the License is distributed on an "AS IS" BASIS, 286 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 287 * See the License for the specific language governing permissions and 288 * limitations under the License. 289 * ============================================================================= 290 */function qr(n,e){let t=n;if(Tn(n))return e==="string"?[]:[n.length];if(Tm(n)){const s=n.channels||"RGBA";return[n.height,n.width*s.length]}else if(km(n))return[n.buffer.size/(e==null?4:wa(e))];if(!Array.isArray(n))return[];const r=[];for(;Array.isArray(t)||Tn(t)&&e!=="string";)r.push(t.length),t=t[0];return Array.isArray(n)&&U().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Fm(n,r,[]),r}function Fm(n,e,t){if(t=t||[],!Array.isArray(n)&&!Tn(n)){N(e.length===0,()=>`Element arr[${t.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);return}N(e.length>0,()=>`Element arr[${t.join("][")}] should be a primitive, but is an array of ${n.length} elements`),N(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 s=0;s<n.length;++s)Fm(n[s],r,t.concat(s))}function Fh(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,e,t,r="numeric"){if(n instanceof Nm())return Fh(r,n.dtype,e,t),n;let s=ka(n);if(s!=="string"&&["bool","int32","float32"].indexOf(r)>=0&&(s=r),Fh(r,s,e,t),n==null||!Tn(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"){const c=n==null?"null":n.constructor.name;throw new Error(`Argument '${e}' passed to '${t}' must be a Tensor or TensorLike, but got '${c}'`)}const a=qr(n,s);!Tn(n)&&!Array.isArray(n)&&(n=[n]);const i=s!=="string"?Mu(n,s):Cs(n,[],!0);return F.makeTensor(i,a,s)}function vi(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,o)=>_(a,`${e}[${o}]`,t,r))}/** 291 * @license 292 * Copyright 2018 Google LLC. All Rights Reserved. 293 * Licensed under the Apache License, Version 2.0 (the "License"); 294 * you may not use this file except in compliance with the License. 295 * You may obtain a copy of the License at 296 * 297 * http://www.apache.org/licenses/LICENSE-2.0 298 * 299 * Unless required by applicable law or agreed to in writing, software 300 * distributed under the License is distributed on an "AS IS" BASIS, 301 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 302 * See the License for the specific language governing permissions and 303 * limitations under the License. 304 * ============================================================================= 305 */const Pm="__op";function D(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+Pm;const s=(...a)=>{F.startScope(t);try{const o=r(...a);return Ss(o)&&console.error("Cannot return a Promise inside of tidy."),F.endScope(o),o}catch(o){throw F.endScope(null),o}};return Object.defineProperty(s,"name",{value:t,configurable:!0}),s}/** 306 * @license 307 * Copyright 2020 Google LLC. All Rights Reserved. 308 * Licensed under the Apache License, Version 2.0 (the "License"); 309 * you may not use this file except in compliance with the License. 310 * You may obtain a copy of the License at 311 * 312 * http://www.apache.org/licenses/LICENSE-2.0 313 * 314 * Unless required by applicable law or agreed to in writing, software 315 * distributed under the License is distributed on an "AS IS" BASIS, 316 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 317 * See the License for the specific language governing permissions and 318 * limitations under the License. 319 * ============================================================================= 320 */function xw(n,e){const t=_(n,"real","complex"),r=_(e,"imag","complex");sn(t.shape,r.shape,`real and imag shapes, ${t.shape} and ${r.shape}, must match in call to tf.complex().`);const s={real:t,imag:r};return F.runKernel(Qf,s)}const zr=D({complex_:xw}
vendor: 4,289 bytes, lines 320-365
320);/** 321 * @license 322 * Copyright 2018 Google LLC. All Rights Reserved. 323 * Licensed under the Apache License, Version 2.0 (the "License"); 324 * you may not use this file except in compliance with the License. 325 * You may obtain a copy of the License at 326 * 327 * http://www.apache.org/licenses/LICENSE-2.0 328 * 329 * Unless required by applicable law or agreed to in writing, software 330 * distributed under the License is distributed on an "AS IS" BASIS, 331 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 332 * See the License for the specific language governing permissions and 333 * limitations under the License. 334 * ============================================================================= 335 */function Kr(n,e,t,r){if(r==null)r=ka(n);else if(r==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(km(n)||Tm(n)){if(r!=="float32"&&r!=="int32")throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${r}.`);return F.backend.createTensorFromGPUData(n,e||t,r)}if(!Tn(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){fn(e);const s=H(e),a=H(t);N(s===a,()=>`Based on the provided shape, [${e}], the tensor should have ${s} values but has ${a}`);for(let o=0;o<t.length;++o){const i=t[o],c=o===t.length-1?i!==H(e.slice(o)):!0;N(t[o]===e[o]||!c,()=>`Error creating a new Tensor. Inferred shape (${t}) does not match the provided shape (${e}). `)}}return!Tn(n)&&!Array.isArray(n)&&(n=[n]),e=e||t,n=r!=="string"?Mu(n,r):Cs(n,[],!0),F.makeTensor(n,e,r)}/** 336 * @license 337 * Copyright 2018 Google LLC. All Rights Reserved. 338 * Licensed under the Apache License, Version 2.0 (the "License"); 339 * you may not use this file except in compliance with the License. 340 * You may obtain a copy of the License at 341 * 342 * http://www.apache.org/licenses/LICENSE-2.0 343 * 344 * Unless required by applicable law or agreed to in writing, software 345 * distributed under the License is distributed on an "AS IS" BASIS, 346 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 347 * See the License for the specific language governing permissions and 348 * limitations under the License. 349 * ============================================================================= 350 */function zn(n,e,t){const r=qr(n,t);return Kr(n,e,r,t)}/** 351 * @license 352 * Copyright 2018 Google LLC. All Rights Reserved. 353 * Licensed under the Apache License, Version 2.0 (the "License"); 354 * you may not use this file except in compliance with the License. 355 * You may obtain a copy of the License at 356 * 357 * http://www.apache.org/licenses/LICENSE-2.0 358 * 359 * Unless required by applicable law or agreed to in writing, software 360 * distributed under the License is distributed on an "AS IS" BASIS, 361 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 362 * See the License for the specific language governing permissions and 363 * limitations under the License. 364 * ============================================================================= 365 */const _s={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class Xn{static join(e){return new Xn(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,e==null||(e instanceof Array||(e=[e]),e=e.map(r=>Tn(r)?r.buffer:r),e.length===0))return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let r=0;r<e.length;r++){const s=e[r];r!==e.length-1&&s.byteLength!==this.bufferUniformSize&&(this.bufferUniformSize=void 0);const a=t+s.byteLength;this.shards.push({buffer:s,start:t,end:a}),t=a}this.shards.length===0&&(this.byteLength=0),this.byteLength=this.shards[this.shards.length-1].end}slice(e=0,t=this.byteLength){if(this.shards.length===0)return new ArrayBuffer(0);if(e=isNaN(Number(e))?0:e,t=isNaN(Number(t))?0:t,e=Math.max(0,e),t=Math.min(this.byteLength,t),t<=e)return new ArrayBuffer(0);const r=this.findShardForByte(e);if(r===-1)throw new Error(`Could not find start shard for byte ${e}`);const s=t-e,a=new ArrayBuffer(s),o=new Uint8Array(a);let i=0;for(let c=r;c<this.shards.length;c++){const l=this.shards[c],d=e+i-l.start,p=i,m=Math.min(t,l.end
vendor: 4,422 bytes, lines 365-395
365)-l.start,g=new Uint8Array(l.buffer,d,m-d);if(o.set(g,p),i+=g.length,t<l.end)break}return a}findShardForByte(e){if(this.shards.length===0||e<0||e>=this.byteLength)return-1;if(this.bufferUniformSize!=null)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(s){return e<s.start?-1:e>=s.end?1:0}if(t(this.shards[this.previousShardIndex])===0)return this.previousShardIndex;const r=ww(this.shards,t);return r===-1?-1:(this.previousShardIndex=r,this.previousShardIndex)}}function ww(n,e){let t=0,r=n.length;for(;t<=r;){const s=Math.floor((r-t)/2)+t,a=e(n[s]);if(a===0)return s;a<0?r=s:t=s+1}return-1}/** 366 * @license 367 * Copyright 2018 Google LLC. All Rights Reserved. 368 * Licensed under the Apache License, Version 2.0 (the "License"); 369 * you may not use this file except in compliance with the License. 370 * You may obtain a copy of the License at 371 * 372 * http://www.apache.org/licenses/LICENSE-2.0 373 * 374 * Unless required by applicable law or agreed to in writing, software 375 * distributed under the License is distributed on an "AS IS" BASIS, 376 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 377 * See the License for the specific language governing permissions and 378 * limitations under the License. 379 * ============================================================================= 380 */function fr(){return F}function Ne(n,e){return F.tidy(n,e)}function nt(n){Em(n).forEach(t=>t.dispose())}function rr(n){return F.keep(n)}function n6(n){return F.setBackend(n)}function r6(){return F.ready()}function vw(){return F.backendName}function Lm(n,e,t=1){return F.registerBackend(n,e,t)}function Iw(){return F.backend}/** 381 * @license 382 * Copyright 2018 Google LLC. All Rights Reserved. 383 * Licensed under the Apache License, Version 2.0 (the "License"); 384 * you may not use this file except in compliance with the License. 385 * You may obtain a copy of the License at 386 * 387 * http://www.apache.org/licenses/LICENSE-2.0 388 * 389 * Unless required by applicable law or agreed to in writing, software 390 * distributed under the License is distributed on an "AS IS" BASIS, 391 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 392 * See the License for the specific language governing permissions and 393 * limitations under the License. 394 * ============================================================================= 395 */const Gr=4;async function $w(n,e){const t=[],r=[],s=Array.isArray(n)?n.map(o=>o.name):Object.keys(n);for(let o=0;o<s.length;++o){const i=s[o],c=Array.isArray(n)?n[o].tensor:n[i];if(c.dtype!=="float32"&&c.dtype!=="int32"&&c.dtype!=="bool"&&c.dtype!=="string"&&c.dtype!=="complex64")throw new Error(`Unsupported dtype in weight '${i}': ${c.dtype}`);const l={name:i,shape:c.shape,dtype:c.dtype};if(c.dtype==="string"){const u=new Promise(async d=>{const p=await c.bytes(),h=p.reduce((y,b)=>y+b.length,0)+Gr*p.length,m=new Uint8Array(h);let g=0;for(let y=0;y<p.length;y++){const b=p[y],v=new Uint8Array(new Uint32Array([b.length]).buffer);m.set(v,g),g+=Gr,m.set(b,g),g+=b.length}d(m)});r.push(u)}else r.push(c.data());e!=null&&(l.group=e),t.push(l)}const a=await Promise.all(r);return{data:_w(a),specs:t}}function Mm(n,e){const t=new Xn(n),r={};let s=0;for(const a of e){const o=Sw(a,(i,c)=>t.slice(s+i,s+c));r[a.name]=Bm(a,t.slice(s,s+o)),s+=o}return r}function Sw(n,e){const t=H(n.shape);let r;if("quantization"in n){const s=n.quantization;r=_s[s.dtype]}else if(n.dtype==="string"){let s=0;for(let a=0;a<t;a++)s+=Gr+new Uint32Array(e(s,s+Gr))[0];return s}else r=_s[n.dtype];return t*r}async function Cw(n,e){const t=H(n.shape);let r;if("quantization"in n){const s=n.quantization;r=_s[s.dtype]}else if(n.dtype==="string"){let s=0;for(let a=0;a<t;a++)s+=Gr+new Uint32Array(await e(s,s+Gr))[0];return s}else r=_s[n.dtype];return t*r}function Bm(n,e){const t=n.name,r=n.dtype,s=n.shape,a=H(s);let o,i=0;if("quantization"in n){const c=n.quantization;if(c.dtype==="uint8"||c.dtype==="uint16"){if(!("min"in c&&"scale"in c))throw new Error(`Weight ${n.name} with quantization ${c.dtype} doesn't have corresponding metadata min and scale.`)}else if(c.dtype==="float16"){if(r!=="float32")throw new Error(`Weight ${n.name} is quantized with ${c.dtype} which only supports weights of type float32 not ${r}.`)}else throw new Error(`Weight ${n.name} has unknown quantization dtype ${c.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);
395const l=_s[c.dtype],u=c.dtype==="uint8"?new Uint8Array(e):new Uint16Array(e);if(r==="float32")if(c.dtype==="uint8"||c.dtype==="uint16"){o=new Float32Array(u.length);for(let d=0;d<u.length;d++){const p=u[d];o[d]=p*c.scale+c.min}}else if(c.dtype==="float16")o=Dw()(u);else throw new Error(`Unsupported quantization type ${c.dtype} for weight type float32.`);else if(r==="int32"){if(c.dtype!=="uint8"&&c.dtype!=="uint16")throw new Error(`Unsupported quantization type ${c.dtype} for weight type int32.`);o=new Int32Array(u.length);for(let d=0;d<u.length;d++){const p=u[d];o[d]=Math.round(p*c.scale+c.min)}}else throw new Error(`Unsupported dtype in weight '${t}': ${r}`);i+=a*l}else if(r==="string"){const c=H(n.shape);o=[];for(let l=0;l<c;l++){const u=new Uint32Array(e.slice(i,i+Gr))[0];i+=Gr;const d=new Uint8Array(e.slice(i,i+u));o.push(d),i+=u}}else{const c=_s[r];if(r==="float32")o=new Float32Array(e);else if(r==="int32")o=new Int32Array(e);else if(r==="bool")o=new Uint8Array(e);else if(r==="complex64"){o=new Float32Array(e);const l=new Float32Array(o.length/2),u=new Float32Array(o.length/2);for(let m=0;m<l.length;m++)l[m]=o[m*2],u[m]=o[m*2+1];const d=zn(l,s,"float32"),p=zn(u,s,"float32"),h=zr(d,p);return d.dispose(),p.dispose(),h}else throw new Error(`Unsupported dtype in weight '${t}': ${r}`);i+=a*c}return zn(o,s,r)}async function Ph(n,e,t){let r=new Uint8Array(e);for(;r.byteLength<t;){const{done:s,value:a}=await n.read();if(s&&a==null){const i=t-r.byteLength;throw new Error(`Reader is done but ${i} bytes are still expected`)}const o=new Uint8Array(r.length+a.byteLength);o.set(r,0),o.set(new Uint8Array(a),r.length),r=o}return r.buffer}async function Vm(n,e){const t={},r=n.getReader();let s=new ArrayBuffer(0);for(const a of e){const o=await Cw(a,async(l,u)=>(s=await Ph(r,s,u),s.slice(l,u)));s=await Ph(r,s,o);const i=s.slice(0,o);s=s.slice(o);const c=Bm(a,i);if(t[a.name]=c,vw()==="webgpu"){const l=Iw();"uploadToGPU"in l&&H(c.shape)>=U().get("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD")&&l.uploadToGPU(c.dataId)}}return t}function _w(n){if(n===null)throw new Error(`Invalid input value: ${JSON.stringify(n)}`);let e=0;const t=[];n.forEach(a=>{if(e+=a.byteLength,t.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});const r=new Uint8Array(e);let s=0;return t.forEach(a=>{r.set(new Uint8Array(a.buffer),s),s+=a.byteLength}),r.buffer}const lp=typeof Buffer<"u"&&(typeof Blob>"u"||typeof atob>"u"||typeof btoa>"u");function Lh(n){return lp?Buffer.byteLength(n,"utf8"):new Blob([n]).size}function Nw(n){if(lp)return Buffer.from(n).toString("base64");const e=new Uint8Array(n);let t="";for(let r=0,s=e.length;r<s;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Tw(n){if(lp){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 kw(n){return Xn.join(n)}function Mh(n){const e="/";for(n=n.trim();n.endsWith(e);)n=n.slice(0,n.length-1);const t=n.split(e);return t[t.length-1]}function Wm(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.initializerSignature!=null&&(t.initializerSignature=n.initializerSignature),n.trainingConfig!=null&&(t.trainingConfig=n.trainingConfig),t}function Um(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),n.initializerSignature!=null&&(r.initializerSignature=n.initializerSignature),r}async function dp(n,e){let t,r;return n.weightsManifest!=null&&([t,r]=await e(n.weightsManifest)),Um(n,t,r)}function No(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:Lh(JSON.stringify(n.modelTopology)),weightSpecsBytes:n.weightSpecs==null?0:Lh(JSON.stringify(n.weightSpecs)),weightDataBytes:n.weightData==null?0:new Xn(n.weightData).byteLength}}function Uc(n){const e=[];for(const t of n)e.push(...t.weights);return e}function Ew(){const n=t=>{let r=t<<13,s=0;for(;(r&8388608)===0;)s-=8388608,r<<=1;return r&=-8388609,s+=947912704,r|s},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 Rw(){const n=new Uint32Array(64);
vendor: 10,367 bytes, lines 395-440
395n[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 Aw(){const n=new Uint32Array(64);for(let e=0;e<64;e++)n[e]=1024;return n[0]=n[32]=0,n}function Dw(){const n=Ew(),e=Rw(),t=Aw();return r=>{const s=new ArrayBuffer(4*r.length),a=new Uint32Array(s);for(let o=0;o<r.length;o++){const i=r[o],c=n[t[i>>10]+(i&1023)]+e[i>>10];a[o]=c}return new Float32Array(s)}}/** 396 * @license 397 * Copyright 2018 Google LLC. All Rights Reserved. 398 * Licensed under the Apache License, Version 2.0 (the "License"); 399 * you may not use this file except in compliance with the License. 400 * You may obtain a copy of the License at 401 * 402 * http://www.apache.org/licenses/LICENSE-2.0 403 * 404 * Unless required by applicable law or agreed to in writing, software 405 * distributed under the License is distributed on an "AS IS" BASIS, 406 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 407 * See the License for the specific language governing permissions and 408 * limitations under the License. 409 * ============================================================================= 410 */class tt{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return tt.instance==null&&(tt.instance=new tt),tt.instance}static registerSaveRouter(e){tt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){tt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return tt.getHandlers(e,"save")}static getLoadHandlers(e,t){return tt.getHandlers(e,"load",t)}static getHandlers(e,t,r){const s=[];return(t==="load"?tt.getInstance().loadRouters:tt.getInstance().saveRouters).forEach(o=>{const i=o(e,r);i!==null&&s.push(i)}),s}}const Ow=n=>tt.registerSaveRouter(n),Fw=n=>tt.registerLoadRouter(n),Pw=n=>tt.getSaveHandlers(n),Lw=(n,e)=>tt.getLoadHandlers(n,e);/** 411 * @license 412 * Copyright 2018 Google LLC. All Rights Reserved. 413 * Licensed under the Apache License, Version 2.0 (the "License"); 414 * you may not use this file except in compliance with the License. 415 * You may obtain a copy of the License at 416 * 417 * http://www.apache.org/licenses/LICENSE-2.0 418 * 419 * Unless required by applicable law or agreed to in writing, software 420 * distributed under the License is distributed on an "AS IS" BASIS, 421 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 422 * See the License for the specific language governing permissions and 423 * limitations under the License. 424 * ============================================================================= 425 */const zc="tensorflowjs",Gc=1,xs="models_store",Pr="model_info_store";function zm(){if(!U().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 Hc(n){const e=n.result;e.createObjectStore(xs,{keyPath:"modelPath"}),e.createObjectStore(Pr,{keyPath:"modelPath"})}class Ns{constructor(e){if(this.indexedDB=zm(),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,s)=>{const a=this.indexedDB.open(zc,Gc);a.onupgradeneeded=()=>Hc(a),a.onsuccess=()=>{const o=a.result;if(t==null){const i=o.transaction(xs,"readonly"),l=i.objectStore(xs).get(this.modelPath);l.onsuccess=()=>{if(l.result==null)return o.close(),s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));r(l.result.modelArtifacts)},l.onerror=u=>(o.close(),s(l.error)),i.oncomplete=()=>o.close()}else{t.weightData=Xn.join(t.weightData);const i=No(t),c=o.transaction(Pr,"readwrite");let l=c.objectStore(Pr),u;try{u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i})}catch(p){return s(p)}let d;u.onsuccess=()=>{d=o.transaction(xs,"readwrite");const p=d.objectStore(xs);let h;try{h=p.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i})}catch(m){return s(m)}h.onsuccess=()=>r({modelArtifactsInfo:i}),h.onerror=m=>{l=c.objectStore(Pr);const g=l.delete(this.modelPath);g.onsuccess=()=>(o.close(),s(h.error)),g.onerror=y=>(o.close(),s(h.error))}},u.onerror=p=>(o.close(),s(u.error)),c.oncomplete=()=>{d==null?o.close():d.oncomplete=()=>o.close()}}},a.onerror=o=>s(a.error)})}}Ns.URL_SCHEME="indexeddb://";const Gm=n=>U().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(Ns.URL_SCHEME)?Mw(n.slice(Ns.URL_SCHEME.length)):null;tt.registerSaveRouter(Gm);tt.registerLoadRouter(Gm);function Mw(n){return new Ns(n)}function Bw(n){return n.startsWith(Ns.URL_SCHEME)?n.slice(Ns.URL_SCHEME.length):n}class Vw{constructor(){this.indexedDB=zm()}async listModels(){return new Promise((e,t)=>{const r=this.indexedDB.open(zc,Gc);r.onupgradeneeded=()=>Hc(r),r.onsuccess=()=>{const s=r.result,a=s.transaction(Pr,"readonly"),i=a.objectStore(Pr).getAll();i.onsuccess=()=>{const c={};for(const l of i.result)c[l.modelPath]=l.modelArtifactsInfo;e(c)},i.onerror=c=>(s.close(),t(i.error)),a.oncomplete=()=>s.close()},r.onerror=s=>t(r.error)})}async removeModel(e){return e=Bw(e),new Promise((t,r)=>{const s=this.indexedDB.open(zc,Gc);s.onupgradeneeded=()=>Hc(s),s.onsuccess=()=>{const a=s.result,o=a.transaction(Pr,"readwrite"),i=o.objectStore(Pr),c=i.get(e);let l;c.onsuccess=()=>{if(c.result==null)return a.close(),r(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const u=i.delete(e),d=()=>{l=a.transaction(xs,"readwrite");const h=l.objectStore(xs).delete(e);h.onsuccess=()=>t(c.result.modelArtifactsInfo),h.onerror=m=>r(c.error)};u.onsuccess=d,u.onerror=p=>(d(),a.close(),r(c.error))}},c.onerror=u=>(a.close(),r(c.error)),o.oncomplete=()=>{l==null?a.close():l.oncomplete=()=>a.close()}},s.onerror=a=>r(s.error)})}}/** 426 * @license 427 * Copyright 2018 Google LLC. All Rights Reserved. 428 * Licensed under the Apache License, Version 2.0 (the "License"); 429 * you may not use this file except in compliance with the License. 430 * You may obtain a copy of the License at 431 * 432 * http://www.apache.org/licenses/LICENSE-2.0 433 * 434 * Unless required by applicable law or agreed to in writing, software 435 * distributed under the License is distributed on an "AS IS" BASIS, 436 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 437 * See the License for the specific language governing permissions and 438 * limitations under the License. 439 * ============================================================================= 440 */const yr="/",da="tensorflowjs_models",Hm="info",Ww="model_topology",Uw="weight_specs",zw="weight_data",Gw="model_metadata";function jm(n){return{info:[da,n,Hm].join(yr),topology:[da,n,Ww].join(yr),weightSpecs:[da,n,Uw].join(yr),weightData:[da,n,zw].join(yr),modelMetadata:[da,n,Gw].join(yr)}}function qm(n){for(const e of Object.values(n))window.localStorage.removeItem(e)}function Hw(n){const e=n.split(yr);if(e.length<3)throw new Error(`Invalid key format: ${n}`);return e.slice(1,e.length-1).join(yr)}function jw(n){return n.startsWith(Ts.URL_SCHEME)?n.slice(Ts.URL_SCHEME.length):n}class Ts{constructor(e){if(!U().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=jm(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),s=No(e),a=Xn.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(s)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,Nw(a));const o={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,initializerSignature:e.initializerSignature!=null?e.initializerSignature:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(o)),{modelArtifactsInfo:s}}catch{throw qm(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=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.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 s=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(s==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=s;const a=this.LS.getItem(this.keys.modelMetadata);if(a!=null){const i=JSON.parse(a);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.initializerSignature!=null&&(t.initializerSignature=i.initializerSignature),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=Tw(o),t}}Ts.URL_SCHEME="localstorage://";const Km=n=>
440U().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(Ts.URL_SCHEME)?qw(n.slice(Ts.URL_SCHEME.length)):null;tt.registerSaveRouter(Km);tt.registerLoadRouter(Km);function qw(n){return new Ts(n)}class Kw{constructor(){N(U().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),N(typeof window>"u"||typeof window.localStorage<"u",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},t=da+yr,r=yr+Hm;for(let s=0;s<this.LS.length;++s){const a=this.LS.key(s);if(a.startsWith(t)&&a.endsWith(r)){const o=Hw(a);e[o]=JSON.parse(this.LS.getItem(a))}}return e}async removeModel(e){e=jw(e);const t=jm(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 qm(t),r}}/** 441 * @license 442 * Copyright 2018 Google LLC. All Rights Reserved. 443 * Licensed under the Apache License, Version 2.0 (the "License"); 444 * you may not use this file except in compliance with the License. 445 * You may obtain a copy of the License at 446 * 447 * http://www.apache.org/licenses/LICENSE-2.0 448 * 449 * Unless required by applicable law or agreed to in writing, software 450 * distributed under the License is distributed on an "AS IS" BASIS, 451 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 452 * See the License for the specific language governing permissions and 453 * limitations under the License. 454 * ============================================================================= 455 */const ga="://";class Pt{constructor(){this.managers={}}static getInstance(){return Pt.instance==null&&(Pt.instance=new Pt),Pt.instance}static registerManager(e,t){N(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(ga)&&(e=e.slice(0,e.indexOf(ga))),N(e.length>0,()=>"scheme must not be an empty string.");const r=Pt.getInstance();N(r.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),r.managers[e]=t}static getManager(e){const t=Pt.getInstance().managers[e];if(t==null)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(Pt.getInstance().managers)}}function hi(n){if(n.indexOf(ga)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Pt.getSchemes().join(",")}`);return{scheme:n.split(ga)[0],path:n.split(ga)[1]}}async function Xm(n,e,t=!1){N(n!==e,()=>`Old path and new path are the same: '${n}'`);const r=tt.getLoadHandlers(n);N(r.length>0,()=>`Copying failed because no load handler is found for source URL ${n}.`),N(r.length<2,()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${n}.`);const s=r[0],a=tt.getSaveHandlers(e);N(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${e}.`),N(a.length<2,()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${e}.`);const o=a[0],i=hi(n).scheme,c=hi(n).path,l=i===hi(n).scheme,u=await s.load();t&&l&&await Pt.getManager(i).removeModel(c);const d=await o.save(u);return t&&!l&&await Pt.getManager(i).removeModel(c),d.modelArtifactsInfo}async function Xw(){const n=Pt.getSchemes(),e={};for(const t of n){const r=await Pt.getManager(t).listModels();for(const s in r){const a=t+ga+s;e[a]=r[s]}}return e}async function Yw(n){const e=hi(n);return Pt.getManager(e.scheme).removeModel(e.path)}async function Qw(n,e){return Xm(n,e,!1)}async function Zw(n,e){return Xm(n,e,!0)}/** 456 * @license 457 * Copyright 2019 Google LLC. All Rights Reserved. 458 * Licensed under the Apache License, Version 2.0 (the "License"); 459 * you may not use this file except in compliance with the License. 460 * You may obtain a copy of the License at 461 * 462 * http://www.apache.org/licenses/LICENSE-2.0 463 * 464 * Unless required by applicable law or agreed to in writing, software 465 * distributed under the License is distributed on an "AS IS" BASIS, 466 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 467 * See the License for the specific language governing permissions and 468 * limitations under the License. 469 * ============================================================================= 470 */class Jw{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(typeof window>"u"||!U().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 s=this.functionRefs[r.data.index];s(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))}isTypedArray(e){return xm(e)}}
vendor: 4,371 bytes, lines 470-533
470if(U().get("IS_BROWSER")){U().setPlatform("browser",new Jw);try{Pt.registerManager(Ts.URL_SCHEME,new Kw)}catch{}try{Pt.registerManager(Ns.URL_SCHEME,new Vw)}catch{}}/** 471 * @license 472 * Copyright 2019 Google LLC. All Rights Reserved. 473 * Licensed under the Apache License, Version 2.0 (the "License"); 474 * you may not use this file except in compliance with the License. 475 * You may obtain a copy of the License at 476 * 477 * http://www.apache.org/licenses/LICENSE-2.0 478 * 479 * Unless required by applicable law or agreed to in writing, software 480 * distributed under the License is distributed on an "AS IS" BASIS, 481 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 482 * See the License for the specific language governing permissions and 483 * limitations under the License. 484 * ============================================================================= 485 */const e1={importFetch:()=>require("node-fetch")};let pc;class t1{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return U().global.fetch!=null?U().global.fetch(e,t):(pc==null&&(pc=e1.importFetch()),pc(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)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}U().get("IS_NODE")&&!U().get("IS_BROWSER")&&U().setPlatform("node",new t1);/** 486 * @license 487 * Copyright 2020 Google Inc. All Rights Reserved. 488 * Licensed under the Apache License, Version 2.0 (the "License"); 489 * you may not use this file except in compliance with the License. 490 * You may obtain a copy of the License at 491 * 492 * http://www.apache.org/licenses/LICENSE-2.0 493 * 494 * Unless required by applicable law or agreed to in writing, software 495 * distributed under the License is distributed on an "AS IS" BASIS, 496 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 497 * See the License for the specific language governing permissions and 498 * limitations under the License. 499 * ============================================================================= 500 */function at(n,e="float32",t){return e=e||"float32",fn(n),new $a(n,e,t)}/** 501 * @license 502 * Copyright 2020 Google Inc. All Rights Reserved. 503 * Licensed under the Apache License, Version 2.0 (the "License"); 504 * you may not use this file except in compliance with the License. 505 * You may obtain a copy of the License at 506 * 507 * http://www.apache.org/licenses/LICENSE-2.0 508 * 509 * Unless required by applicable law or agreed to in writing, software 510 * distributed under the License is distributed on an "AS IS" BASIS, 511 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 512 * See the License for the specific language governing permissions and 513 * limitations under the License. 514 * ============================================================================= 515 */function n1(n,e){const t=_(n,"x","cast");if(!F0(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},s={dtype:e};return F.runKernel(Gi,r,s)}const rt=D({cast_:n1});/** 516 * @license 517 * Copyright 2020 Google LLC. All Rights Reserved. 518 * Licensed under the Apache License, Version 2.0 (the "License"); 519 * you may not use this file except in compliance with the License. 520 * You may obtain a copy of the License at 521 * 522 * http://www.apache.org/licenses/LICENSE-2.0 523 * 524 * Unless required by applicable law or agreed to in writing, software 525 * distributed under the License is distributed on an "AS IS" BASIS, 526 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 527 * See the License for the specific language governing permissions and 528 * limitations under the License. 529 * ============================================================================= 530 */function r1(n){const t={x:_(n,"x","clone","string_or_numeric")};return F.runKernel(au,t)}const Br=D({clone_:r1});/** 531 * @license 532 * Copyright 2020 Google Inc. All Rights Reserved. 533 * Licensed under the Apache License, Version 2.0 (the "License");
534 * you may not use this file except in compliance with the License. 535 * You may obtain a copy of the License at 536 * 537 * http://www.apache.org/licenses/LICENSE-2.0 538 * 539 * Unless required by applicable law or agreed to in writing, software 540 * distributed under the License is distributed on an "AS IS" BASIS, 541 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 542 * See the License for the specific language governing permissions and 543 * limitations under the License. 544 * ============================================================================= 545 */function Ym(n,e=!1){console.log(n.toString(e))}/** 546 * @license 547 * Copyright 2020 Google Inc. All Rights Reserved. 548 * Licensed under the Apache License, Version 2.0 (the "License"); 549 * you may not use this file except in compliance with the License. 550 * You may obtain a copy of the License at 551 * 552 * http://www.apache.org/licenses/LICENSE-2.0 553 * 554 * Unless required by applicable law or agreed to in writing, software 555 * distributed under the License is distributed on an "AS IS" BASIS, 556 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 557 * See the License for the specific language governing permissions and 558 * limitations under the License. 559 * ============================================================================= 560 */Am();const s1={buffer:at,cast:rt,clone:Br,print:Ym};pw(s1);/** 561 * @license 562 * Copyright 2020 Google LLC. All Rights Reserved. 563 * Licensed under the Apache License, Version 2.0 (the "License"); 564 * you may not use this file except in compliance with the License. 565 * You may obtain a copy of the License at 566 * 567 * http://www.apache.org/licenses/LICENSE-2.0 568 * 569 * Unless required by applicable law or agreed to in writing, software 570 * distributed under the License is distributed on an "AS IS" BASIS, 571 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 572 * See the License for the specific language governing permissions and 573 * limitations under the License. 574 * ============================================================================= 575 */function a1(n,e){let t=_(n,"a","add"),r=_(e,"b","add");[t,r]=ut(t,r);const s={a:t,b:r};return F.runKernel(Li,s)}const me=D({add_:a1});/** 576 * @license 577 * Copyright 2020 Google LLC. All Rights Reserved. 578 * Licensed under the Apache License, Version 2.0 (the "License"); 579 * you may not use this file except in compliance with the License. 580 * You may obtain a copy of the License at 581 * 582 * http://www.apache.org/licenses/LICENSE-2.0 583 * 584 * Unless required by applicable law or agreed to in writing, software 585 * distributed under the License is distributed on an "AS IS" BASIS, 586 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 587 * See the License for the specific language governing permissions and 588 * limitations under the License. 589 * ============================================================================= 590 */function o1(n,e){let t=_(n,"a","floorDiv"),r=_(e,"b","floorDiv");[t,r]=ut(t,r);const s={a:t,b:r};return F.runKernel(rd,s)}const Qm=D({floorDiv_:o1});/** 591 * @license 592 * Copyright 2020 Google LLC. All Rights Reserved. 593 * Licensed under the Apache License, Version 2.0 (the "License"); 594 * you may not use this file except in compliance with the License. 595 * You may obtain a copy of the License at 596 * 597 * http://www.apache.org/licenses/LICENSE-2.0 598 * 599 * Unless required by applicable law or agreed to in writing, software 600 * distributed under the License is distributed on an "AS IS" BASIS, 601 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 602 * See the License for the specific language governing permissions and 603 * limitations under the License. 604 * ============================================================================= 605 */function i1(n,e){let t=_(n,"a","div"),r=_(e,"b","div");if([t,r]=ut(t,r),t.dtype==="int32"&&r.dtype==="int32")return Qm(t,r);const s={a:t,b:r},a={};return F.runKernel(ql,s,a)}const Te=D({div_:i1});/** 606 * @license 607 * Copyright 2020 Google LLC. All Rights Reserved. 608 * Licensed under the Apache License, Version 2.0 (the "License");
609 * you may not use this file except in compliance with the License. 610 * You may obtain a copy of the License at 611 * 612 * http://www.apache.org/licenses/LICENSE-2.0 613 * 614 * Unless required by applicable law or agreed to in writing, software 615 * distributed under the License is distributed on an "AS IS" BASIS, 616 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 617 * See the License for the specific language governing permissions and 618 * limitations under the License. 619 * ============================================================================= 620 */function u1(n,e){let t=_(n,"a","mul"),r=_(e,"b","mul");[t,r]=ut(t,r);const s={a:t,b:r};return F.runKernel($d,s)}const Z=D({mul_:u1});/** 621 * @license 622 * Copyright 2018 Google LLC. All Rights Reserved. 623 * Licensed under the Apache License, Version 2.0 (the "License"); 624 * you may not use this file except in compliance with the License. 625 * You may obtain a copy of the License at 626 * 627 * http://www.apache.org/licenses/LICENSE-2.0 628 * 629 * Unless required by applicable law or agreed to in writing, software 630 * distributed under the License is distributed on an "AS IS" BASIS, 631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 632 * See the License for the specific language governing permissions and 633 * limitations under the License. 634 * ============================================================================= 635 */function c1(n){const e=_(n,"x","abs");if(e.dtype==="complex64"){const t={x:e};return F.runKernel(Zf,t)}else{const t={x:e};return F.runKernel(_l,t)}}const ln=D({abs_:c1});/** 636 * @license 637 * Copyright 2018 Google LLC. All Rights Reserved. 638 * Licensed under the Apache License, Version 2.0 (the "License"); 639 * you may not use this file except in compliance with the License. 640 * You may obtain a copy of the License at 641 * 642 * http://www.apache.org/licenses/LICENSE-2.0 643 * 644 * Unless required by applicable law or agreed to in writing, software 645 * distributed under the License is distributed on an "AS IS" BASIS, 646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 647 * See the License for the specific language governing permissions and 648 * limitations under the License. 649 * ============================================================================= 650 */function l1(n){const t={x:_(n,"x","acos")};return F.runKernel(Nl,t)}const d1=D({acos_:l1});/** 651 * @license 652 * Copyright 2018 Google LLC. All Rights Reserved. 653 * Licensed under the Apache License, Version 2.0 (the "License"); 654 * you may not use this file except in compliance with the License. 655 * You may obtain a copy of the License at 656 * 657 * http://www.apache.org/licenses/LICENSE-2.0 658 * 659 * Unless required by applicable law or agreed to in writing, software 660 * distributed under the License is distributed on an "AS IS" BASIS, 661 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 662 * See the License for the specific language governing permissions and 663 * limitations under the License. 664 * ============================================================================= 665 */function p1(n){const t={x:_(n,"x","acosh")};return F.runKernel(Tl,t)}const h1=D({acosh_:p1});/** 666 * @license 667 * Copyright 2020 Google LLC. All Rights Reserved. 668 * Licensed under the Apache License, Version 2.0 (the "License"); 669 * you may not use this file except in compliance with the License. 670 * You may obtain a copy of the License at 671 * 672 * http://www.apache.org/licenses/LICENSE-2.0 673 * 674 * Unless required by applicable law or agreed to in writing, software 675 * distributed under the License is distributed on an "AS IS" BASIS, 676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 677 * See the License for the specific language governing permissions and 678 * limitations under the License. 679 * ============================================================================= 680 */function f1(n){N(Array.isArray(n),()=>"The argument passed to tf.addN() must be a list of tensors"),N(n.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${n.length}`);const e=n.map((s,a)=>_(s,`tensors${a}`,"addN")),t=e[0];e.forEach(s=>{if(s.dtype!==t.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),e.forEach(s=>{if(!st(s.shape,t.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});const r=e;return F.runKernel(Mi,r)}const m1=D({addN_:f1});/** 681 * @license 682 * Copyright 2020 Google LLC. All Rights Reserved. 683 * Licensed under the Apache License, Version 2.0 (the "License");
684 * you may not use this file except in compliance with the License. 685 * You may obtain a copy of the License at 686 * 687 * http://www.apache.org/licenses/LICENSE-2.0 688 * 689 * Unless required by applicable law or agreed to in writing, software 690 * distributed under the License is distributed on an "AS IS" BASIS, 691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 692 * See the License for the specific language governing permissions and 693 * limitations under the License. 694 * ============================================================================= 695 */function g1(n,e=null,t=!1){const s={x:_(n,"x","all","bool")},a={axis:e,keepDims:t};return F.runKernel(Bi,s,a)}const y1=D({all_:g1});/** 696 * @license 697 * Copyright 2020 Google LLC. All Rights Reserved. 698 * Licensed under the Apache License, Version 2.0 (the "License"); 699 * you may not use this file except in compliance with the License. 700 * You may obtain a copy of the License at 701 * 702 * http://www.apache.org/licenses/LICENSE-2.0 703 * 704 * Unless required by applicable law or agreed to in writing, software 705 * distributed under the License is distributed on an "AS IS" BASIS, 706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 707 * See the License for the specific language governing permissions and 708 * limitations under the License. 709 * ============================================================================= 710 */function b1(n,e=null,t=!1){const s={x:_(n,"x","any","bool")},a={axis:e,keepDims:t};return F.runKernel(Vi,s,a)}const x1=D({any_:b1});/** 711 * @license 712 * Copyright 2020 Google Inc. All Rights Reserved. 713 * Licensed under the Apache License, Version 2.0 (the "License"); 714 * you may not use this file except in compliance with the License. 715 * You may obtain a copy of the License at 716 * 717 * http://www.apache.org/licenses/LICENSE-2.0 718 * 719 * Unless required by applicable law or agreed to in writing, software 720 * distributed under the License is distributed on an "AS IS" BASIS, 721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 722 * See the License for the specific language governing permissions and 723 * limitations under the License. 724 * ============================================================================= 725 */function w1(n,e=0){const r={x:_(n,"x","argMax")},s={axis:e};return F.runKernel(kl,r,s)}const v1=D({argMax_:w1});/** 726 * @license 727 * Copyright 2020 Google Inc. All Rights Reserved. 728 * Licensed under the Apache License, Version 2.0 (the "License"); 729 * you may not use this file except in compliance with the License. 730 * You may obtain a copy of the License at 731 * 732 * http://www.apache.org/licenses/LICENSE-2.0 733 * 734 * Unless required by applicable law or agreed to in writing, software 735 * distributed under the License is distributed on an "AS IS" BASIS, 736 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 737 * See the License for the specific language governing permissions and 738 * limitations under the License. 739 * ============================================================================= 740 */function I1(n,e=0){const r={x:_(n,"x","argMin")},s={axis:e};return F.runKernel(El,r,s)}const $1=D({argMin_:I1});/** 741 * @license 742 * Copyright 2018 Google LLC. All Rights Reserved. 743 * Licensed under the Apache License, Version 2.0 (the "License"); 744 * you may not use this file except in compliance with the License. 745 * You may obtain a copy of the License at 746 * 747 * http://www.apache.org/licenses/LICENSE-2.0 748 * 749 * Unless required by applicable law or agreed to in writing, software 750 * distributed under the License is distributed on an "AS IS" BASIS, 751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 752 * See the License for the specific language governing permissions and 753 * limitations under the License. 754 * ============================================================================= 755 */function S1(n){const t={x:_(n,"x","asin")};return F.runKernel(Rl,t)}const C1=D({asin_:S1});/** 756 * @license 757 * Copyright 2018 Google LLC. All Rights Reserved. 758 * Licensed under the Apache License, Version 2.0 (the "License");
759 * you may not use this file except in compliance with the License. 760 * You may obtain a copy of the License at 761 * 762 * http://www.apache.org/licenses/LICENSE-2.0 763 * 764 * Unless required by applicable law or agreed to in writing, software 765 * distributed under the License is distributed on an "AS IS" BASIS, 766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 767 * See the License for the specific language governing permissions and 768 * limitations under the License. 769 * ============================================================================= 770 */function _1(n){const t={x:_(n,"x","asinh")};return F.runKernel(Al,t)}const N1=D({asinh_:_1});/** 771 * @license 772 * Copyright 2018 Google LLC. All Rights Reserved. 773 * Licensed under the Apache License, Version 2.0 (the "License"); 774 * you may not use this file except in compliance with the License. 775 * You may obtain a copy of the License at 776 * 777 * http://www.apache.org/licenses/LICENSE-2.0 778 * 779 * Unless required by applicable law or agreed to in writing, software 780 * distributed under the License is distributed on an "AS IS" BASIS, 781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 782 * See the License for the specific language governing permissions and 783 * limitations under the License. 784 * ============================================================================= 785 */function T1(n){const t={x:_(n,"x","atan")};return F.runKernel(Dl,t)}const k1=D({atan_:T1});/** 786 * @license 787 * Copyright 2020 Google LLC. All Rights Reserved. 788 * Licensed under the Apache License, Version 2.0 (the "License"); 789 * you may not use this file except in compliance with the License. 790 * You may obtain a copy of the License at 791 * 792 * http://www.apache.org/licenses/LICENSE-2.0 793 * 794 * Unless required by applicable law or agreed to in writing, software 795 * distributed under the License is distributed on an "AS IS" BASIS, 796 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 797 * See the License for the specific language governing permissions and 798 * limitations under the License. 799 * ============================================================================= 800 */function E1(n,e){let t=_(n,"a","atan2"),r=_(e,"b","atan2");[t,r]=ut(t,r);const s={a:t,b:r};return F.runKernel(Fl,s)}const R1=D({atan2_:E1});/** 801 * @license 802 * Copyright 2018 Google LLC. All Rights Reserved. 803 * Licensed under the Apache License, Version 2.0 (the "License"); 804 * you may not use this file except in compliance with the License. 805 * You may obtain a copy of the License at 806 * 807 * http://www.apache.org/licenses/LICENSE-2.0 808 * 809 * Unless required by applicable law or agreed to in writing, software 810 * distributed under the License is distributed on an "AS IS" BASIS, 811 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 812 * See the License for the specific language governing permissions and 813 * limitations under the License. 814 * ============================================================================= 815 */function A1(n){const t={x:_(n,"x","atanh")};return F.runKernel(Ol,t)}const D1=D({atanh_:A1});/** 816 * @license 817 * Copyright 2020 Google LLC. All Rights Reserved. 818 * Licensed under the Apache License, Version 2.0 (the "License"); 819 * you may not use this file except in compliance with the License. 820 * You may obtain a copy of the License at 821 * 822 * http://www.apache.org/licenses/LICENSE-2.0 823 * 824 * Unless required by applicable law or agreed to in writing, software 825 * distributed under the License is distributed on an "AS IS" BASIS, 826 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 827 * See the License for the specific language governing permissions and 828 * limitations under the License. 829 * ============================================================================= 830 */function To(n,e,t,r,s="NHWC",a){const o=n[3],i=[...e,o],c=Yr(s);return $t(n,i,t,a,r,null,null,c)}function kn(n,e,t,r,s,a,o="channelsLast"){const[i,c]=po(e);let l;if(o==="channelsLast")l=[i,c,n[3],n[3]];else if(o==="channelsFirst")l=[i,c,n[1],n[1]];else throw new Error(`Unknown dataFormat ${o}`);return $t(n,l,t,r,s,a,!1,o)}function Ir(n,e,t,r,s,a,o="NDHWC"){const[i,c,l]=jc(e);let u,d;if(o==="NDHWC")d="channelsLast",u=[i,c,l,n[4],n[4]];else if(o==="NCDHW")d="channelsFirst",u=[i,c,l,n[1],n[1]];else throw new Error(`Unknown dataFormat ${o}`);return Xr(n,u,t,r,s,!1,d,a)}function $t(n,e,t,r,s,a,o=!1,i="channelsLast"){let[c,l,u,d]=[-1,-1,-1,-1];if(i==="channelsLast")[c,l,u,d]=n;else if(i==="channelsFirst")[c,d,l,u]=n;else throw new Error(`Unknown dataFormat ${i}`);const[p,h,,m]=e,[g,y]=po(t),[b,v]=po(r),$=ya(p,b),S=ya(h,v),{padInfo:T,outHeight:O,outWidth:L}=P1(s,l,u,g,y,$,S,a,i),M=o?m*d:m;let W;return i==="channelsFirst"?W=[c,M,O,L]:i==="channelsLast"&&(W=[c,O,L,M]),{batchSize:c,dataFormat:i,inHeight:l,inWidth:u,inChannels:d,outHeight:O,outWidth:L,outChannels:M,padInfo:T,strideHeight:g,strideWidth:y,filterHeight:p,filterWidth:h,effectiveFilterHeight:$,effectiveFilterWidth:S,dilationHeight:b,dilationWidth:v,inShape:n,outShape:W,filterShape:e}}function Xr(n,e,t,r,s,a=!1,o="channelsLast",i){let[c,l,u,d,p]=[-1,-1,-1,-1,-1];if(o==="channelsLast")[c,l,u,d,p]=n;else if(o==="channelsFirst")[c,p,l,u,d]=n;else throw new Error(`Unknown dataFormat ${o}`);const[h,m,g,,y]=e,[b,v,$]=jc(t),[S,T,O]=jc(r),L=ya(h,S),M=ya(m,T),W=ya(g,O),{padInfo:V,outDepth:G,outHeight:K,outWidth:J}=L1(s,l,u,d,b,v,$,L,M,W,i),ue=a?y*p:y;let se;return o==="channelsFirst"?se=[c,ue,G,K,J]:o==="channelsLast"&&(se=[c,G,K,J,ue]),{batchSize:c,dataFormat:o,inDepth:l,inHeight:u,inWidth:d,inChannels:p,outDepth:G,outHeight:K,outWidth:J,outChannels:ue,padInfo:V,strideDepth:b,strideHeight:v,strideWidth:$,filterDepth:h,filterHeight:m,filterWidth:g,effectiveFilterDepth:L,effectiveFilterHeight:M,effectiveFilterWidth:W,dilationDepth:S,dilationHeight:T,dilationWidth:O,inShape:n,outShape:se,filterShape:e}}function O1(n,e,t,r,s){r==null&&(r=pp(n,e,t));const a=n[0],o=n[1],i=ho((a-e+2*r)/t+1,s),c=ho((o-e+2*r)/t+1,s);return[i,c]}function F1(n,e,t,r,s,a){s==null&&(s=pp(n,e[0],r[0]));const o=[0,0,0,t];for(let i=0;i<3;i++)n[i]+2*s>=e[i]&&(o[i]=ho((n[i]-e[i]+2*s)/r[i]+1,a));return o}function pp(n,e,t,r=1){const s=ya(e,r);return Math.floor((n[0]*(t-1)-t+s)/2)}function po(n){return typeof n=="number"?[n,n,n]:n.length===2?[n[0],n[1],1]:n}function jc(n){return typeof n=="number"?[n,n,n]:n}function ya(n,e){return e<=1?n:n+(n-1)*(e-1)}function P1(n,e,t,r,s,a,o,i,c){let l,u,d;
vendor: 4,283 bytes, lines 830-860
830if(typeof n=="number"){l={top:n,bottom:n,left:n,right:n,type:n===0?"VALID":"NUMBER"};const h=O1([e,t],a,r,n,i);u=h[0],d=h[1]}else if(n==="same"){u=Math.ceil(e/r),d=Math.ceil(t/s);const p=Math.max(0,(u-1)*r+a-e),h=Math.max(0,(d-1)*s+o-t),m=Math.floor(p/2),g=p-m,y=Math.floor(h/2),b=h-y;l={top:m,bottom:g,left:y,right:b,type:"SAME"}}else if(n==="valid")l={top:0,bottom:0,left:0,right:0,type:"VALID"},u=Math.ceil((e-a+1)/r),d=Math.ceil((t-o+1)/s);else if(typeof n=="object"){const p=c==="channelsLast"?n[1][0]:n[2][0],h=c==="channelsLast"?n[1][1]:n[2][1],m=c==="channelsLast"?n[2][0]:n[3][0],g=c==="channelsLast"?n[2][1]:n[3][1];l={top:p,bottom:h,left:m,right:g,type:p===0&&h===0&&m===0&&g===0?"VALID":"EXPLICIT"},u=ho((e-a+p+h)/r+1,i),d=ho((t-o+m+g)/s+1,i)}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:l,outHeight:u,outWidth:d}}function L1(n,e,t,r,s,a,o,i,c,l,u){let d,p,h,m;if(n==="valid"&&(n=0),typeof n=="number"){d={top:n,bottom:n,left:n,right:n,front:n,back:n,type:n===0?"VALID":"NUMBER"};const y=F1([e,t,r,1],[i,c,l],1,[s,a,o],n,u);p=y[0],h=y[1],m=y[2]}else if(n==="same"){p=Math.ceil(e/s),h=Math.ceil(t/a),m=Math.ceil(r/o);const g=(p-1)*s+i-e,y=(h-1)*a+c-t,b=(m-1)*o+l-r,v=Math.floor(g/2),$=g-v,S=Math.floor(y/2),T=y-S,O=Math.floor(b/2),L=b-O;d={top:S,bottom:T,left:O,right:L,front:v,back:$,type:"SAME"}}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:d,outDepth:p,outHeight:h,outWidth:m}}function ho(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 fo(n){const[e,t,r]=po(n);return e===1&&t===1&&r===1}function Kt(n,e){return fo(n)||fo(e)}function ks(n){return po(n).every(e=>e>0)}function Yr(n){if(n==="NHWC")return"channelsLast";if(n==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${n}`)}function En(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")N(xa(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(s=>{N(xa(s),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${s}.`)})});else throw Error(`Error in ${n}: Unknown padding parameter: ${e}`)}}/** 831 * @license 832 * Copyright 2020 Google LLC. All Rights Reserved. 833 * Licensed under the Apache License, Version 2.0 (the "License"); 834 * you may not use this file except in compliance with the License. 835 * You may obtain a copy of the License at 836 * 837 * http://www.apache.org/licenses/LICENSE-2.0 838 * 839 * Unless required by applicable law or agreed to in writing, software 840 * distributed under the License is distributed on an "AS IS" BASIS, 841 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 842 * See the License for the specific language governing permissions and 843 * limitations under the License. 844 * ============================================================================= 845 */function M1(n,e){const r={x:_(n,"x","reshape","string_or_numeric")},s={shape:e};return F.runKernel(Ad,r,s)}const q=D({reshape_:M1});/** 846 * @license 847 * Copyright 2020 Google LLC. All Rights Reserved. 848 * Licensed under the Apache License, Version 2.0 (the "License"); 849 * you may not use this file except in compliance with the License. 850 * You may obtain a copy of the License at 851 * 852 * http://www.apache.org/licenses/LICENSE-2.0 853 * 854 * Unless required by applicable law or agreed to in writing, software 855 * distributed under the License is distributed on an "AS IS" BASIS, 856 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 857 * See the License for the specific language governing permissions and 858 * limitations under the License. 859 * ============================================================================= 860 */function B1(n,e,t,r,s){const a=_(n,"x","avgPool","float32"),o=1;N(Kt(t,o),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`);let i=a,c=!1;a.rank===3&&(c=!0,i=q(a,[1,a.shape[0],a.shape[1],a.shape[2]])),N(i.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${i.rank}
860.`),En("avgPool",r,s);const l={x:i},u={filterSize:e,strides:t,pad:r,dimRoundingMode:s};let d=F.runKernel(Wi,l,u);return d=rt(d,a.dtype),c?q(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const Zm=D({avgPool_:B1});/** 861 * @license 862 * Copyright 2020 Google LLC. All Rights Reserved. 863 * Licensed under the Apache License, Version 2.0 (the "License"); 864 * you may not use this file except in compliance with the License. 865 * You may obtain a copy of the License at 866 * 867 * http://www.apache.org/licenses/LICENSE-2.0 868 * 869 * Unless required by applicable law or agreed to in writing, software 870 * distributed under the License is distributed on an "AS IS" BASIS, 871 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 872 * See the License for the specific language governing permissions and 873 * limitations under the License. 874 * ============================================================================= 875 */function V1(n,e,t,r,s,a="NDHWC"){const o=_(n,"x","avgPool3d","float32");let i=o,c=!1;o.rank===4&&(c=!0,i=q(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),N(i.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`),N(a==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),N(typeof t=="number"&&t>0||Array.isArray(t)&&t[0]>0&&t[1]>0&&t[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${t}'`),En("avgPool3d",r,s);const l={x:i},u={filterSize:e,strides:t,pad:r,dimRoundingMode:s,dataFormat:a};let d=F.runKernel(Pl,l,u);return d=rt(d,i.dtype),c?q(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const W1=D({avgPool3d_:V1});/** 876 * @license 877 * Copyright 2020 Google LLC. All Rights Reserved. 878 * Licensed under the Apache License, Version 2.0 (the "License"); 879 * you may not use this file except in compliance with the License. 880 * You may obtain a copy of the License at 881 * 882 * http://www.apache.org/licenses/LICENSE-2.0 883 * 884 * Unless required by applicable law or agreed to in writing, software 885 * distributed under the License is distributed on an "AS IS" BASIS, 886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 887 * See the License for the specific language governing permissions and 888 * limitations under the License. 889 * ============================================================================= 890 */function U1(n,e=0){N(n.length>=1,()=>"Pass at least one tensor to concat");const t=vi(n,"tensors","concat","string_or_numeric");if(t[0].dtype==="complex64"&&t.forEach(a=>{if(a.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor 891 with dtype ${a.dtype}. `)}),t.length===1)return Br(t[0]);const r=t,s={axis:e};return F.runKernel(Wl,r,s)}const It=D({concat_:U1});/** 892 * @license 893 * Copyright 2020 Google LLC. All Rights Reserved. 894 * Licensed under the Apache License, Version 2.0 (the "License"); 895 * you may not use this file except in compliance with the License. 896 * You may obtain a copy of the License at 897 * 898 * http://www.apache.org/licenses/LICENSE-2.0 899 * 900 * Unless required by applicable law or agreed to in writing, software 901 * distributed under the License is distributed on an "AS IS" BASIS, 902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 903 * See the License for the specific language governing permissions and 904 * limitations under the License. 905 * ============================================================================= 906 */function z1(n,e,t=!1,r=!1){let s=_(n,"a","matMul"),a=_(e,"b","matMul");[s,a]=ut(s,a);const o={a:s,b:a},i={transposeA:t,transposeB:r};return F.runKernel(Ui,o,i)}const Ue=D({matMul_:z1});/** 907 * @license 908 * Copyright 2018 Google LLC. All Rights Reserved. 909 * Licensed under the Apache License, Version 2.0 (the "License"); 910 * you may not use this file except in compliance with the License. 911 * You may obtain a copy of the License at 912 * 913 * http://www.apache.org/licenses/LICENSE-2.0 914 * 915 * Unless required by applicable law or agreed to in writing, software 916 * distributed under the License is distributed on an "AS IS" BASIS, 917 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 918 * See the License for the specific language governing permissions and 919 * limitations under the License. 920 * ============================================================================= 921 */function G1(n){const t={x:_(n,"x","sigmoid","float32")};return F.runKernel(Gd,t)}const Is=D({sigmoid_:G1});/** 922 * @license 923 * Copyright 2018 Google LLC. All Rights Reserved. 924 * Licensed under the Apache License, Version 2.0 (the "License");
925 * you may not use this file except in compliance with the License. 926 * You may obtain a copy of the License at 927 * 928 * http://www.apache.org/licenses/LICENSE-2.0 929 * 930 * Unless required by applicable law or agreed to in writing, software 931 * distributed under the License is distributed on an "AS IS" BASIS, 932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 933 * See the License for the specific language governing permissions and 934 * limitations under the License. 935 * ============================================================================= 936 */function H1(n,e,t){const r=_(n,"x","slice","string_or_numeric");if(r.rank===0)throw new Error("Slicing scalar is not possible");const s={x:r},a={begin:e,size:t};return F.runKernel(Vd,s,a)}const Se=D({slice_:H1});/** 937 * @license 938 * Copyright 2018 Google LLC. All Rights Reserved. 939 * Licensed under the Apache License, Version 2.0 (the "License"); 940 * you may not use this file except in compliance with the License. 941 * You may obtain a copy of the License at 942 * 943 * http://www.apache.org/licenses/LICENSE-2.0 944 * 945 * Unless required by applicable law or agreed to in writing, software 946 * distributed under the License is distributed on an "AS IS" BASIS, 947 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 948 * See the License for the specific language governing permissions and 949 * limitations under the License. 950 * ============================================================================= 951 */function j1(n){const t={x:_(n,"x","tanh","float32")};return F.runKernel(sp,t)}const qc=D({tanh_:j1});/** 952 * @license 953 * Copyright 2020 Google LLC. All Rights Reserved. 954 * Licensed under the Apache License, Version 2.0 (the "License"); 955 * you may not use this file except in compliance with the License. 956 * You may obtain a copy of the License at 957 * 958 * http://www.apache.org/licenses/LICENSE-2.0 959 * 960 * Unless required by applicable law or agreed to in writing, software 961 * distributed under the License is distributed on an "AS IS" BASIS, 962 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 963 * See the License for the specific language governing permissions and 964 * limitations under the License. 965 * ============================================================================= 966 */function q1(n,e,t,r,s,a){const o=_(n,"forgetBias","basicLSTMCell"),i=_(e,"lstmKernel","basicLSTMCell"),c=_(t,"lstmBias","basicLSTMCell"),l=_(r,"data","basicLSTMCell"),u=_(s,"c","basicLSTMCell"),d=_(a,"h","basicLSTMCell"),p=It([l,d],1),h=Ue(p,i),m=me(h,c),g=m.shape[0],y=m.shape[1]/4,b=[g,y],v=Se(m,[0,0],b),$=Se(m,[0,y],b),S=Se(m,[0,y*2],b),T=Se(m,[0,y*3],b),O=me(Z(Is(v),qc($)),Z(u,Is(me(o,S)))),L=Z(qc(O),Is(T));return[O,L]}const K1=D({basicLSTMCell_:q1});/** 967 * @license 968 * Copyright 2020 Google LLC. All Rights Reserved. 969 * Licensed under the Apache License, Version 2.0 (the "License"); 970 * you may not use this file except in compliance with the License. 971 * You may obtain a copy of the License at 972 * 973 * http://www.apache.org/licenses/LICENSE-2.0 974 * 975 * Unless required by applicable law or agreed to in writing, software 976 * distributed under the License is distributed on an "AS IS" BASIS, 977 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 978 * See the License for the specific language governing permissions and 979 * limitations under the License. 980 * ============================================================================= 981 */function X1(n,e,t){const r=_(n,"x","batchToSpaceND"),s=e.reduce((i,c)=>i*c);N(r.rank>=1+e.length,()=>`input rank is ${r.rank} but should be > than blockShape.length ${e.length}`),N(t.length===e.length,()=>`crops.length is ${t.length} but should be equal to blockShape.length ${e.length}`),N(r.shape[0]%s===0,()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${s}`);const a={x:r},o={blockShape:e,crops:t};return F.runKernel(Ll,a,o)}const Jm=D({batchToSpaceND_:X1});function Y1(n){let e;return n.rank===0||n.rank===1?e=q(n,[1,1,1,n.size]):n.rank===2?e=q(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?e=q(n,[1,n.shape[0],n.shape[1],n.shape[2]]):e=n,e}/** 982 * @license 983 * Copyright 2020 Google LLC. All Rights Reserved. 984 * Licensed under the Apache License, Version 2.0 (the "License");
985 * you may not use this file except in compliance with the License. 986 * You may obtain a copy of the License at 987 * 988 * http://www.apache.org/licenses/LICENSE-2.0 989 * 990 * Unless required by applicable law or agreed to in writing, software 991 * distributed under the License is distributed on an "AS IS" BASIS, 992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 993 * See the License for the specific language governing permissions and 994 * limitations under the License. 995 * ============================================================================= 996 */function Q1(n,e,t,r,s,a){a==null&&(a=.001);const o=_(n,"x","batchNorm"),i=_(e,"mean","batchNorm"),c=_(t,"variance","batchNorm");let l;s!=null&&(l=_(s,"scale","batchNorm"));let u;r!=null&&(u=_(r,"offset","batchNorm")),N(i.rank===c.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),N(u==null||i.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),N(l==null||i.rank===l.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const p={x:Y1(o),scale:l,offset:u,mean:i,variance:c},h={varianceEpsilon:a},m=F.runKernel(ru,p,h);return q(m,o.shape)}const Bu=D({batchNorm_:Q1});function Z1(n,e,t,r,s,a){const o=_(n,"x","batchNorm"),i=_(e,"mean","batchNorm"),c=_(t,"variance","batchNorm");let l;s!=null&&(l=_(s,"scale","batchNorm"));let u;return r!=null&&(u=_(r,"offset","batchNorm")),N(o.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`),N(i.rank===2||i.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`),N(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${c.rank}.`),l!=null&&N(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`),u!=null&&N(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${u.rank}.`),Bu(o,i,c,u,l,a)}const J1=D({batchNorm2d_:Z1});function ev(n,e,t,r,s,a){const o=_(n,"x","batchNorm"),i=_(e,"mean","batchNorm"),c=_(t,"variance","batchNorm");let l;s!=null&&(l=_(s,"scale","batchNorm"));let u;return r!=null&&(u=_(r,"offset","batchNorm")),N(o.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`),N(i.rank===3||i.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`),N(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${c.rank}.`),l!=null&&N(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`),u!=null&&N(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${u.rank}.`),Bu(o,i,c,u,l,a)}const tv=D({batchNorm3d_:ev});function nv(n,e,t,r,s,a){const o=_(n,"x","batchNorm"),i=_(e,"mean","batchNorm"),c=_(t,"variance","batchNorm");let l;s!=null&&(l=_(s,"scale","batchNorm"));let u;return r!=null&&(u=_(r,"offset","batchNorm")),N(o.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`),N(i.rank===4||i.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`),N(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${c.rank}.`),l!=null&&N(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`),u!=null&&N(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${u.rank}.`),Bu(o,i,c,u,l,a)}const rv=D({batchNorm4d_:nv});/** 997 * @license 998 * Copyright 2020 Google LLC. All Rights Reserved. 999 * Licensed under the Apache License, Version 2.0 (the "License"); 1000 * you may not use this file except in compliance with the License. 1001 * You may obtain a copy of the License at 1002 * 1003 * http://www.apache.org/licenses/LICENSE-2.0 1004 * 1005 * Unless required by applicable law or agreed to in writing, software 1006 * distributed under the License is distributed on an "AS IS" BASIS, 1007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1008 * See the License for the specific language governing permissions and 1009 * limitations under the License. 1010 * ============================================================================= 1011 */function sv(n,e,t){const r=_(n,"x","bincount"),s=_(e,"weights","bincount");N(r.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`),N(t>=0,()=>`size must be non-negative, but got ${t}.`),N(s.size===r.size||s.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${s.shape}.`);const a={x:r,weights:s},o={size:t};return F.runKernel(zi,a,o)}const eg=D({bincount_:sv});/** 1012 * @license 1013 * Copyright 2023 Google LLC. 1014 * Licensed under the Apache License, Version 2.0 (the "License");
1015 * you may not use this file except in compliance with the License. 1016 * You may obtain a copy of the License at 1017 * 1018 * http://www.apache.org/licenses/LICENSE-2.0 1019 * 1020 * Unless required by applicable law or agreed to in writing, software 1021 * distributed under the License is distributed on an "AS IS" BASIS, 1022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1023 * See the License for the specific language governing permissions and 1024 * limitations under the License. 1025 * ============================================================================= 1026 */function av(n,e){const t=_(n,"x","bitwiseAnd"),r=_(e,"y","bitwiseAnd");if(!st(t.shape,r.shape))throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${t.shape}, y: ${r.shape}`);if(t.dtype!=="int32"||r.dtype!=="int32")throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${t.dtype} and type of y: ${r.dtype}`);const s={a:t,b:r};return F.runKernel(Ml,s)}const ov=D({bitwiseAnd_:av});/** 1027 * @license 1028 * Copyright 2021 Google LLC. All Rights Reserved. 1029 * Licensed under the Apache License, Version 2.0 (the "License"); 1030 * you may not use this file except in compliance with the License. 1031 * You may obtain a copy of the License at 1032 * 1033 * http://www.apache.org/licenses/LICENSE-2.0 1034 * 1035 * Unless required by applicable law or agreed to in writing, software 1036 * distributed under the License is distributed on an "AS IS" BASIS, 1037 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1038 * See the License for the specific language governing permissions and 1039 * limitations under the License. 1040 * ============================================================================= 1041 */function iv(n,e){const t=_(n,"s0","broadcastArgs","int32"),r=_(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 s={s0:t,s1:r};return F.runKernel(Bl,s)}const uv=D({broadcastArgs_:iv});/** 1042 * @license 1043 * Copyright 2020 Google LLC. All Rights Reserved. 1044 * Licensed under the Apache License, Version 2.0 (the "License"); 1045 * you may not use this file except in compliance with the License. 1046 * You may obtain a copy of the License at 1047 * 1048 * http://www.apache.org/licenses/LICENSE-2.0 1049 * 1050 * Unless required by applicable law or agreed to in writing, software 1051 * distributed under the License is distributed on an "AS IS" BASIS, 1052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1053 * See the License for the specific language governing permissions and 1054 * limitations under the License. 1055 * ============================================================================= 1056 */function cv(n,e){let t=_(n,"broadcastTo","x");const r=t.shape;if(fn(e),e.length<t.rank)throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${t.rank}.`);if(e.length>t.rank){const l=t.shape.slice();for(;l.length<e.length;)l.unshift(1);t=q(t,l)}const s=t.shape,a=Array.from(e);for(let l=e.length-1;l>=0;l--)if(s[l]===e[l])a[l]=1;else if(t.shape[l]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${e}].`);if(a.map((l,u)=>l>1?u:-1).filter(l=>l>=0).length===0)return Br(t);const i={x:t},c={reps:a};return F.runKernel(_o,i,c)}const oo=D({broadcastTo_:cv});/** 1057 * @license 1058 * Copyright 2018 Google LLC. All Rights Reserved. 1059 * Licensed under the Apache License, Version 2.0 (the "License"); 1060 * you may not use this file except in compliance with the License. 1061 * You may obtain a copy of the License at 1062 * 1063 * http://www.apache.org/licenses/LICENSE-2.0 1064 * 1065 * Unless required by applicable law or agreed to in writing, software 1066 * distributed under the License is distributed on an "AS IS" BASIS, 1067 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1068 * See the License for the specific language governing permissions and 1069 * limitations under the License. 1070 * ============================================================================= 1071 */function lv(n){const t={x:_(n,"x","ceil","float32")};return F.runKernel(Vl,t)}const dv=D({ceil_:lv});/** 1072 * @license 1073 * Copyright 2020 Google LLC. All Rights Reserved. 1074 * Licensed under the Apache License, Version 2.0 (the "License");
1075 * you may not use this file except in compliance with the License. 1076 * You may obtain a copy of the License at 1077 * 1078 * http://www.apache.org/licenses/LICENSE-2.0 1079 * 1080 * Unless required by applicable law or agreed to in writing, software 1081 * distributed under the License is distributed on an "AS IS" BASIS, 1082 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1083 * See the License for the specific language governing permissions and 1084 * limitations under the License. 1085 * ============================================================================= 1086 */function ko(n,e,t){fn(n),t=t||ka(e);const r={shape:n,value:e,dtype:t};return F.runKernel(td,{},r)}/** 1087 * @license 1088 * Copyright 2018 Google LLC. All Rights Reserved. 1089 * Licensed under the Apache License, Version 2.0 (the "License"); 1090 * you may not use this file except in compliance with the License. 1091 * You may obtain a copy of the License at 1092 * 1093 * http://www.apache.org/licenses/LICENSE-2.0 1094 * 1095 * Unless required by applicable law or agreed to in writing, software 1096 * distributed under the License is distributed on an "AS IS" BASIS, 1097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1098 * See the License for the specific language governing permissions and 1099 * limitations under the License. 1100 * ============================================================================= 1101 */function pv(n,e,t){const r=_(n,"x","clipByValue");if(N(e<=t,()=>`Error in clip: min (${e}) must be less than or equal to max (${t}).`),e===t)return ko(r.shape,e,r.dtype);const s={x:r},a={clipValueMin:e,clipValueMax:t};return F.runKernel(Hi,s,a)}const tg=D({clipByValue_:pv});function hv(n){return It(n,0)}const fv=D({concat1d_:hv});function mv(n,e){return It(n,e)}const gv=D({concat2d_:mv});function yv(n,e){return It(n,e)}const bv=D({concat3d_:yv});function xv(n,e){return It(n,e)}const wv=D({concat4d_:xv});/** 1102 * @license 1103 * Copyright 2020 Google LLC. All Rights Reserved. 1104 * Licensed under the Apache License, Version 2.0 (the "License"); 1105 * you may not use this file except in compliance with the License. 1106 * You may obtain a copy of the License at 1107 * 1108 * http://www.apache.org/licenses/LICENSE-2.0 1109 * 1110 * Unless required by applicable law or agreed to in writing, software 1111 * distributed under the License is distributed on an "AS IS" BASIS, 1112 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1113 * See the License for the specific language governing permissions and 1114 * limitations under the License. 1115 * ============================================================================= 1116 */function vv(n,e,t,r,s="NHWC",a=[1,1],o){const i=_(n,"x","conv2d","float32"),c=_(e,"filter","conv2d","float32");let l=i,u=!1;i.rank===3&&(u=!0,l=q(i,[1,i.shape[0],i.shape[1],i.shape[2]])),N(l.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`),N(c.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${c.rank}.`),En("conv2d",r,o);const d=s==="NHWC"?l.shape[3]:l.shape[1];N(d===c.shape[2],()=>`Error in conv2d: depth of input (${d}) must match input depth for filter ${c.shape[2]}.`),N(Kt(t,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`),N(ks(a),()=>"Error in conv2D: Dilated rates should be larger than 0."),N(ks(t),()=>"Error in conv2D: Strides should be larger than 0.");const p={x:l,filter:c},h={strides:t,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o},m=F.runKernel(ji,p,h);return u?q(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const Vu=D({conv2d_:vv});function Iv(n,e,t,r,s="NWC",a=1,o){const i=_(n,"x","conv1d"),c=_(e,"filter","conv1d");let l=i,u=!1;i.rank===2&&(u=!0,l=q(i,[1,i.shape[0],i.shape[1]])),N(l.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`),N(c.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${c.rank}.`),En("conv1d",r,o),N(l.shape[2]===c.shape[1],()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${c.shape[1]}.`),N(Kt(t,a),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${t} and dilation '${a}'`),N(ks(a),()=>"Error in conv1D: Dilated rates should be larger than 0."),N(ks(t),()=>"Error in conv1D: Stride should be larger than 0."),N(s==="NWC",()=>`Error in conv1d: got dataFormat of ${s} but only NWC is currently supported.`);const d=q(c,[1,c.shape[0],c.shape[1],c.shape[2]]),p=q(l,[l.shape[0],1,l.shape[1],l.shape[2]]),y=Vu(p,d,[1,t],r,"NHWC",[1,a],o);return u?q(y,[y.shape[2],y.shape[3]]):q(y,[y.shape[0],y.shape[2],y.shape[3]])}
vendor: 5,574 bytes, lines 1116-1164
1116const $v=D({conv1d_:Iv});/** 1117 * @license 1118 * Copyright 2020 Google LLC. All Rights Reserved. 1119 * Licensed under the Apache License, Version 2.0 (the "License"); 1120 * you may not use this file except in compliance with the License. 1121 * You may obtain a copy of the License at 1122 * 1123 * http://www.apache.org/licenses/LICENSE-2.0 1124 * 1125 * Unless required by applicable law or agreed to in writing, software 1126 * distributed under the License is distributed on an "AS IS" BASIS, 1127 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1128 * See the License for the specific language governing permissions and 1129 * limitations under the License. 1130 * ============================================================================= 1131 */function Sv(n,e,t,r,s,a="NHWC",o){N(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let i=n,c=e,l=!1;e.rank===3&&(l=!0,c=q(e,[1,e.shape[0],e.shape[1],e.shape[2]]),i=[1,n[0],n[1],n[2]]),N(i.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`),N(c.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${c.rank}`),N(t.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${t.rank}`);const u=a==="NHWC"?i[3]:i[1],d=a==="NHWC"?c.shape[3]:c.shape[1];N(u===t.shape[2],()=>`Error in conv2dDerInput: depth of input (${u}) must match input depth for filter ${t.shape[2]}.`),N(d===t.shape[3],()=>`Error in conv2dDerInput: depth of output (${d}) must match output depth for filter ${t.shape[3]}.`),En("conv2dDerInput",s,o);const p={dy:c,filter:t},h={strides:r,pad:s,dataFormat:a,dimRoundingMode:o,inputShape:i},m=F.runKernel(qi,p,h);return l?q(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const ng=D({conv2DBackpropInput_:Sv});function Cv(n,e,t,r,s,a){const o=_(n,"x","conv2dTranspose"),i=_(e,"filter","conv2dTranspose");return ng(t,o,i,r,s,"NHWC",a)}const _v=D({conv2dTranspose_:Cv});/** 1132 * @license 1133 * Copyright 2020 Google LLC. All Rights Reserved. 1134 * Licensed under the Apache License, Version 2.0 (the "License"); 1135 * you may not use this file except in compliance with the License. 1136 * You may obtain a copy of the License at 1137 * 1138 * http://www.apache.org/licenses/LICENSE-2.0 1139 * 1140 * Unless required by applicable law or agreed to in writing, software 1141 * distributed under the License is distributed on an "AS IS" BASIS, 1142 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1143 * See the License for the specific language governing permissions and 1144 * limitations under the License. 1145 * ============================================================================= 1146 */function Nv(n,e,t,r,s="NDHWC",a=[1,1,1]){const o=_(n,"x","conv3d"),i=_(e,"filter","conv3d");let c=o,l=!1;o.rank===4&&(l=!0,c=q(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),N(c.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${c.rank}.`),N(i.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`),N(c.shape[4]===i.shape[3],()=>`Error in conv3d: depth of input (${c.shape[4]}) must match input depth for filter ${i.shape[3]}.`),N(Kt(t,a),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`),N(s==="NDHWC",()=>`Error in conv3d: got dataFormat of ${s} but only NDHWC is currently supported.`),N(ks(a),()=>"Error in conv3D: Dilated rates should be larger than 0."),N(ks(t),()=>"Error in conv3D: Strides should be larger than 0.");const u={x:c,filter:i},d={strides:t,pad:r,dataFormat:s,dilations:a},p=F.runKernel(Ki,u,d);return l?q(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const Tv=D({conv3d_:Nv});/** 1147 * @license 1148 * Copyright 2020 Google LLC. All Rights Reserved. 1149 * Licensed under the Apache License, Version 2.0 (the "License"); 1150 * you may not use this file except in compliance with the License. 1151 * You may obtain a copy of the License at 1152 * 1153 * http://www.apache.org/licenses/LICENSE-2.0 1154 * 1155 * Unless required by applicable law or agreed to in writing, software 1156 * distributed under the License is distributed on an "AS IS" BASIS, 1157 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1158 * See the License for the specific language governing permissions and 1159 * limitations under the License. 1160 * ============================================================================= 1161 */function kv(n,e,t,r,s){N(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let a=n,o=e,i=!1;e.rank===4&&(i=!0,o=q(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),a=[1,n[0],n[1],n[2],n[3]]);const c=a[4],l=o.shape[4];N(a.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${a.length}.`),N(o.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`),N(t.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${t.rank}`),N(c===t.shape[3],()=>`Error in conv3dDerInput: depth of input (${c}) must match input depth for filter ${t.shape[3]}.`),N(l===t.shape[4],()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${t.shape[4]}.`);const u={dy:o,filter:t},d={pad:s,strides:r,inputShape:a},p=F.runKernel(Xi,u,d);return i?q(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const Ev=D({conv3DBackpropInput_:kv});function Rv(n,e,t,r,s){const a=_(n,"x","conv3dTranspose"),o=_(e,"filter","conv3dTranspose");return Ev(t,a,o,r,s)}const Av=D({conv3dTranspose_:Rv});/** 1162 * @license 1163 * Copyright 2018 Google LLC. All Rights Reserved. 1164 * Licensed under the Apache License, Version 2.0 (the "License");
1165 * you may not use this file except in compliance with the License. 1166 * You may obtain a copy of the License at 1167 * 1168 * http://www.apache.org/licenses/LICENSE-2.0 1169 * 1170 * Unless required by applicable law or agreed to in writing, software 1171 * distributed under the License is distributed on an "AS IS" BASIS, 1172 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1173 * See the License for the specific language governing permissions and 1174 * limitations under the License. 1175 * ============================================================================= 1176 */function Dv(n){const t={x:_(n,"x","cos","float32")};return F.runKernel(zl,t)}const Ov=D({cos_:Dv});/** 1177 * @license 1178 * Copyright 2018 Google LLC. All Rights Reserved. 1179 * Licensed under the Apache License, Version 2.0 (the "License"); 1180 * you may not use this file except in compliance with the License. 1181 * You may obtain a copy of the License at 1182 * 1183 * http://www.apache.org/licenses/LICENSE-2.0 1184 * 1185 * Unless required by applicable law or agreed to in writing, software 1186 * distributed under the License is distributed on an "AS IS" BASIS, 1187 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1188 * See the License for the specific language governing permissions and 1189 * limitations under the License. 1190 * ============================================================================= 1191 */function Fv(n){const t={x:_(n,"x","cosh","float32")};return F.runKernel(Gl,t)}const Pv=D({cosh_:Fv});/** 1192 * @license 1193 * Copyright 2022 Google LLC. All Rights Reserved. 1194 * Licensed under the Apache License, Version 2.0 (the 'License'); 1195 * you may not use this file except in compliance with the License. 1196 * You may obtain a copy of the License at 1197 * 1198 * http://www.apache.org/licenses/LICENSE-2.0 1199 * 1200 * Unless required by applicable law or agreed to in writing, software 1201 * distributed under the License is distributed on an 'AS IS' BASIS, 1202 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1203 * See the License for the specific language governing permissions and 1204 * limitations under the License. 1205 * ============================================================================= 1206 */function Lv(n,e=0,t=!1,r=!1){const a={x:_(n,"x","cumprod")},o={axis:e,exclusive:t,reverse:r};return F.runKernel(Yi,a,o)}const Mv=D({cumprod_:Lv});/** 1207 * @license 1208 * Copyright 2018 Google LLC. All Rights Reserved. 1209 * Licensed under the Apache License, Version 2.0 (the "License"); 1210 * you may not use this file except in compliance with the License. 1211 * You may obtain a copy of the License at 1212 * 1213 * http://www.apache.org/licenses/LICENSE-2.0 1214 * 1215 * Unless required by applicable law or agreed to in writing, software 1216 * distributed under the License is distributed on an "AS IS" BASIS, 1217 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1218 * See the License for the specific language governing permissions and 1219 * limitations under the License. 1220 * ============================================================================= 1221 */function Bv(n,e=0,t=!1,r=!1){const a={x:_(n,"x","cumsum")},o={axis:e,exclusive:t,reverse:r};return F.runKernel(Qi,a,o)}const Vv=D({cumsum_:Bv});/** 1222 * @license 1223 * Copyright 2020 Google LLC. All Rights Reserved. 1224 * Licensed under the Apache License, Version 2.0 (the "License"); 1225 * you may not use this file except in compliance with the License. 1226 * You may obtain a copy of the License at 1227 * 1228 * http://www.apache.org/licenses/LICENSE-2.0 1229 * 1230 * Unless required by applicable law or agreed to in writing, software 1231 * distributed under the License is distributed on an "AS IS" BASIS, 1232 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1233 * See the License for the specific language governing permissions and 1234 * limitations under the License. 1235 * ============================================================================= 1236 */function Wv(n,e,t,r=!1){const s=_(n,"x","denseBincount"),a=_(e,"weights","denseBincount");N(s.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${s.dtype}`),N(s.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${s.rank}
1236.`),N(t>=0,()=>`size must be non-negative, but got ${t}.`),N(a.size===s.size||a.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${s.shape}, weights shape: ${a.shape}.`);const o={x:s,weights:a},i={size:t,binaryOutput:r};return F.runKernel(Hl,o,i)}const Uv=D({denseBincount_:Wv});/** 1237 * @license 1238 * Copyright 2020 Google LLC. All Rights Reserved. 1239 * Licensed under the Apache License, Version 2.0 (the "License"); 1240 * you may not use this file except in compliance with the License. 1241 * You may obtain a copy of the License at 1242 * 1243 * http://www.apache.org/licenses/LICENSE-2.0 1244 * 1245 * Unless required by applicable law or agreed to in writing, software 1246 * distributed under the License is distributed on an "AS IS" BASIS, 1247 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1248 * See the License for the specific language governing permissions and 1249 * limitations under the License. 1250 * ============================================================================= 1251 */function zv(n,e,t="NHWC"){const r=_(n,"x","depthToSpace","float32"),s=t==="NHWC"?r.shape[1]:r.shape[2],a=t==="NHWC"?r.shape[2]:r.shape[3],o=t==="NHWC"?r.shape[3]:r.shape[1];N(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),N(s*e>=0,()=>`Negative dimension size caused by overflow when multiplying 1252 ${s} and ${e} for depthToSpace with input shape 1253 ${r.shape}`),N(a*e>=0,()=>`Negative dimension size caused by overflow when multiplying 1254 ${a} and ${e} for depthToSpace with input shape 1255 ${r.shape}`),N(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},c={blockSize:e,dataFormat:t};return F.runKernel(Ji,i,c)}const Gv=D({depthToSpace_:zv});/** 1256 * @license 1257 * Copyright 2020 Google LLC. All Rights Reserved. 1258 * Licensed under the Apache License, Version 2.0 (the "License"); 1259 * you may not use this file except in compliance with the License. 1260 * You may obtain a copy of the License at 1261 * 1262 * http://www.apache.org/licenses/LICENSE-2.0 1263 * 1264 * Unless required by applicable law or agreed to in writing, software 1265 * distributed under the License is distributed on an "AS IS" BASIS, 1266 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1267 * See the License for the specific language governing permissions and 1268 * limitations under the License. 1269 * ============================================================================= 1270 */function Hv(n,e,t,r,s="NHWC",a=[1,1],o){const i=_(n,"x","depthwiseConv2d","float32"),c=_(e,"filter","depthwiseConv2d","float32");let l=i,u=!1;i.rank===3&&(u=!0,l=q(i,[1,i.shape[0],i.shape[1],i.shape[2]])),N(l.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`),N(c.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${c.rank}.`);const d=s==="NHWC"?l.shape[3]:l.shape[1];N(d===c.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${d}) must match the inChannels dimension in filter ${c.shape[2]}.`),En("depthwiseConv2d",r,o);const p={x:l,filter:c},h={strides:t,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o},m=F.runKernel(eu,p,h);return u?q(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const hp=D({depthwiseConv2d_:Hv});/** 1271 * @license 1272 * Copyright 2020 Google LLC. All Rights Reserved. 1273 * Licensed under the Apache License, Version 2.0 (the "License"); 1274 * you may not use this file except in compliance with the License. 1275 * You may obtain a copy of the License at 1276 * 1277 * http://www.apache.org/licenses/LICENSE-2.0 1278 * 1279 * Unless required by applicable law or agreed to in writing, software 1280 * distributed under the License is distributed on an "AS IS" BASIS, 1281 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1282 * See the License for the specific language governing permissions and 1283 * limitations under the License. 1284 * ============================================================================= 1285 */function jv(n){const t={x:_(n,"x","diag")};return F.runKernel(jl,t)}const qv=D({diag_:jv});/** 1286 * @license 1287 * Copyright 2020 Google LLC. All Rights Reserved. 1288 * Licensed under the Apache License, Version 2.0 (the "License");
1289 * you may not use this file except in compliance with the License. 1290 * You may obtain a copy of the License at 1291 * 1292 * http://www.apache.org/licenses/LICENSE-2.0 1293 * 1294 * Unless required by applicable law or agreed to in writing, software 1295 * distributed under the License is distributed on an "AS IS" BASIS, 1296 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1297 * See the License for the specific language governing permissions and 1298 * limitations under the License. 1299 * ============================================================================= 1300 */function Kv(n,e,t,r,s=[1,1],a="NHWC"){const o=_(n,"x","dilation2d"),i=_(e,"filter","dilation2d");N(o.rank===3||o.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`),N(i.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`),N(a==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`);let c=o,l=!1;o.rank===3&&(c=q(o,[1,o.shape[0],o.shape[1],o.shape[2]]),l=!0),N(c.shape[3]===i.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${c.shape[3]} vs ${i.shape[2]}`);const u={x:c,filter:i},d={strides:t,pad:r,dilations:s},p=F.runKernel(tu,u,d);return l?q(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const Xv=D({dilation2d_:Kv});/** 1301 * @license 1302 * Copyright 2017 Google LLC. All Rights Reserved. 1303 * Licensed under the Apache License, Version 2.0 (the "License"); 1304 * you may not use this file except in compliance with the License. 1305 * You may obtain a copy of the License at 1306 * 1307 * http://www.apache.org/licenses/LICENSE-2.0 1308 * 1309 * Unless required by applicable law or agreed to in writing, software 1310 * distributed under the License is distributed on an "AS IS" BASIS, 1311 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1312 * See the License for the specific language governing permissions and 1313 * limitations under the License. 1314 * ============================================================================= 1315 */function Ii(n,e){const t=n.length,r=[];for(let s=0;s<t;s++){const a=t-1-s,o=n[a]||1;(e[e.length-1-s]||1)>1&&o===1&&r.unshift(a)}return r}function rg(n,e){const t=[];for(let r=0;r<e.length;r++){const s=n[n.length-r-1],a=e.length-r-1,o=e[a];(s==null||s===1&&o>1)&&t.unshift(a)}return t}function ke(n,e){const t=Math.max(n.length,e.length),r=new Array(t);for(let s=0;s<t;s++){let a=n[n.length-s-1];a==null&&(a=1);let o=e[e.length-s-1];if(o==null&&(o=1),a===1)r[t-s-1]=o;else if(o===1)r[t-s-1]=a;else if(a!==o){const i=`Operands could not be broadcast together with shapes ${n} and ${e}.`;throw Error(i)}else r[t-s-1]=a}return r}/** 1316 * @license 1317 * Copyright 2020 Google LLC. All Rights Reserved. 1318 * Licensed under the Apache License, Version 2.0 (the "License"); 1319 * you may not use this file except in compliance with the License. 1320 * You may obtain a copy of the License at 1321 * 1322 * http://www.apache.org/licenses/LICENSE-2.0 1323 * 1324 * Unless required by applicable law or agreed to in writing, software 1325 * distributed under the License is distributed on an "AS IS" BASIS, 1326 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1327 * See the License for the specific language governing permissions and 1328 * limitations under the License. 1329 * ============================================================================= 1330 */function Yv(n,e){let t=_(n,"a","equal","string_or_numeric"),r=_(e,"b","equal","string_or_numeric");[t,r]=ut(t,r),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(Ql,s)}const sg=D({equal_:Yv});/** 1331 * @license 1332 * Copyright 2020 Google LLC. All Rights Reserved. 1333 * Licensed under the Apache License, Version 2.0 (the "License"); 1334 * you may not use this file except in compliance with the License. 1335 * You may obtain a copy of the License at 1336 * 1337 * http://www.apache.org/licenses/LICENSE-2.0 1338 * 1339 * Unless required by applicable law or agreed to in writing, software 1340 * distributed under the License is distributed on an "AS IS" BASIS, 1341 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1342 * See the License for the specific language governing permissions and 1343 * limitations under the License. 1344 * ============================================================================= 1345 */function Qv(n,e,t){const r=_(e,"a","where"),s=_(t,"b","where"),a=_(n,"condition","where","bool"),o=ke(ke(a.shape,r.shape),s.shape),i=oo(a,o),c=oo(r,o),l=oo(s,o),u={condition:i,t:c,e:l};return F.runKernel(Md,u)}const Vr=D({where_:Qv});/** 1346 * @license 1347 * Copyright 2018 Google LLC. All Rights Reserved. 1348 * Licensed under the Apache License, Version 2.0 (the "License");
1349 * you may not use this file except in compliance with the License. 1350 * You may obtain a copy of the License at 1351 * 1352 * http://www.apache.org/licenses/LICENSE-2.0 1353 * 1354 * Unless required by applicable law or agreed to in writing, software 1355 * distributed under the License is distributed on an "AS IS" BASIS, 1356 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1357 * See the License for the specific language governing permissions and 1358 * limitations under the License. 1359 * ============================================================================= 1360 */function Zv(n){const t={x:_(n,"x","zerosLike")};return F.runKernel(ip,t)}const hn=D({zerosLike_:Zv});/** 1361 * @license 1362 * Copyright 2020 Google LLC. All Rights Reserved. 1363 * Licensed under the Apache License, Version 2.0 (the "License"); 1364 * you may not use this file except in compliance with the License. 1365 * You may obtain a copy of the License at 1366 * 1367 * http://www.apache.org/licenses/LICENSE-2.0 1368 * 1369 * Unless required by applicable law or agreed to in writing, software 1370 * distributed under the License is distributed on an "AS IS" BASIS, 1371 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1372 * See the License for the specific language governing permissions and 1373 * limitations under the License. 1374 * ============================================================================= 1375 */function Jv(n,e){let t=_(n,"a","div"),r=_(e,"b","div");[t,r]=ut(t,r);const s=Te(t,r),a=hn(s),o=sg(r,a);return Vr(o,a,s)}const eI=D({divNoNan_:Jv});/** 1376 * @license 1377 * Copyright 2020 Google LLC. All Rights Reserved. 1378 * Licensed under the Apache License, Version 2.0 (the "License"); 1379 * you may not use this file except in compliance with the License. 1380 * You may obtain a copy of the License at 1381 * 1382 * http://www.apache.org/licenses/LICENSE-2.0 1383 * 1384 * Unless required by applicable law or agreed to in writing, software 1385 * distributed under the License is distributed on an "AS IS" BASIS, 1386 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1387 * See the License for the specific language governing permissions and 1388 * limitations under the License. 1389 * ============================================================================= 1390 */function tI(n,e){const t=_(n,"t1","dot"),r=_(e,"t2","dot");N((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 s=t.rank===1?t.size:t.shape[1],a=r.rank===1?r.size:r.shape[0];if(N(s===a,()=>`Error in dot: inner dimensions of inputs must match, but got ${s} and ${a}.`),t.rank===1&&r.rank===1){const o=q(t,[1,-1]),i=q(r,[-1,1]),c=Ue(o,i);return q(c,[])}else if(t.rank===1&&r.rank===2){const o=q(t,[1,-1]),i=q(r,[r.shape[0],r.shape[1]]),c=Ue(o,i);return q(c,[c.size])}else if(t.rank===2&&r.rank===1){const o=q(r,[-1,1]),i=Ue(t,o);return q(i,[i.size])}else{const o=q(r,[r.shape[0],r.shape[1]]);return Ue(t,o)}}const nI=D({dot_:tI});/** 1391 * @license 1392 * Copyright 2021 Google LLC. All Rights Reserved. 1393 * Licensed under the Apache License, Version 2.0 (the "License"); 1394 * you may not use this file except in compliance with the License. 1395 * You may obtain a copy of the License at 1396 * 1397 * http://www.apache.org/licenses/LICENSE-2.0 1398 * 1399 * Unless required by applicable law or agreed to in writing, software 1400 * distributed under the License is distributed on an "AS IS" BASIS, 1401 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1402 * See the License for the specific language governing permissions and 1403 * limitations under the License. 1404 * ============================================================================= 1405 */function rI(n,...e){const t=e.map((s,a)=>_(s,`tensors${a}`,"einsum")),r={equation:n};return F.runKernel(sm,t,r)}const pa=D({einsum_:rI});/** 1406 * @license 1407 * Copyright 2020 Google LLC. All Rights Reserved. 1408 * Licensed under the Apache License, Version 2.0 (the "License"); 1409 * you may not use this file except in compliance with the License. 1410 * You may obtain a copy of the License at 1411 * 1412 * http://www.apache.org/licenses/LICENSE-2.0 1413 * 1414 * Unless required by applicable law or agreed to in writing, softw
1414are 1415 * distributed under the License is distributed on an "AS IS" BASIS, 1416 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1417 * See the License for the specific language governing permissions and 1418 * limitations under the License. 1419 * ============================================================================= 1420 */function sI(n){const t={x:_(n,"x","elu","float32")};return F.runKernel(Kl,t)}const ag=D({elu_:sI});/** 1421 * @license 1422 * Copyright 2023 Google LLC. 1423 * Licensed under the Apache License, Version 2.0 (the "License"); 1424 * you may not use this file except in compliance with the License. 1425 * You may obtain a copy of the License at 1426 * 1427 * http://www.apache.org/licenses/LICENSE-2.0 1428 * 1429 * Unless required by applicable law or agreed to in writing, software 1430 * distributed under the License is distributed on an "AS IS" BASIS, 1431 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1432 * See the License for the specific language governing permissions and 1433 * limitations under the License. 1434 * ============================================================================= 1435 */function aI(n,e){const t=_(n,"x","ensureShape","string_or_numeric");if(!D0(t.shape,e))throw new Error(`EnsureShape: Shape of tensor ${t.shape} is not compatible with expected shape ${e}`);return n}const oI=D({ensureShape_:aI});/** 1436 * @license 1437 * Copyright 2018 Google LLC. All Rights Reserved. 1438 * Licensed under the Apache License, Version 2.0 (the "License"); 1439 * you may not use this file except in compliance with the License. 1440 * You may obtain a copy of the License at 1441 * 1442 * http://www.apache.org/licenses/LICENSE-2.0 1443 * 1444 * Unless required by applicable law or agreed to in writing, software 1445 * distributed under the License is distributed on an "AS IS" BASIS, 1446 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1447 * See the License for the specific language governing permissions and 1448 * limitations under the License. 1449 * ============================================================================= 1450 */function iI(n){let e=_(n,"x","erf");N(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=rt(e,"float32"));const t={x:e};return F.runKernel(Yl,t)}const uI=D({erf_:iI});/** 1451 * @license 1452 * Copyright 2017 Google LLC. All Rights Reserved. 1453 * Licensed under the Apache License, Version 2.0 (the "License"); 1454 * you may not use this file except in compliance with the License. 1455 * You may obtain a copy of the License at 1456 * 1457 * http://www.apache.org/licenses/LICENSE-2.0 1458 * 1459 * Unless required by applicable law or agreed to in writing, software 1460 * distributed under the License is distributed on an "AS IS" BASIS, 1461 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1462 * See the License for the specific language governing permissions and 1463 * limitations under the License. 1464 * ============================================================================= 1465 */function fp(n,e){for(let t=0;t<n.length;++t)if(n[n.length-t-1]!==e-1-t)return!1;return!0}function og(n,e,t){const r=n.length+e.length,s=[];let a=0,o=0;for(let i=0;i<r;i++)t.indexOf(i)===-1?s.push(n[a++]):s.push(e[o++]);return s}function At(n,e){const t=[],r=n.length;for(let a=0;a<r;a++)e.indexOf(a)===-1&&t.push(n[a]);const s=e.map(a=>n[a]);return[t,s]}function pt(n,e){const t=e.map(r=>1);return og(n,t,e)}function ht(n,e,t){N(fp(e,t),()=>`${n} supports only inner-most axes for now. Got axes ${e} and rank-${t} input.`)}function Xt(n,e){if(fp(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 Eo(n){return n.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function St(n,e){const t=[];for(let r=e-n;r<e;++r)t.push(r);return t}/** 1466 * @license 1467 * Copyright 2020 Google LLC. All Rights Reserved. 1468 * Licensed under the Apache License, Version 2.0 (the "License"); 1469 * you may not use this file except in compliance with the License. 1470 * You may obtain a copy of the License at 1471 * 1472 * http://www.apache.org/licenses/LICENSE-2.0 1473 * 1474 * Unless required by applicable law or agreed to in writing, softw
1474are 1475 * distributed under the License is distributed on an "AS IS" BASIS, 1476 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1477 * See the License for the specific language governing permissions and 1478 * limitations under the License. 1479 * ============================================================================= 1480 */function cI(n,e=null,t=!1){const s={x:_(n,"x","max")},a={reductionIndices:e,keepDims:t};return F.runKernel(cu,s,a)}const ba=D({max_:cI});/** 1481 * @license 1482 * Copyright 2020 Google Inc. All Rights Reserved. 1483 * Licensed under the Apache License, Version 2.0 (the "License"); 1484 * you may not use this file except in compliance with the License. 1485 * You may obtain a copy of the License at 1486 * 1487 * http://www.apache.org/licenses/LICENSE-2.0 1488 * 1489 * Unless required by applicable law or agreed to in writing, software 1490 * distributed under the License is distributed on an "AS IS" BASIS, 1491 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1492 * See the License for the specific language governing permissions and 1493 * limitations under the License. 1494 * ============================================================================= 1495 */function lI(n,e=null,t=!1){const s={x:_(n,"x","min")},a={axis:e,keepDims:t};return F.runKernel(pu,s,a)}const Kc=D({min_:lI});/** 1496 * @license 1497 * Copyright 2020 Google LLC. All Rights Reserved. 1498 * Licensed under the Apache License, Version 2.0 (the "License"); 1499 * you may not use this file except in compliance with the License. 1500 * You may obtain a copy of the License at 1501 * 1502 * http://www.apache.org/licenses/LICENSE-2.0 1503 * 1504 * Unless required by applicable law or agreed to in writing, software 1505 * distributed under the License is distributed on an "AS IS" BASIS, 1506 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1507 * See the License for the specific language governing permissions and 1508 * limitations under the License. 1509 * ============================================================================= 1510 */function dI(n,e){let t=_(n,"base","pow"),r=_(e,"exp","pow");[t,r]=ut(t,r);const s={a:t,b:r};return F.runKernel(Td,s)}const mo=D({pow_:dI});/** 1511 * @license 1512 * Copyright 2018 Google LLC. All Rights Reserved. 1513 * Licensed under the Apache License, Version 2.0 (the "License"); 1514 * you may not use this file except in compliance with the License. 1515 * You may obtain a copy of the License at 1516 * 1517 * http://www.apache.org/licenses/LICENSE-2.0 1518 * 1519 * Unless required by applicable law or agreed to in writing, software 1520 * distributed under the License is distributed on an "AS IS" BASIS, 1521 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1522 * See the License for the specific language governing permissions and 1523 * limitations under the License. 1524 * ============================================================================= 1525 */function Re(n,e){if((Tn(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"&&Tn(n)&&!(n instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Kr(n,[],[],e)}/** 1526 * @license 1527 * Copyright 2018 Google LLC. All Rights Reserved. 1528 * Licensed under the Apache License, Version 2.0 (the "License"); 1529 * you may not use this file except in compliance with the License. 1530 * You may obtain a copy of the License at 1531 * 1532 * http://www.apache.org/licenses/LICENSE-2.0 1533 * 1534 * Unless required by applicable law or agreed to in writing, software 1535 * distributed under the License is distributed on an "AS IS" BASIS, 1536 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1537 * See the License for the specific language governing permissions and 1538 * limitations under the License. 1539 * ============================================================================= 1540 */function pI(n){const t={x:_(n,"x","sqrt","float32")};return F.runKernel(jd,t)}const br=D({sqrt_:pI});/** 1541 * @license 1542 * Copyright 2019 Google LLC. All Rights Reserved. 1543 * Licensed under the Apache License, Version 2.0 (the "License");
1544 * you may not use this file except in compliance with the License. 1545 * You may obtain a copy of the License at 1546 * 1547 * http://www.apache.org/licenses/LICENSE-2.0 1548 * 1549 * Unless required by applicable law or agreed to in writing, software 1550 * distributed under the License is distributed on an "AS IS" BASIS, 1551 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1552 * See the License for the specific language governing permissions and 1553 * limitations under the License. 1554 * ============================================================================= 1555 */function hI(n){const e=_(n,"x","square"),t={};return F.runKernel("Square",{x:e},t)}const Gn=D({square_:hI});/** 1556 * @license 1557 * Copyright 2018 Google LLC. All Rights Reserved. 1558 * Licensed under the Apache License, Version 2.0 (the "License"); 1559 * you may not use this file except in compliance with the License. 1560 * You may obtain a copy of the License at 1561 * 1562 * http://www.apache.org/licenses/LICENSE-2.0 1563 * 1564 * Unless required by applicable law or agreed to in writing, software 1565 * distributed under the License is distributed on an "AS IS" BASIS, 1566 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1567 * See the License for the specific language governing permissions and 1568 * limitations under the License. 1569 * ============================================================================= 1570 */function fI(n,e=null,t=!1){let r=_(n,"x","sum");r.dtype==="bool"&&(r=rt(r,"int32"));const s={x:r},a={axis:e,keepDims:t};return F.runKernel(Tu,s,a)}const Ke=D({sum_:fI});/** 1571 * @license 1572 * Copyright 2018 Google LLC. All Rights Reserved. 1573 * Licensed under the Apache License, Version 2.0 (the "License"); 1574 * you may not use this file except in compliance with the License. 1575 * You may obtain a copy of the License at 1576 * 1577 * http://www.apache.org/licenses/LICENSE-2.0 1578 * 1579 * Unless required by applicable law or agreed to in writing, software 1580 * distributed under the License is distributed on an "AS IS" BASIS, 1581 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1582 * See the License for the specific language governing permissions and 1583 * limitations under the License. 1584 * ============================================================================= 1585 */function mI(n,e="euclidean",t=null,r=!1){n=_(n,"x","norm");const s=ig(n,e,t);let a=s.shape;if(r){const o=ot(t,n.shape);a=pt(s.shape,o)}return q(s,a)}function ig(n,e,t=null){if(n.rank===0)return ln(n);if(n.rank!==1&&t===null)return ig(q(n,[-1]),e,t);if(n.rank===1||typeof t=="number"||Array.isArray(t)&&t.length===1){if(e===1)return Ke(ln(n),t);if(e===1/0)return ba(ln(n),t);if(e===-1/0)return Kc(ln(n),t);if(e==="euclidean"||e===2)return br(Ke(mo(ln(n),Re(2,"int32")),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}if(Array.isArray(t)&&t.length===2){if(e===1)return ba(Ke(ln(n),t[0]),t[1]-1);if(e===1/0)return ba(Ke(ln(n),t[1]),t[0]);if(e===-1/0)return Kc(Ke(ln(n),t[1]),t[0]);if(e==="fro"||e==="euclidean")return br(Ke(Gn(n),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}throw new Error(`Error in norm: invalid axis: ${t}`)}const Wu=D({norm_:mI});/** 1586 * @license 1587 * Copyright 2022 Google LLC. All Rights Reserved. 1588 * Licensed under the Apache License, Version 2.0 (the "License"); 1589 * you may not use this file except in compliance with the License. 1590 * You may obtain a copy of the License at 1591 * 1592 * http://www.apache.org/licenses/LICENSE-2.0 1593 * 1594 * Unless required by applicable law or agreed to in writing, software 1595 * distributed under the License is distributed on an "AS IS" BASIS, 1596 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1597 * See the License for the specific language governing permissions and 1598 * limitations under the License. 1599 * ============================================================================= 1600 */function gI(n,e=null,t=!1){return Wu(n,"euclidean",e,t)}const yI=D({euclideanNorm_:gI});/** 1601 * @license 1602 * Copyright 2018 Google LLC. All Rights Reserved. 1603 * Licensed under the Apache License, Version 2.0 (the "License"); 1604 * you may not use this file except in compliance with the License. 1605 * You may obtain a copy of the License at 1606 * 1607 * http://www.apache.org/licenses/LICENSE-2.0 1608 * 1609 * Unless required by applicable law or agreed to in writing, softw
1609are 1610 * distributed under the License is distributed on an "AS IS" BASIS, 1611 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1612 * See the License for the specific language governing permissions and 1613 * limitations under the License. 1614 * ============================================================================= 1615 */function bI(n){const t={x:_(n,"x","exp")};return F.runKernel(Zl,t)}const xr=D({exp_:bI});/** 1616 * @license 1617 * Copyright 2020 Google LLC. All Rights Reserved. 1618 * Licensed under the Apache License, Version 2.0 (the "License"); 1619 * you may not use this file except in compliance with the License. 1620 * You may obtain a copy of the License at 1621 * 1622 * http://www.apache.org/licenses/LICENSE-2.0 1623 * 1624 * Unless required by applicable law or agreed to in writing, software 1625 * distributed under the License is distributed on an "AS IS" BASIS, 1626 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1627 * See the License for the specific language governing permissions and 1628 * limitations under the License. 1629 * ============================================================================= 1630 */function xI(n,e=0){const t=_(n,"x","expandDims","string_or_numeric");N(e<=t.rank,()=>"Axis must be <= rank of the tensor");const r={input:t},s={dim:e};return F.runKernel(Jl,r,s)}const nr=D({expandDims_:xI});/** 1631 * @license 1632 * Copyright 2018 Google LLC. All Rights Reserved. 1633 * Licensed under the Apache License, Version 2.0 (the "License"); 1634 * you may not use this file except in compliance with the License. 1635 * You may obtain a copy of the License at 1636 * 1637 * http://www.apache.org/licenses/LICENSE-2.0 1638 * 1639 * Unless required by applicable law or agreed to in writing, software 1640 * distributed under the License is distributed on an "AS IS" BASIS, 1641 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1642 * See the License for the specific language governing permissions and 1643 * limitations under the License. 1644 * ============================================================================= 1645 */function wI(n){const t={x:_(n,"x","expm1")};return F.runKernel(ed,t)}const vI=D({expm1_:wI});/** 1646 * @license 1647 * Copyright 2020 Google LLC. All Rights Reserved. 1648 * Licensed under the Apache License, Version 2.0 (the "License"); 1649 * you may not use this file except in compliance with the License. 1650 * You may obtain a copy of the License at 1651 * 1652 * http://www.apache.org/licenses/LICENSE-2.0 1653 * 1654 * Unless required by applicable law or agreed to in writing, software 1655 * distributed under the License is distributed on an "AS IS" BASIS, 1656 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1657 * See the License for the specific language governing permissions and 1658 * limitations under the License. 1659 * ============================================================================= 1660 */function II(n,e){const t=_(n,"x","tile","string_or_numeric");N(t.rank===e.length,()=>`Error in transpose: rank of input ${t.rank} must match length of reps ${e}.`);const r={x:t},s={reps:e};return F.runKernel(_o,r,s)}const io=D({tile_:II});/** 1661 * @license 1662 * Copyright 2020 Google LLC. All Rights Reserved. 1663 * Licensed under the Apache License, Version 2.0 (the "License"); 1664 * you may not use this file except in compliance with the License. 1665 * You may obtain a copy of the License at 1666 * 1667 * http://www.apache.org/licenses/LICENSE-2.0 1668 * 1669 * Unless required by applicable law or agreed to in writing, software 1670 * distributed under the License is distributed on an "AS IS" BASIS, 1671 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1672 * See the License for the specific language governing permissions and 1673 * limitations under the License. 1674 * ============================================================================= 1675 */function $I(n,e,t,r="float32"){e==null&&(e=n);const s=at([n,e],r),a=n<=e?n:e;for(let i=0;i<a;++i)s.set(1,i,i);const o=q(s.toTensor(),[n,e]);if(t==null)return o;if(t.length===1)return io(nr(o,0),[t[0],1,1]);if(t.length===2)return io(nr(nr(o,0),0),[t[0],t[1],1,1]);if(t.length===3)return io(nr(nr(nr(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 ug=D({eye_:$I});/** 1676 * @license 1677 * Copyright 2018 Google LLC. All Rights Reserved. 1678 * Licensed under the Apache License, Version 2.0 (the "License");
1679 * you may not use this file except in compliance with the License. 1680 * You may obtain a copy of the License at 1681 * 1682 * http://www.apache.org/licenses/LICENSE-2.0 1683 * 1684 * Unless required by applicable law or agreed to in writing, software 1685 * distributed under the License is distributed on an "AS IS" BASIS, 1686 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1687 * See the License for the specific language governing permissions and 1688 * limitations under the License. 1689 * ============================================================================= 1690 */function SI(n){const t={x:_(n,"x","floor","float32")};return F.runKernel(nd,t)}const cg=D({floor_:SI});/** 1691 * @license 1692 * Copyright 2018 Google LLC. All Rights Reserved. 1693 * Licensed under the Apache License, Version 2.0 (the "License"); 1694 * you may not use this file except in compliance with the License. 1695 * You may obtain a copy of the License at 1696 * 1697 * http://www.apache.org/licenses/LICENSE-2.0 1698 * 1699 * Unless required by applicable law or agreed to in writing, software 1700 * distributed under the License is distributed on an "AS IS" BASIS, 1701 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1702 * See the License for the specific language governing permissions and 1703 * limitations under the License. 1704 * ============================================================================= 1705 */function CI(n,e,t=0,r=0){const s=_(n,"x","gather"),a=_(e,"indices","gather","int32"),o={x:s,indices:a},i={axis:t,batchDims:r};return F.runKernel(sd,o,i)}const lg=D({gather_:CI});/** 1706 * @license 1707 * Copyright 2020 Google LLC. All Rights Reserved. 1708 * Licensed under the Apache License, Version 2.0 (the "License"); 1709 * you may not use this file except in compliance with the License. 1710 * You may obtain a copy of the License at 1711 * 1712 * http://www.apache.org/licenses/LICENSE-2.0 1713 * 1714 * Unless required by applicable law or agreed to in writing, software 1715 * distributed under the License is distributed on an "AS IS" BASIS, 1716 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1717 * See the License for the specific language governing permissions and 1718 * limitations under the License. 1719 * ============================================================================= 1720 */function _I(n,e){let t=_(n,"a","greater","string_or_numeric"),r=_(e,"b","greater","string_or_numeric");[t,r]=ut(t,r),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(ad,s)}const Uu=D({greater_:_I});/** 1721 * @license 1722 * Copyright 2020 Google LLC. All Rights Reserved. 1723 * Licensed under the Apache License, Version 2.0 (the "License"); 1724 * you may not use this file except in compliance with the License. 1725 * You may obtain a copy of the License at 1726 * 1727 * http://www.apache.org/licenses/LICENSE-2.0 1728 * 1729 * Unless required by applicable law or agreed to in writing, software 1730 * distributed under the License is distributed on an "AS IS" BASIS, 1731 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1732 * See the License for the specific language governing permissions and 1733 * limitations under the License. 1734 * ============================================================================= 1735 */function NI(n,e){let t=_(n,"a","greaterEqual","string_or_numeric"),r=_(e,"b","greaterEqual","string_or_numeric");[t,r]=ut(t,r),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(od,s)}const dg=D({greaterEqual_:NI});/** 1736 * @license 1737 * Copyright 2020 Google LLC. All Rights Reserved. 1738 * Licensed under the Apache License, Version 2.0 (the "License"); 1739 * you may not use this file except in compliance with the License. 1740 * You may obtain a copy of the License at 1741 * 1742 * http://www.apache.org/licenses/LICENSE-2.0 1743 * 1744 * Unless required by applicable law or agreed to in writing, software 1745 * distributed under the License is distributed on an "AS IS" BASIS, 1746 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1747 * See the License for the specific language governing permissions and 1748 * limitations under the License. 1749 * ============================================================================= 1750 */function TI(n){const t={input:_(n,"input","imag")};return F.runKernel(im,t)}const zu=D({imag_:TI});/** 1751 * @license 1752 * Copyright 2018 Google LLC. All Rights Reserved. 1753 * Licensed under the Apache License, Version 2.0 (the "License");
1754 * you may not use this file except in compliance with the License. 1755 * You may obtain a copy of the License at 1756 * 1757 * http://www.apache.org/licenses/LICENSE-2.0 1758 * 1759 * Unless required by applicable law or agreed to in writing, software 1760 * distributed under the License is distributed on an "AS IS" BASIS, 1761 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1762 * See the License for the specific language governing permissions and 1763 * limitations under the License. 1764 * ============================================================================= 1765 */function kI(n){const t={x:_(n,"x","isFinite")};return F.runKernel(id,t)}const EI=D({isFinite_:kI});/** 1766 * @license 1767 * Copyright 2018 Google LLC. All Rights Reserved. 1768 * Licensed under the Apache License, Version 2.0 (the "License"); 1769 * you may not use this file except in compliance with the License. 1770 * You may obtain a copy of the License at 1771 * 1772 * http://www.apache.org/licenses/LICENSE-2.0 1773 * 1774 * Unless required by applicable law or agreed to in writing, software 1775 * distributed under the License is distributed on an "AS IS" BASIS, 1776 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1777 * See the License for the specific language governing permissions and 1778 * limitations under the License. 1779 * ============================================================================= 1780 */function RI(n){const t={x:_(n,"x","isInf")};return F.runKernel(ud,t)}const AI=D({isInf_:RI});/** 1781 * @license 1782 * Copyright 2018 Google LLC. All Rights Reserved. 1783 * Licensed under the Apache License, Version 2.0 (the "License"); 1784 * you may not use this file except in compliance with the License. 1785 * You may obtain a copy of the License at 1786 * 1787 * http://www.apache.org/licenses/LICENSE-2.0 1788 * 1789 * Unless required by applicable law or agreed to in writing, software 1790 * distributed under the License is distributed on an "AS IS" BASIS, 1791 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1792 * See the License for the specific language governing permissions and 1793 * limitations under the License. 1794 * ============================================================================= 1795 */function DI(n){const t={x:_(n,"x","isNaN")};return F.runKernel(cd,t)}const OI=D({isNaN_:DI});/** 1796 * @license 1797 * Copyright 2020 Google LLC. All Rights Reserved. 1798 * Licensed under the Apache License, Version 2.0 (the "License"); 1799 * you may not use this file except in compliance with the License. 1800 * You may obtain a copy of the License at 1801 * 1802 * http://www.apache.org/licenses/LICENSE-2.0 1803 * 1804 * Unless required by applicable law or agreed to in writing, software 1805 * distributed under the License is distributed on an "AS IS" BASIS, 1806 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1807 * See the License for the specific language governing permissions and 1808 * limitations under the License. 1809 * ============================================================================= 1810 */function FI(n,e=.2){const r={x:_(n,"x","leakyRelu")},s={alpha:e};return F.runKernel(ou,r,s)}const pg=D({leakyRelu_:FI});/** 1811 * @license 1812 * Copyright 2020 Google LLC. All Rights Reserved. 1813 * Licensed under the Apache License, Version 2.0 (the "License"); 1814 * you may not use this file except in compliance with the License. 1815 * You may obtain a copy of the License at 1816 * 1817 * http://www.apache.org/licenses/LICENSE-2.0 1818 * 1819 * Unless required by applicable law or agreed to in writing, software 1820 * distributed under the License is distributed on an "AS IS" BASIS, 1821 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1822 * See the License for the specific language governing permissions and 1823 * limitations under the License. 1824 * ============================================================================= 1825 */function PI(n,e){let t=_(n,"a","less","string_or_numeric"),r=_(e,"b","less","string_or_numeric");[t,r]=ut(t,r),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(ld,s)}const Xc=D({less_:PI});/** 1826 * @license 1827 * Copyright 2020 Google LLC. All Rights Reserved. 1828 * Licensed under the Apache License, Version 2.0 (the "License");
1829 * you may not use this file except in compliance with the License. 1830 * You may obtain a copy of the License at 1831 * 1832 * http://www.apache.org/licenses/LICENSE-2.0 1833 * 1834 * Unless required by applicable law or agreed to in writing, software 1835 * distributed under the License is distributed on an "AS IS" BASIS, 1836 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1837 * See the License for the specific language governing permissions and 1838 * limitations under the License. 1839 * ============================================================================= 1840 */function LI(n,e){let t=_(n,"a","lessEqual","string_or_numeric"),r=_(e,"b","lessEqual","string_or_numeric");[t,r]=ut(t,r),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(dd,s)}const mp=D({lessEqual_:LI});/** 1841 * @license 1842 * Copyright 2018 Google LLC. All Rights Reserved. 1843 * Licensed under the Apache License, Version 2.0 (the "License"); 1844 * you may not use this file except in compliance with the License. 1845 * You may obtain a copy of the License at 1846 * 1847 * http://www.apache.org/licenses/LICENSE-2.0 1848 * 1849 * Unless required by applicable law or agreed to in writing, software 1850 * distributed under the License is distributed on an "AS IS" BASIS, 1851 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1852 * See the License for the specific language governing permissions and 1853 * limitations under the License. 1854 * ============================================================================= 1855 */function MI(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 F.runKernel(iu,{},r)}/** 1856 * @license 1857 * Copyright 2020 Google LLC. All Rights Reserved. 1858 * Licensed under the Apache License, Version 2.0 (the "License"); 1859 * you may not use this file except in compliance with the License. 1860 * You may obtain a copy of the License at 1861 * 1862 * http://www.apache.org/licenses/LICENSE-2.0 1863 * 1864 * Unless required by applicable law or agreed to in writing, software 1865 * distributed under the License is distributed on an "AS IS" BASIS, 1866 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1867 * See the License for the specific language governing permissions and 1868 * limitations under the License. 1869 * ============================================================================= 1870 */function BI(n,e=5,t=1,r=1,s=.5){const a=_(n,"x","localResponseNormalization");N(a.rank===4||a.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got 1871 rank ${a.rank}.`),N(xa(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let o=a,i=!1;a.rank===3&&(i=!0,o=q(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const c={x:o},l={depthRadius:e,bias:t,alpha:r,beta:s},u=F.runKernel(uu,c,l);return i?q(u,[u.shape[1],u.shape[2],u.shape[3]]):u}const VI=D({localResponseNormalization_:BI});/** 1872 * @license 1873 * Copyright 2018 Google LLC. All Rights Reserved. 1874 * Licensed under the Apache License, Version 2.0 (the "License"); 1875 * you may not use this file except in compliance with the License. 1876 * You may obtain a copy of the License at 1877 * 1878 * http://www.apache.org/licenses/LICENSE-2.0 1879 * 1880 * Unless required by applicable law or agreed to in writing, software 1881 * distributed under the License is distributed on an "AS IS" BASIS, 1882 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1883 * See the License for the specific language governing permissions and 1884 * limitations under the License. 1885 * ============================================================================= 1886 */function WI(n){const t={x:_(n,"x","log","float32")};return F.runKernel(pd,t)}const go=D({log_:WI});/** 1887 * @license 1888 * Copyright 2018 Google LLC. All Rights Reserved. 1889 * Licensed under the Apache License, Version 2.0 (the "License"); 1890 * you may not use this file except in compliance with the License. 1891 * You may obtain a copy of the License at 1892 * 1893 * http://www.apache.org/licenses/LICENSE-2.0 1894 * 1895 * Unless required by applicable law or agreed to in writing, software 1896 * distributed under the License is distributed on an "AS IS" BASIS, 1897 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1898 * See the License for the specific language governing permissions and 1899 * limitations under the License. 1900 * ============================================================================= 1901 */function UI(n){const t={x:_(n,"x","log1p")};return F.runKernel(hd,t)}const hg=D({log1p_:UI});/** 1902 * @license 1903 * Copyright 2018 Google LLC. All Rights Reserved. 1904 * Licensed under the Apache License, Version 2.0 (the "License");
1905 * you may not use this file except in compliance with the License. 1906 * You may obtain a copy of the License at 1907 * 1908 * http://www.apache.org/licenses/LICENSE-2.0 1909 * 1910 * Unless required by applicable law or agreed to in writing, software 1911 * distributed under the License is distributed on an "AS IS" BASIS, 1912 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1913 * See the License for the specific language governing permissions and 1914 * limitations under the License. 1915 * ============================================================================= 1916 */function zI(n,e){N(Ec(n),()=>"The f passed in variableGrads(f) must be a function"),N(e==null||Array.isArray(e)&&e.every(l=>l instanceof wi),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");const t=e!=null;if(!t){e=[];for(const l in F.registeredVariables)e.push(F.registeredVariables[l])}const r=t?e.filter(l=>!l.trainable):null,s=e.length;e=e.filter(l=>l.trainable),N(e.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`);const a=!0,{value:o,grads:i}=F.gradients(n,e,null,a);N(i.some(l=>l!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),N(o.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${o.rank} tensor`);const c={};return e.forEach((l,u)=>{i[u]!=null&&(c[l.name]=i[u])}),r!=null&&r.forEach(l=>c[l.name]=null),{value:o,grads:c}}function wr(n){return F.customGrad(n)}/** 1917 * @license 1918 * Copyright 2018 Google LLC. All Rights Reserved. 1919 * Licensed under the Apache License, Version 2.0 (the "License"); 1920 * you may not use this file except in compliance with the License. 1921 * You may obtain a copy of the License at 1922 * 1923 * http://www.apache.org/licenses/LICENSE-2.0 1924 * 1925 * Unless required by applicable law or agreed to in writing, software 1926 * distributed under the License is distributed on an "AS IS" BASIS, 1927 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1928 * See the License for the specific language governing permissions and 1929 * limitations under the License. 1930 * ============================================================================= 1931 */function GI(n){const t={x:_(n,"x","neg")};return F.runKernel(Sd,t)}const ar=D({neg_:GI});/** 1932 * @license 1933 * Copyright 2018 Google LLC. All Rights Reserved. 1934 * Licensed under the Apache License, Version 2.0 (the "License"); 1935 * you may not use this file except in compliance with the License. 1936 * You may obtain a copy of the License at 1937 * 1938 * http://www.apache.org/licenses/LICENSE-2.0 1939 * 1940 * Unless required by applicable law or agreed to in writing, software 1941 * distributed under the License is distributed on an "AS IS" BASIS, 1942 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1943 * See the License for the specific language governing permissions and 1944 * limitations under the License. 1945 * ============================================================================= 1946 */function HI(n){const t={x:_(n,"x","softplus")};return F.runKernel(Hd,t)}const fg=D({softplus_:HI});/** 1947 * @license 1948 * Copyright 2018 Google LLC. All Rights Reserved. 1949 * Licensed under the Apache License, Version 2.0 (the "License"); 1950 * you may not use this file except in compliance with the License. 1951 * You may obtain a copy of the License at 1952 * 1953 * http://www.apache.org/licenses/LICENSE-2.0 1954 * 1955 * Unless required by applicable law or agreed to in writing, software 1956 * distributed under the License is distributed on an "AS IS" BASIS, 1957 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1958 * See the License for the specific language governing permissions and 1959 * limitations under the License. 1960 * ============================================================================= 1961 */function jI(n){const e=_(n,"x","logSigmoid");return wr(r=>({value:ar(fg(ar(r))),gradFunc:o=>Z(o,Is(ar(r)))}))(e)}const qI=D({logSigmoid_:jI});/** 1962 * @license 1963 * Copyright 2020 Google LLC. All Rights Reserved. 1964 * Licensed under the Apache License, Version 2.0 (the "License");
1965 * you may not use this file except in compliance with the License. 1966 * You may obtain a copy of the License at 1967 * 1968 * http://www.apache.org/licenses/LICENSE-2.0 1969 * 1970 * Unless required by applicable law or agreed to in writing, software 1971 * distributed under the License is distributed on an "AS IS" BASIS, 1972 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1973 * See the License for the specific language governing permissions and 1974 * limitations under the License. 1975 * ============================================================================= 1976 */function KI(n,e){let t=_(n,"a","sub"),r=_(e,"b","sub");[t,r]=ut(t,r);const s={a:t,b:r};return F.runKernel(np,s)}const Ce=D({sub_:KI});/** 1977 * @license 1978 * Copyright 2020 Google Inc. All Rights Reserved. 1979 * Licensed under the Apache License, Version 2.0 (the "License"); 1980 * you may not use this file except in compliance with the License. 1981 * You may obtain a copy of the License at 1982 * 1983 * http://www.apache.org/licenses/LICENSE-2.0 1984 * 1985 * Unless required by applicable law or agreed to in writing, software 1986 * distributed under the License is distributed on an "AS IS" BASIS, 1987 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1988 * See the License for the specific language governing permissions and 1989 * limitations under the License. 1990 * ============================================================================= 1991 */function XI(n,e=-1){const t=_(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 wr((s,a)=>{const i=ba(s,e,!0),c=Ce(s,i),l=Ce(rt(c,"float32"),go(Ke(xr(c),e,!0)));return a([l]),{value:l,gradFunc:(d,p)=>{const[h]=p,m=!0,g=xr(h);return Ce(d,Z(Ke(d,e,m),g))}}})(t)}const YI=D({logSoftmax_:XI});/** 1992 * @license 1993 * Copyright 2020 Google LLC. All Rights Reserved. 1994 * Licensed under the Apache License, Version 2.0 (the "License"); 1995 * you may not use this file except in compliance with the License. 1996 * You may obtain a copy of the License at 1997 * 1998 * http://www.apache.org/licenses/LICENSE-2.0 1999 * 2000 * Unless required by applicable law or agreed to in writing, software 2001 * distributed under the License is distributed on an "AS IS" BASIS, 2002 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2003 * See the License for the specific language governing permissions and 2004 * limitations under the License. 2005 * ============================================================================= 2006 */function QI(n,e=null,t=!1){const r=_(n,"x","logSumExp"),s=ot(e,r.shape),a=ba(r,s,!0),o=Ce(r,a),i=xr(o),c=Ke(i,s),l=go(c),u=me(q(a,l.shape),l);if(t){const d=pt(u.shape,s);return q(u,d)}return u}const mg=D({logSumExp_:QI});/** 2007 * @license 2008 * Copyright 2020 Google LLC. All Rights Reserved. 2009 * Licensed under the Apache License, Version 2.0 (the "License"); 2010 * you may not use this file except in compliance with the License. 2011 * You may obtain a copy of the License at 2012 * 2013 * http://www.apache.org/licenses/LICENSE-2.0 2014 * 2015 * Unless required by applicable law or agreed to in writing, software 2016 * distributed under the License is distributed on an "AS IS" BASIS, 2017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2018 * See the License for the specific language governing permissions and 2019 * limitations under the License. 2020 * ============================================================================= 2021 */function ZI(n,e){const t=_(n,"a","logicalAnd","bool"),r=_(e,"b","logicalAnd","bool");ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(fd,s)}const $i=D({logicalAnd_:ZI});/** 2022 * @license 2023 * Copyright 2020 Google LLC. All Rights Reserved. 2024 * Licensed under the Apache License, Version 2.0 (the "License"); 2025 * you may not use this file except in compliance with the License. 2026 * You may obtain a copy of the License at 2027 * 2028 * http://www.apache.org/licenses/LICENSE-2.0 2029 * 2030 * Unless required by applicable law or agreed to in writing, software 2031 * distributed under the License is distributed on an "AS IS" BASIS, 2032 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2033 * See the License for the specific language governing permissions and 2034 * limitations under the License. 2035 * ============================================================================= 2036 */function JI(n){const t={x:_(n,"x","logicalNot","bool")};return F.runKernel(md,t)}const gg=D({logicalNot_:JI});/** 2037 * @license 2038 * Copyright 2020 Google LLC. All Rights Reserved. 2039 * Licensed under the Apache License, Version 2.0 (the "License");
2040 * you may not use this file except in compliance with the License. 2041 * You may obtain a copy of the License at 2042 * 2043 * http://www.apache.org/licenses/LICENSE-2.0 2044 * 2045 * Unless required by applicable law or agreed to in writing, software 2046 * distributed under the License is distributed on an "AS IS" BASIS, 2047 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2048 * See the License for the specific language governing permissions and 2049 * limitations under the License. 2050 * ============================================================================= 2051 */function e$(n,e){const t=_(n,"a","logicalOr","bool"),r=_(e,"b","logicalOr","bool");ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(gd,s)}const yg=D({logicalOr_:e$});/** 2052 * @license 2053 * Copyright 2020 Google LLC. All Rights Reserved. 2054 * Licensed under the Apache License, Version 2.0 (the "License"); 2055 * you may not use this file except in compliance with the License. 2056 * You may obtain a copy of the License at 2057 * 2058 * http://www.apache.org/licenses/LICENSE-2.0 2059 * 2060 * Unless required by applicable law or agreed to in writing, software 2061 * distributed under the License is distributed on an "AS IS" BASIS, 2062 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2063 * See the License for the specific language governing permissions and 2064 * limitations under the License. 2065 * ============================================================================= 2066 */function t$(n,e){const t=_(n,"a","logicalXor","bool"),r=_(e,"b","logicalXor","bool");return ke(t.shape,r.shape),$i(yg(n,e),gg($i(n,e)))}const n$=D({logicalXor_:t$});/** 2067 * @license 2068 * Copyright 2022 Google LLC. All Rights Reserved. 2069 * Licensed under the Apache License, Version 2.0 (the "License"); 2070 * you may not use this file except in compliance with the License. 2071 * You may obtain a copy of the License at 2072 * 2073 * http://www.apache.org/licenses/LICENSE-2.0 2074 * 2075 * Unless required by applicable law or agreed to in writing, software 2076 * distributed under the License is distributed on an "AS IS" BASIS, 2077 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2078 * See the License for the specific language governing permissions and 2079 * limitations under the License. 2080 * ============================================================================= 2081 */const ni=2147483648;function r$(n,e,t="left"){const r=_(n,"sortedSequence","searchSorted"),s=_(e,"values","searchSorted"),a=r.shape[r.shape.length-1],o=s.shape[s.shape.length-1],i=q(r,[-1,a]),c=q(s,[-1,o]);if(i.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(i.shape[0]!==c.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(H(c.shape)>=ni)throw new Error(`values tensor size must less than ${ni}`);if(i.shape[1]>=ni)throw new Error(`trailing dim_size must less than ${ni} for int32 output type, was ${i.shape[1]}`);const l={sortedSequence:i,values:c},u={side:t};return F.runKernel(Nu,l,u)}const gp=D({searchSorted_:r$});/** 2082 * @license 2083 * Copyright 2022 Google LLC. All Rights Reserved. 2084 * Licensed under the Apache License, Version 2.0 (the "License"); 2085 * you may not use this file except in compliance with the License. 2086 * You may obtain a copy of the License at 2087 * 2088 * http://www.apache.org/licenses/LICENSE-2.0 2089 * 2090 * Unless required by applicable law or agreed to in writing, software 2091 * distributed under the License is distributed on an "AS IS" BASIS, 2092 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2093 * See the License for the specific language governing permissions and 2094 * limitations under the License. 2095 * ============================================================================= 2096 */function s$(n,e){return gp(n,e,"left")}/** 2097 * @license 2098 * Copyright 2020 Google LLC. All Rights Reserved. 2099 * Licensed under the Apache License, Version 2.0 (the "License"); 2100 * you may not use this file except in compliance with the License. 2101 * You may obtain a copy of the License at 2102 * 2103 * http://www.apache.org/licenses/LICENSE-2.0 2104 * 2105 * Unless required by applicable law or agreed to in writing, softw
2105are 2106 * distributed under the License is distributed on an "AS IS" BASIS, 2107 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2108 * See the License for the specific language governing permissions and 2109 * limitations under the License. 2110 * ============================================================================= 2111 */function a$(n,e,t,r,s){const a=_(n,"x","maxPool"),o=1;let i=a,c=!1;a.rank===3&&(c=!0,i=q(a,[1,a.shape[0],a.shape[1],a.shape[2]])),N(i.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${i.rank}.`),N(Kt(t,o),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`),En("maxPool",r,s);const l={x:i},u={filterSize:e,strides:t,pad:r,dimRoundingMode:s},d=F.runKernel(lu,l,u);return c?q(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const bg=D({maxPool_:a$});/** 2112 * @license 2113 * Copyright 2020 Google LLC. All Rights Reserved. 2114 * Licensed under the Apache License, Version 2.0 (the "License"); 2115 * you may not use this file except in compliance with the License. 2116 * You may obtain a copy of the License at 2117 * 2118 * http://www.apache.org/licenses/LICENSE-2.0 2119 * 2120 * Unless required by applicable law or agreed to in writing, software 2121 * distributed under the License is distributed on an "AS IS" BASIS, 2122 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2123 * See the License for the specific language governing permissions and 2124 * limitations under the License. 2125 * ============================================================================= 2126 */function o$(n,e=[1,1,1],t,r,s,a="NDHWC"){const o=_(n,"x","maxPool3d");let i=o,c=!1;o.rank===4&&(c=!0,i=q(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),N(i.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`),N(a==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),En("maxPool3d",r,s);const l={x:i},u={filterSize:e,strides:t,pad:r,dimRoundingMode:s,dataFormat:a},d=F.runKernel(xd,l,u);return c?q(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const i$=D({maxPool3d_:o$});/** 2127 * @license 2128 * Copyright 2018 Google LLC. All Rights Reserved. 2129 * Licensed under the Apache License, Version 2.0 (the "License"); 2130 * you may not use this file except in compliance with the License. 2131 * You may obtain a copy of the License at 2132 * 2133 * http://www.apache.org/licenses/LICENSE-2.0 2134 * 2135 * Unless required by applicable law or agreed to in writing, software 2136 * distributed under the License is distributed on an "AS IS" BASIS, 2137 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2138 * See the License for the specific language governing permissions and 2139 * limitations under the License. 2140 * ============================================================================= 2141 */function u$(n,e,t,r,s=!1){const o={x:_(n,"x","maxPoolWithArgmax")},i={filterSize:e,strides:t,pad:r,includeBatchInIndex:s},c=F.runKernel(wd,o,i);return{result:c[0],indexes:c[1]}}const c$=D({maxPoolWithArgmax_:u$});/** 2142 * @license 2143 * Copyright 2020 Google LLC. All Rights Reserved. 2144 * Licensed under the Apache License, Version 2.0 (the "License"); 2145 * you may not use this file except in compliance with the License. 2146 * You may obtain a copy of the License at 2147 * 2148 * http://www.apache.org/licenses/LICENSE-2.0 2149 * 2150 * Unless required by applicable law or agreed to in writing, software 2151 * distributed under the License is distributed on an "AS IS" BASIS, 2152 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2153 * See the License for the specific language governing permissions and 2154 * limitations under the License. 2155 * ============================================================================= 2156 */function l$(n,e){let t=_(n,"a","maximum"),r=_(e,"b","maximum");[t,r]=ut(t,r),t.dtype==="bool"&&(t=rt(t,"int32"),r=rt(r,"int32")),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(bd,s)}const xg=D({maximum_:l$});/** 2157 * @license 2158 * Copyright 2020 Google Inc. All Rights Reserved. 2159 * Licensed under the Apache License, Version 2.0 (the "License"); 2160 * you may not use this file except in compliance with the License. 2161 * You may obtain a copy of the License at 2162 * 2163 * http://www.apache.org/licenses/LICENSE-2.0 2164 * 2165 * Unless required by applicable law or agreed to in writing, softw
2165are 2166 * distributed under the License is distributed on an "AS IS" BASIS, 2167 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2168 * See the License for the specific language governing permissions and 2169 * limitations under the License. 2170 * ============================================================================= 2171 */function d$(n,e=null,t=!1){const s={x:_(n,"x","mean")},a={axis:e,keepDims:t};return F.runKernel(du,s,a)}const Si=D({mean_:d$});/** 2172 * @license 2173 * Copyright 2018 Google LLC. All Rights Reserved. 2174 * Licensed under the Apache License, Version 2.0 (the "License"); 2175 * you may not use this file except in compliance with the License. 2176 * You may obtain a copy of the License at 2177 * 2178 * http://www.apache.org/licenses/LICENSE-2.0 2179 * 2180 * Unless required by applicable law or agreed to in writing, software 2181 * distributed under the License is distributed on an "AS IS" BASIS, 2182 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2183 * See the License for the specific language governing permissions and 2184 * limitations under the License. 2185 * ============================================================================= 2186 */function Es(n,e="float32"){if(fn(n),e==="complex64"){const r=Es(n,"float32"),s=Es(n,"float32");return zr(r,s)}const t=Ur(H(n),e);return F.makeTensor(t,n,e)}/** 2187 * @license 2188 * Copyright 2018 Google LLC. All Rights Reserved. 2189 * Licensed under the Apache License, Version 2.0 (the "License"); 2190 * you may not use this file except in compliance with the License. 2191 * You may obtain a copy of the License at 2192 * 2193 * http://www.apache.org/licenses/LICENSE-2.0 2194 * 2195 * Unless required by applicable law or agreed to in writing, software 2196 * distributed under the License is distributed on an "AS IS" BASIS, 2197 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2198 * See the License for the specific language governing permissions and 2199 * limitations under the License. 2200 * ============================================================================= 2201 */function ws(n,e="float32"){if(fn(n),e==="complex64"){const r=ws(n,"float32"),s=Es(n,"float32");return zr(r,s)}const t=jf(H(n),e);return F.makeTensor(t,n,e)}/** 2202 * @license 2203 * Copyright 2021 Google LLC. All Rights Reserved. 2204 * Licensed under the Apache License, Version 2.0 (the "License"); 2205 * you may not use this file except in compliance with the License. 2206 * You may obtain a copy of the License at 2207 * 2208 * http://www.apache.org/licenses/LICENSE-2.0 2209 * 2210 * Unless required by applicable law or agreed to in writing, software 2211 * distributed under the License is distributed on an "AS IS" BASIS, 2212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2213 * See the License for the specific language governing permissions and 2214 * limitations under the License. 2215 * ============================================================================= 2216 */function p$(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,"x","meshgrid",n instanceof dt?n.dtype:"float32");if(e===void 0)return[r];let s=_(e,"y","meshgrid",e instanceof dt?e.dtype:"float32");const a=H(r.shape),o=H(s.shape);return t==="xy"?(r=q(r,[1,-1]),s=q(s,[-1,1]),[Ue(ws([o,1],r.dtype),r),Ue(s,ws([1,a],s.dtype))]):(r=q(r,[-1,1]),s=q(s,[1,-1]),[Ue(r,ws([1,o],r.dtype)),Ue(ws([a,1],s.dtype),s)])}/** 2217 * @license 2218 * Copyright 2020 Google LLC. All Rights Reserved. 2219 * Licensed under the Apache License, Version 2.0 (the "License"); 2220 * you may not use this file except in compliance with the License. 2221 * You may obtain a copy of the License at 2222 * 2223 * http://www.apache.org/licenses/LICENSE-2.0 2224 * 2225 * Unless required by applicable law or agreed to in writing, software 2226 * distributed under the License is distributed on an "AS IS" BASIS, 2227 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2228 * See the License for the specific language governing permissions and 2229 * limitations under the License. 2230 * ============================================================================= 2231 */function h$(n,e){let t=_(n,"a","minimum"),r=_(e,"b","minimum");[t,r]=ut(t,r),t.dtype==="bool"&&(t=rt(t,"int32"),r=rt(r,"int32")),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(vd,s)}const Ci=D({minimum_:h$});/** 2232 * @license 2233 * Copyright 2020 Google LLC. All Rights Reserved. 2234 * Licensed under the Apache License, Version 2.0 (the "License");
2235 * you may not use this file except in compliance with the License. 2236 * You may obtain a copy of the License at 2237 * 2238 * http://www.apache.org/licenses/LICENSE-2.0 2239 * 2240 * Unless required by applicable law or agreed to in writing, software 2241 * distributed under the License is distributed on an "AS IS" BASIS, 2242 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2243 * See the License for the specific language governing permissions and 2244 * limitations under the License. 2245 * ============================================================================= 2246 */function f$(n,e,t){N(t==="reflect"||t==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${t}.`);const r=_(n,"x","mirrorPad");if(r.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");N(e.length===r.rank,()=>`Padding doesn't match input. Must be ${r.rank}. Got ${e.length}.`);const s=t==="reflect"?1:0;for(let i=0;i<r.rank;i++)N(e[i].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),N(e[i][0]>=0&&e[i][0]<=r.shape[i]-s&&e[i][1]>=0&&e[i][1]<=r.shape[i]-s,()=>`Padding in dimension ${i} cannot be greater than or equal to ${r.shape[i]-s} or less than 0 for input of shape ${r.shape}`);const a={paddings:e,mode:t},o={x:r};return F.runKernel(hu,o,a)}const m$=D({mirrorPad_:f$});/** 2247 * @license 2248 * Copyright 2020 Google LLC. All Rights Reserved. 2249 * Licensed under the Apache License, Version 2.0 (the "License"); 2250 * you may not use this file except in compliance with the License. 2251 * You may obtain a copy of the License at 2252 * 2253 * http://www.apache.org/licenses/LICENSE-2.0 2254 * 2255 * Unless required by applicable law or agreed to in writing, software 2256 * distributed under the License is distributed on an "AS IS" BASIS, 2257 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2258 * See the License for the specific language governing permissions and 2259 * limitations under the License. 2260 * ============================================================================= 2261 */function g$(n,e){let t=_(n,"a","mod"),r=_(e,"b","mod");[t,r]=ut(t,r);const s={a:t,b:r};return F.runKernel(Id,s)}const y$=D({mod_:g$});/** 2262 * @license 2263 * Copyright 2020 Google LLC. All Rights Reserved. 2264 * Licensed under the Apache License, Version 2.0 (the "License"); 2265 * you may not use this file except in compliance with the License. 2266 * You may obtain a copy of the License at 2267 * 2268 * http://www.apache.org/licenses/LICENSE-2.0 2269 * 2270 * Unless required by applicable law or agreed to in writing, software 2271 * distributed under the License is distributed on an "AS IS" BASIS, 2272 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2273 * See the License for the specific language governing permissions and 2274 * limitations under the License. 2275 * ============================================================================= 2276 */function b$(n,e=null,t=!1){n=_(n,"x","moments");const r=ot(e,n.shape),s=Si(n,r,t);let a=s.shape;t||(a=pt(s.shape,r));const o=Gn(Ce(rt(n,"float32"),q(s,a))),i=Si(o,r,t);return{mean:s,variance:i}}const x$=D({moments_:b$});function w$(n,e,t,r){const s=_(e,"data","multiRNNCell"),a=vi(t,"c","multiRNNCell"),o=vi(r,"h","multiRNNCell");let i=s;const c=[];for(let d=0;d<n.length;d++){const p=n[d](i,a[d],o[d]);c.push(p[0]),c.push(p[1]),i=p[1]}const l=[],u=[];for(let d=0;d<c.length;d+=2)l.push(c[d]),u.push(c[d+1]);return[l,u]}const v$=D({multiRNNCell_:w$});/** 2277 * @license 2278 * Copyright 2020 Google LLC. All Rights Reserved. 2279 * Licensed under the Apache License, Version 2.0 (the "License"); 2280 * you may not use this file except in compliance with the License. 2281 * You may obtain a copy of the License at 2282 * 2283 * http://www.apache.org/licenses/LICENSE-2.0 2284 * 2285 * Unless required by applicable law or agreed to in writing, software 2286 * distributed under the License is distributed on an "AS IS" BASIS, 2287 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2288 * See the License for the specific language governing permissions and 2289 * limitations under the License. 2290 * ============================================================================= 2291 */function I$(n,e,t,r=!1){const s=_(n,"logits","multinomial"),a=s.size,o=s.rank;if(a<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${a}.`);if(o>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`);t=t||Math.random();const c={logits:o===1?q(s,[1,-1]):s},l={numSamples:e,seed:t,normalized:r},u=F.runKernel(fu,c,l);return o===1?q(u,[u.size]):u}const $$=D({multinomial_:I$});/** 2292 * @license 2293 * Copyright 2020 Google LLC. All Rights Reserved. 2294 * Licensed under the Apache License, Version 2.0 (the "License");
2295 * you may not use this file except in compliance with the License. 2296 * You may obtain a copy of the License at 2297 * 2298 * http://www.apache.org/licenses/LICENSE-2.0 2299 * 2300 * Unless required by applicable law or agreed to in writing, software 2301 * distributed under the License is distributed on an "AS IS" BASIS, 2302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2303 * See the License for the specific language governing permissions and 2304 * limitations under the License. 2305 * ============================================================================= 2306 */function S$(n,e){let t=_(n,"a","notEqual","string_or_numeric"),r=_(e,"b","notEqual","string_or_numeric");[t,r]=ut(t,r),ke(t.shape,r.shape);const s={a:t,b:r};return F.runKernel(Cd,s)}const wg=D({notEqual_:S$});/** 2307 * @license 2308 * Copyright 2020 Google LLC. All Rights Reserved. 2309 * Licensed under the Apache License, Version 2.0 (the "License"); 2310 * you may not use this file except in compliance with the License. 2311 * You may obtain a copy of the License at 2312 * 2313 * http://www.apache.org/licenses/LICENSE-2.0 2314 * 2315 * Unless required by applicable law or agreed to in writing, software 2316 * distributed under the License is distributed on an "AS IS" BASIS, 2317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2318 * See the License for the specific language governing permissions and 2319 * limitations under the License. 2320 * ============================================================================= 2321 */function C$(n,e,t=1,r=0,s="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const o={indices:_(n,"indices","oneHot","int32")},i={dtype:s,depth:e,onValue:t,offValue:r};return F.runKernel(bu,o,i)}const _$=D({oneHot_:C$});/** 2322 * @license 2323 * Copyright 2018 Google LLC. All Rights Reserved. 2324 * Licensed under the Apache License, Version 2.0 (the "License"); 2325 * you may not use this file except in compliance with the License. 2326 * You may obtain a copy of the License at 2327 * 2328 * http://www.apache.org/licenses/LICENSE-2.0 2329 * 2330 * Unless required by applicable law or agreed to in writing, software 2331 * distributed under the License is distributed on an "AS IS" BASIS, 2332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2333 * See the License for the specific language governing permissions and 2334 * limitations under the License. 2335 * ============================================================================= 2336 */function N$(n){const t={x:_(n,"x","onesLike")};return F.runKernel(_d,t)}const T$=D({onesLike_:N$});function k$(n,e){const t=_(n,"v1","outerProduct"),r=_(e,"v2","outerProduct");N(t.rank===1&&r.rank===1,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${t.rank} and ${r.rank}.`);const s=q(t,[-1,1]),a=q(r,[1,-1]);return Ue(s,a)}const E$=D({outerProduct_:k$});/** 2337 * @license 2338 * Copyright 2020 Google LLC. All Rights Reserved. 2339 * Licensed under the Apache License, Version 2.0 (the "License"); 2340 * you may not use this file except in compliance with the License. 2341 * You may obtain a copy of the License at 2342 * 2343 * http://www.apache.org/licenses/LICENSE-2.0 2344 * 2345 * Unless required by applicable law or agreed to in writing, software 2346 * distributed under the License is distributed on an "AS IS" BASIS, 2347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2348 * See the License for the specific language governing permissions and 2349 * limitations under the License. 2350 * ============================================================================= 2351 */function R$(n,e,t=0){const r=_(n,"x","pad");if(r.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const s={paddings:e,constantValue:t},a={x:r};return F.runKernel(xu,a,s)}const Ro=D({pad_:R$});function A$(n,e,t=0){return N(e.length===2,()=>"Invalid number of paddings. Must be length of 2."),Ro(n,[e],t)}const D$=D({pad1d_:A$});function O$(n,e,t=0){return N(e.length===2&&e[0].length===2&&e[1].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),Ro(n,e,t)}const F$=D({pad2d_:O$});function P$(n,e,t=0){return N(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."),Ro(n,e,t)}const L$=D({pad3d_:P$});function M$(n,e,t=0){return N(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."),Ro(n,e,t)}const B$=D({pad4d_:M$});/** 2352 * @license 2353 * Copyright 2020 Google LLC. All Rights Reserved. 2354 * Licensed under the Apache License, Version 2.0 (the "License");
2355 * you may not use this file except in compliance with the License. 2356 * You may obtain a copy of the License at 2357 * 2358 * http://www.apache.org/licenses/LICENSE-2.0 2359 * 2360 * Unless required by applicable law or agreed to in writing, software 2361 * distributed under the License is distributed on an "AS IS" BASIS, 2362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2363 * See the License for the specific language governing permissions and 2364 * limitations under the License. 2365 * ============================================================================= 2366 */function V$(n,e,t){const r=_(n,"x","spaceToBatchND");N(r.rank>=1+e.length,()=>`input rank ${r.rank} should be > than [blockShape] ${e.length}`),N(t.length===e.length,()=>`paddings.shape[0] ${t.length} must be equal to [blockShape] ${e.length}`),N(r.shape.reduce((o,i,c)=>c>0&&c<=e.length?o&&(i+t[c-1][0]+t[c-1][1])%e[c-1]===0:o,!0),()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${t.toString()} must be divisible by blockShapes ${e.toString()}`);const s={x:r},a={blockShape:e,paddings:t};return F.runKernel(qd,s,a)}const vg=D({spaceToBatchND_:V$});/** 2367 * @license 2368 * Copyright 2018 Google LLC. All Rights Reserved. 2369 * Licensed under the Apache License, Version 2.0 (the "License"); 2370 * you may not use this file except in compliance with the License. 2371 * You may obtain a copy of the License at 2372 * 2373 * http://www.apache.org/licenses/LICENSE-2.0 2374 * 2375 * Unless required by applicable law or agreed to in writing, software 2376 * distributed under the License is distributed on an "AS IS" BASIS, 2377 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2378 * See the License for the specific language governing permissions and 2379 * limitations under the License. 2380 * ============================================================================= 2381 */function W$(n,e,t,r,s,a,o){s==null&&(s=[1,1]),a==null&&(a=1),r===0&&(r="valid");const i=_(n,"x","maxPool");let c=i,l=!1;i.rank===3&&(l=!0,c=q(i,[1,i.shape[0],i.shape[1],i.shape[2]])),N(Kt(a,s),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${a} and dilations '${s}'`);const u=kn(c.shape,e,a,s,r),d=[u.dilationHeight,u.dilationWidth];let p;r==="same"?p=z$([u.filterHeight,u.filterWidth],d):p=[[0,0],[0,0]];const h=d[0]===1&&d[1]===1,[m,g]=U$([u.inHeight,u.inWidth],d,p),y=h?r:"valid",b=h?c:vg(c,d,m),$=(t==="avg"?()=>Zm(b,e,a,y,o):()=>bg(b,e,a,y,o))(),S=h?$:Jm($,d,g);return l?q(S,[S.shape[1],S.shape[2],S.shape[3]]):S}function U$(n,e,t){const r=t.map(u=>u[0]),s=t.map(u=>u[1]),a=n.concat(r,s),o=e.map((u,d)=>(u-a[d]%u)%u),i=s.map((u,d)=>u+o[d]),c=e.map((u,d)=>[r[d],i[d]]),l=e.map((u,d)=>[0,o[d]]);return[c,l]}function z$(n,e){const r=n.map((o,i)=>o+(o-1)*(e[i]-1)).map(o=>o-1),s=r.map(o=>Math.floor(o/2)),a=r.map((o,i)=>o-s[i]);return r.map((o,i)=>[s[i],a[i]])}const G$=D({pool_:W$});/** 2382 * @license 2383 * Copyright 2020 Google LLC. All Rights Reserved. 2384 * Licensed under the Apache License, Version 2.0 (the "License"); 2385 * you may not use this file except in compliance with the License. 2386 * You may obtain a copy of the License at 2387 * 2388 * http://www.apache.org/licenses/LICENSE-2.0 2389 * 2390 * Unless required by applicable law or agreed to in writing, software 2391 * distributed under the License is distributed on an "AS IS" BASIS, 2392 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2393 * See the License for the specific language governing permissions and 2394 * limitations under the License. 2395 * ============================================================================= 2396 */function H$(n,e){const t=_(n,"x","prelu"),r=_(e,"alpha","prelu"),s={x:t,alpha:r};return F.runKernel(wu,s)}const Ig=D({prelu_:H$});/** 2397 * @license 2398 * Copyright 2020 Google LLC. All Rights Reserved. 2399 * Licensed under the Apache License, Version 2.0 (the "License"); 2400 * you may not use this file except in compliance with the License. 2401 * You may obtain a copy of the License at 2402 * 2403 * http://www.apache.org/licenses/LICENSE-2.0 2404 * 2405 * Unless required by applicable law or agreed to in writing, software 2406 * distributed under the License is distributed on an "AS IS" BASIS, 2407 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2408 * See the License for the specific language governing permissions and 2409 * limitations under the License. 2410 * ============================================================================= 2411 */function j$(n,e=null,t=!1){let r=_(n,"x","prod");r.dtype==="bool"&&(r=rt(r,"int32"));const s={x:r},a={axis:e,keepDims:t};return F.runKernel(vu,s,a)}const q$=D({prod_:j$});/** 2412 * @license 2413 * Copyright 2022 Google LLC. All Rights Reserved. 2414 * Licensed under the Apache License, Version 2.0 (the "License");
2415 * you may not use this file except in compliance with the License. 2416 * You may obtain a copy of the License at 2417 * 2418 * http://www.apache.org/licenses/LICENSE-2.0 2419 * 2420 * Unless required by applicable law or agreed to in writing, software 2421 * distributed under the License is distributed on an "AS IS" BASIS, 2422 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2423 * See the License for the specific language governing permissions and 2424 * limitations under the License. 2425 * ============================================================================= 2426 */function K$(n,e,t,r){const s=n.map((u,d)=>_(u,`tensors${d}`,"raggedGather","int32")),a=_(e,"paramsDenseValues","raggedGather"),o=_(t,"indices","raggedGather","int32"),i={paramsNestedSplits:s,paramsDenseValues:a,indices:o},c={outputRaggedRank:r},l=F.runKernel(lm,i,c);return{outputNestedSplits:l.slice(0,l.length-1),outputDenseValues:l[l.length-1]}}const X$=D({raggedGather_:K$});/** 2427 * @license 2428 * Copyright 2022 Google LLC. 2429 * Licensed under the Apache License, Version 2.0 (the "License"); 2430 * you may not use this file except in compliance with the License. 2431 * You may obtain a copy of the License at 2432 * 2433 * http://www.apache.org/licenses/LICENSE-2.0 2434 * 2435 * Unless required by applicable law or agreed to in writing, software 2436 * distributed under the License is distributed on an "AS IS" BASIS, 2437 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2438 * See the License for the specific language governing permissions and 2439 * limitations under the License. 2440 * ============================================================================= 2441 */function Y$(n,e,t){const r=_(n,"starts","raggedRange"),s=_(e,"limits","raggedRange",r.dtype),a=_(t,"deltas","raggedRange",r.dtype),o={starts:r,limits:s,deltas:a},i=F.runKernel(dm,o);return{rtNestedSplits:i[0],rtDenseValues:i[1]}}const Q$=D({raggedRange_:Y$});/** 2442 * @license 2443 * Copyright 2022 Google LLC. All Rights Reserved. 2444 * Licensed under the Apache License, Version 2.0 (the "License"); 2445 * you may not use this file except in compliance with the License. 2446 * You may obtain a copy of the License at 2447 * 2448 * http://www.apache.org/licenses/LICENSE-2.0 2449 * 2450 * Unless required by applicable law or agreed to in writing, software 2451 * distributed under the License is distributed on an "AS IS" BASIS, 2452 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2453 * See the License for the specific language governing permissions and 2454 * limitations under the License. 2455 * ============================================================================= 2456 */function Z$(n,e,t,r,s){const a=_(n,"shape","raggedTensorToTensor","int32"),o=_(e,"values","raggedTensorToTensor"),i=_(t,"defaultValue","raggedTensorToTensor",o.dtype),c=r.map((d,p)=>_(d,`tensors${p}`,"raggedTensorToTensor","int32")),l={shape:a,values:o,defaultValue:i,rowPartitionTensors:c},u={rowPartitionTypes:s};return F.runKernel(pm,l,u)}const J$=D({raggedTensorToTensor_:Z$});/** 2457 * @license 2458 * Copyright 2020 Google LLC. All Rights Reserved. 2459 * Licensed under the Apache License, Version 2.0 (the "License"); 2460 * you may not use this file except in compliance with the License. 2461 * You may obtain a copy of the License at 2462 * 2463 * http://www.apache.org/licenses/LICENSE-2.0 2464 * 2465 * Unless required by applicable law or agreed to in writing, software 2466 * distributed under the License is distributed on an "AS IS" BASIS, 2467 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2468 * See the License for the specific language governing permissions and 2469 * limitations under the License. 2470 * ============================================================================= 2471 */function eS(n,e,t){fn(n);const r=H(n);let s=null;if(t==null||t==="float32")s=new Float32Array(r);else if(t==="int32")s=new Int32Array(r);else if(t==="bool")s=new Uint8Array(r);else throw new Error(`Unknown data type ${t}`);for(let a=0;a<r;a++)s[a]=e();return F.makeTensor(s,n,t)}const tS=D({rand_:eS});var $g={exports:{}};(function(n){(function(e,t,r){function s(c){var l=this,u=i();l.next=function(){var d=2091639*l.s0+l.c*23283064365386963e-26;return l.s0=l.s1,l.s1=l.s2,l.s2=d-(l.c=d|0)},l.c=1,l.s0=u(" "),l.s1=u(" "),l.s2=u(" "),l.s0-=u(c),l.s0<0&&(l.s0+=1),l.s1-=u(c),l.s1<0&&(l.s1+=1),l.s2-=u(c),l.s2<0&&(l.s2+=1),u=null}function a(c,l){return l.c=c.c,l.s0=c.s0,l.s1=c.s1,l.s2=c.s2,l}function o(c,l){var u=new s(c),d=l&&l.state,p=u.next;return p.int32=function(){return u.next()*4294967296|0},p.double=function(){return p()+(p()*2097152|0)*11102230246251565e-32},p.quick=p,d&&(typeof d=="object"&&a(d,u),p.state=function(){return a(u,{})}),p}function i(){var c=4022871197,l=function(u){u=String(u);for(var d=0;d<u.length;d++){c+=u.charCodeAt(d);var p=.02519603282416938*c;c=p>>>0,p-=c,p*=c,c=p>>>0,p-=c,c+=p*4294967296}return(c>>>0)*23283064365386963e-26};return l}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}
vendor: 4,477 bytes, line 2471
2471):this.alea=o})(Nn,n,!1)})($g);var Sg={exports:{}};(function(n){(function(e,t,r){function s(i){var c=this,l="";c.x=0,c.y=0,c.z=0,c.w=0,c.next=function(){var d=c.x^c.x<<11;return c.x=c.y,c.y=c.z,c.z=c.w,c.w^=c.w>>>19^d^d>>>8},i===(i|0)?c.x=i:l+=i;for(var u=0;u<l.length+64;u++)c.x^=l.charCodeAt(u)|0,c.next()}function a(i,c){return c.x=i.x,c.y=i.y,c.z=i.z,c.w=i.w,c}function o(i,c){var l=new s(i),u=c&&c.state,d=function(){return(l.next()>>>0)/4294967296};return d.double=function(){do var p=l.next()>>>11,h=(l.next()>>>0)/4294967296,m=(p+h)/(1<<21);while(m===0);return m},d.int32=l.next,d.quick=d,u&&(typeof u=="object"&&a(u,l),d.state=function(){return a(l,{})}),d}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(Nn,n,!1)})(Sg);var Cg={exports:{}};(function(n){(function(e,t,r){function s(i){var c=this,l="";c.next=function(){var d=c.x^c.x>>>2;return c.x=c.y,c.y=c.z,c.z=c.w,c.w=c.v,(c.d=c.d+362437|0)+(c.v=c.v^c.v<<4^(d^d<<1))|0},c.x=0,c.y=0,c.z=0,c.w=0,c.v=0,i===(i|0)?c.x=i:l+=i;for(var u=0;u<l.length+64;u++)c.x^=l.charCodeAt(u)|0,u==l.length&&(c.d=c.x<<10^c.x>>>4),c.next()}function a(i,c){return c.x=i.x,c.y=i.y,c.z=i.z,c.w=i.w,c.v=i.v,c.d=i.d,c}function o(i,c){var l=new s(i),u=c&&c.state,d=function(){return(l.next()>>>0)/4294967296};return d.double=function(){do var p=l.next()>>>11,h=(l.next()>>>0)/4294967296,m=(p+h)/(1<<21);while(m===0);return m},d.int32=l.next,d.quick=d,u&&(typeof u=="object"&&a(u,l),d.state=function(){return a(l,{})}),d}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(Nn,n,!1)})(Cg);var _g={exports:{}};(function(n){(function(e,t,r){function s(i){var c=this;c.next=function(){var u=c.x,d=c.i,p,h;return p=u[d],p^=p>>>7,h=p^p<<24,p=u[d+1&7],h^=p^p>>>10,p=u[d+3&7],h^=p^p>>>3,p=u[d+4&7],h^=p^p<<7,p=u[d+7&7],p=p^p<<13,h^=p^p<<9,u[d]=h,c.i=d+1&7,h};function l(u,d){var p,h=[];if(d===(d|0))h[0]=d;else for(d=""+d,p=0;p<d.length;++p)h[p&7]=h[p&7]<<15^d.charCodeAt(p)+h[p+1&7]<<13;for(;h.length<8;)h.push(0);for(p=0;p<8&&h[p]===0;++p);for(p==8?h[7]=-1:h[p],u.x=h,u.i=0,p=256;p>0;--p)u.next()}l(c,i)}function a(i,c){return c.x=i.x.slice(),c.i=i.i,c}function o(i,c){i==null&&(i=+new Date);var l=new s(i),u=c&&c.state,d=function(){return(l.next()>>>0)/4294967296};return d.double=function(){do var p=l.next()>>>11,h=(l.next()>>>0)/4294967296,m=(p+h)/(1<<21);while(m===0);return m},d.int32=l.next,d.quick=d,u&&(u.x&&a(u,l),d.state=function(){return a(l,{})}),d}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(Nn,n,!1)})(_g);var Ng={exports:{}};(function(n){(function(e,t,r){function s(i){var c=this;c.next=function(){var u=c.w,d=c.X,p=c.i,h,m;return c.w=u=u+1640531527|0,m=d[p+34&127],h=d[p=p+1&127],m^=m<<13,h^=h<<17,m^=m>>>15,h^=h>>>12,m=d[p]=m^h,c.i=p,m+(u^u>>>16)|0};function l(u,d){var p,h,m,g,y,b=[],v=128;for(d===(d|0)?(h=d,d=null):(d=d+"\0",h=0,v=Math.max(v,d.length)),m=0,g=-32;g<v;++g)d&&(h^=d.charCodeAt((g+32)%d.length)),g===0&&(y=h),h^=h<<10,h^=h>>>15,h^=h<<4,h^=h>>>13,g>=0&&(y=y+1640531527|0,p=b[g&127]^=h+y,m=p==0?m+1:0);for(m>=128&&(b[(d&&d.length||0)&127]=-1),m=127,g=4*128;g>0;--g)h=b[m+34&127],p=b[m=m+1&127],h^=h<<13,p^=p<<17,h^=h>>>15,p^=p>>>12,b[m]=h^p;u.w=y,u.X=b,u.i=m}l(c,i)}function a(i,c){return c.i=i.i,c.w=i.w,c.X=i.X.slice(),c}function o(i,c){i==null&&(i=+new Date);var l=new s(i),u=c&&c.state,d=function(){return(l.next()>>>0)/4294967296};return d.double=function(){do var p=l.next()>>>11,h=(l.next()>>>0)/4294967296,m=(p+h)/(1<<21);while(m===0);return m},d.int32=l.next,d.quick=d,u&&(u.X&&a(u,l),d.state=function(){return a(l,{})}),d}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(Nn,n,!1)})(Ng);var Tg={exports:{}};(function(n){(function(e,t,r){function s(i){var c=this,l="";c.next=function(){var d=c.b,p=c.c,h=c.d,m=c.a;return d=d<<25^d>>>7^p,p=p-h|0,h=h<<24^h>>>8^m,m=m-d|0,c.b=d=d<<20^d>>>12^p,c.c=p=p-h|0,c.d=h<<16^p>>>16^m,c.a=m-d|0},c.a=0,c.b=0,c.c=-1640531527,c.d=1367130551,i===Math.floor(i)?(c.a=i/4294967296|0,c.b=i|0):l+=i;for(var u=0;u<l.length+20;u++)c.b^=l.charCodeAt(u)|0,c.next()}function a(i,c){return c.a=i.a,c.b=i.b,c.c=i.c,c.d=i.d,c}function o(i,c){var l=new s(i),u=c&&c.state,d=function(){return(l.next()>>>0)/4294967296};return d.double=function(){do var p=l.next()>>>11,h=(l.next()>>>0)/4294967296,m=(p+h)/(1<<21);while(m===0);return m},d.int32=l.next,d.quick=d,u&&(typeof u=="object"&&a(u,l),d.state=function(){return a(l,{})}),d}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}
vendor: 1,217 bytes, line 2471
2471):this.tychei=o})(Nn,n,!1)})(Tg);var kg={exports:{}};const nS={},rS=Object.freeze(Object.defineProperty({__proto__:null,default:nS},Symbol.toStringTag,{value:"Module"})),Fr=k0(rS);(function(n){(function(e,t,r){var s=256,a=6,o=52,i="random",c=r.pow(s,a),l=r.pow(2,o),u=l*2,d=s-1,p;function h(S,T,O){var L=[];T=T==!0?{entropy:!0}:T||{};var M=b(y(T.entropy?[S,$(t)]:S==null?v():S,3),L),W=new m(L),V=function(){for(var G=W.g(a),K=c,J=0;G<l;)G=(G+J)*s,K*=s,J=W.g(1);for(;G>=u;)G/=2,K/=2,J>>>=1;return(G+J)/K};return V.int32=function(){return W.g(4)|0},V.quick=function(){return W.g(4)/4294967296},V.double=V,b($(W.S),t),(T.pass||O||function(G,K,J,ue){return ue&&(ue.S&&g(ue,W),G.state=function(){return g(W,{})}),J?(r[i]=G,K):G})(V,M,"global"in T?T.global:this==r,T.state)}function m(S){var T,O=S.length,L=this,M=0,W=L.i=L.j=0,V=L.S=[];for(O||(S=[O++]);M<s;)V[M]=M++;for(M=0;M<s;M++)V[M]=V[W=d&W+S[M%O]+(T=V[M])],V[W]=T;(L.g=function(G){for(var K,J=0,ue=L.i,se=L.j,fe=L.S;G--;)K=fe[ue=d&ue+1],J=J*s+fe[d&(fe[ue]=fe[se=d&se+K])+(fe[se]=K)];return L.i=ue,L.j=se,J})(s)}function g(S,T){return T.i=S.i,T.j=S.j,T.S=S.S.slice(),T}function y(S,T){var O=[],L=typeof S,M;if(T&&L=="object")for(M in S)try{O.push(y(S[M],T-1))}catch{}
vendor: 4,166 bytes, lines 2471-2501
2471return O.length?O:L=="string"?S:S+"\0"}function b(S,T){for(var O=S+"",L,M=0;M<O.length;)T[d&M]=d&(L^=T[d&M]*19)+O.charCodeAt(M++);return $(T)}function v(){try{var S;return p&&(S=p.randomBytes)?S=S(s):(S=new Uint8Array(s),(e.crypto||e.msCrypto).getRandomValues(S)),$(S)}catch{var T=e.navigator,O=T&&T.plugins;return[+new Date,e,O,e.screen,$(t)]}}function $(S){return String.fromCharCode.apply(0,S)}if(b(r.random(),t),n.exports){n.exports=h;try{p=Fr}catch{}}else r["seed"+i]=h})(typeof self<"u"?self:Nn,[],Math)})(kg);var sS=$g.exports,aS=Sg.exports,oS=Cg.exports,iS=_g.exports,uS=Ng.exports,cS=Tg.exports,Ls=kg.exports;Ls.alea=sS;Ls.xor128=aS;Ls.xorwow=oS;Ls.xorshift7=iS;Ls.xor4096=uS;Ls.tychei=cS;var yp=Ls;/** 2472 * @license 2473 * Copyright 2018 Google LLC. All Rights Reserved. 2474 * Licensed under the Apache License, Version 2.0 (the "License"); 2475 * you may not use this file except in compliance with the License. 2476 * You may obtain a copy of the License at 2477 * 2478 * http://www.apache.org/licenses/LICENSE-2.0 2479 * 2480 * Unless required by applicable law or agreed to in writing, software 2481 * distributed under the License is distributed on an "AS IS" BASIS, 2482 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2483 * See the License for the specific language governing permissions and 2484 * limitations under the License. 2485 * ============================================================================= 2486 */class bp{constructor(e,t,r,s,a){this.mean=e,this.stdDev=t,this.dtype=r,this.nextVal=NaN,this.truncated=s,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);const o=a||Math.random();this.random=yp.alea(o.toString())}nextValue(){if(!isNaN(this.nextVal)){const s=this.nextVal;return this.nextVal=NaN,s}let e,t,r=!1;for(;!r;){let s,a,o;do s=2*this.random()-1,a=2*this.random()-1,o=s*s+a*a;while(o>=1||o===0);const i=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*s*i,t=this.mean+this.stdDev*a*i,(!this.truncated||this.isValidTruncated(e))&&(r=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class lS{constructor(e,t,r,s){this.alpha=e,this.beta=1/t,this.dtype=r;const a=s||Math.random();this.randu=yp.alea(a.toString()),this.randn=new bp(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,s,a,o;for(;;){do s=this.randn.nextValue(),o=1+this.c*s;while(o<=0);if(o*=o*o,e=s*s,t=1-.331*e*e,r=.5*e+this.d*(1-o+Math.log(o)),a=this.randu(),a<t||Math.log(a)<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 dS{constructor(e=0,t=1,r,s){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=r,s==null&&(s=Math.random()),typeof s=="number"&&(s=s.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=yp.alea(s)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}/** 2487 * @license 2488 * Copyright 2020 Google LLC. All Rights Reserved. 2489 * Licensed under the Apache License, Version 2.0 (the "License"); 2490 * you may not use this file except in compliance with the License. 2491 * You may obtain a copy of the License at 2492 * 2493 * http://www.apache.org/licenses/LICENSE-2.0 2494 * 2495 * Unless required by applicable law or agreed to in writing, software 2496 * distributed under the License is distributed on an "AS IS" BASIS, 2497 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2498 * See the License for the specific language governing permissions and 2499 * limitations under the License. 2500 * ============================================================================= 2501 */function pS(n,e,t=1,r="float32",s){if(fn(n),t==null&&(t=1),r==null&&(r="float32"),r!=="float32"&&r!=="int32")throw new Error(`Unsupported data type ${r}`);
vendor: 4,596 bytes, lines 2501-2579
2501const a=new lS(e,t,r,s),o=at(n,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}const hS=D({randomGamma_:pS});/** 2502 * @license 2503 * Copyright 2020 Google LLC. All Rights Reserved. 2504 * Licensed under the Apache License, Version 2.0 (the "License"); 2505 * you may not use this file except in compliance with the License. 2506 * You may obtain a copy of the License at 2507 * 2508 * http://www.apache.org/licenses/LICENSE-2.0 2509 * 2510 * Unless required by applicable law or agreed to in writing, software 2511 * distributed under the License is distributed on an "AS IS" BASIS, 2512 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2513 * See the License for the specific language governing permissions and 2514 * limitations under the License. 2515 * ============================================================================= 2516 */function fS(n,e=0,t=1,r,s){if(fn(n),r!=null&&r==="bool")throw new Error(`Unsupported data type ${r}`);const a=new bp(e,t,r,!1,s),o=at(n,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}const Eg=D({randomNormal_:fS});/** 2517 * @license 2518 * Copyright 2022 Google LLC. All Rights Reserved. 2519 * Licensed under the Apache License, Version 2.0 (the "License"); 2520 * you may not use this file except in compliance with the License. 2521 * You may obtain a copy of the License at 2522 * 2523 * http://www.apache.org/licenses/LICENSE-2.0 2524 * 2525 * Unless required by applicable law or agreed to in writing, software 2526 * distributed under the License is distributed on an "AS IS" BASIS, 2527 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2528 * See the License for the specific language governing permissions and 2529 * limitations under the License. 2530 * ============================================================================= 2531 */function mS(n,e,t){if(e!=null&&e==="bool")throw new Error(`Unsupported data type ${e}`);return Eg(n,0,1,e,t)}const gS=D({randomStandardNormal_:mS});/** 2532 * @license 2533 * Copyright 2020 Google LLC. All Rights Reserved. 2534 * Licensed under the Apache License, Version 2.0 (the "License"); 2535 * you may not use this file except in compliance with the License. 2536 * You may obtain a copy of the License at 2537 * 2538 * http://www.apache.org/licenses/LICENSE-2.0 2539 * 2540 * Unless required by applicable law or agreed to in writing, software 2541 * distributed under the License is distributed on an "AS IS" BASIS, 2542 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2543 * See the License for the specific language governing permissions and 2544 * limitations under the License. 2545 * ============================================================================= 2546 */function yS(n,e=0,t=1,r="float32",s){fn(n);const a=at(n,r),o=new dS(e,t,null,s);for(let i=0;i<a.values.length;i++)a.values[i]=o.nextValue();return a.toTensor()}const xp=D({randomUniform_:yS});/** 2547 * @license 2548 * Copyright 2023 Google LLC. 2549 * Licensed under the Apache License, Version 2.0 (the "License"); 2550 * you may not use this file except in compliance with the License. 2551 * You may obtain a copy of the License at 2552 * 2553 * http://www.apache.org/licenses/LICENSE-2.0 2554 * 2555 * Unless required by applicable law or agreed to in writing, software 2556 * distributed under the License is distributed on an "AS IS" BASIS, 2557 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2558 * See the License for the specific language governing permissions and 2559 * limitations under the License. 2560 * ============================================================================= 2561 */function bS(n,e,t,r){return xp(n,e,t,"int32",r)}const xS=D({randomUniformInt_:bS});/** 2562 * @license 2563 * Copyright 2018 Google LLC. All Rights Reserved. 2564 * Licensed under the Apache License, Version 2.0 (the "License"); 2565 * you may not use this file except in compliance with the License. 2566 * You may obtain a copy of the License at 2567 * 2568 * http://www.apache.org/licenses/LICENSE-2.0 2569 * 2570 * Unless required by applicable law or agreed to in writing, software 2571 * distributed under the License is distributed on an "AS IS" BASIS, 2572 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2573 * See the License for the specific language governing permissions and 2574 * limitations under the License. 2575 * ============================================================================= 2576 */function yo(n,e,t=1,r="float32"){if(t===0)throw new Error("Cannot have a step of zero");const s={start:n,stop:e,step:t,dtype:r};return F.runKernel(kd,{},s)}/** 2577 * @license 2578 * Copyright 2020 Google LLC. All Rights Reserved. 2579 * Licensed under the Apache License, Version 2.0 (the "License");
2580 * you may not use this file except in compliance with the License. 2581 * You may obtain a copy of the License at 2582 * 2583 * http://www.apache.org/licenses/LICENSE-2.0 2584 * 2585 * Unless required by applicable law or agreed to in writing, software 2586 * distributed under the License is distributed on an "AS IS" BASIS, 2587 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2588 * See the License for the specific language governing permissions and 2589 * limitations under the License. 2590 * ============================================================================= 2591 */function wS(n){const t={input:_(n,"input","real")};return F.runKernel(hm,t)}const bo=D({real_:wS});/** 2592 * @license 2593 * Copyright 2018 Google LLC. All Rights Reserved. 2594 * Licensed under the Apache License, Version 2.0 (the "License"); 2595 * you may not use this file except in compliance with the License. 2596 * You may obtain a copy of the License at 2597 * 2598 * http://www.apache.org/licenses/LICENSE-2.0 2599 * 2600 * Unless required by applicable law or agreed to in writing, software 2601 * distributed under the License is distributed on an "AS IS" BASIS, 2602 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2603 * See the License for the specific language governing permissions and 2604 * limitations under the License. 2605 * ============================================================================= 2606 */function vS(n){const t={x:_(n,"x","reciprocal")};return F.runKernel(Ed,t)}const IS=D({reciprocal_:vS});/** 2607 * @license 2608 * Copyright 2020 Google LLC. All Rights Reserved. 2609 * Licensed under the Apache License, Version 2.0 (the "License"); 2610 * you may not use this file except in compliance with the License. 2611 * You may obtain a copy of the License at 2612 * 2613 * http://www.apache.org/licenses/LICENSE-2.0 2614 * 2615 * Unless required by applicable law or agreed to in writing, software 2616 * distributed under the License is distributed on an "AS IS" BASIS, 2617 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2618 * See the License for the specific language governing permissions and 2619 * limitations under the License. 2620 * ============================================================================= 2621 */function $S(n){const t={x:_(n,"x","relu")};return F.runKernel(Rd,t)}const Gu=D({relu_:$S});/** 2622 * @license 2623 * Copyright 2020 Google LLC. All Rights Reserved. 2624 * Licensed under the Apache License, Version 2.0 (the "License"); 2625 * you may not use this file except in compliance with the License. 2626 * You may obtain a copy of the License at 2627 * 2628 * http://www.apache.org/licenses/LICENSE-2.0 2629 * 2630 * Unless required by applicable law or agreed to in writing, software 2631 * distributed under the License is distributed on an "AS IS" BASIS, 2632 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2633 * See the License for the specific language governing permissions and 2634 * limitations under the License. 2635 * ============================================================================= 2636 */function SS(n){const t={x:_(n,"x","relu6")};return F.runKernel(Fd,t)}const Rg=D({relu6_:SS});/** 2637 * @license 2638 * Copyright 2018 Google LLC. All Rights Reserved. 2639 * Licensed under the Apache License, Version 2.0 (the "License"); 2640 * you may not use this file except in compliance with the License. 2641 * You may obtain a copy of the License at 2642 * 2643 * http://www.apache.org/licenses/LICENSE-2.0 2644 * 2645 * Unless required by applicable law or agreed to in writing, software 2646 * distributed under the License is distributed on an "AS IS" BASIS, 2647 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2648 * See the License for the specific language governing permissions and 2649 * limitations under the License. 2650 * ============================================================================= 2651 */function CS(n,e){const r={x:_(n,"x","reverse")},s={dims:e};return F.runKernel(Su,r,s)}const Rs=D({reverse_:CS});/** 2652 * @license 2653 * Copyright 2020 Google LLC. All Rights Reserved. 2654 * Licensed under the Apache License, Version 2.0 (the "License"); 2655 * you may not use this file except in compliance with the License. 2656 * You may obtain a copy of the License at 2657 * 2658 * http://www.apache.org/licenses/LICENSE-2.0 2659 * 2660 * Unless required by applicable law or agreed to in writing, softw
2660are 2661 * distributed under the License is distributed on an "AS IS" BASIS, 2662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2663 * See the License for the specific language governing permissions and 2664 * limitations under the License. 2665 * ============================================================================= 2666 */function _S(n){const e=_(n,"x","reverse");return N(e.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`),Rs(e,0)}const NS=D({reverse1d_:_S});/** 2667 * @license 2668 * Copyright 2020 Google LLC. All Rights Reserved. 2669 * Licensed under the Apache License, Version 2.0 (the "License"); 2670 * you may not use this file except in compliance with the License. 2671 * You may obtain a copy of the License at 2672 * 2673 * http://www.apache.org/licenses/LICENSE-2.0 2674 * 2675 * Unless required by applicable law or agreed to in writing, software 2676 * distributed under the License is distributed on an "AS IS" BASIS, 2677 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2678 * See the License for the specific language governing permissions and 2679 * limitations under the License. 2680 * ============================================================================= 2681 */function TS(n,e){const t=_(n,"x","reverse");return N(t.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${t.rank}.`),Rs(t,e)}const kS=D({reverse2d_:TS});/** 2682 * @license 2683 * Copyright 2020 Google LLC. All Rights Reserved. 2684 * Licensed under the Apache License, Version 2.0 (the "License"); 2685 * you may not use this file except in compliance with the License. 2686 * You may obtain a copy of the License at 2687 * 2688 * http://www.apache.org/licenses/LICENSE-2.0 2689 * 2690 * Unless required by applicable law or agreed to in writing, software 2691 * distributed under the License is distributed on an "AS IS" BASIS, 2692 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2693 * See the License for the specific language governing permissions and 2694 * limitations under the License. 2695 * ============================================================================= 2696 */function ES(n,e){const t=_(n,"x","reverse");return N(t.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${t.rank}.`),Rs(t,e)}const RS=D({reverse3d_:ES});/** 2697 * @license 2698 * Copyright 2020 Google LLC. All Rights Reserved. 2699 * Licensed under the Apache License, Version 2.0 (the "License"); 2700 * you may not use this file except in compliance with the License. 2701 * You may obtain a copy of the License at 2702 * 2703 * http://www.apache.org/licenses/LICENSE-2.0 2704 * 2705 * Unless required by applicable law or agreed to in writing, software 2706 * distributed under the License is distributed on an "AS IS" BASIS, 2707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2708 * See the License for the specific language governing permissions and 2709 * limitations under the License. 2710 * ============================================================================= 2711 */function AS(n,e){const t=_(n,"x","reverse");return N(t.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${t.rank}.`),Rs(t,e)}const DS=D({reverse4d_:AS});/** 2712 * @license 2713 * Copyright 2018 Google LLC. All Rights Reserved. 2714 * Licensed under the Apache License, Version 2.0 (the "License"); 2715 * you may not use this file except in compliance with the License. 2716 * You may obtain a copy of the License at 2717 * 2718 * http://www.apache.org/licenses/LICENSE-2.0 2719 * 2720 * Unless required by applicable law or agreed to in writing, software 2721 * distributed under the License is distributed on an "AS IS" BASIS, 2722 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2723 * See the License for the specific language governing permissions and 2724 * limitations under the License. 2725 * ============================================================================= 2726 */function OS(n){const t={x:_(n,"x","round")};return F.runKernel(Pd,t)}const Ag=D({round_:OS});/** 2727 * @license 2728 * Copyright 2018 Google LLC. All Rights Reserved. 2729 * Licensed under the Apache License, Version 2.0 (the "License"); 2730 * you may not use this file except in compliance with the License. 2731 * You may obtain a copy of the License at 2732 * 2733 * http://www.apache.org/licenses/LICENSE-2.0 2734 * 2735 * Unless required by applicable law or agreed to in writing, softw
2735are 2736 * distributed under the License is distributed on an "AS IS" BASIS, 2737 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2738 * See the License for the specific language governing permissions and 2739 * limitations under the License. 2740 * ============================================================================= 2741 */function FS(n){const t={x:_(n,"x","rsqrt","float32")};return F.runKernel(Ld,t)}const PS=D({rsqrt_:FS});/** 2742 * @license 2743 * Copyright 2020 Google LLC. All Rights Reserved. 2744 * Licensed under the Apache License, Version 2.0 (the "License"); 2745 * you may not use this file except in compliance with the License. 2746 * You may obtain a copy of the License at 2747 * 2748 * http://www.apache.org/licenses/LICENSE-2.0 2749 * 2750 * Unless required by applicable law or agreed to in writing, software 2751 * distributed under the License is distributed on an "AS IS" BASIS, 2752 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2753 * See the License for the specific language governing permissions and 2754 * limitations under the License. 2755 * ============================================================================= 2756 */function LS(n){const t={x:_(n,"x","selu")};return F.runKernel(Bd,t)}const MS=D({selu_:LS});function BS(n,e,t,r,s,a=[1,1],o="NHWC"){const i=_(n,"x","separableConv2d"),c=_(e,"depthwiseFilter","separableConv2d"),l=_(t,"pointwiseFilter","separableConv2d");let u=i,d=!1;if(i.rank===3&&(d=!0,u=q(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");N(u.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${u.rank}.`),N(c.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${c.rank}.`),N(l.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${c.rank}.`),N(l.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`),N(l.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`);const p=c.shape[2],h=c.shape[3];N(l.shape[2]===p*h,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${p*h}, but got ${l.shape[2]}.`);const m=hp(u,c,r,s,o,a),y=Vu(m,l,1,"valid",o);return d?q(y,[y.shape[1],y.shape[2],y.shape[3]]):y}const VS=D({separableConv2d_:BS});/** 2757 * @license 2758 * Copyright 2020 Google Inc. All Rights Reserved. 2759 * Licensed under the Apache License, Version 2.0 (the "License"); 2760 * you may not use this file except in compliance with the License. 2761 * You may obtain a copy of the License at 2762 * 2763 * http://www.apache.org/licenses/LICENSE-2.0 2764 * 2765 * Unless required by applicable law or agreed to in writing, software 2766 * distributed under the License is distributed on an "AS IS" BASIS, 2767 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2768 * See the License for the specific language governing permissions and 2769 * limitations under the License. 2770 * ============================================================================= 2771 */async function WS(n,e){const t=_(n,"x","setdiff1d"),r=_(e,"y","setdiff1d");N(t.dtype===r.dtype,()=>`x and y should have the same dtype, but got x (${t.dtype}) and y (${r.dtype}).`),N(t.rank===1,()=>`x should be 1D tensor, but got x (${t.shape}).`),N(r.rank===1,()=>`y should be 1D tensor, but got y (${r.shape}).`);const s=await t.data(),a=await r.data(),o=new Set(a);let i=0;for(let u=0;u<s.length;u++)o.has(s[u])||i++;const c=new $a([i],t.dtype),l=new $a([i],"int32");for(let u=0,d=0;u<s.length;u++)o.has(s[u])||(c.values[d]=s[u],l.values[d]=u,d++);return[c.toTensor(),l.toTensor()]}const US=WS;/** 2772 * @license 2773 * Copyright 2018 Google LLC. All Rights Reserved. 2774 * Licensed under the Apache License, Version 2.0 (the "License"); 2775 * you may not use this file except in compliance with the License. 2776 * You may obtain a copy of the License at 2777 * 2778 * http://www.apache.org/licenses/LICENSE-2.0 2779 * 2780 * Unless required by applicable law or agreed to in writing, software 2781 * distributed under the License is distributed on an "AS IS" BASIS, 2782 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2783 * See the License for the specific language governing permissions and 2784 * limitations under the License. 2785 * ============================================================================= 2786 */function zS(n){const t={x:_(n,"x","sign")};return F.runKernel(zd,t)}const GS=D({sign_:zS});/** 2787 * @license 2788 * Copyright 2018 Google LLC. All Rights Reserved. 2789 * Licensed under the Apache License, Version 2.0 (the "License");
2790 * you may not use this file except in compliance with the License. 2791 * You may obtain a copy of the License at 2792 * 2793 * http://www.apache.org/licenses/LICENSE-2.0 2794 * 2795 * Unless required by applicable law or agreed to in writing, software 2796 * distributed under the License is distributed on an "AS IS" BASIS, 2797 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2798 * See the License for the specific language governing permissions and 2799 * limitations under the License. 2800 * ============================================================================= 2801 */function HS(n){const t={x:_(n,"x","sin","float32")};return F.runKernel(Wd,t)}const jS=D({sin_:HS});/** 2802 * @license 2803 * Copyright 2018 Google LLC. All Rights Reserved. 2804 * Licensed under the Apache License, Version 2.0 (the "License"); 2805 * you may not use this file except in compliance with the License. 2806 * You may obtain a copy of the License at 2807 * 2808 * http://www.apache.org/licenses/LICENSE-2.0 2809 * 2810 * Unless required by applicable law or agreed to in writing, software 2811 * distributed under the License is distributed on an "AS IS" BASIS, 2812 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2813 * See the License for the specific language governing permissions and 2814 * limitations under the License. 2815 * ============================================================================= 2816 */function qS(n){const t={x:_(n,"x","sinh")};return F.runKernel(Ud,t)}const KS=D({sinh_:qS});/** 2817 * @license 2818 * Copyright 2018 Google LLC. All Rights Reserved. 2819 * Licensed under the Apache License, Version 2.0 (the "License"); 2820 * you may not use this file except in compliance with the License. 2821 * You may obtain a copy of the License at 2822 * 2823 * http://www.apache.org/licenses/LICENSE-2.0 2824 * 2825 * Unless required by applicable law or agreed to in writing, software 2826 * distributed under the License is distributed on an "AS IS" BASIS, 2827 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2828 * See the License for the specific language governing permissions and 2829 * limitations under the License. 2830 * ============================================================================= 2831 */function XS(n,e,t){const r=_(n,"x","slice1d");return N(r.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`),Se(r,[e],[t])}const YS=D({slice1d_:XS});/** 2832 * @license 2833 * Copyright 2018 Google LLC. All Rights Reserved. 2834 * Licensed under the Apache License, Version 2.0 (the "License"); 2835 * you may not use this file except in compliance with the License. 2836 * You may obtain a copy of the License at 2837 * 2838 * http://www.apache.org/licenses/LICENSE-2.0 2839 * 2840 * Unless required by applicable law or agreed to in writing, software 2841 * distributed under the License is distributed on an "AS IS" BASIS, 2842 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2843 * See the License for the specific language governing permissions and 2844 * limitations under the License. 2845 * ============================================================================= 2846 */function QS(n,e,t){const r=_(n,"x","slice2d");return N(r.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`),Se(r,e,t)}const ZS=D({slice2d_:QS});/** 2847 * @license 2848 * Copyright 2018 Google LLC. All Rights Reserved. 2849 * Licensed under the Apache License, Version 2.0 (the "License"); 2850 * you may not use this file except in compliance with the License. 2851 * You may obtain a copy of the License at 2852 * 2853 * http://www.apache.org/licenses/LICENSE-2.0 2854 * 2855 * Unless required by applicable law or agreed to in writing, software 2856 * distributed under the License is distributed on an "AS IS" BASIS, 2857 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2858 * See the License for the specific language governing permissions and 2859 * limitations under the License. 2860 * ============================================================================= 2861 */function JS(n,e,t){const r=_(n,"x","slice3d");return N(r.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`),Se(r,e,t)}const e2=D({slice3d_:JS});/** 2862 * @license 2863 * Copyright 2018 Google LLC. All Rights Reserved. 2864 * Licensed under the Apache License, Version 2.0 (the "License");
2865 * you may not use this file except in compliance with the License. 2866 * You may obtain a copy of the License at 2867 * 2868 * http://www.apache.org/licenses/LICENSE-2.0 2869 * 2870 * Unless required by applicable law or agreed to in writing, software 2871 * distributed under the License is distributed on an "AS IS" BASIS, 2872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2873 * See the License for the specific language governing permissions and 2874 * limitations under the License. 2875 * ============================================================================= 2876 */function t2(n,e,t){const r=_(n,"x","slice4d");return N(r.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`),Se(r,e,t)}const n2=D({slice4d_:t2});/** 2877 * @license 2878 * Copyright 2018 Google LLC. All Rights Reserved. 2879 * Licensed under the Apache License, Version 2.0 (the "License"); 2880 * you may not use this file except in compliance with the License. 2881 * You may obtain a copy of the License at 2882 * 2883 * http://www.apache.org/licenses/LICENSE-2.0 2884 * 2885 * Unless required by applicable law or agreed to in writing, software 2886 * distributed under the License is distributed on an "AS IS" BASIS, 2887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2888 * See the License for the specific language governing permissions and 2889 * limitations under the License. 2890 * ============================================================================= 2891 */function r2(n,e=-1){const t=_(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},s={dim:e};return F.runKernel(ku,r,s)}const s2=D({softmax_:r2});/** 2892 * @license 2893 * Copyright 2020 Google LLC. All Rights Reserved. 2894 * Licensed under the Apache License, Version 2.0 (the "License"); 2895 * you may not use this file except in compliance with the License. 2896 * You may obtain a copy of the License at 2897 * 2898 * http://www.apache.org/licenses/LICENSE-2.0 2899 * 2900 * Unless required by applicable law or agreed to in writing, software 2901 * distributed under the License is distributed on an "AS IS" BASIS, 2902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2903 * See the License for the specific language governing permissions and 2904 * limitations under the License. 2905 * ============================================================================= 2906 */function a2(n){N(n.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${n.dtype}.`);const e={input:n};return F.runKernel(am,e)}const wp=D({fft_:a2});/** 2907 * @license 2908 * Copyright 2020 Google LLC. All Rights Reserved. 2909 * Licensed under the Apache License, Version 2.0 (the "License"); 2910 * you may not use this file except in compliance with the License. 2911 * You may obtain a copy of the License at 2912 * 2913 * http://www.apache.org/licenses/LICENSE-2.0 2914 * 2915 * Unless required by applicable law or agreed to in writing, software 2916 * distributed under the License is distributed on an "AS IS" BASIS, 2917 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2918 * See the License for the specific language governing permissions and 2919 * limitations under the License. 2920 * ============================================================================= 2921 */function o2(n){N(n.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${n.dtype}.`);const e={input:n};return F.runKernel(om,e)}const _i=D({ifft_:o2});/** 2922 * @license 2923 * Copyright 2018 Google LLC. All Rights Reserved. 2924 * Licensed under the Apache License, Version 2.0 (the "License"); 2925 * you may not use this file except in compliance with the License. 2926 * You may obtain a copy of the License at 2927 * 2928 * http://www.apache.org/licenses/LICENSE-2.0 2929 * 2930 * Unless required by applicable law or agreed to in writing, software 2931 * distributed under the License is distributed on an "AS IS" BASIS, 2932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2933 * See the License for the specific language governing permissions and 2934 * limitations under the License. 2935 * ============================================================================= 2936 */function i2(n){const e=n.shape[n.shape.length-1],t=n.size/e;let r;if(e<=2){const s=q(n,[t,e]);r=_i(s)}else{const s=[t,2*(e-1)],a=q(bo(n),[t,e]),o=q(zu(n),[t,e]),i=Rs(Se(a,[0,1],[t,e-2]),1),c=Z(Rs(Se(o,[0,1],[t,e-2]),1),Re(-1)),l=It([a,i],1),u=It([o,c],1),d=q(zr(l,u),[s[0],s[1]]);r=_i(d)}if(r=bo(r),n.rank===3&&n.shape[0]!==0){const s=r,a=n.shape[0];r=q(r,[a,r.shape[0]/a,r.shape[1]]),s.dispose()}return r}const Dg=D({irfft_:i2});/** 2937 * @license 2938 * Copyright 2020 Google LLC. All Rights Reserved. 2939 * Licensed under the Apache License, Version 2.0 (the "License");
2940 * you may not use this file except in compliance with the License. 2941 * You may obtain a copy of the License at 2942 * 2943 * http://www.apache.org/licenses/LICENSE-2.0 2944 * 2945 * Unless required by applicable law or agreed to in writing, software 2946 * distributed under the License is distributed on an "AS IS" BASIS, 2947 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2948 * See the License for the specific language governing permissions and 2949 * limitations under the License. 2950 * ============================================================================= 2951 */function u2(n,e,t=0){const s={x:_(n,"x","split")},a={numOrSizeSplits:e,axis:t};return F.runKernel(Kd,s,a)}const xo=D({split_:u2});/** 2952 * @license 2953 * Copyright 2018 Google LLC. All Rights Reserved. 2954 * Licensed under the Apache License, Version 2.0 (the "License"); 2955 * you may not use this file except in compliance with the License. 2956 * You may obtain a copy of the License at 2957 * 2958 * http://www.apache.org/licenses/LICENSE-2.0 2959 * 2960 * Unless required by applicable law or agreed to in writing, software 2961 * distributed under the License is distributed on an "AS IS" BASIS, 2962 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2963 * See the License for the specific language governing permissions and 2964 * limitations under the License. 2965 * ============================================================================= 2966 */function c2(n,e){N(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 s;if(e!=null&&e<t){const m=n.shape.map(y=>0),g=n.shape.map(y=>y);g[n.shape.length-1]=e,s=Se(n,m,g),t=e}else if(e!=null&&e>t){const m=n.shape.map(g=>g);m[n.shape.length-1]=e-t,s=It([n,Es(m)],n.shape.length-1),t=e}else s=n;const a=hn(s),o=q(zr(s,a),[r,t]),i=wp(o),c=Math.floor(t/2)+1,l=bo(i),u=zu(i),d=xo(l,[c,t-c],l.shape.length-1),p=xo(u,[c,t-c],u.shape.length-1),h=s.shape.slice();return h[s.shape.length-1]=c,q(zr(d[0],p[0]),h)}const vp=D({rfft_:c2});/** 2967 * @license 2968 * Copyright 2020 Google LLC. All Rights Reserved. 2969 * Licensed under the Apache License, Version 2.0 (the "License"); 2970 * you may not use this file except in compliance with the License. 2971 * You may obtain a copy of the License at 2972 * 2973 * http://www.apache.org/licenses/LICENSE-2.0 2974 * 2975 * Unless required by applicable law or agreed to in writing, software 2976 * distributed under the License is distributed on an "AS IS" BASIS, 2977 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2978 * See the License for the specific language governing permissions and 2979 * limitations under the License. 2980 * ============================================================================= 2981 */function l2(n,e){let t=_(n,"a","squaredDifference"),r=_(e,"b","squaredDifference");[t,r]=ut(t,r),ke(t.shape,r.shape);const s={a:t,b:r},a={};return F.runKernel(Zd,s,a)}const Og=D({squaredDifference_:l2});/** 2982 * @license 2983 * Copyright 2020 Google LLC. All Rights Reserved. 2984 * Licensed under the Apache License, Version 2.0 (the "License"); 2985 * you may not use this file except in compliance with the License. 2986 * You may obtain a copy of the License at 2987 * 2988 * http://www.apache.org/licenses/LICENSE-2.0 2989 * 2990 * Unless required by applicable law or agreed to in writing, software 2991 * distributed under the License is distributed on an "AS IS" BASIS, 2992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2993 * See the License for the specific language governing permissions and 2994 * limitations under the License. 2995 * ============================================================================= 2996 */function d2(n,e){const t=_(n,"x","squeeze","string_or_numeric");return q(t,jr(t.shape,e).newShape)}const xt=D({squeeze_:d2});/** 2997 * @license 2998 * Copyright 2020 Google LLC. All Rights Reserved. 2999 * Licensed under the Apache License, Version 2.0 (the "License"); 3000 * you may not use this file except in compliance with the License. 3001 * You may obtain a copy of the License at 3002 * 3003 * http://www.apache.org/licenses/LICENSE-2.0 3004 * 3005 * Unless required by applicable law or agreed to in writing, softw
3005are 3006 * distributed under the License is distributed on an "AS IS" BASIS, 3007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3008 * See the License for the specific language governing permissions and 3009 * limitations under the License. 3010 * ============================================================================= 3011 */function p2(n,e=0){const t=vi(n,"tensors","stack","string_or_numeric");N(t.length>=1,()=>"Pass at least one tensor to tf.stack"),t.length>0&&N(e<=t[0].rank,()=>"Axis must be <= rank of the tensor");const r=t,s={axis:e};return F.runKernel(Nd,r,s)}const vr=D({stack_:p2});/** 3012 * @license 3013 * Copyright 2018 Google LLC. All Rights Reserved. 3014 * Licensed under the Apache License, Version 2.0 (the "License"); 3015 * you may not use this file except in compliance with the License. 3016 * You may obtain a copy of the License at 3017 * 3018 * http://www.apache.org/licenses/LICENSE-2.0 3019 * 3020 * Unless required by applicable law or agreed to in writing, software 3021 * distributed under the License is distributed on an "AS IS" BASIS, 3022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3023 * See the License for the specific language governing permissions and 3024 * limitations under the License. 3025 * ============================================================================= 3026 */function h2(n,e=0){const r={x:_(n,"x","step")},s={alpha:e};return F.runKernel(Fu,r,s)}const Fg=D({step_:h2});/** 3027 * @license 3028 * Copyright 2018 Google LLC. All Rights Reserved. 3029 * Licensed under the Apache License, Version 2.0 (the "License"); 3030 * you may not use this file except in compliance with the License. 3031 * You may obtain a copy of the License at 3032 * 3033 * http://www.apache.org/licenses/LICENSE-2.0 3034 * 3035 * Unless required by applicable law or agreed to in writing, software 3036 * distributed under the License is distributed on an "AS IS" BASIS, 3037 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3038 * See the License for the specific language governing permissions and 3039 * limitations under the License. 3040 * ============================================================================= 3041 */function f2(n,e,t,r,s=0,a=0,o=0,i=0,c=0){const u={x:_(n,"x","stridedSlice","string_or_numeric")},d={begin:e,end:t,strides:r,beginMask:s,endMask:a,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:c};return F.runKernel(Au,u,d)}const m2=D({stridedSlice_:f2});/** 3042 * @license 3043 * Copyright 2018 Google LLC. All Rights Reserved. 3044 * Licensed under the Apache License, Version 2.0 (the "License"); 3045 * you may not use this file except in compliance with the License. 3046 * You may obtain a copy of the License at 3047 * 3048 * http://www.apache.org/licenses/LICENSE-2.0 3049 * 3050 * Unless required by applicable law or agreed to in writing, software 3051 * distributed under the License is distributed on an "AS IS" BASIS, 3052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3053 * See the License for the specific language governing permissions and 3054 * limitations under the License. 3055 * ============================================================================= 3056 */function g2(n){const t={x:_(n,"x","tan","float32")};return F.runKernel(rp,t)}const y2=D({tan_:g2});/** 3057 * @license 3058 * Copyright 2018 Google LLC. All Rights Reserved. 3059 * Licensed under the Apache License, Version 2.0 (the "License"); 3060 * you may not use this file except in compliance with the License. 3061 * You may obtain a copy of the License at 3062 * 3063 * http://www.apache.org/licenses/LICENSE-2.0 3064 * 3065 * Unless required by applicable law or agreed to in writing, software 3066 * distributed under the License is distributed on an "AS IS" BASIS, 3067 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3068 * See the License for the specific language governing permissions and 3069 * limitations under the License. 3070 * ============================================================================= 3071 */function Rt(n,e){Ta(n);const t=qr(n,e);if(t.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Kr(n,null,t,e)}/** 3072 * @license 3073 * Copyright 2018 Google LLC. All Rights Reserved. 3074 * Licensed under the Apache License, Version 2.0 (the "License");
3075 * you may not use this file except in compliance with the License. 3076 * You may obtain a copy of the License at 3077 * 3078 * http://www.apache.org/licenses/LICENSE-2.0 3079 * 3080 * Unless required by applicable law or agreed to in writing, software 3081 * distributed under the License is distributed on an "AS IS" BASIS, 3082 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3083 * See the License for the specific language governing permissions and 3084 * limitations under the License. 3085 * ============================================================================= 3086 */function $s(n,e,t){if(Ta(n),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");const r=qr(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 Kr(n,e,r,t)}/** 3087 * @license 3088 * Copyright 2018 Google LLC. All Rights Reserved. 3089 * Licensed under the Apache License, Version 2.0 (the "License"); 3090 * you may not use this file except in compliance with the License. 3091 * You may obtain a copy of the License at 3092 * 3093 * http://www.apache.org/licenses/LICENSE-2.0 3094 * 3095 * Unless required by applicable law or agreed to in writing, software 3096 * distributed under the License is distributed on an "AS IS" BASIS, 3097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3098 * See the License for the specific language governing permissions and 3099 * limitations under the License. 3100 * ============================================================================= 3101 */function Pg(n,e,t){if(Ta(n),e!=null&&e.length!==3)throw new Error("tensor3d() requires shape to have three numbers");const r=qr(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 Kr(n,e,r,t)}/** 3102 * @license 3103 * Copyright 2018 Google LLC. All Rights Reserved. 3104 * Licensed under the Apache License, Version 2.0 (the "License"); 3105 * you may not use this file except in compliance with the License. 3106 * You may obtain a copy of the License at 3107 * 3108 * http://www.apache.org/licenses/LICENSE-2.0 3109 * 3110 * Unless required by applicable law or agreed to in writing, software 3111 * distributed under the License is distributed on an "AS IS" BASIS, 3112 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3113 * See the License for the specific language governing permissions and 3114 * limitations under the License. 3115 * ============================================================================= 3116 */function b2(n,e,t){if(Ta(n),e!=null&&e.length!==4)throw new Error("tensor4d() requires shape to have four numbers");const r=qr(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 Kr(n,e,r,t)}/** 3117 * @license 3118 * Copyright 2018 Google LLC. All Rights Reserved. 3119 * Licensed under the Apache License, Version 2.0 (the "License"); 3120 * you may not use this file except in compliance with the License. 3121 * You may obtain a copy of the License at 3122 * 3123 * http://www.apache.org/licenses/LICENSE-2.0 3124 * 3125 * Unless required by applicable law or agreed to in writing, software 3126 * distributed under the License is distributed on an "AS IS" BASIS, 3127 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3128 * See the License for the specific language governing permissions and 3129 * limitations under the License. 3130 * ============================================================================= 3131 */function x2(n,e,t){if(Ta(n),e!=null&&e.length!==5)throw new Error("tensor5d() requires shape to have five numbers");const r=qr(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 Kr(n,e,r,t)}/** 3132 * @license 3133 * Copyright 2018 Google LLC. All Rights Reserved. 3134 * Licensed under the Apache License, Version 2.0 (the "License");
3135 * you may not use this file except in compliance with the License. 3136 * You may obtain a copy of the License at 3137 * 3138 * http://www.apache.org/licenses/LICENSE-2.0 3139 * 3140 * Unless required by applicable law or agreed to in writing, software 3141 * distributed under the License is distributed on an "AS IS" BASIS, 3142 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3143 * See the License for the specific language governing permissions and 3144 * limitations under the License. 3145 * ============================================================================= 3146 */function w2(n,e,t){if(Ta(n),e!=null&&e.length!==6)throw new Error("tensor6d() requires shape to have six numbers");const r=qr(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,Kr(n,e,r,t)}function Lg(n,e,t){const r=e.rank>1?e.shape[e.rank-1]:1,s=e.rank>1?e.rank-1:1,a=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t.shape}, indices.shape: ${e.shape}, shape: ${n}, sliceDim: ${r}, and batchDim: ${s}.`;if(t.rank<s)throw new Error(a+` update.rank < ${s}. `);if(n.length<r+(t.rank-s))throw new Error(a+` Output shape length < ${r+(t.rank-s)}`);if(t.rank!==s+n.length-r)throw new Error(a+` update.rank != ${s+n.length-r}`);for(let o=0;o<s;++o)if(t.shape[o]!==e.shape[o])throw new Error(a+` updates.shape[${o}] (${t.shape[o]}) != indices.shape[${o}] (${e.shape[o]}).`);for(let o=0;o<t.rank-s;++o)if(t.shape[o+s]!==n[o+r])throw new Error(a+` updates.shape[${o+s}] (${t.shape[o+s]}) != shape[${o+s}] (${n[o+s]})`)}function Ip(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}`)}Lg(t,e,n)}function Ms(n,e,t){const r=e.shape.length,s=r>1?e.shape[r-1]:1,a=t.length;let o=1;for(let d=s;d<a;++d)o*=t[d];const i=s<1?1:s,c=H(e.shape)/i,l=[...Be(t.slice(0,s)),1],u=H(t);return{sliceRank:s,numUpdates:c,sliceSize:o,strides:l,outputSize:u}}/** 3147 * @license 3148 * Copyright 2022 Google LLC. All Rights Reserved. 3149 * Licensed under the Apache License, Version 2.0 (the "License"); 3150 * you may not use this file except in compliance with the License. 3151 * You may obtain a copy of the License at 3152 * 3153 * http://www.apache.org/licenses/LICENSE-2.0 3154 * 3155 * Unless required by applicable law or agreed to in writing, software 3156 * distributed under the License is distributed on an "AS IS" BASIS, 3157 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3158 * See the License for the specific language governing permissions and 3159 * limitations under the License. 3160 * ============================================================================= 3161 */function v2(n,e,t){const r=_(n,"tensor","tensorScatterupdate"),s=_(e,"indices","tensorScatterupdate","int32"),a=_(t,"updates","tensorScatterupdate");if(Ip(a,s,r.shape),r.dtype!==a.dtype)throw new Error(`tensor and updates must have the same dtype, instead they are ${r.dtype} and ${a.dtype}.`);const o={tensor:r,indices:s,updates:a},i={};return F.runKernel(_u,o,i)}const I2=D({tensorScatterUpdate_:v2});/** 3162 * @license 3163 * Copyright 2018 Google LLC. All Rights Reserved. 3164 * Licensed under the Apache License, Version 2.0 (the "License"); 3165 * you may not use this file except in compliance with the License. 3166 * You may obtain a copy of the License at 3167 * 3168 * http://www.apache.org/licenses/LICENSE-2.0 3169 * 3170 * Unless required by applicable law or agreed to in writing, softw
3170are 3171 * distributed under the License is distributed on an "AS IS" BASIS, 3172 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3173 * See the License for the specific language governing permissions and 3174 * limitations under the License. 3175 * ============================================================================= 3176 */function $2(n,e=1,t=!0){const r=_(n,"x","topk");if(r.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");const s=r.shape[r.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>s)throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${e}`);const a={x:r},o={k:e,sorted:t},[i,c]=F.runKernel(Du,a,o);return{values:i,indices:c}}const S2=D({topk_:$2});/** 3177 * @license 3178 * Copyright 2020 Google LLC. All Rights Reserved. 3179 * Licensed under the Apache License, Version 2.0 (the "License"); 3180 * you may not use this file except in compliance with the License. 3181 * You may obtain a copy of the License at 3182 * 3183 * http://www.apache.org/licenses/LICENSE-2.0 3184 * 3185 * Unless required by applicable law or agreed to in writing, software 3186 * distributed under the License is distributed on an "AS IS" BASIS, 3187 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3188 * See the License for the specific language governing permissions and 3189 * limitations under the License. 3190 * ============================================================================= 3191 */function C2(n,e=0,t=1,r,s){if(fn(n),r!=null&&r==="bool")throw new Error("Unsupported data type $ { dtype }");const a=new bp(e,t,r,!0,s),o=at(n,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}const _2=D({truncatedNormal_:C2});/** 3192 * @license 3193 * Copyright 2020 Google LLC. All Rights Reserved. 3194 * Licensed under the Apache License, Version 2.0 (the "License"); 3195 * you may not use this file except in compliance with the License. 3196 * You may obtain a copy of the License at 3197 * 3198 * http://www.apache.org/licenses/LICENSE-2.0 3199 * 3200 * Unless required by applicable law or agreed to in writing, software 3201 * distributed under the License is distributed on an "AS IS" BASIS, 3202 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3203 * See the License for the specific language governing permissions and 3204 * limitations under the License. 3205 * ============================================================================= 3206 */function N2(n,e=0){const t=_(n,"x","unique","string_or_numeric");N(t.rank>0,()=>"The input tensor must be at least 1D");const r={x:t},s={axis:e},[a,o]=F.runKernel(ap,r,s);return{values:a,indices:o}}const T2=D({unique_:N2});/** 3207 * @license 3208 * Copyright 2020 Google LLC. All Rights Reserved. 3209 * Licensed under the Apache License, Version 2.0 (the "License"); 3210 * you may not use this file except in compliance with the License. 3211 * You may obtain a copy of the License at 3212 * 3213 * http://www.apache.org/licenses/LICENSE-2.0 3214 * 3215 * Unless required by applicable law or agreed to in writing, software 3216 * distributed under the License is distributed on an "AS IS" BASIS, 3217 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3218 * See the License for the specific language governing permissions and 3219 * limitations under the License. 3220 * ============================================================================= 3221 */function k2(n,e,t){const r=_(n,"x","unsortedSegmentSum"),s=_(e,"segmentIds","unsortedSegmentSum","int32");N(xa(t),()=>"numSegments must be of dtype int");const a={x:r,segmentIds:s},o={numSegments:t};return F.runKernel(gm,a,o)}const E2=D({unsortedSegmentSum_:k2});/** 3222 * @license 3223 * Copyright 2020 Google LLC. All Rights Reserved. 3224 * Licensed under the Apache License, Version 2.0 (the "License"); 3225 * you may not use this file except in compliance with the License. 3226 * You may obtain a copy of the License at 3227 * 3228 * http://www.apache.org/licenses/LICENSE-2.0 3229 * 3230 * Unless required by applicable law or agreed to in writing, software 3231 * distributed under the License is distributed on an "AS IS" BASIS, 3232 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3233 * See the License for the specific language governing permissions and 3234 * limitations under the License. 3235 * ============================================================================= 3236 */function R2(n,e=0){const t=_(n,"x","unstack","string_or_numeric");N(e>=-t.shape.length&&e<t.shape.length,()=>`Axis = ${e} is not in [-${t.shape.length}, ${t.shape.length})`);const r={value:t},s={axis:e};return F.runKernel(op,r,s)}const Bs=D({unstack_:R2});/** 3237 * @license 3238 * Copyright 2022 Google LLC. All Rights Reserved. 3239 * Licensed under the Apache License, Version 2.0 (the "License");
3240 * you may not use this file except in compliance with the License. 3241 * You may obtain a copy of the License at 3242 * 3243 * http://www.apache.org/licenses/LICENSE-2.0 3244 * 3245 * Unless required by applicable law or agreed to in writing, software 3246 * distributed under the License is distributed on an "AS IS" BASIS, 3247 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3248 * See the License for the specific language governing permissions and 3249 * limitations under the License. 3250 * ============================================================================= 3251 */function A2(n,e){return gp(n,e,"right")}/** 3252 * @license 3253 * Copyright 2018 Google LLC. All Rights Reserved. 3254 * Licensed under the Apache License, Version 2.0 (the "License"); 3255 * you may not use this file except in compliance with the License. 3256 * You may obtain a copy of the License at 3257 * 3258 * http://www.apache.org/licenses/LICENSE-2.0 3259 * 3260 * Unless required by applicable law or agreed to in writing, software 3261 * distributed under the License is distributed on an "AS IS" BASIS, 3262 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3263 * See the License for the specific language governing permissions and 3264 * limitations under the License. 3265 * ============================================================================= 3266 */function D2(n,e=!0,t,r){return F.makeVariable(n,e,t,r)}/** 3267 * @license 3268 * Copyright 2018 Google LLC. All Rights Reserved. 3269 * Licensed under the Apache License, Version 2.0 (the "License"); 3270 * you may not use this file except in compliance with the License. 3271 * You may obtain a copy of the License at 3272 * 3273 * http://www.apache.org/licenses/LICENSE-2.0 3274 * 3275 * Unless required by applicable law or agreed to in writing, software 3276 * distributed under the License is distributed on an "AS IS" BASIS, 3277 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3278 * See the License for the specific language governing permissions and 3279 * limitations under the License. 3280 * ============================================================================= 3281 */function Mg(n,e){const t=[];for(let a=0;a<e.length;a++)e[a]&&t.push(a);const r=at(n,"int32"),s=at([t.length,n.length],"int32");for(let a=0;a<t.length;a++){const o=r.indexToLoc(t[a]),i=a*n.length;s.values.set(o,i)}return s.toTensor()}/** 3282 * @license 3283 * Copyright 2020 Google LLC. All Rights Reserved. 3284 * Licensed under the Apache License, Version 2.0 (the "License"); 3285 * you may not use this file except in compliance with the License. 3286 * You may obtain a copy of the License at 3287 * 3288 * http://www.apache.org/licenses/LICENSE-2.0 3289 * 3290 * Unless required by applicable law or agreed to in writing, software 3291 * distributed under the License is distributed on an "AS IS" BASIS, 3292 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3293 * See the License for the specific language governing permissions and 3294 * limitations under the License. 3295 * ============================================================================= 3296 */async function O2(n){const e=_(n,"condition","whereAsync","bool"),t=await e.data(),r=Mg(e.shape,t);return n!==e&&e.dispose(),r}const Bg=O2;/** 3297 * @license 3298 * Copyright 2018 Google LLC. All Rights Reserved. 3299 * Licensed under the Apache License, Version 2.0 (the "License"); 3300 * you may not use this file except in compliance with the License. 3301 * You may obtain a copy of the License at 3302 * 3303 * http://www.apache.org/licenses/LICENSE-2.0 3304 * 3305 * Unless required by applicable law or agreed to in writing, software 3306 * distributed under the License is distributed on an "AS IS" BASIS, 3307 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3308 * See the License for the specific language governing permissions and 3309 * limitations under the License. 3310 * ============================================================================= 3311 */async function F2(n,e,t){const r=_(n,"tensor","boolMask"),s=_(e,"mask","boolMask","bool"),a=t==null?0:t,o=s.rank,i=r.shape;N(o>0,()=>"mask cannot be scalar"),sn(i.slice(a,a+o),s.shape,"mask's shape must match the first K dimensions of tensor's shape,");let c=1;for(let g=a;g<a+o;g++)c*=i[g];const l=i.slice(0,a).concat([c],i.slice(a+o)),u=q(r,l),d=q(s,[-1]),p=await Bg(d),h=xt(p,[1]),m=lg(u,h,a);return n!==r&&r.dispose(),e!==s&&s.dispose(),h.dispose(),u.dispose(),d.dispose(),p.dispose(),m}const P2=F2;/** 3312 * @license 3313 * Copyright 2018 Google LLC. All Rights Reserved. 3314 * Licensed under the Apache License, Version 2.0 (the "License");
3315 * you may not use this file except in compliance with the License. 3316 * You may obtain a copy of the License at 3317 * 3318 * http://www.apache.org/licenses/LICENSE-2.0 3319 * 3320 * Unless required by applicable law or agreed to in writing, software 3321 * distributed under the License is distributed on an "AS IS" BASIS, 3322 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3323 * See the License for the specific language governing permissions and 3324 * limitations under the License. 3325 * ============================================================================= 3326 */function L2(n,e,t){const r=_(n,"x","transpose");if(e==null&&(e=r.shape.map((o,i)=>i).reverse()),N(r.rank===e.length,()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${e}.`),e.forEach(o=>{N(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 s={x:r},a={perm:e};return r.dtype==="complex64"?Ne(()=>{let o=bo(r),i=zu(r);return o=F.runKernel(ma,{x:o},a),i=F.runKernel(ma,{x:i},a),t&&(i=ar(i)),zr(o,i)}):F.runKernel(ma,s,a)}const Yc=D({transpose_:L2});/** 3327 * @license 3328 * Copyright 2018 Google LLC. All Rights Reserved. 3329 * Licensed under the Apache License, Version 2.0 (the "License"); 3330 * you may not use this file except in compliance with the License. 3331 * You may obtain a copy of the License at 3332 * 3333 * http://www.apache.org/licenses/LICENSE-2.0 3334 * 3335 * Unless required by applicable law or agreed to in writing, software 3336 * distributed under the License is distributed on an "AS IS" BASIS, 3337 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3338 * See the License for the specific language governing permissions and 3339 * limitations under the License. 3340 * ============================================================================= 3341 */function M2(n,e,t,r,s=!0){const a=_(n,"v","movingAverage"),o=_(e,"x","movingAverage"),i=_(t,"decay","movingAverage");fw(a,o),N(st(a.shape,o.shape),()=>"Shape mismatch in v and x");const c=Re(1),l=Ce(c,i);let u=Z(Ce(o,a),l);if(s){N(r!=null,()=>"When using zeroDebias: true, step is required.");const d=_(r,"step","movingAverage");u=Te(u,Ce(c,mo(i,d)))}return me(a,u)}const B2=D({movingAverage_:M2});/** 3342 * @license 3343 * Copyright 2018 Google LLC. All Rights Reserved. 3344 * Licensed under the Apache License, Version 2.0 (the "License"); 3345 * you may not use this file except in compliance with the License. 3346 * You may obtain a copy of the License at 3347 * 3348 * http://www.apache.org/licenses/LICENSE-2.0 3349 * 3350 * Unless required by applicable law or agreed to in writing, software 3351 * distributed under the License is distributed on an "AS IS" BASIS, 3352 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3353 * See the License for the specific language governing permissions and 3354 * limitations under the License. 3355 * ============================================================================= 3356 */function V2(n,e,t){fn(t);const r=_(n,"indices","scatterND","int32"),s=_(e,"updates","scatterND");Ip(s,r,t);const a={indices:r,updates:s},o={shape:t};return F.runKernel(Cu,a,o)}const W2=D({scatterND_:V2});function U2(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 s=n.rank>0?n.shape[0]:1,a=n.rank>1?n.shape[1]:1;if(t.length!==a)throw new Error(`outputShape has incorrect number of elements:, ${t.length}, should be: ${a}.`);const o=e.size;if(!(e.rank===0||e.rank===1&&o===s))throw new Error(`sparseValues has incorrect shape ${e.shape}, should be [] or [${s}]`);if(e.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}/** 3357 * @license 3358 * Copyright 2018 Google LLC. All Rights Reserved. 3359 * Licensed under the Apache License, Version 2.0 (the "License"); 3360 * you may not use this file except in compliance with the License. 3361 * You may obtain a copy of the License at 3362 * 3363 * http://www.apache.org/licenses/LICENSE-2.0 3364 * 3365 * Unless required by applicable law or agreed to in writing, softw
3365are 3366 * distributed under the License is distributed on an "AS IS" BASIS, 3367 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3368 * See the License for the specific language governing permissions and 3369 * limitations under the License. 3370 * ============================================================================= 3371 */function z2(n,e,t,r=0){fn(t);const s=_(n,"sparseIndices","sparseToDense","int32"),a=_(e,"sparseValues","sparseToDense","string_or_numeric"),o=_(r,"defaultValue","sparseToDense",a.dtype);U2(s,a,t,o);const i={sparseIndices:s,sparseValues:a,defaultValue:o},c={outputShape:t};return F.runKernel(Ru,i,c)}const G2=D({sparseToDense_:z2});/** 3372 * @license 3373 * Copyright 2018 Google LLC. All Rights Reserved. 3374 * Licensed under the Apache License, Version 2.0 (the "License"); 3375 * you may not use this file except in compliance with the License. 3376 * You may obtain a copy of the License at 3377 * 3378 * http://www.apache.org/licenses/LICENSE-2.0 3379 * 3380 * Unless required by applicable law or agreed to in writing, software 3381 * distributed under the License is distributed on an "AS IS" BASIS, 3382 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3383 * See the License for the specific language governing permissions and 3384 * limitations under the License. 3385 * ============================================================================= 3386 */function H2(n,e){const t=_(e,"indices","gatherND","int32"),s={params:_(n,"x","gatherND","string_or_numeric"),indices:t};return F.runKernel(su,s)}const j2=D({gatherND_:H2});/** 3387 * @license 3388 * Copyright 2019 Google LLC. All Rights Reserved. 3389 * Licensed under the Apache License, Version 2.0 (the "License"); 3390 * you may not use this file except in compliance with the License. 3391 * You may obtain a copy of the License at 3392 * 3393 * http://www.apache.org/licenses/LICENSE-2.0 3394 * 3395 * Unless required by applicable law or agreed to in writing, software 3396 * distributed under the License is distributed on an "AS IS" BASIS, 3397 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3398 * See the License for the specific language governing permissions and 3399 * limitations under the License. 3400 * ============================================================================= 3401 */function q2(n,e){if(e==null)return n.shape.slice();if(st(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}/** 3402 * @license 3403 * Copyright 2018 Google LLC. All Rights Reserved. 3404 * Licensed under the Apache License, Version 2.0 (the "License"); 3405 * you may not use this file except in compliance with the License. 3406 * You may obtain a copy of the License at 3407 * 3408 * http://www.apache.org/licenses/LICENSE-2.0 3409 * 3410 * Unless required by applicable law or agreed to in writing, software 3411 * distributed under the License is distributed on an "AS IS" BASIS, 3412 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3413 * See the License for the specific language governing permissions and 3414 * limitations under the License. 3415 * ============================================================================= 3416 */function K2(n,e,t,r){const s=_(n,"x","dropout");if(N(s.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${s.dtype} tensor instead.`),N(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return n instanceof dt?s.clone():s;const a=q2(s,t),o=1-e,i=Te(cg(me(xp(a,0,1,"float32",r),o)),o);return Z(s,i)}const X2=D({dropout_:K2});/** 3417 * @license 3418 * Copyright 2019 Google LLC. All Rights Reserved. 3419 * Licensed under the Apache License, Version 2.0 (the "License"); 3420 * you may not use this file except in compliance with the License. 3421 * You may obtain a copy of the License at 3422 * 3423 * http://www.apache.org/licenses/LICENSE-2.0 3424 * 3425 * Unless required by applicable law or agreed to in writing, software 3426 * distributed under the License is distributed on an "AS IS" BASIS, 3427 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3428 * See the License for the specific language governing permissions and 3429 * limitations under the License. 3430 * ============================================================================= 3431 */function Vg(n){return Math.floor(Math.pow(2,Math.ceil(Math.log(n)/Math.log(2))))}function $p(n,e,t){const r=1-n%2,s=new Float32Array(n);for(let a=0;a<n;++a){const o=2*Math.PI*a/(n+r-1);s[a]=e-t*Math.cos(o)}return Rt(s,"float32")}/** 3432 * @license 3433 * Copyright 2019 Google LLC. All Rights Reserved. 3434 * Licensed under the Apache License, Version 2.0 (the "License");
3435 * you may not use this file except in compliance with the License. 3436 * You may obtain a copy of the License at 3437 * 3438 * http://www.apache.org/licenses/LICENSE-2.0 3439 * 3440 * Unless required by applicable law or agreed to in writing, software 3441 * distributed under the License is distributed on an "AS IS" BASIS, 3442 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3443 * See the License for the specific language governing permissions and 3444 * limitations under the License. 3445 * ============================================================================= 3446 */async function Y2(n,e,t=1){const r=_(n,"predictions","inTopK"),s=_(e,"targets","inTopK");N(r.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`),N(r.rank-1===s.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${s.rank}`),sn(r.shape.slice(0,r.shape.length-1),s.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const a=r.shape[r.shape.length-1];N(t>0&&t<=a,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${a}), but got ${t}`);const o=await r.data(),i=await s.data(),[c,l]=[o.length/a,a],u=Wr("bool",c);for(let d=0;d<c;d++){const p=d*l,h=o.subarray(p,p+l),m=[];for(let g=0;g<h.length;g++)m.push({value:h[g],index:g});m.sort((g,y)=>y.value-g.value),u[d]=0;for(let g=0;g<t;g++)if(m[g].index===i[d]){u[d]=1;break}}return n!==r&&r.dispose(),e!==s&&s.dispose(),zn(u,s.shape,"bool")}const Q2=Y2;/** 3447 * @license 3448 * Copyright 2020 Google LLC. All Rights Reserved. 3449 * Licensed under the Apache License, Version 2.0 (the "License"); 3450 * you may not use this file except in compliance with the License. 3451 * You may obtain a copy of the License at 3452 * 3453 * http://www.apache.org/licenses/LICENSE-2.0 3454 * 3455 * Unless required by applicable law or agreed to in writing, software 3456 * distributed under the License is distributed on an "AS IS" BASIS, 3457 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3458 * See the License for the specific language governing permissions and 3459 * limitations under the License. 3460 * ============================================================================= 3461 */function Z2(n,e,t,r,s,a="NHWC",o){let i=n;n.rank===3&&(i=q(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let c=e;c.rank===3&&(c=q(e,[1,e.shape[0],e.shape[1],e.shape[2]])),N(i.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`),N(c.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${c.shape}.`),N(t.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${t}.`);const l=a==="NHWC"?i.shape[3]:i.shape[1],u=a==="NHWC"?c.shape[3]:c.shape[1];N(l===t[2],()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${t[2]}.`),N(u===t[3],()=>`Error in conv2dDerFilter: depth of dy (${u}) must match output depth for filter (${t[3]}).`),En("conv2dDerFilter",s,o);const d={x:i,dy:c},p={strides:r,pad:s,dataFormat:a,dimRoundingMode:o,filterShape:t};return F.runKernel(Jf,d,p)}const J2=D({conv2DBackpropFilter_:Z2});/** 3462 * @license 3463 * Copyright 2019 Google LLC. All Rights Reserved. 3464 * Licensed under the Apache License, Version 2.0 (the "License"); 3465 * you may not use this file except in compliance with the License. 3466 * You may obtain a copy of the License at 3467 * 3468 * http://www.apache.org/licenses/LICENSE-2.0 3469 * 3470 * Unless required by applicable law or agreed to in writing, software 3471 * distributed under the License is distributed on an "AS IS" BASIS, 3472 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3473 * See the License for the specific language governing permissions and 3474 * limitations under the License. 3475 * ============================================================================= 3476 */function Hu(n,e,t){if(t==null||t==="linear")return n;if(t==="relu")return Z(n,Fg(e));throw new Error(`Cannot compute gradient for fused activation ${t}.`)}function ju(n,e){let t=e;const r=rg(n.shape,e.shape);return r.length>0&&(t=Ke(t,r)),q(t,n.shape)}function qu(n,e,t,r){if(e==="linear")return n;if(e==="relu")return Gu(n);if(e==="elu")return ag(n);if(e==="relu6")return Rg(n);if(e==="prelu")return Ig(n,t);if(e==="leakyrelu")return pg(n,r);if(e==="sigmoid")return Is(n);throw new Error(`Unknown fused activation ${e}.`)}const Ku=(n,e)=>!(n>0)||e==="linear";/** 3477 * @license 3478 * Copyright 2019 Google LLC. All Rights Reserved. 3479 * Licensed under the Apache License, Version 2.0 (the "License");
3480 * you may not use this file except in compliance with the License. 3481 * You may obtain a copy of the License at 3482 * 3483 * http://www.apache.org/licenses/LICENSE-2.0 3484 * 3485 * Unless required by applicable law or agreed to in writing, software 3486 * distributed under the License is distributed on an "AS IS" BASIS, 3487 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3488 * See the License for the specific language governing permissions and 3489 * limitations under the License. 3490 * ============================================================================= 3491 */function eC({x:n,filter:e,strides:t,pad:r,dataFormat:s="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:c="linear",preluActivationWeights:l,leakyreluAlpha:u}){if(c=c||"linear",Ku(F.state.gradientDepth,c)===!1){N(s==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${s} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let O=Vu(n,e,t,r,s,a,o);return i!=null&&(O=me(O,i)),qu(O,c,l,u)}const d=_(n,"x","conv2d","float32"),p=_(e,"filter","conv2d","float32");let h=d,m=!1;d.rank===3&&(m=!0,h=q(d,[1,d.shape[0],d.shape[1],d.shape[2]])),N(h.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`),N(p.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${p.rank}.`),En("fused conv2d",r,o);const g=s==="NHWC"?h.shape[3]:h.shape[1];N(p.shape[2]===g,()=>`Error in conv2d: depth of input (${g}) must match input depth for filter ${p.shape[2]}.`),N(Kt(t,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`);const y=$t(h.shape,p.shape,t,a,r,o);let b;i!=null&&(b=_(i,"bias","fused conv2d"),[b]=ut(b,d),s==="NHWC"?ke(y.outShape,b.shape):(N(b.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${b.shape.length}.`),N(b.shape.length===0||b.shape[0]===y.outChannels||b.shape[0]===1,()=>`Error in fused conv2d: bias shape (${b.shape}) is not compatible with the number of output channels (${y.outChannels})`)));let v;if(l!=null){const O=l.shape;if(N(O.length<=1||O.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-${O.length}.`),O.length===1)N(O[0]===1||O[0]===y.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${O}) is not compatible with the number of output channels (${y.outChannels}).`);else if(O.length===3)try{ke(O,y.outShape)}catch{const M=`Error in fused conv2d: PReLU activation weights (${O}) is not compatible with the output shape of the conv2d (${y.outShape}).`;throw Error(M)}v=_(l,"prelu weights","fused conv2d")}const $=(O,L)=>{N(s==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${s} but only NHWC is currently supported.`);const[M,W,V,G]=L,K=Hu(O,V,c);N(fo(a),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`);const J=ng(W.shape,K,M,t,r),ue=J2(W,K,M.shape,t,r),se=[J,ue];if(G!=null){const fe=ju(G,K);se.push(fe)}return se},S={x:h,filter:p,bias:b,preluActivationWeights:v},T={strides:t,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o,activation:c,leakyreluAlpha:u};return i==null?wr((L,M,W)=>{let V=F.runKernel(co,S,T);return W([M,L,V]),m&&(V=q(V,[V.shape[1],V.shape[2],V.shape[3]])),{value:V,gradFunc:$}})(h,p):wr((L,M,W,V)=>{let G=F.runKernel(co,S,T);return V([M,L,G,W]),m&&(G=q(G,[G.shape[1],G.shape[2],G.shape[3]])),{value:G,gradFunc:$}})(h,p,b)}const tC=D({fusedConv2d_:eC});/** 3492 * @license 3493 * Copyright 2020 Google LLC. All Rights Reserved. 3494 * Licensed under the Apache License, Version 2.0 (the "License"); 3495 * you may not use this file except in compliance with the License. 3496 * You may obtain a copy of the License at 3497 * 3498 * http://www.apache.org/licenses/LICENSE-2.0 3499 * 3500 * Unless required by applicable law or agreed to in writing, software 3501 * distributed under the License is distributed on an "AS IS" BASIS, 3502 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3503 * See the License for the specific language governing permissions and 3504 * limitations under the License. 3505 * ============================================================================= 3506 */function nC(n,e,t,r,s,a=[1,1],o){let i=n;n.rank===3&&(i=q(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let c=e;c.rank===3&&(c=q(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const l={x:i,dy:c},u={strides:r,pad:s,dimRoundingMode:o,dilations:a,filterShape:t};return F.runKernel(em,l,u)}const rC=D({depthwiseConv2dNativeBackpropFilter_:nC});/** 3507 * @license 3508 * Copyright 2020 Google LLC. All Rights Reserved. 3509 * Licensed under the Apache License, Version 2.0 (the "License");
3510 * you may not use this file except in compliance with the License. 3511 * You may obtain a copy of the License at 3512 * 3513 * http://www.apache.org/licenses/LICENSE-2.0 3514 * 3515 * Unless required by applicable law or agreed to in writing, software 3516 * distributed under the License is distributed on an "AS IS" BASIS, 3517 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3518 * See the License for the specific language governing permissions and 3519 * limitations under the License. 3520 * ============================================================================= 3521 */function sC(n,e,t,r,s,a=[1,1],o){let i=e,c=!1;e.rank===3&&(c=!0,i=q(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const l={dy:i,filter:t},u={strides:r,pad:s,dimRoundingMode:o,dilations:a,inputShape:n},d=F.runKernel(tm,l,u);return c?q(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const aC=D({depthwiseConv2dNativeBackpropInput_:sC});/** 3522 * @license 3523 * Copyright 2019 Google LLC. All Rights Reserved. 3524 * Licensed under the Apache License, Version 2.0 (the "License"); 3525 * you may not use this file except in compliance with the License. 3526 * You may obtain a copy of the License at 3527 * 3528 * http://www.apache.org/licenses/LICENSE-2.0 3529 * 3530 * Unless required by applicable law or agreed to in writing, software 3531 * distributed under the License is distributed on an "AS IS" BASIS, 3532 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3533 * See the License for the specific language governing permissions and 3534 * limitations under the License. 3535 * ============================================================================= 3536 */function oC({x:n,filter:e,strides:t,pad:r,dataFormat:s="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:c="linear",preluActivationWeights:l,leakyreluAlpha:u}){if(Ku(F.state.gradientDepth,c)===!1){let T=hp(n,e,t,r,s,a,o);return i!=null&&(T=me(T,i)),qu(T,c,l,u)}const d=_(n,"x","depthwiseConv2d","float32"),p=_(e,"filter","depthwiseConv2d","float32");let h=d,m=!1;d.rank===3&&(m=!0,h=q(d,[1,d.shape[0],d.shape[1],d.shape[2]])),N(h.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`),N(p.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`),N(h.shape[3]===p.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${p.shape[2]}.`),a==null&&(a=[1,1]),N(Kt(t,a),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`),En("fused depthwiseConv2d",r,o);const g=$t(h.shape,p.shape,t,a,r,o,!0);let y;i!=null&&(y=_(i,"bias","fused conv2d"),[y]=ut(y,d),ke(g.outShape,y.shape));let b;l!=null&&(b=_(l,"prelu weights","fused depthwiseConv2d"));const v=(T,O)=>{N(fo(a),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);const[L,M,W,V]=O,G=Hu(T,W,c),K=aC(M.shape,G,L,t,r,a,o),J=rC(M,G,L.shape,t,r,a,o);if(V!=null){const ue=ju(y,G);return[K,J,ue]}return[K,J]},$={x:h,filter:p,bias:y,preluActivationWeights:b},S={strides:t,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o,activation:c,leakyreluAlpha:u};return i==null?wr((O,L,M)=>{let W=F.runKernel(lo,$,S);return M([L,O,W]),m&&(W=q(W,[W.shape[1],W.shape[2],W.shape[3]])),{value:W,gradFunc:v}})(h,p):wr((O,L,M,W)=>{let V=F.runKernel(lo,$,S);return W([L,O,V,M]),m&&(V=q(V,[V.shape[1],V.shape[2],V.shape[3]])),{value:V,gradFunc:v}})(h,p,y)}const iC=D({fusedDepthwiseConv2d_:oC});/** 3537 * @license 3538 * Copyright 2019 Google LLC. All Rights Reserved. 3539 * Licensed under the Apache License, Version 2.0 (the "License"); 3540 * you may not use this file except in compliance with the License. 3541 * You may obtain a copy of the License at 3542 * 3543 * http://www.apache.org/licenses/LICENSE-2.0 3544 * 3545 * Unless required by applicable law or agreed to in writing, software 3546 * distributed under the License is distributed on an "AS IS" BASIS, 3547 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3548 * See the License for the specific language governing permissions and 3549 * limitations under the License. 3550 * ============================================================================= 3551 */function uC({a:n,b:e,transposeA:t=!1,transposeB:r=!1,bias:s,activation:a="linear",preluActivationWeights:o,leakyreluAlpha:i=.2}){if(Ku(F.state.gradientDepth,a)===!1){let G=Ue(n,e,t,r);return s!=null&&(G=me(G,s)),qu(G,a,o,i)}let c=_(n,"a","fused matMul"),l=_(e,"b","fused matMul");[c,l]=ut(c,l);const u=t?c.shape[c.rank-2]:c.shape[c.rank-1],d=r?l.shape[l.rank-1]:l.shape[l.rank-2],p=t?c.shape[c.rank-1]:c.shape[c.rank-2],h=r?l.shape[l.rank-2]:l.shape[l.rank-1],m=c.shape.slice(0,-2),g=l.shape.slice(0,-2),y=H(m),b=H(g);N(u===d,()=>`Error in fused matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${c.shape} and ${l.shape} and transposeA=${t} and transposeB=${r} must match.`);
vendor: 4,383 bytes, lines 3551-3614
3551const $=ke(c.shape.slice(0,-2),l.shape.slice(0,-2)).concat([p,h]),S=t?q(c,[y,u,p]):q(c,[y,p,u]),T=r?q(l,[b,h,d]):q(l,[b,d,h]);let O;s!=null&&(O=_(s,"bias","fused matMul"),[O]=ut(O,c),ke($,O.shape));let L;o!=null&&(L=_(o,"prelu weights","fused matMul"));const M=(G,K)=>{const[J,ue,se,fe]=K,Ie=Hu(q(G,se.shape),se,a);let pe,Fe;if(!t&&!r?(pe=Ue(Ie,ue,!1,!0),Fe=Ue(J,Ie,!0,!1)):!t&&r?(pe=Ue(Ie,ue,!1,!1),Fe=Ue(Ie,J,!0,!1)):t&&!r?(pe=Ue(ue,Ie,!1,!0),Fe=Ue(J,Ie,!1,!1)):(pe=Ue(ue,Ie,!0,!0),Fe=Ue(Ie,J,!0,!0)),s!=null){const Qe=ju(fe,Ie);return[pe,Fe,Qe]}else return[pe,Fe]},W={a:S,b:T,bias:O,preluActivationWeights:L},V={transposeA:t,transposeB:r,activation:a,leakyreluAlpha:i};return s==null?wr((K,J,ue)=>{const se=F.runKernel(uo,W,V);return ue([K,J,se]),{value:q(se,$),gradFunc:M}})(S,T):wr((K,J,ue,se)=>{const fe=F.runKernel(uo,W,V);return se([K,J,fe,ue]),{value:q(fe,$),gradFunc:M}})(S,T,O)}const cC=D({fusedMatMul_:uC});/** 3552 * @license 3553 * Copyright 2019 Google LLC. All Rights Reserved. 3554 * Licensed under the Apache License, Version 2.0 (the "License"); 3555 * you may not use this file except in compliance with the License. 3556 * You may obtain a copy of the License at 3557 * 3558 * http://www.apache.org/licenses/LICENSE-2.0 3559 * 3560 * Unless required by applicable law or agreed to in writing, software 3561 * distributed under the License is distributed on an "AS IS" BASIS, 3562 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3563 * See the License for the specific language governing permissions and 3564 * limitations under the License. 3565 * ============================================================================= 3566 */const lC=Object.freeze(Object.defineProperty({__proto__:null,conv2d:tC,depthwiseConv2d:iC,matMul:cC},Symbol.toStringTag,{value:"Module"}));/** 3567 * @license 3568 * Copyright 2019 Google LLC. All Rights Reserved. 3569 * Licensed under the Apache License, Version 2.0 (the "License"); 3570 * you may not use this file except in compliance with the License. 3571 * You may obtain a copy of the License at 3572 * 3573 * http://www.apache.org/licenses/LICENSE-2.0 3574 * 3575 * Unless required by applicable law or agreed to in writing, software 3576 * distributed under the License is distributed on an "AS IS" BASIS, 3577 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3578 * See the License for the specific language governing permissions and 3579 * limitations under the License. 3580 * ============================================================================= 3581 */function dC(n){return $p(n,.54,.46)}const pC=D({hammingWindow_:dC});/** 3582 * @license 3583 * Copyright 2019 Google LLC. All Rights Reserved. 3584 * Licensed under the Apache License, Version 2.0 (the "License"); 3585 * you may not use this file except in compliance with the License. 3586 * You may obtain a copy of the License at 3587 * 3588 * http://www.apache.org/licenses/LICENSE-2.0 3589 * 3590 * Unless required by applicable law or agreed to in writing, software 3591 * distributed under the License is distributed on an "AS IS" BASIS, 3592 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3593 * See the License for the specific language governing permissions and 3594 * limitations under the License. 3595 * ============================================================================= 3596 */function hC(n){return $p(n,.5,.5)}const Wg=D({hannWindow_:hC});/** 3597 * @license 3598 * Copyright 2019 Google LLC. All Rights Reserved. 3599 * Licensed under the Apache License, Version 2.0 (the "License"); 3600 * you may not use this file except in compliance with the License. 3601 * You may obtain a copy of the License at 3602 * 3603 * http://www.apache.org/licenses/LICENSE-2.0 3604 * 3605 * Unless required by applicable law or agreed to in writing, software 3606 * distributed under the License is distributed on an "AS IS" BASIS, 3607 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3608 * See the License for the specific language governing permissions and 3609 * limitations under the License. 3610 * ============================================================================= 3611 */function fC(n,e,t,r=!1,s=0){let a=0;const o=[];for(;a+e<=n.size;)o.push(Se(n,a,e)),a+=t;if(r)for(;a<n.size;){const i=a+e-n.size,c=It([Se(n,a,e-i),ko([i],s)]);o.push(c),a+=t}return o.length===0?$s([],[0,e]):q(It(o),[o.length,e])}const Ug=D({frame_:fC});/** 3612 * @license 3613 * Copyright 2019 Google LLC. All Rights Reserved. 3614 * Licensed under the Apache License, Version 2.0 (the "License");
3615 * you may not use this file except in compliance with the License. 3616 * You may obtain a copy of the License at 3617 * 3618 * http://www.apache.org/licenses/LICENSE-2.0 3619 * 3620 * Unless required by applicable law or agreed to in writing, software 3621 * distributed under the License is distributed on an "AS IS" BASIS, 3622 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3623 * See the License for the specific language governing permissions and 3624 * limitations under the License. 3625 * ============================================================================= 3626 */function mC(n,e,t,r,s=Wg){r==null&&(r=Vg(e));const a=Ug(n,e,t),o=Z(a,s(e));return vp(o,r)}const gC=D({stft_:mC});/** 3627 * @license 3628 * Copyright 2020 Google LLC. All Rights Reserved. 3629 * Licensed under the Apache License, Version 2.0 (the "License"); 3630 * you may not use this file except in compliance with the License. 3631 * You may obtain a copy of the License at 3632 * 3633 * http://www.apache.org/licenses/LICENSE-2.0 3634 * 3635 * Unless required by applicable law or agreed to in writing, software 3636 * distributed under the License is distributed on an "AS IS" BASIS, 3637 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3638 * See the License for the specific language governing permissions and 3639 * limitations under the License. 3640 * ============================================================================= 3641 */function yC(n,e,t,r,s="bilinear",a=0){const o=_(n,"image","cropAndResize"),i=_(e,"boxes","cropAndResize","float32"),c=_(t,"boxInd","cropAndResize","int32"),l=i.shape[0];N(o.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`),N(i.rank===2&&i.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${i.shape}.`),N(c.rank===1&&c.shape[0]===l,()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${i.shape}.`),N(r.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`),N(r[0]>=1&&r[1]>=1,()=>`cropSize must be atleast [1,1], but was ${r}`),N(s==="bilinear"||s==="nearest",()=>`method must be bilinear or nearest, but was ${s}`);const u={image:o,boxes:i,boxInd:c},d={method:s,extrapolationValue:a,cropSize:r};return F.runKernel(Zi,u,d)}const bC=D({cropAndResize_:yC});/** 3642 * @license 3643 * Copyright 2020 Google LLC. All Rights Reserved. 3644 * Licensed under the Apache License, Version 2.0 (the "License"); 3645 * you may not use this file except in compliance with the License. 3646 * You may obtain a copy of the License at 3647 * 3648 * http://www.apache.org/licenses/LICENSE-2.0 3649 * 3650 * Unless required by applicable law or agreed to in writing, software 3651 * distributed under the License is distributed on an "AS IS" BASIS, 3652 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3653 * See the License for the specific language governing permissions and 3654 * limitations under the License. 3655 * ============================================================================= 3656 */function xC(n){const e=_(n,"image","flipLeftRight","float32");N(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const t={image:e};return F.runKernel(nu,t,{})}const wC=D({flipLeftRight_:xC});/** 3657 * @license 3658 * Copyright 2021 Google LLC. All Rights Reserved. 3659 * Licensed under the Apache License, Version 2.0 (the "License"); 3660 * you may not use this file except in compliance with the License. 3661 * You may obtain a copy of the License at 3662 * 3663 * http://www.apache.org/licenses/LICENSE-2.0 3664 * 3665 * Unless required by applicable law or agreed to in writing, software 3666 * distributed under the License is distributed on an "AS IS" BASIS, 3667 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3668 * See the License for the specific language governing permissions and 3669 * limitations under the License. 3670 * ============================================================================= 3671 */function vC(n){const e=_(n,"image","grayscaleToRGB"),t=e.rank-1,r=e.shape[t];N(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),N(r===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);const s=new Array(e.rank);return s.fill(1,0,t),s[t]=3,io(e,s)}const IC=D({grayscaleToRGB_:vC});/** 3672 * @license 3673 * Copyright 2023 Google LLC. 3674 * Licensed under the Apache License, Version 2.0 (the "License");
3675 * you may not use this file except in compliance with the License. 3676 * You may obtain a copy of the License at 3677 * 3678 * http://www.apache.org/licenses/LICENSE-2.0 3679 * 3680 * Unless required by applicable law or agreed to in writing, software 3681 * distributed under the License is distributed on an "AS IS" BASIS, 3682 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3683 * See the License for the specific language governing permissions and 3684 * limitations under the License. 3685 * ============================================================================= 3686 */function $C(n){const e=_(n,"image","RGBToGrayscale"),t=e.rank-1,r=e.shape[t];N(e.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`),N(r===3,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`);const s=e.dtype,a=rt(e,"float32"),o=Rt([.2989,.587,.114]);let i;switch(e.rank){case 2:i=pa("ij,j->i",a,o);break;case 3:i=pa("ijk,k->ij",a,o);break;case 4:i=pa("ijkl,l->ijk",a,o);break;case 5:i=pa("ijklm,m->ijkl",a,o);break;case 6:i=pa("ijklmn,n->ijklm",a,o);break;default:throw new Error("Not a valid tensor rank.")}return i=nr(i,-1),rt(i,s)}const SC=D({rgbToGrayscale_:$C});/** 3687 * @license 3688 * Copyright 2020 Google LLC. All Rights Reserved. 3689 * Licensed under the Apache License, Version 2.0 (the "License"); 3690 * you may not use this file except in compliance with the License. 3691 * You may obtain a copy of the License at 3692 * 3693 * http://www.apache.org/licenses/LICENSE-2.0 3694 * 3695 * Unless required by applicable law or agreed to in writing, software 3696 * distributed under the License is distributed on an "AS IS" BASIS, 3697 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3698 * See the License for the specific language governing permissions and 3699 * limitations under the License. 3700 * ============================================================================= 3701 */function CC(n,e,t=0,r=.5){const s=_(n,"image","rotateWithOffset","float32");N(s.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${s.rank}.`);const a={image:s},o={radians:e,fillValue:t,center:r};return F.runKernel(Pu,a,o)}const _C=D({rotateWithOffset_:CC});/** 3702 * @license 3703 * Copyright 2020 Google LLC. All Rights Reserved. 3704 * Licensed under the Apache License, Version 2.0 (the "License"); 3705 * you may not use this file except in compliance with the License. 3706 * You may obtain a copy of the License at 3707 * 3708 * http://www.apache.org/licenses/LICENSE-2.0 3709 * 3710 * Unless required by applicable law or agreed to in writing, software 3711 * distributed under the License is distributed on an "AS IS" BASIS, 3712 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3713 * See the License for the specific language governing permissions and 3714 * limitations under the License. 3715 * ============================================================================= 3716 */function Ra(n,e,t,r,s,a){r==null&&(r=.5),s==null&&(s=Number.NEGATIVE_INFINITY),a==null&&(a=0);const o=n.shape[0];return t=Math.min(t,o),N(0<=r&&r<=1,()=>`iouThreshold must be in [0, 1], but was '${r}'`),N(n.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${n.rank}'`),N(n.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${n.shape[1]}`),N(e.rank===1,()=>"scores must be a 1D tensor"),N(e.shape[0]===o,()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${e.shape[0]}`),N(0<=a&&a<=1,()=>`softNmsSigma must be in [0, 1], but was '${a}'`),{maxOutputSize:t,iouThreshold:r,scoreThreshold:s,softNmsSigma:a}}/** 3717 * @license 3718 * Copyright 2020 Google LLC. All Rights Reserved. 3719 * Licensed under the Apache License, Version 2.0 (the "License"); 3720 * you may not use this file except in compliance with the License. 3721 * You may obtain a copy of the License at 3722 * 3723 * http://www.apache.org/licenses/LICENSE-2.0 3724 * 3725 * Unless required by applicable law or agreed to in writing, software 3726 * distributed under the License is distributed on an "AS IS" BASIS, 3727 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3728 * See the License for the specific language governing permissions and 3729 * limitations under the License. 3730 * ============================================================================= 3731 */function NC(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY){const a=_(n,"boxes","nonMaxSuppression","float32"),o=_(e,"scores","nonMaxSuppression","float32"),i=Ra(a,o,t,r,s);t=i.maxOutputSize,r=i.iouThreshold,s=i.scoreThreshold;const c={maxOutputSize:t,iouThreshold:r,scoreThreshold:s};return F.runKernel(mu,{boxes:a,scores:o},c)}const TC=D({nonMaxSuppression_:NC});/** 3732 * @license 3733 * Copyright 2019 Google LLC. All Rights Reserved. 3734 * Licensed under the Apache License, Version 2.0 (the "License");
3735 * you may not use this file except in compliance with the License. 3736 * You may obtain a copy of the License at 3737 * 3738 * http://www.apache.org/licenses/LICENSE-2.0 3739 * 3740 * Unless required by applicable law or agreed to in writing, software 3741 * distributed under the License is distributed on an "AS IS" BASIS, 3742 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3743 * See the License for the specific language governing permissions and 3744 * limitations under the License. 3745 * ============================================================================= 3746 */function kC(n,e,t){const r=EC(n,e,t),s=r<0?-(r+1):r;n.splice(s,0,e)}function EC(n,e,t){return AC(n,e,t||RC)}function RC(n,e){return n>e?1:n<e?-1:0}function AC(n,e,t){let r=0,s=n.length,a=0,o=!1;for(;r<s;){a=r+(s-r>>>1);const i=t(e,n[a]);i>0?r=a+1:(s=a,o=!i)}return o?r:-r-1}/** 3747 * @license 3748 * Copyright 2020 Google LLC. All Rights Reserved. 3749 * Licensed under the Apache License, Version 2.0 (the "License"); 3750 * you may not use this file except in compliance with the License. 3751 * You may obtain a copy of the License at 3752 * 3753 * http://www.apache.org/licenses/LICENSE-2.0 3754 * 3755 * Unless required by applicable law or agreed to in writing, software 3756 * distributed under the License is distributed on an "AS IS" BASIS, 3757 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3758 * See the License for the specific language governing permissions and 3759 * limitations under the License. 3760 * ============================================================================= 3761 */function zg(n,e,t,r,s){return Sp(n,e,t,r,s,0)}function Gg(n,e,t,r,s,a){return Sp(n,e,t,r,s,0,!1,a,!0)}function Hg(n,e,t,r,s,a){return Sp(n,e,t,r,s,a,!0)}function Sp(n,e,t,r,s,a,o=!1,i=!1,c=!1){const l=[];for(let y=0;y<e.length;y++)e[y]>s&&l.push({score:e[y],boxIndex:y,suppressBeginIndex:0});l.sort(Bh);const u=a>0?-.5/a:0,d=[],p=[];for(;d.length<t&&l.length>0;){const y=l.pop(),{score:b,boxIndex:v,suppressBeginIndex:$}=y;if(b<s)break;let S=!1;for(let T=d.length-1;T>=$;--T){const O=DC(n,v,d[T]);if(O>=r){S=!0;break}if(y.score=y.score*OC(r,u,O),y.score<=s)break}y.suppressBeginIndex=d.length,S||(y.score===b?(d.push(v),p.push(y.score)):y.score>s&&kC(l,y,Bh))}const h=d.length,m=t-h;i&&m>0&&(d.push(...new Array(m).fill(0)),p.push(...new Array(m).fill(0)));const g={selectedIndices:d};return o&&(g.selectedScores=p),c&&(g.validOutputs=h),g}function DC(n,e,t){const r=n.subarray(e*4,e*4+4),s=n.subarray(t*4,t*4+4),a=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),c=Math.max(r[1],r[3]),l=Math.min(s[0],s[2]),u=Math.min(s[1],s[3]),d=Math.max(s[0],s[2]),p=Math.max(s[1],s[3]),h=(i-a)*(c-o),m=(d-l)*(p-u);if(h<=0||m<=0)return 0;const g=Math.max(a,l),y=Math.max(o,u),b=Math.min(i,d),v=Math.min(c,p),$=Math.max(b-g,0)*Math.max(v-y,0);return $/(h+m-$)}function OC(n,e,t){const r=Math.exp(e*t*t);return t<=n?r:0}function Bh(n,e){return n.score-e.score||n.score===e.score&&e.boxIndex-n.boxIndex}/** 3762 * @license 3763 * Copyright 2020 Google LLC. All Rights Reserved. 3764 * Licensed under the Apache License, Version 2.0 (the "License"); 3765 * you may not use this file except in compliance with the License. 3766 * You may obtain a copy of the License at 3767 * 3768 * http://www.apache.org/licenses/LICENSE-2.0 3769 * 3770 * Unless required by applicable law or agreed to in writing, software 3771 * distributed under the License is distributed on an "AS IS" BASIS, 3772 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3773 * See the License for the specific language governing permissions and 3774 * limitations under the License. 3775 * ============================================================================= 3776 */async function FC(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY){const a=_(n,"boxes","nonMaxSuppressionAsync"),o=_(e,"scores","nonMaxSuppressionAsync"),i=Ra(a,o,t,r,s);t=i.maxOutputSize,r=i.iouThreshold,s=i.scoreThreshold;const c=await Promise.all([a.data(),o.data()]),l=c[0],u=c[1],{selectedIndices:d}=zg(l,u,t,r,s);return a!==n&&a.dispose(),o!==e&&o.dispose(),Rt(d,"int32")}const PC=FC;/** 3777 * @license 3778 * Copyright 2020 Google LLC. All Rights Reserved. 3779 * Licensed under the Apache License, Version 2.0 (the "License");
3780 * you may not use this file except in compliance with the License. 3781 * You may obtain a copy of the License at 3782 * 3783 * http://www.apache.org/licenses/LICENSE-2.0 3784 * 3785 * Unless required by applicable law or agreed to in writing, software 3786 * distributed under the License is distributed on an "AS IS" BASIS, 3787 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3788 * See the License for the specific language governing permissions and 3789 * limitations under the License. 3790 * ============================================================================= 3791 */function LC(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,a=0){const o=_(n,"boxes","nonMaxSuppression"),i=_(e,"scores","nonMaxSuppression"),c=Ra(o,i,t,r,s,a);t=c.maxOutputSize,r=c.iouThreshold,s=c.scoreThreshold,a=c.softNmsSigma;const l={boxes:o,scores:i},u={maxOutputSize:t,iouThreshold:r,scoreThreshold:s,softNmsSigma:a},d=F.runKernel(yu,l,u);return{selectedIndices:d[0],selectedScores:d[1]}}const MC=D({nonMaxSuppressionWithScore_:LC});/** 3792 * @license 3793 * Copyright 2020 Google LLC. All Rights Reserved. 3794 * Licensed under the Apache License, Version 2.0 (the "License"); 3795 * you may not use this file except in compliance with the License. 3796 * You may obtain a copy of the License at 3797 * 3798 * http://www.apache.org/licenses/LICENSE-2.0 3799 * 3800 * Unless required by applicable law or agreed to in writing, software 3801 * distributed under the License is distributed on an "AS IS" BASIS, 3802 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3803 * See the License for the specific language governing permissions and 3804 * limitations under the License. 3805 * ============================================================================= 3806 */async function BC(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,a=0){const o=_(n,"boxes","nonMaxSuppressionAsync"),i=_(e,"scores","nonMaxSuppressionAsync"),c=Ra(o,i,t,r,s,a);t=c.maxOutputSize,r=c.iouThreshold,s=c.scoreThreshold,a=c.softNmsSigma;const l=await Promise.all([o.data(),i.data()]),u=l[0],d=l[1],{selectedIndices:p,selectedScores:h}=Hg(u,d,t,r,s,a);return o!==n&&o.dispose(),i!==e&&i.dispose(),{selectedIndices:Rt(p,"int32"),selectedScores:Rt(h)}}const VC=BC;/** 3807 * @license 3808 * Copyright 2020 Google LLC. All Rights Reserved. 3809 * Licensed under the Apache License, Version 2.0 (the "License"); 3810 * you may not use this file except in compliance with the License. 3811 * You may obtain a copy of the License at 3812 * 3813 * http://www.apache.org/licenses/LICENSE-2.0 3814 * 3815 * Unless required by applicable law or agreed to in writing, software 3816 * distributed under the License is distributed on an "AS IS" BASIS, 3817 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3818 * See the License for the specific language governing permissions and 3819 * limitations under the License. 3820 * ============================================================================= 3821 */function WC(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,a=!1){const o=_(n,"boxes","nonMaxSuppression"),i=_(e,"scores","nonMaxSuppression"),c=Ra(o,i,t,r,s,null),l=c.maxOutputSize,u=c.iouThreshold,d=c.scoreThreshold,p={boxes:o,scores:i},h={maxOutputSize:l,iouThreshold:u,scoreThreshold:d,padToMaxOutputSize:a},m=F.runKernel(gu,p,h);return{selectedIndices:m[0],validOutputs:m[1]}}const UC=D({nonMaxSuppressionPadded_:WC});/** 3822 * @license 3823 * Copyright 2020 Google LLC. All Rights Reserved. 3824 * Licensed under the Apache License, Version 2.0 (the "License"); 3825 * you may not use this file except in compliance with the License. 3826 * You may obtain a copy of the License at 3827 * 3828 * http://www.apache.org/licenses/LICENSE-2.0 3829 * 3830 * Unless required by applicable law or agreed to in writing, software 3831 * distributed under the License is distributed on an "AS IS" BASIS, 3832 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3833 * See the License for the specific language governing permissions and 3834 * limitations under the License. 3835 * ============================================================================= 3836 */async function zC(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,a=!1){const o=_(n,"boxes","nonMaxSuppressionAsync"),i=_(e,"scores","nonMaxSuppressionAsync"),
vendor: 5,055 bytes, lines 3836-3884
3836c=Ra(o,i,t,r,s,null),l=c.maxOutputSize,u=c.iouThreshold,d=c.scoreThreshold,[p,h]=await Promise.all([o.data(),i.data()]),{selectedIndices:m,validOutputs:g}=Gg(p,h,l,u,d,a);return o!==n&&o.dispose(),i!==e&&i.dispose(),{selectedIndices:Rt(m,"int32"),validOutputs:Re(g,"int32")}}const GC=zC;/** 3837 * @license 3838 * Copyright 2020 Google LLC. All Rights Reserved. 3839 * Licensed under the Apache License, Version 2.0 (the "License"); 3840 * you may not use this file except in compliance with the License. 3841 * You may obtain a copy of the License at 3842 * 3843 * http://www.apache.org/licenses/LICENSE-2.0 3844 * 3845 * Unless required by applicable law or agreed to in writing, software 3846 * distributed under the License is distributed on an "AS IS" BASIS, 3847 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3848 * See the License for the specific language governing permissions and 3849 * limitations under the License. 3850 * ============================================================================= 3851 */function HC(n,e,t=!1,r=!1){const s=_(n,"images","resizeBilinear");N(s.rank===3||s.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${s.rank}.`),N(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),N(r===!1||t===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let a=s,o=!1;s.rank===3&&(o=!0,a=q(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const i={images:a},c={alignCorners:t,halfPixelCenters:r,size:e},l=F.runKernel($u,i,c);return o?q(l,[l.shape[1],l.shape[2],l.shape[3]]):l}const jC=D({resizeBilinear_:HC});/** 3852 * @license 3853 * Copyright 2020 Google LLC. All Rights Reserved. 3854 * Licensed under the Apache License, Version 2.0 (the "License"); 3855 * you may not use this file except in compliance with the License. 3856 * You may obtain a copy of the License at 3857 * 3858 * http://www.apache.org/licenses/LICENSE-2.0 3859 * 3860 * Unless required by applicable law or agreed to in writing, software 3861 * distributed under the License is distributed on an "AS IS" BASIS, 3862 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3863 * See the License for the specific language governing permissions and 3864 * limitations under the License. 3865 * ============================================================================= 3866 */function qC(n,e,t=!1,r=!1){const s=_(n,"images","resizeNearestNeighbor");N(s.rank===3||s.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${s.rank}.`),N(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),N(s.dtype==="float32"||s.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),N(r===!1||t===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let a=s,o=!1;s.rank===3&&(o=!0,a=q(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const i={images:a},c={alignCorners:t,halfPixelCenters:r,size:e},l=F.runKernel(Iu,i,c);return o?q(l,[l.shape[1],l.shape[2],l.shape[3]]):l}const KC=D({resizeNearestNeighbor_:qC});/** 3867 * @license 3868 * Copyright 2021 Google LLC. All Rights Reserved. 3869 * Licensed under the Apache License, Version 2.0 (the "License"); 3870 * you may not use this file except in compliance with the License. 3871 * You may obtain a copy of the License at 3872 * 3873 * https://www.apache.org/licenses/LICENSE-2.0 3874 * 3875 * Unless required by applicable law or agreed to in writing, software 3876 * distributed under the License is distributed on an "AS IS" BASIS, 3877 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3878 * See the License for the specific language governing permissions and 3879 * limitations under the License. 3880 * ============================================================================= 3881 */function XC(n,e="binary",t=!1,r=.5){const s=_(n,"image","threshold"),a=.2989,o=.587,i=.114,c=s.shape[0]*s.shape[1];let l=Z(Rt([r]),255),u,d,p,h;if(N(s.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${s.rank}.`),N(s.shape[2]===3||s.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${s.shape[2]}.`),N(s.dtype==="int32"||s.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${s.dtype}.`),N(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),s.shape[2]===3){[u,d,p]=xo(s,[1,1,1],-1);const y=Z(u,a),b=Z(d,o),v=Z(p,i);h=me(me(y,b),v)}else h=n;if(e==="otsu"){const y=eg(rt(Ag(h),"int32"),zn([]),256);l=YC(y,c)}const m=t?mp(h,l):Uu(h,l);return rt(Z(m,255),"int32")}function YC(n,e){let t=Rt([-1]),r=Rt([0]),s=Rt([0]),a,o,i,c,l,u;for(let d=0;d<n.size-1;d++){a=Se(n,0,d+1),o=Se(n,d+1),l=Te(Ke(a),e),u=Te(Ke(o),e);const p=Ke(Z(a,yo(0,a.size)));i=Te(p,Ke(a));const h=ko(o.shape,a.size),m=me(yo(0,o.size),h),g=Z(o,m);c=Te(Ke(g),Ke(o));const y=Ce(i,c),b=Ce(i,c),v=Z(l,u);s=Z(Z(v,y),b);const $=Uu(s,r);r=Vr($,s,r),t=Vr($,Rt([d]),t)}return t}const QC=D({threshold_:XC});/** 3882 * @license 3883 * Copyright 2021 Google LLC. All Rights Reserved. 3884 * Licensed under the Apache License, Version 2.0 (the "License");
3885 * you may not use this file except in compliance with the License. 3886 * You may obtain a copy of the License at 3887 * 3888 * http://www.apache.org/licenses/LICENSE-2.0 3889 * 3890 * Unless required by applicable law or agreed to in writing, software 3891 * distributed under the License is distributed on an "AS IS" BASIS, 3892 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3893 * See the License for the specific language governing permissions and 3894 * limitations under the License. 3895 * ============================================================================= 3896 */function ZC(n,e,t="nearest",r="constant",s=0,a){const o=_(n,"image","transform","float32"),i=_(e,"transforms","transform","float32");N(o.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${o.rank}.`),N(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"),N(a==null||a.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${a}.`);const c={image:o,transforms:i},l={interpolation:t,fillMode:r,fillValue:s,outputShape:a};return F.runKernel(Ou,c,l)}const JC=D({transform_:ZC});/** 3897 * @license 3898 * Copyright 2020 Google LLC. All Rights Reserved. 3899 * Licensed under the Apache License, Version 2.0 (the "License"); 3900 * you may not use this file except in compliance with the License. 3901 * You may obtain a copy of the License at 3902 * 3903 * http://www.apache.org/licenses/LICENSE-2.0 3904 * 3905 * Unless required by applicable law or agreed to in writing, software 3906 * distributed under the License is distributed on an "AS IS" BASIS, 3907 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3908 * See the License for the specific language governing permissions and 3909 * limitations under the License. 3910 * ============================================================================= 3911 */function e_(n,e,t){const r=_(n,"a","bandPart");N(r.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`);const s=r.shape,[a,o]=r.shape.slice(-2);let i,c;typeof e=="number"?(N(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),N(e<=a,()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${a}).`),i=_(e<0?a:e,"numLower","bandPart")):(N(e.dtype==="int32",()=>"bandPart(): numLower's dtype must be an int32."),i=Vr(Xc(e,0),a,Ci(e,a))),typeof t=="number"?(N(t%1===0,()=>`bandPart(): numUpper must be an integer, got ${t}.`),N(t<=o,()=>`bandPart(): numUpper (${t}) must not be greater than the number of columns (${o}).`),c=_(t<0?o:t,"numUpper","bandPart")):(N(t.dtype==="int32",()=>"bandPart(): numUpper's dtype must be an int32."),c=Vr(Xc(t,0),o,Ci(t,o)));const l=q(yo(0,a,1,"int32"),[-1,1]),u=yo(0,o,1,"int32"),d=Ce(l,u),p=$i(mp(d,i),dg(d,ar(c))),h=Es([a,o],r.dtype);return q(vr(Bs(q(r,[-1,a,o])).map(m=>Vr(p,m,h))),s)}const t_=D({bandPart_:e_});/** 3912 * @license 3913 * Copyright 2020 Google LLC. All Rights Reserved. 3914 * Licensed under the Apache License, Version 2.0 (the "License"); 3915 * you may not use this file except in compliance with the License. 3916 * You may obtain a copy of the License at 3917 * 3918 * http://www.apache.org/licenses/LICENSE-2.0 3919 * 3920 * Unless required by applicable law or agreed to in writing, software 3921 * distributed under the License is distributed on an "AS IS" BASIS, 3922 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3923 * See the License for the specific language governing permissions and 3924 * limitations under the License. 3925 * ============================================================================= 3926 */function n_(n){let e;if(Array.isArray(n)){e=!1,N(n!=null&&n.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const s=n[0].shape[0];for(let a=1;a<n.length;++a)N(n[a].shape[0]===s,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${n[a].shape[0]} vs. ${s})`)}else e=!0,n=xo(n,n.shape[0],0).map(s=>xt(s,[0]));N(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 s=0;s<n.length;++s)t.push(F.tidy(()=>{let a=r[s];if(s>0)for(let o=0;o<s;++o){const i=Z(Ke(Z(t[o],a)),t[o]);a=Ce(a,i)}
vendor: 5,274 bytes, lines 3926-3974
3926return Te(a,Wu(a,"euclidean"))}));return e?vr(t,0):t}const r_=D({gramSchmidt_:n_});/** 3927 * @license 3928 * Copyright 2020 Google LLC. All Rights Reserved. 3929 * Licensed under the Apache License, Version 2.0 (the "License"); 3930 * you may not use this file except in compliance with the License. 3931 * You may obtain a copy of the License at 3932 * 3933 * http://www.apache.org/licenses/LICENSE-2.0 3934 * 3935 * Unless required by applicable law or agreed to in writing, software 3936 * distributed under the License is distributed on an "AS IS" BASIS, 3937 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3938 * See the License for the specific language governing permissions and 3939 * limitations under the License. 3940 * ============================================================================= 3941 */function s_(n,e=!1){if(N(n.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${n.rank}`),n.rank===2)return Vh(n,e);{const t=n.shape.slice(0,n.shape.length-2).reduce((c,l)=>c*l),r=Bs(q(n,[t,n.shape[n.shape.length-2],n.shape[n.shape.length-1]]),0),s=[],a=[];r.forEach(c=>{const[l,u]=Vh(c,e);s.push(l),a.push(u)});const o=q(vr(s,0),n.shape),i=q(vr(a,0),n.shape);return[o,i]}}function Vh(n,e=!1){return F.tidy(()=>{N(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 s=ug(t),a=Br(n);const o=$s([[1]],[1,1]);let i=Br(o);const c=t>=r?r:t;for(let l=0;l<c;++l){const u=a,d=i,p=s;[i,a,s]=F.tidy(()=>{const h=Se(a,[l,l],[t-l,1]),m=Wu(h),g=Se(a,[l,l],[1,1]),y=Vr(Uu(g,0),$s([[-1]]),$s([[1]])),b=Ce(g,Z(y,m)),v=Te(h,b);v.shape[0]===1?i=Br(o):i=It([o,Se(v,[1,0],[v.shape[0]-1,v.shape[1]])],0);const $=ar(Te(Ue(y,b),m)),S=Se(a,[l,0],[t-l,r]),T=Z($,i),O=Yc(i);if(l===0)a=Ce(S,Ue(T,Ue(O,S)));else{const W=Ce(S,Ue(T,Ue(O,S)));a=It([Se(a,[0,0],[l,r]),W],0)}const L=Yc(T),M=Se(s,[0,l],[t,s.shape[1]-l]);if(l===0)s=Ce(M,Ue(Ue(M,i),L));else{const W=Ce(M,Ue(Ue(M,i),L));s=It([Se(s,[0,0],[t,l]),W],1)}return[i,a,s]}),nt([u,d,p])}return!e&&t>r&&(s=Se(s,[0,0],[t,r]),a=Se(a,[0,0],[r,r])),[s,a]})}const a_=D({qr_:s_});/** 3942 * @license 3943 * Copyright 2020 Google LLC. All Rights Reserved. 3944 * Licensed under the Apache License, Version 2.0 (the "License"); 3945 * you may not use this file except in compliance with the License. 3946 * You may obtain a copy of the License at 3947 * 3948 * http://www.apache.org/licenses/LICENSE-2.0 3949 * 3950 * Unless required by applicable law or agreed to in writing, software 3951 * distributed under the License is distributed on an "AS IS" BASIS, 3952 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3953 * See the License for the specific language governing permissions and 3954 * limitations under the License. 3955 * ============================================================================= 3956 */var Ht;(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"})(Ht||(Ht={}));function o_(n,e,t=Ht.SUM_BY_NONZERO_WEIGHTS){const r=_(n,"losses","computeWeightedLoss");let s=null;e!=null&&(s=_(e,"weights","computeWeightedLoss"));const a=s==null?r:Z(r,s);if(t===Ht.NONE)return a;if(t===Ht.SUM)return Ke(a);if(t===Ht.MEAN){if(s==null)return Si(a);{const o=r.size/s.size,i=Te(Ke(a),Ke(s));return o>1?Te(i,Re(o)):i}}if(t===Ht.SUM_BY_NONZERO_WEIGHTS){if(s==null)return Te(Ke(a),Re(r.size));{const o=Z(s,ws(r.shape)),i=rt(Ke(wg(o,Re(0))),"float32");return Te(Ke(a),i)}}throw Error(`Unknown reduction: ${t}`)}const $r=D({computeWeightedLoss_:o_});/** 3957 * @license 3958 * Copyright 2020 Google LLC. All Rights Reserved. 3959 * Licensed under the Apache License, Version 2.0 (the "License"); 3960 * you may not use this file except in compliance with the License. 3961 * You may obtain a copy of the License at 3962 * 3963 * http://www.apache.org/licenses/LICENSE-2.0 3964 * 3965 * Unless required by applicable law or agreed to in writing, software 3966 * distributed under the License is distributed on an "AS IS" BASIS, 3967 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3968 * See the License for the specific language governing permissions and 3969 * limitations under the License. 3970 * ============================================================================= 3971 */function i_(n,e,t,r=Ht.SUM_BY_NONZERO_WEIGHTS){const s=_(n,"labels","absoluteDifference"),a=_(e,"predictions","absoluteDifference");let o=null;t!=null&&(o=_(t,"weights","absoluteDifference")),sn(s.shape,a.shape,"Error in absoluteDifference: ");const i=ln(Ce(s,a));return $r(i,o,r)}const u_=D({absoluteDifference_:i_});function c_(n,e,t,r,s=Ht.SUM_BY_NONZERO_WEIGHTS){const a=_(n,"labels","cosineDistance"),o=_(e,"predictions","cosineDistance");let i=null;r!=null&&(i=_(r,"weights","cosineDistance")),sn(a.shape,o.shape,"Error in cosineDistance: ");const c=Re(1),l=Ce(c,Ke(Z(a,o),t,!0));return $r(l,i,s)}const l_=D({cosineDistance_:c_});function d_(n,e,t,r=Ht.SUM_BY_NONZERO_WEIGHTS){let s=_(n,"labels","hingeLoss");const a=_(e,"predictions","hingeLoss");let o=null;t!=null&&(o=_(t,"weights","hingeLoss")),sn(s.shape,a.shape,"Error in hingeLoss: ");const i=Re(1);s=Ce(Z(Re(2),s),i);const c=Gu(Ce(i,Z(s,a)));return $r(c,o,r)}const p_=D({hingeLoss_:d_});/** 3972 * @license 3973 * Copyright 2020 Google LLC. All Rights Reserved. 3974 * Licensed under the Apache License, Version 2.0 (the "License");
3975 * you may not use this file except in compliance with the License. 3976 * You may obtain a copy of the License at 3977 * 3978 * http://www.apache.org/licenses/LICENSE-2.0 3979 * 3980 * Unless required by applicable law or agreed to in writing, software 3981 * distributed under the License is distributed on an "AS IS" BASIS, 3982 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3983 * See the License for the specific language governing permissions and 3984 * limitations under the License. 3985 * ============================================================================= 3986 */function h_(n,e,t,r=1,s=Ht.SUM_BY_NONZERO_WEIGHTS){const a=_(n,"labels","huberLoss"),o=_(e,"predictions","huberLoss");let i=null;t!=null&&(i=_(t,"weights","huberLoss")),sn(a.shape,o.shape,"Error in huberLoss: ");const c=Re(r),l=ln(Ce(o,a)),u=Ci(l,c),d=Ce(l,u),p=me(Z(Re(.5),Gn(u)),Z(c,d));return $r(p,i,s)}const f_=D({huberLoss_:h_});/** 3987 * @license 3988 * Copyright 2020 Google LLC. All Rights Reserved. 3989 * Licensed under the Apache License, Version 2.0 (the "License"); 3990 * you may not use this file except in compliance with the License. 3991 * You may obtain a copy of the License at 3992 * 3993 * http://www.apache.org/licenses/LICENSE-2.0 3994 * 3995 * Unless required by applicable law or agreed to in writing, software 3996 * distributed under the License is distributed on an "AS IS" BASIS, 3997 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3998 * See the License for the specific language governing permissions and 3999 * limitations under the License. 4000 * ============================================================================= 4001 */function m_(n,e,t,r=1e-7,s=Ht.SUM_BY_NONZERO_WEIGHTS){const a=_(n,"labels","logLoss"),o=_(e,"predictions","logLoss");let i=null;t!=null&&(i=_(t,"weights","logLoss")),sn(a.shape,o.shape,"Error in logLoss: ");const c=Re(1),l=Re(r),u=ar(Z(a,go(me(o,l)))),d=Z(Ce(c,a),go(me(Ce(c,o),l))),p=Ce(u,d);return $r(p,i,s)}const g_=D({logLoss_:m_});/** 4002 * @license 4003 * Copyright 2020 Google LLC. All Rights Reserved. 4004 * Licensed under the Apache License, Version 2.0 (the "License"); 4005 * you may not use this file except in compliance with the License. 4006 * You may obtain a copy of the License at 4007 * 4008 * http://www.apache.org/licenses/LICENSE-2.0 4009 * 4010 * Unless required by applicable law or agreed to in writing, software 4011 * distributed under the License is distributed on an "AS IS" BASIS, 4012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4013 * See the License for the specific language governing permissions and 4014 * limitations under the License. 4015 * ============================================================================= 4016 */function y_(n,e,t,r=Ht.SUM_BY_NONZERO_WEIGHTS){const s=_(n,"labels","meanSquaredError"),a=_(e,"predictions","meanSquaredError");let o=null;t!=null&&(o=_(t,"weights","meanSquaredError")),sn(s.shape,a.shape,"Error in meanSquaredError: ");const i=Og(s,a);return $r(i,o,r)}const b_=D({meanSquaredError_:y_});/** 4017 * @license 4018 * Copyright 2020 Google LLC. All Rights Reserved. 4019 * Licensed under the Apache License, Version 2.0 (the "License"); 4020 * you may not use this file except in compliance with the License. 4021 * You may obtain a copy of the License at 4022 * 4023 * http://www.apache.org/licenses/LICENSE-2.0 4024 * 4025 * Unless required by applicable law or agreed to in writing, software 4026 * distributed under the License is distributed on an "AS IS" BASIS, 4027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4028 * See the License for the specific language governing permissions and 4029 * limitations under the License. 4030 * ============================================================================= 4031 */function x_(n,e){const t=_(n,"labels","sigmoidCrossEntropyWithLogits"),r=_(e,"logits","sigmoidCrossEntropyWithLogits");sn(t.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const s=Gu(r),a=Z(r,t),o=hg(xr(ar(ln(r))));return me(Ce(s,a),o)}function w_(n,e,t,r=0,s=Ht.SUM_BY_NONZERO_WEIGHTS){let a=_(n,"multiClassLabels","sigmoidCrossEntropy");const o=_(e,"logits","sigmoidCrossEntropy");let i=null;if(t!=null&&(i=_(t,"weights","sigmoidCrossEntropy")),sn(a.shape,o.shape,"Error in sigmoidCrossEntropy: "),r>0){const l=Re(r),u=Re(1),d=Re(.5);a=me(Z(a,Ce(u,l)),Z(d,l))}const c=x_(a,o);return $r(c,i,s)}const v_=D({sigmoidCrossEntropy_:w_});/** 4032 * @license 4033 * Copyright 2020 Google LLC. All Rights Reserved. 4034 * Licensed under the Apache License, Version 2.0 (the "License");
4035 * you may not use this file except in compliance with the License. 4036 * You may obtain a copy of the License at 4037 * 4038 * http://www.apache.org/licenses/LICENSE-2.0 4039 * 4040 * Unless required by applicable law or agreed to in writing, software 4041 * distributed under the License is distributed on an "AS IS" BASIS, 4042 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4043 * See the License for the specific language governing permissions and 4044 * limitations under the License. 4045 * ============================================================================= 4046 */function I_(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 wr((s,a,o)=>{const c=mg(a,[t],!0),l=Ce(rt(a,"float32"),c);o([s,l]);const u=ar(Z(l,s));return{value:Ke(u,[t]),gradFunc:(h,m)=>{const[g,y]=m,b=pt(h.shape,[t]);return[Z(q(h,b),Ce(rt(g,"float32"),xr(y))),Z(q(h,b),Ce(xr(y),rt(g,"float32")))]}}})(n,e)}function $_(n,e,t,r=0,s=Ht.SUM_BY_NONZERO_WEIGHTS){let a=_(n,"onehotLabels","softmaxCrossEntropy");const o=_(e,"logits","softmaxCrossEntropy");let i=null;if(t!=null&&(i=_(t,"weights","softmaxCrossEntropy")),sn(a.shape,o.shape,"Error in softmaxCrossEntropy: "),r>0){const l=Re(r),u=Re(1),d=Re(a.shape[1]);a=me(Z(a,Ce(u,l)),Te(l,d))}const c=I_(a,o);return $r(c,i,s)}const S_=D({softmaxCrossEntropy_:$_});/** 4047 * @license 4048 * Copyright 2021 Google LLC. All Rights Reserved. 4049 * Licensed under the Apache License, Version 2.0 (the "License"); 4050 * you may not use this file except in compliance with the License. 4051 * You may obtain a copy of the License at 4052 * 4053 * http://www.apache.org/licenses/LICENSE-2.0 4054 * 4055 * Unless required by applicable law or agreed to in writing, software 4056 * distributed under the License is distributed on an "AS IS" BASIS, 4057 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4058 * See the License for the specific language governing permissions and 4059 * limitations under the License. 4060 * ============================================================================= 4061 */function C_(n,e,t,r){const s=_(n,"indices","sparseFillEmptyRows","int32"),a=_(e,"values","sparseFillEmptyRows"),o=_(t,"denseShape","sparseFillEmptyRows","int32"),i=_(r,"defaultValue","sparseFillEmptyRows",a.dtype);if(s.rank!==2)throw new Error(`Indices should be Tensor2D but received shape 4062 ${s.shape}`);if(a.rank!==1)throw new Error(`Values should be Tensor1D but received shape ${a.shape}`);if(o.rank!==1)throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`);if(i.rank!==0)throw new Error(`Default value should be a scalar but received shape ${i.shape}`);const c={indices:s,values:a,denseShape:o,defaultValue:i},l=F.runKernel(Xd,c);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}const __=D({sparseFillEmptyRows_:C_});/** 4063 * @license 4064 * Copyright 2021 Google LLC. All Rights Reserved. 4065 * Licensed under the Apache License, Version 2.0 (the "License"); 4066 * you may not use this file except in compliance with the License. 4067 * You may obtain a copy of the License at 4068 * 4069 * http://www.apache.org/licenses/LICENSE-2.0 4070 * 4071 * Unless required by applicable law or agreed to in writing, software 4072 * distributed under the License is distributed on an "AS IS" BASIS, 4073 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4074 * See the License for the specific language governing permissions and 4075 * limitations under the License. 4076 * ============================================================================= 4077 */function N_(n,e,t){const r=_(n,"inputIndices","sparseReshape","int32"),s=_(e,"inputShape","sparseReshape","int32"),a=_(t,"newShape","sparseReshape","int32");if(r.rank!==2)throw new Error(`Input indices should be Tensor2D but received shape 4078 ${r.shape}`);if(s.rank!==1)throw new Error(`Input shape should be Tensor1D but received shape ${s.shape}`);if(a.rank!==1)throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`);const o={inputIndices:r,inputShape:s,newShape:a},i=F.runKernel(Eu,o);return{outputIndices:i[0],outputShape:i[1]}}const T_=D({sparseReshape_:N_});/** 4079 * @license 4080 * Copyright 2021 Google LLC. All Rights Reserved. 4081 * Licensed under the Apache License, Version 2.0 (the "License");
4082 * you may not use this file except in compliance with the License. 4083 * You may obtain a copy of the License at 4084 * 4085 * http://www.apache.org/licenses/LICENSE-2.0 4086 * 4087 * Unless required by applicable law or agreed to in writing, software 4088 * distributed under the License is distributed on an "AS IS" BASIS, 4089 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4090 * See the License for the specific language governing permissions and 4091 * limitations under the License. 4092 * ============================================================================= 4093 */function k_(n,e,t){const r=_(n,"data","sparseSegmentMean"),s=_(e,"indices","sparseSegmentMean","int32"),a=_(t,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.rank!==1)throw new Error(`Indices should be Tensor1D but received shape 4094 ${s.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape 4095 ${a.shape}`);const o={data:r,indices:s,segmentIds:a};return F.runKernel(Yd,o)}const E_=D({sparseSegmentMean_:k_});/** 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 R_(n,e,t){const r=_(n,"data","sparseSegmentSum"),s=_(e,"indices","sparseSegmentSum","int32"),a=_(t,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.rank!==1)throw new Error(`Indices should be Tensor1D but received shape 4111 ${s.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape 4112 ${a.shape}`);const o={data:r,indices:s,segmentIds:a};return F.runKernel(Qd,o)}const A_=D({sparseSegmentSum_:R_});/** 4113 * @license 4114 * Copyright 2021 Google LLC. All Rights Reserved. 4115 * Licensed under the Apache License, Version 2.0 (the "License"); 4116 * you may not use this file except in compliance with the License. 4117 * You may obtain a copy of the License at 4118 * 4119 * http://www.apache.org/licenses/LICENSE-2.0 4120 * 4121 * Unless required by applicable law or agreed to in writing, software 4122 * distributed under the License is distributed on an "AS IS" BASIS, 4123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4124 * See the License for the specific language governing permissions and 4125 * limitations under the License. 4126 * ============================================================================= 4127 */function D_(n,e,t,r,s,a,o,i){const c=_(n,"data","stringNGrams","string");if(c.dtype!=="string")throw new Error("Data must be of datatype string");if(c.shape.length!==1)throw new Error(`Data must be a vector, saw: ${c.shape}`);const l=_(e,"dataSplits","stringNGrams");if(l.dtype!=="int32")throw new Error("Data splits must be of datatype int32");const u={separator:t,nGramWidths:r,leftPad:s,rightPad:a,padWidth:o,preserveShortSequences:i},d={data:c,dataSplits:l},p=F.runKernel(Jd,d,u);return{nGrams:p[0],nGramsSplits:p[1]}}const O_=D({stringNGrams_:D_});/** 4128 * @license 4129 * Copyright 2021 Google LLC. All Rights Reserved. 4130 * Licensed under the Apache License, Version 2.0 (the "License"); 4131 * you may not use this file except in compliance with the License. 4132 * You may obtain a copy of the License at 4133 * 4134 * http://www.apache.org/licenses/LICENSE-2.0 4135 * 4136 * Unless required by applicable law or agreed to in writing, software 4137 * distributed under the License is distributed on an "AS IS" BASIS, 4138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4139 * See the License for the specific language governing permissions and 4140 * limitations under the License. 4141 * ============================================================================= 4142 */function F_(n,e,t=!0){const r=_(n,"input","stringSplit","string"),s=_(e,"delimiter","stringSplit","string");if(r.rank!==1)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(s.rank!==0)throw new Error(`Delimiter should be a scalar but received shape ${s.shape}`);const a={skipEmpty:t},o={input:r,delimiter:s},i=F.runKernel(ep,o,a);return{indices:i[0],values:i[1],shape:i[2]}}const P_=D({stringSplit_:F_});/** 4143 * @license 4144 * Copyright 2021 Google LLC. All Rights Reserved. 4145 * Licensed under the Apache License, Version 2.0 (the "License");
4146 * you may not use this file except in compliance with the License. 4147 * You may obtain a copy of the License at 4148 * 4149 * http://www.apache.org/licenses/LICENSE-2.0 4150 * 4151 * Unless required by applicable law or agreed to in writing, software 4152 * distributed under the License is distributed on an "AS IS" BASIS, 4153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4154 * See the License for the specific language governing permissions and 4155 * limitations under the License. 4156 * ============================================================================= 4157 */function L_(n,e){const t=_(n,"input","stringToHashBucketFast","string"),r={numBuckets:e};if(e<=0)throw new Error("Number of buckets must be at least 1");const s={input:t};return F.runKernel(tp,s,r)}const M_=D({stringToHashBucketFast_:L_});/** 4158 * @license 4159 * Copyright 2023 Google LLC. 4160 * Licensed under the Apache License, Version 2.0 (the "License"); 4161 * you may not use this file except in compliance with the License. 4162 * You may obtain a copy of the License at 4163 * 4164 * http://www.apache.org/licenses/LICENSE-2.0 4165 * 4166 * Unless required by applicable law or agreed to in writing, software 4167 * distributed under the License is distributed on an "AS IS" BASIS, 4168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4169 * See the License for the specific language governing permissions and 4170 * limitations under the License. 4171 * ============================================================================= 4172 */function B_(n,e,t,r=!0){const s=_(n,"input","staticRegexReplace","string"),a={pattern:e,rewrite:t,replaceGlobal:r};return F.runKernel(mm,{x:s},a)}const V_=D({staticRegexReplace_:B_});/** 4173 * @license 4174 * Copyright 2020 Google LLC. All Rights Reserved. 4175 * Licensed under the Apache License, Version 2.0 (the "License"); 4176 * you may not use this file except in compliance with the License. 4177 * You may obtain a copy of the License at 4178 * 4179 * http://www.apache.org/licenses/LICENSE-2.0 4180 * 4181 * Unless required by applicable law or agreed to in writing, software 4182 * distributed under the License is distributed on an "AS IS" BASIS, 4183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4184 * See the License for the specific language governing permissions and 4185 * limitations under the License. 4186 * ============================================================================= 4187 */const W_={fft:wp,ifft:_i,rfft:vp,irfft:Dg},U_={hammingWindow:pC,hannWindow:Wg,frame:Ug,stft:gC},Xu={flipLeftRight:wC,grayscaleToRGB:IC,resizeNearestNeighbor:KC,resizeBilinear:jC,rgbToGrayscale:SC,rotateWithOffset:_C,cropAndResize:bC,nonMaxSuppression:TC,nonMaxSuppressionAsync:PC,nonMaxSuppressionWithScore:MC,nonMaxSuppressionWithScoreAsync:VC,nonMaxSuppressionPadded:UC,nonMaxSuppressionPaddedAsync:GC,threshold:QC,transform:JC},z_={bandPart:t_,gramSchmidt:r_,qr:a_},G_={absoluteDifference:u_,computeWeightedLoss:$r,cosineDistance:l_,hingeLoss:p_,huberLoss:f_,logLoss:g_,meanSquaredError:b_,sigmoidCrossEntropy:v_,softmaxCrossEntropy:S_},H_={sparseFillEmptyRows:__,sparseReshape:T_,sparseSegmentMean:E_,sparseSegmentSum:A_},j_={stringNGrams:O_,stringSplit:P_,stringToHashBucketFast:M_,staticRegexReplace:V_};/** 4188 * @license 4189 * Copyright 2018 Google LLC. All Rights Reserved. 4190 * Licensed under the Apache License, Version 2.0 (the "License"); 4191 * you may not use this file except in compliance with the License. 4192 * You may obtain a copy of the License at 4193 * 4194 * http://www.apache.org/licenses/LICENSE-2.0 4195 * 4196 * Unless required by applicable law or agreed to in writing, software 4197 * distributed under the License is distributed on an "AS IS" BASIS, 4198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4199 * See the License for the specific language governing permissions and 4200 * limitations under the License. 4201 * ============================================================================= 4202 */const q_=new Map,K_=new Map;class X_{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class ms{constructor(){this.classNameMap={}}static getMap(){return ms.instance==null&&(ms.instance=new ms),ms.instance}static register(e){ms.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function Y_(n,e,t){N(n.className!=null,()=>"Class being registered does not have the static className property defined."),N(typeof n.className=="string",()=>"className is required to be a string, but got type "+typeof n.className),N(n.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),typeof e>"u"&&(e="Custom"),typeof t>"u"&&(t=n.className);const r=t,s=e+">"+r;return ms.register(n),q_.set(s,n),K_.set(n,s),n}/** 4203 * @license 4204 * Copyright 2018 Google LLC. All Rights Reserved. 4205 * Licensed under the Apache License, Version 2.0 (the "License");
4206 * you may not use this file except in compliance with the License. 4207 * You may obtain a copy of the License at 4208 * 4209 * http://www.apache.org/licenses/LICENSE-2.0 4210 * 4211 * Unless required by applicable law or agreed to in writing, software 4212 * distributed under the License is distributed on an "AS IS" BASIS, 4213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4214 * See the License for the specific language governing permissions and 4215 * limitations under the License. 4216 * ============================================================================= 4217 */class Vs extends X_{minimize(e,t=!1,r){const{value:s,grads:a}=this.computeGradients(e,r);if(r!=null){const o=r.map(i=>({name:i.name,tensor:a[i.name]}));this.applyGradients(o)}else this.applyGradients(a);return nt(a),t?s:(s.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return zI(e,t)}dispose(){this.iterations_!=null&&nt(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Re(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(Vs,Symbol.hasInstance,{value:n=>n.minimize!=null&&n.computeGradients!=null&&n.applyGradients!=null});/** 4218 * @license 4219 * Copyright 2018 Google LLC. All Rights Reserved. 4220 * Licensed under the Apache License, Version 2.0 (the "License"); 4221 * you may not use this file except in compliance with the License. 4222 * You may obtain a copy of the License at 4223 * 4224 * http://www.apache.org/licenses/LICENSE-2.0 4225 * 4226 * Unless required by applicable law or agreed to in writing, software 4227 * distributed under the License is distributed on an "AS IS" BASIS, 4228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4229 * See the License for the specific language governing permissions and 4230 * limitations under the License. 4231 * ============================================================================= 4232 */class Q_ extends Vs{static get className(){return"Adadelta"}constructor(e,t,r=null){super(),this.learningRate=e,this.rho=t,this.epsilon=r,this.accumulatedGrads=[],this.accumulatedUpdates=[],r==null&&(this.epsilon=F.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const a=F.registeredVariables[r],o=!1;this.accumulatedGrads[s]==null&&(this.accumulatedGrads[s]={originalName:`${r}/accum_grad`,variable:Ne(()=>hn(a).variable(o))}),this.accumulatedUpdates[s]==null&&(this.accumulatedUpdates[s]={originalName:`${r}/accum_var`,variable:Ne(()=>hn(a).variable(o))});const i=Array.isArray(e)?e[s].tensor:e[r];if(i==null)return;const c=this.accumulatedGrads[s].variable,l=this.accumulatedUpdates[s].variable;Ne(()=>{const u=me(Z(c,this.rho),Z(Gn(i),1-this.rho)),d=Z(Te(br(me(l,this.epsilon)),br(me(c,this.epsilon))),i),p=me(Z(l,this.rho),Z(Gn(d),1-this.rho));c.assign(u),l.assign(p);const h=me(Z(d,-this.learningRate),a);a.assign(h)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(nt(this.accumulatedGrads.map(e=>e.variable)),nt(this.accumulatedUpdates.map(e=>e.variable)))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=e.length/2,r=!1;this.accumulatedGrads=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.accumulatedUpdates=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(r)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}/** 4233 * @license 4234 * Copyright 2018 Google LLC. All Rights Reserved. 4235 * Licensed under the Apache License, Version 2.0 (the "License");
4236 * you may not use this file except in compliance with the License. 4237 * You may obtain a copy of the License at 4238 * 4239 * http://www.apache.org/licenses/LICENSE-2.0 4240 * 4241 * Unless required by applicable law or agreed to in writing, software 4242 * distributed under the License is distributed on an "AS IS" BASIS, 4243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4244 * See the License for the specific language governing permissions and 4245 * limitations under the License. 4246 * ============================================================================= 4247 */class Z_ extends Vs{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const a=F.registeredVariables[r];this.accumulatedGrads[s]==null&&(this.accumulatedGrads[s]={originalName:`${r}/accumulator`,variable:Ne(()=>ko(a.shape,this.initialAccumulatorValue).variable(!1))});const o=Array.isArray(e)?e[s].tensor:e[r];if(o==null)return;const i=this.accumulatedGrads[s].variable;Ne(()=>{const c=me(i,Gn(o));i.assign(c);const l=me(Z(Te(o,br(me(c,F.backend.epsilon()))),-this.learningRate),a);a.assign(l)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&nt(this.accumulatedGrads.map(e=>e.variable))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulatedGrads=e.map(r=>({originalName:r.name,variable:r.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}/** 4248 * @license 4249 * Copyright 2018 Google LLC. All Rights Reserved. 4250 * Licensed under the Apache License, Version 2.0 (the "License"); 4251 * you may not use this file except in compliance with the License. 4252 * You may obtain a copy of the License at 4253 * 4254 * http://www.apache.org/licenses/LICENSE-2.0 4255 * 4256 * Unless required by applicable law or agreed to in writing, software 4257 * distributed under the License is distributed on an "AS IS" BASIS, 4258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4259 * See the License for the specific language governing permissions and 4260 * limitations under the License. 4261 * ============================================================================= 4262 */class J_ extends Vs{static get className(){return"Adam"}constructor(e,t,r,s=null){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=s,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],Ne(()=>{this.accBeta1=Re(t).variable(),this.accBeta2=Re(r).variable()}),s==null&&(this.epsilon=F.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(r=>r.name):Object.keys(e);Ne(()=>{const r=Ce(1,this.accBeta1),s=Ce(1,this.accBeta2);t.forEach((a,o)=>{const i=F.registeredVariables[a],c=!1;this.accumulatedFirstMoment[o]==null&&(this.accumulatedFirstMoment[o]={originalName:`${a}/m`,variable:Ne(()=>hn(i).variable(c))}),this.accumulatedSecondMoment[o]==null&&(this.accumulatedSecondMoment[o]={originalName:`${a}/v`,variable:Ne(()=>hn(i).variable(c))});const l=Array.isArray(e)?e[o].tensor:e[a];if(l==null)return;const u=this.accumulatedFirstMoment[o].variable,d=this.accumulatedSecondMoment[o].variable,p=me(Z(u,this.beta1),Z(l,1-this.beta1)),h=me(Z(d,this.beta2),Z(Gn(l),1-this.beta2)),m=Te(p,r),g=Te(h,s);u.assign(p),d.assign(h);const y=me(Z(Te(m,me(br(g),this.epsilon)),-this.learningRate),i);i.assign(y)}),this.accBeta1.assign(Z(this.accBeta1,this.beta1)),this.accBeta2.assign(Z(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&nt(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&nt(this.accumulatedSecondMoment.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable}
vendor: 4,817 bytes, lines 4262-4295
4262)))}async setWeights(e){e=await this.extractIterations(e),Ne(()=>{this.accBeta1.assign(mo(this.beta1,this.iterations_+1)),this.accBeta2.assign(mo(this.beta2,this.iterations_+1))});const t=e.length/2,r=!1;this.accumulatedFirstMoment=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(r)}))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}/** 4263 * @license 4264 * Copyright 2018 Google LLC. All Rights Reserved. 4265 * Licensed under the Apache License, Version 2.0 (the "License"); 4266 * you may not use this file except in compliance with the License. 4267 * You may obtain a copy of the License at 4268 * 4269 * http://www.apache.org/licenses/LICENSE-2.0 4270 * 4271 * Unless required by applicable law or agreed to in writing, software 4272 * distributed under the License is distributed on an "AS IS" BASIS, 4273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4274 * See the License for the specific language governing permissions and 4275 * limitations under the License. 4276 * ============================================================================= 4277 */class eN extends Vs{static get className(){return"Adamax"}constructor(e,t,r,s=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=s,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],Ne(()=>{this.iteration=Re(0).variable(),this.accBeta1=Re(t).variable()}),s==null&&(this.epsilon=F.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(r=>r.name):Object.keys(e);Ne(()=>{const r=Ce(1,this.accBeta1),s=Te(-this.learningRate,me(Z(this.iteration,this.decay),1));t.forEach((a,o)=>{const i=F.registeredVariables[a],c=!1;this.accumulatedFirstMoment[o]==null&&(this.accumulatedFirstMoment[o]={originalName:`${a}/m`,variable:hn(i).variable(c)}),this.accumulatedWeightedInfNorm[o]==null&&(this.accumulatedWeightedInfNorm[o]={originalName:`${a}/v`,variable:hn(i).variable(c)});const l=Array.isArray(e)?e[o].tensor:e[a];if(l==null)return;const u=this.accumulatedFirstMoment[o].variable,d=this.accumulatedWeightedInfNorm[o].variable,p=me(Z(u,this.beta1),Z(l,1-this.beta1)),h=Z(d,this.beta2),m=ln(l),g=xg(h,m);u.assign(p),d.assign(g);const y=me(Z(Te(s,r),Te(p,me(g,this.epsilon))),i);i.assign(y)}),this.iteration.assign(me(this.iteration,1)),this.accBeta1.assign(Z(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&nt(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&nt(this.accumulatedWeightedInfNorm.map(e=>e.variable))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}/** 4278 * @license 4279 * Copyright 2018 Google LLC. All Rights Reserved. 4280 * Licensed under the Apache License, Version 2.0 (the "License"); 4281 * you may not use this file except in compliance with the License. 4282 * You may obtain a copy of the License at 4283 * 4284 * http://www.apache.org/licenses/LICENSE-2.0 4285 * 4286 * Unless required by applicable law or agreed to in writing, software 4287 * distributed under the License is distributed on an "AS IS" BASIS, 4288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4289 * See the License for the specific language governing permissions and 4290 * limitations under the License. 4291 * ============================================================================= 4292 */class jg extends Vs{static get className(){return"SGD"}constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const a=Array.isArray(e)?e[s].tensor:e[r];if(a==null)return;const o=F.registeredVariables[r];Ne(()=>{const i=me(Z(this.c,a),o);o.assign(i)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=rr(Re(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(e=await this.extractIterations(e),e.length!==0)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}/** 4293 * @license 4294 * Copyright 2018 Google LLC. All Rights Reserved. 4295 * Licensed under the Apache License, Version 2.0 (the "License");
4296 * you may not use this file except in compliance with the License. 4297 * You may obtain a copy of the License at 4298 * 4299 * http://www.apache.org/licenses/LICENSE-2.0 4300 * 4301 * Unless required by applicable law or agreed to in writing, software 4302 * distributed under the License is distributed on an "AS IS" BASIS, 4303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4304 * See the License for the specific language governing permissions and 4305 * limitations under the License. 4306 * ============================================================================= 4307 */class tN extends jg{static get className(){return"Momentum"}constructor(e,t,r=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=r,this.accumulations=[],this.m=Re(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const a=F.registeredVariables[r];this.accumulations[s]==null&&(this.accumulations[s]={originalName:`${r}/momentum`,variable:Ne(()=>hn(a).variable(!1))});const o=this.accumulations[s].variable,i=Array.isArray(e)?e[s].tensor:e[r];i!=null&&Ne(()=>{let c;const l=me(Z(this.m,o),i);this.useNesterov?c=me(Z(this.c,me(i,Z(l,this.m))),a):c=me(Z(this.c,l),a),o.assign(l),a.assign(c)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&nt(this.accumulations.map(e=>e.variable))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulations=e.map(r=>({originalName:r.name,variable:r.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}/** 4308 * @license 4309 * Copyright 2018 Google LLC. All Rights Reserved. 4310 * Licensed under the Apache License, Version 2.0 (the "License"); 4311 * you may not use this file except in compliance with the License. 4312 * You may obtain a copy of the License at 4313 * 4314 * http://www.apache.org/licenses/LICENSE-2.0 4315 * 4316 * Unless required by applicable law or agreed to in writing, software 4317 * distributed under the License is distributed on an "AS IS" BASIS, 4318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4319 * See the License for the specific language governing permissions and 4320 * limitations under the License. 4321 * ============================================================================= 4322 */class nN extends Vs{static get className(){return"RMSProp"}constructor(e,t=.9,r=0,s=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=r,this.epsilon=s,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,s==null&&(this.epsilon=F.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const a=F.registeredVariables[r],o=!1;this.accumulatedMeanSquares[s]==null&&(this.accumulatedMeanSquares[s]={originalName:`${r}/rms`,variable:Ne(()=>hn(a).variable(o))}),this.accumulatedMoments[s]==null&&(this.accumulatedMoments[s]={originalName:`${r}/momentum`,variable:Ne(()=>hn(a).variable(o))}),this.accumulatedMeanGrads[s]==null&&this.centered&&(this.accumulatedMeanGrads[s]={originalName:`${r}/mg`,variable:Ne(()=>hn(a).variable(o))});const i=Array.isArray(e)?e[s].tensor:e[r];if(i==null)return;const c=this.accumulatedMeanSquares[s].variable,l=this.accumulatedMoments[s].variable;Ne(()=>{const u=me(Z(c,this.decay),Z(Gn(i),1-this.decay));if(this.centered){const d=this.accumulatedMeanGrads[s].variable,p=me(Z(d,this.decay),Z(i,1-this.decay)),h=Te(Z(i,this.learningRate),br(Ce(u,me(Gn(p),this.epsilon)))),m=me(Z(l,this.momentum),h);c.assign(u),d.assign(p),l.assign(m);const g=Ce(a,m);a.assign(g)}else{const d=me(Z(c,this.decay),Z(Gn(i),1-this.decay)),p=me(Z(l,this.momentum),Te(Z(i,this.learningRate),br(me(d,this.epsilon))));c.assign(d),l.assign(p);const h=Ce(a,p);a.assign(h)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&nt(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&nt(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&nt(this.accumulatedMoments.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable}
4322)))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,r=!1;this.accumulatedMeanSquares=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.accumulatedMoments=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}/** 4323 * @license 4324 * Copyright 2022 Google LLC. 4325 * Licensed under the Apache License, Version 2.0 (the "License"); 4326 * you may not use this file except in compliance with the License. 4327 * You may obtain a copy of the License at 4328 * 4329 * http://www.apache.org/licenses/LICENSE-2.0 4330 * 4331 * Unless required by applicable law or agreed to in writing, software 4332 * distributed under the License is distributed on an "AS IS" BASIS, 4333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4334 * See the License for the specific language governing permissions and 4335 * limitations under the License. 4336 * ============================================================================= 4337 */const rN=[Q_,Z_,J_,eN,tN,nN,jg];function sN(){for(const n of rN)Y_(n)}/** 4338 * @license 4339 * Copyright 2018 Google LLC. All Rights Reserved. 4340 * Licensed under the Apache License, Version 2.0 (the "License"); 4341 * you may not use this file except in compliance with the License. 4342 * You may obtain a copy of the License at 4343 * 4344 * http://www.apache.org/licenses/LICENSE-2.0 4345 * 4346 * Unless required by applicable law or agreed to in writing, software 4347 * distributed under the License is distributed on an "AS IS" BASIS, 4348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4349 * See the License for the specific language governing permissions and 4350 * limitations under the License. 4351 * ============================================================================= 4352 */const aN="model",oN=".json",iN=".weights.bin";function Wh(n){return new Promise(e=>setTimeout(e)).then(n)}class As{constructor(e){if(!U().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(As.URL_SCHEME)&&(e=e.slice(As.URL_SCHEME.length)),(e==null||e.length===0)&&(e=aN),this.modelJsonFileName=e+oN,this.weightDataFileName=e+iN}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=Xn.join(e.weightData),r=window.URL.createObjectURL(new Blob([t],{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 s=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],a=Wm(e,s),o=window.URL.createObjectURL(new Blob([JSON.stringify(a)],{type:"application/json"})),i=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(i.download=this.modelJsonFileName,i.href=o,await Wh(()=>i.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){const c=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;c.download=this.weightDataFileName,c.href=r,await Wh(()=>c.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:No(e)}}}}As.URL_SCHEME="downloads://";class uN{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=s=>{const a=JSON.parse(s.target.result),o=a.modelTopology;if(o==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(a.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 c=dp(a,l=>this.loadWeights(l));e(c)},r.onerror=s=>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 s=this.checkManifestAndWeightFiles(e),a=r.map(o=>this.loadWeightsFile(o,s[o]));return Promise.all(a).then(o=>[t,o])}loadWeightsFile(e,t){return new Promise((r,s)=>{const a=new FileReader;a.onload=o=>{const i=o.target.result;r(i)},a.onerror=o=>s(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){const t=[],r=this.weightsFiles.map(a=>Mh(a.name)),s={};for(const a of e)a.paths.forEach(o=>{const i=Mh(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.`);s[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 s}}const cN=n=>
4352U().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(As.URL_SCHEME)?lN(n.slice(As.URL_SCHEME.length)):null;tt.registerSaveRouter(cN);function lN(n="model"){return new As(n)}function dN(n){return new uN(n)}/** 4353 * @license 4354 * Copyright 2019 Google LLC. All Rights Reserved. 4355 * Licensed under the Apache License, Version 2.0 (the "License"); 4356 * you may not use this file except in compliance with the License. 4357 * You may obtain a copy of the License at 4358 * 4359 * http://www.apache.org/licenses/LICENSE-2.0 4360 * 4361 * Unless required by applicable law or agreed to in writing, software 4362 * distributed under the License is distributed on an "AS IS" BASIS, 4363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4364 * See the License for the specific language governing permissions and 4365 * limitations under the License. 4366 * ============================================================================= 4367 */function Uh(n,e,t,r){o(n),t=t==null?0:t,r=r==null?1:r,i(t,r);let s=0;const a=c=>(c.then(l=>{const u=t+ ++s/n.length*(r-t);return e(u),l}),c);function o(c){N(c!=null&&Array.isArray(c)&&c.length>0,()=>"promises must be a none empty array")}function i(c,l){N(c>=0&&c<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${c}`),N(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${l}`),N(l>=c,()=>`startFraction must be no more than endFraction, but got startFraction ${c} and endFraction ${l}`)}return Promise.all(n.map(a))}/** 4368 * @license 4369 * Copyright 2018 Google LLC. All Rights Reserved. 4370 * Licensed under the Apache License, Version 2.0 (the "License"); 4371 * you may not use this file except in compliance with the License. 4372 * You may obtain a copy of the License at 4373 * 4374 * http://www.apache.org/licenses/LICENSE-2.0 4375 * 4376 * Unless required by applicable law or agreed to in writing, software 4377 * distributed under the License is distributed on an "AS IS" BASIS, 4378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4379 * See the License for the specific language governing permissions and 4380 * limitations under the License. 4381 * ============================================================================= 4382 */async function qg(n,e){e==null&&(e={});const t=e.fetchFunc==null?U().platform.fetch:e.fetchFunc,r=n.map(d=>t(d,e.requestInit,{isBinary:!0})),s=0,a=.5,i=(e.onProgress==null?await Promise.all(r):await Uh(r,e.onProgress,s,a)).map(d=>d.arrayBuffer()),c=.5,l=1;return e.onProgress==null?await Promise.all(i):await Uh(i,e.onProgress,c,l)}function pN(n,e){var t;const r=e.fetchFunc==null?U().platform.fetch:e.fetchFunc;let s=0,a;return(t=e.onProgress)===null||t===void 0||t.call(e,0),new ReadableStream({pull:async o=>{for(var i;s<n.length;){a||(a=(await r(n[s],e.requestInit,{isBinary:!0})).body.getReader());const{done:c,value:l}=await a.read();if(c){s++,a=void 0,(i=e.onProgress)===null||i===void 0||i.call(e,s/n.length);continue}o.enqueue(l);return}o.close()}})}async function hN(n,e="",t,r){return Kg(o=>qg(o,{requestInit:r}))(n,e,t)}function Kg(n){return async(e,t="",r)=>{const s=e.map(()=>!1),a={},o=r!=null?r.map(()=>!1):[],i=[];if(e.forEach((h,m)=>{let g=0;h.weights.forEach(y=>{const b="quantization"in y?y.quantization.dtype:y.dtype,v=_s[b]*H(y.shape),$=()=>{s[m]=!0,a[m]==null&&(a[m]=[]),a[m].push({manifestEntry:y,groupOffset:g,sizeBytes:v})};r!=null?r.forEach((S,T)=>{S===y.name&&($(),o[T]=!0)}):$(),i.push(y.name),g+=v})}),!o.every(h=>h)){const h=r.filter((m,g)=>!o[g]);throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. 4383Manifest JSON has weights with names: ${i.join(", ")}.`)}const c=s.reduce((h,m,g)=>(m&&h.push(g),h),[]),l=[];c.forEach(h=>{e[h].paths.forEach(m=>{const g=t+(t.endsWith("/")?"":"/")+m;l.push(g)})});const u=await n(l),d={};let p=0;return c.forEach(h=>{const m=e[h].paths.length,g=new Xn(u.slice(p,p+m));a[h].forEach(b=>{const v=g.slice(b.groupOffset,b.groupOffset+b.sizeBytes),$=Mm(v,[b.manifestEntry]);for(const S in $)d[S]=$[S]}),p+=m}),d}}/** 4384 * @license 4385 * Copyright 2018 Google LLC. All Rights Reserved. 4386 * Licensed under the Apache License, Version 2.0 (the "License");
4387 * you may not use this file except in compliance with the License. 4388 * You may obtain a copy of the License at 4389 * 4390 * http://www.apache.org/licenses/LICENSE-2.0 4391 * 4392 * Unless required by applicable law or agreed to in writing, software 4393 * distributed under the License is distributed on an "AS IS" BASIS, 4394 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4395 * See the License for the specific language governing permissions and 4396 * limitations under the License. 4397 * ============================================================================= 4398 */const fN="application/octet-stream",mN="application/json";class Cp{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?(N(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=U().platform.fetch,N(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&N(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||{},this.loadOptions=t}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}],s=Wm(e,r);if(t.body.append("model.json",new Blob([JSON.stringify(s)],{type:mN}),"model.json"),e.weightData!=null){const o=Xn.join(e.weightData);t.body.append("model.weights.bin",new Blob([o],{type:fN}),"model.weights.bin")}const a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:No(e),responses:[a]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${a.status}.`)}async loadModelJSON(){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 o=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?o+=" 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.":o+=" Please make sure the server is serving valid JSON for this request.",new Error(o)}const r=t.modelTopology,s=t.weightsManifest;if(r==null&&s==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return t}async load(){if(this.loadOptions.streamWeights)return this.loadStream();const e=await this.loadModelJSON();return dp(e,t=>this.loadWeights(t))}async loadStream(){const e=await this.loadModelJSON(),t=await this.getWeightUrls(e.weightsManifest),r=Uc(e.weightsManifest),s=()=>pN(t,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:r,getWeightStream:s})}async getWeightUrls(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[r,s]=gN(t),a=this.weightPathPrefix||r,o=[],i=[];for(const c of e)for(const l of c.paths)this.weightUrlConverter!=null?i.push(this.weightUrlConverter(l)):o.push(a+l+s);return this.weightUrlConverter&&o.push(...await Promise.all(i)),o}async loadWeights(e){const t=await this.getWeightUrls(e),r=Uc(e),s=await qg(t,this.loadOptions);return[r,s]}}Cp.URL_SCHEME_REGEX=/^https?:\/\//;function gN(n){const e=n.lastIndexOf("/"),t=n.lastIndexOf("?"),r=n.substring(0,e),s=t>e?n.substring(t):"";return[r+"/",s]}function Qc(n){return n.match(Cp.URL_SCHEME_REGEX)!=null}const Xg=(n,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let t=!0;if(Array.isArray(n)?t=n.every(r=>Qc(r)):t=Qc(n),t)return _p(n,e)}return null};tt.registerSaveRouter(Xg);tt.registerLoadRouter(Xg);function _p(n,e){return new Cp(n,e)}function yN(n,e){return _p(n,e)}/** 4399 * @license 4400 * Copyright 2018 Google LLC. All Rights Reserved. 4401 * Licensed under the Apache License, Version 2.0 (the "License");
4402 * you may not use this file except in compliance with the License. 4403 * You may obtain a copy of the License at 4404 * 4405 * http://www.apache.org/licenses/LICENSE-2.0 4406 * 4407 * Unless required by applicable law or agreed to in writing, software 4408 * distributed under the License is distributed on an "AS IS" BASIS, 4409 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4410 * See the License for the specific language governing permissions and 4411 * limitations under the License. 4412 * ============================================================================= 4413 */class hc{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class Yg{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class bN{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function xN(n,e,t,r){const s=arguments;return new bN(Qg(...s))}function Qg(n,e,t,r){return arguments.length===1?n.modelTopology!=null||n.weightSpecs!=null?new hc(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 hc({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 hc({modelTopology:n,weightSpecs:e,weightData:t,trainingConfig:r}))}function wN(n){return new Yg(n)}function vN(n){return new Yg(n)}/** 4414 * @license 4415 * Copyright 2018 Google LLC. All Rights Reserved. 4416 * Licensed under the Apache License, Version 2.0 (the "License"); 4417 * you may not use this file except in compliance with the License. 4418 * You may obtain a copy of the License at 4419 * 4420 * http://www.apache.org/licenses/LICENSE-2.0 4421 * 4422 * Unless required by applicable law or agreed to in writing, software 4423 * distributed under the License is distributed on an "AS IS" BASIS, 4424 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4425 * See the License for the specific language governing permissions and 4426 * limitations under the License. 4427 * ============================================================================= 4428 */const Zg=Object.freeze(Object.defineProperty({__proto__:null,browserFiles:dN,browserHTTPRequest:yN,CompositeArrayBuffer:Xn,concatenateArrayBuffers:kw,decodeWeights:Mm,decodeWeightsStream:Vm,encodeWeights:$w,fromMemory:xN,fromMemorySync:Qg,getLoadHandlers:Lw,getModelArtifactsForJSON:dp,getModelArtifactsForJSONSync:Um,getModelArtifactsInfoForJSON:No,getSaveHandlers:Pw,getWeightSpecs:Uc,http:_p,isHTTPScheme:Qc,loadWeights:hN,registerLoadRouter:Fw,registerSaveRouter:Ow,weightsLoaderFactory:Kg,withSaveHandler:wN,withSaveHandlerSync:vN,copyModel:Qw,listModels:Xw,moveModel:Zw,removeModel:Yw},Symbol.toStringTag,{value:"Module"}));/** 4429 * @license 4430 * Copyright 2019 Google LLC. All Rights Reserved. 4431 * Licensed under the Apache License, Version 2.0 (the "License"); 4432 * you may not use this file except in compliance with the License. 4433 * You may obtain a copy of the License at 4434 * 4435 * http://www.apache.org/licenses/LICENSE-2.0 4436 * 4437 * Unless required by applicable law or agreed to in writing, software 4438 * distributed under the License is distributed on an "AS IS" BASIS, 4439 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4440 * See the License for the specific language governing permissions and 4441 * limitations under the License. 4442 * ============================================================================= 4443 */let ds,zh=!1;function IN(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,s=!1,a=!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)s=!0;else if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)a=!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(bi(Oc,F.backendName)!=null){const m={pixels:n},g={numChannels:e};return F.runKernel(Oc,m,g)}const[l,u]=s?[n.videoWidth,n.videoHeight]:[n.width,n.height];let d;if(o)d=n.getContext("2d").getImageData(0,0,l,u).data;else if(r||t)d=n.data;
vendor: 11,294 bytes, lines 4443-4476
4443else if(a||s||i){if(ds==null)if(typeof document>"u")if(typeof OffscreenCanvas<"u"&&typeof OffscreenCanvasRenderingContext2D<"u")ds=new OffscreenCanvas(1,1).getContext("2d");else throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");else ds=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});ds.canvas.width=l,ds.canvas.height=u,ds.drawImage(n,0,0,l,u),d=ds.getImageData(0,0,l,u).data}let p;if(e===4)p=new Int32Array(d);else{const m=l*u;p=new Int32Array(m*e);for(let g=0;g<m;g++)for(let y=0;y<e;++y)p[g*e+y]=d[g*4+y]}return Pg(p,[u,l,e],"int32")}function $N(n){if(n.rank!==2&&n.rank!==3)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${n.rank}.`);const e=n.rank===2?1:n.shape[2];if(e>4||e===2)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${e}`);if(n.dtype!=="float32"&&n.dtype!=="int32")throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`)}async function SN(n,e){let t=_(n,"img","toPixels");if(!(n instanceof dt)){const l=t;t=rt(l,"int32"),l.dispose()}$N(t);const[r,s]=t.shape.slice(0,2),a=t.rank===2?1:t.shape[2],o=await t.data(),i=t.dtype==="float32"?255:1,c=new Uint8ClampedArray(s*r*4);for(let l=0;l<r*s;++l){const u=[0,0,0,255];for(let p=0;p<a;p++){const h=o[l*a+p];if(t.dtype==="float32"){if(h<0||h>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${h}.`)}else if(t.dtype==="int32"&&(h<0||h>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${h}.`);a===1?(u[0]=h*i,u[1]=h*i,u[2]=h*i):u[p]=h*i}const d=l*4;c[d+0]=Math.round(u[0]),c[d+1]=Math.round(u[1]),c[d+2]=Math.round(u[2]),c[d+3]=Math.round(u[3])}if(e!=null){zh||bi(j0,F.backendName)!=null&&(console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."),zh=!0),e.width=s,e.height=r;const l=e.getContext("2d"),u=new ImageData(c,s,r);l.putImageData(u,0,0)}return t!==n&&t.dispose(),c}const CN=D({fromPixels_:IN});function Np(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(H(n.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${n.shape}.`);const s=e.shape,a=s[s.length-1];let o=1;for(let d=0;d<s.length-1;++d)o*=s[d];const i=n.shape,c=s.slice();c.pop();let l=1;for(let d=a;d<t;++d)l*=i[d],c.push(i[d]);const u=[...Be(n.shape).map(d=>d/l),1].slice(0,a);return[c,o,l,u]}/** 4444 * @license 4445 * Copyright 2021 Google LLC. All Rights Reserved. 4446 * Licensed under the Apache License, Version 2.0 (the "License"); 4447 * you may not use this file except in compliance with the License. 4448 * You may obtain a copy of the License at 4449 * 4450 * http://www.apache.org/licenses/LICENSE-2.0 4451 * 4452 * Unless required by applicable law or agreed to in writing, software 4453 * distributed under the License is distributed on an "AS IS" BASIS, 4454 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4455 * See the License for the specific language governing permissions and 4456 * limitations under the License. 4457 * ============================================================================= 4458 */const Zc=-2,_N=-1;function Jg(n,e,t){const r=n.shape.length;N(r===e.length,()=>`Error in slice${r}D: Length of begin ${e} must match the rank of the array (${r}).`),N(r===t.length,()=>`Error in slice${r}D: Length of size ${t} must match the rank of the array (${r}).`);for(let s=0;s<r;++s)N(e[s]+t[s]<=n.shape[s],()=>`Error in slice${r}D: begin[${s}] + size[${s}] (${e[s]+t[s]}) would overflow input.shape[${s}] (${n.shape[s]})`)}function NN(n){const e=[];let t=0;for(;n>0;)n&1&&e.push(t),n/=2,t++;return e}function Tp(n,e,t){const r=[];for(let s=0;s<n.length;s++)r[s]=Math.ceil((e[s]-n[s])/t[s]);return r}function ey(n,e,t,r){const s=[...n];for(let a=s.length;a<r.length;a++)s.push(1);for(let a=0;a<t;a++)a===0?s[e]=1:(s.splice(e,0,1),s.pop());return s}function ty(n,e,t){return t<=n?t:t-(e-1)}function ny(n,e){const t=[];for(let r=0;r<n;r++)t.push(e+r);return t}function TN(n,e,t,r,s,a,o,i,c){const l=n.length;let u=new Array(l),d=new Array(l),p=new Array(l);if(e.length&&t>0){const h=e[0],m=t+1;u=ry(o,h,m,r,n),d=sy(i,h,m,s,n),p=ey(a,h,m,n)}else for(let h=0;h<l;h++)u[h]=oy(o,r,a,n,h,c),d[h]=iy(i,s,a,n,h,c),p[h]=ay(a,h,c);return{begin:u,end:d,strides:p}}function ry(n,e,t,r,s){const a=[...s],o=ny(t,e);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=0;else{const c=ty(e,t,i);let l=r[c];n&1<<c&&(l=0),a[i]=l}return a}function sy(n,e,t,r,s){const a=[...s],o=ny(t,e);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=Number.MAX_SAFE_INTEGER;else{const c=ty(e,t,i);let l=r[c];n&1<<c&&(l=Number.MAX_SAFE_INTEGER),a[i]=l}for(let i=0;i<a.length;i++){const c=s[i];a[i]<0&&(a[i]+=c),a[i]=gi(0,a[i],s[i])}return a}function ay(n,e,t){let r=n[e];return(t&1<<e||r==null)&&(r=1),r}function oy(n,e,t,r,s,a){let o=e[s];const i=t[s]||1;(n&1<<s||a&1<<s||o==null)&&(i>0?o=Number.MIN_SAFE_INTEGER:o=Number.MAX_SAFE_INTEGER);const c=r[s];return o<0&&(o+=c),o=gi(0,o,c-1),o}function iy(n,e,t,r,s,a){let o=e[s];const i=t[s]||1;(n&1<<s||a&1<<s||o==null)&&(i>0?o=Number.MAX_SAFE_INTEGER:o=Number.MIN_SAFE_INTEGER);const c=r[s];return o<0&&(o+=c),i>0?o=gi(0,o,c):o=gi(-1,o,c-1),o}function Yu(n,e,t){let r=t.length;for(let s=0;s<t.length;s++)if(t[s]>1){r=s;break}for(let s=r+1;s<t.length;s++)if(e[s]>0||t[s]!==n[s])return!1;return!0}function Qu(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 kp(n,e,t){let r;const s=n.shape.length;typeof e=="number"?r=[e,...new Array(s-1).fill(0)]:e.length<s?r=e.concat(new Array(s-e.length).fill(0)):r=e.slice(),r.forEach(o=>{N(o!==-1,()=>"slice() does not support negative begin indexing.")});let a;return t==null?a=new Array(s).fill(-1):typeof t=="number"?a=[t,...new Array(s-1).fill(-1)]:t.length<s?a=t.concat(new Array(s-t.length).fill(-1)):a=t,a=a.map((o,i)=>o>=0?o:(N(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,a]}function Ep(n,e,t,r,s,a,o,i,c){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 u=!1;const d={dims:l.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:t.slice(),strides:l.slice(),beginMask:s,endMask:a,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:c};for(let $=0;$<d.dims;$++)u&&(1<<$&i)!==0&&d.numAddAxisAfterEllipsis++,1<<$&o&&(u=!0);u||(d.ellipsisMask|=1<<d.dims,d.dims++);const p={dims:n.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};kN(d,p);let h=!0,m=!0,g=!0;const y=[],b=[];for(let $=0;$<n.length;++$){if(p.strides[$]===0)throw Error(`strides[${$}] must be non-zero`);const S=!!(p.shrinkAxisMask&1<<$),T=n[$];if(T===-1){y.push(S?1:-1);continue}const O=[p.beginMask&1<<$,p.endMask&1<<$],L=[p.strides[$]>0?0:-1,p.strides[$]>0?T:T-1];if(S&&p.strides[$]<=0)throw Error("only stride 1 allowed on non-range indexing.");g=g&&p.strides[$]===1;const M=!!(p.beginMask&1<<$&&p.endMask&1<<$);if(p.beginValid&&p.endValid){if(S){const K=p.begin[$]<0?T+p.begin[$]:p.begin[$];if(p.begin[$]=K,p.end[$]=p.begin[$]+1,K<0||K>=T)throw Error(`slice index ${p.begin[$]} of dimension ${$} out of bounds.`)}else p.begin[$]=Gh(p.begin[$],0,p.strides[$],T,O,L),p.end[$]=Gh(p.end[$],1,p.strides[$],T,O,L);const G=p.strides[$]===1&&p.begin[$]===0&&p.end[$]===T;h=h&&G,m=m&&($===0&&p.strides[$]===1||G)}else h=h&&p.strides[$]===1&&M,m=m&&($===0&&p.strides[$]===1||M);let W,V=!1;if(p.beginValid&&p.endValid?(W=p.end[$]-p.begin[$],V=!0):S?(W=1,V=!0):M&&T>=0&&(p.strides[$]<0?W=-T:W=T,V=!0),V){let G;W===0||W<0!=p.strides[$]<0?G=0:G=Math.trunc(W/p.strides[$])+(W%p.strides[$]!==0?1:0),y.push(G)}else y.push(-1)}for(let $=0;$<p.finalShapeGatherIndices.length;++$){const S=p.finalShapeGatherIndices[$];S>=0?b.push(y[S]):S===Zc&&b.push(1)}return{finalShapeSparse:b.filter(($,S)=>p.finalShapeGatherIndices[S]!==Zc),finalShape:b,isIdentity:h,sliceDim0:m,isSimpleSlice:g,begin:p.begin,end:p.end,strides:p.strides}}function kN(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 s=Math.min(e.dims-(n.dims-r)+1+n.numAddAxisAfterEllipsis,e.dims);for(;t<s;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(Zc),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(_N),e.finalShapeGatherIndicesSparse.push(-1),e.shrinkAxisMask|=1<<t):(e.finalShapeGatherIndices.push(t),e.finalShapeGatherIndicesSparse.push(r)),e.inputShapeGatherIndicesSparse[t]=r,t++}}function Gh(n,e,t,r,s,a){if(s[e])return t>0?a[e]:a[e+1&1];{const o=n<0?r+n:n;return o<a[0]?a[0]:o>a[1]?a[1]:o}}const EN=Object.freeze(Object.defineProperty({__proto__:null,assertParamsValid:Jg,maskToAxes:NN,computeOutShape:Tp,stridesWithElidedDims:ey,getNormalizedAxes:TN,startIndicesWithElidedDims:ry,stopIndicesWithElidedDims:sy,stridesForAxis:ay,startForAxis:oy,stopForAxis:iy,isSliceContinous:Yu,computeFlatOffset:Qu,parseSliceParams:kp,sliceInfo:Ep},Symbol.toStringTag,{value:"Module"}));/** 4459 * @license 4460 * Copyright 2017 Google LLC. All Rights Reserved. 4461 * Licensed under the Apache License, Version 2.0 (the "License"); 4462 * you may not use this file except in compliance with the License. 4463 * You may obtain a copy of the License at 4464 * 4465 * http://www.apache.org/licenses/LICENSE-2.0 4466 * 4467 * Unless required by applicable law or agreed to in writing, software 4468 * distributed under the License is distributed on an "AS IS" BASIS, 4469 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4470 * See the License for the specific language governing permissions and 4471 * limitations under the License. 4472 * ============================================================================= 4473 */const RN=(()=>typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:n=>n())();function AN(){return new Promise(n=>RN(()=>n()))}/** 4474 * @license 4475 * Copyright 2017 Google LLC. All Rights Reserved. 4476 * Licensed under the Apache License, Version 2.0 (the "License");
4477 * you may not use this file except in compliance with the License. 4478 * You may obtain a copy of the License at 4479 * 4480 * http://www.apache.org/licenses/LICENSE-2.0 4481 * 4482 * Unless required by applicable law or agreed to in writing, software 4483 * distributed under the License is distributed on an "AS IS" BASIS, 4484 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4485 * See the License for the specific language governing permissions and 4486 * limitations under the License. 4487 * ============================================================================= 4488 */function Rp(n,e){const t=n[0].length;n.forEach((s,a)=>{N(s.length===t,()=>`Error in concat${t}D: rank of tensors[${a}] must be the same as the rank of the rest (${t})`)}),N(e>=0&&e<t,()=>`Error in concat${t}D: axis must be between 0 and ${t-1}.`);const r=n[0];n.forEach((s,a)=>{for(let o=0;o<t;o++)N(o===e||s[o]===r[o],()=>`Error in concat${t}D: Shape of tensors[${a}] (${s}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`)})}function or(n,e){const t=n[0].slice();for(let r=1;r<n.length;r++)t[e]+=n[r][e];return t}/** 4489 * @license 4490 * Copyright 2022 Google LLC. All Rights Reserved. 4491 * Licensed under the Apache License, Version 2.0 (the "License"); 4492 * you may not use this file except in compliance with the License. 4493 * You may obtain a copy of the License at 4494 * 4495 * http://www.apache.org/licenses/LICENSE-2.0 4496 * 4497 * Unless required by applicable law or agreed to in writing, software 4498 * distributed under the License is distributed on an "AS IS" BASIS, 4499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4500 * See the License for the specific language governing permissions and 4501 * limitations under the License. 4502 * ============================================================================= 4503 */var Wn;(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"})(Wn||(Wn={}));function uy(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 s=1;s<t.length;++s){const a=t[s],o=r[r.length-t.length+s],i=r[o];if(a>=0)if(i>=0){if(i!==a)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${s+n}] = ${a} but shape[${s+n}] = ${i}`)}else r[o]=a}return r}function cy(n){const e={FIRST_DIM_SIZE:Wn.FIRST_DIM_SIZE,VALUE_ROWIDS:Wn.VALUE_ROWIDS,ROW_LENGTHS:Wn.ROW_LENGTHS,ROW_SPLITS:Wn.ROW_SPLITS,ROW_LIMITS:Wn.ROW_LIMITS,ROW_STARTS:Wn.ROW_STARTS},t=[];for(const r of n)if(r in e)t.push(e[r]);else break;return t}function ly(n){return n.length===0?0:n[0]===Wn.FIRST_DIM_SIZE?n.length-1:n.length}function dy(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 s=0;s<Math.min(t,r-1);++s){const a=n[s],o=e[s+1];if(a>=0&&o>=0&&a!==1&&a!==o)throw new Error(`defaultValue.shape=${n}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${s-n.length}] = ${a} but ragged tensor input.flatValues.shape[${s-n.length}] = ${o}`)}}/** 4504 * @license 4505 * Copyright 2017 Google LLC. All Rights Reserved. 4506 * Licensed under the Apache License, Version 2.0 (the "License"); 4507 * you may not use this file except in compliance with the License. 4508 * You may obtain a copy of the License at 4509 * 4510 * http://www.apache.org/licenses/LICENSE-2.0 4511 * 4512 * Unless required by applicable law or agreed to in writing, software 4513 * distributed under the License is distributed on an "AS IS" BASIS, 4514 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4515 * See the License for the specific language governing permissions and 4516 * limitations under the License. 4517 * ============================================================================= 4518 */const Ap=30;function Zu(n){return n<=Ap?n:Rc(n,Math.floor(Math.sqrt(n)))}/** 4519 * @license 4520 * Copyright 2020 Google LLC. All Rights Reserved. 4521 * Licensed under the Apache License, Version 2.0 (the "License");
4522 * you may not use this file except in compliance with the License. 4523 * You may obtain a copy of the License at 4524 * 4525 * http://www.apache.org/licenses/LICENSE-2.0 4526 * 4527 * Unless required by applicable law or agreed to in writing, software 4528 * distributed under the License is distributed on an "AS IS" BASIS, 4529 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4530 * See the License for the specific language governing permissions and 4531 * limitations under the License. 4532 * ============================================================================= 4533 */function Dp(n,e,t){const r=t*(typeof n=="number"?n:n[0]),s=e*(typeof n=="number"?n:n[1]);return[r,s]}/** 4534 * @license 4535 * Copyright 2018 Google LLC. All Rights Reserved. 4536 * Licensed under the Apache License, Version 2.0 (the "License"); 4537 * you may not use this file except in compliance with the License. 4538 * You may obtain a copy of the License at 4539 * 4540 * http://www.apache.org/licenses/LICENSE-2.0 4541 * 4542 * Unless required by applicable law or agreed to in writing, software 4543 * distributed under the License is distributed on an "AS IS" BASIS, 4544 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4545 * See the License for the specific language governing permissions and 4546 * limitations under the License. 4547 * ============================================================================= 4548 */function Ao(n,e,t,r=!0){let s=[];if(r)s=s.concat(e.slice(0)),s.push(n[0]/t),s=s.concat(n.slice(1));else{s=s.concat(n[0]);const a=e.length;for(let o=0;o<a;++o)s=s.concat([n[o+1]/e[o],e[o]]);s=s.concat(n.slice(a+1))}return s}function Do(n,e,t=!0){const r=[];if(t){r.push(e);for(let s=e+1;s<n;++s)s<=2*e?(r.push(s),r.push(s-(e+1))):r.push(s)}else{const s=[],a=[];for(let o=1;o<n;++o)o>=e*2+1||o%2===1?a.push(o):s.push(o);r.push(...s),r.push(0),r.push(...a)}return r}function Oo(n,e,t,r=!0){const s=[];r?s.push(n[0]/t):s.push(n[0]*t);for(let a=1;a<n.length;++a)a<=e.length?r?s.push(e[a-1]*n[a]):s.push(n[a]/e[a-1]):s.push(n[a]);return s}function Op(n,e){const t=[0];for(let r=0;r<e;++r)t.push(n[r][0]);return t}function Fp(n,e,t){const r=n.slice(0,1);for(let s=0;s<t;++s)r.push(n[s+1]-e[s][0]-e[s][1]);return r}/** 4549 * @license 4550 * Copyright 2018 Google LLC. All Rights Reserved. 4551 * Licensed under the Apache License, Version 2.0 (the "License"); 4552 * you may not use this file except in compliance with the License. 4553 * You may obtain a copy of the License at 4554 * 4555 * http://www.apache.org/licenses/LICENSE-2.0 4556 * 4557 * Unless required by applicable law or agreed to in writing, software 4558 * distributed under the License is distributed on an "AS IS" BASIS, 4559 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4560 * See the License for the specific language governing permissions and 4561 * limitations under the License. 4562 * ============================================================================= 4563 */const py=1.7580993408473768,hy=1.0507009873554805;/** 4564 * @license 4565 * Copyright 2018 Google LLC. All Rights Reserved. 4566 * Licensed under the Apache License, Version 2.0 (the "License"); 4567 * you may not use this file except in compliance with the License. 4568 * You may obtain a copy of the License at 4569 * 4570 * http://www.apache.org/licenses/LICENSE-2.0 4571 * 4572 * Unless required by applicable law or agreed to in writing, software 4573 * distributed under the License is distributed on an "AS IS" BASIS, 4574 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4575 * See the License for the specific language governing permissions and 4576 * limitations under the License. 4577 * ============================================================================= 4578 */const fy=.3275911,my=.254829592,gy=-.284496736,yy=1.421413741,by=-1.453152027,xy=1.061405429;/** 4579 * @license 4580 * Copyright 2018 Google LLC. All Rights Reserved. 4581 * Licensed under the Apache License, Version 2.0 (the "License"); 4582 * you may not use this file except in compliance with the License. 4583 * You may obtain a copy of the License at 4584 * 4585 * http://www.apache.org/licenses/LICENSE-2.0 4586 * 4587 * Unless required by applicable law or agreed to in writing, software 4588 * distributed under the License is distributed on an "AS IS" BASIS, 4589 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4590 * See the License for the specific language governing permissions and 4591 * limitations under the License. 4592 * =============================================================================
vendor: 4,680 bytes, lines 4593-4611
4593 */function Jc(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 DN(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 ON(n){const e=Math.ceil(n.length/4),t=new Float32Array(e),r=new Float32Array(e);for(let s=0;s<n.length;s+=4)t[Math.floor(s/4)]=n[s],r[Math.floor(s/4)]=n[s+1];return{real:t,imag:r}}function FN(n){const e=Math.floor(n.length/4),t=new Float32Array(e),r=new Float32Array(e);for(let s=2;s<n.length;s+=4)t[Math.floor(s/4)]=n[s],r[Math.floor(s/4)]=n[s+1];return{real:t,imag:r}}function PN(n,e){const t=n[e*2],r=n[e*2+1];return{real:t,imag:r}}function LN(n,e,t,r){n[r*2]=e,n[r*2+1]=t}function MN(n,e){const t=new Float32Array(n/2),r=new Float32Array(n/2);for(let s=0;s<Math.ceil(n/2);s++){const a=(e?2:-2)*Math.PI*(s/n);t[s]=Math.cos(a),r[s]=Math.sin(a)}return{real:t,imag:r}}function BN(n,e,t){const r=(t?2:-2)*Math.PI*(n/e),s=Math.cos(r),a=Math.sin(r);return{real:s,imag:a}}/** 4594 * @license 4595 * Copyright 2021 Google LLC. All Rights Reserved. 4596 * Licensed under the Apache License, Version 2.0 (the "License"); 4597 * you may not use this file except in compliance with the License. 4598 * You may obtain a copy of the License at 4599 * 4600 * http://www.apache.org/licenses/LICENSE-2.0 4601 * 4602 * Unless required by applicable law or agreed to in writing, software 4603 * distributed under the License is distributed on an "AS IS" BASIS, 4604 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4605 * See the License for the specific language governing permissions and 4606 * limitations under the License. 4607 * ============================================================================= 4608 */const fc="->",VN=/->/g,Hh=",",jh="...";function wy(n,e){n=n.replace(/\s/g,"");const t=(n.length-n.replace(VN,"").length)/fc.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 ("${fc}").`);const[r,s]=n.split(fc);N(r.indexOf(jh)===-1,()=>`The ellipsis notation ("${jh}") is not supported yet.`);const a=r.split(Hh),o=a.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 p=0;p<s.length;++p){const h=s[p];if(!a.some(m=>m.indexOf(h)!==-1))throw new Error(`Output subscripts contain the label ${h} not present in the input subscripts.`);i.indexOf(h)===-1&&i.push(h)}for(let p=0;p<r.length;++p){const h=r[p];i.indexOf(h)===-1&&h!==Hh&&i.push(h)}const c=new Array(a.length);for(let p=0;p<o;++p){if(new Set(a[p].split("")).size!==a[p].length)throw new Error(`Found duplicate axes in input component ${a[p]}. Support for duplicate axes in input is not implemented yet.`);c[p]=[];for(let h=0;h<a[p].length;++h)c[p].push(i.indexOf(a[p][h]))}const l=i.length,u=s.length,d=[];for(let p=u;p<l;++p)d.push(p);return{allDims:i,summedDims:d,idDims:c}}function vy(n,e){let t=new Array(n);t.fill(-1);for(let s=0;s<e.length;++s)t[e[s]]=s;const r=[];for(let s=0;s<n;++s)t[s]===-1&&r.push(s);return t=t.filter(s=>s!==-1),{permutationIndices:t,expandDims:r}}function Iy(n,e,t){const r=new Array(n);for(let s=0;s<t.length;++s){const a=t[s].shape;for(let o=0;o<e[s].length;++o)r[e[s][o]]===void 0?r[e[s][o]]=a[o]:N(r[e[s][o]]===a[o],()=>`Expected dimension ${r[e[s][o]]} at axis ${o} of input shaped ${JSON.stringify(a)}, but got dimension ${a[o]}`)}}function $y(n,e){const t=n,r=[];let s=0;n.length===0&&t.push(-1),s=n.length+1;for(let o=0;o<s;++o)r.push([]);const a=[];for(let o=0;o<t.length;++o){const i=t[o],c=WN(e,i);for(const l of c)a.indexOf(l)===-1&&(r[o].push(l),a.push(l))}return{path:t,steps:r}}function Sy(n){return n.every((e,t)=>e===t)}function WN(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 Pp(n,e,t=0){let r=[];if(typeof e=="number")N(n.shape[t]%e===0,()=>"Number of splits must evenly divide the axis."),r=new Array(e).fill(n.shape[t]/e);else{const s=e.reduce((o,i)=>(i===-1&&(o+=1),o),0);N(s<=1,()=>"There should be only one negative value in split array.");const a=e.indexOf(-1);if(a!==-1){const o=e.reduce((i,c)=>c>0?i+c:i);e[a]=n.shape[t]-o}N(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}/** 4609 * @license 4610 * Copyright 2021 Google LLC. All Rights Reserved. 4611 * Licensed under the Apache License, Version 2.0 (the "License");
4612 * you may not use this file except in compliance with the License. 4613 * You may obtain a copy of the License at 4614 * 4615 * http://www.apache.org/licenses/LICENSE-2.0 4616 * 4617 * Unless required by applicable law or agreed to in writing, software 4618 * distributed under the License is distributed on an "AS IS" BASIS, 4619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4620 * See the License for the specific language governing permissions and 4621 * limitations under the License. 4622 * ============================================================================= 4623 */function Lp(n){return`Received SparseTensor with denseShape[0] = 0 but 4624 indices.shape[0] = ${n}`}function Mp(n,e){return`indices(${n}, 0) is invalid: ${e} < 0`}function Bp(n,e,t){return`indices(${n}, 0) is invalid: ${e} >= ${t}`}/** 4625 * @license 4626 * Copyright 2021 Google LLC. All Rights Reserved. 4627 * Licensed under the Apache License, Version 2.0 (the "License"); 4628 * you may not use this file except in compliance with the License. 4629 * You may obtain a copy of the License at 4630 * 4631 * http://www.apache.org/licenses/LICENSE-2.0 4632 * 4633 * Unless required by applicable law or agreed to in writing, software 4634 * distributed under the License is distributed on an "AS IS" BASIS, 4635 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4636 * See the License for the specific language governing permissions and 4637 * limitations under the License. 4638 * ============================================================================= 4639 */function Vp(n,e){return`only one output dimension may be -1, not both ${n} and ${e}`}function Wp(n,e){return`size ${n} must be non-negative, not ${e}`}function Up(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function zp(n,e){const t=H(n),r=H(e);return`Input to reshape is a SparseTensor with ${t} 4640 dense values, but the requested shape requires a multiple of ${r}. inputShape=${n} outputShape= ${e}`}function Gp(n,e){const t=H(n),r=H(e);return`Input to reshape is a tensor with ${t} dense values, but the requested shape has ${r}. inputShape=${n} outputShape=${e}`}/** 4641 * @license 4642 * Copyright 2021 Google LLC. All Rights Reserved. 4643 * Licensed under the Apache License, Version 2.0 (the "License"); 4644 * you may not use this file except in compliance with the License. 4645 * You may obtain a copy of the License at 4646 * 4647 * http://www.apache.org/licenses/LICENSE-2.0 4648 * 4649 * Unless required by applicable law or agreed to in writing, software 4650 * distributed under the License is distributed on an "AS IS" BASIS, 4651 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4652 * See the License for the specific language governing permissions and 4653 * limitations under the License. 4654 * ============================================================================= 4655 */function wo(){return"segment ids must be >= 0"}function Hp(){return"segment ids are not increasing"}function jp(n,e){return`Segment id ${n} out of range [0, ${e}), possibly because segmentIds input is not sorted.`}function qp(n,e,t){return`Bad: indices[${n}] == ${e} out of range [0, ${t})`}/** 4656 * @license 4657 * Copyright 2018 Google LLC. All Rights Reserved. 4658 * Licensed under the Apache License, Version 2.0 (the "License"); 4659 * you may not use this file except in compliance with the License. 4660 * You may obtain a copy of the License at 4661 * 4662 * http://www.apache.org/licenses/LICENSE-2.0 4663 * 4664 * Unless required by applicable law or agreed to in writing, software 4665 * distributed under the License is distributed on an "AS IS" BASIS, 4666 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4667 * See the License for the specific language governing permissions and 4668 * limitations under the License. 4669 * ============================================================================= 4670 */function Cy(n,e){let t=!1,r;for(n<=Ap?(r=n,t=!0):r=Rc(n,Math.floor(Math.sqrt(n)));!t;)r>e||r===n?t=!0:r=Rc(n,r+1);return r}function _y(n,e,t){const r=[],s=n.length;for(let a=0;a<s;a++)a!==e?r.push(n[a]):r.push(t);return r}function Kp(n,e,t,r){const s=e.shape.length,a=n.shape.length;if(r!==0&&(r<-s||r>s))throw new Error(`Expect batchDims in the range of [-${s}, ${s}], but got ${r}`);if(r<0&&(r+=s),r>a)throw new Error(`batchDims (${r}) must be less than rank(x) ( 4671 ${a}).`);if(t<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${t}).`);for(let d=0;d<r;++d)if(n.shape[d]!==e.shape[d])throw new Error(`x.shape[${d}]: ${n.shape[d]} should be equal to indices.shape[${d}]: ${e.shape[d]}.`);const o=n.shape[t],i=[];let c=1,l=1,u=1;for(let d=0;d<r;++d)i.push(n.shape[d]),c*=n.shape[d];for(let d=r;d<t;d++)i.push(n.shape[d]),l*=n.shape[d];for(let d=r;d<s;d++)i.push(e.shape[d]);for(let d=t+1;d<a;d++)i.push(n.shape[d]),u*=n.shape[d];return{batchSize:c,sliceSize:u,outerSize:l,dimSize:o,outputShape:i}}const UN=Object.freeze(Object.defineProperty({__proto__:null,segOpComputeOptimalWindowSize:Cy,computeOutShape:_y,collectGatherOpShapeInfo:Kp},Symbol.toStringTag,{value:"Module"}));/** 4672 * @license 4673 * Copyright 2018 Google LLC. All Rights Reserved. 4674 * Licensed under the Apache License, Version 2.0 (the "License");
4675 * you may not use this file except in compliance with the License. 4676 * You may obtain a copy of the License at 4677 * 4678 * http://www.apache.org/licenses/LICENSE-2.0 4679 * 4680 * Unless required by applicable law or agreed to in writing, software 4681 * distributed under the License is distributed on an "AS IS" BASIS, 4682 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4683 * See the License for the specific language governing permissions and 4684 * limitations under the License. 4685 * ============================================================================= 4686 */function Ca(n){try{return n.map(e=>Ia(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Xp(n){return n.map(e=>vs(e))}const zN=Object.freeze(Object.defineProperty({__proto__:null,slice_util:EN,segment_util:UN,fromUint8ToStringArray:Ca,fromStringArrayToUint8:Xp,upcastType:ir,axesAreInnerMostDims:fp,combineLocations:og,computeOutAndReduceShapes:At,expandShapeToKeepDim:pt,assertAxesAreInnerMostDims:ht,getAxesPermutation:Xt,getUndoAxesPermutation:Eo,getInnerMostAxes:St,getBroadcastDims:Ii,getReductionAxes:rg,assertAndGetBroadcastShape:ke,assertParamsConsistent:Rp,computeOutShape:or,computeDilation2DInfo:To,computePool2DInfo:kn,computePool3DInfo:Ir,computeConv2DInfo:$t,computeConv3DInfo:Xr,computeDefaultPad:pp,tupleValuesAreOne:fo,eitherStridesOrDilationsAreOne:Kt,stridesOrDilationsArePositive:ks,convertConv2DDataFormat:Yr,checkPadOnDimRoundingMode:En,getFusedDyActivation:Hu,getFusedBiasGradient:ju,applyActivation:qu,shouldFuse:Ku,get RowPartitionType(){return Wn},combineRaggedTensorToTensorShapes:uy,getRowPartitionTypesHelper:cy,getRaggedRank:ly,validateDefaultValueShape:dy,PARALLELIZE_THRESHOLD:Ap,computeOptimalWindowSize:Zu,getImageCenter:Dp,getReshaped:Ao,getPermuted:Do,getReshapedPermuted:Oo,getSliceBeginCoords:Op,getSliceSize:Fp,prepareAndValidate:Np,validateUpdateShape:Lg,validateInput:Ip,calculateShapes:Ms,SELU_SCALEALPHA:py,SELU_SCALE:hy,ERF_P:fy,ERF_A1:my,ERF_A2:gy,ERF_A3:yy,ERF_A4:by,ERF_A5:xy,warn:Un,log:K0,mergeRealAndImagArrays:Jc,splitRealAndImagArrays:DN,complexWithEvenIndex:ON,complexWithOddIndex:FN,getComplexWithIndex:PN,assignToTypedArray:LN,exponents:MN,exponent:BN,decodeEinsumEquation:wy,getEinsumPermutation:vy,checkEinsumDimSizes:Iy,getEinsumComputePath:$y,isIdentityPermutation:Sy,prepareSplitSize:Pp,getSparseFillEmptyRowsIndicesDenseShapeMismatch:Lp,getSparseFillEmptyRowsNegativeIndexErrorMessage:Mp,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:Bp,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:Vp,getSparseReshapeNegativeOutputDimErrorMessage:Wp,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:Up,getSparseReshapeInputOutputMultipleErrorMessage:zp,getSparseReshapeInputOutputMismatchErrorMessage:Gp,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:wo,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:Hp,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:jp,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:qp},Symbol.toStringTag,{value:"Module"}));/** 4687 * @license 4688 * Copyright 2017 Google LLC. All Rights Reserved. 4689 * Licensed under the Apache License, Version 2.0 (the "License"); 4690 * you may not use this file except in compliance with the License. 4691 * You may obtain a copy of the License at 4692 * 4693 * http://www.apache.org/licenses/LICENSE-2.0 4694 * 4695 * Unless required by applicable law or agreed to in writing, software 4696 * distributed under the License is distributed on an "AS IS" BASIS, 4697 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4698 * See the License for the specific language governing permissions and 4699 * limitations under the License. 4700 * ============================================================================= 4701 */sN();/** 4702 * @license 4703 * Copyright 2018 Google LLC. All Rights Reserved. 4704 * Licensed under the Apache License, Version 2.0 (the "License"); 4705 * you may not use this file except in compliance with the License. 4706 * You may obtain a copy of the License at 4707 * 4708 * http://www.apache.org/licenses/LICENSE-2.0 4709 * 4710 * Unless required by applicable law or agreed to in writing, softw
4710are 4711 * distributed under the License is distributed on an "AS IS" BASIS, 4712 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4713 * See the License for the specific language governing permissions and 4714 * limitations under the License. 4715 * ============================================================================= 4716 */const gs={},ri={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function GN(n,e){gs[n]=e}function qn(n,e){if(!(n in gs)||e!=null){const r=jN(n,e);if(r!==null)gs[n]=r;else return console.log("Could not get context for WebGL version",n),null}const t=gs[n];return t==null||t.isContextLost()?(delete gs[n],qn(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),gs[n])}function HN(n){if(!U().getBool("IS_SAFARI")&&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 jN(n,e){if(n!==1&&n!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=e==null?HN(n):e;return t.addEventListener("webglcontextlost",r=>{r.preventDefault(),delete gs[n]},!1),U().getBool("SOFTWARE_WEBGL_ENABLED")&&(ri.failIfMajorPerformanceCaveat=!1),n===1?t.getContext("webgl",ri)||t.getContext("experimental-webgl",ri):t.getContext("webgl2",ri)}/** 4717 * @license 4718 * Copyright 2017 Google LLC. All Rights Reserved. 4719 * Licensed under the Apache License, Version 2.0 (the "License"); 4720 * you may not use this file except in compliance with the License. 4721 * You may obtain a copy of the License at 4722 * 4723 * http://www.apache.org/licenses/LICENSE-2.0 4724 * 4725 * Unless required by applicable law or agreed to in writing, software 4726 * distributed under the License is distributed on an "AS IS" BASIS, 4727 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4728 * See the License for the specific language governing permissions and 4729 * limitations under the License. 4730 * ============================================================================= 4731 */var vo;(function(n){n[n.DENSE=0]="DENSE",n[n.SHARED_BATCH=1]="SHARED_BATCH"})(vo||(vo={}));var pn;(function(n){n[n.RENDER=0]="RENDER",n[n.UPLOAD=1]="UPLOAD",n[n.PIXELS=2]="PIXELS",n[n.DOWNLOAD=3]="DOWNLOAD"})(pn||(pn={}));var wt;(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"})(wt||(wt={}));function Fo(n,e){return[e,n]}function qN(n,e){return n*e}function si(n){const e=H(n),t=Math.ceil(e/4);return kc(t)}function Aa(n,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(n/2))]}function KN(n,e){const[t,r]=Aa(n,e);return t*r*4}function Yp(n,e){const t=n;let r,s,a,o,i,c,l,u,d,p;return U().getNumber("WEBGL_VERSION")===2?(r=t.R32F,s=t.R16F,a=t.RGBA16F,o=t.RGBA32F,i=t.RED,l=4,u=1,d=t.HALF_FLOAT,p=t.FLOAT,c=t.RGBA8):(r=n.RGBA,s=n.RGBA,a=n.RGBA,o=t.RGBA,i=n.RGBA,l=4,u=4,d=e!=null?e.HALF_FLOAT_OES:null,p=n.FLOAT,c=n.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:s,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:o,textureFormatFloat:i,downloadTextureFormat:c,downloadUnpackNumChannels:l,defaultNumChannels:u,textureTypeHalfFloat:d,textureTypeFloat:p}}/** 4732 * @license 4733 * Copyright 2017 Google LLC. All Rights Reserved. 4734 * Licensed under the Apache License, Version 2.0 (the "License"); 4735 * you may not use this file except in compliance with the License. 4736 * You may obtain a copy of the License at 4737 * 4738 * http://www.apache.org/licenses/LICENSE-2.0 4739 * 4740 * Unless required by applicable law or agreed to in writing, software 4741 * distributed under the License is distributed on an "AS IS" BASIS, 4742 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4743 * See the License for the specific language governing permissions and 4744 * limitations under the License. 4745 * ============================================================================= 4746 */function oe(n,e){const t=e();
vendor: 18,060 bytes, lines 4746-4891
4746return U().getBool("DEBUG")&&XN(n),t}function XN(n){const e=n.getError();if(e!==n.NO_ERROR)throw new Error("WebGL Error: "+JN(n,e))}const YN=596e-10,QN=65504;function ZN(n){return!!(U().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||n===0||YN<Math.abs(n)&&Math.abs(n)<QN)}function JN(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 ai(n,e){return Sr(n,()=>n.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function eT(n,e){const t=Sr(n,()=>n.createShader(n.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(oe(n,()=>n.shaderSource(t,e)),oe(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 tT(n,e){const t=Sr(n,()=>n.createShader(n.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(oe(n,()=>n.shaderSource(t,e)),oe(n,()=>n.compileShader(t)),U().get("ENGINE_COMPILE_ONLY"))return t;if(n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw Ny(e,n.getShaderInfoLog(t)),new Error("Failed to compile fragment shader.");return t}const nT=/ERROR: [0-9]+:([0-9]+):/g;function Ny(n,e){const t=nT.exec(e);if(t==null){console.log(`Couldn't parse line number in error: ${e}`),console.log(n);return}const r=+t[1],s=n.split(` 4747`),a=s.length.toString().length+2,o=s.map((d,p)=>fa((p+1).toString(),a)+d);let i=0;for(let d=0;d<o.length;d++)i=Math.max(o[d].length,i);const c=o.slice(0,r-1),l=o.slice(r-1,r),u=o.slice(r);console.log(c.join(` 4748`)),console.log(e.split(` 4749`)[0]),console.log(`%c ${fa(l[0],i)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(u.join(` 4750`))}function rT(n){return Sr(n,()=>n.createProgram(),"Unable to create WebGLProgram.")}function sT(n,e){if(oe(n,()=>n.linkProgram(e)),!U().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 mc(n,e){if(oe(n,()=>n.validateProgram(e)),n.getProgramParameter(e,n.VALIDATE_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function aT(n,e){const t=Sr(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return oe(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),oe(n,()=>n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function oT(n,e){const t=Sr(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return oe(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t)),oe(n,()=>n.bufferData(n.ELEMENT_ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function iT(n){return Sr(n,()=>n.createTexture(),"Unable to create WebGLTexture.")}function uT(n,e){const t=U().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(n<=0||e<=0){const r=`[${n}x${e}]`;throw new Error("Requested texture size "+r+" is invalid.")}if(n>t||e>t){const r=`[${n}x${e}]`,s=`[${t}x${t}]`;throw new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU "+s+".")}}function cT(n){return Sr(n,()=>n.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function qh(n,e,t,r,s,a,o){const i=n.getAttribLocation(e,t);return i===-1?!1:(oe(n,()=>n.bindBuffer(n.ARRAY_BUFFER,r)),oe(n,()=>n.vertexAttribPointer(i,s,n.FLOAT,!1,a,o)),oe(n,()=>n.enableVertexAttribArray(i)),!0)}function lT(n,e,t){mT(n,t),oe(n,()=>n.activeTexture(n.TEXTURE0+t)),oe(n,()=>n.bindTexture(n.TEXTURE_2D,e))}function dT(n,e,t){return Sr(n,()=>n.getUniformLocation(e,t),'uniform "'+t+'" not present in program.')}function pT(n,e,t){return n.getUniformLocation(e,t)}function hT(n,e,t,r){oe(n,()=>lT(n,e,r)),oe(n,()=>n.uniform1i(t,r))}function gc(n,e,t){oe(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,t)),oe(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0))}function Kh(n,e){oe(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,e)),oe(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,null,0))}function oi(n){const e=n.checkFramebufferStatus(n.FRAMEBUFFER);if(e!==n.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+fT(n,e))}function fT(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 Sr(n,e,t){const r=oe(n,()=>e());if(r==null)throw new Error(t);return r}function mT(n,e){const t=n.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+n.TEXTURE0;if(r<n.TEXTURE0||r>t){const s=`[gl.TEXTURE0, gl.TEXTURE${t}]`;throw new Error(`textureUnit must be in ${s}.`)}}function _a(n,e=2){return H(n.slice(0,n.length-e))}function Na(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 ii(n){let e=[1,1,1];return n.length===0||n.length===1&&n[0]===1||(e=[_a(n),...Na(n)]),e}function gT(n,e=!1){let t=U().getNumber("WEBGL_MAX_TEXTURE_SIZE"),r=U().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");r===1/0&&U().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(r=t/2),e&&(t=t*2,r=r*2,n=n.map((i,c)=>c>=n.length-2?$l(n[c]):n[c]),n.length===1&&(n=[2,n[0]])),n.length!==2&&(n=jr(n).newShape);let s=H(n),a=null;n.length<=1&&s<=t?a=[1,s]:n.length===2&&n[0]<=t&&n[1]<=t?a=n:n.length===3&&n[0]*n[1]<=t&&n[2]<=t?a=[n[0]*n[1],n[2]]:n.length===3&&n[0]<=t&&n[1]*n[2]<=t?a=[n[0],n[1]*n[2]]:n.length===4&&n[0]*n[1]*n[2]<=t&&n[3]<=t?a=[n[0]*n[1]*n[2],n[3]]:n.length===4&&n[0]<=t&&n[1]*n[2]*n[3]<=t&&(a=[n[0],n[1]*n[2]*n[3]]);const o=a!=null&&Math.max(...a)>r&&Math.min(...a)<=(e?2:1)&&Math.min(...a)>0;if(a==null||o)if(e){const i=_a(n);let c=2,l=2;n.length&&([c,l]=Na(n)),s=i*(c/2)*(l/2),a=kc(s).map(u=>u*2)}else a=kc(s);return a}function ui(n){return n%2===0}function Ni(n,e){if(n=n.slice(-2),e=e.slice(-2),st(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[n.length-1],r=e[e.length-1];if(t===r||ui(t)&&ui(r)&&(n[0]===1||e[0]===1))return!0}return n[1]===e[1]&&ui(n[0])&&ui(e[0])}let yc,bc;function yT(n){if(yc==null){const e=qn(n);yc=e.getParameter(e.MAX_TEXTURE_SIZE)}return yc}function bT(n){if(bc==null){const e=qn(n);bc=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,bc)}function xT(n){if(n===0)return 0;let e;const t=qn(n);return _n(t,"EXT_disjoint_timer_query_webgl2")&&n===2?e=2:_n(t,"EXT_disjoint_timer_query")?e=1:e=0,e}function _n(n,e){return n.getExtension(e)!=null}function Xh(n){try{if(qn(n)!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function wT(n){if(n===0)return!1;const e=qn(n);if(n===1){if(!_n(e,"OES_texture_float"))return!1}else if(!_n(e,"EXT_color_buffer_float"))return!1;return el(e)}function vT(n){if(n===0)return!1;const e=qn(n);if(n===1){if(!_n(e,"OES_texture_float")||!_n(e,"WEBGL_color_buffer_float"))return!1}else{if(_n(e,"EXT_color_buffer_float"))return el(e);const r="EXT_color_buffer_half_float";if(_n(e,r)){const s=e.getExtension(r);return IT(e,s)}return!1}return el(e)}function el(n){const e=Yp(n),t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t);const r=1,s=1;n.texImage2D(n.TEXTURE_2D,0,e.internalFormatFloat,r,s,0,e.textureFormatFloat,e.textureTypeFloat,null);const a=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,a),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0);const o=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(t),n.deleteFramebuffer(a),o}function IT(n,e){const t=Yp(n,e),r=n.createTexture();n.bindTexture(n.TEXTURE_2D,r);const s=1,a=1;n.texImage2D(n.TEXTURE_2D,0,t.internalFormatHalfFloat,s,a,0,t.textureFormatFloat,t.textureTypeHalfFloat,null);const o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,r,0);const i=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(r),n.deleteFramebuffer(o),i}function $T(n){return n!==2?!1:qn(n).fenceSync!=null}function Po(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>{t!=null&&N(t.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the WebGL backend.`)})}/** 4751 * @license 4752 * Copyright 2019 Google LLC. All Rights Reserved. 4753 * Licensed under the Apache License, Version 2.0 (the "License"); 4754 * you may not use this file except in compliance with the License. 4755 * You may obtain a copy of the License at 4756 * 4757 * http://www.apache.org/licenses/LICENSE-2.0 4758 * 4759 * Unless required by applicable law or agreed to in writing, software 4760 * distributed under the License is distributed on an "AS IS" BASIS, 4761 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4762 * See the License for the specific language governing permissions and 4763 * limitations under the License. 4764 * ============================================================================= 4765 */const le=U();le.registerFlag("HAS_WEBGL",()=>le.getNumber("WEBGL_VERSION")>0);le.registerFlag("WEBGL_VERSION",()=>Xh(2)?2:Xh(1)?1:0);le.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);le.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>le.get("WEBGL_VERSION")===2);le.registerFlag("WEBGL_CPU_FORWARD",()=>!0);le.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);le.registerFlag("WEBGL_PACK",()=>le.getBool("HAS_WEBGL"));le.registerFlag("WEBGL_PACK_NORMALIZATION",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_CLIP",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_REDUCE",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_LAZILY_UNPACK",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_CONV_IM2COL",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>le.getBool("WEBGL_PACK"));le.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>yT(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>bT(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const n=le.getNumber("WEBGL_VERSION");return n===0?0:xT(n)});le.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>le.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Dm());le.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>wT(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>le.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:le.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));le.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>vT(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_FENCE_API_ENABLED",()=>$T(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>le.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);le.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${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}.`)});le.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>Dm()?1:-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${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}.`)});le.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);le.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1);le.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5);le.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128);le.registerFlag("WEBGL_EXP_CONV",()=>!1);le.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>le.getBool("IS_TEST"));le.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0);le.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1);le.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1);le.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);/** 4766 * @license 4767 * Copyright 2018 Google LLC. All Rights Reserved. 4768 * Licensed under the Apache License, Version 2.0 (the "License"); 4769 * you may not use this file except in compliance with the License. 4770 * You may obtain a copy of the License at 4771 * 4772 * http://www.apache.org/licenses/LICENSE-2.0 4773 * 4774 * Unless required by applicable law or agreed to in writing, software 4775 * distributed under the License is distributed on an "AS IS" BASIS, 4776 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4777 * See the License for the specific language governing permissions and 4778 * limitations under the License. 4779 * ============================================================================= 4780 */function Wt(){let n,e,t,r,s,a,o,i,c,l;return U().getNumber("WEBGL_VERSION")===2?(n="#version 300 es",e="in",t="out",r="in",s="texture",a="outputColor",o="out vec4 outputColor;",i=U().getBool("WEBGL2_ISNAN_CUSTOM")?` 4781 bool isnan_custom(float val) { 4782 uint floatToUint = floatBitsToUint(val); 4783 return (floatToUint & 0x7fffffffu) > 0x7f800000u; 4784 } 4785 4786 bvec4 isnan_custom(vec4 val) { 4787 return bvec4(isnan_custom(val.x), 4788 isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w)); 4789 } 4790 4791 #define isnan(value) isnan_custom(value) 4792 `:"",c="",l=` 4793 #define round(value) newRound(value) 4794 int newRound(float value) { 4795 return int(floor(value + 0.5)); 4796 } 4797 4798 ivec4 newRound(vec4 value) { 4799 return ivec4(floor(value + vec4(0.5))); 4800 } 4801 `):(n="",e="attribute",t="varying",r="varying",s="texture2D",a="gl_FragColor",o="",i=` 4802 #define isnan(value) isnan_custom(value) 4803 bool isnan_custom(float val) { 4804 return (val > 0. || val < 1. || val == 0.) ? false : true; 4805 } 4806 bvec4 isnan_custom(vec4 val) { 4807 return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w)); 4808 } 4809 `,c=` 4810 uniform float INFINITY; 4811 4812 bool isinf(float val) { 4813 return abs(val) == INFINITY; 4814 } 4815 bvec4 isinf(vec4 val) { 4816 return equal(abs(val), vec4(INFINITY)); 4817 } 4818 `,l=` 4819 int round(float value) { 4820 return int(floor(value + 0.5)); 4821 } 4822 4823 ivec4 round(vec4 value) { 4824 return ivec4(floor(value + vec4(0.5))); 4825 } 4826 `),{version:n,attribute:e,varyingVs:t,varyingFs:r,texture2D:s,output:a,defineOutput:o,defineSpecialNaN:i,defineSpecialInf:c,defineRound:l}}/** 4827 * @license 4828 * Copyright 2018 Google LLC. All Rights Reserved. 4829 * Licensed under the Apache License, Version 2.0 (the "License"); 4830 * you may not use this file except in compliance with the License. 4831 * You may obtain a copy of the License at 4832 * 4833 * http://www.apache.org/licenses/LICENSE-2.0 4834 * 4835 * Unless required by applicable law or agreed to in writing, software 4836 * distributed under the License is distributed on an "AS IS" BASIS, 4837 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4838 * See the License for the specific language governing permissions and 4839 * limitations under the License. 4840 * ============================================================================= 4841 */function Ws(n,e,t="index"){const r=Be(e);return r.map((s,a)=>{const o=`int ${n[a]} = ${t} / ${s}`,i=a===r.length-1?`int ${n[a+1]} = ${t} - ${n[a]} * ${s}`:`index -= ${n[a]} * ${s}`;return`${o}; ${i};`}).join("")}function Ju(n,e,t="index"){const r=Be(e);return r.map((s,a)=>{const o=`int ${n[a]} = ${t} / outShapeStrides[${a}]`,i=a===r.length-1?`int ${n[a+1]} = ${t} - ${n[a]} * outShapeStrides[${a}]`:`index -= ${n[a]} * outShapeStrides[${a}]`;return`${o}; ${i};`}).join("")}function ST(n,e){const t=n.length,r=n.map(a=>`${e}[${a}]`),s=new Array(t-1);s[t-2]=r[t-1];for(let a=t-3;a>=0;--a)s[a]=`(${s[a+1]} * ${r[a+1]})`;return s}function CT(n,e,t="index"){const r=n.map((a,o)=>o),s=ST(r,e);return s.map((a,o)=>{const i=`int ${n[o]} = ${t} / ${s[o]}`,c=o===s.length-1?`int ${n[o+1]} = ${t} - ${n[o]} * ${s[o]}`:`index -= ${n[o]} * ${s[o]}`;return`${i}; ${c};`}).join("")}function Qp(n){const e=Be(n).map(t=>t.toString());return` 4842 int getFlatIndex(ivec3 coords) { 4843 return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z; 4844 } 4845`}function Zp(){return` 4846 int getFlatIndex(ivec3 coords) { 4847 return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z; 4848 } 4849`}const Ty=` 4850 const float FLOAT_MAX = 1.70141184e38; 4851 const float FLOAT_MIN = 1.17549435e-38; 4852 4853 lowp vec4 encode_float(highp float v) { 4854 if (isnan(v)) { 4855 return vec4(255, 255, 255, 255); 4856 } 4857 4858 highp float av = abs(v); 4859 4860 if(av < FLOAT_MIN) { 4861 return vec4(0.0, 0.0, 0.0, 0.0); 4862 } else if(v > FLOAT_MAX) { 4863 return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; 4864 } else if(v < -FLOAT_MAX) { 4865 return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; 4866 } 4867 4868 highp vec4 c = vec4(0,0,0,0); 4869 4870 highp float e = floor(log2(av)); 4871 highp float m = exp2(fract(log2(av))) - 1.0; 4872 4873 c[2] = floor(128.0 * m); 4874 m -= c[2] / 128.0; 4875 c[1] = floor(32768.0 * m); 4876 m -= c[1] / 32768.0; 4877 c[0] = floor(8388608.0 * m); 4878 4879 highp float ebias = e + 127.0; 4880 c[3] = floor(ebias / 2.0); 4881 ebias -= c[3] * 2.0; 4882 c[2] += floor(ebias) * 128.0; 4883 4884 c[3] += 128.0 * step(0.0, -v); 4885 4886 return c / 255.0; 4887 } 4888`;/** 4889 * @license 4890 * Copyright 2017 Google LLC. All Rights Reserved. 4891 * Licensed under the Apache License, Version 2.0 (the "License");
4892 * you may not use this file except in compliance with the License. 4893 * You may obtain a copy of the License at 4894 * 4895 * http://www.apache.org/licenses/LICENSE-2.0 4896 * 4897 * Unless required by applicable law or agreed to in writing, software 4898 * distributed under the License is distributed on an "AS IS" BASIS, 4899 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4900 * See the License for the specific language governing permissions and 4901 * limitations under the License. 4902 * ============================================================================= 4903 */const{getBroadcastDims:ky}=zN;function _T(n,e,t){const r=[];if(n.forEach(h=>{const m=H(h.shapeInfo.logicalShape);if(h.shapeInfo.isUniform?r.push(`uniform float ${h.name}${m>1?`[${m}]`:""};`):(r.push(`uniform sampler2D ${h.name};`),r.push(`uniform int offset${h.name};`)),t.enableShapeUniforms){const{uniformShape:g}=Jp(t.packedInputs,h.shapeInfo.logicalShape,h.shapeInfo.texShape);switch(g.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 4903-5038
4903t.customUniforms&&t.customUniforms.forEach(h=>{r.push(`uniform ${h.type} ${h.name}${h.arrayIndex?`[${h.arrayIndex}]`:""};`)});const s=r.join(` 4904`),a=n.map(h=>NT(h,e,t.packedInputs,t.enableShapeUniforms)).join(` 4905`),o=e.texShape,i=Wt(),c=ET(i);let l,u,d=DT(i);return e.isPacked?(l=TT(e.logicalShape,o,t.enableShapeUniforms),u=AT(i)):(l=kT(e.logicalShape,o,t.enableShapeUniforms),u=RT(i)),t.packedInputs&&(d+=LT),[d,c,u,s,l,a,t.userCode].join(` 4906`)}function Da(n,e=!1){const t=n.shapeInfo.logicalShape;switch(t.length){case 0:return XT(n,e);case 1:return QT(n,e);case 2:return JT(n,e);case 3:return tk(n,e);case 4:return rk(n,e);case 5:return sk(n);case 6:return ak(n);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function Ey(n,e){switch(n.shapeInfo.logicalShape.length){case 0:return KT(n);case 1:return YT(n,e);case 2:return ZT(n,e);case 3:return ek(n,e);default:return nk(n,e)}}function NT(n,e,t=!1,r){let s="";t?s+=Ey(n,r):s+=Da(n,r);const a=n.shapeInfo.logicalShape,o=e.logicalShape;return a.length<=o.length&&(t?s+=ok(n,e):s+=ik(n,e)),s}function TT(n,e,t){switch(n.length){case 0:return Ry();case 1:return MT(n,e,t);case 2:return jT(n,e,t);case 3:return VT(n,e,t);default:return UT(n,e,t)}}function kT(n,e,t){switch(n.length){case 0:return Ry();case 1:return BT(n,e,t);case 2:return qT(n,e,t);case 3:return WT(n,e,t);case 4:return zT(n,e,t);case 5:return GT(n,e);case 6:return HT(n,e);default:throw new Error(`${n.length}-D output sampling is not yet supported`)}}function ET(n){return` 4907 float sampleTexture(sampler2D textureSampler, vec2 uv) { 4908 return ${n.texture2D}(textureSampler, uv).r; 4909 } 4910 `}function RT(n){return` 4911 void setOutput(float val) { 4912 ${n.output} = vec4(val, 0, 0, 0); 4913 } 4914 `}function AT(n){return` 4915 void setOutput(vec4 val) { 4916 ${n.output} = val; 4917 } 4918 `}function DT(n){return`${n.version} 4919 precision highp float; 4920 precision highp int; 4921 precision highp sampler2D; 4922 ${n.varyingFs} vec2 resultUV; 4923 ${n.defineOutput} 4924 const vec2 halfCR = vec2(0.5, 0.5); 4925 4926 struct ivec5 4927 { 4928 int x; 4929 int y; 4930 int z; 4931 int w; 4932 int u; 4933 }; 4934 4935 struct ivec6 4936 { 4937 int x; 4938 int y; 4939 int z; 4940 int w; 4941 int u; 4942 int v; 4943 }; 4944 4945 uniform float NAN; 4946 ${n.defineSpecialNaN} 4947 ${n.defineSpecialInf} 4948 ${n.defineRound} 4949 4950 int imod(int x, int y) { 4951 return x - y * (x / y); 4952 } 4953 4954 int idiv(int a, int b, float sign) { 4955 int res = a / b; 4956 int mod = imod(a, b); 4957 if (sign < 0. && mod != 0) { 4958 res -= 1; 4959 } 4960 return res; 4961 } 4962 4963 //Based on the work of Dave Hoskins 4964 //https://www.shadertoy.com/view/4djSRW 4965 #define HASHSCALE1 443.8975 4966 float random(float seed){ 4967 vec2 p = resultUV * seed; 4968 vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1); 4969 p3 += dot(p3, p3.yzx + 19.19); 4970 return fract((p3.x + p3.y) * p3.z); 4971 } 4972 4973 ${OT} 4974 ${FT} 4975 ${PT} 4976 `}const OT=` 4977vec2 uvFromFlat(int texNumR, int texNumC, int index) { 4978 int texR = index / texNumC; 4979 int texC = index - texR * texNumC; 4980 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 4981} 4982vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { 4983 int texelIndex = index / 2; 4984 int texR = texelIndex / texNumC; 4985 int texC = texelIndex - texR * texNumC; 4986 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 4987} 4988`,FT=` 4989vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, 4990 int texNumC, int row, int col) { 4991 int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); 4992 int texR = texelIndex / texNumC; 4993 int texC = texelIndex - texR * texNumC; 4994 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 4995} 4996`,PT=` 4997vec2 packedUVfrom3D(int texNumR, int texNumC, 4998 int texelsInBatch, int texelsInLogicalRow, int b, 4999 int row, int col) { 5000 int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); 5001 int texR = index / texNumC; 5002 int texC = index - texR * texNumC; 5003 return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); 5004} 5005`,LT=` 5006 float getChannel(vec4 frag, vec2 innerDims) { 5007 vec2 modCoord = mod(innerDims, 2.); 5008 return modCoord.x == 0. ? 5009 (modCoord.y == 0. ? frag.r : frag.g) : 5010 (modCoord.y == 0. ? frag.b : frag.a); 5011 } 5012 float getChannel(vec4 frag, int dim) { 5013 float modCoord = mod(float(dim), 2.); 5014 return modCoord == 0. ? frag.r : frag.g; 5015 } 5016`;function Ry(){return` 5017 int getOutputCoords() { 5018 return 0; 5019 } 5020 `}function MT(n,e,t){const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return r[0]===1?t?` 5021 int getOutputCoords() { 5022 return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0)); 5023 } 5024 `:` 5025 int getOutputCoords() { 5026 return 2 * int(resultUV.x * ${r[1]}.0); 5027 } 5028 `:r[1]===1?t?` 5029 int getOutputCoords() { 5030 return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0)); 5031 } 5032 `:` 5033 int getOutputCoords() { 5034 return 2 * int(resultUV.y * ${r[0]}.0); 5035 } 5036 `:t?` 5037 int getOutputCoords() { 5038 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
5039 ivec2 resTexRC = ivec2(resultUV.yx * 5040 vec2(packedTexShape[0], packedTexShape[1])); 5041 return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y); 5042 } 5043 `:` 5044 int getOutputCoords() { 5045 ivec2 resTexRC = ivec2(resultUV.yx * 5046 vec2(${r[0]}, ${r[1]})); 5047 return 2 * (resTexRC.x * ${r[1]} + resTexRC.y); 5048 } 5049 `}function BT(n,e,t){return e[0]===1?t?` 5050 int getOutputCoords() { 5051 return int(resultUV.x * float(outTexShape[1])); 5052 } 5053 `:` 5054 int getOutputCoords() { 5055 return int(resultUV.x * ${e[1]}.0); 5056 } 5057 `:e[1]===1?t?` 5058 int getOutputCoords() { 5059 return int(resultUV.y * float(outTexShape[0])); 5060 } 5061 `:` 5062 int getOutputCoords() { 5063 return int(resultUV.y * ${e[0]}.0); 5064 } 5065 `:t?` 5066 int getOutputCoords() { 5067 ivec2 resTexRC = ivec2(resultUV.yx * 5068 vec2(outTexShape[0], outTexShape[1])); 5069 return resTexRC.x * outTexShape[1] + resTexRC.y; 5070 } 5071 `:` 5072 int getOutputCoords() { 5073 ivec2 resTexRC = ivec2(resultUV.yx * 5074 vec2(${e[0]}, ${e[1]})); 5075 return resTexRC.x * ${e[1]} + resTexRC.y; 5076 } 5077 `}function VT(n,e,t){if(t)return` 5078 ivec3 getOutputCoords() { 5079 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 5080 int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0)); 5081 int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0)); 5082 ivec2 resTexRC = ivec2(resultUV.yx * 5083 vec2(packedTexShape[0], packedTexShape[1])); 5084 int index = resTexRC.x * packedTexShape[1] + resTexRC.y; 5085 5086 int b = index / texelsInBatch; 5087 index -= b * texelsInBatch; 5088 5089 int r = 2 * (index / texelsInLogicalRow); 5090 int c = imod(index, texelsInLogicalRow) * 2; 5091 5092 return ivec3(b, r, c); 5093 } 5094 `;const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(n[2]/2),a=s*Math.ceil(n[1]/2);return` 5095 ivec3 getOutputCoords() { 5096 ivec2 resTexRC = ivec2(resultUV.yx * 5097 vec2(${r[0]}, ${r[1]})); 5098 int index = resTexRC.x * ${r[1]} + resTexRC.y; 5099 5100 int b = index / ${a}; 5101 index -= b * ${a}; 5102 5103 int r = 2 * (index / ${s}); 5104 int c = imod(index, ${s}) * 2; 5105 5106 return ivec3(b, r, c); 5107 } 5108 `}function WT(n,e,t){if(t)return` 5109 ivec3 getOutputCoords() { 5110 ivec2 resTexRC = ivec2(resultUV.yx * 5111 vec2(outTexShape[0], outTexShape[1])); 5112 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 5113 ${Ju(["r","c","d"],n)} 5114 return ivec3(r, c, d); 5115 } 5116`;const r=Ws(["r","c","d"],n);return` 5117 ivec3 getOutputCoords() { 5118 ivec2 resTexRC = ivec2(resultUV.yx * 5119 vec2(${e[0]}, ${e[1]})); 5120 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5121 ${r} 5122 return ivec3(r, c, d); 5123 } 5124 `}function UT(n,e,t){if(t)return` 5125 ivec4 getOutputCoords() { 5126 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 5127 ivec2 resTexRC = ivec2(resultUV.yx * 5128 vec2(packedTexShape[0], packedTexShape[1])); 5129 int index = resTexRC.x * packedTexShape[1] + resTexRC.y; 5130 5131 int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0)); 5132 int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0)); 5133 int texelsInBatchN = texelsInBatch * outShape[1]; 5134 5135 int b2 = index / texelsInBatchN; 5136 index -= b2 * texelsInBatchN; 5137 5138 int b = index / texelsInBatch; 5139 index -= b * texelsInBatch; 5140 5141 int r = 2 * (index / texelsInLogicalRow); 5142 int c = imod(index, texelsInLogicalRow) * 2; 5143 5144 return ivec4(b2, b, r, c); 5145 } 5146 `;const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(n[n.length-1]/2),a=s*Math.ceil(n[n.length-2]/2);let o=a,i="",c="b, r, c";for(let l=2;l<n.length-1;l++)o*=n[n.length-l-1],i=` 5147 int b${l} = index / ${o}; 5148 index -= b${l} * ${o}; 5149 `+i,c=`b${l}, `+c;return` 5150 ivec${n.length} getOutputCoords() {
5151 ivec2 resTexRC = ivec2(resultUV.yx * 5152 vec2(${r[0]}, ${r[1]})); 5153 int index = resTexRC.x * ${r[1]} + resTexRC.y; 5154 5155 ${i} 5156 5157 int b = index / ${a}; 5158 index -= b * ${a}; 5159 5160 int r = 2 * (index / ${s}); 5161 int c = imod(index, ${s}) * 2; 5162 5163 return ivec${n.length}(${c}); 5164 } 5165 `}function zT(n,e,t){if(t)return` 5166 ivec4 getOutputCoords() { 5167 ivec2 resTexRC = ivec2(resultUV.yx * 5168 vec2(outTexShape[0], outTexShape[1])); 5169 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 5170 ${Ju(["r","c","d","d2"],n)} 5171 return ivec4(r, c, d, d2); 5172 } 5173 `;const r=Ws(["r","c","d","d2"],n);return` 5174 ivec4 getOutputCoords() { 5175 ivec2 resTexRC = ivec2(resultUV.yx * 5176 vec2(${e[0]}, ${e[1]})); 5177 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5178 ${r} 5179 return ivec4(r, c, d, d2); 5180 } 5181 `}function GT(n,e){const t=Ws(["r","c","d","d2","d3"],n);return` 5182 ivec5 getOutputCoords() { 5183 ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, 5184 ${e[1]})); 5185 5186 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5187 5188 ${t} 5189 5190 ivec5 outShape = ivec5(r, c, d, d2, d3); 5191 return outShape; 5192 } 5193 `}function HT(n,e){const t=Ws(["r","c","d","d2","d3","d4"],n);return` 5194 ivec6 getOutputCoords() { 5195 ivec2 resTexRC = ivec2(resultUV.yx * 5196 vec2(${e[0]}, ${e[1]})); 5197 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5198 5199 ${t} 5200 5201 ivec6 result = ivec6(r, c, d, d2, d3, d4); 5202 return result; 5203 } 5204 `}function jT(n,e,t){const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(st(n,e))return t?` 5205 ivec2 getOutputCoords() { 5206 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 5207 return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1])); 5208 } 5209 `:` 5210 ivec2 getOutputCoords() { 5211 return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]})); 5212 } 5213 `;const s=Math.ceil(n[1]/2);return t?` 5214 ivec2 getOutputCoords() { 5215 ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); 5216 int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0)); 5217 ivec2 resTexRC = ivec2(resultUV.yx * 5218 vec2(packedTexShape[0], packedTexShape[1])); 5219 5220 int index = resTexRC.x * packedTexShape[1] + resTexRC.y; 5221 int r = 2 * (index / texelsInLogicalRow); 5222 int c = imod(index, texelsInLogicalRow) * 2; 5223 5224 return ivec2(r, c); 5225 } 5226 `:` 5227 ivec2 getOutputCoords() { 5228 ivec2 resTexRC = ivec2(resultUV.yx * 5229 vec2(${r[0]}, ${r[1]})); 5230 5231 int index = resTexRC.x * ${r[1]} + resTexRC.y; 5232 int r = 2 * (index / ${s}); 5233 int c = imod(index, ${s}) * 2; 5234 5235 return ivec2(r, c); 5236 } 5237 `}function qT(n,e,t){return st(n,e)?t?` 5238 ivec2 getOutputCoords() { 5239 return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); 5240 } 5241 `:` 5242 ivec2 getOutputCoords() { 5243 return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); 5244 } 5245 `:n[1]===1?t?` 5246 ivec2 getOutputCoords() { 5247 ivec2 resTexRC = ivec2(resultUV.yx * 5248 vec2(outTexShape[0], outTexShape[1])); 5249 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 5250 return ivec2(index, 0); 5251 } 5252 `:` 5253 ivec2 getOutputCoords() { 5254 ivec2 resTexRC = ivec2(resultUV.yx * 5255 vec2(${e[0]}, ${e[1]})); 5256 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5257 return ivec2(index, 0); 5258 } 5259 `:n[0]===1?t?` 5260 ivec2 getOutputCoords() { 5261 ivec2 resTexRC = ivec2(resultUV.yx * 5262 vec2(outTexShape[0], outTexShape[1])); 5263 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 5264 return ivec2(0, index); 5265 } 5266 `:` 5267 ivec2 getOutputCoords() { 5268 ivec2 resTexRC = ivec2(resultUV.yx * 5269 vec2(${e[0]}, ${e[1]})); 5270 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5271 return ivec2(0, index); 5272 } 5273 `:t?` 5274 ivec2 getOutputCoords() {
5275 ivec2 resTexRC = ivec2(resultUV.yx * 5276 vec2(outTexShape[0], outTexShape[1])); 5277 int index = resTexRC.x * outTexShape[1] + resTexRC.y; 5278 int r = index / outShape[1]; 5279 int c = index - r * outShape[1]; 5280 return ivec2(r, c); 5281 } 5282 `:` 5283 ivec2 getOutputCoords() { 5284 ivec2 resTexRC = ivec2(resultUV.yx * 5285 vec2(${e[0]}, ${e[1]})); 5286 int index = resTexRC.x * ${e[1]} + resTexRC.y; 5287 int r = index / ${n[1]}; 5288 int c = index - r * ${n[1]}; 5289 return ivec2(r, c); 5290 } 5291 `}function Us(n){return`offset${n}`}function KT(n){const e=n.name,t="get"+e.charAt(0).toUpperCase()+e.slice(1),r=Wt();return` 5292 vec4 ${t}() { 5293 return ${r.texture2D}(${e}, halfCR); 5294 } 5295 `}function XT(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[s,a]=n.shapeInfo.texShape;if(s===1&&a===1)return` 5296 float ${r}() { 5297 return sampleTexture(${t}, halfCR); 5298 } 5299 `;const o=Us(t);if(e)return` 5300 float ${r}() { 5301 vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], ${o}); 5302 return sampleTexture(${t}, uv); 5303 } 5304 `;const[i,c]=n.shapeInfo.texShape;return` 5305 float ${r}() { 5306 vec2 uv = uvFromFlat(${i}, ${c}, ${o}); 5307 return sampleTexture(${t}, uv); 5308 } 5309 `}function YT(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),s=n.shapeInfo.texShape,a=Wt();if(e)return` 5310 vec4 ${r}(int index) { 5311 ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0)); 5312 vec2 uv = packedUVfrom1D( 5313 packedTexShape[0], packedTexShape[1], index); 5314 return ${a.texture2D}(${t}, uv); 5315 } 5316 `;const o=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];return` 5317 vec4 ${r}(int index) { 5318 vec2 uv = packedUVfrom1D( 5319 ${o[0]}, ${o[1]}, index); 5320 return ${a.texture2D}(${t}, uv); 5321 } 5322 `}function QT(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return` 5323 float ${r}(int index) { 5324 ${Oa(n)} 5325 } 5326 `;const s=n.shapeInfo.texShape,a=s[0],o=s[1];if(o===1&&a===1)return` 5327 float ${r}(int index) { 5328 return sampleTexture(${t}, halfCR); 5329 } 5330 `;const i=Us(t);return o===1?e?` 5331 float ${r}(int index) { 5332 vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${t}TexShape[0])); 5333 return sampleTexture(${t}, uv); 5334 } 5335 `:` 5336 float ${r}(int index) { 5337 vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${a}.0); 5338 return sampleTexture(${t}, uv); 5339 } 5340 `:a===1?e?` 5341 float ${r}(int index) { 5342 vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${t}TexShape[1]), 0.5); 5343 return sampleTexture(${t}, uv); 5344 } 5345 `:` 5346 float ${r}(int index) { 5347 vec2 uv = vec2((float(index + ${i}) + 0.5) / ${o}.0, 0.5); 5348 return sampleTexture(${t}, uv); 5349 } 5350 `:e?` 5351 float ${r}(int index) { 5352 vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], index + ${i}); 5353 return sampleTexture(${t}, uv); 5354 } 5355 `:` 5356 float ${r}(int index) { 5357 vec2 uv = uvFromFlat(${a}, ${o}, index + ${i}); 5358 return sampleTexture(${t}, uv); 5359 } 5360 `}function ZT(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),a=n.shapeInfo.texShape,o=a[0],i=a[1],c=Wt();if(a!=null&&st(t,a))return e?` 5361 vec4 ${s}(int row, int col) { 5362 vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]); 5363 5364 return ${c.texture2D}(${r}, uv); 5365 } 5366 `:` 5367 vec4 ${s}(int row, int col) { 5368 vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}.0, ${o}.0); 5369 5370 return ${c.texture2D}(${r}, uv); 5371 } 5372 `;if(e)return` 5373 vec4 ${s}(int row, int col) { 5374 ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0)); 5375 int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0)); 5376 vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col); 5377 return ${c.texture2D}(${r}, uv); 5378 } 5379 `;const l=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],u=Math.ceil(t[1]/2);return` 5380 vec4 ${s}(int row, int col) { 5381 vec2 uv = packedUVfrom2D(${u}, ${l[0]}, ${l[1]}
5381, row, col); 5382 return ${c.texture2D}(${r}, uv); 5383 } 5384 `}function JT(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),a=n.shapeInfo.texShape;if(a!=null&&st(t,a)){if(e)return` 5385 float ${s}(int row, int col) { 5386 vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]); 5387 return sampleTexture(${r}, uv); 5388 } 5389 `;const p=a[0],h=a[1];return` 5390 float ${s}(int row, int col) { 5391 vec2 uv = (vec2(col, row) + halfCR) / vec2(${h}.0, ${p}.0); 5392 return sampleTexture(${r}, uv); 5393 } 5394 `}const{newShape:o,keptDims:i}=jr(t),c=o;if(c.length<t.length){const p=Fa(n,c),h=["row","col"];return` 5395 ${Da(p,e)} 5396 float ${s}(int row, int col) { 5397 return ${s}(${Pa(h,i)}); 5398 } 5399 `}if(n.shapeInfo.isUniform)return` 5400 float ${s}(int row, int col) { 5401 int index = round(dot(vec2(row, col), vec2(${t[1]}, 1))); 5402 ${Oa(n)} 5403 } 5404 `;const l=a[0],u=a[1],d=Us(r);return u===1?e?` 5405 float ${s}(int row, int col) { 5406 float index = dot(vec3(row, col, ${d}), vec3(${r}Shape[1], 1, 1)); 5407 vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0])); 5408 return sampleTexture(${r}, uv); 5409 } 5410 `:` 5411 float ${s}(int row, int col) { 5412 float index = dot(vec3(row, col, ${d}), vec3(${t[1]}, 1, 1)); 5413 vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0); 5414 return sampleTexture(${r}, uv); 5415 } 5416 `:l===1?e?` 5417 float ${s}(int row, int col) { 5418 float index = dot(vec3(row, col, ${d}), vec3(${r}Shape[1], 1, 1)); 5419 vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5); 5420 return sampleTexture(${r}, uv); 5421 } 5422 `:` 5423 float ${s}(int row, int col) { 5424 float index = dot(vec3(row, col, ${d}), vec3(${t[1]}, 1, 1)); 5425 vec2 uv = vec2((index + 0.5) / ${u}.0, 0.5); 5426 return sampleTexture(${r}, uv); 5427 } 5428 `:e?` 5429 float ${s}(int row, int col) { 5430 // Explicitly use integer operations as dot() only works on floats. 5431 int index = row * ${r}Shape[1] + col + ${d}; 5432 vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index); 5433 return sampleTexture(${r}, uv); 5434 } 5435 `:` 5436 float ${s}(int row, int col) { 5437 // Explicitly use integer operations as dot() only works on floats. 5438 int index = row * ${t[1]} + col + ${d}; 5439 vec2 uv = uvFromFlat(${l}, ${u}, index); 5440 return sampleTexture(${r}, uv); 5441 } 5442`}function ek(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),a=n.shapeInfo.texShape,o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];if(t[0]===1){const p=t.slice(1),h=[1,2],m=Fa(n,p),g=["b","row","col"];return` 5443 ${Ey(m,e)} 5444 vec4 ${s}(int b, int row, int col) { 5445 return ${s}(${Pa(g,h)}); 5446 } 5447 `}const i=Wt();if(e)return` 5448 vec4 ${s}(int b, int row, int col) { 5449 ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0)); 5450 int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0)); 5451 int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0)); 5452 vec2 uv = packedUVfrom3D( 5453 packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col); 5454 return ${i.texture2D}(${r}, uv); 5455 } 5456 `;const c=o[0],l=o[1],u=Math.ceil(t[2]/2),d=u*Math.ceil(t[1]/2);return` 5457 vec4 ${s}(int b, int row, int col) { 5458 vec2 uv = packedUVfrom3D( 5459 ${c}, ${l}, ${d}, ${u}, b, row, col); 5460 return ${i.texture2D}(${r}, uv); 5461 } 5462 `}function tk(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),a=t[1]*t[2],o=t[2],{newShape:i,keptDims:c}=jr(t),l=i;if(l.length<t.length){const g=Fa(n,l),y=["row","col","depth"];return` 5463 ${Da(g,e)} 5464 float ${s}(int row, int col, int depth) { 5465 return ${s}(${Pa(y,c)}); 5466 } 5467 `}if(n.shapeInfo.isUniform)return` 5468 float ${s}(int row, int col, int depth) { 5469 int index = round(dot(vec3(row, col, depth), 5470 vec3(${a}, ${o}, 1))); 5471 ${Oa(n)} 5472 } 5473 `;const u=n.shapeInfo.texShape,d=u[0],p=u[1],h=n.shapeInfo.flatOffset;if(p===a&&h==null)return e?` 5474 float ${s}(int row, int col, int depth) {
5475 int stride1 = ${r}Shape[2]; 5476 float texR = float(row); 5477 float texC = dot(vec2(col, depth), vec2(stride1, 1)); 5478 vec2 uv = (vec2(texC, texR) + halfCR) / 5479 vec2(${r}TexShape[1], ${r}TexShape[0]); 5480 return sampleTexture(${r}, uv); 5481 } 5482 `:` 5483 float ${s}(int row, int col, int depth) { 5484 float texR = float(row); 5485 float texC = dot(vec2(col, depth), vec2(${o}, 1)); 5486 vec2 uv = (vec2(texC, texR) + halfCR) / 5487 vec2(${p}.0, ${d}.0); 5488 return sampleTexture(${r}, uv); 5489 } 5490 `;if(p===o&&h==null)return e?` 5491 float ${s}(int row, int col, int depth) { 5492 float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1)); 5493 float texC = float(depth); 5494 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]); 5495 return sampleTexture(${r}, uv); 5496 } 5497 `:` 5498 float ${s}(int row, int col, int depth) { 5499 float texR = dot(vec2(row, col), vec2(${t[1]}, 1)); 5500 float texC = float(depth); 5501 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${p}.0, ${d}.0); 5502 return sampleTexture(${r}, uv); 5503 } 5504 `;const m=Us(r);return e?` 5505 float ${s}(int row, int col, int depth) { 5506 // Explicitly use integer operations as dot() only works on floats. 5507 int stride0 = ${r}Shape[1] * ${r}Shape[2]; 5508 int stride1 = ${r}Shape[2]; 5509 int index = row * stride0 + col * stride1 + depth + ${m}; 5510 vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index); 5511 return sampleTexture(${r}, uv); 5512 } 5513 `:` 5514 float ${s}(int row, int col, int depth) { 5515 // Explicitly use integer operations as dot() only works on floats. 5516 int index = row * ${a} + col * ${o} + depth + ${m}; 5517 vec2 uv = uvFromFlat(${d}, ${p}, index); 5518 return sampleTexture(${r}, uv); 5519 } 5520 `}function nk(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),s=Wt();if(e)return` 5521 vec4 ${r}(int b2, int b, int row, int col) { 5522 int valuesPerRow = int(ceil(float(${t}Shape[3]) / 2.0)); 5523 int texelsInBatch = valuesPerRow * int(ceil(float(${t}Shape[2]) / 2.0)); 5524 int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2); 5525 texelsInBatch *= ${t}Shape[1]; 5526 index = b2 * texelsInBatch + index; 5527 ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0)); 5528 int texR = index / packedTexShape[1]; 5529 int texC = index - texR * packedTexShape[1]; 5530 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${s.texture2D}(${t}, uv); 5531 } 5532 `;const a=n.shapeInfo.logicalShape,o=a.length,i=n.shapeInfo.texShape,c=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],l=c[0],u=c[1],d=Math.ceil(a[o-1]/2);let p=d*Math.ceil(a[o-2]/2),h="int b, int row, int col",m=`b * ${p} + (row / 2) * ${d} + (col / 2)`;for(let g=2;g<o-1;g++)h=`int b${g}, `+h,p*=a[o-g-1],m=`b${g} * ${p} + `+m;return` 5533 vec4 ${r}(${h}) { 5534 int index = ${m}; 5535 int texR = index / ${u}; 5536 int texC = index - texR * ${u}; 5537 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${u}, ${l}); 5538 return ${s.texture2D}(${t}, uv); 5539 } 5540 `}function rk(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),a=t[3],o=t[2]*a,i=t[1]*o,{newShape:c,keptDims:l}=jr(t);if(c.length<t.length){const v=Fa(n,c),$=["row","col","depth","depth2"];return` 5541 ${Da(v,e)} 5542 float ${s}(int row, int col, int depth, int depth2) { 5543 return ${s}(${Pa($,l)}); 5544 } 5545 `}if(n.shapeInfo.isUniform)return` 5546 float ${s}(int row, int col, int depth, int depth2) { 5547 int index = round(dot(vec4(row, col, depth, depth2), 5548 vec4(${i}, ${o}, ${a}, 1))); 5549 ${Oa(n)} 5550 } 5551 `;const u=n.shapeInfo.flatOffset,d=n.shapeInfo.texShape,p=d[0],h=d[1],m=`int stride2 = ${r}Shape[3];`,g=`int stride1 = ${r}Shape[2] * stride2;`,y=`int stride0 = ${r}Shape[1] * stride1;`;if(h===i&&u==null)return e?` 5552 float ${s}(int row, int col, int depth, int depth2) { 5553 ${m} 5554 ${g} 5555 float texR = float(row); 5556 float texC = 5557 dot(vec3(col, depth, depth2),
5558 vec3(stride1, stride2, 1)); 5559 vec2 uv = (vec2(texC, texR) + halfCR) / 5560 vec2(${r}TexShape[1], ${r}TexShape[0]); 5561 return sampleTexture(${r}, uv); 5562 } 5563 `:` 5564 float ${s}(int row, int col, int depth, int depth2) { 5565 float texR = float(row); 5566 float texC = 5567 dot(vec3(col, depth, depth2), 5568 vec3(${o}, ${a}, 1)); 5569 vec2 uv = (vec2(texC, texR) + halfCR) / 5570 vec2(${h}.0, ${p}.0); 5571 return sampleTexture(${r}, uv); 5572 } 5573 `;if(h===a&&u==null)return e?` 5574 float ${s}(int row, int col, int depth, int depth2) { 5575 float texR = dot(vec3(row, col, depth), 5576 vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1)); 5577 float texC = float(depth2); 5578 vec2 uv = (vec2(texC, texR) + halfCR) / 5579 vec2(${r}TexShape[1], ${r}TexShape[0]); 5580 return sampleTexture(${r}, uv); 5581 } 5582 `:` 5583 float ${s}(int row, int col, int depth, int depth2) { 5584 float texR = dot(vec3(row, col, depth), 5585 vec3(${t[1]*t[2]}, ${t[2]}, 1)); 5586 float texC = float(depth2); 5587 vec2 uv = (vec2(texC, texR) + halfCR) / 5588 vec2(${h}.0, ${p}.0); 5589 return sampleTexture(${r}, uv); 5590 } 5591 `;const b=Us(r);return e?` 5592 float ${s}(int row, int col, int depth, int depth2) { 5593 // Explicitly use integer operations as dot() only works on floats. 5594 ${m} 5595 ${g} 5596 ${y} 5597 int index = row * stride0 + col * stride1 + 5598 depth * stride2 + depth2; 5599 vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${b}); 5600 return sampleTexture(${r}, uv); 5601 } 5602 `:` 5603 float ${s}(int row, int col, int depth, int depth2) { 5604 // Explicitly use integer operations as dot() only works on floats. 5605 int index = row * ${i} + col * ${o} + 5606 depth * ${a} + depth2; 5607 vec2 uv = uvFromFlat(${p}, ${h}, index + ${b}); 5608 return sampleTexture(${r}, uv); 5609 } 5610 `}function sk(n){const e=n.shapeInfo.logicalShape,t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),s=e[4],a=e[3]*s,o=e[2]*a,i=e[1]*o,{newShape:c,keptDims:l}=jr(e);if(c.length<e.length){const g=Fa(n,c),y=["row","col","depth","depth2","depth3"];return` 5611 ${Da(g)} 5612 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5613 return ${r}(${Pa(y,l)}); 5614 } 5615 `}if(n.shapeInfo.isUniform)return` 5616 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5617 float index = dot( 5618 vec4(row, col, depth, depth2), 5619 vec4(${i}, ${o}, ${a}, ${s})) + 5620 depth3; 5621 ${Oa(n)} 5622 } 5623 `;const u=n.shapeInfo.flatOffset,d=n.shapeInfo.texShape,p=d[0],h=d[1];if(h===i&&u==null)return` 5624 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5625 int texR = row; 5626 float texC = dot(vec4(col, depth, depth2, depth3), 5627 vec4(${o}, ${a}, ${s}, 1)); 5628 vec2 uv = (vec2(texC, texR) + halfCR) / 5629 vec2(${h}.0, ${p}.0); 5630 return sampleTexture(${t}, uv); 5631 } 5632 `;if(h===s&&u==null)return` 5633 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5634 float texR = dot( 5635 vec4(row, col, depth, depth2), 5636 vec4(${e[1]*e[2]*e[3]}, 5637 ${e[2]*e[3]}, ${e[3]}, 1)); 5638 int texC = depth3; 5639 vec2 uv = (vec2(texC, texR) + halfCR) / 5640 vec2(${h}.0, ${p}.0); 5641 return sampleTexture(${t}, uv); 5642 } 5643 `;const m=Us(t);return` 5644 float ${r}(int row, int col, int depth, int depth2, int depth3) { 5645 // Explicitly use integer operations as dot() only works on floats. 5646 int index = row * ${i} + col * ${o} + depth * ${a} + 5647 depth2 * ${s} + depth3 + ${m}; 5648 vec2 uv = uvFromFlat(${p}, ${h}, index); 5649 return sampleTexture(${t}, uv); 5650 } 5651 `}function ak(n){const e=n.shapeInfo.logicalShape,t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),{newShape:s,keptDims:a}=jr(e);if(s.length<e.length){const y=Fa(n,s),b=["row","col","depth","depth2","depth3","depth4"];return` 5652 ${Da(y)} 5653 float ${r}(int row, int col, int depth, 5654 int depth2, int depth3, int depth4) { 5655 return ${r}(${Pa(b,a)}); 5656 } 5657 `}const o=e[5],i=e[4]*o,c=e[3]*i,l=e[2]*c,u=e[1]*l;if(n.shapeInfo.isUniform)return` 5658 float ${r}(int row, int col, int depth, 5659 int depth2, int depth3, int depth4) { 5660 int index = round(dot( 5661 vec4(row, col, depth, depth2), 5662 vec4(${u}, ${l}, ${c}, ${i})) + 5663 dot( 5664 vec2(depth3, depth4), 5665 vec2(${o}, 1))); 5666 ${Oa(n)} 5667 } 5668 `;const d=n.shapeInfo.flatOffset,p=n.shapeInfo.texShape,h=p[0],m=p[1];if(m===u&&d==null)return` 5669 float ${r}(int row, int col, int depth, 5670 int depth2, int depth3, int depth4) { 5671 int texR = row; 5672 float texC = dot(vec4(col, depth, depth2, depth3), 5673 vec4(${l}, ${c}, ${i}, ${o})) + 5674 float(depth4); 5675 vec2 uv = (vec2(texC, texR) + halfCR) / 5676 vec2(${m}.0, ${h}.0); 5677 return sampleTexture(${t}, uv); 5678 } 5679 `;if(m===o&&d==null)return` 5680 float ${r}(int row, int col, int depth, 5681 int depth2, int depth3, int depth4) {
5682 float texR = dot(vec4(row, col, depth, depth2), 5683 vec4(${e[1]*e[2]*e[3]*e[4]}, 5684 ${e[2]*e[3]*e[4]}, 5685 ${e[3]*e[4]}, 5686 ${e[4]})) + float(depth3); 5687 int texC = depth4; 5688 vec2 uv = (vec2(texC, texR) + halfCR) / 5689 vec2(${m}.0, ${h}.0); 5690 return sampleTexture(${t}, uv); 5691 } 5692 `;const g=Us(t);return` 5693 float ${r}(int row, int col, int depth, 5694 int depth2, int depth3, int depth4) { 5695 // Explicitly use integer operations as dot() only works on floats. 5696 int index = row * ${u} + col * ${l} + depth * ${c} + 5697 depth2 * ${i} + depth3 * ${o} + depth4 + ${g}; 5698 vec2 uv = uvFromFlat(${h}, ${m}, index); 5699 return sampleTexture(${t}, uv); 5700 } 5701 `}function Oa(n){const e=n.name,t=H(n.shapeInfo.logicalShape);return t<2?`return ${e};`:` 5702 for (int i = 0; i < ${t}; i++) { 5703 if (i == index) { 5704 return ${e}[i]; 5705 } 5706 } 5707 `}function ok(n,e){const t=n.name,r=t.charAt(0).toUpperCase()+t.slice(1),s="get"+r+"AtOutCoords",a=n.shapeInfo.logicalShape.length,o=e.logicalShape.length,i=ky(n.shapeInfo.logicalShape,e.logicalShape),c=ze(o),l=o-a;let u;const d=["x","y","z","w","u","v"];a===0?u="":o<2&&i.length>=1?u="coords = 0;":u=i.map(v=>`coords.${d[v+l]} = 0;`).join(` 5708`);let p="";o<2&&a>0?p="coords":p=n.shapeInfo.logicalShape.map((v,$)=>`coords.${d[$+l]}`).join(", ");let h="return outputValue;";const g=H(n.shapeInfo.logicalShape)===1,b=H(e.logicalShape)===1;if(a===1&&!g&&!b)h=` 5709 return vec4(outputValue.xy, outputValue.xy); 5710 `;else if(g&&!b)o===1?h=` 5711 return vec4(outputValue.x, outputValue.x, 0., 0.); 5712 `:h=` 5713 return vec4(outputValue.x); 5714 `;else if(i.length){const v=a-2,$=a-1;i.indexOf(v)>-1&&i.indexOf($)>-1?h="return vec4(outputValue.x);":i.indexOf(v)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":i.indexOf($)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}return` 5715 vec4 ${s}() { 5716 ${c} coords = getOutputCoords(); 5717 ${u} 5718 vec4 outputValue = get${r}(${p}); 5719 ${h} 5720 } 5721 `}function ik(n,e){const t=n.name,r=t.charAt(0).toUpperCase()+t.slice(1),s="get"+r+"AtOutCoords",a=e.texShape,o=n.shapeInfo.texShape,i=n.shapeInfo.logicalShape.length,c=e.logicalShape.length;if(!n.shapeInfo.isUniform&&i===c&&n.shapeInfo.flatOffset==null&&st(o,a))return` 5722 float ${s}() { 5723 return sampleTexture(${t}, resultUV); 5724 } 5725 `;const l=ze(c),u=ky(n.shapeInfo.logicalShape,e.logicalShape),d=c-i;let p;const h=["x","y","z","w","u","v"];i===0?p="":c<2&&u.length>=1?p="coords = 0;":p=u.map(g=>`coords.${h[g+d]} = 0;`).join(` 5726`);let m="";return c<2&&i>0?m="coords":m=n.shapeInfo.logicalShape.map((g,y)=>`coords.${h[y+d]}`).join(", "),` 5727 float ${s}() { 5728 ${l} coords = getOutputCoords(); 5729 ${p} 5730 return get${r}(${m}); 5731 } 5732 `}function ze(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 Jp(n,e,t){const{newShape:r,keptDims:s}=jr(e),a=e.length,o=n&&a===3&&e[0]===1,i=o?e.slice(1):r,c=!n&&a>1&&!st(e,t)&&r.length<a||o;return{useSqueezeShape:c,uniformShape:c?i:e,keptDims:s}}function Fa(n,e){const t=JSON.parse(JSON.stringify(n));return t.shapeInfo.logicalShape=e,t}function Pa(n,e){return e.map(t=>n[t]).join(", ")}/** 5733 * @license 5734 * Copyright 2017 Google LLC. All Rights Reserved. 5735 * Licensed under the Apache License, Version 2.0 (the "License"); 5736 * you may not use this file except in compliance with the License. 5737 * You may obtain a copy of the License at 5738 * 5739 * http://www.apache.org/licenses/LICENSE-2.0 5740 * 5741 * Unless required by applicable law or agreed to in writing, software 5742 * distributed under the License is distributed on an "AS IS" BASIS, 5743 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5744 * See the License for the specific language governing permissions and 5745 * limitations under the License. 5746 * ============================================================================= 5747 */function uk(n,e,t,r){const s=t.map((u,d)=>{const p={logicalShape:u.shape,texShape:u.isUniform?null:u.texData.texShape,isUniform:u.isUniform,isPacked:u.isUniform?!1:u.texData.isPacked,flatOffset:null};return u.texData!=null&&u.texData.slice!=null&&u.texData.slice.flatOffset>0&&(p.flatOffset=u.texData.slice.flatOffset),{name:e.variableNames[d],shapeInfo:p}}),a=s.map(u=>u.shapeInfo),o={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},i=_T(s,o,e),c=tT(n.gl,i),l=n.createProgram(c);return U().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:c,source:i,webGLProgram:l,inShapeInfos:a,outShapeInfo:o,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(n.buildVao(l),Object.assign({program:e,fragmentShader:c,source:i,webGLProgram:l,inShapeInfos:a,outShapeInfo:o},Ay(n,e,l)))}function Ay(n,e,t){const r=[],s=[];let a,o,i,c=null,l=null;l=n.getUniformLocation(t,"NAN",!1),U().getNumber("WEBGL_VERSION")===1&&(c=n.getUniformLocation(t,"INFINITY",!1));const u=!1;for(const d of e.variableNames){const p={name:d,uniform:n.getUniformLocation(t,d,u),offset:n.getUniformLocation(t,`offset${d}`,u)};e.enableShapeUniforms&&(p.shape=n.getUniformLocation(t,`${d}Shape`,u),p.texShape=n.getUniformLocation(t,`${d}TexShape`,u)),r.push(p)}if(e.enableShapeUniforms&&(a=n.getUniformLocation(t,"outShape",u),i=n.getUniformLocation(t,"outShapeStrides",u),o=n.getUniformLocation(t,"outTexShape",u)),e.customUniforms)for(const d of e.customUniforms)s.push(n.getUniformLocation(t,d.name,u));return{variablesLocations:r,customUniformLocations:s,infLoc:c,nanLoc:l,outShapeLocation:a,outShapeStridesLocation:i,outTexShapeLocation:o}}function Yh(n,e){if(n.length!==e.length)throw Error(`Binary was compiled with ${n.length}
5747 inputs, but was executed with ${e.length} inputs`);n.forEach((t,r)=>{const s=t.logicalShape,a=e[r],o=a.shape;if(!st(s,o))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${s} and ${o} must match`);if(t.isUniform&&a.isUniform)return;const i=t.texShape,c=a.isUniform?null:a.texData.texShape;if(!st(i,c))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${i} and ${c} must match`)})}function ck(n,e,t,r,s){e.program.enableShapeUniforms||(Yh(e.inShapeInfos,t),Yh([e.outShapeInfo],[r]));const a=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?n.setOutputPackedMatrixTexture(a.texture,o[0],o[1]):n.setOutputMatrixTexture(a.texture,o[0],o[1]),n.setProgram(e.webGLProgram),n.bindVertexArray(e.webGLProgram.vao),U().getNumber("WEBGL_VERSION")===1&&e.infLoc!==null&&n.gl.uniform1f(e.infLoc,1/0),e.nanLoc!==null&&n.gl.uniform1f(e.nanLoc,NaN);for(let c=0;c<t.length;++c){const l=t[c],{uniform:u,offset:d,shape:p,texShape:h}=e.variablesLocations[c];if(p){const{uniformShape:m}=Jp(e.program.packedInputs,l.shape,l.texData.texShape);switch(m.length){case 1:n.gl.uniform1iv(p,new Int32Array(m));break;case 2:n.gl.uniform2iv(p,new Int32Array(m));break;case 3:n.gl.uniform3iv(p,new Int32Array(m));break;case 4:n.gl.uniform4iv(p,new Int32Array(m));break}}if(h&&n.gl.uniform2i(h,l.texData.texShape[0],l.texData.texShape[1]),u!=null){if(l.isUniform){if(H(l.shape)<2)n.gl.uniform1f(u,l.uniformValues[0]);else{let m=l.uniformValues;m instanceof Float32Array||(m=new Float32Array(m)),n.gl.uniform1fv(u,m)}continue}l.texData.slice!=null&&d!=null&&n.gl.uniform1i(d,l.texData.slice.flatOffset),n.setInputMatrixTexture(l.texData.texture.texture,u,c)}}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 c=Be(r.shape);switch(r.shape.length){case 2:n.gl.uniform1iv(e.outShapeStridesLocation,new Int32Array(c));break;case 3:n.gl.uniform2iv(e.outShapeStridesLocation,new Int32Array(c));break;case 4:n.gl.uniform3iv(e.outShapeStridesLocation,new Int32Array(c));break}}if(e.outTexShapeLocation&&n.gl.uniform2i(e.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),e.program.customUniforms&&s)for(let c=0;c<e.program.customUniforms.length;++c){const l=e.program.customUniforms[c],u=e.customUniformLocations[c],d=s[c];if(l.type==="float")n.gl.uniform1fv(u,d);else if(l.type==="vec2")n.gl.uniform2fv(u,d);else if(l.type==="vec3")n.gl.uniform3fv(u,d);else if(l.type==="vec4")n.gl.uniform4fv(u,d);else if(l.type==="int")n.gl.uniform1iv(u,d);else if(l.type==="ivec2")n.gl.uniform2iv(u,d);else if(l.type==="ivec3")n.gl.uniform3iv(u,d);else if(l.type==="ivec4")n.gl.uniform4iv(u,d);else throw Error(`uniform type ${l.type} is not supported yet.`)}n.executeProgram()}function lk(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 c=o.texData.texShape,{useSqueezeShape:l,uniformShape:u,keptDims:d}=Jp(n.packedInputs,o.shape,c);let p="",h="",m="";if(u.length===1&&n.packedInputs){const T=[Math.ceil(c[0]/2),Math.ceil(c[1]/2)];p=`${T[0]>1}_${T[1]>1}`}else if(u.length===2&&!n.packedInputs)h=`${u[0]>1}_${u[1]>1}`;else if(u.length>2&&!n.packedInputs){const T=Be(u);m=`${T[0]===c[1]}_${T[T.length-1]===c[1]}`}const g=o.shape.length,y=u.length===2&&st(o.shape,c),b=H(o.shape)===1,v=Ii(o.shape,t.shape),$=!n.packedInputs&&g===t.shape.length&&st(c,t.texData.texShape),S=n.packedInputs||u.length>2?"":`${c[0]>1}_${c[1]>1}`;r+=`${g}_${$}_${l?d:""}_${u.length}_${b}_${v}_${y}_${p}_${h}_${m}_${S}_${i}`}else{const c=o.isUniform?"uniform":o.texData.texShape;r+=`${o.shape}_${c}_${i}`}});const s=n.userCode;let a=n.constructor.name;return a+="_"+r+"_"+s+`${U().getNumber("WEBGL_VERSION")}`,a}function Dt(n){return U().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&n<=4}/** 5748 * @license 5749 * Copyright 2019 Google LLC. All Rights Reserved. 5750 * Licensed under the Apache License, Version 2.0 (the "License");
5751 * you may not use this file except in compliance with the License. 5752 * You may obtain a copy of the License at 5753 * 5754 * http://www.apache.org/licenses/LICENSE-2.0 5755 * 5756 * Unless required by applicable law or agreed to in writing, software 5757 * distributed under the License is distributed on an "AS IS" BASIS, 5758 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5759 * See the License for the specific language governing permissions and 5760 * limitations under the License. 5761 * ============================================================================= 5762 */class dk{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=vo.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Wt();this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length),this.userCode=` 5763 ivec3 outCoordsFromFlatIndex(int index) { 5764 ${this.enableShapeUniforms?Ju(["r","c","d"],e):Ws(["r","c","d"],e)} 5765 return ivec3(r, c, d); 5766 } 5767 5768 void main() { 5769 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 5770 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 5771 5772 vec4 result = vec4(0.); 5773 5774 for (int i=0; i<4; i++) { 5775 int flatIndex = index + i; 5776 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 5777 result[i] = getA(rc.x, rc.y, rc.z); 5778 } 5779 5780 ${t.output} = result; 5781 } 5782 `}}/** 5783 * @license 5784 * Copyright 2019 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 */class pk{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=vo.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Wt();this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length),this.userCode=` 5798 ivec3 outCoordsFromFlatIndex(int index) { 5799 ${this.enableShapeUniforms?Ju(["r","c","d"],e):Ws(["r","c","d"],e)} 5800 return ivec3(r, c, d); 5801 } 5802 5803 void main() { 5804 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 5805 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 5806 5807 vec4 result = vec4(0.); 5808 5809 for (int i=0; i<4; i++) { 5810 int flatIndex = index + i; 5811 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 5812 result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z)); 5813 } 5814 5815 ${t.output} = result; 5816 } 5817 `}}/** 5818 * @license 5819 * Copyright 2018 Google LLC. All Rights Reserved. 5820 * Licensed under the Apache License, Version 2.0 (the "License"); 5821 * you may not use this file except in compliance with the License. 5822 * You may obtain a copy of the License at 5823 * 5824 * http://www.apache.org/licenses/LICENSE-2.0 5825 * 5826 * Unless required by applicable law or agreed to in writing, software 5827 * distributed under the License is distributed on an "AS IS" BASIS, 5828 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5829 * See the License for the specific language governing permissions and 5830 * limitations under the License. 5831 * ============================================================================= 5832 */class hk{constructor(e){this.variableNames=["A"],this.outTexUsage=pn.DOWNLOAD;const t=Wt();this.outputShape=e,this.userCode=` 5833 ${Ty} 5834 5835 void main() { 5836 float x = getAAtOutCoords(); 5837 ${t.output} = encode_float(x); 5838 } 5839 `}}/** 5840 * @license 5841 * Copyright 2018 Google LLC. All Rights Reserved. 5842 * Licensed under the Apache License, Version 2.0 (the "License");
5843 * you may not use this file except in compliance with the License. 5844 * You may obtain a copy of the License at 5845 * 5846 * http://www.apache.org/licenses/LICENSE-2.0 5847 * 5848 * Unless required by applicable law or agreed to in writing, software 5849 * distributed under the License is distributed on an "AS IS" BASIS, 5850 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5851 * See the License for the specific language governing permissions and 5852 * limitations under the License. 5853 * ============================================================================= 5854 */class fk{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=pn.DOWNLOAD;const t=Wt();this.outputShape=e,this.userCode=` 5855 ${Ty} 5856 5857 void main() { 5858 ivec3 coords = getOutputCoords(); 5859 float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z)); 5860 ${t.output} = encode_float(x); 5861 } 5862 `}}/** 5863 * @license 5864 * Copyright 2018 Google LLC. All Rights Reserved. 5865 * Licensed under the Apache License, Version 2.0 (the "License"); 5866 * you may not use this file except in compliance with the License. 5867 * You may obtain a copy of the License at 5868 * 5869 * http://www.apache.org/licenses/LICENSE-2.0 5870 * 5871 * Unless required by applicable law or agreed to in writing, software 5872 * distributed under the License is distributed on an "AS IS" BASIS, 5873 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5874 * See the License for the specific language governing permissions and 5875 * limitations under the License. 5876 * ============================================================================= 5877 */const mk={R:0,G:1,B:2,A:3};class Qh{constructor(e,t=!1,r="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const s=Wt();this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length);let a="result";t&&(a="floor(result * 255. + 0.5)");let o="";for(let i=0;i<r.length;i++){const c=r[i];o+=` 5878 if(offset == ${i}) { 5879 result = values[${mk[c]}]; 5880 }`}this.userCode=` 5881 ${this.enableShapeUniforms?Zp():Qp(e)} 5882 5883 void main() { 5884 ivec3 coords = getOutputCoords(); 5885 int flatIndex = getFlatIndex(coords); 5886 float result = 0.; 5887 int offset = imod(flatIndex, ${r.length}); 5888 5889 flatIndex = idiv(flatIndex, ${r.length}, 1.); 5890 5891 int r = flatIndex / texShape[1]; 5892 if (r < texShape[0]) { 5893 int c = imod(flatIndex, texShape[1]); 5894 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 5895 vec4 values = ${s.texture2D}(A, uv); 5896 ${o} 5897 } 5898 ${s.output} = vec4(${a}, 0., 0., 0.); 5899 } 5900 `}}/** 5901 * @license 5902 * Copyright 2018 Google LLC. All Rights Reserved. 5903 * Licensed under the Apache License, Version 2.0 (the "License"); 5904 * you may not use this file except in compliance with the License. 5905 * You may obtain a copy of the License at 5906 * 5907 * http://www.apache.org/licenses/LICENSE-2.0 5908 * 5909 * Unless required by applicable law or agreed to in writing, software 5910 * distributed under the License is distributed on an "AS IS" BASIS, 5911 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5912 * See the License for the specific language governing permissions and 5913 * limitations under the License. 5914 * ============================================================================= 5915 */class gk{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=Wt();this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length);let s="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let o=0;o<=1;o++)for(let i=0;i<=1;i++){const c=o*2+i;s+=` 5916 localCoords = coords; 5917 if(localCoords[2] + ${i} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) { 5918 localCoords[2] += ${i}; 5919 if (localCoords[1] + ${o} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) { 5920 localCoords[1] += ${o}; 5921 5922 flatIndex = getFlatIndex(localCoords); 5923 offset = imod(flatIndex, 4); 5924 5925 flatIndex = idiv(flatIndex, 4, 1.); 5926 5927 int r = flatIndex / texShape[1]; 5928 int c = imod(flatIndex, texShape[1]); 5929 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 5930 values = ${r.texture2D}(A, uv); 5931 5932 if (offset == 0) { 5933 result[${c}] = values[0]; 5934 } else if (offset == 1) { 5935 result[${c}] = values[1]; 5936 } else if (offset == 2) { 5937 result[${c}] = values[2]; 5938 } else { 5939 result[${c}] = values[3]; 5940 } 5941 } 5942 } 5943 `}this.userCode=` 5944 ${this.enableShapeUniforms?Zp():Qp(e)} 5945 5946 void main() { 5947 ivec3 coords = getOutputCoords(); 5948 5949 vec4 result = vec4(0.); 5950 int flatIndex, r, c, offset; 5951 ivec3 localCoords; 5952 vec2 uv; 5953 vec4 values; 5954 5955 ${s} 5956 5957 ${r.output} = ${a}; 5958 } 5959 `}}/** 5960 * @license 5961 * Copyright 2017 Google LLC. All Rights Reserved. 5962 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 15,316 bytes, lines 5963-6001
5963 * you may not use this file except in compliance with the License. 5964 * You may obtain a copy of the License at 5965 * 5966 * http://www.apache.org/licenses/LICENSE-2.0 5967 * 5968 * Unless required by applicable law or agreed to in writing, software 5969 * distributed under the License is distributed on an "AS IS" BASIS, 5970 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5971 * See the License for the specific language governing permissions and 5972 * limitations under the License. 5973 * ============================================================================= 5974 */function yk(n){const e=Wt(),t=`${e.version} 5975 precision highp float; 5976 ${e.attribute} vec3 clipSpacePos; 5977 ${e.attribute} vec2 uv; 5978 ${e.varyingVs} vec2 resultUV; 5979 5980 void main() { 5981 gl_Position = vec4(clipSpacePos, 1); 5982 resultUV = uv; 5983 }`;return eT(n,t)}function bk(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 aT(n,e)}function xk(n){const e=new Uint16Array([0,1,2,2,1,3]);return oT(n,e)}function Lo(n,e,t,r,s,a){uT(e,t);const o=iT(n),i=n.TEXTURE_2D;return oe(n,()=>n.bindTexture(i,o)),oe(n,()=>n.texParameteri(i,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE)),oe(n,()=>n.texParameteri(i,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),oe(n,()=>n.texParameteri(i,n.TEXTURE_MIN_FILTER,n.NEAREST)),oe(n,()=>n.texParameteri(i,n.TEXTURE_MAG_FILTER,n.NEAREST)),U().getNumber("WEBGL_VERSION")===1?oe(n,()=>n.texImage2D(i,0,r,e,t,0,s,a,null)):oe(n,()=>n.texStorage2D(i,1,r,e,t)),oe(n,()=>n.bindTexture(n.TEXTURE_2D,null)),{texture:o,texShape:[t,e]}}function Dy(n){return n.internalFormatFloat}function wk(n,e,t,r){const[s,a]=Fo(e,t);return Lo(n,s,a,Dy(r),r.textureFormatFloat,n.FLOAT)}function Oy(n){return n.internalFormatHalfFloat}function vk(n,e,t,r){const[s,a]=Fo(e,t);return Lo(n,s,a,Oy(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function Fy(n){return n.downloadTextureFormat}function Ik(n,e,t,r){const[s,a]=Fo(e,t);return Lo(n,s,a,Fy(r),n.RGBA,n.UNSIGNED_BYTE)}function Py(n){return n.internalFormatPackedFloat}function $k(n,e,t,r){const[s,a]=Aa(e,t);return Lo(n,s,a,Py(r),n.RGBA,n.FLOAT)}function Ly(n){return n.internalFormatPackedHalfFloat}function Sk(n,e,t,r){const[s,a]=Aa(e,t);return Lo(n,s,a,Ly(r),n.RGBA,r.textureTypeHalfFloat)}function Ck(n,e,t){return oe(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),qh(n,e,"clipSpacePos",t,3,20,0)&&qh(n,e,"uv",t,2,20,12)}function _k(n,e,t,r,s,a){oe(n,()=>n.bindTexture(n.TEXTURE_2D,e));let o,i,c;s instanceof Uint8Array?(o=new Uint8Array(t*r*4),i=n.UNSIGNED_BYTE,c=n.RGBA):(o=new Float32Array(t*r*4),i=n.FLOAT,c=a.internalFormatPackedFloat),o.set(s),U().getNumber("WEBGL_VERSION")===2?oe(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t,r,n.RGBA,i,o)):oe(n,()=>n.texImage2D(n.TEXTURE_2D,0,c,t,r,0,n.RGBA,i,o)),oe(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function Nk(n,e,t){oe(n,()=>n.bindTexture(n.TEXTURE_2D,e)),t.data instanceof Uint8Array?U().getNumber("WEBGL_VERSION")===2?oe(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,t.data)):oe(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t.width,t.height,0,n.RGBA,n.UNSIGNED_BYTE,t.data)):U().getNumber("WEBGL_VERSION")===2?oe(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,t)):oe(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)),oe(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function Tk(n,e,t,r){const s=n.createBuffer();oe(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,s));const i=4*4*e*t;return oe(n,()=>n.bufferData(n.PIXEL_PACK_BUFFER,i,n.STREAM_READ)),oe(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,0)),oe(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,null)),s}function kk(n,e,t){const r=n,s=new Float32Array(t);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,s),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),s}function Ek(n,e,t,r){const[s,a]=Fo(e,t),o=4,i=new Uint8Array(qN(e*t,o));return oe(n,()=>n.readPixels(0,0,s,a,r.downloadTextureFormat,n.UNSIGNED_BYTE,i)),new Float32Array(i.buffer)}function Rk(n,e,t,r,s,a,o,i){const c=n,l=new Float32Array(KN(a,o));return c.bindBuffer(c.PIXEL_PACK_BUFFER,e),c.getBufferSubData(c.PIXEL_PACK_BUFFER,0,l),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),l}function Ak(n,e,t){const r=new Float32Array(e*t*4);return oe(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,r)),r}/** 5984 * @license 5985 * Copyright 2017 Google LLC. All Rights Reserved. 5986 * Licensed under the Apache License, Version 2.0 (the "License"); 5987 * you may not use this file except in compliance with the License. 5988 * You may obtain a copy of the License at 5989 * 5990 * http://www.apache.org/licenses/LICENSE-2.0 5991 * 5992 * Unless required by applicable law or agreed to in writing, software 5993 * distributed under the License is distributed on an "AS IS" BASIS, 5994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5995 * See the License for the specific language governing permissions and 5996 * limitations under the License. 5997 * ============================================================================= 5998 */class xc{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const t=U().getNumber("WEBGL_VERSION");if(e!=null?(this.gl=e,GN(t,e)):this.gl=qn(t),e=this.gl,U().getNumber("WEBGL_VERSION")===2){const a=e;this.createVertexArray=()=>oe(a,()=>a.createVertexArray()),this.bindVertexArray=o=>oe(a,()=>a.bindVertexArray(o)),this.deleteVertexArray=o=>oe(a,()=>a.deleteVertexArray(o)),this.getVertexArray=()=>oe(a,()=>a.getParameter(a.VERTEX_ARRAY_BINDING))}else if(e!=null){const a=e.getExtension("OES_vertex_array_object");if(a==null)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>oe(e,()=>a.createVertexArrayOES()),this.bindVertexArray=o=>oe(e,()=>a.bindVertexArrayOES(o)),this.deleteVertexArray=o=>oe(e,()=>a.deleteVertexArrayOES(o)),this.getVertexArray=()=>oe(e,()=>e.getParameter(a.VERTEX_ARRAY_BINDING_OES))}let r="WEBGL_color_buffer_float";const s="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),U().getNumber("WEBGL_VERSION")===1){const a="OES_texture_float",o="OES_texture_half_float";if(this.textureFloatExtension=ai(this.gl,a),_n(this.gl,o))this.textureHalfFloatExtension=ai(this.gl,o);else if(U().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),_n(this.gl,s))this.colorBufferHalfFloatExtension=ai(this.gl,s);else if(U().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",_n(this.gl,r))this.colorBufferFloatExtension=this.gl.getExtension(r);else if(_n(this.gl,s))this.colorBufferHalfFloatExtension=this.gl.getExtension(s);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=bk(this.gl),this.indexBuffer=xk(this.gl),this.framebuffer=cT(this.gl),this.textureConfig=Yp(this.gl,this.textureHalfFloatExtension)}get debug(){return U().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;oe(e,()=>e.finish()),oe(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),oe(e,()=>e.deleteFramebuffer(this.framebuffer)),oe(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),oe(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),oe(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),wk(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),vk(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),Ik(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),Nk(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,r,s){this.throwIfDisposed(),_k(this.gl,e,t,r,s,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),Sk(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),$k(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(Kh(this.gl,this.framebuffer),this.outputTexture=null),oe(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,r){return this.downloadMatrixDriver(e,()=>Ek(this.gl,t,r,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,r,s,a,o){return Rk(this.gl,e,t,r,s,a,o,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return kk(this.gl,e,t)}createBufferFromTexture(e,t,r){this.bindTextureToFrameBuffer(e);const s=Tk(this.gl,t,r,this.textureConfig);return this.unbindTextureToFrameBuffer(),s}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,r;if(U().getBool("WEBGL_FENCE_API_ENABLED")){const s=e,a=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),r=()=>{const o=s.clientWaitSync(a,0,0);return o===s.ALREADY_SIGNALED||o===s.CONDITION_SATISFIED},t=a}else U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),r=()=>this.isQueryAvailable(t,U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):r=()=>!0;return{query:t,isFencePassed:r}}downloadMatrixFromPackedTexture(e,t,r){return this.downloadMatrixDriver(e,()=>Ak(this.gl,t,r))}createProgram(e){this.throwIfDisposed();const t=this.gl;this.vertexShader==null&&(this.vertexShader=yk(t));const r=rT(t);oe(t,()=>t.attachShader(r,this.vertexShader)),oe(t,()=>t.attachShader(r,e)),sT(t,r);const s=Object.assign(r,{vao:this.createVertexArray()});return this.debug&&mc(t,s),s}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);const t=this.gl;oe(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),Ck(t,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&(oe(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&mc(this.gl,this.program),oe(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,r=!0){return this.throwIfDisposed(),r?dT(this.gl,e,t):pT(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),oe(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(),hT(this.gl,e,t,r)}setOutputMatrixTexture(e,t,r){this.setOutputMatrixTextureDriver(e,r,t)}setOutputPackedMatrixTexture(e,t,r){this.throwIfDisposed();const[s,a]=Aa(t,r);this.setOutputMatrixTextureDriver(e,s,a)}setOutputMatrixWriteRegion(e,t,r,s){this.setOutputMatrixWriteRegionDriver(r,e,s,t)}setOutputPackedMatrixWriteRegion(e,t,r,s){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&mc(this.gl,this.program),oi(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const t=this.getVertexArray();console.assert(t===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}oe(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),oe(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=ai(this.gl,U().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(U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const r=this.gl,s=this.getQueryTimerExtensionWebGL2(),a=r.createQuery();return r.beginQuery(s.TIME_ELAPSED_EXT,a),a}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(U().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 Ih(()=>this.disposed||this.isQueryAvailable(e,U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,U().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,s=this.getQueryTimerExtensionWebGL2(),a=r.getQueryParameter(e,r.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),a&&!this.disjoint}else{const r=this.getQueryTimerExtensionWebGL1(),s=r.getQueryObjectEXT(e,r.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),s&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){const e=Dk(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 U().platform&&(r=U().platform.setTimeoutCustom.bind(U().platform)),Ih(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,r)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),gc(this.gl,e,this.framebuffer),this.debug&&oi(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(gc(this.gl,this.outputTexture,this.framebuffer),this.debug&&oi(this.gl)):Kh(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const r=t();return this.unbindTextureToFrameBuffer(),r}setOutputMatrixTextureDriver(e,t,r){this.throwIfDisposed();const s=this.gl;gc(s,e,this.framebuffer),this.debug&&oi(s),this.outputTexture=e,oe(s,()=>s.viewport(0,0,t,r)),oe(s,()=>s.scissor(0,0,t,r))}setOutputMatrixWriteRegionDriver(e,t,r,s){this.throwIfDisposed(),oe(this.gl,()=>this.gl.scissor(e,t,r,s))}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 Dk(n){let e=0;for(;e<n.length&&n[e]();++e);return e-1}/** 5999 * @license 6000 * Copyright 2020 Google LLC. All Rights Reserved. 6001 * Licensed under the Apache License, Version 2.0 (the License);
6002 * you may not use this file except in compliance with the License. 6003 * You may obtain a copy of the License at 6004 * 6005 * http://www.apache.org/licenses/LICENSE-2.0 6006 * 6007 * Unless required by applicable law or agreed to in writing, software 6008 * distributed under the License is distributed on an AS IS BASIS, 6009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6010 * See the License for the specific language governing permissions and 6011 * limitations under the License. 6012 * ============================================================================= 6013 */function Ok(n){const e=new Float32Array(n.length);for(let t=0;t<n.length;++t)e[t]=Math.abs(n[t]);return e}/** 6014 * @license 6015 * Copyright 2020 Google LLC. All Rights Reserved. 6016 * Licensed under the Apache License, Version 2.0 (the "License"); 6017 * you may not use this file except in compliance with the License. 6018 * You may obtain a copy of the License at 6019 * 6020 * http://www.apache.org/licenses/LICENSE-2.0 6021 * 6022 * Unless required by applicable law or agreed to in writing, software 6023 * distributed under the License is distributed on an "AS IS" BASIS, 6024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6025 * See the License for the specific language governing permissions and 6026 * limitations under the License. 6027 * ============================================================================= 6028 */function Yt(n){return(e,t,r,s,a)=>{const o=ke(e,t),i=o.length,c=Be(o),l=H(o),u=Wr(a,l),d=e.length,p=t.length,h=Be(e),m=Be(t),g=Ii(e,o),y=Ii(t,o);if(g.length+y.length===0)for(let b=0;b<u.length;++b)u[b]=n(r[b%r.length],s[b%s.length]);else for(let b=0;b<u.length;++b){const v=Sl(b,i,c),$=v.slice(-d);g.forEach(L=>$[L]=0);const S=Dc($,d,h),T=v.slice(-p);y.forEach(L=>T[L]=0);const O=Dc(T,p,m);u[b]=n(r[S],s[O])}return[u,o]}}/** 6029 * @license 6030 * Copyright 2020 Google LLC. All Rights Reserved. 6031 * Licensed under the Apache License, Version 2.0 (the "License"); 6032 * you may not use this file except in compliance with the License. 6033 * You may obtain a copy of the License at 6034 * 6035 * http://www.apache.org/licenses/LICENSE-2.0 6036 * 6037 * Unless required by applicable law or agreed to in writing, software 6038 * distributed under the License is distributed on an "AS IS" BASIS, 6039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6040 * See the License for the specific language governing permissions and 6041 * limitations under the License. 6042 * ============================================================================= 6043 */function Fk(n,e,t,r){if(r==="int32"){const s=Int32Array.from(n);return[e,"int32",s]}if(r==="bool"){const s=Mu([0],t),[a,o]=Yt((i,c)=>i!==c?1:0)(e,[],n,s,"bool");return[o,"bool",a]}throw new Error(`Error in Cast: failed to cast ${t} to ${r}`)}/** 6044 * @license 6045 * Copyright 2020 Google LLC. All Rights Reserved. 6046 * Licensed under the Apache License, Version 2.0 (the "License"); 6047 * you may not use this file except in compliance with the License. 6048 * You may obtain a copy of the License at 6049 * 6050 * http://www.apache.org/licenses/LICENSE-2.0 6051 * 6052 * Unless required by applicable law or agreed to in writing, software 6053 * distributed under the License is distributed on an "AS IS" BASIS, 6054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6055 * See the License for the specific language governing permissions and 6056 * limitations under the License. 6057 * ============================================================================= 6058 */const Pk=Yt((n,e)=>n+e);/** 6059 * @license 6060 * Copyright 2020 Google LLC. All Rights Reserved. 6061 * Licensed under the Apache License, Version 2.0 (the "License"); 6062 * you may not use this file except in compliance with the License. 6063 * You may obtain a copy of the License at 6064 * 6065 * http://www.apache.org/licenses/LICENSE-2.0 6066 * 6067 * Unless required by applicable law or agreed to in writing, software 6068 * distributed under the License is distributed on an "AS IS" BASIS, 6069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6070 * See the License for the specific language governing permissions and 6071 * limitations under the License. 6072 * =============================================================================
6073 */function Lk(n,e,t,r,s){const a=H(r),o=Ur(s,t);for(let i=0;i<n.length;i++){const c=n[i];if(c<0)throw new Error("Input x must be non-negative!");c>=s||(a>0?o[c]+=e[i]:o[c]+=1)}return o}function Mk(n,e,t,r=!1){const s=n.shape[0],a=n.shape[1],o=at([s,t],e.dtype);for(let i=0;i<s;i++)for(let c=0;c<a;c++){const l=n.get(i,c);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,c),i,l):o.set(o.get(i,l)+1,i,l))}return o}/** 6074 * @license 6075 * Copyright 2023 Google LLC. 6076 * Licensed under the Apache License, Version 2.0 (the "License"); 6077 * you may not use this file except in compliance with the License. 6078 * You may obtain a copy of the License at 6079 * 6080 * http://www.apache.org/licenses/LICENSE-2.0 6081 * 6082 * Unless required by applicable law or agreed to in writing, software 6083 * distributed under the License is distributed on an "AS IS" BASIS, 6084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6085 * See the License for the specific language governing permissions and 6086 * limitations under the License. 6087 * ============================================================================= 6088 */const Bk=Yt((n,e)=>n&e);/** 6089 * @license 6090 * Copyright 2020 Google LLC. All Rights Reserved. 6091 * Licensed under the Apache License, Version 2.0 (the "License"); 6092 * you may not use this file except in compliance with the License. 6093 * You may obtain a copy of the License at 6094 * 6095 * http://www.apache.org/licenses/LICENSE-2.0 6096 * 6097 * Unless required by applicable law or agreed to in writing, software 6098 * distributed under the License is distributed on an "AS IS" BASIS, 6099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6100 * See the License for the specific language governing permissions and 6101 * limitations under the License. 6102 * ============================================================================= 6103 */function Cr(n){return(e,t,r)=>{const s=yt(t,e.length);for(let a=0;a<e.length;++a)s[a]=n(e[a],r);return s}}/** 6104 * @license 6105 * Copyright 2020 Google LLC. All Rights Reserved. 6106 * Licensed under the Apache License, Version 2.0 (the License); 6107 * you may not use this file except in compliance with the License. 6108 * You may obtain a copy of the License at 6109 * 6110 * http://www.apache.org/licenses/LICENSE-2.0 6111 * 6112 * Unless required by applicable law or agreed to in writing, software 6113 * distributed under the License is distributed on an AS IS BASIS, 6114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6115 * See the License for the specific language governing permissions and 6116 * limitations under the License. 6117 * ============================================================================= 6118 */const Vk=Cr(n=>Math.ceil(n));/** 6119 * @license 6120 * Copyright 2020 Google LLC. All Rights Reserved. 6121 * Licensed under the Apache License, Version 2.0 (the "License"); 6122 * you may not use this file except in compliance with the License. 6123 * You may obtain a copy of the License at 6124 * 6125 * http://www.apache.org/licenses/LICENSE-2.0 6126 * 6127 * Unless required by applicable law or agreed to in writing, software 6128 * distributed under the License is distributed on an "AS IS" BASIS, 6129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6130 * See the License for the specific language governing permissions and 6131 * limitations under the License. 6132 * ============================================================================= 6133 */function My(n,e,t,r){const s=yt(t,H(e));if(r&&t!=="string"){let a=0;n.forEach(o=>{const i=H(o.shape);s.set(o.vals,a),a+=i})}else{let a=0;n.forEach(o=>{const i=t==="string"?Ca(o.vals):o.vals;let c=0;for(let l=0;l<o.shape[0];++l){const u=l*e[1]+a;for(let d=0;d<o.shape[1];++d)s[u+d]=i[c++]}a+=o.shape[1]})}return s}/** 6134 * @license 6135 * Copyright 2020 Google LLC. All Rights Reserved. 6136 * Licensed under the Apache License, Version 2.0 (the "License"); 6137 * you may not use this file except in compliance with the License. 6138 * You may obtain a copy of the License at 6139 * 6140 * http://www.apache.org/licenses/LICENSE-2.0 6141 * 6142 * Unless required by applicable law or agreed to in writing, software 6143 * distributed under the License is distributed on an "AS IS" BASIS, 6144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6145 * See the License for the specific language governing permissions and 6146 * limitations under the License. 6147 * ============================================================================= 6148 */const Wk=Yt((n,e)=>n===e?1:0);/** 6149 * @license 6150 * Copyright 2020 Google LLC. All Rights Reserved. 6151 * Licensed under the Apache License, Version 2.0 (the License);
6152 * you may not use this file except in compliance with the License. 6153 * You may obtain a copy of the License at 6154 * 6155 * http://www.apache.org/licenses/LICENSE-2.0 6156 * 6157 * Unless required by applicable law or agreed to in writing, software 6158 * distributed under the License is distributed on an AS IS BASIS, 6159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6160 * See the License for the specific language governing permissions and 6161 * limitations under the License. 6162 * ============================================================================= 6163 */const Uk=Cr(n=>Math.exp(n));/** 6164 * @license 6165 * Copyright 2020 Google LLC. All Rights Reserved. 6166 * Licensed under the Apache License, Version 2.0 (the License); 6167 * you may not use this file except in compliance with the License. 6168 * You may obtain a copy of the License at 6169 * 6170 * http://www.apache.org/licenses/LICENSE-2.0 6171 * 6172 * Unless required by applicable law or agreed to in writing, software 6173 * distributed under the License is distributed on an AS IS BASIS, 6174 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6175 * See the License for the specific language governing permissions and 6176 * limitations under the License. 6177 * ============================================================================= 6178 */const zk=Cr(n=>Math.expm1(n));/** 6179 * @license 6180 * Copyright 2020 Google LLC. All Rights Reserved. 6181 * Licensed under the Apache License, Version 2.0 (the License); 6182 * you may not use this file except in compliance with the License. 6183 * You may obtain a copy of the License at 6184 * 6185 * http://www.apache.org/licenses/LICENSE-2.0 6186 * 6187 * Unless required by applicable law or agreed to in writing, software 6188 * distributed under the License is distributed on an AS IS BASIS, 6189 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6190 * See the License for the specific language governing permissions and 6191 * limitations under the License. 6192 * ============================================================================= 6193 */const Gk=Cr(n=>Math.floor(n));/** 6194 * @license 6195 * Copyright 2020 Google LLC. All Rights Reserved. 6196 * Licensed under the Apache License, Version 2.0 (the "License"); 6197 * you may not use this file except in compliance with the License. 6198 * You may obtain a copy of the License at 6199 * 6200 * http://www.apache.org/licenses/LICENSE-2.0 6201 * 6202 * Unless required by applicable law or agreed to in writing, software 6203 * distributed under the License is distributed on an "AS IS" BASIS, 6204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6205 * See the License for the specific language governing permissions and 6206 * limitations under the License. 6207 * ============================================================================= 6208 */const Hk=Yt((n,e)=>Math.floor(n/e));/** 6209 * @license 6210 * Copyright 2021 Google LLC. All Rights Reserved. 6211 * Licensed under the Apache License, Version 2.0 (the "License"); 6212 * you may not use this file except in compliance with the License. 6213 * You may obtain a copy of the License at 6214 * 6215 * http://www.apache.org/licenses/LICENSE-2.0 6216 * 6217 * Unless required by applicable law or agreed to in writing, software 6218 * distributed under the License is distributed on an "AS IS" BASIS, 6219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6220 * See the License for the specific language governing permissions and 6221 * limitations under the License. 6222 * ============================================================================= 6223 */function jk(n,e,t,r,s,a,o,i,c){const l=at([r,a],t);for(let u=0;u<r;u++){const d=[];let p=0;for(let h=0;h<s;h++){const m=n[u*s+h];p+=m*o[h],d.push(m)}if(p<0||p>=c/a)throw new Error(`Invalid indices: ${d} does not index into ${i}`);for(let h=0;h<a;h++)l.values[u*a+h]=e.get(...e.indexToLoc(p*a+h))}return l}/** 6224 * @license 6225 * Copyright 2020 Google LLC. All Rights Reserved. 6226 * Licensed under the Apache License, Version 2.0 (the "License"); 6227 * you may not use this file except in compliance with the License. 6228 * You may obtain a copy of the License at 6229 * 6230 * http://www.apache.org/licenses/LICENSE-2.0 6231 * 6232 * Unless required by applicable law or agreed to in writing, softw
6232are 6233 * distributed under the License is distributed on an "AS IS" BASIS, 6234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6235 * See the License for the specific language governing permissions and 6236 * limitations under the License. 6237 * ============================================================================= 6238 */function qk(n,e,t){const r=at(t,n.dtype);for(let s=0;s<r.size;++s){const o=r.indexToLoc(s).slice(),i=o[0],c=o[2],l=e.locToIndex([i,c]);o[2]=e.values[l];const u=n.locToIndex(o);0<=u&&u<n.values.length&&(r.values[s]=n.values[u])}return r}/** 6239 * @license 6240 * Copyright 2020 Google LLC. All Rights Reserved. 6241 * Licensed under the Apache License, Version 2.0 (the "License"); 6242 * you may not use this file except in compliance with the License. 6243 * You may obtain a copy of the License at 6244 * 6245 * http://www.apache.org/licenses/LICENSE-2.0 6246 * 6247 * Unless required by applicable law or agreed to in writing, software 6248 * distributed under the License is distributed on an "AS IS" BASIS, 6249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6250 * See the License for the specific language governing permissions and 6251 * limitations under the License. 6252 * ============================================================================= 6253 */const Kk=Yt((n,e)=>n>e?1:0);/** 6254 * @license 6255 * Copyright 2020 Google LLC. All Rights Reserved. 6256 * Licensed under the Apache License, Version 2.0 (the "License"); 6257 * you may not use this file except in compliance with the License. 6258 * You may obtain a copy of the License at 6259 * 6260 * http://www.apache.org/licenses/LICENSE-2.0 6261 * 6262 * Unless required by applicable law or agreed to in writing, software 6263 * distributed under the License is distributed on an "AS IS" BASIS, 6264 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6265 * See the License for the specific language governing permissions and 6266 * limitations under the License. 6267 * ============================================================================= 6268 */const Xk=Yt((n,e)=>n>=e?1:0);/** 6269 * @license 6270 * Copyright 2020 Google LLC. All Rights Reserved. 6271 * Licensed under the Apache License, Version 2.0 (the "License"); 6272 * you may not use this file except in compliance with the License. 6273 * You may obtain a copy of the License at 6274 * 6275 * http://www.apache.org/licenses/LICENSE-2.0 6276 * 6277 * Unless required by applicable law or agreed to in writing, software 6278 * distributed under the License is distributed on an "AS IS" BASIS, 6279 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6280 * See the License for the specific language governing permissions and 6281 * limitations under the License. 6282 * ============================================================================= 6283 */const Yk=Yt((n,e)=>n<e?1:0);/** 6284 * @license 6285 * Copyright 2020 Google LLC. All Rights Reserved. 6286 * Licensed under the Apache License, Version 2.0 (the "License"); 6287 * you may not use this file except in compliance with the License. 6288 * You may obtain a copy of the License at 6289 * 6290 * http://www.apache.org/licenses/LICENSE-2.0 6291 * 6292 * Unless required by applicable law or agreed to in writing, software 6293 * distributed under the License is distributed on an "AS IS" BASIS, 6294 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6295 * See the License for the specific language governing permissions and 6296 * limitations under the License. 6297 * ============================================================================= 6298 */const Qk=Yt((n,e)=>n<=e?1:0);/** 6299 * @license 6300 * Copyright 2020 Google LLC. All Rights Reserved. 6301 * Licensed under the Apache License, Version 2.0 (the "License"); 6302 * you may not use this file except in compliance with the License. 6303 * You may obtain a copy of the License at 6304 * 6305 * http://www.apache.org/licenses/LICENSE-2.0 6306 * 6307 * Unless required by applicable law or agreed to in writing, software 6308 * distributed under the License is distributed on an "AS IS" BASIS, 6309 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6310 * See the License for the specific language governing permissions and 6311 * limitations under the License. 6312 * ============================================================================= 6313 */function Zk(n,e,t){const r=(e-n)/(t-1),s=Ur(t,"float32");s[0]=n;for(let a=1;a<s.length;a++)s[a]=s[a-1]+r;return s}/** 6314 * @license 6315 * Copyright 2020 Google LLC. All Rights Reserved. 6316 * Licensed under the Apache License, Version 2.0 (the License);
6317 * you may not use this file except in compliance with the License. 6318 * You may obtain a copy of the License at 6319 * 6320 * http://www.apache.org/licenses/LICENSE-2.0 6321 * 6322 * Unless required by applicable law or agreed to in writing, software 6323 * distributed under the License is distributed on an AS IS BASIS, 6324 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6325 * See the License for the specific language governing permissions and 6326 * limitations under the License. 6327 * ============================================================================= 6328 */const Jk=Cr(n=>Math.log(n));/** 6329 * @license 6330 * Copyright 2020 Google LLC. All Rights Reserved. 6331 * Licensed under the Apache License, Version 2.0 (the "License"); 6332 * you may not use this file except in compliance with the License. 6333 * You may obtain a copy of the License at 6334 * 6335 * http://www.apache.org/licenses/LICENSE-2.0 6336 * 6337 * Unless required by applicable law or agreed to in writing, software 6338 * distributed under the License is distributed on an "AS IS" BASIS, 6339 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6340 * See the License for the specific language governing permissions and 6341 * limitations under the License. 6342 * ============================================================================= 6343 */function eE(n,e,t,r){const s=Wr(r,H(t));for(let a=0;a<s.length;++a){const o=a*e;let i=n[o];for(let c=0;c<e;++c){const l=n[o+c];(Number.isNaN(l)||l>i)&&(i=l)}s[a]=i}return s}/** 6344 * @license 6345 * Copyright 2020 Google LLC. All Rights Reserved. 6346 * Licensed under the Apache License, Version 2.0 (the "License"); 6347 * you may not use this file except in compliance with the License. 6348 * You may obtain a copy of the License at 6349 * 6350 * http://www.apache.org/licenses/LICENSE-2.0 6351 * 6352 * Unless required by applicable law or agreed to in writing, software 6353 * distributed under the License is distributed on an "AS IS" BASIS, 6354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6355 * See the License for the specific language governing permissions and 6356 * limitations under the License. 6357 * ============================================================================= 6358 */const tE=Yt((n,e)=>Math.max(n,e));/** 6359 * @license 6360 * Copyright 2020 Google LLC. All Rights Reserved. 6361 * Licensed under the Apache License, Version 2.0 (the "License"); 6362 * you may not use this file except in compliance with the License. 6363 * You may obtain a copy of the License at 6364 * 6365 * http://www.apache.org/licenses/LICENSE-2.0 6366 * 6367 * Unless required by applicable law or agreed to in writing, software 6368 * distributed under the License is distributed on an "AS IS" BASIS, 6369 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6370 * See the License for the specific language governing permissions and 6371 * limitations under the License. 6372 * ============================================================================= 6373 */const nE=Yt((n,e)=>Math.min(n,e));/** 6374 * @license 6375 * Copyright 2020 Google LLC. All Rights Reserved. 6376 * Licensed under the Apache License, Version 2.0 (the "License"); 6377 * you may not use this file except in compliance with the License. 6378 * You may obtain a copy of the License at 6379 * 6380 * http://www.apache.org/licenses/LICENSE-2.0 6381 * 6382 * Unless required by applicable law or agreed to in writing, software 6383 * distributed under the License is distributed on an "AS IS" BASIS, 6384 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6385 * See the License for the specific language governing permissions and 6386 * limitations under the License. 6387 * ============================================================================= 6388 */const By=Yt((n,e)=>n*e);/** 6389 * @license 6390 * Copyright 2020 Google LLC. All Rights Reserved. 6391 * Licensed under the Apache License, Version 2.0 (the "License"); 6392 * you may not use this file except in compliance with the License. 6393 * You may obtain a copy of the License at 6394 * 6395 * http://www.apache.org/licenses/LICENSE-2.0 6396 * 6397 * Unless required by applicable law or agreed to in writing, software 6398 * distributed under the License is distributed on an "AS IS" BASIS, 6399 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6400 * See the License for the specific language governing permissions and 6401 * limitations under the License. 6402 * ============================================================================= 6403 */function rE(n,e,t){const r=Ea(-1,t);return By([],e,r,n,t)}/** 6404 * @license 6405 * Copyright 2020 Google LLC. All Rights Reserved. 6406 * Licensed under the Apache License, Version 2.0 (the "License");
6407 * you may not use this file except in compliance with the License. 6408 * You may obtain a copy of the License at 6409 * 6410 * http://www.apache.org/licenses/LICENSE-2.0 6411 * 6412 * Unless required by applicable law or agreed to in writing, software 6413 * distributed under the License is distributed on an "AS IS" BASIS, 6414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6415 * See the License for the specific language governing permissions and 6416 * limitations under the License. 6417 * ============================================================================= 6418 */const sE=Yt((n,e)=>n!==e?1:0);/** 6419 * @license 6420 * Copyright 2020 Google LLC. All Rights Reserved. 6421 * Licensed under the Apache License, Version 2.0 (the "License"); 6422 * you may not use this file except in compliance with the License. 6423 * You may obtain a copy of the License at 6424 * 6425 * http://www.apache.org/licenses/LICENSE-2.0 6426 * 6427 * Unless required by applicable law or agreed to in writing, software 6428 * distributed under the License is distributed on an "AS IS" BASIS, 6429 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6430 * See the License for the specific language governing permissions and 6431 * limitations under the License. 6432 * ============================================================================= 6433 */function aE(n,e,t,r,s){const a=e.length,o=H(e),i=Be(e),c=Be(s),l=Wr(t,H(s));for(let u=0;u<o;++u){const d=Sl(u,a,i),p=new Array(d.length);for(let m=0;m<p.length;m++)p[m]=d[r[m]];const h=Dc(p,a,c);l[h]=n[u]}return l}/** 6434 * @license 6435 * Copyright 2020 Google LLC. All Rights Reserved. 6436 * Licensed under the Apache License, Version 2.0 (the "License"); 6437 * you may not use this file except in compliance with the License. 6438 * You may obtain a copy of the License at 6439 * 6440 * http://www.apache.org/licenses/LICENSE-2.0 6441 * 6442 * Unless required by applicable law or agreed to in writing, software 6443 * distributed under the License is distributed on an "AS IS" BASIS, 6444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6445 * See the License for the specific language governing permissions and 6446 * limitations under the License. 6447 * ============================================================================= 6448 */function oE(n,e,t,r){const[s,a]=At(n,r),o=ir(e,"int32"),i=Ur(H(s),o),c=H(a);for(let l=0;l<i.length;++l){const u=l*c;let d=1;for(let p=0;p<c;++p)d*=t[u+p];i[l]=d}return{outVals:i,outShape:s,outDtype:o}}/** 6449 * @license 6450 * Copyright 2022 Google LLC. All Rights Reserved. 6451 * Licensed under the Apache License, Version 2.0 (the "License"); 6452 * you may not use this file except in compliance with the License. 6453 * You may obtain a copy of the License at 6454 * 6455 * http://www.apache.org/licenses/LICENSE-2.0 6456 * 6457 * Unless required by applicable law or agreed to in writing, software 6458 * distributed under the License is distributed on an "AS IS" BASIS, 6459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6460 * See the License for the specific language governing permissions and 6461 * limitations under the License. 6462 * ============================================================================= 6463 */function iE(n,e,t){n.forEach((r,s)=>{if(r<0||r>=t){const a=Sl(s,e.length,Be(e)).join(",");throw new Error(`indices[${a}] = ${r} is not in [0, ${t})`)}})}function uE(n,e){for(let t=0;t<n.length;++t){const r=n[t],s=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]>s)throw new Error("Ragged splits must not point past values");for(let a=1;a<r.length;++a)if(r[a-1]>r[a])throw new Error("Ragged splits must be sorted in ascending order")}}function cE(n,e,t,r){const s=[];let a=0;const o=e.length-1+t.length,i=new Array(o).fill(null).map(()=>[0]);uE(t,r);let c=1;for(let l=0;l<e.length-1;++l){c*=e[l];const u=e[l+1];for(let d=1;d<c+1;++d)i[l].push(d*u)}for(let l=0;l<n.length;++l){let u=n[l],d=n[l]+1;for(let p=0;p<t.length;++p){const h=t[p],m=p+e.length-1;if(m>=0){const g=i[m],y=g[g.length-1]-h[u];for(let b=u;b<d;++b)i[m].push(h[b+1]+y)}u=h[u],d=h[d]}d!==u&&(s.push([u,d]),a+=d-u)}
vendor: 17,302 bytes, lines 6463-6616
6463return{outSplits:i,valueSlices:s,numValues:a}}function lE(n){const e=[];for(let t=0;t<n.length;++t){const r=n[t].length,s=yt("int32",r);e.push(s),n[t].forEach((a,o)=>s[o]=a)}return e}function Zh(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 dE(n,e,t,r,s,a){const o=Zh(e,2)[1],i=Zh(a,2)[1];let c=0;for(const l of t)for(let u=l[0];u<l[1];++u){for(let d=0;d<r;++d)s[c*i+d]=n[u*o+d];++c}}function pE(n,e,t,r,s){const a=e.slice();a[0]=s;const o=yt(t,H(a)),i=n.length,c=i===0?0:i/e[0];return dE(n,e,r,c,o,a),[o,a]}function hE(n,e,t,r,s,a,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 c=e[0][0]-1;if(iE(a,o,c),r.length===0)throw new Error("params.rank must be nonzero");const l=r[0],{outSplits:u,valueSlices:d,numValues:p}=cE(a,o,n,l),h=lE(u),m=pE(t,r,s,d,p);return[h,m[0],m[1]]}/** 6464 * @license 6465 * Copyright 2022 Google LLC. 6466 * Licensed under the Apache License, Version 2.0 (the "License"); 6467 * you may not use this file except in compliance with the License. 6468 * You may obtain a copy of the License at 6469 * 6470 * http://www.apache.org/licenses/LICENSE-2.0 6471 * 6472 * Unless required by applicable law or agreed to in writing, software 6473 * distributed under the License is distributed on an "AS IS" BASIS, 6474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6475 * See the License for the specific language governing permissions and 6476 * limitations under the License. 6477 * ============================================================================= 6478 */const Jh=2147483647;function fE(n,e,t,r,s,a,o){if(e.length>1)throw new Error("starts must be a scalar or vector");if(s.length>1)throw new Error("limits must be a scalar or vector");if(o.length>1)throw new Error("deltas must be a scalar or vector");const i=e.length===0,c=s.length===0,l=o.length===0,u=[];i||u.push(e[0]),c||u.push(s[0]),l||u.push(o[0]);for(let y=1;y<u.length;++y)if(u[y]!==u[y-1])throw new Error("starts, limits, and deltas must have the same shape");const d=u.length===0?1:u[0],p=yt("int32",d+1);p[0]=0;for(let y=0;y<d;++y){const b=i?n[0]:n[y],v=c?r[0]:r[y],$=l?a[0]:a[y];if($===0)throw new Error("Requires delta != 0");let S;if($>0&&v<b||$<0&&v>b)S=0;else if(S=Math.ceil(Math.abs((v-b)/$)),S>Jh)throw new Error(`Requires ((limit - start) / delta) <= ${Jh}`);p[y+1]=p[y]+S}const h=p[d],m=yt(t,h);let g=0;for(let y=0;y<d;++y){const b=p[y+1]-p[y];let v=i?n[0]:n[y];const $=l?a[0]:a[y];for(let S=0;S<b;++S)m[g++]=v,v+=$}return[p,m]}/** 6479 * @license 6480 * Copyright 2022 Google LLC. All Rights Reserved. 6481 * Licensed under the Apache License, Version 2.0 (the "License"); 6482 * you may not use this file except in compliance with the License. 6483 * You may obtain a copy of the License at 6484 * 6485 * http://www.apache.org/licenses/LICENSE-2.0 6486 * 6487 * Unless required by applicable law or agreed to in writing, software 6488 * distributed under the License is distributed on an "AS IS" BASIS, 6489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6490 * See the License for the specific language governing permissions and 6491 * limitations under the License. 6492 * ============================================================================= 6493 */var vn=Wn;class Ti{constructor(e,t,r,s,a,o,i,c,l,u){this.shape=e,this.shapeShape=t,this.values=r,this.valuesShape=s,this.valuesDType=a,this.defaultValue=o,this.defaultValueShape=i,this.rowPartitionValues=c,this.rowPartitionValuesShapes=l,this.rowPartitionTypes=cy(u),this.raggedRank=ly(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===vn.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===vn.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case vn.VALUE_ROWIDS:return Ti.getMaxWidthValueRowID(t);case vn.ROW_SPLITS:return Ti.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${vn[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(t===0||t===1)return 0;let r=0;for(let s=0;s<t-1;++s){const a=e[s+1]-e[s];a>r&&(r=a)}return r}static getMaxWidthValueRowID(e){const t=e.length;if(t===0)return 0;let r=0,s=e[0],a=0;for(let o=1;o<t;++o){const i=e[o];i!==s&&(s=i,a=Math.max(o-r,a),r=o)}return Math.max(t-r,a)}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 tf(e,r)}calculateOutputSize(e){const t=this.valuesShape,r=this.defaultValueShape;dy(r,t);const s=this.tensorShapeFromTensor(this.shape,this.shapeShape),o=uy(this.raggedRank,s,t);o[0]<0&&(o[0]=e);for(let i=1;i<=this.raggedRank;++i)o[i]<0&&(o[i]=this.getMaxWidth(i));return o}calculateFirstParentOutputIndex(e,t,r){const s=Math.min(e,r),a=[];let o=0;for(let i=0;i<s;++i,o+=t)a.push(o);for(let i=s;i<e;++i)a.push(-1);return N(a.length===e,()=>"Final length of result must be equal to firstDimension."),a}calculateOutputIndexRowSplit(e,t,r,s){const a=e.length,o=[];for(let i=0;i<a-1;++i){const c=e[i+1]-e[i];let l=Math.min(s,c),u=t[i];u===-1&&(l=0);for(let d=0;d<l;++d)o.push(u),u+=r;for(let d=0;d<c-l;++d)o.push(-1)}if(a>0&&o.length!==e[a-1])throw new Error("Invalid row split size.");return o}calculateOutputIndexValueRowID(e,t,r,s){const a=e.length,o=[];if(a===0)return[];let i=0,c=e[0];if(c>=t.length)throw new Error(`Got currentValueRowId=${c}, which is not less than ${t.length}`);let l=t[c];o.push(l);for(let u=1;u<a;++u){const d=e[u];if(d===c)l>=0&&(++i,i<s?l+=r:l=-1);else{if(i=0,c=d,d>=t.length)throw new Error(`Got nextValueRowId=${d} which is not less than ${t.length}`);l=t[d]}o.push(l)}if(o.length!==e.length)throw new Error("Invalid row ids.");return o}calculateOutputIndex(e,t,r,s){const a=this.getRowPartitionTensor(e),o=this.getRowPartitionTypeByDimension(e);switch(o){case vn.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(a,t,r,s);case vn.ROW_SPLITS:if(a.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${a.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(a,t,r,s);default:throw new Error(`Unsupported partition type: ${vn[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 vn.FIRST_DIM_SIZE:return e[0];case vn.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case vn.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${vn[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const t=this.getFirstDimensionSize(),r=this.calculateOutputSize(t),s=new Array(this.raggedRank+1);s[s.length-1]=1;for(let c=s.length-2;c>=0;--c)s[c]=s[c+1]*r[c+1];const a=tf(r,!1),o=yt(this.valuesDType,H(a));if(s[0]*r[0]>0){let c=this.calculateFirstParentOutputIndex(t,s[0],r[0]);for(let l=1;l<=this.raggedRank;++l)c=this.calculateOutputIndex(l-1,c,s[l],r[l]);this.setOutput(this.raggedRank,c,o,a)}return[a,o]}setOutput(e,t,r,s){if(r.length===0)return;const a=this.values,o=r;let i=s.slice();i=i.slice(e+1);const c=H(i),l=t.length;let u=this.defaultValue;if(u.length!==c&&u.length!==1){const m=this.defaultValueShape;Ne(()=>{const g=q(u,m);u=oo(g,i).dataSync()})}let d=0,p=0,h=0;for(let m=0;m<=l;++m){let g=m<l?t[m]:-1;if(g===h){++h;continue}if(p<h){const y=a.subarray(d*c),b=o.subarray(p*c),v=(h-p)*c;ef(b,y,v)}if(m>=l){const y=r.length;g=Math.floor(y/c)}if(g>h)if(this.defaultValue.length===1)o.subarray(h*c,g*c).fill(this.defaultValue[0]),h=g;else for(;g>h;){const y=o.slice(h*c);ef(y,u,c),++h}g<0?(d=m+1,p=h):(d=m,p=h,h=p+1)}}}function ef(n,e,t){for(let r=0;r<t;r++)n[r]=e[r]}function tf(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 mE(n,e,t,r,s,a,o,i,c,l){return new Ti(n,e,t,r,s,a,o,i,c,l).compute()}/** 6494 * @license 6495 * Copyright 2020 Google LLC. All Rights Reserved. 6496 * Licensed under the Apache License, Version 2.0 (the "License"); 6497 * you may not use this file except in compliance with the License. 6498 * You may obtain a copy of the License at 6499 * 6500 * http://www.apache.org/licenses/LICENSE-2.0 6501 * 6502 * Unless required by applicable law or agreed to in writing, software 6503 * distributed under the License is distributed on an "AS IS" BASIS, 6504 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6505 * See the License for the specific language governing permissions and 6506 * limitations under the License. 6507 * ============================================================================= 6508 */function Vy(n,e,t,r){const s=n===e,a=n<e&&t<0,o=e<n&&t>1;if(s||a||o)return Ur(0,r);const i=Math.abs(Math.ceil((e-n)/t)),c=Ur(i,r);e<n&&t===1&&(t=-1),c[0]=n;for(let l=1;l<c.length;l++)c[l]=c[l-1]+t;return c}/** 6509 * @license 6510 * Copyright 2020 Google LLC. All Rights Reserved. 6511 * Licensed under the Apache License, Version 2.0 (the License); 6512 * you may not use this file except in compliance with the License. 6513 * You may obtain a copy of the License at 6514 * 6515 * http://www.apache.org/licenses/LICENSE-2.0 6516 * 6517 * Unless required by applicable law or agreed to in writing, software 6518 * distributed under the License is distributed on an AS IS BASIS, 6519 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6520 * See the License for the specific language governing permissions and 6521 * limitations under the License. 6522 * ============================================================================= 6523 */const gE=Cr(n=>1/Math.sqrt(n));/** 6524 * @license 6525 * Copyright 2020 Google LLC. All Rights Reserved. 6526 * Licensed under the Apache License, Version 2.0 (the "License"); 6527 * you may not use this file except in compliance with the License. 6528 * You may obtain a copy of the License at 6529 * 6530 * http://www.apache.org/licenses/LICENSE-2.0 6531 * 6532 * Unless required by applicable law or agreed to in writing, software 6533 * distributed under the License is distributed on an "AS IS" BASIS, 6534 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6535 * See the License for the specific language governing permissions and 6536 * limitations under the License. 6537 * ============================================================================= 6538 */function yE(n,e,t,r,s,a,o,i,c,l){const u=[r/s,s],d=n.values,p=e.values;if(r===0)return at(t,e.dtype);const h=c instanceof $a?c:at(u,e.dtype);typeof c=="string"||typeof c=="number"?h.values.fill(c):typeof c=="boolean"&&h.values.fill(+c);for(let m=0;m<a;m++){const g=[];let y=0;for(let b=0;b<o;b++){const v=d[m*o+b];g.push(v),y+=v*i[b]}if(y<0||y>=r/s)throw new Error(`Invalid indices: ${g} does not index into ${t}`);for(let b=0;b<s;b++)l?h.values[y*s+b]+=p[m*s+b]:h.values[y*s+b]=e.rank===0?p[0]:p[m*s+b]}return h}/** 6539 * @license 6540 * Copyright 2020 Google LLC. All Rights Reserved. 6541 * Licensed under the Apache License, Version 2.0 (the License); 6542 * you may not use this file except in compliance with the License. 6543 * You may obtain a copy of the License at 6544 * 6545 * http://www.apache.org/licenses/LICENSE-2.0 6546 * 6547 * Unless required by applicable law or agreed to in writing, software 6548 * distributed under the License is distributed on an AS IS BASIS, 6549 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6550 * See the License for the specific language governing permissions and 6551 * limitations under the License. 6552 * ============================================================================= 6553 */const bE=Cr(n=>1/(1+Math.exp(-n)));/** 6554 * @license 6555 * Copyright 2020 Google LLC. All Rights Reserved. 6556 * Licensed under the Apache License, Version 2.0 (the "License"); 6557 * you may not use this file except in compliance with the License. 6558 * You may obtain a copy of the License at 6559 * 6560 * http://www.apache.org/licenses/LICENSE-2.0 6561 * 6562 * Unless required by applicable law or agreed to in writing, software 6563 * distributed under the License is distributed on an "AS IS" BASIS, 6564 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6565 * See the License for the specific language governing permissions and 6566 * limitations under the License. 6567 * ============================================================================= 6568 */function tl(n,e,t,r,s){const a=Yu(r,e,t),o=H(t),i=Be(r);if(a){const d=Qu(e,i);return s==="string"?n.slice(d,d+o):n.subarray(d,d+o)}const c=s==="string"?Ca(n):n,l=at(r,s,c),u=at(t,s);for(let d=0;d<u.size;++d){const p=u.indexToLoc(d),h=p.map((m,g)=>m+e[g]);u.set(l.get(...h),...p)}return s==="string"?Xp(u.values):u.values}/** 6569 * @license 6570 * Copyright 2021 Google LLC. All Rights Reserved. 6571 * Licensed under the Apache License, Version 2.0 (the "License"); 6572 * you may not use this file except in compliance with the License. 6573 * You may obtain a copy of the License at 6574 * 6575 * http://www.apache.org/licenses/LICENSE-2.0 6576 * 6577 * Unless required by applicable law or agreed to in writing, software 6578 * distributed under the License is distributed on an "AS IS" BASIS, 6579 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6580 * See the License for the specific language governing permissions and 6581 * limitations under the License. 6582 * ============================================================================= 6583 */function xE(n,e,t,r,s,a,o){const i=e[0],c=a[0],l=new Array(c),u=new Array(i),d=e[1];if(c===0){if(i!==0)throw new Error(Lp(i));const y=yt(t,0),b=yt(s,0);return[y,[0,d],b,l,u]}let p=!0,h=0;const m=new Array(c).fill(0);for(let y=0;y<i;++y){const b=n[y*d];if(b<0)throw new Error(Mp(y,b));if(b>=c)throw new Error(Bp(y,b,c));++m[b],p=p&&b>=h,h=b}let g=!0;for(let y=0;y<c;++y){const b=m[y]===0;l[y]=b,g=g&&!b,m[y]=Math.max(m[y],1),y>0&&(m[y]+=m[y-1])}if(g&&p){const y=n,b=r;for(let v=0;v<i;++v)u[v]=v;return[y,[i,d],b,l,u]}else{const y=m[c-1],b=yt(t,y*d),v=yt(s,y),$=new Array(c).fill(0);for(let S=0;S<i;++S){const T=n[S*d],O=$[T],L=(T===0?0:m[T-1])+O;$[T]++;for(let M=0;M<d;++M)b[L*d+M]=n[S*d+M];v[L]=r[S],u[S]=L}for(let S=0;S<c;++S)if($[S]===0){const O=S===0?0:m[S-1];b[O*d+0]=S;for(let L=1;L<d;++L)b[O*d+L]=0;v[O]=o}return[b,[y,d],v,l,u]}}/** 6584 * @license 6585 * Copyright 2021 Google LLC. All Rights Reserved. 6586 * Licensed under the Apache License, Version 2.0 (the "License"); 6587 * you may not use this file except in compliance with the License. 6588 * You may obtain a copy of the License at 6589 * 6590 * http://www.apache.org/licenses/LICENSE-2.0 6591 * 6592 * Unless required by applicable law or agreed to in writing, software 6593 * distributed under the License is distributed on an "AS IS" BASIS, 6594 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6595 * See the License for the specific language governing permissions and 6596 * limitations under the License. 6597 * ============================================================================= 6598 */function wE(n,e,t,r,s){const a=H(r),o=e[0],i=s.length,c=[];let l=1,u=-1;for(let y=0;y<i;++y){const b=s[y];if(b===-1){if(u!==-1)throw new Error(Vp(u,y));u=y,c.push(1)}else{if(b<0)throw new Error(Wp(y,b));l*=b,c.push(b)}}if(u!==-1){if(l<=0)throw new Error(Up());const y=Math.trunc(a/l);if(l*y!==a)throw new Error(zp(r,c));c[u]=y}if(H(c)!==a)throw new Error(Gp(r,c));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 m=[];if(i>0){m[i-1]=1;for(let y=i-2;y>=0;--y)m[y]=m[y+1]*c[y+1]}const g=yt(t,o*i);for(let y=0;y<o;++y){let b=0;for(let v=0;v<p;++v)b+=n[y*p+v]*h[v];for(let v=0;v<i;++v)g[y*i+v]=Math.trunc(b/m[v]),b%=m[v]}return[g,[o,i],c]}/** 6599 * @license 6600 * Copyright 2021 Google LLC. All Rights Reserved. 6601 * Licensed under the Apache License, Version 2.0 (the "License"); 6602 * you may not use this file except in compliance with the License. 6603 * You may obtain a copy of the License at 6604 * 6605 * http://www.apache.org/licenses/LICENSE-2.0 6606 * 6607 * Unless required by applicable law or agreed to in writing, software 6608 * distributed under the License is distributed on an "AS IS" BASIS, 6609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6610 * See the License for the specific language governing permissions and 6611 * limitations under the License. 6612 * ============================================================================= 6613 */function vE(n,e,t,r,s,a=!1,o=0){const i=r.length,c=[e[0],n.length/e[0]],l=c[1],d=i>0?s[i-1]+1:0;if(d<0)throw new Error(wo());const p=e.slice();p[0]=d;const h=p.reduce(($,S)=>$*S,1),m=yt(t,h);if(i===0)return d>0&&m.fill(o),[m,p];if(d<=0)throw new Error(wo());let g=0,y=1,b=0,v=s[g];for(;;){let $=0;if(y<i){if($=s[y],v===$){++y;continue}if(v>=$)throw new Error(Hp())}if(v<0||v>=d)throw new Error(jp(v,d));v>b&&m.fill(o,b*l,v*l);for(let S=g;S<y;++S){const T=r[S];if(T<0||T>=c[0])throw new Error(qp(S,r[S],c[0]));for(let O=0;O<l;O++)m[v*l+O]+=n[T*l+O]}if(a)for(let S=0;S<l;S++)m[v*l+S]/=y-g;if(g=y,++y,b=v+1,v=$,y>i)break}return b<d&&m.fill(o,b*l,d*l),[m,p]}/** 6614 * @license 6615 * Copyright 2020 Google LLC. All Rights Reserved. 6616 * Licensed under the Apache License, Version 2.0 (the License);
6617 * you may not use this file except in compliance with the License. 6618 * You may obtain a copy of the License at 6619 * 6620 * http://www.apache.org/licenses/LICENSE-2.0 6621 * 6622 * Unless required by applicable law or agreed to in writing, software 6623 * distributed under the License is distributed on an AS IS BASIS, 6624 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6625 * See the License for the specific language governing permissions and 6626 * limitations under the License. 6627 * ============================================================================= 6628 */const IE=Cr(n=>Math.sqrt(n));/** 6629 * @license 6630 * Copyright 2020 Google LLC. All Rights Reserved. 6631 * Licensed under the Apache License, Version 2.0 (the "License"); 6632 * you may not use this file except in compliance with the License. 6633 * You may obtain a copy of the License at 6634 * 6635 * http://www.apache.org/licenses/LICENSE-2.0 6636 * 6637 * Unless required by applicable law or agreed to in writing, software 6638 * distributed under the License is distributed on an "AS IS" BASIS, 6639 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6640 * See the License for the specific language governing permissions and 6641 * limitations under the License. 6642 * ============================================================================= 6643 */const $E=Yt((n,e)=>{const t=n-e;return t*t});/** 6644 * @license 6645 * Copyright 2023 Google LLC. 6646 * Licensed under the Apache License, Version 2.0 (the "License"); 6647 * you may not use this file except in compliance with the License. 6648 * You may obtain a copy of the License at 6649 * 6650 * http://www.apache.org/licenses/LICENSE-2.0 6651 * 6652 * Unless required by applicable law or agreed to in writing, software 6653 * distributed under the License is distributed on an "AS IS" BASIS, 6654 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6655 * See the License for the specific language governing permissions and 6656 * limitations under the License. 6657 * ============================================================================= 6658 */const SE=Cr((n,e)=>{const{pattern:t,replaceGlobal:r,rewrite:s}=e;return n.replace(new RegExp(t,r?"g":""),s)});/** 6659 * @license 6660 * Copyright 2020 Google LLC. All Rights Reserved. 6661 * Licensed under the Apache License, Version 2.0 (the "License"); 6662 * you may not use this file except in compliance with the License. 6663 * You may obtain a copy of the License at 6664 * 6665 * http://www.apache.org/licenses/LICENSE-2.0 6666 * 6667 * Unless required by applicable law or agreed to in writing, software 6668 * distributed under the License is distributed on an "AS IS" BASIS, 6669 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6670 * See the License for the specific language governing permissions and 6671 * limitations under the License. 6672 * ============================================================================= 6673 */function CE(n,e,t,r){const s=at(n,e.dtype);for(let a=0;a<s.size;a++){const o=s.indexToLoc(a),i=new Array(o.length);for(let c=0;c<i.length;c++)i[c]=o[c]*t[c]+r[c];s.set(e.get(...i),...o)}return s}/** 6674 * @license 6675 * Copyright 2021 Google LLC. All Rights Reserved. 6676 * Licensed under the Apache License, Version 2.0 (the "License"); 6677 * you may not use this file except in compliance with the License. 6678 * You may obtain a copy of the License at 6679 * 6680 * http://www.apache.org/licenses/LICENSE-2.0 6681 * 6682 * Unless required by applicable law or agreed to in writing, software 6683 * distributed under the License is distributed on an "AS IS" BASIS, 6684 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6685 * See the License for the specific language governing permissions and 6686 * limitations under the License. 6687 * ============================================================================= 6688 */class _E{constructor(e,t,r,s,a,o){this.separator=vs(e),this.nGramWidths=t,this.leftPad=vs(r),this.rightPad=vs(s),this.padWidth=a,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,s,a,o){for(let i=0;i<a;++i){const c=this.getPadWidth(o),l=Math.max(0,c-i),u=Math.max(0,c-(a-(i+1))),d=o-(l+u),p=t+(l>0?0:i-c);let h=0;h+=l*this.leftPad.length;for(let v=0;v<d;++v)h+=e[p+v].length;h+=u*this.rightPad.length;const m=l+u+d-1;h+=m*this.separator.length,r[s+i]=new Uint8Array(h);const g=r[s+i];let y=0;const b=v=>v.forEach($=>g[y++]=$);for(let v=0;v<l;++v)b(this.leftPad),b(this.separator);for(let v=0;v<d-1;++v)b(e[p+v]),b(this.separator);if(d>0){b(e[p+d-1]);for(let v=0;v<u;++v)b(this.separator),b(this.rightPad)}else{for(let v=0;v<u-1;++v)b(this.rightPad),b(this.separator);b(this.rightPad)}}}compute(e,t){const r=e.length,s=t.length;if(s>0){let c=t[0];if(c!==0)throw new Error(`First split value must be 0, got ${c}`);for(let l=1;l<s;++l){let u=t[l]>=c;if(u=u&&t[l]<=r,!u)throw new Error(`Invalid split value ${t[l]}, must be in [${c}, ${r}]`);c=t[l]}if(c!==r)throw new Error(`Last split value must be data size. Expected ${r}, got ${c}`)}const a=s-1,o=yt("int32",s);if(r===0||s===0){const c=new Array(r);for(let l=0;l<=a;++l)o[l]=0;return[c,o]}o[0]=0;for(let c=1;c<=a;++c){const l=t[c]-t[c-1];let u=0;this.nGramWidths.forEach(d=>{u+=this.getNumNGrams(l,d)}),this.preserveShort&&l>0&&u===0&&(u=1),o[c]=o[c-1]+u}const i=new Array(o[a]);for(let c=0;c<a;++c){const l=t[c];let u=o[c];if(this.nGramWidths.forEach(d=>{const p=t[c+1]-t[c],h=this.getNumNGrams(p,d);this.createNGrams(e,l,i,u,h,d),u+=h}),this.preserveShort&&u===o[c]){const d=t[c+1]-t[c];if(d===0)continue;const p=d+2*this.padWidth,h=1;this.createNGrams(e,l,i,u,h,p)}}return[i,o]}}function Wy(n,e,t,r,s,a,o,i){return new _E(t,r,s,a,o,i).compute(n,e)}/** 6689 * @license 6690 * Copyright 2021 Google LLC. All Rights Reserved. 6691 * Licensed under the Apache License, Version 2.0 (the "License");
6692 * you may not use this file except in compliance with the License. 6693 * You may obtain a copy of the License at 6694 * 6695 * http://www.apache.org/licenses/LICENSE-2.0 6696 * 6697 * Unless required by applicable law or agreed to in writing, software 6698 * distributed under the License is distributed on an "AS IS" BASIS, 6699 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6700 * See the License for the specific language governing permissions and 6701 * limitations under the License. 6702 * ============================================================================= 6703 */function NE(n,e,t,r){if(!n.length)return;if(e.length===0){for(let a=0;a<n.length;++a)r.push(n.subarray(a,a+1));return}if(e.length===1){const a=e[0];let o=n.indexOf(a);for(;o!==-1;){const i=n.subarray(0,o);(!t||i.length!==0)&&r.push(i),n=n.subarray(o+1),o=n.indexOf(a)}(!t||n.length!==0)&&r.push(n);return}let s=0;for(let a=0;a<n.length+1;a++)if(a===n.length||e.indexOf(n[a])!==-1){const o=n.subarray(s,a);(!t||o.length!==0)&&r.push(o),s=a+1}}function Uy(n,e,t){const r=n.length,s=[];let a=0,o=0;const i=new Array(r);for(let p=0;p<r;++p){const h=s.length;NE(n[p],e,t,s);const m=s.length-h;i[p]=m,a+=m,o=Math.max(o,m)}const c=yt("int32",a*2),l=new Array(a),u=[r,o];let d=0;for(let p=0;p<r;++p)for(let h=0;h<i[p];++h)c[d*2]=p,c[d*2+1]=h,l[d]=s[d],++d;return[c,l,u]}/** 6704 * @license 6705 * Copyright 2021 Google LLC. All Rights Reserved. 6706 * Licensed under the Apache License, Version 2.0 (the "License"); 6707 * you may not use this file except in compliance with the License. 6708 * You may obtain a copy of the License at 6709 * 6710 * http://www.apache.org/licenses/LICENSE-2.0 6711 * 6712 * Unless required by applicable law or agreed to in writing, software 6713 * distributed under the License is distributed on an "AS IS" BASIS, 6714 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6715 * See the License for the specific language governing permissions and 6716 * limitations under the License. 6717 * ============================================================================= 6718 */function zy(n,e){const t=yt("int32",n.length);for(let r=0;r<n.length;++r)t[r]=nw(n[r]).modulo(e).getLowBitsUnsigned();return t}/** 6719 * @license 6720 * Copyright 2020 Google LLC. All Rights Reserved. 6721 * Licensed under the Apache License, Version 2.0 (the "License"); 6722 * you may not use this file except in compliance with the License. 6723 * You may obtain a copy of the License at 6724 * 6725 * http://www.apache.org/licenses/LICENSE-2.0 6726 * 6727 * Unless required by applicable law or agreed to in writing, software 6728 * distributed under the License is distributed on an "AS IS" BASIS, 6729 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6730 * See the License for the specific language governing permissions and 6731 * limitations under the License. 6732 * ============================================================================= 6733 */const TE=Yt((n,e)=>n-e);/** 6734 * @license 6735 * Copyright 2019 Google LLC. All Rights Reserved. 6736 * Licensed under the Apache License, Version 2.0 (the "License"); 6737 * you may not use this file except in compliance with the License. 6738 * You may obtain a copy of the License at 6739 * 6740 * http://www.apache.org/licenses/LICENSE-2.0 6741 * 6742 * Unless required by applicable law or agreed to in writing, software 6743 * distributed under the License is distributed on an "AS IS" BASIS, 6744 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6745 * See the License for the specific language governing permissions and 6746 * limitations under the License. 6747 * ============================================================================= 6748 */function kE(n,e){const t=new Array(n.rank);for(let s=0;s<t.length;s++)t[s]=n.shape[s]*e[s];const r=at(t,n.dtype);for(let s=0;s<r.values.length;++s){const a=r.indexToLoc(s),o=new Array(n.rank);for(let c=0;c<o.length;c++)o[c]=a[c]%n.shape[c];const i=n.locToIndex(o);r.values[s]=n.values[i]}return r}/** 6749 * @license 6750 * Copyright 2020 Google LLC. All Rights Reserved. 6751 * Licensed under the Apache License, Version 2.0 (the "License"); 6752 * you may not use this file except in compliance with the License. 6753 * You may obtain a copy of the License at 6754 * 6755 * http://www.apache.org/licenses/LICENSE-2.0 6756 * 6757 * Unless required by applicable law or agreed to in writing, softw
vendor: 4,457 bytes, lines 6757-6796
6757are 6758 * distributed under the License is distributed on an "AS IS" BASIS, 6759 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6760 * See the License for the specific language governing permissions and 6761 * limitations under the License. 6762 * ============================================================================= 6763 */const so=(n,e)=>{const t=e.value-n.value;return t===0?n.index-e.index:t};function Gy(n,e,t=0,r=n.length-1){for(;r>t;){if(r-t>600){const i=r-t+1,c=e-t+1,l=Math.log(i),u=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*u*(i-u)/i)*Math.sign(c-i/2),p=Math.max(t,Math.floor(e-c*u/i+d)),h=Math.min(r,Math.floor(e+(i-c)*u/i+d));Gy(n,e,p,h)}const s=n[e];let a=t,o=r;for(Ja(n,t,e),so(n[r],s)>0&&Ja(n,t,r);a<o;){for(Ja(n,a,o),a++,o--;so(n[a],s)<0;)a=a+1;for(;so(n[o],s)>0;)o=o-1}so(n[t],s)===0?Ja(n,t,o):(o=o+1,Ja(n,o,r)),o<=e&&(t=o+1),e<=o&&(r=o-1)}}function EE(n,e,t,r,s){const a=e[e.length-1],[o,i]=[n.length/a,a],c=Wr(t,o*r),l=Wr("int32",o*r);for(let d=0;d<o;d++){const p=d*i,h=n.subarray(p,p+i);let m=new Array(h.length);h.forEach((v,$)=>m[$]={value:v,index:$}),r<m.length&&(Gy(m,r),m=m.slice(0,r)),s&&m.sort(so);const g=d*r,y=c.subarray(g,g+r),b=l.subarray(g,g+r);for(let v=0;v<r;v++)y[v]=m[v].value,b[v]=m[v].index}const u=e.slice();return u[u.length-1]=r,[at(u,t,c),at(u,"int32",l)]}/** 6764 * @license 6765 * Copyright 2020 Google LLC. All Rights Reserved. 6766 * Licensed under the Apache License, Version 2.0 (the "License"); 6767 * you may not use this file except in compliance with the License. 6768 * You may obtain a copy of the License at 6769 * 6770 * http://www.apache.org/licenses/LICENSE-2.0 6771 * 6772 * Unless required by applicable law or agreed to in writing, software 6773 * distributed under the License is distributed on an "AS IS" BASIS, 6774 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6775 * See the License for the specific language governing permissions and 6776 * limitations under the License. 6777 * ============================================================================= 6778 */function Hy(n,e,t,r){const s=ot(e,t)[0],a=[1,t[0],1];for(let m=0;m<s;m++)a[0]*=t[m];a[1]=t[s];for(let m=s+1;m<t.length;m++)a[2]*=t[m];const o=new Map,i=new Int32Array(t[s]),c=new $a(a,r,n),l=[],u=a[0]===1&&a[2]===1;for(let m=0;m<t[s];m++){let g;if(u)g=n[m].toString();else{const b=[];for(let v=0;v<a[0];v++)for(let $=0;$<a[2];$++)b.push(c.get(v,m,$));g=b.join(",")}const y=o.get(g);if(y!=null)i[m]=y;else{const b=o.size;o.set(g,b),i[m]=b,l.push(m)}}const d=a.slice();d[1]=o.size;const p=new $a(d,r);l.forEach((m,g)=>{for(let y=0;y<a[0];y++)for(let b=0;b<a[2];b++)p.set(c.get(y,m,b),y,g,b)});const h=t.slice();return h[s]=d[1],{outputValues:p.values,outputShape:h,indices:i}}/** 6779 * @license 6780 * Copyright 2020 Google LLC. All Rights Reserved. 6781 * Licensed under the Apache License, Version 2.0 (the "License"); 6782 * you may not use this file except in compliance with the License. 6783 * You may obtain a copy of the License at 6784 * 6785 * http://www.apache.org/licenses/LICENSE-2.0 6786 * 6787 * Unless required by applicable law or agreed to in writing, software 6788 * distributed under the License is distributed on an "AS IS" BASIS, 6789 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6790 * See the License for the specific language governing permissions and 6791 * limitations under the License. 6792 * ============================================================================= 6793 */const RE=Object.freeze(Object.defineProperty({__proto__:null,simpleAbsImpl:Ok,addImpl:Pk,bincountImpl:Lk,bincountReduceImpl:Mk,bitwiseAndImpl:Bk,castImpl:Fk,ceilImpl:Vk,concatImpl:My,equalImpl:Wk,expImpl:Uk,expm1Impl:zk,floorImpl:Gk,floorDivImpl:Hk,gatherNdImpl:jk,gatherV2Impl:qk,greaterImpl:Kk,greaterEqualImpl:Xk,lessImpl:Yk,lessEqualImpl:Qk,linSpaceImpl:Zk,logImpl:Jk,maxImpl:eE,maximumImpl:tE,minimumImpl:nE,multiplyImpl:By,negImpl:rE,notEqualImpl:sE,prodImpl:oE,raggedGatherImpl:hE,raggedRangeImpl:fE,raggedTensorToTensorImpl:mE,rangeImpl:Vy,rsqrtImpl:gE,scatterImpl:yE,sigmoidImpl:bE,sliceImpl:tl,sparseFillEmptyRowsImpl:xE,sparseReshapeImpl:wE,sparseSegmentReductionImpl:vE,sqrtImpl:IE,squaredDifferenceImpl:$E,staticRegexReplaceImpl:SE,stridedSliceImpl:CE,stringNGramsImpl:Wy,stringSplitImpl:Uy,stringToHashBucketFastImpl:zy,subImpl:TE,tileImpl:kE,topKImpl:EE,transposeImpl:aE,uniqueImpl:Hy},Symbol.toStringTag,{value:"Module"}));/** 6794 * @license 6795 * Copyright 2020 Google LLC. All Rights Reserved. 6796 * Licensed under the Apache License, Version 2.0 (the "License");
6797 * you may not use this file except in compliance with the License. 6798 * You may obtain a copy of the License at 6799 * 6800 * http://www.apache.org/licenses/LICENSE-2.0 6801 * 6802 * Unless required by applicable law or agreed to in writing, software 6803 * distributed under the License is distributed on an "AS IS" BASIS, 6804 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6805 * See the License for the specific language governing permissions and 6806 * limitations under the License. 6807 * ============================================================================= 6808 */const{addImpl:AE,bincountImpl:jy,bincountReduceImpl:DE,bitwiseAndImpl:OE,castImpl:FE,ceilImpl:PE,concatImpl:LE,equalImpl:ME,expImpl:BE,expm1Impl:VE,floorImpl:WE,gatherNdImpl:UE,gatherV2Impl:zE,greaterImpl:GE,greaterEqualImpl:HE,lessImpl:jE,lessEqualImpl:qE,linSpaceImpl:KE,logImpl:XE,maxImpl:YE,maximumImpl:QE,minimumImpl:ZE,multiplyImpl:JE,negImpl:eR,notEqualImpl:tR,prodImpl:nR,raggedGatherImpl:rR,raggedRangeImpl:sR,raggedTensorToTensorImpl:aR,rangeImpl:oR,rsqrtImpl:iR,scatterImpl:uR,sigmoidImpl:cR,simpleAbsImpl:qy,sliceImpl:lR,sparseFillEmptyRowsImpl:dR,sparseReshapeImpl:pR,sparseSegmentReductionImpl:Ky,sqrtImpl:hR,staticRegexReplaceImpl:fR,stridedSliceImpl:mR,stringNGramsImpl:gR,stringSplitImpl:yR,stringToHashBucketFastImpl:bR,subImpl:xR,tileImpl:wR,topKImpl:vR,transposeImpl:eh,uniqueImpl:IR}=RE;/** 6809 * @license 6810 * Copyright 2018 Google LLC. All Rights Reserved. 6811 * Licensed under the Apache License, Version 2.0 (the "License"); 6812 * you may not use this file except in compliance with the License. 6813 * You may obtain a copy of the License at 6814 * 6815 * http://www.apache.org/licenses/LICENSE-2.0 6816 * 6817 * Unless required by applicable law or agreed to in writing, software 6818 * distributed under the License is distributed on an "AS IS" BASIS, 6819 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6820 * See the License for the specific language governing permissions and 6821 * limitations under the License. 6822 * ============================================================================= 6823 */function Xy(n,e){return["x","y","z","w","u","v"].slice(0,e).map(t=>`${n}.${t}`)}function Bt(n,e){return e===1?[n]:Xy(n,e)}function $R(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}/** 6824 * @license 6825 * Copyright 2018 Google LLC. All Rights Reserved. 6826 * Licensed under the Apache License, Version 2.0 (the "License"); 6827 * you may not use this file except in compliance with the License. 6828 * You may obtain a copy of the License at 6829 * 6830 * http://www.apache.org/licenses/LICENSE-2.0 6831 * 6832 * Unless required by applicable law or agreed to in writing, software 6833 * distributed under the License is distributed on an "AS IS" BASIS, 6834 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6835 * See the License for the specific language governing permissions and 6836 * limitations under the License. 6837 * ============================================================================= 6838 */class SR{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=Dt(this.outputShape.length),this.rank===0)this.userCode=` 6839 void main() { 6840 setOutput(vec4(getA(), 0., 0., 0.)); 6841 } 6842 `;else{const t=Bt("rc",this.rank),r=ze(this.rank),s=this.getOutOfBoundsCondition(t),a=this.getSetup(t),o=this.getOutput(t);this.userCode=` 6843 void main() { 6844 ${r} rc = getOutputCoords(); 6845 6846 if(${s}) { 6847 setOutput(vec4(0)); 6848 } else { 6849 ${a} 6850 6851 setOutput(vec4(${o})); 6852 } 6853 } 6854 `}}getSourceCoordsArr(e){const t=[];for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){let a=`${r===0?"r":"rp1"}, ${s===0?"c":"cp1"}`;for(let o=2;o<this.rank;o++)a=`${e[e.length-1-o]},`+a;t.push(a)}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],s=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return` 6855 int r = ${t[0]}; 6856 int c = ${t[1]}; 6857 int rp1 = r + 1; 6858 int cp1 = c + 1; 6859 6860 bool cEdge = cp1 >= ${r}; 6861 bool rEdge = rp1 >= ${s}; 6862 `}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]}), 6863 cEdge ? 0. : getA(${t[1]}),
6864 rEdge ? 0. : getA(${t[2]}), 6865 rEdge || cEdge ? 0. : getA(${t[3]})`}}/** 6866 * @license 6867 * Copyright 2018 Google LLC. All Rights Reserved. 6868 * Licensed under the Apache License, Version 2.0 (the "License"); 6869 * you may not use this file except in compliance with the License. 6870 * You may obtain a copy of the License at 6871 * 6872 * http://www.apache.org/licenses/LICENSE-2.0 6873 * 6874 * Unless required by applicable law or agreed to in writing, software 6875 * distributed under the License is distributed on an "AS IS" BASIS, 6876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6877 * See the License for the specific language governing permissions and 6878 * limitations under the License. 6879 * ============================================================================= 6880 */class Yy{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length);let r="";for(let s=0;s<4;s++){let a="thisRC = rc;";s%2===1&&(a+="thisRC.z += 1;"),s>1&&(a+="thisRC.y += 1;"),r+=` 6881 ${a} 6882 ${s>0?"if(thisRC.y < rows && thisRC.z < cols){":""} 6883 int flatIndex = getFlatIndex(thisRC); 6884 6885 ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex); 6886 vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z)); 6887 6888 result[${s}] = 6889 getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); 6890 ${s>0?"}":""} 6891 `}this.userCode=` 6892 ${CR(t,this.enableShapeUniforms)} 6893 ${this.enableShapeUniforms?Zp():Qp(e)} 6894 6895 void main() { 6896 ivec3 rc = getOutputCoords(); 6897 6898 vec4 result = vec4(0.); 6899 6900 ivec3 thisRC; 6901 int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]}; 6902 int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]}; 6903 6904 ${r} 6905 6906 setOutput(result); 6907 } 6908 `}}function CR(n,e){return` 6909 ivec3 inputCoordsFromReshapedOutCoords(int index) { 6910 ${e?CT(["r","c","d"],"inputShape"):Ws(["r","c","d"],n)} 6911 return ivec3(r, c, d); 6912 } 6913 `}/** 6914 * @license 6915 * Copyright 2017 Google LLC. All Rights Reserved. 6916 * Licensed under the Apache License, Version 2.0 (the "License"); 6917 * you may not use this file except in compliance with the License. 6918 * You may obtain a copy of the License at 6919 * 6920 * http://www.apache.org/licenses/LICENSE-2.0 6921 * 6922 * Unless required by applicable law or agreed to in writing, software 6923 * distributed under the License is distributed on an "AS IS" BASIS, 6924 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6925 * See the License for the specific language governing permissions and 6926 * limitations under the License. 6927 * ============================================================================= 6928 */class _R{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(e,t,r){const s=rf(t,r),a=sf(e,s,r);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const o=nf(e,s,this.gpgpu.gl,this.gpgpu.textureConfig,r);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();const c=this.freeTextures[a].pop();return this.usedTextures[a].push(c),c}let i;return s===wt.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):s===wt.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):s===wt.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):s===wt.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):s===wt.PACKED_4X1_UNSIGNED_BYTE&&(i=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(i),this.numUsedTextures++,this._numBytesAllocated+=o,this.log(),i}releaseTexture(e,t,r,s){if(this.freeTextures==null)return;const a=rf(r,s),o=sf(t,a,s);o in this.freeTextures||(this.freeTextures[o]=[]);const i=nf(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,s),c=U().getNumber("WEBGL_DELET
6928E_TEXTURE_THRESHOLD");c!==-1&&this._numBytesAllocated>c?(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],u=l&&l.indexOf(e);if(u==null||u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l[u]=l[l.length-1],l.pop(),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 NR(n,e){const t=n;if(e===t.R32F)return 4;if(e===t.R16F)return 2;if(e===t.RGBA32F)return 16;if(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 nf(n,e,t,r,s){const a=TR(e,r);let o;if(s){const[c,l]=Aa(n[0],n[1]);o=c*l}else{const[c,l]=Fo(n[0],n[1]);o=c*l}const i=NR(t,a);return o*i}function TR(n,e){switch(n){case wt.PACKED_2X2_FLOAT32:return Py(e);case wt.PACKED_2X2_FLOAT16:return Ly(e);case wt.UNPACKED_FLOAT32:return Dy(e);case wt.UNPACKED_FLOAT16:return Oy(e);case wt.PACKED_4X1_UNSIGNED_BYTE:return Fy(e);default:throw new Error(`Unknown physical texture type ${n}`)}}function kR(n){return U().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?wt.PACKED_2X2_FLOAT32:wt.UNPACKED_FLOAT32:n?wt.PACKED_2X2_FLOAT16:wt.UNPACKED_FLOAT16}function rf(n,e){if(n===pn.UPLOAD)return wt.PACKED_2X2_FLOAT32;if(n===pn.RENDER||n==null)return kR(e);if(n===pn.DOWNLOAD||n===pn.PIXELS)return wt.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${n}`)}function sf(n,e,t){return`${n[0]}_${n[1]}_${e}_${t}`}/** 6929 * @license 6930 * Copyright 2017 Google LLC. All Rights Reserved. 6931 * Licensed under the Apache License, Version 2.0 (the "License"); 6932 * you may not use this file except in compliance with the License. 6933 * You may obtain a copy of the License at 6934 * 6935 * http://www.apache.org/licenses/LICENSE-2.0 6936 * 6937 * Unless required by applicable law or agreed to in writing, software 6938 * distributed under the License is distributed on an "AS IS" BASIS, 6939 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6940 * See the License for the specific language governing permissions and 6941 * limitations under the License. 6942 * ============================================================================= 6943 */class sr{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length),this.userCode=` 6944 float unaryOperation(float x) { 6945 ${t} 6946 } 6947 6948 void main() { 6949 float x = getAAtOutCoords(); 6950 float y = unaryOperation(x); 6951 6952 setOutput(y); 6953 } 6954 `}}const Rn="if (isnan(x)) return x;",ER="return x;",af="return abs(x);",RR="return (x >= 0.0) ? x : (exp(x) - 1.0);",AR=Rn+` 6955 return (x < 0.0) ? 0.0 : x; 6956`,DR=Rn+` 6957 return (x < 0.0) ? 0.0 : min(6.0, x); 6958`,Or="return x;",OR="return 1.0 / (1.0 + exp(-1.0 * x));";/** 6959 * @license 6960 * Copyright 2018 Google LLC. All Rights Reserved. 6961 * Licensed under the Apache License, Version 2.0 (the "License"); 6962 * you may not use this file except in compliance with the License. 6963 * You may obtain a copy of the License at 6964 * 6965 * http://www.apache.org/licenses/LICENSE-2.0 6966 * 6967 * Unless required by applicable law or agreed to in writing, softw
vendor: 21,693 bytes, lines 6967-7068
6967are 6968 * distributed under the License is distributed on an "AS IS" BASIS, 6969 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6970 * See the License for the specific language governing permissions and 6971 * limitations under the License. 6972 * ============================================================================= 6973 */const FR="return x;",PR=` 6974 vec4 result; 6975 6976 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 6977 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 6978 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 6979 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 6980 6981 return result; 6982`,LR=` 6983 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 6984 bvec4 isNaN = isnan(x); 6985 6986 result.r = isNaN.r ? x.r : result.r; 6987 result.g = isNaN.g ? x.g : result.g; 6988 result.b = isNaN.b ? x.b : result.b; 6989 result.a = isNaN.a ? x.a : result.a; 6990 6991 return result; 6992`,MR=` 6993 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 6994 bvec4 isNaN = isnan(x); 6995 6996 result.r = isNaN.r ? x.r : result.r; 6997 result.g = isNaN.g ? x.g : result.g; 6998 result.b = isNaN.b ? x.b : result.b; 6999 result.a = isNaN.a ? x.a : result.a; 7000 7001 return result; 7002`,BR="return 1.0 / (1.0 + exp(-1.0 * x));";class Lr{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length),this.userCode=` 7003 vec4 unaryOperation(vec4 x) { 7004 ${t} 7005 } 7006 7007 void main() { 7008 vec4 x = getAAtOutCoords(); 7009 vec4 y = unaryOperation(x); 7010 7011 setOutput(y); 7012 } 7013 `}}/** 7014 * @license 7015 * Copyright 2018 Google LLC. All Rights Reserved. 7016 * Licensed under the Apache License, Version 2.0 (the "License"); 7017 * you may not use this file except in compliance with the License. 7018 * You may obtain a copy of the License at 7019 * 7020 * http://www.apache.org/licenses/LICENSE-2.0 7021 * 7022 * Unless required by applicable law or agreed to in writing, software 7023 * distributed under the License is distributed on an "AS IS" BASIS, 7024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7025 * See the License for the specific language governing permissions and 7026 * limitations under the License. 7027 * ============================================================================= 7028 */class VR{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=Dt(this.outputShape.length);const t=e.length,r=Bt("rc",t),s=ze(t),a=$R(t,r),o=r.slice(-2),i=t<=1?"rc":`vec2(${o.join(",")})`;this.userCode=` 7029 void main() { 7030 ${s} rc = getOutputCoords(); 7031 vec4 packedInput = getA(${a}); 7032 7033 setOutput(getChannel(packedInput, ${i})); 7034 } 7035 `}}/** 7036 * @license 7037 * Copyright 2017 Google LLC. All Rights Reserved. 7038 * Licensed under the Apache License, Version 2.0 (the "License"); 7039 * you may not use this file except in compliance with the License. 7040 * You may obtain a copy of the License at 7041 * 7042 * http://www.apache.org/licenses/LICENSE-2.0 7043 * 7044 * Unless required by applicable law or agreed to in writing, software 7045 * distributed under the License is distributed on an "AS IS" BASIS, 7046 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7047 * See the License for the specific language governing permissions and 7048 * limitations under the License. 7049 * ============================================================================= 7050 */const WR=Mg,UR=1e-7,zR=1e-4,ci={};function GR(n){return n in ci||(ci[n]={}),ci[n]}const HR=U().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),jR=600;function qR(){return U().global.screen==null?1024:U().global.screen.height*U().global.screen.width*window.devicePixelRatio*jR/1024/1024}class ec extends Il{nextDataId(){return ec.nextDataId++}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,!U().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(e!=null){if(e instanceof xc)t=e;else{const r=qn(U().getNumber("WEBGL_VERSION"),e);t=new xc(r)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const r=qn(U().getNumber("WEBGL_VERSION"));t=new xc(r),this.binaryCache=GR(U().getNumber("WEBGL_VERSION")),this.gpgpuCreatedLocally=!0}this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new _R(this.gpgpu),this.numMBBeforeWarning=qR(),this.texData=new zf(this,fr())}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(e,t,r,s,a,o){const i=this.makeTensorInfo(t,r),c=this.texData.get(i.dataId);c.isPacked=!1,c.texture={texture:e,texShape:[s,a]},c.texShape=[s,a];const l=ii(t),u=new Qh(l,!1,o),d=this.runWebGLProgram(u,[i],r,[[s,a]]);return d.shape=t,c.texture=null,this.disposeIntermediateTensorInfo(i),d.dataId}write(e,t,r){if((U().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||U().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 s={id:this.nextDataId()};return this.texData.set(s,{shape:t,dtype:r,values:e,usage:pn.UPLOAD,refCount:1}),s}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,s,a){if(U().getBool("DEBUG")&&this.checkNumericalProblems(t),s==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:r,dtype:s,values:t,usage:pn.UPLOAD,refCount:a})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:r,dtype:s,complexTensorInfos:a,slice:o,shape:i,isPacked:c}=t;if(o!=null){let p;c?p=new Lr(i,Or):p=new sr(i,Or);const h=this.runWebGLProgram(p,[{dataId:e,shape:i,dtype:s}],s),m=this.readSync(h.dataId);return this.disposeIntermediateTensorInfo(h),m}if(r!=null)return this.convertAndCacheOnCPU(e);if(s==="string")return r;const l=this.activeTimers!=null;let u;l&&(u=dn());let d;if(s==="complex64"){const p=this.readSync(a.real.dataId),h=this.readSync(a.imag.dataId);d=Jc(p,h)}else d=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=dn()-u),this.convertAndCacheOnCPU(e,d)}async read(e){if(this.pendingRead.has(e)){const m=this.pendingRead.get(e);return new Promise(g=>m.push(g))}const t=this.texData.get(e),{values:r,shape:s,slice:a,dtype:o,complexTensorInfos:i,isPacked:c}=t;if(a!=null){let m;c?m=new Lr(s,Or):m=new sr(s,Or);const g=this.runWebGLProgram(m,[{dataId:e,shape:s,dtype:o}],o),y=this.read(g.dataId);return this.disposeIntermediateTensorInfo(g),y}if(r!=null)return this.convertAndCacheOnCPU(e);if(U().getBool("DEBUG")&&!U().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&U().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l=null,u;if(o!=="complex64"&&U().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const m=this.texData.get(u.dataId);l=this.gpgpu.createBufferFromTexture(m.texture.texture,...si(s))}this.pendingRead.set(e,[]),o!=="complex64"&&await this.gpgpu.createAndWaitForFence();let d;if(o==="complex64"){const m=await Promise.all([this.read(i.real.dataId),this.read(i.imag.dataId)]),g=m[0],y=m[1];d=Jc(g,y)}else if(l==null)d=this.getValuesFromTexture(e);else{const m=H(s);d=this.gpgpu.downloadFloat32MatrixFromBuffer(l,m)}if(u!=null&&this.disposeIntermediateTensorInfo(u),l!=null){const m=this.gpgpu.gl;oe(m,()=>m.deleteBuffer(l))}const p=this.convertAndCacheOnCPU(e,d),h=this.pendingRead.get(e);return this.pendingRead.delete(e),h.forEach(m=>m(p)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&fr().removeDataId(e,this),this.pendingDeletes--),p}readToGPU(e,t={}){const r=this.texData.get(e),{values:s,shape:a,slice:o,dtype:i,isPacked:c,texture:l}=r;if(i==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(o!=null){let h;c?h=new Lr(a,Or):h=new sr(a,Or);const m=this.runWebGLProgram(h,[{dataId:e,shape:a,dtype:i}],i),g=this.readToGPU(m,t);return this.disposeIntermediateTensorInfo(m),g}if(l==null)throw s!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const u=this.decode(e,t.customTexShape),d=fr().makeTensorFromTensorInfo(u),p=this.texData.get(u.dataId);return Object.assign({tensorRef:d},p.texture)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const r=t.map(s=>Ia(s));return at(e.shape,e.dtype,r)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return at(e.shape,e.dtype,t)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){const r=e[t];if(!ZN(r))throw U().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:s}=this.texData.get(e),a=H(t);if(U().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const p=this.decode(e),h=this.texData.get(p.dataId),m=this.gpgpu.downloadMatrixFromPackedTexture(h.texture.texture,...si(t)).subarray(0,a);return this.disposeIntermediateTensorInfo(p),m}const o=U().getBool("WEBGL_PACK")&&s===!0,i=o?ii(t):t,c=o?new fk(i):new hk(i),l=this.runWebGLProgram(c,[{shape:i,dtype:r,dataId:e}],"float32"),u=this.texData.get(l.dataId),d=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(u.texture.texture,u.texShape[0],u.texShape[1]).subarray(0,a);return this.disposeIntermediateTensorInfo(l),d}timerAvailable(){return U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(e){const t=this.activeTimers,r=[];let s=!1;this.programTimersStack==null?(this.programTimersStack=r,s=!0):this.activeTimers.push(r),this.activeTimers=r,e();const a=Cs(this.activeTimers.map(c=>c.query)).filter(c=>c!=null),o=Cs(this.activeTimers.map(c=>c.name)).filter(c=>c!=null);this.activeTimers=t,s&&(this.programTimersStack=null);const i={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const c=await Promise.all(a);i.kernelMs=A0(c),i.getExtraProfileInfo=()=>c.map((l,u)=>({name:o[u],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 U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:dn(),endMs:null}}endTimer(e){return U().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=dn(),e)}async getQueryTime(e){if(U().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:s,usage:a,isPacked:o,slice:i}=this.texData.get(e),c=i&&i.origDataId||e,l=this.dataRefCount.get(c);l>1?this.dataRefCount.set(c,l-1):(this.dataRefCount.delete(c),t!=null&&(this.numBytesInGPU-=this.computeBytes(s,r),this.textureManager.releaseTexture(t,s,a,o)));const u=this.texData.get(e);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=HR){return U().getBool("WEBGL_CPU_FORWARD")&&e.every(r=>this.texData.get(r.dataId).texture==null&&H(r.shape)<t)}getGPGPUContext(){return this.gpgpu}where(e){Un("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return WR(e.shape,t)}packedUnaryOp(e,t,r){const s=new Lr(e.shape,t),a=this.compileAndRun(s,[e],r);return fr().makeTensorFromTensorInfo(a)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){const s=qy(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,s)}if(U().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,af,e.dtype);const t=new sr(e.shape,af),r=this.compileAndRun(t,[e]);return fr().makeTensorFromTensorInfo(r)}makeTensorInfo(e,t,r){let s;if(t==="string"&&r!=null&&r.length>0&&Pi(r[0])){const a=r.map(o=>vs(o));s=this.write(a,e,t)}else s=this.write(r,e,t);return this.texData.get(s).usage=null,{dataId:s,shape:e,dtype:t}}makeOutput(e,t,r){return fr().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,r),this)}unpackTensor(e){const t=new VR(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new SR(e.shape),r=!0;return this.runWebGLProgram(t,[e],e.dtype,null,r)}packedReshape(e,t){const r=[_a(e.shape),...Na(e.shape)],s={dtype:e.dtype,shape:r,dataId:e.dataId},a=[_a(t),...Na(t)],o=new Yy(a,r),i=!0,c=[r],l=this.runWebGLProgram(o,[s],e.dtype,c,i);return{dataId:l.dataId,shape:t,dtype:l.dtype}}decode(e,t){const r=this.texData.get(e),{isPacked:s,shape:a,dtype:o}=r;if(t!=null){const p=H(a),h=t[0]*t[1]*4;N(p<=h,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const i=ii(a);let c;s?c=new pk(i):c=new dk(i);const l=!0,u=[t!=null?t:si(i)],d=this.runWebGLProgram(c,[{shape:i,dtype:o,dataId:e}],o,u,l,t);return{dtype:o,shape:a,dataId:d.dataId}}runWebGLProgram(e,t,r,s,a=!1,o){const i=this.makeTensorInfo(e.outputShape,r),c=this.texData.get(i.dataId);if(e.packedOutput&&(c.isPacked=!0),e.outPackingScheme===vo.DENSE){const b=o!=null?o:si(e.outputShape);c.texShape=b.map(v=>v*2)}if(e.outTexUsage!=null&&(c.usage=e.outTexUsage),H(i.shape)===0)return c.values=Wr(i.dtype,0),i;const l=[],u=t.map(b=>{if(b.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let v=this.texData.get(b.dataId);if(v.texture==null){if(!e.packedInputs&&H(b.shape)<=U().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:b.shape,texData:null,isUniform:!0,uniformValues:v.values};e.packedInputs&&(v.isPacked=!0,v.shape=b.shape)}if(this.uploadToGPU(b.dataId),!!v.isPacked!=!!e.packedInputs)b=v.isPacked?this.unpackTensor(b):this.packTensor(b),l.push(b),v=this.texData.get(b.dataId);else if(v.isPacked&&!Ni(v.shape,b.shape)){const $=b,S=b.shape;b.shape=v.shape,b=this.packedReshape(b,S),l.push(b),v=this.texData.get(b.dataId),$.shape=S}return{shape:b.shape,texData:v,isUniform:!1}});this.uploadToGPU(i.dataId);const d={shape:i.shape,texData:c,isUniform:!1},p=lk(e,u,d),h=this.getAndSaveBinary(p,()=>uk(this.gpgpu,e,u,d)),m=this.activeTimers!=null;let g;m&&(g=this.startTimer()),U().get("ENGINE_COMPILE_ONLY")||ck(this.gpgpu,h,u,d,s),l.forEach(b=>this.disposeIntermediateTensorInfo(b)),m&&(g=this.endTimer(g),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(g)}));const y=U().getNumber("WEBGL_FLUSH_THRESHOLD");if(y>0){const b=dn();b-this.lastGlFlushTime>y&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=b)}if(!U().getBool("WEBGL_LAZILY_UNPACK")&&c.isPacked&&a===!1){const b=this.unpackTensor(i);return this.disposeIntermediateTensorInfo(i),b}return i}compileAndRun(e,t,r,s,a=!1){return r=r||t[0].dtype,this.runWebGLProgram(e,t,r,s,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(U().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement<"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=Ne(()=>{if(!U().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=U().getBool("DEBUG");U().set("DEBUG",!1);const t=this.abs(Re(1e-8)).dataSync()[0];if(U().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?UR:zR}uploadToGPU(e){const t=this.texData.get(e),{shape:r,dtype:s,values:a,texture:o,usage:i,isPacked:c}=t;if(o!=null)return;const l=this.activeTimers!=null;let u;l&&(u=dn());let d=t.texShape;if(d==null&&(d=gT(r,c),t.texShape=d),a!=null){const p=ii(r);let h,m=d[1],g=d[0];const y=a instanceof Uint8Array||a instanceof Uint8ClampedArray;(c||!y)&&([m,g]=Aa(d[0],d[1])),c?h=new gk(p,y):h=new Qh(p,y);const b=y?[g,m]:d,v=this.makeTensorInfo(b,s),$=this.texData.get(v.dataId);y?$.usage=pn.PIXELS:$.usage=pn.UPLOAD,$.texShape=b,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(v.dataId),m,g,a);const S=[[g,m]],T=!0,O=this.runWebGLProgram(h,[v],s,S,T),L=this.texData.get(O.dataId);t.texShape=L.texShape,t.isPacked=L.isPacked,t.usage=L.usage,U().get("ENGINE_COMPILE_ONLY")?this.disposeData(O.dataId):(t.texture=L.texture,t.values=null,this.texData.delete(O.dataId)),this.disposeIntermediateTensorInfo(v),l&&(this.uploadWaitMs+=dn()-u)}else{const p=this.acquireTexture(d,i,s,c);t.texture=p}}convertAndCacheOnCPU(e,t){const r=this.texData.get(e),{dtype:s}=r;return t!=null&&(r.values=KR(t,s)),r.values}acquireTexture(e,t,r,s){if(this.numBytesInGPU+=this.computeBytes(e,r),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){const a=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${a} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,s)}computeBytes(e,t){return e[0]*e[1]*wa(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(s=>{try{this.checkCompletion_(t),s(!0)}catch(a){throw a}});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 AN(),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?(Ny(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.values(this.binaryCache)){this.gpgpu.buildVao(e.webGLProgram);const{variablesLocations:t,customUniformLocations:r,infLoc:s,nanLoc:a,outShapeLocation:o,outShapeStridesLocation:i,outTexShapeLocation:c}=Ay(this.gpgpu,e.program,e.webGLProgram);e.variablesLocations=t,e.customUniformLocations=r,e.infLoc=s,e.nanLoc=a,e.outShapeLocation=o,e.outShapeStridesLocation=i,e.outTexShapeLocation=c}}createTensorFromGPUData(e,t,r){e.channels=e.channels||"RGBA";const{texture:s,height:a,width:o,channels:i}=e,c=fr().backend;if(!c.gpgpu.gl.isTexture(s))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const l=c.writeTexture(s,t,r,a,o,i);return fr().makeTensorFromDataId(l,t,r,c)}}ec.nextDataId=0;function KR(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}`)}/** 7051 * @license 7052 * Copyright 2020 Google Inc. All Rights Reserved. 7053 * Licensed under the Apache License, Version 2.0 (the "License"); 7054 * you may not use this file except in compliance with the License. 7055 * You may obtain a copy of the License at 7056 * 7057 * http://www.apache.org/licenses/LICENSE-2.0 7058 * 7059 * Unless required by applicable law or agreed to in writing, software 7060 * distributed under the License is distributed on an "AS IS" BASIS, 7061 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7062 * See the License for the specific language governing permissions and 7063 * limitations under the License. 7064 * ============================================================================= 7065 */Om()&&Lm("webgl",()=>new ec,2);/** 7066 * @license 7067 * Copyright 2017 Google LLC. All Rights Reserved. 7068 * Licensed under the Apache License, Version 2.0 (the "License");
7069 * you may not use this file except in compliance with the License. 7070 * You may obtain a copy of the License at 7071 * 7072 * http://www.apache.org/licenses/LICENSE-2.0 7073 * 7074 * Unless required by applicable law or agreed to in writing, software 7075 * distributed under the License is distributed on an "AS IS" BASIS, 7076 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7077 * See the License for the specific language governing permissions and 7078 * limitations under the License. 7079 * ============================================================================= 7080 */const th=` 7081 if (isnan(a)) return a; 7082 if (isnan(b)) return b; 7083`;class Ds{constructor(e,t,r){this.variableNames=["A","B"],this.outputShape=ke(t,r),this.enableShapeUniforms=Dt(this.outputShape.length),this.userCode=` 7084 float binaryOperation(float a, float b) { 7085 ${e} 7086 } 7087 7088 void main() { 7089 float a = getAAtOutCoords(); 7090 float b = getBAtOutCoords(); 7091 setOutput(binaryOperation(a, b)); 7092 } 7093 `}}/** 7094 * @license 7095 * Copyright 2018 Google LLC. All Rights Reserved. 7096 * Licensed under the Apache License, Version 2.0 (the "License"); 7097 * you may not use this file except in compliance with the License. 7098 * You may obtain a copy of the License at 7099 * 7100 * http://www.apache.org/licenses/LICENSE-2.0 7101 * 7102 * Unless required by applicable law or agreed to in writing, software 7103 * distributed under the License is distributed on an "AS IS" BASIS, 7104 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7105 * See the License for the specific language governing permissions and 7106 * limitations under the License. 7107 * ============================================================================= 7108 */const zs=` 7109 result.r = isNaN.r ? NAN : result.r; 7110 result.g = isNaN.g ? NAN : result.g; 7111 result.b = isNaN.b ? NAN : result.b; 7112 result.a = isNaN.a ? NAN : result.a; 7113`;class La{constructor(e,t,r,s=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=ke(t,r);const a=this.outputShape.length;this.enableShapeUniforms=Dt(a);let o="";if(s)if(a===0||H(this.outputShape)===1)o=` 7114 result.y = 0.; 7115 result.z = 0.; 7116 result.w = 0.; 7117 `;else if(o=` 7118 ${ze(a)} coords = getOutputCoords(); 7119 `,a===1)this.enableShapeUniforms?o+=` 7120 result.y = (coords + 1) >= outShape ? 0. : result.y; 7121 result.z = 0.; 7122 result.w = 0.; 7123 `:o+=` 7124 result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y; 7125 result.z = 0.; 7126 result.w = 0.; 7127 `;else{const c=Bt("coords",a);this.enableShapeUniforms?o+=` 7128 bool nextRowOutOfBounds = 7129 (${c[a-2]} + 1) >= outShape[${a} - 2]; 7130 bool nextColOutOfBounds = 7131 (${c[a-1]} + 1) >= outShape[${a} - 1]; 7132 result.y = nextColOutOfBounds ? 0. : result.y; 7133 result.z = nextRowOutOfBounds ? 0. : result.z; 7134 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 7135 `:o+=` 7136 bool nextRowOutOfBounds = 7137 (${c[a-2]} + 1) >= ${this.outputShape[a-2]}; 7138 bool nextColOutOfBounds = 7139 (${c[a-1]} + 1) >= ${this.outputShape[a-1]}; 7140 result.y = nextColOutOfBounds ? 0. : result.y; 7141 result.z = nextRowOutOfBounds ? 0. : result.z; 7142 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 7143 `}this.userCode=` 7144 vec4 binaryOperation(vec4 a, vec4 b) { 7145 ${e} 7146 } 7147 7148 void main() { 7149 vec4 a = getAAtOutCoords(); 7150 vec4 b = getBAtOutCoords(); 7151 7152 vec4 result = binaryOperation(a, b); 7153 ${o} 7154 7155 setOutput(result); 7156 } 7157 `}}/** 7158 * @license 7159 * Copyright 2020 Google LLC. All Rights Reserved. 7160 * Licensed under the Apache License, Version 2.0 (the "License"); 7161 * you may not use this file except in compliance with the License. 7162 * You may obtain a copy of the License at 7163 * 7164 * http://www.apache.org/licenses/LICENSE-2.0 7165 * 7166 * Unless required by applicable law or agreed to in writing, softw
7166are 7167 * distributed under the License is distributed on an "AS IS" BASIS, 7168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7169 * See the License for the specific language governing permissions and 7170 * limitations under the License. 7171 * ============================================================================= 7172 */function rn(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 XR={kernelName:au,backendName:"webgl",kernelFunc:rn};/** 7173 * @license 7174 * Copyright 2020 Google LLC. All Rights Reserved. 7175 * Licensed under the Apache License, Version 2.0 (the "License"); 7176 * you may not use this file except in compliance with the License. 7177 * You may obtain a copy of the License at 7178 * 7179 * http://www.apache.org/licenses/LICENSE-2.0 7180 * 7181 * Unless required by applicable law or agreed to in writing, software 7182 * distributed under the License is distributed on an "AS IS" BASIS, 7183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7184 * See the License for the specific language governing permissions and 7185 * limitations under the License. 7186 * ============================================================================= 7187 */function Qr(n){const{inputs:e,backend:t}=n,{real:r,imag:s}=e,a=t.makeTensorInfo(r.shape,"complex64"),o=t.texData.get(a.dataId),i=rn({inputs:{x:r},backend:t}),c=rn({inputs:{x:s},backend:t});return o.complexTensorInfos={real:i,imag:c},a}const YR={kernelName:Qf,backendName:"webgl",kernelFunc:Qr};/** 7188 * @license 7189 * Copyright 2020 Google LLC. All Rights Reserved. 7190 * Licensed under the Apache License, Version 2.0 (the "License"); 7191 * you may not use this file except in compliance with the License. 7192 * You may obtain a copy of the License at 7193 * 7194 * http://www.apache.org/licenses/LICENSE-2.0 7195 * 7196 * Unless required by applicable law or agreed to in writing, software 7197 * distributed under the License is distributed on an "AS IS" BASIS, 7198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7199 * See the License for the specific language governing permissions and 7200 * limitations under the License. 7201 * ============================================================================= 7202 */const Qy="return (a < 0.) ? b * a : a;",Zy=` 7203 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
7204 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 7205`;function QR(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{alpha:a}=r,o=t.makeTensorInfo([],"float32",Ea(a,"float32")),i=U().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new La(Zy,s.shape,o.shape):new Ds(Qy,s.shape,o.shape),c=t.runWebGLProgram(i,[s,o],"float32");return t.disposeIntermediateTensorInfo(o),c}const ZR={kernelName:ou,backendName:"webgl",kernelFunc:QR};/** 7206 * @license 7207 * Copyright 2020 Google LLC. All Rights Reserved. 7208 * Licensed under the Apache License, Version 2.0 (the "License"); 7209 * you may not use this file except in compliance with the License. 7210 * You may obtain a copy of the License at 7211 * 7212 * http://www.apache.org/licenses/LICENSE-2.0 7213 * 7214 * Unless required by applicable law or agreed to in writing, software 7215 * distributed under the License is distributed on an "AS IS" BASIS, 7216 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7217 * See the License for the specific language governing permissions and 7218 * limitations under the License. 7219 * ============================================================================= 7220 */const Jy="return (a < 0.) ? b * a : a;",eb=` 7221 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
7222 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 7223`;function JR(n){const{inputs:e,backend:t}=n,{x:r,alpha:s}=e,a=U().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new La(eb,r.shape,s.shape):new Ds(Jy,r.shape,s.shape);return t.runWebGLProgram(a,[r,s],"float32")}const eA={kernelName:wu,backendName:"webgl",kernelFunc:JR};/** 7224 * @license 7225 * Copyright 2020 Google LLC. All Rights Reserved. 7226 * Licensed under the Apache License, Version 2.0 (the "License"); 7227 * you may not use this file except in compliance with the License. 7228 * You may obtain a copy of the License at 7229 * 7230 * http://www.apache.org/licenses/LICENSE-2.0 7231 * 7232 * Unless required by applicable law or agreed to in writing, software 7233 * distributed under the License is distributed on an "AS IS" BASIS, 7234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7235 * See the License for the specific language governing permissions and 7236 * limitations under the License. 7237 * ============================================================================= 7238 */const Ma="if (isnan(x)) return x;";function De({opSnippet:n,packedOpSnippet:e,cpuKernelImpl:t,dtype:r}){return({inputs:s,backend:a})=>{const{x:o}=s,i=a,c=r||o.dtype;if(i.shouldExecuteOnCPU([o])&&t!=null){const d=i.texData.get(o.dataId),p=t(d.values,c);return i.makeTensorInfo(o.shape,c,p)}const l=U().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let u;return l?u=new Lr(o.shape,e):u=new sr(o.shape,n),i.runWebGLProgram(u,[o],c)}}function Ct({opSnippet:n,packedOpSnippet:e,checkOutOfBounds:t=!1,supportsComplex:r=!1,cpuKernelImpl:s,dtype:a}){return({inputs:o,backend:i})=>{const{a:c,b:l}=o,u=i;if(r&&c.dtype==="complex64"){const m=u.texData.get(c.dataId),g=u.texData.get(l.dataId),[y,b]=[[m.complexTensorInfos.real,g.complexTensorInfos.real],[m.complexTensorInfos.imag,g.complexTensorInfos.imag]].map($=>{const[S,T]=$,O={dataId:S.dataId,dtype:S.dtype,shape:c.shape},L={dataId:T.dataId,dtype:T.dtype,shape:l.shape},M=new Ds(n,c.shape,l.shape);return u.runWebGLProgram(M,[O,L],ir(S.dtype,T.dtype))}),v=Qr({inputs:{real:y,imag:b},backend:u});return u.disposeIntermediateTensorInfo(y),u.disposeIntermediateTensorInfo(b),v}const d=a||ir(c.dtype,l.dtype);if((c.dtype==="string"||l.dtype==="string"||u.shouldExecuteOnCPU([c,l]))&&s!=null){const m=u.texData.get(c.dataId).values,g=u.texData.get(l.dataId).values,y=c.dtype==="string"?Ca(m):m,b=c.dtype==="string"?Ca(g):g,[v,$]=s(c.shape,l.shape,y,b,d),S=u.makeTensorInfo($,d),T=u.texData.get(S.dataId);return T.values=v,S}const p=U().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let h;return p?h=new La(e,c.shape,l.shape,t):h=new Ds(n,c.shape,l.shape),u.runWebGLProgram(h,[c,l],d)}}function Io(n,e=!1){if(n==="linear")return e?FR:ER;if(n==="relu")return e?LR:AR;if(n==="elu")return e?PR:RR;if(n==="relu6")return e?MR:DR;if(n==="prelu")return e?eb:Jy;if(n==="leakyrelu")return e?Zy:Qy;if(n==="sigmoid")return e?BR:OR;throw new Error(`Activation ${n} has not been implemented for the WebGL backend.`)}/** 7239 * @license 7240 * Copyright 2018 Google LLC. All Rights Reserved. 7241 * Licensed under the Apache License, Version 2.0 (the "License"); 7242 * you may not use this file except in compliance with the License. 7243 * You may obtain a copy of the License at 7244 * 7245 * http://www.apache.org/licenses/LICENSE-2.0 7246 * 7247 * Unless required by applicable law or agreed to in writing, software 7248 * distributed under the License is distributed on an "AS IS" BASIS, 7249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7250 * See the License for the specific language governing permissions and 7251 * limitations under the License. 7252 * ============================================================================= 7253 */class tb{constructor(e,t,r,s=!1,a=!1,o=!1,i=null,c=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r,this.enableShapeUniforms=Dt(this.outputShape.length);const u=s?e[1]:e[2],d=Math.ceil(u/2),p=s?"i * 2, rc.y":"rc.y, i * 2",h=a?"rc.z, i * 2":"i * 2, rc.z",m=s?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],g=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let y="",b="";i&&(c?y=`vec4 activation(vec4 a) { 7254 vec4 b = getPreluActivationWeightsAtOutCoords(); 7255 ${i} 7256 }`:l?y=`vec4 activation(vec4 a) { 7257 vec4 b = getLeakyreluAlphaAtOutCoords(); 7258 ${i} 7259 }`:y=`vec4 activation(vec4 x) { 7260 ${i} 7261 }`,b="result = activation(result);");const v=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),c&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let $="rc.x",S="rc.x";e[0]<t[0]?$=`imod(rc.x, ${e[0]})`:t[0]<e[0]&&(S=`imod(rc.x, ${t[0]})`),this.userCode=` 7262 ${y} 7263 // Don't use uniform for sharedDimensionPacked for performance. 7264 const float sharedDimension = ${d}.0; 7265 7266 vec4 dot2x2ARowBCol(ivec3 rc) { 7267 vec4 result = vec4(0); 7268 int batchA = ${$}; 7269 int batchB = ${S}; 7270 for (int i = 0; i < ${d}; i++) { 7271 vec4 a = getMatrixA(batchA, ${p}); 7272 vec4 b = getMatrixB(batchB, ${h}); 7273 7274 // These swizzled products need to be separately added.
7275 // See: https://github.com/tensorflow/tfjs/issues/1735 7276 result += (${m[0]} * ${g[0]}); 7277 result += (${m[1]} * ${g[1]}); 7278 } 7279 return result; 7280 } 7281 7282 void main() { 7283 ivec3 rc = getOutputCoords(); 7284 vec4 result = dot2x2ARowBCol(rc); 7285 7286 ${v} 7287 7288 ${b} 7289 7290 setOutput(result); 7291 } 7292 `}}/** 7293 * @license 7294 * Copyright 2018 Google LLC. All Rights Reserved. 7295 * Licensed under the Apache License, Version 2.0 (the "License"); 7296 * you may not use this file except in compliance with the License. 7297 * You may obtain a copy of the License at 7298 * 7299 * http://www.apache.org/licenses/LICENSE-2.0 7300 * 7301 * Unless required by applicable law or agreed to in writing, software 7302 * distributed under the License is distributed on an "AS IS" BASIS, 7303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7304 * See the License for the specific language governing permissions and 7305 * limitations under the License. 7306 * ============================================================================= 7307 */const of={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class uf{constructor(e,t,r){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=ke(t,r),this.userCode=` 7308 float binaryOpComplex( 7309 float areal, float aimag, float breal, float bimag) { 7310 ${e} 7311 } 7312 7313 void main() { 7314 float areal = getARealAtOutCoords(); 7315 float aimag = getAImagAtOutCoords(); 7316 float breal = getBRealAtOutCoords(); 7317 float bimag = getBImagAtOutCoords(); 7318 setOutput(binaryOpComplex(areal, aimag, breal, bimag)); 7319 } 7320 `}}/** 7321 * @license 7322 * Copyright 2020 Google LLC. All Rights Reserved. 7323 * Licensed under the Apache License, Version 2.0 (the "License"); 7324 * you may not use this file except in compliance with the License. 7325 * You may obtain a copy of the License at 7326 * 7327 * http://www.apache.org/licenses/LICENSE-2.0 7328 * 7329 * Unless required by applicable law or agreed to in writing, software 7330 * distributed under the License is distributed on an "AS IS" BASIS, 7331 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7332 * See the License for the specific language governing permissions and 7333 * limitations under the License. 7334 * ============================================================================= 7335 */const cf="return a * b;";function nh(n){const{inputs:e,backend:t}=n,{a:r,b:s}=e,a=ir(r.dtype,s.dtype);if(r.dtype==="complex64"){const i=t.texData.get(r.dataId),c=t.texData.get(s.dataId),l=new uf(of.REAL,r.shape,s.shape),u=new uf(of.IMAG,r.shape,s.shape),d=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:r.shape},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:c.complexTensorInfos.real.dataId,dtype:c.complexTensorInfos.real.dtype,shape:s.shape},{dataId:c.complexTensorInfos.imag.dataId,dtype:c.complexTensorInfos.imag.dtype,shape:s.shape}],p=t.runWebGLProgram(l,d,"float32"),h=t.runWebGLProgram(u,d,"float32"),m=Qr({inputs:{real:p,imag:h},backend:t});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(h),m}if(t.shouldExecuteOnCPU([r,s])){const i=t.texData.get(r.dataId),c=t.texData.get(s.dataId),[l,u]=JE(r.shape,s.shape,i.values,c.values,a),d=t.makeTensorInfo(u,a),p=t.texData.get(d.dataId);return p.values=l,d}let o;return U().getBool("WEBGL_PACK_BINARY_OPERATIONS")?o=new La(cf,r.shape,s.shape):o=new Ds(cf,r.shape,s.shape),t.runWebGLProgram(o,[r,s],a)}const tA={kernelName:$d,backendName:"webgl",kernelFunc:nh};/** 7336 * @license 7337 * Copyright 2020 Google LLC. All Rights Reserved. 7338 * Licensed under the Apache License, Version 2.0 (the "License"); 7339 * you may not use this file except in compliance with the License. 7340 * You may obtain a copy of the License at 7341 * 7342 * http://www.apache.org/licenses/LICENSE-2.0 7343 * 7344 * Unless required by applicable law or agreed to in writing, software 7345 * distributed under the License is distributed on an "AS IS" BASIS, 7346 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7347 * See the License for the specific language governing permissions and 7348 * limitations under the License. 7349 * ============================================================================= 7350 */function nA(n,e,t){const r=[_a(n.shape),...Na(n.shape)],s={dtype:n.dtype,shape:r,dataId:n.dataId},a=[_a(e),...Na(e)],o=new Yy(a,r),i=!0,c=[r],l=t.runWebGLProgram(o,[s],n.dtype,c,i);return{dataId:l.dataId,shape:e,dtype:l.dtype}}/** 7351 * @license 7352 * Copyright 2020 Google LLC. All Rights Reserved. 7353 * Licensed under the Apache License, Version 2.0 (the "License");
7354 * you may not use this file except in compliance with the License. 7355 * You may obtain a copy of the License at 7356 * 7357 * http://www.apache.org/licenses/LICENSE-2.0 7358 * 7359 * Unless required by applicable law or agreed to in writing, software 7360 * distributed under the License is distributed on an "AS IS" BASIS, 7361 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7362 * See the License for the specific language governing permissions and 7363 * limitations under the License. 7364 * ============================================================================= 7365 */function te(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{shape:a}=r,o=t,i=H(s.shape),c=Gf(a,i),l=H(c);N(i===l,()=>`The new shape (${c}) has ${l} elements and the old shape (${s.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);const u=o.texData.get(s.dataId);return u.isPacked&&!Ni(s.shape,c)&&!(u.texture!==null&&Ni(u.shape,c))?nA(s,c,o):(o.incRef(s.dataId),{dataId:s.dataId,shape:c,dtype:s.dtype})}const rA={kernelName:Ad,backendName:"webgl",kernelFunc:te};/** 7366 * @license 7367 * Copyright 2020 Google LLC. All Rights Reserved. 7368 * Licensed under the Apache License, Version 2.0 (the "License"); 7369 * you may not use this file except in compliance with the License. 7370 * You may obtain a copy of the License at 7371 * 7372 * http://www.apache.org/licenses/LICENSE-2.0 7373 * 7374 * Unless required by applicable law or agreed to in writing, software 7375 * distributed under the License is distributed on an "AS IS" BASIS, 7376 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7377 * See the License for the specific language governing permissions and 7378 * limitations under the License. 7379 * ============================================================================= 7380 */class lf{constructor(e,t){this.variableNames=["x"];const{windowSize:r,batchSize:s,inSize:a,outSize:o}=e;this.outputShape=[s,o];const i=Math.floor(r/4)*4,c=r%4;let l="sumValue += dot(values, ones);";if(t!=null){const d=1/t;l=`sumValue += dot(values * ${xa(d)?d.toPrecision(2):d}, ones);`}let u="";a%r>0&&(u=` 7381 if (inIdx < 0 || inIdx >= ${a}) { 7382 return 0.0; 7383 } 7384 `),this.userCode=` 7385 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 7386 7387 float getValue(int batch, int inIdx) { 7388 ${u} 7389 return getX(batch, inIdx); 7390 } 7391 7392 void main() { 7393 ivec2 coords = getOutputCoords(); 7394 int batch = coords[0]; 7395 int outIdx = coords[1]; 7396 int inOffset = outIdx * ${r}; 7397 7398 float sumValue = 0.0; 7399 7400 for (int i = 0; i < ${i}; i += 4) { 7401 int inIdx = inOffset + i; 7402 vec4 values = vec4( 7403 getValue(batch, inIdx), 7404 getValue(batch, inIdx + 1), 7405 getValue(batch, inIdx + 2), 7406 getValue(batch, inIdx + 3) 7407 ); 7408 7409 ${l} 7410 } 7411 7412 int inIdx = inOffset + ${i}; 7413 if (${c===1}) { 7414 vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0); 7415 7416 ${l} 7417 } else if (${c===2}) { 7418 vec4 values = vec4( 7419 getValue(batch, inIdx), 7420 getValue(batch, inIdx + 1), 0.0, 0.0); 7421 7422 ${l} 7423 } else if (${c===3}) { 7424 vec4 values = vec4( 7425 getValue(batch, inIdx), 7426 getValue(batch, inIdx + 1), 7427 getValue(batch, inIdx + 2), 0.0); 7428 7429 ${l} 7430 } 7431 setOutput(sumValue); 7432 } 7433 `}}/** 7434 * @license 7435 * Copyright 2017 Google LLC. All Rights Reserved. 7436 * Licensed under the Apache License, Version 2.0 (the "License"); 7437 * you may not use this file except in compliance with the License. 7438 * You may obtain a copy of the License at 7439 * 7440 * http://www.apache.org/licenses/LICENSE-2.0 7441 * 7442 * Unless required by applicable law or agreed to in writing, software 7443 * distributed under the License is distributed on an "AS IS" BASIS, 7444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7445 * See the License for the specific language governing permissions and 7446 * limitations under the License. 7447 * ============================================================================= 7448 */class sA{constructor(e,t){this.variableNames=["x"];const{windowSize:r,batchSize:s,inSize:a,outSize:o}=e;this.outputShape=[s,o];let i="0.0",c="";t==="prod"?i="1.0":t==="min"?(i="1.0 / 1e-20",c="min"):t==="max"&&(i="-1.0 / 1e-20",c="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 u=Math.floor(r/4)*4,d=r%4;let p=` 7449 if (${t==="sum"}) { 7450 sumValue += dot(values, ones); 7451 } else if (${t==="prod"}) { 7452 vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]); 7453 prodValue *= tmp[0] * tmp[1]; 7454 } else { 7455 minMaxValue = ${c}(values, minMaxValue); 7456 if (${t==="min"} || ${t==="max"}) { 7457 minMaxValue = ${c}(values, minMaxValue); 7458 bvec4 isNaN = isnan(values); 7459 if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) { 7460 minMaxValue = vec4(NAN); 7461 } 7462 } 7463 } 7464 `,h="vec4";t==="all"?(i="1.0",p=` 7465 bool reducedAllValue = all(values); 7466 float floatedReducedAllValue = float(reducedAllValue); 7467 allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0); 7468 `,h="bvec4"):t==="any"&&(i="0.0",p=` 7469 bool reducedAnyValue = any(values); 7470 float floatedReducedAnyValue = float(reducedAnyValue); 7471 anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0); 7472 `,h="bvec4");let m="";a%r>0&&(m=` 7473 if (inIdx < 0 || inIdx >= ${a}) { 7474 return initializationValue; 7475 } 7476 `),this.userCode=` 7477 const float initializationValue = ${i}; 7478 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 7479 7480 float getValue(int batch, int inIdx) { 7481 ${m} 7482 return getX(batch, inIdx); 7483 } 7484 7485 void main() { 7486 ivec2 coords = getOutputCoords(); 7487 int batch = coords[0]; 7488 int outIdx = coords[1]; 7489 int inOffset = outIdx * ${r}; 7490 7491 vec4 minMaxValue = vec4(${i}); 7492 float prodValue = 1.0; 7493 float sumValue = 0.0; 7494 float allValue = 1.0; 7495 float anyValue = 0.0; 7496 7497 for (int i = 0; i < ${u}; i += 4) { 7498 int inIdx = inOffset + i; 7499 ${h} values = ${h}( 7500 getValue(batch, inIdx), 7501 getValue(batch, inIdx + 1), 7502 getValue(batch, inIdx + 2), 7503 getValue(batch, inIdx + 3) 7504 ); 7505 7506 ${p} 7507 } 7508 7509 int inIdx = inOffset + ${u}; 7510 if (${d===1}) { 7511 ${h} values = ${h}( 7512 getValue(batch, inIdx), 7513 initializationValue, 7514 initializationValue, 7515 initializationValue 7516 ); 7517 7518 ${p} 7519 } else if (${d===2}) { 7520 ${h} values = ${h}( 7521 getValue(batch, inIdx), 7522 getValue(batch, inIdx + 1), 7523 initializationValue, 7524 initializationValue 7525 ); 7526 7527 ${p} 7528 } else if (${d===3}) { 7529 ${h} values = ${h}( 7530 getValue(batch, inIdx), 7531 getValue(batch, inIdx + 1), 7532 getValue(batch, inIdx + 2), 7533 initializationValue 7534 ); 7535 7536 ${p} 7537 } 7538 setOutput(${l}); 7539 } 7540 `}}/** 7541 * @license 7542 * Copyright 2020 Google LLC. All Rights Reserved. 7543 * Licensed under the Apache License, Version 2.0 (the "License");
7544 * you may not use this file except in compliance with the License. 7545 * You may obtain a copy of the License at 7546 * 7547 * http://www.apache.org/licenses/LICENSE-2.0 7548 * 7549 * Unless required by applicable law or agreed to in writing, software 7550 * distributed under the License is distributed on an "AS IS" BASIS, 7551 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7552 * See the License for the specific language governing permissions and 7553 * limitations under the License. 7554 * ============================================================================= 7555 */function aA(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=Zu(t);e.push({inSize:t,windowSize:r,outSize:Math.ceil(t/r)})}return e}function Gs(n,e,t,r){const s=aA(n.shape);let a=n;for(let o=0;o<s.length;o++){const{inSize:i,windowSize:c,outSize:l}=s[o];let u,d;t==="mean"?u=o===0?new lf({windowSize:c,inSize:i,batchSize:n.shape[0],outSize:l},i):new lf({windowSize:c,inSize:i,batchSize:n.shape[0],outSize:l}):u=new sA({windowSize:c,inSize:i,batchSize:n.shape[0],outSize:l},t),d=a,a=r.runWebGLProgram(u,[a],e),d.dataId!==n.dataId&&r.disposeIntermediateTensorInfo(d)}return a}/** 7556 * @license 7557 * Copyright 2017 Google LLC. All Rights Reserved. 7558 * Licensed under the Apache License, Version 2.0 (the "License"); 7559 * you may not use this file except in compliance with the License. 7560 * You may obtain a copy of the License at 7561 * 7562 * http://www.apache.org/licenses/LICENSE-2.0 7563 * 7564 * Unless required by applicable law or agreed to in writing, software 7565 * distributed under the License is distributed on an "AS IS" BASIS, 7566 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7567 * See the License for the specific language governing permissions and 7568 * limitations under the License. 7569 * ============================================================================= 7570 */class oA{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 s=ze(this.rank),a=iA(t);this.userCode=` 7571 void main() { 7572 ${s} resRC = getOutputCoords(); 7573 setOutput(getA(${a})); 7574 } 7575 `}}function iA(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 s=0;s<n.length;s++)r[n[s]]=t[s];return r.join()}/** 7576 * @license 7577 * Copyright 2019 Google LLC. All Rights Reserved. 7578 * Licensed under the Apache License, Version 2.0 (the "License"); 7579 * you may not use this file except in compliance with the License. 7580 * You may obtain a copy of the License at 7581 * 7582 * http://www.apache.org/licenses/LICENSE-2.0 7583 * 7584 * Unless required by applicable law or agreed to in writing, software 7585 * distributed under the License is distributed on an "AS IS" BASIS, 7586 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7587 * See the License for the specific language governing permissions and 7588 * limitations under the License. 7589 * ============================================================================= 7590 */class uA{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const r=new Array(e.length);for(let u=0;u<r.length;u++)r[u]=e[t[u]];if(this.outputShape=r,this.rank=r.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const s=ze(this.rank),a=Xy("rc",this.rank),o=new Array(this.rank);for(let u=0;u<t.length;u++)o[t[u]]=a[u];const i=`vec2(${o.slice(-2).join()})`,c=`++${a[this.rank-1]} < ${r[this.rank-1]}`,l=`getChannel(getA(${o.join()}), ${i})`;this.userCode=` 7591 void main() { 7592 ${s} rc = getOutputCoords(); 7593 vec4 result = vec4(0.); 7594 result[0] = ${l}; 7595 if(${c}) { 7596 result[1] = ${l}; 7597 } 7598 --${a[this.rank-1]}; 7599 if(++${a[this.rank-2]} < ${r[this.rank-2]}) { 7600 result[2] = ${l}; 7601 if(${c}) { 7602 result[3] = ${l}; 7603 } 7604 } 7605 setOutput(result); 7606 } 7607 `}}/** 7608 * @license 7609 * Copyright 2020 Google LLC. All Rights Reserved. 7610 * Licensed under the Apache License, Version 2.0 (the "License");
7611 * you may not use this file except in compliance with the License. 7612 * You may obtain a copy of the License at 7613 * 7614 * http://www.apache.org/licenses/LICENSE-2.0 7615 * 7616 * Unless required by applicable law or agreed to in writing, software 7617 * distributed under the License is distributed on an "AS IS" BASIS, 7618 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7619 * See the License for the specific language governing permissions and 7620 * limitations under the License. 7621 * ============================================================================= 7622 */function tc(n,e,t){const r=U().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new uA(n.shape,e):new oA(n.shape,e);return t.runWebGLProgram(r,[n],n.dtype)}/** 7623 * @license 7624 * Copyright 2020 Google LLC. All Rights Reserved. 7625 * Licensed under the Apache License, Version 2.0 (the "License"); 7626 * you may not use this file except in compliance with the License. 7627 * You may obtain a copy of the License at 7628 * 7629 * http://www.apache.org/licenses/LICENSE-2.0 7630 * 7631 * Unless required by applicable law or agreed to in writing, software 7632 * distributed under the License is distributed on an "AS IS" BASIS, 7633 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7634 * See the License for the specific language governing permissions and 7635 * limitations under the License. 7636 * ============================================================================= 7637 */function cA(n,e,t,r){const s=e,a=n.shape.length,o=ot(s,n.shape);let i=o;const c=Xt(i,a),l=c!=null;let u=n;l&&(u=tc(n,c,r),i=St(i.length,a)),ht("sum",i,a);const[d,p]=At(u.shape,i);let h=d;t&&(h=pt(d,o));const m=H(p),y=H(n.shape)/m,b=te({inputs:{x:u},attrs:{shape:[y,m]},backend:r}),v=cp(n.dtype),$=Gs(b,v,"sum",r),S=te({inputs:{x:$},attrs:{shape:h},backend:r});return r.disposeIntermediateTensorInfo(b),r.disposeIntermediateTensorInfo($),l&&r.disposeIntermediateTensorInfo(u),S}/** 7638 * @license 7639 * Copyright 2020 Google LLC. All Rights Reserved. 7640 * Licensed under the Apache License, Version 2.0 (the "License"); 7641 * you may not use this file except in compliance with the License. 7642 * You may obtain a copy of the License at 7643 * 7644 * http://www.apache.org/licenses/LICENSE-2.0 7645 * 7646 * Unless required by applicable law or agreed to in writing, software 7647 * distributed under the License is distributed on an "AS IS" BASIS, 7648 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7649 * See the License for the specific language governing permissions and 7650 * limitations under the License. 7651 * ============================================================================= 7652 */function nc(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,keepDims:o}=r;return cA(s,a,o,t)}const lA={kernelName:Tu,backendName:"webgl",kernelFunc:nc};/** 7653 * @license 7654 * Copyright 2020 Google LLC. All Rights Reserved. 7655 * Licensed under the Apache License, Version 2.0 (the "License"); 7656 * you may not use this file except in compliance with the License. 7657 * You may obtain a copy of the License at 7658 * 7659 * http://www.apache.org/licenses/LICENSE-2.0 7660 * 7661 * Unless required by applicable law or agreed to in writing, software 7662 * distributed under the License is distributed on an "AS IS" BASIS, 7663 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7664 * See the License for the specific language governing permissions and 7665 * limitations under the License. 7666 * ============================================================================= 7667 */function Vt(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{perm:a}=r,o=t,i=s.shape.length,c=new Array(i);for(let u=0;u<c.length;u++)c[u]=s.shape[a[u]];let l;if(o.shouldExecuteOnCPU([s])){const d=o.texData.get(s.dataId).values,p=eh(d,s.shape,s.dtype,a,c);l=o.makeTensorInfo(c,s.dtype);const h=o.texData.get(l.dataId);h.values=p}else l=tc(s,a,o);return l}const dA={kernelName:ma,backendName:"webgl",kernelFunc:Vt};/** 7668 * @license 7669 * Copyright 2020 Google LLC. All Rights Reserved. 7670 * Licensed under the Apache License, Version 2.0 (the "License"); 7671 * you may not use this file except in compliance with the License. 7672 * You may obtain a copy of the License at 7673 * 7674 * http://www.apache.org/licenses/LICENSE-2.0 7675 * 7676 * Unless required by applicable law or agreed to in writing, softw
7676are 7677 * distributed under the License is distributed on an "AS IS" BASIS, 7678 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7679 * See the License for the specific language governing permissions and 7680 * limitations under the License. 7681 * ============================================================================= 7682 */const nb=1e3;function ki({a:n,b:e,transposeA:t,transposeB:r,backend:s,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:c=null}){const l=n.shape.length,u=e.shape.length,d=t?n.shape[l-2]:n.shape[l-1],p=r?e.shape[u-1]:e.shape[u-2],h=t?n.shape[l-1]:n.shape[l-2],m=r?e.shape[u-2]:e.shape[u-1],g=n.shape.slice(0,-2),y=e.shape.slice(0,-2),b=H(g),v=H(y),S=ke(n.shape.slice(0,-2),e.shape.slice(0,-2)).concat([h,m]);N(d===p,()=>`Error in matMul: inner shapes (${d}) and (${p}) of Tensors with shapes ${n.shape} and ${e.shape} and transposeA=${t} and transposeB=${r} must match.`);const T=t?[b,d,h]:[b,h,d],O=r?[v,m,p]:[v,p,m],L=te({inputs:{x:n},backend:s,attrs:{shape:T}}),M=te({inputs:{x:e},backend:s,attrs:{shape:O}}),W=[L,M],V=Math.max(b,v),G=t?L.shape[1]:L.shape[2],K=a!=null,J=o!=null,ue=c==="leakyrelu",se=c!=null?Io(c,!0):null,fe=K||J||ue||se!=null;let Ie;if((h===1||m===1)&&G>nb&&fe===!1){let Fe=L,Qe=M;t&&(Fe=Vt({inputs:{x:L},backend:s,attrs:{perm:[0,2,1]}}),W.push(Fe)),r&&(Qe=Vt({inputs:{x:M},backend:s,attrs:{perm:[0,2,1]}}),W.push(Qe));const it=m!==1,Nt=m===1;let He=Fe;it&&(He=te({inputs:{x:Fe},backend:s,attrs:{shape:[V,G,1]}}),W.push(He));const An=m===1?2:1;let on=Qe;Nt&&(on=te({inputs:{x:Qe},backend:s,attrs:{shape:[V,1,G]}}),W.push(on));const Dn=nh({inputs:{a:He,b:on},backend:s});Ie=nc({inputs:{x:Dn},backend:s,attrs:{axis:An,keepDims:!0}}),W.push(Dn)}else{const Fe=ir(n.dtype,e.dtype),Qe=new tb(T,O,[V,h,m],t,r,K,se,J,ue),it=[L,M];if(a!=null&&it.push(a),J&&it.push(o),ue){const Nt=s.makeTensorInfo([],"float32",Ea(i,"float32"));it.push(Nt),W.push(Nt)}Ie=s.runWebGLProgram(Qe,it,Fe)}const pe=te({inputs:{x:Ie},backend:s,attrs:{shape:S}});W.push(Ie);for(const Fe of W)s.disposeIntermediateTensorInfo(Fe);return pe}/** 7683 * @license 7684 * Copyright 2020 Google LLC. All Rights Reserved. 7685 * Licensed under the Apache License, Version 2.0 (the License); 7686 * you may not use this file except in compliance with the License. 7687 * You may obtain a copy of the License at 7688 * 7689 * http://www.apache.org/licenses/LICENSE-2.0 7690 * 7691 * Unless required by applicable law or agreed to in writing, software 7692 * distributed under the License is distributed on an AS IS BASIS, 7693 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7694 * See the License for the specific language governing permissions and 7695 * limitations under the License. 7696 * ============================================================================= 7697 */function pA(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:a,bias:o,preluActivationWeights:i}=e,{transposeA:c,transposeB:l,activation:u,leakyreluAlpha:d}=r;return ki({a:s,b:a,transposeA:c,transposeB:l,backend:t,bias:o,preluActivationWeights:i,leakyreluAlpha:d,activation:u})}const hA={kernelName:uo,backendName:"webgl",kernelFunc:pA};/** 7698 * @license 7699 * Copyright 2020 Google LLC. All Rights Reserved. 7700 * Licensed under the Apache License, Version 2.0 (the "License"); 7701 * you may not use this file except in compliance with the License. 7702 * You may obtain a copy of the License at 7703 * 7704 * http://www.apache.org/licenses/LICENSE-2.0 7705 * 7706 * Unless required by applicable law or agreed to in writing, software 7707 * distributed under the License is distributed on an "AS IS" BASIS, 7708 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7709 * See the License for the specific language governing permissions and 7710 * limitations under the License. 7711 * ============================================================================= 7712 */const df="return abs(x);";function fA(n){const{inputs:e,backend:t}=n,{x:r}=e;if(t.shouldExecuteOnCPU([r])&&r.dtype!=="complex64"){const a=t.texData.get(r.dataId),o=qy(a.values);return t.makeTensorInfo(r.shape,r.dtype,o)}let s;return U().getBool("WEBGL_PACK_UNARY_OPERATIONS")?s=new Lr(r.shape,df):s=new sr(r.shape,df),t.runWebGLProgram(s,[r],r.dtype)}const mA={kernelName:_l,backendName:"webgl",kernelFunc:fA};/** 7713 * @license 7714 * Copyright 2020 Google LLC. All Rights Reserved. 7715 * Licensed under the Apache License, Version 2.0 (the "License");
7716 * you may not use this file except in compliance with the License. 7717 * You may obtain a copy of the License at 7718 * 7719 * http://www.apache.org/licenses/LICENSE-2.0 7720 * 7721 * Unless required by applicable law or agreed to in writing, software 7722 * distributed under the License is distributed on an "AS IS" BASIS, 7723 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7724 * See the License for the specific language governing permissions and 7725 * limitations under the License. 7726 * ============================================================================= 7727 */const gA=Rn+` 7728 if (abs(x) > 1.) { 7729 return NAN; 7730 } 7731 return acos(x); 7732`,yA=De({opSnippet:gA}),bA={kernelName:Nl,backendName:"webgl",kernelFunc:yA};/** 7733 * @license 7734 * Copyright 2020 Google LLC. All Rights Reserved. 7735 * Licensed under the Apache License, Version 2.0 (the "License"); 7736 * you may not use this file except in compliance with the License. 7737 * You may obtain a copy of the License at 7738 * 7739 * http://www.apache.org/licenses/LICENSE-2.0 7740 * 7741 * Unless required by applicable law or agreed to in writing, software 7742 * distributed under the License is distributed on an "AS IS" BASIS, 7743 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7744 * See the License for the specific language governing permissions and 7745 * limitations under the License. 7746 * ============================================================================= 7747 */const xA=Rn+` 7748 if (x < 1.0) return NAN; 7749return log(x + sqrt(x * x - 1.0));`,wA=De({opSnippet:xA}),vA={kernelName:Tl,backendName:"webgl",kernelFunc:wA};/** 7750 * @license 7751 * Copyright 2020 Google LLC. All Rights Reserved. 7752 * Licensed under the Apache License, Version 2.0 (the "License"); 7753 * you may not use this file except in compliance with the License. 7754 * You may obtain a copy of the License at 7755 * 7756 * http://www.apache.org/licenses/LICENSE-2.0 7757 * 7758 * Unless required by applicable law or agreed to in writing, software 7759 * distributed under the License is distributed on an "AS IS" BASIS, 7760 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7761 * See the License for the specific language governing permissions and 7762 * limitations under the License. 7763 * ============================================================================= 7764 */const pf="return a + b;",IA=Ct({opSnippet:pf,packedOpSnippet:pf,supportsComplex:!0,cpuKernelImpl:AE}),$A={kernelName:Li,backendName:"webgl",kernelFunc:IA};/** 7765 * @license 7766 * Copyright 2019 Google LLC. All Rights Reserved. 7767 * Licensed under the Apache License, Version 2.0 (the "License"); 7768 * you may not use this file except in compliance with the License. 7769 * You may obtain a copy of the License at 7770 * 7771 * http://www.apache.org/licenses/LICENSE-2.0 7772 * 7773 * Unless required by applicable law or agreed to in writing, software 7774 * distributed under the License is distributed on an "AS IS" BASIS, 7775 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7776 * See the License for the specific language governing permissions and 7777 * limitations under the License. 7778 * ============================================================================= 7779 */class SA{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((a,o)=>`T${o}`);const r=[];this.variableNames.forEach(a=>{r.push(`float v${a} = get${a}AtOutCoords();`)});const s=this.variableNames.map(a=>`v${a}`).join(" + ");this.userCode=` 7780 void main() { 7781 ${r.join(` 7782 `)} 7783 7784 float result = ${s}; 7785 setOutput(result); 7786 } 7787 `}}/** 7788 * @license 7789 * Copyright 2019 Google LLC. All Rights Reserved. 7790 * Licensed under the Apache License, Version 2.0 (the "License"); 7791 * you may not use this file except in compliance with the License. 7792 * You may obtain a copy of the License at 7793 * 7794 * http://www.apache.org/licenses/LICENSE-2.0 7795 * 7796 * Unless required by applicable law or agreed to in writing, software 7797 * distributed under the License is distributed on an "AS IS" BASIS, 7798 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7799 * See the License for the specific language governing permissions and 7800 * limitations under the License. 7801 * ============================================================================= 7802 */class CA{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((a,o)=>`T${o}`);const r=[];
vendor: 9,754 bytes, lines 7802-7970
7802this.variableNames.forEach(a=>{r.push(`vec4 v${a} = get${a}AtOutCoords();`)});const s=this.variableNames.map(a=>`v${a}`).join(" + ");this.userCode=` 7803 void main() { 7804 ${r.join(` 7805 `)} 7806 7807 vec4 result = ${s}; 7808 setOutput(result); 7809 } 7810 `}}/** 7811 * @license 7812 * Copyright 2020 Google LLC. All Rights Reserved. 7813 * Licensed under the Apache License, Version 2.0 (the "License"); 7814 * you may not use this file except in compliance with the License. 7815 * You may obtain a copy of the License at 7816 * 7817 * http://www.apache.org/licenses/LICENSE-2.0 7818 * 7819 * Unless required by applicable law or agreed to in writing, software 7820 * distributed under the License is distributed on an "AS IS" BASIS, 7821 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7822 * See the License for the specific language governing permissions and 7823 * limitations under the License. 7824 * ============================================================================= 7825 */function fi(n){const{inputs:e,backend:t}=n,r=e;if(r.length===1)return rn({inputs:{x:r[0]},backend:t});if(r.length>U().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const c=Math.floor(r.length/2),l=fi({inputs:r.slice(0,c),backend:t}),u=fi({inputs:r.slice(c),backend:t});return fi({inputs:[l,u],backend:t})}const s=r.map(c=>c.dtype).reduce((c,l)=>ir(c,l)),a=r.map(c=>c.shape),i=U().getBool("WEBGL_PACK")?new CA(r[0].shape,a):new SA(r[0].shape,a);return t.runWebGLProgram(i,r,s)}const _A={kernelName:Mi,backendName:"webgl",kernelFunc:fi};/** 7826 * @license 7827 * Copyright 2020 Google LLC. All Rights Reserved. 7828 * Licensed under the Apache License, Version 2.0 (the "License"); 7829 * you may not use this file except in compliance with the License. 7830 * You may obtain a copy of the License at 7831 * 7832 * http://www.apache.org/licenses/LICENSE-2.0 7833 * 7834 * Unless required by applicable law or agreed to in writing, software 7835 * distributed under the License is distributed on an "AS IS" BASIS, 7836 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7837 * See the License for the specific language governing permissions and 7838 * limitations under the License. 7839 * ============================================================================= 7840 */function NA(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,keepDims:o}=r,i=s.shape.length,c=ot(a,s.shape);let l=c;const u=Xt(l,i);let d=s;u!=null&&(d=Vt({inputs:{x:s},backend:t,attrs:{perm:u}}),l=St(l.length,i)),ht("all",l,i);const[p,h]=At(d.shape,l),m=H(h),g=te({inputs:{x:d},backend:t,attrs:{shape:[-1,m]}}),y=Gs(g,g.dtype,"all",t);let b;if(o){const v=pt(p,c);b=te({inputs:{x:y},backend:t,attrs:{shape:v}})}else b=te({inputs:{x:y},backend:t,attrs:{shape:p}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(y),u!=null&&t.disposeIntermediateTensorInfo(d),b}const TA={kernelName:Bi,backendName:"webgl",kernelFunc:NA};/** 7841 * @license 7842 * Copyright 2020 Google LLC. All Rights Reserved. 7843 * Licensed under the Apache License, Version 2.0 (the "License"); 7844 * you may not use this file except in compliance with the License. 7845 * You may obtain a copy of the License at 7846 * 7847 * http://www.apache.org/licenses/LICENSE-2.0 7848 * 7849 * Unless required by applicable law or agreed to in writing, software 7850 * distributed under the License is distributed on an "AS IS" BASIS, 7851 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7852 * See the License for the specific language governing permissions and 7853 * limitations under the License. 7854 * ============================================================================= 7855 */function kA(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,keepDims:o}=r,i=s.shape.length,c=ot(a,s.shape);let l=c;const u=Xt(l,i);let d=s;u!=null&&(d=Vt({inputs:{x:s},backend:t,attrs:{perm:u}}),l=St(l.length,i)),ht("any",l,i);const[p,h]=At(d.shape,l),m=H(h),g=te({inputs:{x:d},backend:t,attrs:{shape:[-1,m]}}),y=Gs(g,g.dtype,"any",t);let b;if(o){const v=pt(p,c);b=te({inputs:{x:y},backend:t,attrs:{shape:v}})}else b=te({inputs:{x:y},backend:t,attrs:{shape:p}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(y),u!=null&&t.disposeIntermediateTensorInfo(d),b}const EA={kernelName:Vi,backendName:"webgl",kernelFunc:kA};/** 7856 * @license 7857 * Copyright 2017 Google LLC. All Rights Reserved. 7858 * Licensed under the Apache License, Version 2.0 (the "License"); 7859 * you may not use this file except in compliance with the License. 7860 * You may obtain a copy of the License at 7861 * 7862 * http://www.apache.org/licenses/LICENSE-2.0 7863 * 7864 * Unless required by applicable law or agreed to in writing, software 7865 * distributed under the License is distributed on an "AS IS" BASIS, 7866 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7867 * See the License for the specific language governing permissions and 7868 * limitations under the License. 7869 * ============================================================================= 7870 */class RA{constructor(e,t,r){this.variableNames=["A"];const{windowSize:s,batchSize:a,outSize:o}=e;r||this.variableNames.push("bestIndicesA"),this.outputShape=[a,o];const i=t==="max"?">":"<",c=r?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=` 7871 void main() { 7872 ivec2 coords = getOutputCoords(); 7873 int batch = coords[0]; 7874 int outIdx = coords[1]; 7875 int inOffset = outIdx * ${s}; 7876 7877 int bestIndex = inOffset; 7878 float bestValue = getA(batch, bestIndex); 7879 7880 for (int i = 0; i < ${s}; i++) { 7881 int inIdx = ${c}; 7882 float candidate = getA(batch, inIdx); 7883 if (candidate ${i} bestValue) { 7884 bestValue = candidate; 7885 bestIndex = inIdx; 7886 } 7887 } 7888 setOutput(float(bestIndex)); 7889 } 7890 `}}/** 7891 * @license 7892 * Copyright 2019 Google LLC. All Rights Reserved. 7893 * Licensed under the Apache License, Version 2.0 (the "License"); 7894 * you may not use this file except in compliance with the License. 7895 * You may obtain a copy of the License at 7896 * 7897 * http://www.apache.org/licenses/LICENSE-2.0 7898 * 7899 * Unless required by applicable law or agreed to in writing, software 7900 * distributed under the License is distributed on an "AS IS" BASIS, 7901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7902 * See the License for the specific language governing permissions and 7903 * limitations under the License. 7904 * ============================================================================= 7905 */class AA{constructor(e,t,r,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,N(e.length>2,()=>`Packed arg${r.charAt(0).toUpperCase()+r.slice(1)} supports only inputs with rank above 2.`);const a=e[e.length-1],o=Math.ceil(a/t);this.outputShape=e.slice(0,-1),o>1&&this.outputShape.push(o),s||this.variableNames.push("bestIndicesA");const i=this.outputShape,c=i.length,l=ze(c),u=Bt("coords",c);let d,p;if(o===1){p=c+1;const M=ze(p);d=` 7906 ${M} sourceLocR = ${M}(${u.join()}, 0); 7907 ++${u[c-1]}; 7908 ${M} sourceLocG = ${M}(${u.join()}, 0); 7909 ++${u[c-2]}; 7910 ${M} sourceLocA = ${M}(${u.join()}, 0); 7911 --${u[c-1]}; 7912 ${M} sourceLocB = ${M}(${u.join()}, 0); 7913 --${u[c-2]};`}else p=c,d=` 7914 ${l} sourceLocR = coords; 7915 ++${u[c-1]}; 7916 ${l} sourceLocG = coords; 7917 ++${u[c-2]}; 7918 ${l} sourceLocA = coords; 7919 --${u[c-1]}; 7920 ${l} sourceLocB = coords; 7921 --${u[c-2]};`;const h=["x","y","z","w","u","v"].slice(0,p),m="."+h[p-1],g=h.map(M=>"int "+M),y=Bt("sourceLocR",p-1).concat("inIdx.r"),b=Bt("sourceLocG",p-1).concat("inIdx.g"),v=Bt("sourceLocB",p-1).concat("inIdx.b"),$=Bt("sourceLocA",p-1).concat("inIdx.a"),S=r==="max"?"greaterThan":"lessThan",T=s?"":` 7922 inIdx = round(vec4(getBestIndicesAChannel(${y.join()}), 7923 getBestIndicesAChannel(${b.join()}), 7924 getBestIndicesAChannel(${v.join()}), 7925 getBestIndicesAChannel(${$.join()})));`,O=`vec4( 7926 getAChannel(${y.join()}), 7927 hasNextCol ? getAChannel(${b.join()}) : 0., 7928 hasNextRow ? getAChannel(${v.join()}) : 0., 7929 hasNextRow && hasNextCol ? getAChannel(${$.join()}) : 0.)`,L=s?"":` 7930 float getBestIndicesAChannel(${g.join()}) { 7931 return getChannel(getBestIndicesA(${h.join()}), 7932 vec2(${h.slice(-2).join()})); 7933 }`;this.userCode=` 7934 float getAChannel(${g.join()}) { 7935 return getChannel(getA(${h.join()}), 7936 vec2(${h.slice(-2).join()})); 7937 } 7938 ${L} 7939 void main() { 7940 ${l} coords = getOutputCoords(); 7941 bool hasNextCol = ${u[c-1]} < ${i[c-1]-1}; 7942 bool hasNextRow = ${u[c-2]} < ${i[c-2]-1}; 7943 ${d} 7944 ivec4 srcIdx = ivec4(sourceLocR${m}, sourceLocG${m}, 7945 sourceLocB${m}, sourceLocA${m}) * ${t}; 7946 ivec4 inIdx = srcIdx; 7947 vec4 bestIndex = vec4(inIdx); 7948 vec4 bestValue = ${O}; 7949 7950 for (int i = 0; i < ${t}; i++) { 7951 inIdx = srcIdx; 7952 ${T} 7953 vec4 candidate = ${O}; 7954 bvec4 nan = isnan(candidate); 7955 bvec4 replace = bvec4( 7956 vec4(${S}(candidate, bestValue)) * (vec4(1.0) - vec4(nan))); 7957 7958 bestValue = vec4(replace.x ? candidate.x : bestValue.x, 7959 replace.y ? candidate.y : bestValue.y, 7960 replace.z ? candidate.z : bestValue.z, 7961 replace.w ? candidate.w : bestValue.w); 7962 bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace)); 7963 srcIdx++; 7964 } 7965 setOutput(bestIndex); 7966 } 7967 `}}/** 7968 * @license 7969 * Copyright 2020 Google LLC. All Rights Reserved. 7970 * Licensed under the Apache License, Version 2.0 (the "License");
7971 * you may not use this file except in compliance with the License. 7972 * You may obtain a copy of the License at 7973 * 7974 * http://www.apache.org/licenses/LICENSE-2.0 7975 * 7976 * Unless required by applicable law or agreed to in writing, software 7977 * distributed under the License is distributed on an "AS IS" BASIS, 7978 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7979 * See the License for the specific language governing permissions and 7980 * limitations under the License. 7981 * ============================================================================= 7982 */function rb(n,e,t,r=null){let s=e.shape[0],a=e.shape[1];r!=null&&(s=r.shape[0],a=r.shape[1]);const o=Zu(a),i={windowSize:o,inSize:a,batchSize:s,outSize:Math.ceil(a/o)},c=new RA(i,t,r==null),l=[e];r!=null&&l.push(r);const u=n.runWebGLProgram(c,l,"int32");if(u.shape[1]===1)return u;const d=rb(n,e,t,u);return n.disposeIntermediateTensorInfo(u),d}function sb(n,e,t,r=null){const s=r!=null?r.shape:e.shape,a=s[s.length-1],o=Zu(a),i=new AA(s,o,t,r==null),c=r==null?[e]:[e,r],l=n.runWebGLProgram(i,c,"int32");if(l.shape.length===e.shape.length){const u=sb(n,e,t,l);return n.disposeIntermediateTensorInfo(l),u}return l}function ab(n,e,t,r){const s=[t];if(ht("arg"+r.charAt(0).toUpperCase()+r.slice(1),s,e.shape.length),!U().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const a=[],o=n.texData.get(e.dataId),i=o!==null&&o.isPacked;let c=e;i&&(c=n.unpackTensor(e),a.push(c));const[l,u]=At(c.shape,s),d=H(u),p=te({inputs:{x:c},backend:n,attrs:{shape:[-1,d]}});a.push(p);const h=rb(n,p,r);a.push(h);const m=te({inputs:{x:h},backend:n,attrs:{shape:l}});return a.forEach(g=>n.disposeIntermediateTensorInfo(g)),m}return sb(n,e,r)}/** 7983 * @license 7984 * Copyright 2020 Google LLC. All Rights Reserved. 7985 * Licensed under the Apache License, Version 2.0 (the "License"); 7986 * you may not use this file except in compliance with the License. 7987 * You may obtain a copy of the License at 7988 * 7989 * http://www.apache.org/licenses/LICENSE-2.0 7990 * 7991 * Unless required by applicable law or agreed to in writing, software 7992 * distributed under the License is distributed on an "AS IS" BASIS, 7993 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7994 * See the License for the specific language governing permissions and 7995 * limitations under the License. 7996 * ============================================================================= 7997 */function DA(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a}=r;let o=ot(a,s.shape);const i=Xt(o,s.shape.length);let c=s;const l=[];i!=null&&(c=Vt({inputs:{x:s},backend:t,attrs:{perm:i}}),l.push(c),o=St(o.length,c.shape.length)),ht("argMax",[o[0]],c.shape.length);const u=ab(t,c,o[0],"max");return l.forEach(d=>t.disposeIntermediateTensorInfo(d)),u}const OA={kernelName:kl,backendName:"webgl",kernelFunc:DA};/** 7998 * @license 7999 * Copyright 2020 Google LLC. All Rights Reserved. 8000 * Licensed under the Apache License, Version 2.0 (the "License"); 8001 * you may not use this file except in compliance with the License. 8002 * You may obtain a copy of the License at 8003 * 8004 * http://www.apache.org/licenses/LICENSE-2.0 8005 * 8006 * Unless required by applicable law or agreed to in writing, software 8007 * distributed under the License is distributed on an "AS IS" BASIS, 8008 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8009 * See the License for the specific language governing permissions and 8010 * limitations under the License. 8011 * ============================================================================= 8012 */function FA(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a}=r;let o=ot(a,s.shape);const i=Xt(o,s.shape.length);let c=s;const l=[];i!=null&&(c=Vt({inputs:{x:s},backend:t,attrs:{perm:i}}),l.push(c),o=St(o.length,c.shape.length)),ht("argMin",[o[0]],c.shape.length);const u=ab(t,c,o[0],"min");return l.forEach(d=>t.disposeIntermediateTensorInfo(d)),u}const PA={kernelName:El,backendName:"webgl",kernelFunc:FA};/** 8013 * @license 8014 * Copyright 2020 Google LLC. All Rights Reserved. 8015 * Licensed under the Apache License, Version 2.0 (the "License"); 8016 * you may not use this file except in compliance with the License. 8017 * You may obtain a copy of the License at 8018 * 8019 * http://www.apache.org/licenses/LICENSE-2.0 8020 * 8021 * Unless required by applicable law or agreed to in writing, softw
8021are 8022 * distributed under the License is distributed on an "AS IS" BASIS, 8023 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8024 * See the License for the specific language governing permissions and 8025 * limitations under the License. 8026 * ============================================================================= 8027 */const LA=Rn+` 8028 if (abs(x) > 1.) { 8029 return NAN; 8030 } 8031 return asin(x); 8032`,MA=De({opSnippet:LA}),BA={kernelName:Rl,backendName:"webgl",kernelFunc:MA};/** 8033 * @license 8034 * Copyright 2020 Google LLC. All Rights Reserved. 8035 * Licensed under the Apache License, Version 2.0 (the "License"); 8036 * you may not use this file except in compliance with the License. 8037 * You may obtain a copy of the License at 8038 * 8039 * http://www.apache.org/licenses/LICENSE-2.0 8040 * 8041 * Unless required by applicable law or agreed to in writing, software 8042 * distributed under the License is distributed on an "AS IS" BASIS, 8043 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8044 * See the License for the specific language governing permissions and 8045 * limitations under the License. 8046 * ============================================================================= 8047 */const VA=Rn+"return log(x + sqrt(x * x + 1.0));",WA=De({opSnippet:VA}),UA={kernelName:Al,backendName:"webgl",kernelFunc:WA};/** 8048 * @license 8049 * Copyright 2020 Google LLC. All Rights Reserved. 8050 * Licensed under the Apache License, Version 2.0 (the "License"); 8051 * you may not use this file except in compliance with the License. 8052 * You may obtain a copy of the License at 8053 * 8054 * http://www.apache.org/licenses/LICENSE-2.0 8055 * 8056 * Unless required by applicable law or agreed to in writing, software 8057 * distributed under the License is distributed on an "AS IS" BASIS, 8058 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8059 * See the License for the specific language governing permissions and 8060 * limitations under the License. 8061 * ============================================================================= 8062 */const zA=Rn+` 8063 return atan(x); 8064`,GA=De({opSnippet:zA}),HA={kernelName:Dl,backendName:"webgl",kernelFunc:GA};/** 8065 * @license 8066 * Copyright 2020 Google LLC. All Rights Reserved. 8067 * Licensed under the Apache License, Version 2.0 (the "License"); 8068 * you may not use this file except in compliance with the License. 8069 * You may obtain a copy of the License at 8070 * 8071 * http://www.apache.org/licenses/LICENSE-2.0 8072 * 8073 * Unless required by applicable law or agreed to in writing, software 8074 * distributed under the License is distributed on an "AS IS" BASIS, 8075 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8076 * See the License for the specific language governing permissions and 8077 * limitations under the License. 8078 * ============================================================================= 8079 */const jA=th+` 8080 return atan(a, b); 8081`,qA=` 8082 vec4 result = atan(a, b); 8083 bvec4 isNaNA = isnan(a); 8084 bvec4 isNaNB = isnan(b); 8085 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 8086 `+zs+` 8087 return result; 8088`,KA=Ct({opSnippet:jA,packedOpSnippet:qA}),XA={kernelName:Fl,backendName:"webgl",kernelFunc:KA};/** 8089 * @license 8090 * Copyright 2020 Google LLC. All Rights Reserved. 8091 * Licensed under the Apache License, Version 2.0 (the "License"); 8092 * you may not use this file except in compliance with the License. 8093 * You may obtain a copy of the License at 8094 * 8095 * http://www.apache.org/licenses/LICENSE-2.0 8096 * 8097 * Unless required by applicable law or agreed to in writing, software 8098 * distributed under the License is distributed on an "AS IS" BASIS, 8099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8100 * See the License for the specific language governing permissions and 8101 * limitations under the License. 8102 * ============================================================================= 8103 */const YA=Rn+` 8104 if ((x < -1.0) || (x > 1.0)) return NAN; 8105return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,QA=De({opSnippet:YA}),ZA={kernelName:Ol,backendName:"webgl",kernelFunc:QA};/** 8106 * @license 8107 * Copyright 2017 Google LLC. All Rights Reserved. 8108 * Licensed under the Apache License, Version 2.0 (the "License");
8109 * you may not use this file except in compliance with the License. 8110 * You may obtain a copy of the License at 8111 * 8112 * http://www.apache.org/licenses/LICENSE-2.0 8113 * 8114 * Unless required by applicable law or agreed to in writing, software 8115 * distributed under the License is distributed on an "AS IS" BASIS, 8116 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8117 * See the License for the specific language governing permissions and 8118 * limitations under the License. 8119 * ============================================================================= 8120 */class $o{constructor(e,t,r,s=!1,a=!1){if(this.variableNames=["x"],t==="avg"&&r)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,i=e.strideHeight,c=e.strideWidth,l=e.dilationHeight,u=e.dilationWidth,d=e.effectiveFilterHeight,p=e.effectiveFilterWidth,h=e.padInfo.top,m=e.padInfo.left;this.outputShape=e.outShape;const g=t==="avg",y=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,b=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let v="0.0";if(g||(v="-1.0 / 1e-20"),r){const M=">=";this.userCode=` 8121 const ivec2 strides = ivec2(${i}, ${c}); 8122 const ivec2 pads = ivec2(${h}, ${m}); 8123 8124 void main() { 8125 ivec4 coords = getOutputCoords(); 8126 int batch = coords[0]; 8127 int d = coords[3]; 8128 8129 ivec2 xRCCorner = coords.yz * strides - pads; 8130 int xRCorner = xRCCorner.x; 8131 int xCCorner = xRCCorner.y; 8132 8133 // max/min x(?, ?, d) to get y(yR, yC, d). 8134 // ? = to be determined 8135 float minMaxValue = 0.0; 8136 float minMaxValueFound = 0.0; 8137 int minMaxPosition = 0; 8138 float avgValue = 0.0; 8139 8140 for (int wR = 0; wR < ${d}; 8141 wR += ${l}) { 8142 int xR = xRCorner + wR; 8143 8144 if (xR < 0 || xR >= ${e.inHeight}) { 8145 continue; 8146 } 8147 8148 for (int wC = 0; wC < ${p}; 8149 wC += ${u}) { 8150 int xC = xCCorner + wC; 8151 8152 if (xC < 0 || xC >= ${e.inWidth}) { 8153 continue; 8154 } 8155 8156 float value = getX(batch, xR, xC, d); 8157 8158 // If a min / max value has already been found, use it. If not, 8159 // use the current value. 8160 float currMinMaxValue = mix( 8161 value, minMaxValue, minMaxValueFound); 8162 if (value ${M} currMinMaxValue) { 8163 minMaxValue = value; 8164 minMaxValueFound = 1.0; 8165 minMaxPosition = ${s?a?y:b:`wR * ${p} + wC`}; 8166 } 8167 } 8168 } 8169 setOutput(float(minMaxPosition)); 8170 } 8171 `;return}const $="max";let S=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(S="avgValue / max(count, 1.0)");const T=Math.floor(o/4)*4,O=o%4,L=` 8172 if (${g}) { 8173 avgValue += dot(values, ones); 8174 } else { 8175 minMaxValue = ${$}(values, minMaxValue); 8176 } 8177 `;this.userCode=` 8178 const ivec2 strides = ivec2(${i}, ${c}); 8179 const ivec2 pads = ivec2(${h}, ${m}); 8180 const float initializationValue = ${v}; 8181 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 8182 8183 float count = 0.0; 8184 8185 float getValue(int batch, int xR, int xC, int d) { 8186 if (xC < 0 || xC >= ${e.inWidth}) { 8187 return initializationValue; 8188 } 8189 count += 1.0; 8190 return getX(batch, xR, xC, d); 8191 } 8192 8193 void main() { 8194 ivec4 coords = getOutputCoords(); 8195 int batch = coords[0]; 8196 int d = coords[3]; 8197 8198 ivec2 xRCCorner = coords.yz * strides - pads; 8199 int xRCorner = xRCCorner.x; 8200 int xCCorner = xRCCorner.y; 8201 8202 // max/min x(?, ?, d) to get y(yR, yC, d). 8203 // ? = to be determined 8204 vec4 minMaxValue = vec4(${v}); 8205 float avgValue = 0.0; 8206 count = 0.0; 8207 8208 for (int wR = 0; wR < ${d}; 8209 wR += ${l}) { 8210 int xR = xRCorner + wR; 8211 8212 if (xR < 0 || xR >= ${e.inHeight}) { 8213 continue; 8214 } 8215 8216 for (int wC = 0; wC < ${T}; wC += 4) { 8217 int xC = xCCorner + wC * ${u}; 8218 8219 vec4 values = vec4( 8220 getValue(batch, xR, xC, d), 8221 getValue(batch, xR, xC + ${u}, d), 8222 getValue(batch, xR, xC + 2 * ${u}, d), 8223 getValue(batch, xR, xC + 3 * ${u}, d) 8224 ); 8225 8226 ${L} 8227 } 8228 8229 int xC = xCCorner + ${T}; 8230 if (${O===1}) { 8231 vec4 values = vec4( 8232 getValue(batch, xR, xC, d), 8233 initializationValue, 8234 initializationValue, 8235 initializationValue 8236 ); 8237 8238 ${L} 8239 } else if (${O===2}) { 8240 vec4 values = vec4( 8241 getValue(batch, xR, xC, d), 8242 getValue(batch, xR, xC + ${u}, d), 8243 initializationValue, 8244 initializationValue 8245 ); 8246 8247 ${L} 8248 } else if (${O===3}) { 8249 vec4 values = vec4( 8250 getValue(batch, xR, xC, d), 8251 getValue(batch, xR, xC + ${u}, d), 8252 getValue(batch, xR, xC + 2 * ${u}, d), 8253 initializationValue 8254 ); 8255 8256 ${L} 8257 } 8258 } 8259 setOutput(${S}); 8260 } 8261 `}}class rh{constructor(e,t,r,s=!1,a=!1){if(this.variableNames=["x"],t==="avg"&&r)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,i=e.strideDepth,c=e.strideHeight,l=e.strideWidth,u=e.dilationDepth,d=e.dilationHeight,p=e.dilationWidth,h=e.effectiveFilterDepth,m=e.effectiveFilterHeight,g=e.effectiveFilterWidth,y=e.padInfo.front,b=e.padInfo.top,v=e.padInfo.left;this.outputShape=e.outShape;const $=t==="avg";let S="0.0";if($||(S="-1.0 / 1e-20"),r){const V=">=";this.userCode=` 8262 const ivec3 strides = 8263 ivec3(${i}, ${c}, ${l}); 8264 const ivec3 pads = ivec3(${y}, ${b}, ${v}); 8265 8266 void main() { 8267 ivec5 coords = getOutputCoords(); 8268 int batch = coords.x; 8269 int ch = coords.u; 8270 8271 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 8272 int xDCorner = xCorner.x; 8273 int xRCorner = xCorner.y; 8274 int xCCorner = xCorner.z; 8275 8276 // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch). 8277 // ? = to be determined 8278 float minMaxValue = 0.0; 8279 float minMaxValueFound = 0.0; 8280 int minMaxPosition = 0; 8281 8282 for (int wD = 0; wD < ${h}; 8283 wD += ${u}) { 8284 int xD = xDCorner + wD; 8285 8286 if (xD < 0 || xD >= ${e.inDepth}) { 8287 continue; 8288 } 8289 8290 for (int wR = 0; wR < ${m}; 8291 wR += ${d}) { 8292 int xR = xRCorner + wR; 8293 8294 if (xR < 0 || xR >= ${e.inHeight}) { 8295 continue; 8296 } 8297 8298 for (int wC = 0; wC < ${g}; 8299 wC += ${p}) { 8300 int xC = xCCorner + wC; 8301 8302 if (xC < 0 || xC >= ${e.inWidth}) { 8303 continue; 8304 } 8305 8306 float value = getX(batch, xD, xR, xC, ch); 8307 8308 // If a min / max value has already been found, use it. If not, 8309 // use the current value. 8310 float currMinMaxValue = mix( 8311 value, minMaxValue, minMaxValueFound); 8312 if (value ${V} currMinMaxValue) { 8313 minMaxValue = value; 8314 minMaxValueFound = 1.0; 8315 minMaxPosition = ${s?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${m} * ${g} + 8316 wR * ${g} + wC`}; 8317 } 8318 } 8319 } 8320 } 8321 setOutput(float(minMaxPosition)); 8322 } 8323 `;return}const T="max";let O=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(O="avgValue / max(count, 1.0)");const L=Math.floor(o/4)*4,M=o%4,W=` 8324 if (${$}) { 8325 avgValue += dot(values, ones); 8326 } else { 8327 minMaxValue = ${T}(values, minMaxValue); 8328 } 8329 `;this.userCode=` 8330 const ivec3 strides = 8331 ivec3(${i}, ${c}, ${l}); 8332 const ivec3 pads = ivec3(${y}, ${b}, ${v}); 8333 const float initializationValue = ${S}; 8334 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 8335 8336 float count = 0.0; 8337 8338 float getValue(int batch, int xD, int xR, int xC, int ch) { 8339 if (xC < 0 || xC >= ${e.inWidth}) { 8340 return initializationValue; 8341 } 8342 count += 1.0; 8343 return getX(batch, xD, xR, xC, ch); 8344 } 8345 8346 void main() { 8347 ivec5 coords = getOutputCoords(); 8348 int batch = coords.x; 8349 int ch = coords.u; 8350 8351 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 8352 int xDCorner = xCorner.x; 8353 int xRCorner = xCorner.y; 8354 int xCCorner = xCorner.z; 8355 8356 // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch). 8357 // ? = to be determined 8358 vec4 minMaxValue = vec4(${S}); 8359 float avgValue = 0.0; 8360 count = 0.0; 8361 8362 for (int wD = 0; wD < ${h}; 8363 wD += ${u}) { 8364 int xD = xDCorner + wD; 8365 8366 if (xD < 0 || xD >= ${e.inDepth}) { 8367 continue; 8368 } 8369 8370 for (int wR = 0; wR < ${m}; 8371 wR += ${d}) { 8372 int xR = xRCorner + wR; 8373 8374 if (xR < 0 || xR >= ${e.inHeight}) { 8375 continue; 8376 } 8377 8378 for (int wC = 0; wC < ${L}; wC += 4) { 8379 int xC = xCCorner + wC * ${p}; 8380 8381 vec4 values = vec4( 8382 getValue(batch, xD, xR, xC, ch), 8383 getValue(batch, xD, xR, xC + ${p}, ch), 8384 getValue(batch, xD, xR, xC + 2 * ${p}, ch), 8385 getValue(batch, xD, xR, xC + 3 * ${p}, ch) 8386 ); 8387 8388 ${W} 8389 } 8390 8391 int xC = xCCorner + ${L}; 8392 if (${M===1}) { 8393 vec4 values = vec4( 8394 getValue(batch, xD, xR, xC, ch), 8395 initializationValue, 8396 initializationValue, 8397 initializationValue 8398 ); 8399 8400 ${W} 8401 } else if (${M===2}) { 8402 vec4 values = vec4( 8403 getValue(batch, xD, xR, xC, ch), 8404 getValue(batch, xD, xR, xC + ${p}, ch), 8405 initializationValue, 8406 initializationValue 8407 ); 8408 8409 ${W} 8410 } else if (${M===3}) { 8411 vec4 values = vec4( 8412 getValue(batch, xD, xR, xC, ch), 8413 getValue(batch, xD, xR, xC + ${p}, ch), 8414 getValue(batch, xD, xR, xC + 2 * ${p}, ch), 8415 initializationValue 8416 ); 8417 8418 ${W} 8419 } 8420 } 8421 } 8422 setOutput(${O}); 8423 } 8424 `}}/** 8425 * @license 8426 * Copyright 2020 Google LLC. All Rights Reserved. 8427 * Licensed under the Apache License, Version 2.0 (the "License");
8428 * you may not use this file except in compliance with the License. 8429 * You may obtain a copy of the License at 8430 * 8431 * http://www.apache.org/licenses/LICENSE-2.0 8432 * 8433 * Unless required by applicable law or agreed to in writing, software 8434 * distributed under the License is distributed on an "AS IS" BASIS, 8435 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8436 * See the License for the specific language governing permissions and 8437 * limitations under the License. 8438 * ============================================================================= 8439 */function JA(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;Po(s,"avgPool");const{filterSize:a,strides:o,pad:i,dimRoundingMode:c}=r,l=1;N(Kt(o,l),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${l}'`);const u=kn(s.shape,a,o,l,i,c);if(u.filterWidth===1&&u.filterHeight===1&&st(u.inShape,u.outShape))return rn({inputs:{x:s},backend:t});const d=new $o(u,"avg",!1);return t.runWebGLProgram(d,[s],"float32")}const eD={kernelName:Wi,backendName:"webgl",kernelFunc:JA};/** 8440 * @license 8441 * Copyright 2020 Google LLC. All Rights Reserved. 8442 * Licensed under the Apache License, Version 2.0 (the "License"); 8443 * you may not use this file except in compliance with the License. 8444 * You may obtain a copy of the License at 8445 * 8446 * http://www.apache.org/licenses/LICENSE-2.0 8447 * 8448 * Unless required by applicable law or agreed to in writing, software 8449 * distributed under the License is distributed on an "AS IS" BASIS, 8450 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8451 * See the License for the specific language governing permissions and 8452 * limitations under the License. 8453 * ============================================================================= 8454 */function tD(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:a,strides:o,pad:i,dimRoundingMode:c,dataFormat:l}=r,u=[1,1,1],d=Ir(s.shape,a,o,u,i,c,l),p=new rh(d,"avg",!1);return t.runWebGLProgram(p,[s],"float32")}const nD={kernelName:Pl,backendName:"webgl",kernelFunc:tD};/** 8455 * @license 8456 * Copyright 2017 Google LLC. All Rights Reserved. 8457 * Licensed under the Apache License, Version 2.0 (the "License"); 8458 * you may not use this file except in compliance with the License. 8459 * You may obtain a copy of the License at 8460 * 8461 * http://www.apache.org/licenses/LICENSE-2.0 8462 * 8463 * Unless required by applicable law or agreed to in writing, software 8464 * distributed under the License is distributed on an "AS IS" BASIS, 8465 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8466 * See the License for the specific language governing permissions and 8467 * limitations under the License. 8468 * ============================================================================= 8469 */class rD{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,s=e.strideHeight,a=e.strideWidth,o=e.dilationHeight,i=e.dilationWidth,c=e.effectiveFilterHeight,l=e.effectiveFilterWidth,u=c-1-e.padInfo.top,d=l-1-e.padInfo.left,p=1/(t*r);this.userCode=` 8470 const ivec2 pads = ivec2(${u}, ${d}); 8471 const float avgMultiplier = float(${p}); 8472 8473 void main() { 8474 ivec4 coords = getOutputCoords(); 8475 int b = coords[0]; 8476 int d = coords[3]; 8477 8478 ivec2 dyRCCorner = coords.yz - pads; 8479 int dyRCorner = dyRCCorner.x; 8480 int dyCCorner = dyRCCorner.y; 8481 8482 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 8483 // ? = to be determined. : = across all values in that axis. 8484 float dotProd = 0.0; 8485 for (int wR = 0; wR < ${c}; 8486 wR += ${o}) { 8487 float dyR = float(dyRCorner + wR) / ${s}.0; 8488 8489 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 8490 continue; 8491 } 8492 int idyR = int(dyR); 8493 8494 for (int wC = 0; wC < ${l}; 8495 wC+= ${i}) { 8496 float dyC = float(dyCCorner + wC) / ${a}.0; 8497 8498 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 8499 fract(dyC) > 0.0) { 8500 continue; 8501 } 8502 int idyC = int(dyC); 8503 8504 float dyValue = getDy(b, idyR, idyC, d); 8505 8506 dotProd += dyValue * avgMultiplier; 8507 } 8508 } 8509 setOutput(dotProd); 8510 } 8511 `}}class sD{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,r=e.filterHeight,s=e.filterWidth,a=e.strideDepth,o=e.strideHeight,i=e.strideWidth,c=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,d=e.effectiveFilterDepth,p=e.effectiveFilterHeight,h=e.effectiveFilterWidth,m=d-1-e.padInfo.front,g=p-1-e.padInfo.top,y=h-1-e.padInfo.left,b=1/(t*r*s);this.userCode=` 8512 const ivec3 pads = ivec3(${m}, ${g}, ${y}); 8513 const float avgMultiplier = float(${b}); 8514 8515 void main() { 8516 ivec5 coords = getOutputCoords(); 8517 int batch = coords.x; 8518 int ch = coords.u; 8519 8520 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 8521 int dyDCorner = dyCorner.x; 8522 int dyRCorner = dyCorner.y; 8523 int dyCCorner = dyCorner.z; 8524 8525 // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
8526 // dx(xD, xR, xC, ch). 8527 // ? = to be determined. : = across all values in that axis. 8528 float dotProd = 0.0; 8529 8530 for (int wD = 0; wD < ${d}; 8531 wD += ${c}) { 8532 float dyD = float(dyDCorner + wD) / ${a}.0; 8533 8534 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 8535 continue; 8536 } 8537 int idyD = int(dyD); 8538 8539 for (int wR = 0; wR < ${p}; 8540 wR += ${l}) { 8541 float dyR = float(dyRCorner + wR) / ${o}.0; 8542 8543 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 8544 fract(dyR) > 0.0) { 8545 continue; 8546 } 8547 int idyR = int(dyR); 8548 8549 for (int wC = 0; wC < ${h}; 8550 wC += ${u}) { 8551 float dyC = float(dyCCorner + wC) / ${i}.0; 8552 8553 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 8554 fract(dyC) > 0.0) { 8555 continue; 8556 } 8557 int idyC = int(dyC); 8558 8559 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 8560 8561 dotProd += dyValue * avgMultiplier; 8562 } 8563 } 8564 } 8565 setOutput(dotProd); 8566 } 8567 `}}/** 8568 * @license 8569 * Copyright 2020 Google LLC. All Rights Reserved. 8570 * Licensed under the Apache License, Version 2.0 (the "License"); 8571 * you may not use this file except in compliance with the License. 8572 * You may obtain a copy of the License at 8573 * 8574 * http://www.apache.org/licenses/LICENSE-2.0 8575 * 8576 * Unless required by applicable law or agreed to in writing, software 8577 * distributed under the License is distributed on an "AS IS" BASIS, 8578 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8579 * See the License for the specific language governing permissions and 8580 * limitations under the License. 8581 * ============================================================================= 8582 */function aD(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a}=e,o=a,{filterSize:i,strides:c,pad:l,dimRoundingMode:u}=r,d=[1,1,1],p=Ir(o.shape,i,c,d,l,u),h=new sD(p);return t.runWebGLProgram(h,[s],o.dtype)}const oD={kernelName:Yf,backendName:"webgl",kernelFunc:aD};/** 8583 * @license 8584 * Copyright 2020 Google LLC. All Rights Reserved. 8585 * Licensed under the Apache License, Version 2.0 (the "License"); 8586 * you may not use this file except in compliance with the License. 8587 * You may obtain a copy of the License at 8588 * 8589 * http://www.apache.org/licenses/LICENSE-2.0 8590 * 8591 * Unless required by applicable law or agreed to in writing, software 8592 * distributed under the License is distributed on an "AS IS" BASIS, 8593 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8594 * See the License for the specific language governing permissions and 8595 * limitations under the License. 8596 * ============================================================================= 8597 */function iD(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a}=e,o=a;Po([s,a],"avgPoolGrad");const{filterSize:i,strides:c,pad:l}=r,u=kn(o.shape,i,c,1,l),d=new rD(u);return t.runWebGLProgram(d,[s],o.dtype)}const uD={kernelName:Xf,backendName:"webgl",kernelFunc:iD};/** 8598 * @license 8599 * Copyright 2020 Google LLC. All Rights Reserved. 8600 * Licensed under the Apache License, Version 2.0 (the "License"); 8601 * you may not use this file except in compliance with the License. 8602 * You may obtain a copy of the License at 8603 * 8604 * http://www.apache.org/licenses/LICENSE-2.0 8605 * 8606 * Unless required by applicable law or agreed to in writing, software 8607 * distributed under the License is distributed on an "AS IS" BASIS, 8608 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8609 * See the License for the specific language governing permissions and 8610 * limitations under the License. 8611 * ============================================================================= 8612 */function cD(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:a}=e,{transposeA:o,transposeB:i}=r;return ki({a:s,b:a,transposeA:o,transposeB:i,backend:t})}const lD={kernelName:Ui,backendName:"webgl",kernelFunc:cD};/** 8613 * @license 8614 * Copyright 2017 Google LLC. All Rights Reserved. 8615 * Licensed under the Apache License, Version 2.0 (the "License");
8616 * you may not use this file except in compliance with the License. 8617 * You may obtain a copy of the License at 8618 * 8619 * http://www.apache.org/licenses/LICENSE-2.0 8620 * 8621 * Unless required by applicable law or agreed to in writing, software 8622 * distributed under the License is distributed on an "AS IS" BASIS, 8623 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8624 * See the License for the specific language governing permissions and 8625 * limitations under the License. 8626 * ============================================================================= 8627 */class dD{constructor(e,t,r,s,a,o){this.outputShape=[],this.variableNames=["x","mean","variance"],ke(e,t),ke(e,r);let i="0.0";s!=null&&(ke(e,s),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let c="1.0";a!=null&&(ke(e,a),this.variableNames.push("scale"),c="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 8628 void main() { 8629 float x = getXAtOutCoords(); 8630 float mean = getMeanAtOutCoords(); 8631 float variance = getVarianceAtOutCoords(); 8632 float offset = ${i}; 8633 float scale = ${c}; 8634 float inv = scale * inversesqrt(variance + float(${o})); 8635 setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1))); 8636 } 8637 `}}/** 8638 * @license 8639 * Copyright 2018 Google LLC. All Rights Reserved. 8640 * Licensed under the Apache License, Version 2.0 (the "License"); 8641 * you may not use this file except in compliance with the License. 8642 * You may obtain a copy of the License at 8643 * 8644 * http://www.apache.org/licenses/LICENSE-2.0 8645 * 8646 * Unless required by applicable law or agreed to in writing, software 8647 * distributed under the License is distributed on an "AS IS" BASIS, 8648 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8649 * See the License for the specific language governing permissions and 8650 * limitations under the License. 8651 * ============================================================================= 8652 */class pD{constructor(e,t,r,s,a,o){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],ke(e,t),ke(e,r);let i="vec4(0.0)";s!=null&&(ke(e,s),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let c="vec4(1.0)";a!=null&&(ke(e,a),this.variableNames.push("scale"),c="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 8653 void main() { 8654 vec4 offset = ${i}; 8655 vec4 scale = ${c}; 8656 8657 vec4 x = getXAtOutCoords(); 8658 vec4 mean = getMeanAtOutCoords(); 8659 vec4 variance = getVarianceAtOutCoords(); 8660 8661 vec4 inv = scale * inversesqrt(variance + vec4(${o})); 8662 8663 setOutput((x - mean) * inv + offset); 8664 } 8665 `}}/** 8666 * @license 8667 * Copyright 2020 Google LLC. All Rights Reserved. 8668 * Licensed under the Apache License, Version 2.0 (the "License"); 8669 * you may not use this file except in compliance with the License. 8670 * You may obtain a copy of the License at 8671 * 8672 * http://www.apache.org/licenses/LICENSE-2.0 8673 * 8674 * Unless required by applicable law or agreed to in writing, software 8675 * distributed under the License is distributed on an "AS IS" BASIS, 8676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8677 * See the License for the specific language governing permissions and 8678 * limitations under the License. 8679 * ============================================================================= 8680 */const hD=({inputs:n,backend:e,attrs:t})=>{const{x:r,mean:s,variance:a,offset:o,scale:i}=n;N(s.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),N(o==null||s.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),N(i==null||s.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:c}=t;c==null&&(c=.001);const l=[r,s,a];let u=null;o!=null&&(u=o.shape,l.push(o));let d=null;i!=null&&(d=i.shape,l.push(i));const p=U().getBool("WEBGL_PACK_NORMALIZATION")?new pD(r.shape,s.shape,a.shape,u,d,c):new dD(r.shape,s.shape,a.shape,u,d,c);return e.runWebGLProgram(p,l,l[0].dtype)},fD={kernelName:ru,backendName:"webgl",kernelFunc:hD};/** 8681 * @license 8682 * Copyright 2017 Google LLC. All Rights Reserved. 8683 * Licensed under the Apache License, Version 2.0 (the "License");
8684 * you may not use this file except in compliance with the License. 8685 * You may obtain a copy of the License at 8686 * 8687 * http://www.apache.org/licenses/LICENSE-2.0 8688 * 8689 * Unless required by applicable law or agreed to in writing, software 8690 * distributed under the License is distributed on an "AS IS" BASIS, 8691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8692 * See the License for the specific language governing permissions and 8693 * limitations under the License. 8694 * ============================================================================= 8695 */class mD{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=ze(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const r=gD(this.rank);let s;const a=e.map((o,i)=>`sourceLoc.${nl[i]} = start[${i}] + coords.${nl[i]};`);s=` 8696 ${t} sourceLoc; 8697 ${t} coords = getOutputCoords(); 8698 ${a.join(` 8699`)} 8700 `,this.userCode=` 8701 void main() { 8702 ${s} 8703 setOutput(getSource(${r})); 8704 } 8705 `}}const nl=["x","y","z","w","u","v"];function gD(n){if(n===1)return"sourceLoc";if(n<=6)return nl.slice(0,n).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${n} is not yet supported`)}/** 8706 * @license 8707 * Copyright 2019 Google LLC. All Rights Reserved. 8708 * Licensed under the Apache License, Version 2.0 (the "License"); 8709 * you may not use this file except in compliance with the License. 8710 * You may obtain a copy of the License at 8711 * 8712 * http://www.apache.org/licenses/LICENSE-2.0 8713 * 8714 * Unless required by applicable law or agreed to in writing, software 8715 * distributed under the License is distributed on an "AS IS" BASIS, 8716 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8717 * See the License for the specific language governing permissions and 8718 * limitations under the License. 8719 * ============================================================================= 8720 */class yD{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=ze(this.rank),r=Bt("coords",this.rank),s=Bt("sourceLoc",this.rank),a=this.rank===1?"sourceLoc":`vec2(${s.slice(-2).join()})`,o=`getChannel(getSource(${s.join()}), ${a})`,i=` 8721 result.x = ${o}; 8722 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 8723 ++${s[this.rank-1]}; 8724 result.y = ${o}; 8725 --${s[this.rank-1]}; 8726 } 8727 `,c=this.rank===1?"":` 8728 --${r[this.rank-1]}; 8729 if (++${r[this.rank-2]} < ${e[this.rank-2]}) { 8730 ++${s[this.rank-2]}; 8731 result.z = ${o}; 8732 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 8733 ++${s[this.rank-1]}; 8734 result.w = ${o}; 8735 } 8736 } 8737 `,l=this.rank<=4?`sourceLoc = coords + 8738 ${t}(${e.map((u,d)=>`start[${d}]`).join()});`:e.map((u,d)=>`${s[d]} = ${r[d]} + start[${d}];`).join(` 8739`);this.userCode=` 8740 void main() { 8741 ${t} coords = getOutputCoords(); 8742 ${t} sourceLoc; 8743 ${l} 8744 vec4 result = vec4(0.); 8745 ${i} 8746 ${c} 8747 setOutput(result); 8748 } 8749 `}}/** 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 bD(n,e,t,r){const s=r.texData.get(n.dataId),a=r.makeTensorInfo(t,n.dtype),o=r.texData.get(a.dataId);Object.assign(o,s),o.refCount=1,o.shape=t,o.dtype=n.dtype;let i=Qu(e,Be(n.shape));
vendor: 4,662 bytes, lines 8764-8820
8764s.slice&&(i+=s.slice.flatOffset),o.slice={flatOffset:i,origDataId:s.slice&&s.slice.origDataId||n.dataId};const c=r.dataRefCount.get(o.slice.origDataId)||1;return r.dataRefCount.set(o.slice.origDataId,c+1),a}function Ba(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{begin:a,size:o}=r,[i,c]=kp(s,a,o);if(Jg(s,i,c),H(c)===0)return t.makeTensorInfo(c,s.dtype,[]);if(t.shouldExecuteOnCPU([s])||s.dtype==="string"){const d=t.texData.get(s.dataId),p=lR(d.values,i,c,s.shape,s.dtype);return t.makeTensorInfo(c,s.dtype,p)}const{isPacked:l}=t.texData.get(s.dataId),u=Yu(s.shape,i,c);if(l||!u){const d=U().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new yD(c):new mD(c),p=[i];return t.runWebGLProgram(d,[s],s.dtype,p)}return t.uploadToGPU(s.dataId),bD(s,i,c,t)}const xD={kernelName:Vd,backendName:"webgl",kernelFunc:Ba};/** 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 */const wD=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockShape:a,crops:o}=r;N(s.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const i=a.reduce((v,$)=>v*$),c=Ao(s.shape,a,i),l=Do(c.length,a.length),u=Oo(s.shape,a,i),d=Op(o,a.length),p=Fp(u,o,a.length),h=[],m=te({inputs:{x:s},backend:t,attrs:{shape:c}}),g=Vt({inputs:{x:m},backend:t,attrs:{perm:l}}),y=te({inputs:{x:g},backend:t,attrs:{shape:u}}),b=Ba({inputs:{x:y},backend:t,attrs:{begin:d,size:p}});return h.push(m),h.push(g),h.push(y),h.forEach(v=>t.disposeIntermediateTensorInfo(v)),b},vD={kernelName:Ll,backendName:"webgl",kernelFunc:wD};/** 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 ID(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,weights:a}=e,{size:o}=r,i=t.readSync(s.dataId),c=t.readSync(a.dataId),l=jy(i,c,a.dtype,a.shape,o);return t.makeTensorInfo([o],a.dtype,l)}const $D={kernelName:zi,backendName:"webgl",kernelFunc:ID};/** 8795 * @license 8796 * Copyright 2023 Google LLC. 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 */const SD=` 8810 int r = int(a.r) & int(b.r); 8811 int g = int(a.g) & int(b.g); 8812 int rb = int(a.b) & int(b.b); 8813 int ra = int(a.a) & int(b.a); 8814 return vec4(r, g, rb, ra); 8815`,CD=` 8816 return float(int(a.r) & int(b.r)); 8817`;function _D(n){const{inputs:e,backend:t}=n,{a:r,b:s}=e,a=U().getBool("WEBGL_PACK_BINARY_OPERATIONS"),o=U().getNumber("WEBGL_VERSION");if(t.shouldExecuteOnCPU([r,s])||o===1){const c=t.texData.get(r.dataId).values,l=t.texData.get(s.dataId).values,[u,d]=OE(r.shape,s.shape,c,l,r.dtype),p=t.makeTensorInfo(d,r.dtype),h=t.texData.get(p.dataId);return h.values=u,p}let i;return a?i=new La(SD,r.shape,s.shape,!1):i=new Ds(CD,r.shape,s.shape),t.runWebGLProgram(i,[r,s],r.dtype)}const ND={kernelName:Ml,backendName:"webgl",kernelFunc:_D};/** 8818 * @license 8819 * Copyright 2021 Google LLC. All Rights Reserved. 8820 * Licensed under the Apache License, Version 2.0 (the "License");
8821 * you may not use this file except in compliance with the License. 8822 * You may obtain a copy of the License at 8823 * 8824 * http://www.apache.org/licenses/LICENSE-2.0 8825 * 8826 * Unless required by applicable law or agreed to in writing, software 8827 * distributed under the License is distributed on an "AS IS" BASIS, 8828 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8829 * See the License for the specific language governing permissions and 8830 * limitations under the License. 8831 * ============================================================================= 8832 */function TD(n){const{inputs:e,backend:t}=n,{s0:r,s1:s}=e,a=t.readSync(r.dataId),o=t.readSync(s.dataId),i=ke(Array.from(a),Array.from(o));return t.makeTensorInfo([i.length],"int32",Int32Array.from(i))}const kD={kernelName:Bl,backendName:"webgl",kernelFunc:TD};/** 8833 * @license 8834 * Copyright 2020 Google LLC. All Rights Reserved. 8835 * Licensed under the Apache License, Version 2.0 (the "License"); 8836 * you may not use this file except in compliance with the License. 8837 * You may obtain a copy of the License at 8838 * 8839 * http://www.apache.org/licenses/LICENSE-2.0 8840 * 8841 * Unless required by applicable law or agreed to in writing, software 8842 * distributed under the License is distributed on an "AS IS" BASIS, 8843 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8844 * See the License for the specific language governing permissions and 8845 * limitations under the License. 8846 * ============================================================================= 8847 */const ED="return float(a != b);",ob=Ct({opSnippet:ED,cpuKernelImpl:tR,dtype:"bool"}),RD={kernelName:Cd,backendName:"webgl",kernelFunc:ob};/** 8848 * @license 8849 * Copyright 2020 Google LLC. All Rights Reserved. 8850 * Licensed under the Apache License, Version 2.0 (the "License"); 8851 * you may not use this file except in compliance with the License. 8852 * You may obtain a copy of the License at 8853 * 8854 * http://www.apache.org/licenses/LICENSE-2.0 8855 * 8856 * Unless required by applicable law or agreed to in writing, software 8857 * distributed under the License is distributed on an "AS IS" BASIS, 8858 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8859 * See the License for the specific language governing permissions and 8860 * limitations under the License. 8861 * ============================================================================= 8862 */function Mo(n){const{inputs:e,backend:t}=n,{input:r}=e,s=t.texData.get(r.dataId);return rn({inputs:{x:s.complexTensorInfos.real},backend:t})}const AD={kernelName:hm,backendName:"webgl",kernelFunc:Mo};/** 8863 * @license 8864 * Copyright 2020 Google LLC. All Rights Reserved. 8865 * Licensed under the Apache License, Version 2.0 (the "License"); 8866 * you may not use this file except in compliance with the License. 8867 * You may obtain a copy of the License at 8868 * 8869 * http://www.apache.org/licenses/LICENSE-2.0 8870 * 8871 * Unless required by applicable law or agreed to in writing, software 8872 * distributed under the License is distributed on an "AS IS" BASIS, 8873 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8874 * See the License for the specific language governing permissions and 8875 * limitations under the License. 8876 * ============================================================================= 8877 */const DD="return float(int(x));";function OD(n,e){const t=new sr(n.shape,DD),r=e.runWebGLProgram(t,[n],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}/** 8878 * @license 8879 * Copyright 2020 Google LLC. All Rights Reserved. 8880 * Licensed under the Apache License, Version 2.0 (the "License"); 8881 * you may not use this file except in compliance with the License. 8882 * You may obtain a copy of the License at 8883 * 8884 * http://www.apache.org/licenses/LICENSE-2.0 8885 * 8886 * Unless required by applicable law or agreed to in writing, software 8887 * distributed under the License is distributed on an "AS IS" BASIS, 8888 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8889 * See the License for the specific language governing permissions and 8890 * limitations under the License. 8891 * ============================================================================= 8892 */function rl(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{dtype:a}=r;if(a==="complex64"){if(s.dtype==="complex64")return rn({inputs:{x:s},backend:t});const o=Es(s.shape),i=rl({inputs:{x:s},backend:t,attrs:{dtype:"float32"}}),c=Qr({inputs:{real:i,imag:o},backend:t});
vendor: 4,164 bytes, lines 8892-8968
8892return o.dispose(),t.disposeIntermediateTensorInfo(i),c}if(s.dtype==="complex64"){const o=Mo({inputs:{input:s},backend:t}),i=rl({inputs:{x:o},backend:t,attrs:{dtype:a}});return t.disposeIntermediateTensorInfo(o),i}if(!P0(s.dtype,a)){const o=rn({inputs:{x:s},backend:t});return{dataId:o.dataId,shape:o.shape,dtype:a}}if(t.shouldExecuteOnCPU([s])){const o=t.texData.get(s.dataId).values,[i,c,l]=FE(o,s.shape,s.dtype,a);return t.makeTensorInfo(i,c,l)}if(a==="int32")return OD(s,t);if(a==="bool"){const o=t.makeTensorInfo([],"bool",Wr("bool",1)),c=ob({inputs:{a:s,b:o},backend:t});return t.disposeIntermediateTensorInfo(o),c}throw new Error(`Error in Cast: failed to cast ${s.dtype} to ${a}`)}const FD={kernelName:Gi,backendName:"webgl",kernelFunc:rl};/** 8893 * @license 8894 * Copyright 2020 Google LLC. All Rights Reserved. 8895 * Licensed under the Apache License, Version 2.0 (the "License"); 8896 * you may not use this file except in compliance with the License. 8897 * You may obtain a copy of the License at 8898 * 8899 * http://www.apache.org/licenses/LICENSE-2.0 8900 * 8901 * Unless required by applicable law or agreed to in writing, software 8902 * distributed under the License is distributed on an "AS IS" BASIS, 8903 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8904 * See the License for the specific language governing permissions and 8905 * limitations under the License. 8906 * ============================================================================= 8907 */const hf="return ceil(x);",PD=De({opSnippet:hf,packedOpSnippet:hf,cpuKernelImpl:PE}),LD={kernelName:Vl,backendName:"webgl",kernelFunc:PD};/** 8908 * @license 8909 * Copyright 2017 Google LLC. All Rights Reserved. 8910 * Licensed under the Apache License, Version 2.0 (the "License"); 8911 * you may not use this file except in compliance with the License. 8912 * You may obtain a copy of the License at 8913 * 8914 * http://www.apache.org/licenses/LICENSE-2.0 8915 * 8916 * Unless required by applicable law or agreed to in writing, software 8917 * distributed under the License is distributed on an "AS IS" BASIS, 8918 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8919 * See the License for the specific language governing permissions and 8920 * limitations under the License. 8921 * ============================================================================= 8922 */class MD{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` 8923 8924 void main() { 8925 float value = getAAtOutCoords(); 8926 if (isnan(value)) { 8927 setOutput(value); 8928 return; 8929 } 8930 8931 setOutput(clamp(value, minVal, maxVal)); 8932 } 8933 `}}/** 8934 * @license 8935 * Copyright 2018 Google LLC. All Rights Reserved. 8936 * Licensed under the Apache License, Version 2.0 (the "License"); 8937 * you may not use this file except in compliance with the License. 8938 * You may obtain a copy of the License at 8939 * 8940 * http://www.apache.org/licenses/LICENSE-2.0 8941 * 8942 * Unless required by applicable law or agreed to in writing, software 8943 * distributed under the License is distributed on an "AS IS" BASIS, 8944 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8945 * See the License for the specific language governing permissions and 8946 * limitations under the License. 8947 * ============================================================================= 8948 */class BD{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=` 8949 void main() { 8950 vec4 value = getAAtOutCoords(); 8951 8952 if (any(isnan(value))) { 8953 setOutput(value); 8954 return; 8955 } 8956 8957 setOutput(clamp(value, vec4(minVal), vec4(maxVal))); 8958 } 8959 `}}/** 8960 * @license 8961 * Copyright 2020 Google LLC. All Rights Reserved. 8962 * Licensed under the Apache License, Version 2.0 (the "License"); 8963 * you may not use this file except in compliance with the License. 8964 * You may obtain a copy of the License at 8965 * 8966 * http://www.apache.org/licenses/LICENSE-2.0 8967 * 8968 * Unless required by applicable law or agreed to in writing, softw
8968are 8969 * distributed under the License is distributed on an "AS IS" BASIS, 8970 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8971 * See the License for the specific language governing permissions and 8972 * limitations under the License. 8973 * ============================================================================= 8974 */function VD(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{clipValueMin:a,clipValueMax:o}=r;let i;U().getBool("WEBGL_PACK_CLIP")?i=new BD(s.shape):i=new MD(s.shape);const c=[[a],[o]];return t.runWebGLProgram(i,[s],s.dtype,c)}const WD={kernelName:Hi,backendName:"webgl",kernelFunc:VD};/** 8975 * @license 8976 * Copyright 2018 Google LLC. All Rights Reserved. 8977 * Licensed under the Apache License, Version 2.0 (the "License"); 8978 * you may not use this file except in compliance with the License. 8979 * You may obtain a copy of the License at 8980 * 8981 * http://www.apache.org/licenses/LICENSE-2.0 8982 * 8983 * Unless required by applicable law or agreed to in writing, software 8984 * distributed under the License is distributed on an "AS IS" BASIS, 8985 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8986 * See the License for the specific language governing permissions and 8987 * limitations under the License. 8988 * ============================================================================= 8989 */class UD{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` 8990 void main() { 8991 float re = abs(getRealAtOutCoords()); 8992 float im = abs(getImagAtOutCoords()); 8993 float mx = max(re, im); 8994 8995 // sadly the length function in glsl is not underflow-safe 8996 // (at least not on Intel GPUs). So the safe solution is 8997 // to ensure underflow-safety in all cases. 8998 setOutput( 8999 mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx)) 9000 ); 9001 } 9002 `}}/** 9003 * @license 9004 * Copyright 2020 Google LLC. All Rights Reserved. 9005 * Licensed under the Apache License, Version 2.0 (the "License"); 9006 * you may not use this file except in compliance with the License. 9007 * You may obtain a copy of the License at 9008 * 9009 * http://www.apache.org/licenses/LICENSE-2.0 9010 * 9011 * Unless required by applicable law or agreed to in writing, software 9012 * distributed under the License is distributed on an "AS IS" BASIS, 9013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9014 * See the License for the specific language governing permissions and 9015 * limitations under the License. 9016 * ============================================================================= 9017 */function ff(n,e){return{dataId:e.dataId,dtype:e.dtype,shape:n.shape}}function zD(n){const{inputs:e,backend:t}=n,{x:r}=e,s=t.texData.get(r.dataId),a=new UD(r.shape),o=[ff(r,s.complexTensorInfos.real),ff(r,s.complexTensorInfos.imag)];return t.runWebGLProgram(a,o,o[0].dtype)}const GD={kernelName:Zf,backendName:"webgl",kernelFunc:zD};/** 9018 * @license 9019 * Copyright 2017 Google LLC. All Rights Reserved. 9020 * Licensed under the Apache License, Version 2.0 (the "License"); 9021 * you may not use this file except in compliance with the License. 9022 * You may obtain a copy of the License at 9023 * 9024 * http://www.apache.org/licenses/LICENSE-2.0 9025 * 9026 * Unless required by applicable law or agreed to in writing, software 9027 * distributed under the License is distributed on an "AS IS" BASIS, 9028 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9029 * See the License for the specific language governing permissions and 9030 * limitations under the License. 9031 * ============================================================================= 9032 */class HD{constructor(e){this.outputShape=[],this.outputShape=or(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 s=t.length,a=t[t.length-1];r.push(`else setOutput(getT${s}(yR, yC-${a}));`),this.userCode=` 9033 void main() { 9034 ivec2 coords = getOutputCoords(); 9035 int yR = coords.x; 9036 int yC = coords.y; 9037 9038 ${r.join(` 9039 `)} 9040 } 9041 `}}/** 9042 * @license 9043 * Copyright 2019 Google LLC. All Rights Reserved. 9044 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 35,057 bytes, lines 9045-9730
9045 * you may not use this file except in compliance with the License. 9046 * You may obtain a copy of the License at 9047 * 9048 * http://www.apache.org/licenses/LICENSE-2.0 9049 * 9050 * Unless required by applicable law or agreed to in writing, software 9051 * distributed under the License is distributed on an "AS IS" BASIS, 9052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9053 * See the License for the specific language governing permissions and 9054 * limitations under the License. 9055 * ============================================================================= 9056 */class jD{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=or(e,t);const r=this.outputShape,s=r.length,a=ze(s),o=Bt("coords",s),i=["x","y","z","w","u","v"].slice(0,s);this.variableNames=e.map((g,y)=>`T${y}`);const c=new Array(e.length-1);c[0]=e[0][t];for(let g=1;g<c.length;g++)c[g]=c[g-1]+e[g][t];const l=i[t],u=i.slice(-2),d=i.join();let p=`if (${l} < ${c[0]}) { 9057 return getChannel( 9058 getT0(${d}), vec2(${u.join()})); 9059 }`;for(let g=1;g<c.length;g++){const y=c[g-1];p+=` 9060 if (${l} < ${c[g]} && ${l} >= ${c[g-1]}) { 9061 return getChannel( 9062 getT${g}(${li(i,l,y)}), 9063 vec2(${li(u,l,y)})); 9064 }`}const h=c.length,m=c[c.length-1];p+=` 9065 return getChannel( 9066 getT${h}(${li(i,l,m)}), 9067 vec2(${li(u,l,m)}));`,this.userCode=` 9068 float getValue(${i.map(g=>"int "+g)}) { 9069 ${p} 9070 } 9071 9072 void main() { 9073 ${a} coords = getOutputCoords(); 9074 vec4 result = vec4(getValue(${o}), 0., 0., 0.); 9075 9076 ${o[s-1]} = ${o[s-1]} + 1; 9077 if (${o[s-1]} < ${r[s-1]}) { 9078 result.g = getValue(${o}); 9079 } 9080 9081 ${o[s-2]} = ${o[s-2]} + 1; 9082 if (${o[s-2]} < ${r[s-2]}) { 9083 result.a = getValue(${o}); 9084 } 9085 9086 ${o[s-1]} = ${o[s-1]} - 1; 9087 if (${o[s-2]} < ${r[s-2]} && 9088 ${o[s-1]} < ${r[s-1]}) { 9089 result.b = getValue(${o}); 9090 } 9091 setOutput(result); 9092 } 9093 `}}function li(n,e,t){const r=n.indexOf(e);return n.map((a,o)=>o===r?`${a} - ${t}`:a).join()}/** 9094 * @license 9095 * Copyright 2020 Google LLC. All Rights Reserved. 9096 * Licensed under the Apache License, Version 2.0 (the "License"); 9097 * you may not use this file except in compliance with the License. 9098 * You may obtain a copy of the License at 9099 * 9100 * http://www.apache.org/licenses/LICENSE-2.0 9101 * 9102 * Unless required by applicable law or agreed to in writing, software 9103 * distributed under the License is distributed on an "AS IS" BASIS, 9104 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9105 * See the License for the specific language governing permissions and 9106 * limitations under the License. 9107 * ============================================================================= 9108 */function rc(n){const{inputs:e,backend:t}=n,{input:r}=e,s=t.texData.get(r.dataId);return rn({inputs:{x:s.complexTensorInfos.imag},backend:t})}const qD={kernelName:im,backendName:"webgl",kernelFunc:rc};/** 9109 * @license 9110 * Copyright 2020 Google LLC. All Rights Reserved. 9111 * Licensed under the Apache License, Version 2.0 (the "License"); 9112 * you may not use this file except in compliance with the License. 9113 * You may obtain a copy of the License at 9114 * 9115 * http://www.apache.org/licenses/LICENSE-2.0 9116 * 9117 * Unless required by applicable law or agreed to in writing, software 9118 * distributed under the License is distributed on an "AS IS" BASIS, 9119 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9120 * See the License for the specific language governing permissions and 9121 * limitations under the License. 9122 * ============================================================================= 9123 */function ao(n,e,t){const r=n[0].dtype;if(r==="complex64"){const h=n.map(v=>Mo({inputs:{input:v},backend:t})),m=n.map(v=>rc({inputs:{input:v},backend:t})),g=ao(h,e,t),y=ao(m,e,t),b=Qr({inputs:{real:g,imag:y},backend:t});return h.forEach(v=>t.disposeIntermediateTensorInfo(v)),m.forEach(v=>t.disposeIntermediateTensorInfo(v)),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(y),b}let s=t.shouldExecuteOnCPU(n);if(r==="string"&&(s=!0),s){const h=n.map(S=>{const O=[-1,H(S.shape.slice(e))];return te({inputs:{x:S},backend:t,attrs:{shape:O}})}),m=h.map(S=>({vals:t.readSync(S.dataId),shape:S.shape})),g=or(h.map(S=>S.shape),1),y=h[0].shape[0]===1,b=LE(m,g,r,y),v=or(n.map(S=>S.shape),e),$=t.makeTensorInfo(v,r,b);return h.forEach(S=>t.disposeIntermediateTensorInfo(S)),$}const a=n.filter(h=>H(h.shape)>0),o=U().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&a[0].shape.length>1;if(a.length===1){const h=o?new sr(n[0].shape,Or):new Lr(n[0].shape,Or);return t.runWebGLProgram(h,n,r)}const i=U().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(a.length>i){const h=[];for(let g=0;g<a.length;g+=i){const y=a.slice(g,g+i);h.push(ao(y,e,t))}const m=ao(h,e,t);for(const g of h)t.disposeIntermediateTensorInfo(g);return m}if(o){const h=new jD(a.map(m=>m.shape),e);return t.runWebGLProgram(h,a,r)}const{tensors2D:c,outShape:l}=KD(a,e,t),u=new HD(c.map(h=>h.shape)),d=t.runWebGLProgram(u,c,r);c.forEach(h=>t.disposeIntermediateTensorInfo(h));const p=te({inputs:{x:d},attrs:{shape:l},backend:t});return t.disposeIntermediateTensorInfo(d),p}function KD(n,e,t){const r=or(n.map(a=>a.shape),e);return{tensors2D:n.map(a=>te({inputs:{x:a},attrs:{shape:[-1,H(a.shape.slice(e))]},backend:t})),outShape:r}}/** 9124 * @license 9125 * Copyright 2020 Google LLC. All Rights Reserved. 9126 * Licensed under the Apache License, Version 2.0 (the "License"); 9127 * you may not use this file except in compliance with the License. 9128 * You may obtain a copy of the License at 9129 * 9130 * http://www.apache.org/licenses/LICENSE-2.0 9131 * 9132 * Unless required by applicable law or agreed to in writing, software 9133 * distributed under the License is distributed on an "AS IS" BASIS, 9134 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9135 * See the License for the specific language governing permissions and 9136 * limitations under the License. 9137 * ============================================================================= 9138 */function ib(n){const{inputs:e,backend:t,attrs:r}=n,{axis:s}=r,a=ot(s,e[0].shape)[0],o=e.map(l=>l.shape);Rp(o,a);const i=or(e.map(l=>l.shape),a);if(H(i)===0)return t.makeTensorInfo(i,e[0].dtype,[]);const c=e.filter(l=>H(l.shape)>0);return c.length===1?rn({inputs:{x:c[0]},backend:t}):ao(c,a,t)}const XD={kernelName:Wl,backendName:"webgl",kernelFunc:ib};/** 9139 * @license 9140 * Copyright 2017 Google LLC. All Rights Reserved. 9141 * Licensed under the Apache License, Version 2.0 (the "License"); 9142 * you may not use this file except in compliance with the License. 9143 * You may obtain a copy of the License at 9144 * 9145 * http://www.apache.org/licenses/LICENSE-2.0 9146 * 9147 * Unless required by applicable law or agreed to in writing, software 9148 * distributed under the License is distributed on an "AS IS" BASIS, 9149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9150 * See the License for the specific language governing permissions and 9151 * limitations under the License. 9152 * ============================================================================= 9153 */class ub{constructor(e,t=!1,r=null,s=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const o=e.padInfo.top,i=e.padInfo.left,c=e.strideHeight,l=e.strideWidth,u=e.dilationHeight,d=e.dilationWidth,p=e.filterHeight,h=e.filterWidth,m=Math.floor(e.inChannels/4)*4,g=e.inChannels%4,y=e.dataFormat==="channelsLast",b=y?1:2,v=y?2:3,$=y?3:1;let S="",T="";r&&(s?S=`float activation(float a) { 9154 float b = getPreluActivationWeightsAtOutCoords(); 9155 ${r} 9156 }`:a?S=`float activation(float a) { 9157 float b = getLeakyreluAlphaAtOutCoords(); 9158 ${r} 9159 }`:S=` 9160 float activation(float x) { 9161 ${r} 9162 } 9163 `,T="result = activation(result);");const O=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 9164 ${S} 9165 9166 const ivec2 strides = ivec2(${c}, ${l}); 9167 const ivec2 pads = ivec2(${o}, ${i}); 9168 9169 void main() { 9170 ivec4 coords = getOutputCoords(); 9171 int batch = coords[0]; 9172 int d2 = coords[${$}]; 9173 9174 ivec2 xRCCorner = 9175 ivec2(coords[${b}], coords[${v}]) * strides - pads; 9176 int xRCorner = xRCCorner.x; 9177 int xCCorner = xRCCorner.y; 9178 9179 // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2). 9180 // ? = to be determined. : = across all values in that axis. 9181 float dotProd = 0.0; 9182 for (int wR = 0; wR < ${p}; wR++) { 9183 int xR = xRCorner + wR * ${u}; 9184 9185 if (xR < 0 || xR >= ${e.inHeight}) { 9186 continue; 9187 } 9188 9189 for (int wC = 0; wC < ${h}; wC++) { 9190 int xC = xCCorner + wC * ${d}; 9191 9192 if (xC < 0 || xC >= ${e.inWidth}) { 9193 continue; 9194 } 9195 9196 for (int d1 = 0; d1 < ${m}; d1 += 4) { 9197 vec4 wValues = vec4( 9198 getW(wR, wC, d1, d2), 9199 getW(wR, wC, d1 + 1, d2), 9200 getW(wR, wC, d1 + 2, d2), 9201 getW(wR, wC, d1 + 3, d2) 9202 ); 9203 9204 if (${y}) { 9205 vec4 xValues = vec4( 9206 getX(batch, xR, xC, d1), 9207 getX(batch, xR, xC, d1 + 1), 9208 getX(batch, xR, xC, d1 + 2), 9209 getX(batch, xR, xC, d1 + 3) 9210 ); 9211 dotProd += dot(xValues, wValues); 9212 } else { 9213 vec4 xValues = vec4( 9214 getX(batch, d1, xR, xC), 9215 getX(batch, d1 + 1, xR, xC), 9216 getX(batch, d1 + 2, xR, xC), 9217 getX(batch, d1 + 3, xR, xC) 9218 ); 9219 dotProd += dot(xValues, wValues); 9220 } 9221 } 9222 9223 if (${g===1}) { 9224 9225 if (${y}) { 9226 dotProd += 9227 getX(batch, xR, xC, ${m}) * 9228 getW(wR, wC, ${m}, d2); 9229 } else { 9230 dotProd += 9231 getX(batch, ${m}, xR, xC) * 9232 getW(wR, wC, ${m}, d2); 9233 } 9234 9235 } else if (${g===2}) { 9236 vec2 wValues = vec2( 9237 getW(wR, wC, ${m}, d2), 9238 getW(wR, wC, ${m} + 1, d2) 9239 ); 9240 9241 if (${y}) { 9242 vec2 xValues = vec2( 9243 getX(batch, xR, xC, ${m}), 9244 getX(batch, xR, xC, ${m} + 1) 9245 ); 9246 dotProd += dot(xValues, wValues); 9247 } else { 9248 vec2 xValues = vec2( 9249 getX(batch, ${m}, xR, xC), 9250 getX(batch, ${m} + 1, xR, xC) 9251 ); 9252 dotProd += dot(xValues, wValues); 9253 } 9254 9255 } else if (${g===3}) { 9256 vec3 wValues = vec3( 9257 getW(wR, wC, ${m}, d2), 9258 getW(wR, wC, ${m} + 1, d2), 9259 getW(wR, wC, ${m} + 2, d2) 9260 ); 9261 9262 if (${y}) { 9263 vec3 xValues = vec3( 9264 getX(batch, xR, xC, ${m}), 9265 getX(batch, xR, xC, ${m} + 1), 9266 getX(batch, xR, xC, ${m} + 2) 9267 ); 9268 dotProd += dot(xValues, wValues); 9269 } else { 9270 vec3 xValues = vec3( 9271 getX(batch, ${m}, xR, xC), 9272 getX(batch, ${m} + 1, xR, xC), 9273 getX(batch, ${m} + 2, xR, xC) 9274 ); 9275 dotProd += dot(xValues, wValues); 9276 } 9277 9278 } 9279 } 9280 } 9281 9282 float result = dotProd; 9283 ${O} 9284 ${T} 9285 setOutput(result); 9286 } 9287 `}}class YD{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,r=e.padInfo.top,s=e.padInfo.left,a=e.strideDepth,o=e.strideHeight,i=e.strideWidth,c=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,d=e.filterDepth,p=e.filterHeight,h=e.filterWidth,m=Math.floor(e.inChannels/4)*4,g=e.inChannels%4;this.userCode=` 9288 const ivec3 strides = ivec3(${a}, ${o}, ${i}); 9289 const ivec3 pads = ivec3(${t}, ${r}, ${s}); 9290 9291 void main() { 9292 ivec5 coords = getOutputCoords(); 9293 int batch = coords.x; 9294 int d2 = coords.u; 9295 9296 ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 9297 int xFCorner = xFRCCorner.x; 9298 int xRCorner = xFRCCorner.y; 9299 int xCCorner = xFRCCorner.z; 9300 9301 // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get 9302 // y(yF, yR, yC, d2). ? = to be determined. : = across all 9303 // values in that axis. 9304 float dotProd = 0.0; 9305 for (int wF = 0; wF < ${d}; wF++) { 9306 int xF = xFCorner + wF * ${c}; 9307 9308 if (xF < 0 || xF >= ${e.inDepth}) { 9309 continue; 9310 } 9311 9312 for (int wR = 0; wR < ${p}; wR++) { 9313 int xR = xRCorner + wR * ${l}; 9314 9315 if (xR < 0 || xR >= ${e.inHeight}) { 9316 continue; 9317 } 9318 9319 for (int wC = 0; wC < ${h}; wC++) { 9320 int xC = xCCorner + wC * ${u}; 9321 9322 if (xC < 0 || xC >= ${e.inWidth}) { 9323 continue; 9324 } 9325 9326 for (int d1 = 0; d1 < ${m}; d1 += 4) { 9327 vec4 xValues = vec4( 9328 getX(batch, xF, xR, xC, d1), 9329 getX(batch, xF, xR, xC, d1 + 1), 9330 getX(batch, xF, xR, xC, d1 + 2), 9331 getX(batch, xF, xR, xC, d1 + 3) 9332 ); 9333 vec4 wValues = vec4( 9334 getW(wF, wR, wC, d1, d2), 9335 getW(wF, wR, wC, d1 + 1, d2), 9336 getW(wF, wR, wC, d1 + 2, d2), 9337 getW(wF, wR, wC, d1 + 3, d2) 9338 ); 9339 9340 dotProd += dot(xValues, wValues); 9341 } 9342 9343 if (${g===1}) { 9344 dotProd += 9345 getX(batch, xF, xR, xC, ${m}) * 9346 getW(wF, wR, wC, ${m}, d2); 9347 } else if (${g===2}) { 9348 vec2 xValues = vec2( 9349 getX(batch, xF, xR, xC, ${m}), 9350 getX(batch, xF, xR, xC, ${m} + 1) 9351 ); 9352 vec2 wValues = vec2( 9353 getW(wF, wR, wC, ${m}, d2), 9354 getW(wF, wR, wC, ${m} + 1, d2) 9355 ); 9356 dotProd += dot(xValues, wValues); 9357 } else if (${g===3}) { 9358 vec3 xValues = vec3( 9359 getX(batch, xF, xR, xC, ${m}), 9360 getX(batch, xF, xR, xC, ${m} + 1), 9361 getX(batch, xF, xR, xC, ${m} + 2) 9362 ); 9363 vec3 wValues = vec3( 9364 getW(wF, wR, wC, ${m}, d2), 9365 getW(wF, wR, wC, ${m} + 1, d2), 9366 getW(wF, wR, wC, ${m} + 2, d2) 9367 ); 9368 dotProd += dot(xValues, wValues); 9369 } 9370 } 9371 } 9372 } 9373 setOutput(dotProd); 9374 } 9375 `}}/** 9376 * @license 9377 * Copyright 2022 Google LLC. All Rights Reserved. 9378 * Licensed under the Apache License, Version 2.0 (the "License"); 9379 * you may not use this file except in compliance with the License. 9380 * You may obtain a copy of the License at 9381 * 9382 * http://www.apache.org/licenses/LICENSE-2.0 9383 * 9384 * Unless required by applicable law or agreed to in writing, software 9385 * distributed under the License is distributed on an "AS IS" BASIS, 9386 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9387 * See the License for the specific language governing permissions and 9388 * limitations under the License. 9389 * ============================================================================= 9390 */class cb{constructor(e,t=!1,r=null,s=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Dt(this.outputShape.length);const o=e.padInfo.left,i=e.strideWidth,c=e.dilationWidth,l=e.filterHeight,u=e.filterWidth,d=u;let p=` 9391 int xR; int xC; int xCOffset; 9392 vec4 wTexel; vec4 previous; vec4 final;`;for(let y=0;y<u;y++)p+=` 9393 vec4 xTexelC${y*2}; 9394 int xTexelC${y*2}Ready; 9395 vec4 xTexelC${y*2+1}; 9396 int xTexelC${y*2+1}Ready; 9397 vec4 xC${y};`;p+=` 9398 for (int r = 0; r < ${l}; r++) { 9399 for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) { 9400 `;for(let y=0;y<u;y++)p+=` 9401 xTexelC${y*2} = vec4(0.0); 9402 xTexelC${y*2}Ready = 0; 9403 xTexelC${y*2+1} = vec4(0.0); 9404 xTexelC${y*2+1}Ready = 0; 9405 xC${y} = vec4(0.0);`;p+=` 9406 xR = xRCorner + r * dilations[0]; 9407 if (xR >=0 && xR < inDims[0]) { 9408 `;for(let y=0;y<(d+1)/2;y++){const b=y*2;if(p+=` 9409 xC = xCCorner + ${b*c}; 9410 `,i===1){if(b<u&&(o%2===1?(p+=` 9411 xCOffset = xC + 1; 9412 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b}Ready == 0) { 9413 xTexelC${b} = getX(batch, xR, xCOffset, d1); 9414 9415 // Need to manually clear unused channels in case 9416 // we're reading from recycled texture. 9417 if (xCOffset + 1 >= inDims[1]) { 9418 xTexelC${b}.zw = vec2(0.0); 9419 } 9420 xTexelC${b}Ready = 1; 9421 } 9422 `,c===1&&b>0?p+=` 9423 xC${b} = vec4(xTexelC${b-2}.zw, xTexelC${b}.xy); 9424 `:p+=` 9425 xCOffset = xC + 1 - 2; 9426 9427 if (xCOffset >= 0 && xCOffset < inDims[1]) { 9428 previous = getX(batch, xR, xCOffset, d1); 9429 9430 // Need to manually clear unused channels in case 9431 // we're reading from recycled texture. 9432 if (xCOffset + 1 >= inDims[1]) { 9433 previous.zw = vec2(0.0); 9434 } 9435 9436 xC${b} = vec4(previous.zw, xTexelC${b}.xy); 9437 } else { 9438 xC${b} = vec4(0.0, 0.0, xTexelC${b}.xy); 9439 } 9440 `):p+=` 9441 if (xC >= 0 && xC < inDims[1] && xTexelC${b}Ready == 0) { 9442 xTexelC${b} = getX(batch, xR, xC, d1); 9443 if (xC + 1 >= inDims[1]) { 9444 xTexelC${b}.zw = vec2(0.0); 9445 } 9446 xTexelC${b}Ready = 1; 9447 } 9448 9449 xC${b} = xTexelC${b}; 9450 `,b+1<u)){const v=o%2===0?$l(c):c;c%2===0&&o%2===1||c%2!==0&&o%2!==1?(p+=` 9451 xCOffset = xC + imod(pads[1], 2) + ${v}; 9452 9453 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b+1}Ready == 0) { 9454 xTexelC${b+1} = getX(batch, xR, xCOffset, d1); 9455 9456 // Need to manually clear unused channels in case 9457 // we're reading from recycled texture. 9458 if (xCOffset + 1 >= inDims[1]) { 9459 xTexelC${b+1}.zw = vec2(0.0); 9460 } 9461 xTexelC${b+1}Ready = 1; 9462 } 9463 `,c>1?p+=` 9464 xCOffset -= 2; 9465 if (xCOffset >= 0 && xCOffset < inDims[1]) { 9466 previous = getX(batch, xR, xCOffset, d1); 9467 xC${b+1} = vec4(previous.zw, xTexelC${b+1}.xy); 9468 } else { 9469 xC${b+1} = vec4(0.0, 0.0, xTexelC${b+1}.xy); 9470 } 9471 `:p+=` 9472 xC${b+1} = vec4(xTexelC${b}.zw, xTexelC${b+1}.xy); 9473 `):v===1?p+=` 9474 xC${b+1} = xTexelC${b}; 9475 `:p+=` 9476 xCOffset = xC + ${v}; 9477 9478 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b+1}Ready == 0) { 9479 xTexelC${b+1} = getX(batch, xR, xCOffset, d1); 9480 if (xCOffset + 1 >= inDims[1]) { 9481 xTexelC${b+1}.zw = vec2(0.0); 9482 } 9483 xTexelC${b+1}Ready = 1; 9484 } 9485 9486 xC${b+1} = xTexelC${b+1}; 9487 `}}else b<u&&(o%2===1?(p+=` 9488 xCOffset = xC + 1 - strides[1]; 9489 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b}Ready == 0) { 9490 xTexelC${b} = getX(batch, xR, xCOffset, d1); 9491 // Need to manually clear unused channels in case 9492 // we're reading from recycled texture. 9493 if (xCOffset + 1 >= inDims[1]) { 9494 xTexelC${b}.zw = vec2(0.0); 9495 } 9496 xTexelC${b}Ready = 1; 9497 } 9498 9499 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${b+1}Ready == 0) { 9500 xTexelC${b+1} = getX(batch, xR, xC + 1, d1); 9501 // Need to manually clear unused channels in case 9502 // we're reading from recycled texture. 9503 if (xC + 2 >= inDims[1]) { 9504 xTexelC${b+1}.zw = vec2(0.0); 9505 } 9506 xTexelC${b+1}Ready = 1; 9507 } 9508 9509 xC${b} = vec4(xTexelC${b}.zw, xTexelC${b+1}.zw); 9510 `,b+1<u&&(p+=` 9511 final = vec4(0.0); 9512 xCOffset = xC + 1 + strides[1]; 9513 if(xCOffset >= 0 && xCOffset < inDims[1]) { 9514 final = getX(batch, xR, xCOffset, d1); 9515 } 9516 xC${b+1} = vec4(xTexelC${b+1}.xy, final.xy); 9517 `)):(p+=` 9518 if(xC >= 0 && xC < inDims[1] && xTexelC${b}Ready == 0) { 9519 xTexelC${b} = getX(batch, xR, xC, d1); 9520 if (xC + 1 >= inDims[1]) { 9521 xTexelC${b}.zw = vec2(0.0); 9522 } 9523 xTexelC${b}Ready = 1; 9524 } 9525 9526 xCOffset = xC + strides[1]; 9527 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${b+1}Ready == 0) { 9528 xTexelC${b+1} = getX(batch, xR, xCOffset, d1); 9529 if (xCOffset + 1 >= inDims[1]) { 9530 xTexelC${b+1}.zw = vec2(0.); 9531 } 9532 xTexelC${b+1}Ready = 1; 9533 } 9534 9535 xC${b} = vec4( 9536 xTexelC${b}.xy, xTexelC${b+1}.xy); 9537 `,b+1<u&&(p+=` 9538 xC${b+1} = vec4(xTexelC${b}.zw, xTexelC${b+1}.zw); 9539 `)));b<u&&(p+=` 9540 wTexel = getW(r, ${b}, d1, d2); 9541 dotProd += xC${b}.xxzz * vec4(wTexel.xy, wTexel.xy); 9542 if(d1 + 1 < ${e.inChannels}) { 9543 dotProd += xC${b}.yyww * vec4(wTexel.zw, wTexel.zw); 9544 } 9545 `,b+1<u&&(p+=` 9546 wTexel = getW(r, ${b+1}, d1, d2); 9547 dotProd += xC${b+1}.xxzz * vec4(wTexel.xy, wTexel.xy); 9548 if(d1 + 1 < ${e.inChannels}) { 9549 dotProd += xC${b+1}.yyww * vec4(wTexel.zw, wTexel.zw); 9550 } 9551 `))}p+=` 9552 } 9553 `,p+=` 9554 } 9555 `,p+=` 9556 } 9557 `;let h="",m="";r&&(s?h=`vec4 activation(vec4 a) { 9558 vec4 b = getPreluActivationWeightsAtOutCoords(); 9559 ${r} 9560 }`:a?h=`vec4 activation(vec4 a) { 9561 vec4 b = getLeakyreluAlphaAtOutCoords(); 9562 ${r} 9563 }`:h=`vec4 activation(vec4 x) { 9564 ${r} 9565 }`,m="result = activation(result);");const g=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 9566 ${h} 9567 9568 void main() { 9569 ivec4 coords = getOutputCoords(); 9570 int batch = coords.x; 9571 ivec2 xRCCorner = coords.yz * strides - pads; 9572 int d2 = coords.w; 9573 int xRCorner = xRCCorner.x; 9574 int xCCorner = xRCCorner.y; 9575 9576 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 9577 vec4 dotProd = vec4(0.000000000000001); 9578 9579 ${p} 9580 9581 vec4 result = dotProd - vec4(0.000000000000001); 9582 ${g} 9583 ${m} 9584 setOutput(result); 9585 } 9586 `}}/** 9587 * @license 9588 * Copyright 2019 Google LLC. All Rights Reserved. 9589 * Licensed under the Apache License, Version 2.0 (the "License"); 9590 * you may not use this file except in compliance with the License. 9591 * You may obtain a copy of the License at 9592 * 9593 * http://www.apache.org/licenses/LICENSE-2.0 9594 * 9595 * Unless required by applicable law or agreed to in writing, software 9596 * distributed under the License is distributed on an "AS IS" BASIS, 9597 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9598 * See the License for the specific language governing permissions and 9599 * limitations under the License. 9600 * ============================================================================= 9601 */class QD{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=Dt(this.outputShape.length);const{dataFormat:r}=t,s=Wt(),a=r==="channelsLast",o=a?1:2,i=a?2:3,c=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let l="";for(let u=0;u<=1;u++)for(let d=0;d<=1;d++)l+=` 9602 blockIndex = rc.z + ${d}; 9603 pos = rc.y + ${u}; 9604 9605 ${c} 9606 offsetY = int(blockIndex / outWidth) * stride[0] - pad[0]; 9607 d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow); 9608 9609 if(d0 < inputShape[${o}] && d0 >= 0) { 9610 // Use custom imod instead mod. On Intel GPU, mod may generate 9611 // unexpected value. 9612 // https://github.com/tensorflow/tfjs/issues/5447 9613 offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1]; 9614 d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) / 9615 inChannels); 9616 9617 if(d1 < inputShape[${i}] && d1 >= 0) { 9618 9619 ch = imod(pos, inChannels); 9620 9621 if (${a}) { 9622 innerDims = vec2(d1, ch); 9623 result[${u*2+d}] = getChannel( 9624 getA(rc.x, d0, int(innerDims.x), 9625 int(innerDims.y)), innerDims); 9626 } else { 9627 innerDims = vec2(d0, d1); 9628 result[${u*2+d}] = getChannel( 9629 getA(rc.x, ch, int(innerDims.x), 9630 int(innerDims.y)), innerDims); 9631 } 9632 } 9633 } 9634 } 9635 `;this.userCode=` 9636 void main() { 9637 ivec3 rc = getOutputCoords(); 9638 9639 vec4 result = vec4(0); 9640 9641 int blockIndex, pos, offsetY, d0, offsetX, d1, ch; 9642 vec2 innerDims; 9643 9644 ${l} 9645 9646 ${s.output} = result; 9647 } 9648 `}}/** 9649 * @license 9650 * Copyright 2020 Google LLC. All Rights Reserved. 9651 * Licensed under the Apache License, Version 2.0 (the "License"); 9652 * you may not use this file except in compliance with the License. 9653 * You may obtain a copy of the License at 9654 * 9655 * http://www.apache.org/licenses/LICENSE-2.0 9656 * 9657 * Unless required by applicable law or agreed to in writing, software 9658 * distributed under the License is distributed on an "AS IS" BASIS, 9659 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9660 * See the License for the specific language governing permissions and 9661 * limitations under the License. 9662 * ============================================================================= 9663 */function Ei(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 lb({x:n,filter:e,convInfo:t,backend:r,bias:s=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){const c=n.shape,l=r.texData.get(n.dataId),u=t.inChannels,d=c[0]*c[1]*c[2],p=t.outChannels,h=t.dataFormat==="channelsLast",m=!1,g=!1;let y;const b=[];if(a!=null){const S=Ei(a.shape,h);S!=null&&(a=te({inputs:{x:a},backend:r,attrs:{shape:S}}),b.push(a))}if(s!=null){const S=Ei(s.shape,h);S!=null&&(s=te({inputs:{x:s},backend:r,attrs:{shape:S}}),b.push(s))}if(!((d===1||p===1)&&u>nb)&&l.isPacked&&h&&l.texture!=null&&c[2]%2!==0&&st(l.shape.slice(-3),c.slice(-3))){const S=c[0]*c[1]*(c[2]+1),T={dataId:n.dataId,shape:[1,S,t.inChannels],dtype:n.dtype},O=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,N(Ni(l.shape,T.shape),()=>`packed reshape ${l.shape} to ${T.shape} isn't free`);const L=te({inputs:{x:e},backend:r,attrs:{shape:[1,t.inChannels,t.outChannels]}});b.push(L);const M=ki({a:T,b:L,backend:r,transposeA:m,transposeB:g,bias:s,activation:i,preluActivationWeights:a,leakyreluAlpha:o}),W=r.texData.get(M.dataId);N(W.isPacked,()=>"batchMatMul result is expected to be packed"),l.shape=O,W.shape=t.outShape,y=rn({inputs:{x:M},backend:r}),y.shape=t.outShape,b.push(M)}else{const S=t.outHeight*t.outWidth,T=te({inputs:{x:n},backend:r,attrs:{shape:h?[t.batchSize,S,t.inChannels]:[t.batchSize,t.inChannels,S]}}),O=te({inputs:{x:e},backend:r,attrs:{shape:[1,t.inChannels,t.outChannels]}}),L=ki({a:h?T:O,b:h?O:T,transposeA:!h,transposeB:g,backend:r,bias:s,activation:i,preluActivationWeights:a,leakyreluAlpha:o});y=te({inputs:{x:L},backend:r,attrs:{shape:t.outShape}}),b.push(T),b.push(O),b.push(L)}for(const S of b)r.disposeIntermediateTensorInfo(S);return y}function db({x:n,filter:e,convInfo:t,backend:r,bias:s=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){const{filterWidth:c,filterHeight:l,inChannels:u,outWidth:d,outHeight:p,dataFormat:h}=t,m=h==="channelsLast",g=c*l*u,y=p*d,b=[t.batchSize,g,y],v=!0,$=!1,S=[];if(a!=null){const pe=Ei(a.shape,m);pe!=null&&(a=te({inputs:{x:a},backend:r,attrs:{shape:pe}}),S.push(a))}if(s!=null){const pe=Ei(s.shape,m);pe!=null&&(s=te({inputs:{x:s},backend:r,attrs:{shape:pe}}),S.push(s))}const T=te({inputs:{x:e},backend:r,attrs:{shape:[1,g,H(e.shape)/g]}});S.push(T);const O=new QD(b,t),L=[n.shape,[t.padInfo.top,t.padInfo.left],[t.strideHeight,t.strideWidth],[t.dilationHeight,t.dilationWidth],[t.inChannels],[t.filterWidth*t.inChannels],[t.outWidth]],M=r.runWebGLProgram(O,[n],"float32",L),W=te({inputs:{x:M},backend:r,attrs:{shape:b}});S.push(M),S.push(W);const V=s!=null,G=a!=null,K=i==="leakyrelu",J=i?Io(i,!0):null,ue=new tb(m?W.shape:T.shape,m?T.shape:W.shape,m?[t.batchSize,y,t.outChannels]:[t.batchSize,t.outChannels,y],v,$,V,J,G,K),se=m?[W,T]:[T,W];if(s&&se.push(s),G&&se.push(a),K){const pe=r.makeTensorInfo([],"float32",Ea(o,"float32"));se.push(pe),S.push(pe)}const fe=r.runWebGLProgram(ue,se,"float32"),Ie=te({inputs:{x:fe},backend:r,attrs:{shape:t.outShape}});S.push(fe);for(const pe of S)r.disposeIntermediateTensorInfo(pe);return Ie}/** 9664 * @license 9665 * Copyright 2020 Google LLC. All Rights Reserved. 9666 * Licensed under the Apache License, Version 2.0 (the "License"); 9667 * you may not use this file except in compliance with the License. 9668 * You may obtain a copy of the License at 9669 * 9670 * http://www.apache.org/licenses/LICENSE-2.0 9671 * 9672 * Unless required by applicable law or agreed to in writing, software 9673 * distributed under the License is distributed on an "AS IS" BASIS, 9674 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9675 * See the License for the specific language governing permissions and 9676 * limitations under the License. 9677 * ============================================================================= 9678 */function ZD(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a}=e,{strides:o,pad:i,dataFormat:c,dilations:l,dimRoundingMode:u}=r,d=Yr(c),p=$t(s.shape,a.shape,o,l,i,u,!1,d);let h;if(p.filterHeight===1&&p.filterWidth===1&&p.dilationHeight===1&&p.dilationWidth===1&&p.strideHeight===1&&p.strideWidth===1&&(p.padInfo.type==="SAME"||p.padInfo.type==="VALID"))h=lb({x:s,filter:a,convInfo:p,backend:t});else if(p.strideWidth<=2&&d==="channelsLast"&&U().getBool("WEBGL_EXP_CONV")){const g=new cb(p),y=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];h=t.runWebGLProgram(g,[s,a],"float32",y)}else if(U().getBool("WEBGL_CONV_IM2COL"))h=db({x:s,filter:a,convInfo:p,backend:t});else{const g=new ub(p);h=t.runWebGLProgram(g,[s,a],"float32")}const m=te({inputs:{x:h},backend:t,attrs:{shape:p.outShape}});return t.disposeIntermediateTensorInfo(h),m}const JD={kernelName:ji,backendName:"webgl",kernelFunc:ZD};/** 9679 * @license 9680 * Copyright 2017 Google LLC. All Rights Reserved. 9681 * Licensed under the Apache License, Version 2.0 (the "License"); 9682 * you may not use this file except in compliance with the License. 9683 * You may obtain a copy of the License at 9684 * 9685 * http://www.apache.org/licenses/LICENSE-2.0 9686 * 9687 * Unless required by applicable law or agreed to in writing, software 9688 * distributed under the License is distributed on an "AS IS" BASIS, 9689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9690 * See the License for the specific language governing permissions and 9691 * limitations under the License. 9692 * ============================================================================= 9693 */class eO{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,r=e.strideWidth,s=e.padInfo.top,a=e.padInfo.left,o=e.dataFormat==="channelsLast";this.userCode=` 9694 void main() { 9695 ivec4 coords = getOutputCoords(); 9696 int wR = coords.x; 9697 int wC = coords.y; 9698 int d1 = coords.z; 9699 int d2 = coords.w; 9700 9701 // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2). 9702 // ? = to be determined. : = across all values in that axis. 9703 float dotProd = 0.0; 9704 9705 for (int b = 0; b < ${e.batchSize}; b++) { 9706 for (int yR = 0; yR < ${e.outHeight}; yR++) { 9707 int xR = wR + yR * ${t} - ${s}; 9708 9709 if (xR < 0 || xR >= ${e.inHeight}) { 9710 continue; 9711 } 9712 9713 for (int yC = 0; yC < ${e.outWidth}; yC++) { 9714 int xC = wC + yC * ${r} - ${a}; 9715 9716 if (xC < 0 || xC >= ${e.inWidth}) { 9717 continue; 9718 } 9719 9720 ${o?`float dyValue = getDy(b, yR, yC, d2); 9721 float xValue = getX(b, xR, xC, d1); 9722 dotProd += (xValue * dyValue);`:`float dyValue = getDy(b, d2, yR, yC); 9723 float xValue = getX(b, d1, xR, xC); 9724 dotProd += (xValue * dyValue);`} 9725 } 9726 } 9727 } 9728 setOutput(dotProd); 9729 } 9730 `}}class tO{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,s=e.strideHeight,a=e.strideWidth,o=e.dataFormat==="channelsLast",i=t-1-e.padInfo.top,c=r-1-e.padInfo.left,l=o?1:2,u=o?2
9730:3,d=o?3:1;this.userCode=` 9731 const ivec2 pads = ivec2(${i}, ${c}); 9732 9733 void main() { 9734 ivec4 coords = getOutputCoords(); 9735 int batch = coords[0]; 9736 int d1 = coords[${d}]; 9737 9738 ivec2 dyCorner = ivec2(coords[${l}], coords[${u}]) - pads; 9739 int dyRCorner = dyCorner.x; 9740 int dyCCorner = dyCorner.y; 9741 9742 // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). 9743 // ? = to be determined. : = across all values in that axis. 9744 float dotProd = 0.0; 9745 for (int wR = 0; wR < ${t}; wR++) { 9746 float dyR = float(dyRCorner + wR) / ${s}.0; 9747 9748 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 9749 continue; 9750 } 9751 int idyR = int(dyR); 9752 9753 int wRPerm = ${t} - 1 - wR; 9754 9755 for (int wC = 0; wC < ${r}; wC++) { 9756 float dyC = float(dyCCorner + wC) / ${a}.0; 9757 9758 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 9759 fract(dyC) > 0.0) { 9760 continue; 9761 } 9762 int idyC = int(dyC); 9763 9764 int wCPerm = ${r} - 1 - wC; 9765 9766 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 9767 9768 if (${o}) { 9769 float xValue = getDy(batch, idyR, idyC, d2); 9770 float wValue = getW(wRPerm, wCPerm, d1, d2); 9771 dotProd += xValue * wValue; 9772 } else { 9773 float xValue = getDy(batch, d2, idyR, idyC); 9774 float wValue = getW(wRPerm, wCPerm, d1, d2); 9775 dotProd += xValue * wValue; 9776 } 9777 9778 } 9779 } 9780 } 9781 setOutput(dotProd); 9782 } 9783 `}}class nO{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,r=e.strideHeight,s=e.strideWidth,a=e.padInfo.front,o=e.padInfo.top,i=e.padInfo.left;this.userCode=` 9784 void main() { 9785 ivec5 coords = getOutputCoords(); 9786 int wF = coords.x; 9787 int wR = coords.y; 9788 int wC = coords.z; 9789 int d1 = coords.w; 9790 int d2 = coords.u; 9791 9792 float dotProd = 0.0; 9793 9794 for (int b = 0; b < ${e.batchSize}; b++) { 9795 for (int yF = 0; yF < ${e.outDepth}; yF++) { 9796 int xF = wF + yF * ${t} - ${a}; 9797 9798 if (xF < 0 || xF >= ${e.inDepth}) { 9799 continue; 9800 } 9801 9802 for (int yR = 0; yR < ${e.outHeight}; yR++) { 9803 int xR = wR + yR * ${r} - ${o}; 9804 9805 if (xR < 0 || xR >= ${e.inHeight}) { 9806 continue; 9807 } 9808 9809 for (int yC = 0; yC < ${e.outWidth}; yC++) { 9810 int xC = wC + yC * ${s} - ${i}; 9811 9812 if (xC < 0 || xC >= ${e.inWidth}) { 9813 continue; 9814 } 9815 9816 float dyValue = getDy(b, yF, yR, yC, d2); 9817 float xValue = getX(b, xF, xR, xC, d1); 9818 dotProd += (xValue * dyValue); 9819 } 9820 } 9821 } 9822 } 9823 setOutput(dotProd); 9824 } 9825 `}}class rO{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,r=e.filterHeight,s=e.filterWidth,a=e.strideDepth,o=e.strideHeight,i=e.strideWidth,c=t-1-e.padInfo.front,l=r-1-e.padInfo.top,u=s-1-e.padInfo.left;this.userCode=` 9826 const ivec3 pads = ivec3(${c}, ${l}, ${u}); 9827 9828 void main() { 9829 ivec5 coords = getOutputCoords(); 9830 int batch = coords.x; 9831 int d1 = coords.u; 9832 9833 9834 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 9835 int dyFCorner = dyCorner.x; 9836 int dyRCorner = dyCorner.y; 9837 int dyCCorner = dyCorner.z; 9838 9839 float dotProd = 0.0; 9840 for (int wF = 0; wF < ${t}; wF++) { 9841 float dyF = float(dyFCorner + wF) / ${a}.0; 9842 9843 if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) { 9844 continue; 9845 } 9846 int idyF = int(dyF); 9847 9848 int wFPerm = ${t} - 1 - wF; 9849 9850 for (int wR = 0; wR < ${r}; wR++) { 9851 float dyR = float(dyRCorner + wR) / ${o}.0; 9852 9853 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 9854 fract(dyR) > 0.0) { 9855 continue; 9856 } 9857 int idyR = int(dyR); 9858 9859 int wRPerm = ${r} - 1 - wR; 9860 9861 for (int wC = 0; wC < ${s}; wC++) { 9862 float dyC = float(dyCCorner + wC) / ${i}.0; 9863 9864 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 9865 fract(dyC) > 0.0) { 9866 continue; 9867 } 9868 int idyC = int(dyC); 9869 9870 int wCPerm = ${s} - 1 - wC; 9871 9872 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 9873 float xValue = getDy(batch, idyF, idyR, idyC, d2); 9874 float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); 9875 dotProd += xValue * wValue; 9876 } 9877 } 9878 } 9879 } 9880 setOutput(dotProd); 9881 } 9882 `}}/** 9883 * @license 9884 * Copyright 2020 Google LLC. All Rights Reserved. 9885 * Licensed under the Apache License, Version 2.0 (the "License");
9886 * you may not use this file except in compliance with the License. 9887 * You may obtain a copy of the License at 9888 * 9889 * http://www.apache.org/licenses/LICENSE-2.0 9890 * 9891 * Unless required by applicable law or agreed to in writing, software 9892 * distributed under the License is distributed on an "AS IS" BASIS, 9893 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9894 * See the License for the specific language governing permissions and 9895 * limitations under the License. 9896 * ============================================================================= 9897 */function sO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:a}=e,{strides:o,pad:i,dataFormat:c,dimRoundingMode:l,filterShape:u}=r,d=Yr(c),p=$t(s.shape,u,o,1,i,l,!1,d),h=new eO(p);return t.runWebGLProgram(h,[s,a],"float32")}const aO={kernelName:Jf,backendName:"webgl",kernelFunc:sO};/** 9898 * @license 9899 * Copyright 2023 Google LLC. 9900 * Licensed under the Apache License, Version 2.0 (the "License"); 9901 * you may not use this file except in compliance with the License. 9902 * You may obtain a copy of the License at 9903 * 9904 * http://www.apache.org/licenses/LICENSE-2.0 9905 * 9906 * Unless required by applicable law or agreed to in writing, software 9907 * distributed under the License is distributed on an "AS IS" BASIS, 9908 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9909 * See the License for the specific language governing permissions and 9910 * limitations under the License. 9911 * ============================================================================= 9912 */class oO{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=Dt(this.outputShape.length);const t=e.filterHeight,r=e.filterWidth,s=t-1-e.padInfo.top,a=r-1-e.padInfo.left;this.userCode=` 9913 const ivec2 pads = ivec2(${s}, ${a}); 9914 9915 void main() { 9916 ivec4 coords = getOutputCoords(); 9917 int batch = coords[0]; 9918 int d1 = coords[3]; 9919 9920 ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads; 9921 int dyRCorner = dyCorner.x; 9922 int dyCCorner = dyCorner.y; 9923 9924 vec4 result = vec4(0.); 9925 for (int wR = 0; wR < ${t}; wR++) { 9926 float dyR = float(dyRCorner + wR) / strides[0]; 9927 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 9928 continue; 9929 } 9930 int idyR = int(dyR); 9931 int wRPerm = ${t} - 1 - wR; 9932 9933 for (int wC = 0; wC < ${r}; wC++) { 9934 int wCPerm = ${r} - 1 - wC; 9935 9936 float dyC = float(dyCCorner + wC) / strides[1]; 9937 bool idyCVal = (dyC >= 0.0) && (dyC < ${e.outWidth}.0) 9938 && (fract(dyC) == 0.0); 9939 int idyC = int(dyC); 9940 9941 float dyC2 = float(dyCCorner + wC + 1) / strides[1]; 9942 bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${e.outWidth}.0) 9943 && (fract(dyC2) == 0.0); 9944 int idyC2 = int(dyC2); 9945 9946 if (idyCVal && idyCVal2) { 9947 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 9948 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 9949 vec4 dySample = getDy(batch, idyR, idyC, d2); 9950 vec4 dySample2 = (idyC / 2 == idyC2 / 2) ? 9951 dySample : getDy(batch, idyR, idyC2, d2); 9952 9953 vec2 dyValue = mod(float(idyC), 2.) == 0. ? 9954 dySample.xy : dySample.zw; 9955 result.xy += vec2(dot(dyValue, wValue.xy), 9956 dot(dyValue, wValue.zw)); 9957 9958 dyValue = mod(float(idyC2), 2.) == 0. ? 9959 dySample2.xy : dySample2.zw; 9960 result.zw += vec2(dot(dyValue, wValue.xy), 9961 dot(dyValue, wValue.zw)); 9962 } 9963 } else if (idyCVal) { 9964 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 9965 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 9966 vec4 dySample = getDy(batch, idyR, idyC, d2); 9967 vec2 dyValue = mod(float(idyC), 2.) == 0. ? 9968 dySample.xy : dySample.zw; 9969 result.xy += vec2(dot(dyValue, wValue.xy), 9970 dot(dyValue, wValue.zw)); 9971 } 9972 } else if (idyCVal2) { 9973 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 9974 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 9975 vec4 dySample = getDy(batch, idyR, idyC2, d2); 9976 vec2 dyValue = mod(float(idyC2), 2.) == 0. ? 9977 dySample.xy : dySample.zw; 9978 result.zw += vec2(dot(dyValue, wValue.xy), 9979 dot(dyValue, wValue.zw)); 9980 } 9981 } 9982 } 9983 } 9984 setOutput(result); 9985 } 9986 `}}/** 9987 * @license 9988 * Copyright 2020 Google LLC. All Rights Reserved. 9989 * Licensed under the Apache License, Version 2.0 (the "License");
9990 * you may not use this file except in compliance with the License. 9991 * You may obtain a copy of the License at 9992 * 9993 * http://www.apache.org/licenses/LICENSE-2.0 9994 * 9995 * Unless required by applicable law or agreed to in writing, software 9996 * distributed under the License is distributed on an "AS IS" BASIS, 9997 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9998 * See the License for the specific language governing permissions and 9999 * limitations under the License. 10000 * ============================================================================= 10001 */function iO(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:a}=e,{inputShape:o,strides:i,pad:c,dataFormat:l,dimRoundingMode:u}=r,d=Yr(l),p=$t(o,a.shape,i,1,c,u,!1,d);if(U().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&d==="channelsLast"){const h=[[p.strideHeight,p.strideWidth]],m=new oO(p);return t.runWebGLProgram(m,[s,a],"float32",h)}else{const h=new tO(p);return t.runWebGLProgram(h,[s,a],"float32")}}const uO={kernelName:qi,backendName:"webgl",kernelFunc:iO};/** 10002 * @license 10003 * Copyright 2020 Google LLC. All Rights Reserved. 10004 * Licensed under the Apache License, Version 2.0 (the "License"); 10005 * you may not use this file except in compliance with the License. 10006 * You may obtain a copy of the License at 10007 * 10008 * http://www.apache.org/licenses/LICENSE-2.0 10009 * 10010 * Unless required by applicable law or agreed to in writing, software 10011 * distributed under the License is distributed on an "AS IS" BASIS, 10012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10013 * See the License for the specific language governing permissions and 10014 * limitations under the License. 10015 * ============================================================================= 10016 */function cO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a}=e,{strides:o,pad:i,dilations:c}=r,l=Xr(s.shape,a.shape,o,c,i),u=new YD(l);return t.runWebGLProgram(u,[s,a],"float32")}const lO={kernelName:Ki,backendName:"webgl",kernelFunc:cO};/** 10017 * @license 10018 * Copyright 2020 Google LLC. All Rights Reserved. 10019 * Licensed under the Apache License, Version 2.0 (the "License"); 10020 * you may not use this file except in compliance with the License. 10021 * You may obtain a copy of the License at 10022 * 10023 * http://www.apache.org/licenses/LICENSE-2.0 10024 * 10025 * Unless required by applicable law or agreed to in writing, software 10026 * distributed under the License is distributed on an "AS IS" BASIS, 10027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10028 * See the License for the specific language governing permissions and 10029 * limitations under the License. 10030 * ============================================================================= 10031 */function dO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:a}=e,{strides:o,pad:i,filterShape:c}=r,l=Xr(s.shape,c,o,1,i),u=new nO(l);return t.runWebGLProgram(u,[s,a],"float32")}const pO={kernelName:Ul,backendName:"webgl",kernelFunc:dO};/** 10032 * @license 10033 * Copyright 2020 Google LLC. All Rights Reserved. 10034 * Licensed under the Apache License, Version 2.0 (the "License"); 10035 * you may not use this file except in compliance with the License. 10036 * You may obtain a copy of the License at 10037 * 10038 * http://www.apache.org/licenses/LICENSE-2.0 10039 * 10040 * Unless required by applicable law or agreed to in writing, software 10041 * distributed under the License is distributed on an "AS IS" BASIS, 10042 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10043 * See the License for the specific language governing permissions and 10044 * limitations under the License. 10045 * ============================================================================= 10046 */function hO(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:a}=e,{pad:o,strides:i,inputShape:c}=r,l=Xr(c,a.shape,i,1,o),u=new rO(l);return t.runWebGLProgram(u,[s,a],"float32")}const fO={kernelName:Xi,backendName:"webgl",kernelFunc:hO};/** 10047 * @license 10048 * Copyright 2020 Google LLC. All Rights Reserved. 10049 * Licensed under the Apache License, Version 2.0 (the "License"); 10050 * you may not use this file except in compliance with the License. 10051 * You may obtain a copy of the License at 10052 * 10053 * http://www.apache.org/licenses/LICENSE-2.0 10054 * 10055 * Unless required by applicable law or agreed to in writing, softw
10055are 10056 * distributed under the License is distributed on an "AS IS" BASIS, 10057 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10058 * See the License for the specific language governing permissions and 10059 * limitations under the License. 10060 * ============================================================================= 10061 */const mO=Ma+` 10062 return cos(x); 10063`,gO=` 10064 vec4 result = cos(x); 10065 bvec4 isNaN = isnan(x); 10066 ${zs} 10067 return result; 10068`,yO=De({opSnippet:mO,packedOpSnippet:gO}),bO={kernelName:zl,backendName:"webgl",kernelFunc:yO};/** 10069 * @license 10070 * Copyright 2020 Google LLC. All Rights Reserved. 10071 * Licensed under the Apache License, Version 2.0 (the "License"); 10072 * you may not use this file except in compliance with the License. 10073 * You may obtain a copy of the License at 10074 * 10075 * http://www.apache.org/licenses/LICENSE-2.0 10076 * 10077 * Unless required by applicable law or agreed to in writing, software 10078 * distributed under the License is distributed on an "AS IS" BASIS, 10079 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10080 * See the License for the specific language governing permissions and 10081 * limitations under the License. 10082 * ============================================================================= 10083 */const xO=` 10084 float e2x = exp(-x); 10085 return (e2x + 1.0 / e2x) / 2.0; 10086`,wO=De({opSnippet:xO}),vO={kernelName:Gl,backendName:"webgl",kernelFunc:wO};/** 10087 * @license 10088 * Copyright 2017 Google LLC. All Rights Reserved. 10089 * Licensed under the Apache License, Version 2.0 (the "License"); 10090 * you may not use this file except in compliance with the License. 10091 * You may obtain a copy of the License at 10092 * 10093 * http://www.apache.org/licenses/LICENSE-2.0 10094 * 10095 * Unless required by applicable law or agreed to in writing, software 10096 * distributed under the License is distributed on an "AS IS" BASIS, 10097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10098 * See the License for the specific language governing permissions and 10099 * limitations under the License. 10100 * ============================================================================= 10101 */class IO{constructor(e,t,r,s,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[o,i,c,l]=e,[u]=t,[d,p]=r;this.outputShape=[u,d,p,l];const h=s==="bilinear"?1:0,[m,g]=[`${i-1}.0`,`${c-1}.0`],[y,b,v]=d>1?[`${(i-1)/(d-1)}`,"(y2-y1) * height_ratio",`y1*${m} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${m}`],[$,S,T]=p>1?[`${(c-1)/(p-1)}`,"(x2-x1) * width_ratio",`x1*${g} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${g}`];this.userCode=` 10102 const float height_ratio = float(${y}); 10103 const float width_ratio = float(${$}); 10104 void main() { 10105 ivec4 coords = getOutputCoords(); 10106 int b = coords[0]; 10107 int y = coords[1]; 10108 int x = coords[2]; 10109 int d = coords[3]; 10110 10111 // get box vals 10112 float y1 = getBoxes(b,0); 10113 float x1 = getBoxes(b,1); 10114 float y2 = getBoxes(b,2); 10115 float x2 = getBoxes(b,3); 10116 10117 // get image in batch index 10118 int bInd = round(getBoxInd(b)); 10119 if(bInd < 0 || bInd >= ${o}) { 10120 return; 10121 } 10122 10123 float height_scale = ${b}; 10124 float width_scale = ${S}; 10125 10126 float in_y = ${v}; 10127 if( in_y < 0.0 || in_y > ${m} ) { 10128 setOutput(float(${a})); 10129 return; 10130 } 10131 float in_x = ${T}; 10132 if( in_x < 0.0 || in_x > ${g} ) { 10133 setOutput(float(${a})); 10134 return; 10135 } 10136 10137 vec2 sourceFracIndexCR = vec2(in_x,in_y); 10138 if(${h} == 1) { 10139 // Compute the four integer indices. 10140 ivec2 sourceFloorCR = ivec2(sourceFracIndexCR); 10141 ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR)); 10142 10143 float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d); 10144 float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d); 10145 float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d); 10146 float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d); 10147 10148 vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR); 10149 10150 float top = topLeft + (topRight - topLeft) * fracCR.x; 10151 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x; 10152 float newValue = top + (bottom - top) * fracCR.y; 10153 setOutput(newValue); 10154 } else { 10155 // Compute the coordinators of nearest neighbor point. 10156 ivec2 sourceNearestCR = ivec2(floor( 10157 sourceFracIndexCR + vec2(0.5,0.5))); 10158 float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d); 10159 setOutput(newValue); 10160 } 10161 } 10162 `}}/** 10163 * @license 10164 * Copyright 2020 Google LLC. All Rights Reserved. 10165 * Licensed under the Apache License, Version 2.0 (the "License");
10166 * you may not use this file except in compliance with the License. 10167 * You may obtain a copy of the License at 10168 * 10169 * http://www.apache.org/licenses/LICENSE-2.0 10170 * 10171 * Unless required by applicable law or agreed to in writing, software 10172 * distributed under the License is distributed on an "AS IS" BASIS, 10173 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10174 * See the License for the specific language governing permissions and 10175 * limitations under the License. 10176 * ============================================================================= 10177 */const $O=n=>{const{inputs:e,backend:t,attrs:r}=n,{image:s,boxes:a,boxInd:o}=e,{cropSize:i,method:c,extrapolationValue:l}=r,u=new IO(s.shape,a.shape,i,c,l);return t.runWebGLProgram(u,[s,a,o],"float32")},SO={kernelName:Zi,backendName:"webgl",kernelFunc:$O};var So;(function(n){n.Prod="*",n.Sum="+"})(So||(So={}));class mf{constructor(e,t,r,s){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const a=this.outputShape.length,o=this.op===So.Prod?"1.0":"0.0",i=r?o:`getX(${gf(a,"coords",this.op)})`,c=this.outputShape[this.outputShape.length-1];let l="",u="";r?(l=s?`end != ${c-1}`:"end != 0",u=s?"end + 1":"end - 1"):(l=s?`end + pow2 < ${c}`:"end >= pow2",u=s?"end + pow2":"end - pow2"),this.userCode=` 10178 void main() { 10179 ${ze(a)} coords = getOutputCoords(); 10180 int end = ${yf(a,"coords",this.op)}; 10181 float val = ${i}; 10182 int pow2 = int(pow(2.0, index)); 10183 if (${l}) { 10184 int idx = ${u}; 10185 ${yf(a,"coords",this.op)} = idx; 10186 val ${this.op}= getX(${gf(a,"coords",this.op)}); 10187 } 10188 setOutput(val); 10189 } 10190 `}}function gf(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 yf(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`)}/** 10191 * @license 10192 * Copyright 2022 Google LLC. All Rights Reserved. 10193 * Licensed under the Apache License, Version 2.0 (the "License"); 10194 * you may not use this file except in compliance with the License. 10195 * You may obtain a copy of the License at 10196 * 10197 * http://www.apache.org/licenses/LICENSE-2.0 10198 * 10199 * Unless required by applicable law or agreed to in writing, software 10200 * distributed under the License is distributed on an "AS IS" BASIS, 10201 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10202 * See the License for the specific language governing permissions and 10203 * limitations under the License. 10204 * ============================================================================= 10205 */function pb(n,e,t,r,s,a){const o=e.shape.length,i=Xt([r],o);let c=e;i!=null&&(c=Vt({inputs:{x:e},backend:t,attrs:{perm:i}}));const l=St(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 u=c.shape[l];let d=rn({inputs:{x:c},backend:t});for(let p=0;p<=Math.ceil(Math.log2(u))-1;p++){const h=new mf(n,c.shape,!1,a),m=[[p]],g=d;d=t.runWebGLProgram(h,[d],d.dtype,m),t.disposeIntermediateTensorInfo(g)}if(s){const p=new mf(n,c.shape,s,a),h=d;d=t.runWebGLProgram(p,[d],d.dtype),t.disposeIntermediateTensorInfo(h)}if(i!=null){const p=Eo(i),h=Vt({inputs:{x:d},backend:t,attrs:{perm:p}});return t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(c),h}return d}/** 10206 * @license 10207 * Copyright 2022 Google LLC. All Rights Reserved. 10208 * Licensed under the Apache License, Version 2.0 (the "License"); 10209 * you may not use this file except in compliance with the License. 10210 * You may obtain a copy of the License at 10211 * 10212 * http://www.apache.org/licenses/LICENSE-2.0 10213 * 10214 * Unless required by applicable law or agreed to in writing, software 10215 * distributed under the License is distributed on an "AS IS" BASIS, 10216 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10217 * See the License for the specific language governing permissions and 10218 * limitations under the License. 10219 * ============================================================================= 10220 */function CO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,exclusive:o,reverse:i}
vendor: 8,069 bytes, lines 10220-10370
10220=r;return pb(So.Prod,s,t,a,o,i)}const _O={kernelName:Yi,backendName:"webgl",kernelFunc:CO};/** 10221 * @license 10222 * Copyright 2022 Google LLC. All Rights Reserved. 10223 * Licensed under the Apache License, Version 2.0 (the "License"); 10224 * you may not use this file except in compliance with the License. 10225 * You may obtain a copy of the License at 10226 * 10227 * http://www.apache.org/licenses/LICENSE-2.0 10228 * 10229 * Unless required by applicable law or agreed to in writing, software 10230 * distributed under the License is distributed on an "AS IS" BASIS, 10231 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10232 * See the License for the specific language governing permissions and 10233 * limitations under the License. 10234 * ============================================================================= 10235 */function NO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,exclusive:o,reverse:i}=r;return pb(So.Sum,s,t,a,o,i)}const TO={kernelName:Qi,backendName:"webgl",kernelFunc:NO};/** 10236 * @license 10237 * Copyright 2020 Google LLC. All Rights Reserved. 10238 * Licensed under the Apache License, Version 2.0 (the "License"); 10239 * you may not use this file except in compliance with the License. 10240 * You may obtain a copy of the License at 10241 * 10242 * http://www.apache.org/licenses/LICENSE-2.0 10243 * 10244 * Unless required by applicable law or agreed to in writing, software 10245 * distributed under the License is distributed on an "AS IS" BASIS, 10246 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10247 * See the License for the specific language governing permissions and 10248 * limitations under the License. 10249 * ============================================================================= 10250 */function kO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,weights:a}=e,{size:o,binaryOutput:i}=r;if(s.shape.length===1){const c=t.readSync(s.dataId),l=t.readSync(a.dataId),u=jy(c,l,a.dtype,a.shape,o);return t.makeTensorInfo([o],a.dtype,u)}else if(s.shape.length===2){const c=t.bufferSync(s),l=t.bufferSync(a),u=DE(c,l,o,i);return t.makeTensorInfo(u.shape,a.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}const EO={kernelName:Hl,backendName:"webgl",kernelFunc:kO};/** 10251 * @license 10252 * Copyright 2018 Google LLC. All Rights Reserved. 10253 * Licensed under the Apache License, Version 2.0 (the "License"); 10254 * you may not use this file except in compliance with the License. 10255 * You may obtain a copy of the License at 10256 * 10257 * http://www.apache.org/licenses/LICENSE-2.0 10258 * 10259 * Unless required by applicable law or agreed to in writing, software 10260 * distributed under the License is distributed on an "AS IS" BASIS, 10261 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10262 * See the License for the specific language governing permissions and 10263 * limitations under the License. 10264 * ============================================================================= 10265 */class RO{constructor(e,t,r){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=r,this.userCode=` 10266 void main() { 10267 ivec4 coords = getOutputCoords(); 10268 int b = coords[0]; 10269 int h = ${this.getHeightCoordString()}; 10270 int w = ${this.getWidthCoordString()}; 10271 int d = ${this.getDepthCoordString()}; 10272 10273 int in_h = h / ${t}; 10274 int offset_h = imod(h, ${t}); 10275 int in_w = w / ${t}; 10276 int offset_w = imod(w, ${t}); 10277 int offset_d = (offset_h * ${t} + offset_w) * 10278 ${this.getOutputDepthSize()}; 10279 int in_d = d + offset_d; 10280 10281 float result = ${this.getInputSamplingString()}; 10282 setOutput(result); 10283 } 10284 `}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)"}}/** 10285 * @license 10286 * Copyright 2020 Google LLC. All Rights Reserved. 10287 * Licensed under the Apache License, Version 2.0 (the "License"); 10288 * you may not use this file except in compliance with the License. 10289 * You may obtain a copy of the License at 10290 * 10291 * http://www.apache.org/licenses/LICENSE-2.0 10292 * 10293 * Unless required by applicable law or agreed to in writing, software 10294 * distributed under the License is distributed on an "AS IS" BASIS, 10295 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10296 * See the License for the specific language governing permissions and 10297 * limitations under the License. 10298 * ============================================================================= 10299 */function AO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockSize:a,dataFormat:o}=r,i=s.shape[0],c=o==="NHWC"?s.shape[1]:s.shape[2],l=o==="NHWC"?s.shape[2]:s.shape[3],u=o==="NHWC"?s.shape[3]:s.shape[1],d=c*a,p=l*a,h=u/(a*a),m=o==="NHWC"?[i,d,p,h]:[i,h,d,p],g=new RO(m,a,o);return t.runWebGLProgram(g,[s],s.dtype)}const DO={kernelName:Ji,backendName:"webgl",kernelFunc:AO};/** 10300 * @license 10301 * Copyright 2017 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 */class hb{constructor(e,t=!1,r=null,s=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Dt(this.outputShape.length);const o=e.filterHeight,i=e.filterWidth,c=e.outChannels/e.inChannels;let l="",u="";r&&(s?l=`float activation(float a) { 10315 float b = getPreluActivationWeightsAtOutCoords(); 10316 ${r} 10317 }`:a?l=`float activation(float a) { 10318 float b = getLeakyreluAlphaAtOutCoords(); 10319 ${r} 10320 }`:l=` 10321 float activation(float x) { 10322 ${r} 10323 } 10324 `,u="result = activation(result);");const d=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 10325 ${l} 10326 10327 void main() { 10328 ivec4 coords = getOutputCoords(); 10329 int batch = coords.x; 10330 ivec2 xRCCorner = coords.yz * strides - pads; 10331 int d2 = coords.w; 10332 int d1 = d2 / ${c}; 10333 int q = d2 - d1 * ${c}; 10334 10335 int xRCorner = xRCCorner.x; 10336 int xCCorner = xRCCorner.y; 10337 10338 // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2). 10339 // ? = to be determined. : = across all values in that axis. 10340 float dotProd = 0.0; 10341 // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations. 10342 for (int wR = 0; wR < ${o}; wR++) { 10343 int xR = xRCorner + wR * dilations[0]; 10344 10345 if (xR < 0 || xR >= inDims[0]) { 10346 continue; 10347 } 10348 10349 for (int wC = 0; wC < ${i}; wC++) { 10350 int xC = xCCorner + wC * dilations[1]; 10351 10352 if (xC < 0 || xC >= inDims[1]) { 10353 continue; 10354 } 10355 10356 float xVal = getX(batch, xR, xC, d1); 10357 float wVal = getW(wR, wC, d1, q); 10358 dotProd += xVal * wVal; 10359 } 10360 } 10361 10362 float result = dotProd; 10363 ${d} 10364 ${u} 10365 setOutput(result); 10366 } 10367 `}}/** 10368 * @license 10369 * Copyright 2018 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 */class fb{constructor(e,t=!1,r=null,s=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Dt(this.outputShape.length);const o=e.outChannels/e.inChannels,i=e.padInfo.left,c=e.strideWidth,l=e.dilationWidth,u=e.filterHeight,d=e.filterWidth,p=d;let h=` 10383 int xR; int xC; int xCOffset; 10384 vec4 wTexel; vec4 previous; vec4 final;`;for(let b=0;b<d;b++)h+=` 10385 vec4 xTexelC${b*2}; 10386 int xTexelC${b*2}Ready; 10387 vec4 xTexelC${b*2+1}; 10388 int xTexelC${b*2+1}Ready; 10389 vec4 xC${b};`;h+=` 10390 for (int r = 0; r < ${u}; r++) { 10391 `;for(let b=0;b<d;b++)h+=` 10392 xTexelC${b*2} = vec4(0.0); 10393 xTexelC${b*2}Ready = 0; 10394 xTexelC${b*2+1} = vec4(0.0); 10395 xTexelC${b*2+1}Ready = 0; 10396 xC${b} = vec4(0.0);`;h+=` 10397 xR = xRCorner + r * dilations[0]; 10398 if (xR >=0 && xR < inDims[0]) { 10399 `;for(let b=0;b<(p+1)/2;b++){const v=b*2;if(h+=` 10400 xC = xCCorner + ${v*l}; 10401 `,c===1){if(v<d&&(i%2===1?(h+=` 10402 xCOffset = xC + 1; 10403 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${v}Ready == 0) { 10404 xTexelC${v} = getX(batch, xR, xCOffset, d1); 10405 10406 // Need to manually clear unused channels in case 10407 // we're reading from recycled texture. 10408 if (xCOffset + 1 >= inDims[1]) { 10409 xTexelC${v}.zw = vec2(0.0); 10410 } 10411 xTexelC${v}Ready = 1; 10412 } 10413 `,l===1&&v>0?h+=` 10414 xC${v} = vec4(xTexelC${v-2}.zw, xTexelC${v}.xy); 10415 `:h+=` 10416 xCOffset = xC + 1 - 2; 10417 10418 if (xCOffset >= 0 && xCOffset < inDims[1]) { 10419 previous = getX(batch, xR, xCOffset, d1); 10420 10421 // Need to manually clear unused channels in case 10422 // we're reading from recycled texture. 10423 if (xCOffset + 1 >= inDims[1]) { 10424 previous.zw = vec2(0.0); 10425 } 10426 10427 xC${v} = vec4(previous.zw, xTexelC${v}.xy); 10428 } else { 10429 xC${v} = vec4(0.0, 0.0, xTexelC${v}.xy); 10430 } 10431 `):h+=` 10432 if (xC >= 0 && xC < inDims[1] && xTexelC${v}Ready == 0) { 10433 xTexelC${v} = getX(batch, xR, xC, d1); 10434 if (xC + 1 >= inDims[1]) { 10435 xTexelC${v}.zw = vec2(0.0); 10436 } 10437 xTexelC${v}Ready = 1; 10438 } 10439 10440 xC${v} = xTexelC${v}; 10441 `,v+1<d)){const $=i%2===0?$l(l):l;l%2===0&&i%2===1||l%2!==0&&i%2!==1?(h+=` 10442 xCOffset = xC + imod(pads[1], 2) + ${$}; 10443 10444 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${v+1}Ready == 0) { 10445 xTexelC${v+1} = getX(batch, xR, xCOffset, d1); 10446 10447 // Need to manually clear unused channels in case 10448 // we're reading from recycled texture. 10449 if (xCOffset + 1 >= inDims[1]) { 10450 xTexelC${v+1}.zw = vec2(0.0); 10451 } 10452 xTexelC${v+1}Ready = 1; 10453 } 10454 `,l>1?h+=` 10455 xCOffset -= 2; 10456 if (xCOffset >= 0 && xCOffset < inDims[1]) { 10457 previous = getX(batch, xR, xCOffset, d1); 10458 xC${v+1} = vec4(previous.zw, xTexelC${v+1}.xy); 10459 } else { 10460 xC${v+1} = vec4(0.0, 0.0, xTexelC${v+1}.xy); 10461 } 10462 `:h+=` 10463 xC${v+1} = vec4(xTexelC${v}.zw, xTexelC${v+1}.xy); 10464 `):$===1?h+=` 10465 xC${v+1} = xTexelC${v}; 10466 `:h+=` 10467 xCOffset = xC + ${$}; 10468 10469 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${v+1}Ready == 0) { 10470 xTexelC${v+1} = getX(batch, xR, xCOffset, d1); 10471 if (xCOffset + 1 >= inDims[1]) { 10472 xTexelC${v+1}.zw = vec2(0.0); 10473 } 10474 xTexelC${v+1}Ready = 1; 10475 } 10476 10477 xC${v+1} = xTexelC${v+1}; 10478 `}}else v<d&&(i%2===1?(h+=` 10479 xCOffset = xC + 1 - strides[1]; 10480 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${v}Ready == 0) { 10481 xTexelC${v} = getX(batch, xR, xCOffset, d1); 10482 // Need to manually clear unused channels in case 10483 // we're reading from recycled texture. 10484 if (xCOffset + 1 >= inDims[1]) { 10485 xTexelC${v}.zw = vec2(0.0); 10486 } 10487 xTexelC${v}Ready = 1; 10488 } 10489 10490 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${v+1}Ready == 0) { 10491 xTexelC${v+1} = getX(batch, xR, xC + 1, d1); 10492 // Need to manually clear unused channels in case 10493 // we're reading from recycled texture. 10494 if (xC + 2 >= inDims[1]) { 10495 xTexelC${v+1}.zw = vec2(0.0); 10496 } 10497 xTexelC${v+1}Ready = 1; 10498 } 10499 10500 xC${v} = vec4(xTexelC${v}.zw, xTexelC${v+1}.zw); 10501 `,v+1<d&&(h+=` 10502 final = vec4(0.0); 10503 xCOffset = xC + 1 + strides[1]; 10504 if(xCOffset >= 0 && xCOffset < inDims[1]) { 10505 final = getX(batch, xR, xCOffset, d1); 10506 } 10507 xC${v+1} = vec4(xTexelC${v+1}.xy, final.xy); 10508 `)):(h+=` 10509 if(xC >= 0 && xC < inDims[1] && xTexelC${v}Ready == 0) { 10510 xTexelC${v} = getX(batch, xR, xC, d1); 10511 if (xC + 1 >= inDims[1]) { 10512 xTexelC${v}.zw = vec2(0.0); 10513 } 10514 xTexelC${v}Ready = 1; 10515 } 10516 10517 xCOffset = xC + strides[1]; 10518 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${v+1}Ready == 0) { 10519 xTexelC${v+1} = getX(batch, xR, xCOffset, d1); 10520 if (xCOffset + 1 >= inDims[1]) { 10521 xTexelC${v+1}.zw = vec2(0.); 10522 } 10523 xTexelC${v+1}Ready = 1; 10524 } 10525 10526 xC${v} = vec4( 10527 xTexelC${v}.xy, xTexelC${v+1}.xy); 10528 `,v+1<d&&(h+=` 10529 xC${v+1} = vec4(xTexelC${v}.zw, xTexelC${v+1}.zw); 10530 `)));v<d&&(h+=` 10531 wTexel = getW(r, ${v}, d1, q); 10532 dotProd += xC${v} * vec4(wTexel.xz, wTexel.xz); 10533 `,v+1<d&&(h+=` 10534 wTexel = getW(r, ${v+1}, d1, q); 10535 dotProd += xC${v+1} * vec4(wTexel.xz, wTexel.xz); 10536 `))}h+=` 10537 } 10538 `,h+=` 10539 } 10540 `;let m="",g="";r&&(s?m=`vec4 activation(vec4 a) { 10541 vec4 b = getPreluActivationWeightsAtOutCoords(); 10542 ${r} 10543 }`:a?m=`vec4 activation(vec4 a) { 10544 vec4 b = getLeakyreluAlphaAtOutCoords(); 10545 ${r} 10546 }`:m=`vec4 activation(vec4 x) { 10547 ${r} 10548 }`,g="result = activation(result);");const y=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 10549 ${m} 10550 10551 void main() { 10552 ivec4 coords = getOutputCoords(); 10553 int batch = coords.x; 10554 ivec2 xRCCorner = coords.yz * strides - pads; 10555 int d2 = coords.w; 10556 int d1 = d2 / ${o}; 10557 int q = d2 - d1 * ${o}; 10558 int xRCorner = xRCCorner.x; 10559 int xCCorner = xRCCorner.y; 10560 10561 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 10562 vec4 dotProd = vec4(0.000000000000001); 10563 10564 ${h} 10565 10566 vec4 result = dotProd - vec4(0.000000000000001); 10567 ${y} 10568 ${g} 10569 setOutput(result); 10570 } 10571 `}}/** 10572 * @license 10573 * Copyright 2020 Google LLC. All Rights Reserved. 10574 * Licensed under the Apache License, Version 2.0 (the "License");
10575 * you may not use this file except in compliance with the License. 10576 * You may obtain a copy of the License at 10577 * 10578 * http://www.apache.org/licenses/LICENSE-2.0 10579 * 10580 * Unless required by applicable law or agreed to in writing, software 10581 * distributed under the License is distributed on an "AS IS" BASIS, 10582 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10583 * See the License for the specific language governing permissions and 10584 * limitations under the License. 10585 * ============================================================================= 10586 */function OO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a}=e,{strides:o,pad:i,dilations:c,dimRoundingMode:l}=r;let u=c;u==null&&(u=[1,1]),N(Kt(o,u),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);const d=$t(s.shape,a.shape,o,u,i,l,!0);let p;U().getBool("WEBGL_PACK_DEPTHWISECONV")&&d.strideWidth<=2&&d.outChannels/d.inChannels===1?p=new fb(d):p=new hb(d);const h=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];return t.runWebGLProgram(p,[s,a],"float32",h)}const FO={kernelName:eu,backendName:"webgl",kernelFunc:OO};/** 10587 * @license 10588 * Copyright 2018 Google LLC. All Rights Reserved. 10589 * Licensed under the Apache License, Version 2.0 (the "License"); 10590 * you may not use this file except in compliance with the License. 10591 * You may obtain a copy of the License at 10592 * 10593 * http://www.apache.org/licenses/LICENSE-2.0 10594 * 10595 * Unless required by applicable law or agreed to in writing, software 10596 * distributed under the License is distributed on an "AS IS" BASIS, 10597 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10598 * See the License for the specific language governing permissions and 10599 * limitations under the License. 10600 * ============================================================================= 10601 */class PO{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,r=e.strideWidth,s=e.padInfo.top,a=e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=` 10602 void main() { 10603 ivec4 coords = getOutputCoords(); 10604 int wR = coords.x; 10605 int wC = coords.y; 10606 int d1 = coords.z; 10607 int dm = coords.w; 10608 int d2 = d1 * ${o} + dm; 10609 10610 float dotProd = 0.0; 10611 10612 // TO DO: Vec4 over the batch size 10613 for (int b = 0; b < ${e.batchSize}; b++) { 10614 for (int yR = 0; yR < ${e.outHeight}; yR++) { 10615 int xR = wR + yR * ${t} - ${s}; 10616 10617 if (xR < 0 || xR >= ${e.inHeight}) { 10618 continue; 10619 } 10620 10621 for (int yC = 0; yC < ${e.outWidth}; yC++) { 10622 int xC = wC + yC * ${r} - ${a}; 10623 10624 if (xC < 0 || xC >= ${e.inWidth}) { 10625 continue; 10626 } 10627 10628 float dyValue = getDy(b, yR, yC, d2); 10629 float xValue = getX(b, xR, xC, d1); 10630 dotProd += (xValue * dyValue); 10631 } 10632 } 10633 } 10634 setOutput(dotProd); 10635 } 10636 `}}class LO{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,s=e.strideHeight,a=e.strideWidth,o=t-1-e.padInfo.top,i=r-1-e.padInfo.left,c=e.outChannels/e.inChannels;this.userCode=` 10637 const ivec2 pads = ivec2(${o}, ${i}); 10638 10639 void main() { 10640 ivec4 coords = getOutputCoords(); 10641 int batch = coords[0]; 10642 int d1 = coords[3]; 10643 ivec2 dyCorner = coords.yz - pads; 10644 int dyRCorner = dyCorner.x; 10645 int dyCCorner = dyCorner.y; 10646 10647 float dotProd = 0.0; 10648 10649 for (int wR = 0; wR < ${t}; wR++) { 10650 float dyR = float(dyRCorner + wR) / ${s}.0; 10651 10652 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 10653 continue; 10654 } 10655 int idyR = int(dyR); 10656 10657 int wRPerm = ${t} - 1 - wR; 10658 10659 for (int wC = 0; wC < ${r}; wC++) { 10660 float dyC = float(dyCCorner + wC) / ${a}.0; 10661 10662 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 10663 fract(dyC) > 0.0) { 10664 continue; 10665 } 10666 int idyC = int(dyC); 10667 10668 int wCPerm = ${r} - 1 - wC; 10669 10670 // TO DO: Vec4 over the channelMul 10671 for (int dm = 0; dm < ${c}; dm++) { 10672 int d2 = d1 * ${c} + dm; 10673 float xValue = getDy(batch, idyR, idyC, d2); 10674 float wValue = getW(wRPerm, wCPerm, d1, dm); 10675 dotProd += xValue * wValue; 10676 } 10677 } 10678 } 10679 setOutput(dotProd); 10680 } 10681 `}}/** 10682 * @license 10683 * Copyright 2020 Google LLC. All Rights Reserved. 10684 * Licensed under the Apache License, Version 2.0 (the "License");
10685 * you may not use this file except in compliance with the License. 10686 * You may obtain a copy of the License at 10687 * 10688 * http://www.apache.org/licenses/LICENSE-2.0 10689 * 10690 * Unless required by applicable law or agreed to in writing, software 10691 * distributed under the License is distributed on an "AS IS" BASIS, 10692 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10693 * See the License for the specific language governing permissions and 10694 * limitations under the License. 10695 * ============================================================================= 10696 */function MO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:a}=e,{strides:o,dilations:i,pad:c,dimRoundingMode:l,filterShape:u}=r,d=$t(s.shape,u,o,i,c,l,!0),p=new PO(d);return t.runWebGLProgram(p,[s,a],"float32")}const BO={kernelName:em,backendName:"webgl",kernelFunc:MO};/** 10697 * @license 10698 * Copyright 2020 Google LLC. All Rights Reserved. 10699 * Licensed under the Apache License, Version 2.0 (the "License"); 10700 * you may not use this file except in compliance with the License. 10701 * You may obtain a copy of the License at 10702 * 10703 * http://www.apache.org/licenses/LICENSE-2.0 10704 * 10705 * Unless required by applicable law or agreed to in writing, software 10706 * distributed under the License is distributed on an "AS IS" BASIS, 10707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10708 * See the License for the specific language governing permissions and 10709 * limitations under the License. 10710 * ============================================================================= 10711 */function VO(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:a}=e,{strides:o,dilations:i,pad:c,dimRoundingMode:l,inputShape:u}=r,d=$t(u,a.shape,o,i,c,l,!0),p=new LO(d);return t.runWebGLProgram(p,[s,a],"float32")}const WO={kernelName:tm,backendName:"webgl",kernelFunc:VO};/** 10712 * @license 10713 * Copyright 2019 Google LLC. All Rights Reserved. 10714 * Licensed under the Apache License, Version 2.0 (the "License"); 10715 * you may not use this file except in compliance with the License. 10716 * You may obtain a copy of the License at 10717 * 10718 * http://www.apache.org/licenses/LICENSE-2.0 10719 * 10720 * Unless required by applicable law or agreed to in writing, software 10721 * distributed under the License is distributed on an "AS IS" BASIS, 10722 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10723 * See the License for the specific language governing permissions and 10724 * limitations under the License. 10725 * ============================================================================= 10726 */class UO{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` 10727 void main() { 10728 ivec2 coords = getOutputCoords(); 10729 float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; 10730 setOutput(val); 10731 } 10732 `}}/** 10733 * @license 10734 * Copyright 2020 Google LLC. All Rights Reserved. 10735 * Licensed under the Apache License, Version 2.0 (the "License"); 10736 * you may not use this file except in compliance with the License. 10737 * You may obtain a copy of the License at 10738 * 10739 * http://www.apache.org/licenses/LICENSE-2.0 10740 * 10741 * Unless required by applicable law or agreed to in writing, software 10742 * distributed under the License is distributed on an "AS IS" BASIS, 10743 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10744 * See the License for the specific language governing permissions and 10745 * limitations under the License. 10746 * ============================================================================= 10747 */function zO(n){const{inputs:e,backend:t}=n,{x:r}=e,s=[...r.shape,...r.shape],a=H(r.shape),o=te({inputs:{x:r},backend:t,attrs:{shape:[a]}}),i=new UO(a),c=t.runWebGLProgram(i,[o],o.dtype),l=te({inputs:{x:c},backend:t,attrs:{shape:s}});return t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(c),l}const GO={kernelName:jl,backendName:"webgl",kernelFunc:zO};/** 10748 * @license 10749 * Copyright 2017 Google LLC. All Rights Reserved. 10750 * Licensed under the Apache License, Version 2.0 (the "License"); 10751 * you may not use this file except in compliance with the License. 10752 * You may obtain a copy of the License at 10753 * 10754 * http://www.apache.org/licenses/LICENSE-2.0 10755 * 10756 * Unless required by applicable law or agreed to in writing, softw
vendor: 4,354 bytes, lines 10756-10833
10756are 10757 * distributed under the License is distributed on an "AS IS" BASIS, 10758 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10759 * See the License for the specific language governing permissions and 10760 * limitations under the License. 10761 * ============================================================================= 10762 */class HO{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:r,padInfo:s,strideHeight:a,strideWidth:o,filterHeight:i,filterWidth:c,dilationHeight:l,dilationWidth:u}=e,{top:d,left:p}=s;this.userCode=` 10763 const ivec2 strides = ivec2(${a}, ${o}); 10764 const ivec2 pads = ivec2(${d}, ${p}); 10765 const float neg_infinity = -3.4e38; 10766 10767 void main() { 10768 ivec4 coords = getOutputCoords(); 10769 int batch = coords.x; 10770 int d1 = coords.w; 10771 ivec2 outTopLeftCorner = 10772 coords.yz * strides - pads; 10773 int hBeg = outTopLeftCorner.x; 10774 int wBeg = outTopLeftCorner.y; 10775 10776 float curVal = neg_infinity; 10777 for (int h = 0; h < ${i}; h++) { 10778 int hIn = hBeg + h * ${l}; 10779 10780 if (hIn >= 0 && hIn < ${t}) { 10781 for (int w = 0; w < ${c}; w++) { 10782 int wIn = wBeg + w * ${u}; 10783 10784 if (wIn >= 0 && wIn < ${r}) { 10785 float xVal = getX(batch, hIn, wIn, d1); 10786 float wVal = getW(h, w, d1); 10787 10788 float val = xVal + wVal; 10789 if (val > curVal) { 10790 curVal = val; 10791 } 10792 } 10793 } 10794 } 10795 } 10796 10797 float result = curVal; 10798 setOutput(result); 10799 } 10800 `}}/** 10801 * @license 10802 * Copyright 2020 Google LLC. All Rights Reserved. 10803 * Licensed under the Apache License, Version 2.0 (the "License"); 10804 * you may not use this file except in compliance with the License. 10805 * You may obtain a copy of the License at 10806 * 10807 * http://www.apache.org/licenses/LICENSE-2.0 10808 * 10809 * Unless required by applicable law or agreed to in writing, software 10810 * distributed under the License is distributed on an "AS IS" BASIS, 10811 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10812 * See the License for the specific language governing permissions and 10813 * limitations under the License. 10814 * ============================================================================= 10815 */function jO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a}=e,{strides:o,pad:i,dilations:c}=r,l=To(s.shape,a.shape,o,i,"NHWC",c);let u;const d=new HO(l);u=t.runWebGLProgram(d,[s,a],"float32");const p=te({inputs:{x:u},backend:t,attrs:{shape:l.outShape}});return t.disposeIntermediateTensorInfo(u),p}const qO={kernelName:tu,backendName:"webgl",kernelFunc:jO};/** 10816 * @license 10817 * Copyright 2021 Google LLC. All Rights Reserved. 10818 * Licensed under the Apache License, Version 2.0 (the "License"); 10819 * you may not use this file except in compliance with the License. 10820 * You may obtain a copy of the License at 10821 * 10822 * http://www.apache.org/licenses/LICENSE-2.0 10823 * 10824 * Unless required by applicable law or agreed to in writing, software 10825 * distributed under the License is distributed on an "AS IS" BASIS, 10826 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10827 * See the License for the specific language governing permissions and 10828 * limitations under the License. 10829 * ============================================================================= 10830 */function KO(n){const{inputs:e,backend:t,attrs:r}=n,{equation:s}=r,a=e,{allDims:o,summedDims:i,idDims:c}=wy(s,a.length);Iy(o.length,c,a);const{path:l,steps:u}=$y(i,c),d=u.length;let p=null,h=o.length;const m=[];for(let g=0;g<d;++g){for(const y of u[g]){const{permutationIndices:b,expandDims:v}=vy(h,c[y]);let $;Sy(b)?$=a[y]:($=Vt({inputs:{x:a[y]},backend:t,attrs:{perm:b}}),m.push($));const S=$.shape.slice();for(let T=0;T<v.length;++T)S.splice(v[T],0,1);st($.shape,S)||($=te({inputs:{x:$},backend:t,attrs:{shape:S}}),m.push($)),p===null?p=$:(p=nh({inputs:{a:$,b:p},backend:t}),m.push(p))}g<d-1&&(l[g]>=0&&(p=nc({inputs:{x:p},backend:t,attrs:{axis:l[g]-(o.length-h),keepDims:!1}}),m.push(p)),h--)}for(const g of m)g!==p&&t.disposeIntermediateTensorInfo(g);return p}const XO={kernelName:sm,backendName:"webgl",kernelFunc:KO};/** 10831 * @license 10832 * Copyright 2020 Google LLC. All Rights Reserved. 10833 * Licensed under the Apache License, Version 2.0 (the "License");
10834 * you may not use this file except in compliance with the License. 10835 * You may obtain a copy of the License at 10836 * 10837 * http://www.apache.org/licenses/LICENSE-2.0 10838 * 10839 * Unless required by applicable law or agreed to in writing, software 10840 * distributed under the License is distributed on an "AS IS" BASIS, 10841 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10842 * See the License for the specific language governing permissions and 10843 * limitations under the License. 10844 * ============================================================================= 10845 */const YO="return (x >= 0.0) ? x : (exp(x) - 1.0);",QO=` 10846 vec4 result; 10847 10848 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 10849 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 10850 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 10851 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 10852 10853 return result; 10854`,ZO=De({opSnippet:YO,packedOpSnippet:QO}),JO={kernelName:Kl,backendName:"webgl",kernelFunc:ZO};/** 10855 * @license 10856 * Copyright 2020 Google LLC. All Rights Reserved. 10857 * Licensed under the Apache License, Version 2.0 (the "License"); 10858 * you may not use this file except in compliance with the License. 10859 * You may obtain a copy of the License at 10860 * 10861 * http://www.apache.org/licenses/LICENSE-2.0 10862 * 10863 * Unless required by applicable law or agreed to in writing, software 10864 * distributed under the License is distributed on an "AS IS" BASIS, 10865 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10866 * See the License for the specific language governing permissions and 10867 * limitations under the License. 10868 * ============================================================================= 10869 */const eF="return (b >= 0.0) ? a : a * (b + 1.0);",tF=` 10870 vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
10871 return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); 10872`,nF=n=>{const{inputs:e,backend:t}=n,{dy:r,y:s}=e,a=U().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new La(tF,r.shape,s.shape):new Ds(eF,r.shape,s.shape);return t.runWebGLProgram(a,[r,s],r.dtype)},rF={kernelName:Xl,backendName:"webgl",kernelFunc:nF};/** 10873 * @license 10874 * Copyright 2020 Google LLC. All Rights Reserved. 10875 * Licensed under the Apache License, Version 2.0 (the "License"); 10876 * you may not use this file except in compliance with the License. 10877 * You may obtain a copy of the License at 10878 * 10879 * http://www.apache.org/licenses/LICENSE-2.0 10880 * 10881 * Unless required by applicable law or agreed to in writing, software 10882 * distributed under the License is distributed on an "AS IS" BASIS, 10883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10884 * See the License for the specific language governing permissions and 10885 * limitations under the License. 10886 * ============================================================================= 10887 */const sF=` 10888 return vec4(equal(a, b)); 10889`,aF="return float(a == b);",oF=Ct({opSnippet:aF,packedOpSnippet:sF,dtype:"bool",cpuKernelImpl:ME}),iF={kernelName:Ql,backendName:"webgl",kernelFunc:oF};/** 10890 * @license 10891 * Copyright 2020 Google LLC. All Rights Reserved. 10892 * Licensed under the Apache License, Version 2.0 (the "License"); 10893 * you may not use this file except in compliance with the License. 10894 * You may obtain a copy of the License at 10895 * 10896 * http://www.apache.org/licenses/LICENSE-2.0 10897 * 10898 * Unless required by applicable law or agreed to in writing, software 10899 * distributed under the License is distributed on an "AS IS" BASIS, 10900 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10901 * See the License for the specific language governing permissions and 10902 * limitations under the License. 10903 * ============================================================================= 10904 */const uF=` 10905 // Error function is calculated approximately with elementary function. 10906 // See "Handbook of Mathematical Functions with Formulas, 10907 // Graphs, and Mathematical Tables", Abramowitz and Stegun. 10908 float p = ${fy}; 10909 float a1 = ${my}; 10910 float a2 = ${gy}; 10911 float a3 = ${yy}; 10912 float a4 = ${by}; 10913 float a5 = ${xy}; 10914 10915 float sign = sign(x); 10916 x = abs(x); 10917 float t = 1.0 / (1.0 + p * x); 10918 return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); 10919`,cF=De({opSnippet:uF}),lF={kernelName:Yl,backendName:"webgl",kernelFunc:cF};/** 10920 * @license 10921 * Copyright 2020 Google LLC. All Rights Reserved. 10922 * Licensed under the Apache License, Version 2.0 (the "License"); 10923 * you may not use this file except in compliance with the License. 10924 * You may obtain a copy of the License at 10925 * 10926 * http://www.apache.org/licenses/LICENSE-2.0 10927 * 10928 * Unless required by applicable law or agreed to in writing, software 10929 * distributed under the License is distributed on an "AS IS" BASIS, 10930 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10931 * See the License for the specific language governing permissions and 10932 * limitations under the License. 10933 * ============================================================================= 10934 */const dF=Ma+` 10935 return exp(x); 10936`,pF=` 10937 vec4 result = exp(x); 10938 bvec4 isNaN = isnan(x); 10939 result.r = isNaN.r ? x.r : result.r; 10940 result.g = isNaN.g ? x.g : result.g; 10941 result.b = isNaN.b ? x.b : result.b; 10942 result.a = isNaN.a ? x.a : result.a; 10943 10944 return result; 10945`,mb=De({opSnippet:dF,packedOpSnippet:pF,cpuKernelImpl:BE,dtype:"float32"}),hF={kernelName:Zl,backendName:"webgl",kernelFunc:mb};/** 10946 * @license 10947 * Copyright 2020 Google LLC. All Rights Reserved. 10948 * Licensed under the Apache License, Version 2.0 (the License); 10949 * you may not use this file except in compliance with the License. 10950 * You may obtain a copy of the License at 10951 * 10952 * http://www.apache.org/licenses/LICENSE-2.0 10953 * 10954 * Unless required by applicable law or agreed to in writing, software 10955 * distributed under the License is distributed on an AS IS BASIS, 10956 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10957 * See the License for the specific language governing permissions and 10958 * limitations under the License. 10959 * ============================================================================= 10960 */function sl(n){const{inputs:e,attrs:t,backend:r}=n,{dim:s}=t,{input:a}=e,o=a.shape.length,i=a.shape.slice();let c=s;return s<0&&(N(-(o+1)<=s,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),c=o+s+1),i.splice(c,0,1),te({inputs:{x:a},backend:r,attrs:{shape:i}})}const fF={kernelName:Jl,backendName:"webgl",kernelFunc:sl};/** 10961 * @license 10962 * Copyright 2020 Google LLC. All Rights Reserved. 10963 * Licensed under the Apache License, Version 2.0 (the "License");
10964 * you may not use this file except in compliance with the License. 10965 * You may obtain a copy of the License at 10966 * 10967 * http://www.apache.org/licenses/LICENSE-2.0 10968 * 10969 * Unless required by applicable law or agreed to in writing, software 10970 * distributed under the License is distributed on an "AS IS" BASIS, 10971 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10972 * See the License for the specific language governing permissions and 10973 * limitations under the License. 10974 * ============================================================================= 10975 */const bf="return exp(x) - 1.0;",mF=De({opSnippet:bf,packedOpSnippet:bf,cpuKernelImpl:VE}),gF={kernelName:ed,backendName:"webgl",kernelFunc:mF};/** 10976 * @license 10977 * Copyright 2018 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 */class xf{constructor(e,t,r){this.variableNames=["real","imag"];const s=t[1];this.outputShape=t;const a=r?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,o=r?`${s}.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=` 10991 const float exponentMultiplier = ${a}; 10992 10993 float unaryOpComplex(float real, float expR, float imag, float expI) { 10994 ${i} 10995 } 10996 10997 float mulMatDFT(int batch, int index) { 10998 float indexRatio = float(index) / float(${s}); 10999 float exponentMultiplierTimesIndexRatio = 11000 exponentMultiplier * indexRatio; 11001 11002 float result = 0.0; 11003 11004 for (int i = 0; i < ${s}; i++) { 11005 // x = (-2|2 * PI / N) * index * i; 11006 float x = exponentMultiplierTimesIndexRatio * float(i); 11007 float expR = cos(x); 11008 float expI = sin(x); 11009 float real = getReal(batch, i); 11010 float imag = getImag(batch, i); 11011 11012 result += 11013 unaryOpComplex(real, expR, imag, expI) / ${o}; 11014 } 11015 11016 return result; 11017 } 11018 11019 void main() { 11020 ivec2 coords = getOutputCoords(); 11021 setOutput(mulMatDFT(coords[0], coords[1])); 11022 } 11023 `}}/** 11024 * @license 11025 * Copyright 2020 Google LLC. All Rights Reserved. 11026 * Licensed under the Apache License, Version 2.0 (the "License"); 11027 * you may not use this file except in compliance with the License. 11028 * You may obtain a copy of the License at 11029 * 11030 * http://www.apache.org/licenses/LICENSE-2.0 11031 * 11032 * Unless required by applicable law or agreed to in writing, software 11033 * distributed under the License is distributed on an "AS IS" BASIS, 11034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11035 * See the License for the specific language governing permissions and 11036 * limitations under the License. 11037 * ============================================================================= 11038 */function gb(n,e,t){const r=t.texData.get(n.dataId),s=H(n.shape),a=n.shape[n.shape.length-1],o=s/a,i=te({inputs:{x:n},backend:t,attrs:{shape:[o,a]}}),c=i.shape,l=new xf("real",c,e),u=new xf("imag",c,e),d=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:c},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:c}],p=t.runWebGLProgram(l,d,"float32"),h=t.runWebGLProgram(u,d,"float32"),m=Qr({inputs:{real:p,imag:h},backend:t});t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(h);const g=te({inputs:{x:m},backend:t,attrs:{shape:n.shape}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(m),g}/** 11039 * @license 11040 * Copyright 2020 Google LLC. All Rights Reserved. 11041 * Licensed under the Apache License, Version 2.0 (the "License");
11042 * you may not use this file except in compliance with the License. 11043 * You may obtain a copy of the License at 11044 * 11045 * http://www.apache.org/licenses/LICENSE-2.0 11046 * 11047 * Unless required by applicable law or agreed to in writing, software 11048 * distributed under the License is distributed on an "AS IS" BASIS, 11049 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11050 * See the License for the specific language governing permissions and 11051 * limitations under the License. 11052 * ============================================================================= 11053 */function yF(n){const{inputs:e,backend:t}=n,{input:r}=e;return gb(r,!1,t)}const bF={kernelName:am,backendName:"webgl",kernelFunc:yF};/** 11054 * @license 11055 * Copyright 2019 Google LLC. All Rights Reserved. 11056 * Licensed under the Apache License, Version 2.0 (the "License"); 11057 * you may not use this file except in compliance with the License. 11058 * You may obtain a copy of the License at 11059 * 11060 * http://www.apache.org/licenses/LICENSE-2.0 11061 * 11062 * Unless required by applicable law or agreed to in writing, software 11063 * distributed under the License is distributed on an "AS IS" BASIS, 11064 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11065 * See the License for the specific language governing permissions and 11066 * limitations under the License. 11067 * ============================================================================= 11068 */class xF{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` 11069 void main() { 11070 // Input can be obtained from uniform value. 11071 setOutput(value); 11072 } 11073 `}}/** 11074 * @license 11075 * Copyright 2020 Google LLC. All Rights Reserved. 11076 * Licensed under the Apache License, Version 2.0 (the "License"); 11077 * you may not use this file except in compliance with the License. 11078 * You may obtain a copy of the License at 11079 * 11080 * http://www.apache.org/licenses/LICENSE-2.0 11081 * 11082 * Unless required by applicable law or agreed to in writing, software 11083 * distributed under the License is distributed on an "AS IS" BASIS, 11084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11085 * See the License for the specific language governing permissions and 11086 * limitations under the License. 11087 * ============================================================================= 11088 */function Bo(n){const{backend:e,attrs:t}=n,{shape:r,value:s}=t;let{dtype:a}=t;if(a=a||ka(s),a==="string"){const o=yt(a,H(r));return o.fill(s),e.makeTensorInfo(r,a,o)}else{const o=new xF(r,s),i=[[s]];return e.runWebGLProgram(o,[],a,i)}}const wF={kernelName:td,backendName:"webgl",kernelFunc:Bo};/** 11089 * @license 11090 * Copyright 2020 Google LLC. All Rights Reserved. 11091 * Licensed under the Apache License, Version 2.0 (the "License"); 11092 * you may not use this file except in compliance with the License. 11093 * You may obtain a copy of the License at 11094 * 11095 * http://www.apache.org/licenses/LICENSE-2.0 11096 * 11097 * Unless required by applicable law or agreed to in writing, software 11098 * distributed under the License is distributed on an "AS IS" BASIS, 11099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11100 * See the License for the specific language governing permissions and 11101 * limitations under the License. 11102 * ============================================================================= 11103 */class vF{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=` 11104 void main() { 11105 ivec4 coords = getOutputCoords(); 11106 int x = coords[2]; 11107 11108 int coordX = ${t} - x - 1; 11109 float outputValue; 11110 if(coordX >= 0 && coordX < ${t}) { 11111 outputValue = getImage(coords[0], coords[1], coordX, coords[3]); 11112 } else { 11113 outputValue = getImage(coords[0], coords[1], coords[2], coords[3]); 11114 } 11115 setOutput(outputValue); 11116 } 11117 `}}/** 11118 * @license 11119 * Copyright 2020 Google LLC. All Rights Reserved. 11120 * Licensed under the Apache License, Version 2.0 (the "License"); 11121 * you may not use this file except in compliance with the License. 11122 * You may obtain a copy of the License at 11123 * 11124 * http://www.apache.org/licenses/LICENSE-2.0 11125 * 11126 * Unless required by applicable law or agreed to in writing, softw
11126are 11127 * distributed under the License is distributed on an "AS IS" BASIS, 11128 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11129 * See the License for the specific language governing permissions and 11130 * limitations under the License. 11131 * ============================================================================= 11132 */const IF={kernelName:nu,backendName:"webgl",kernelFunc:({inputs:n,backend:e})=>{const{image:t}=n,r=e,s=new vF(t.shape);return r.runWebGLProgram(s,[t],t.dtype)}};/** 11133 * @license 11134 * Copyright 2020 Google LLC. All Rights Reserved. 11135 * Licensed under the Apache License, Version 2.0 (the "License"); 11136 * you may not use this file except in compliance with the License. 11137 * You may obtain a copy of the License at 11138 * 11139 * http://www.apache.org/licenses/LICENSE-2.0 11140 * 11141 * Unless required by applicable law or agreed to in writing, software 11142 * distributed under the License is distributed on an "AS IS" BASIS, 11143 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11144 * See the License for the specific language governing permissions and 11145 * limitations under the License. 11146 * ============================================================================= 11147 */const wf="return floor(x);",$F=De({opSnippet:wf,packedOpSnippet:wf,cpuKernelImpl:WE}),SF={kernelName:nd,backendName:"webgl",kernelFunc:$F};/** 11148 * @license 11149 * Copyright 2020 Google LLC. All Rights Reserved. 11150 * Licensed under the Apache License, Version 2.0 (the "License"); 11151 * you may not use this file except in compliance with the License. 11152 * You may obtain a copy of the License at 11153 * 11154 * http://www.apache.org/licenses/LICENSE-2.0 11155 * 11156 * Unless required by applicable law or agreed to in writing, software 11157 * distributed under the License is distributed on an "AS IS" BASIS, 11158 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11159 * See the License for the specific language governing permissions and 11160 * limitations under the License. 11161 * ============================================================================= 11162 */const CF=` 11163 float s = sign(a) * sign(b); 11164 int ia = round(a); 11165 int ib = round(b); 11166 if (ib != 0) { 11167 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 11168 return float(idiv(ia, ib, s)); 11169 } else { 11170 return NAN; 11171 } 11172`,_F=` 11173 ivec4 ia = round(a); 11174 ivec4 ib = round(b); 11175 bvec4 cond = notEqual(ib, ivec4(0)); 11176 ivec4 result = ivec4(0); 11177 vec4 s = sign(a) * sign(b); 11178 11179 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 11180 if (cond[0]) { 11181 result[0] = idiv(ia[0], ib[0], s[0]); 11182 } 11183 if (cond[1]) { 11184 result[1] = idiv(ia[1], ib[1], s[1]); 11185 } 11186 if (cond[2]) { 11187 result[2] = idiv(ia[2], ib[2], s[2]); 11188 } 11189 if (cond[3]) { 11190 result[3] = idiv(ia[3], ib[3], s[3]); 11191 } 11192 return vec4(result); 11193`,NF=Ct({opSnippet:CF,packedOpSnippet:_F,dtype:"int32"}),TF={kernelName:rd,backendName:"webgl",kernelFunc:NF};/** 11194 * @license 11195 * Copyright 2018 Google LLC. All Rights Reserved. 11196 * Licensed under the Apache License, Version 2.0 (the "License"); 11197 * you may not use this file except in compliance with the License. 11198 * You may obtain a copy of the License at 11199 * 11200 * http://www.apache.org/licenses/LICENSE-2.0 11201 * 11202 * Unless required by applicable law or agreed to in writing, software 11203 * distributed under the License is distributed on an "AS IS" BASIS, 11204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11205 * See the License for the specific language governing permissions and 11206 * limitations under the License. 11207 * ============================================================================= 11208 */class kF{constructor(e){this.variableNames=["A"];const t=Wt(),[r,s]=e;this.outputShape=e,this.userCode=` 11209 void main() { 11210 ivec3 coords = getOutputCoords(); 11211 int texR = coords[0]; 11212 int texC = coords[1]; 11213 int depth = coords[2]; 11214 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${s}.0, ${r}.0); 11215 11216 vec4 values = ${t.texture2D}(A, uv); 11217 float value; 11218 if (depth == 0) { 11219 value = values.r; 11220 } else if (depth == 1) { 11221 value = values.g; 11222 } else if (depth == 2) { 11223 value = values.b; 11224 } else if (depth == 3) { 11225 value = values.a; 11226 } 11227 11228 setOutput(floor(value * 255.0 + 0.5)); 11229 } 11230 `}}/** 11231 * @license 11232 * Copyright 2018 Google LLC. All Rights Reserved. 11233 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 13,364 bytes, lines 11234-11411
11234 * you may not use this file except in compliance with the License. 11235 * You may obtain a copy of the License at 11236 * 11237 * http://www.apache.org/licenses/LICENSE-2.0 11238 * 11239 * Unless required by applicable law or agreed to in writing, software 11240 * distributed under the License is distributed on an "AS IS" BASIS, 11241 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11242 * See the License for the specific language governing permissions and 11243 * limitations under the License. 11244 * ============================================================================= 11245 */class EF{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=Wt(),[r,s]=e;this.outputShape=e,this.userCode=` 11246 void main() { 11247 ivec3 coords = getOutputCoords(); 11248 int texR = coords[0]; 11249 int texC = coords[1]; 11250 int depth = coords[2]; 11251 11252 vec4 result = vec4(0.); 11253 11254 for(int row=0; row<=1; row++) { 11255 for(int col=0; col<=1; col++) { 11256 texC = coords[1] + row; 11257 depth = coords[2] + col; 11258 11259 vec2 uv = (vec2(texC, texR) + halfCR) / 11260 vec2(${s}.0, ${r}.0); 11261 vec4 values = ${t.texture2D}(A, uv); 11262 float value; 11263 if (depth == 0) { 11264 value = values.r; 11265 } else if (depth == 1) { 11266 value = values.g; 11267 } else if (depth == 2) { 11268 value = values.b; 11269 } else if (depth == 3) { 11270 value = values.a; 11271 } 11272 11273 result[row * 2 + col] = floor(value * 255.0 + 0.5); 11274 } 11275 } 11276 11277 ${t.output} = result; 11278 } 11279 `}}/** 11280 * @license 11281 * Copyright 2019 Google LLC. All Rights Reserved. 11282 * Licensed under the Apache License, Version 2.0 (the "License"); 11283 * you may not use this file except in compliance with the License. 11284 * You may obtain a copy of the License at 11285 * 11286 * http://www.apache.org/licenses/LICENSE-2.0 11287 * 11288 * Unless required by applicable law or agreed to in writing, software 11289 * distributed under the License is distributed on an "AS IS" BASIS, 11290 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11291 * See the License for the specific language governing permissions and 11292 * limitations under the License. 11293 * ============================================================================= 11294 */const RF={kernelName:Oc,backendName:"webgl",kernelFunc:AF};let ca,wc=U().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function AF(n){const{inputs:e,backend:t,attrs:r}=n;let{pixels:s}=e;const{numChannels:a}=r,o=typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement,i=typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement,[c,l]=o?[s.videoWidth,s.videoHeight]:[s.width,s.height],u=[l,c],d=[l,c,a];if(i||o){const g=U().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(ca==null||g!==wc)&&(wc=g,ca=document.createElement("canvas").getContext("2d",{willReadFrequently:wc})),ca.canvas.width=c,ca.canvas.height=l,ca.drawImage(s,0,0,c,l),s=ca.canvas}const p=t.makeTensorInfo(u,"int32");t.texData.get(p.dataId).usage=pn.PIXELS,t.gpgpu.uploadPixelDataToTexture(t.getTexture(p.dataId),s);const h=U().getBool("WEBGL_PACK")?new EF(d):new kF(d),m=t.runWebGLProgram(h,[p],"int32");return t.disposeData(p.dataId),m}/** 11295 * @license 11296 * Copyright 2020 Google LLC. All Rights Reserved. 11297 * Licensed under the Apache License, Version 2.0 (the "License"); 11298 * you may not use this file except in compliance with the License. 11299 * You may obtain a copy of the License at 11300 * 11301 * http://www.apache.org/licenses/LICENSE-2.0 11302 * 11303 * Unless required by applicable law or agreed to in writing, software 11304 * distributed under the License is distributed on an "AS IS" BASIS, 11305 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11306 * See the License for the specific language governing permissions and 11307 * limitations under the License. 11308 * ============================================================================= 11309 */function DF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a,bias:o,preluActivationWeights:i}=e,{strides:c,pad:l,dataFormat:u,dilations:d,dimRoundingMode:p,activation:h,leakyreluAlpha:m}=r,g=Yr(u),y=$t(s.shape,a.shape,c,d,l,p,!1,g);let b;const v=[],$=o!=null,S=i!=null,T=h==="leakyrelu",O=()=>{const M=[s,a],W=(V,G)=>{if(G==="NCHW"&&V.shape.length===1&&V.shape[0]!==1){const K=te({inputs:{x:V},backend:t,attrs:{shape:[V.shape[0],1,1]}});return v.push(K),K}return V};if($&&M.push(W(o,u)),S&&M.push(W(i,u)),T){const V=t.makeTensorInfo([],"float32",Ea(m,"float32"));M.push(V),v.push(V)}return M};if(y.filterHeight===1&&y.filterWidth===1&&y.dilationHeight===1&&y.dilationWidth===1&&y.strideHeight===1&&y.strideWidth===1&&(y.padInfo.type==="SAME"||y.padInfo.type==="VALID"))b=lb({x:s,filter:a,convInfo:y,backend:t,bias:o,activation:h,preluActivationWeights:i,leakyreluAlpha:m});else if(y.strideWidth<=2&&g==="channelsLast"&&U().getBool("WEBGL_EXP_CONV")){const M=h?Io(h,!0):null,W=new cb(y,$,M,S,T),V=[[y.padInfo.top,y.padInfo.left],[y.strideHeight,y.strideWidth],[y.dilationHeight,y.dilationWidth],[y.inHeight,y.inWidth]],G=O();b=t.runWebGLProgram(W,G,"float32",V)}else if(U().getBool("WEBGL_CONV_IM2COL"))b=db({x:s,filter:a,convInfo:y,backend:t,bias:o,activation:h,preluActivationWeights:i,leakyreluAlpha:m});else{const M=h?Io(h,!1):null,W=new ub(y,$,M,S,T),V=O();b=t.runWebGLProgram(W,V,"float32")}const L=te({inputs:{x:b},backend:t,attrs:{shape:y.outShape}});return v.push(b),v.forEach(M=>t.disposeIntermediateTensorInfo(M)),L}const OF={kernelName:co,backendName:"webgl",kernelFunc:DF};/** 11310 * @license 11311 * Copyright 2020 Google LLC. All Rights Reserved. 11312 * Licensed under the Apache License, Version 2.0 (the "License"); 11313 * you may not use this file except in compliance with the License. 11314 * You may obtain a copy of the License at 11315 * 11316 * http://www.apache.org/licenses/LICENSE-2.0 11317 * 11318 * Unless required by applicable law or agreed to in writing, software 11319 * distributed under the License is distributed on an "AS IS" BASIS, 11320 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11321 * See the License for the specific language governing permissions and 11322 * limitations under the License. 11323 * ============================================================================= 11324 */function FF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a,bias:o,preluActivationWeights:i}=e,{strides:c,pad:l,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:h}=r,m=[];let g=u;g==null&&(g=[1,1]),N(Kt(c,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${c} and dilations '${g}'`);const y=$t(s.shape,a.shape,c,g,l,d,!0),b=U().getBool("WEBGL_PACK_DEPTHWISECONV")&&y.strideWidth<=2&&y.outChannels/y.inChannels===1,v=p?Io(p,b):null,$=[s,a],S=o!=null,T=i!=null,O=p==="leakyrelu";if(S&&$.push(o),T&&$.push(i),O){const V=t.makeTensorInfo([],"float32",Ea(h,"float32"));$.push(V),m.push(V)}let L;b?L=new fb(y,S,v,T,O):L=new hb(y,S,v,T,O);const M=[[y.padInfo.top,y.padInfo.left],[y.strideHeight,y.strideWidth],[y.dilationHeight,y.dilationWidth],[y.inHeight,y.inWidth]],W=t.runWebGLProgram(L,$,"float32",M);return m.forEach(V=>t.disposeIntermediateTensorInfo(V)),W}const PF={kernelName:lo,backendName:"webgl",kernelFunc:FF};class LF{constructor(e,t,r,s){this.sliceDim=e,this.strides=t,this.paramsShape=s,this.variableNames=["x","indices"],this.outputShape=r;const a=ze(r.length);let o=` 11325 int index;`;for(let i=0;i<this.sliceDim;i++)o+=` 11326 index = round(getIndices(coords[0], ${i})); 11327 out_of_bounds = out_of_bounds || index < 0; 11328 out_of_bounds = out_of_bounds || index >= ${this.paramsShape[i]}; 11329 flattenIndex += index * ${this.strides[i]};`;this.userCode=` 11330 void main() { 11331 ${a} coords = getOutputCoords(); 11332 int flattenIndex = 0; 11333 bool out_of_bounds = false; 11334 11335 ${o} 11336 11337 setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1])); 11338 } 11339 `}}/** 11340 * @license 11341 * Copyright 2020 Google LLC. All Rights Reserved. 11342 * Licensed under the Apache License, Version 2.0 (the "License"); 11343 * you may not use this file except in compliance with the License. 11344 * You may obtain a copy of the License at 11345 * 11346 * http://www.apache.org/licenses/LICENSE-2.0 11347 * 11348 * Unless required by applicable law or agreed to in writing, software 11349 * distributed under the License is distributed on an "AS IS" BASIS, 11350 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11351 * See the License for the specific language governing permissions and 11352 * limitations under the License. 11353 * ============================================================================= 11354 */function MF(n){const{inputs:e,backend:t}=n,{params:r,indices:s}=e,a=s.shape,o=a[a.length-1],i=H(r.shape),[c,l,u,d]=Np(r,s),p=te({inputs:{x:s},backend:t,attrs:{shape:[l,o]}}),h=te({inputs:{x:r},backend:t,attrs:{shape:[H(r.shape)/u,u]}});if(t.shouldExecuteOnCPU([r,s])||r.dtype==="string"){const b=t.readSync(s.dataId),v=t.bufferSync(r),$=UE(b,v,r.dtype,l,o,u,d,r.shape,i);return t.makeTensorInfo(c,r.dtype,$.values)}const m=new LF(o,d,[l,u],r.shape),g=t.runWebGLProgram(m,[h,p],h.dtype),y=te({inputs:{x:g},backend:t,attrs:{shape:c}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(g),y}const BF={kernelName:su,backendName:"webgl",kernelFunc:MF};/** 11355 * @license 11356 * Copyright 2017 Google LLC. All Rights Reserved. 11357 * Licensed under the Apache License, Version 2.0 (the "License"); 11358 * you may not use this file except in compliance with the License. 11359 * You may obtain a copy of the License at 11360 * 11361 * http://www.apache.org/licenses/LICENSE-2.0 11362 * 11363 * Unless required by applicable law or agreed to in writing, software 11364 * distributed under the License is distributed on an "AS IS" BASIS, 11365 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11366 * See the License for the specific language governing permissions and 11367 * limitations under the License. 11368 * ============================================================================= 11369 */class VF{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const r=ze(this.rank),s=WF(e);this.userCode=` 11370 void main() { 11371 ${r} resRC = getOutputCoords(); 11372 int index = int(getIndices(resRC.x, resRC.z)); 11373 float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0; 11374 setOutput(inBounds * getA(${s})); 11375 } 11376 `}}function WF(n,e){const t=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let s=0;s<n.length;s++)s===2?r.push("index"):r.push(`${t[s]}`);return r.join()}/** 11377 * @license 11378 * Copyright 2020 Google LLC. All Rights Reserved. 11379 * Licensed under the Apache License, Version 2.0 (the "License"); 11380 * you may not use this file except in compliance with the License. 11381 * You may obtain a copy of the License at 11382 * 11383 * http://www.apache.org/licenses/LICENSE-2.0 11384 * 11385 * Unless required by applicable law or agreed to in writing, software 11386 * distributed under the License is distributed on an "AS IS" BASIS, 11387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11388 * See the License for the specific language governing permissions and 11389 * limitations under the License. 11390 * ============================================================================= 11391 */function yb(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,indices:a}=e,{axis:o,batchDims:i}=r,c=ot(o,s.shape)[0];if(U().get("DEBUG")){const v=t.readSync(a.dataId),$=s.shape[c];for(let S=0;S<v.length;++S){const T=v[S];N(T<=$-1&&T>=0,()=>`GatherV2: the index value ${T} is not in [0, ${$-1}]`)}}const l=Kp(s,a,c,i),u=H(a.shape),d=[],p=te({inputs:{x:s},backend:t,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),h=te({inputs:{x:a},backend:t,attrs:{shape:[l.batchSize,u/l.batchSize]}});d.push(p),d.push(h);const m=[l.batchSize,l.outerSize,u/l.batchSize,l.sliceSize];if(t.shouldExecuteOnCPU([s,a])||s.dtype==="string"){const v=t.bufferSync(h),$=t.bufferSync(p),S=zE($,v,m);return d.forEach(T=>t.disposeIntermediateTensorInfo(T)),t.makeTensorInfo(l.outputShape,S.dtype,S.values)}const g=new VF(p.shape,m),y=t.runWebGLProgram(g,[p,h],p.dtype);d.push(y);const b=te({inputs:{x:y},backend:t,attrs:{shape:l.outputShape}});return d.forEach(v=>t.disposeIntermediateTensorInfo(v)),b}const UF={kernelName:sd,backendName:"webgl",kernelFunc:yb};/** 11392 * @license 11393 * Copyright 2020 Google LLC. All Rights Reserved. 11394 * Licensed under the Apache License, Version 2.0 (the "License"); 11395 * you may not use this file except in compliance with the License. 11396 * You may obtain a copy of the License at 11397 * 11398 * http://www.apache.org/licenses/LICENSE-2.0 11399 * 11400 * Unless required by applicable law or agreed to in writing, software 11401 * distributed under the License is distributed on an "AS IS" BASIS, 11402 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11403 * See the License for the specific language governing permissions and 11404 * limitations under the License. 11405 * ============================================================================= 11406 */const zF="return float(a > b);",GF=` 11407 return vec4(greaterThan(a, b)); 11408`,HF=Ct({opSnippet:zF,packedOpSnippet:GF,cpuKernelImpl:GE,dtype:"bool"}),jF={kernelName:ad,backendName:"webgl",kernelFunc:HF};/** 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 */const qF="return float(a >= b);",KF=` 11424 return vec4(greaterThanEqual(a, b)); 11425`,XF=Ct({opSnippet:qF,packedOpSnippet:KF,dtype:"bool",cpuKernelImpl:HE}),YF={kernelName:od,backendName:"webgl",kernelFunc:XF};/** 11426 * @license 11427 * Copyright 2020 Google LLC. All Rights Reserved. 11428 * Licensed under the Apache License, Version 2.0 (the "License"); 11429 * you may not use this file except in compliance with the License. 11430 * You may obtain a copy of the License at 11431 * 11432 * http://www.apache.org/licenses/LICENSE-2.0 11433 * 11434 * Unless required by applicable law or agreed to in writing, software 11435 * distributed under the License is distributed on an "AS IS" BASIS, 11436 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11437 * See the License for the specific language governing permissions and 11438 * limitations under the License. 11439 * ============================================================================= 11440 */function QF(n){const{inputs:e,backend:t}=n,{input:r}=e;return gb(r,!0,t)}const ZF={kernelName:om,backendName:"webgl",kernelFunc:QF};/** 11441 * @license 11442 * Copyright 2020 Google LLC. All Rights Reserved. 11443 * Licensed under the Apache License, Version 2.0 (the "License"); 11444 * you may not use this file except in compliance with the License. 11445 * You may obtain a copy of the License at 11446 * 11447 * http://www.apache.org/licenses/LICENSE-2.0 11448 * 11449 * Unless required by applicable law or agreed to in writing, software 11450 * distributed under the License is distributed on an "AS IS" BASIS, 11451 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11452 * See the License for the specific language governing permissions and 11453 * limitations under the License. 11454 * ============================================================================= 11455 */const JF="return float(!isnan(x) && !isinf(x));",eP=De({opSnippet:JF,dtype:"bool"}),tP={kernelName:id,backendName:"webgl",kernelFunc:eP};/** 11456 * @license 11457 * Copyright 2020 Google LLC. All Rights Reserved. 11458 * Licensed under the Apache License, Version 2.0 (the "License"); 11459 * you may not use this file except in compliance with the License. 11460 * You may obtain a copy of the License at 11461 * 11462 * http://www.apache.org/licenses/LICENSE-2.0 11463 * 11464 * Unless required by applicable law or agreed to in writing, software 11465 * distributed under the License is distributed on an "AS IS" BASIS, 11466 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11467 * See the License for the specific language governing permissions and 11468 * limitations under the License. 11469 * ============================================================================= 11470 */const nP="return float(isinf(x));",rP=De({opSnippet:nP,dtype:"bool"}),sP={kernelName:ud,backendName:"webgl",kernelFunc:rP};/** 11471 * @license 11472 * Copyright 2020 Google LLC. All Rights Reserved. 11473 * Licensed under the Apache License, Version 2.0 (the "License"); 11474 * you may not use this file except in compliance with the License. 11475 * You may obtain a copy of the License at 11476 * 11477 * http://www.apache.org/licenses/LICENSE-2.0 11478 * 11479 * Unless required by applicable law or agreed to in writing, software 11480 * distributed under the License is distributed on an "AS IS" BASIS, 11481 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11482 * See the License for the specific language governing permissions and 11483 * limitations under the License. 11484 * ============================================================================= 11485 */const aP="return float(isnan(x));",oP=De({opSnippet:aP,dtype:"bool"}),iP={kernelName:cd,backendName:"webgl",kernelFunc:oP};/** 11486 * @license 11487 * Copyright 2020 Google LLC. All Rights Reserved. 11488 * Licensed under the Apache License, Version 2.0 (the "License");
11489 * you may not use this file except in compliance with the License. 11490 * You may obtain a copy of the License at 11491 * 11492 * http://www.apache.org/licenses/LICENSE-2.0 11493 * 11494 * Unless required by applicable law or agreed to in writing, software 11495 * distributed under the License is distributed on an "AS IS" BASIS, 11496 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11497 * See the License for the specific language governing permissions and 11498 * limitations under the License. 11499 * ============================================================================= 11500 */const uP="return float(a < b);",cP=` 11501 return vec4(lessThan(a, b)); 11502`,lP=Ct({opSnippet:uP,packedOpSnippet:cP,cpuKernelImpl:jE,dtype:"bool"}),dP={kernelName:ld,backendName:"webgl",kernelFunc:lP};/** 11503 * @license 11504 * Copyright 2020 Google LLC. All Rights Reserved. 11505 * Licensed under the Apache License, Version 2.0 (the "License"); 11506 * you may not use this file except in compliance with the License. 11507 * You may obtain a copy of the License at 11508 * 11509 * http://www.apache.org/licenses/LICENSE-2.0 11510 * 11511 * Unless required by applicable law or agreed to in writing, software 11512 * distributed under the License is distributed on an "AS IS" BASIS, 11513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11514 * See the License for the specific language governing permissions and 11515 * limitations under the License. 11516 * ============================================================================= 11517 */const pP="return float(a <= b);",hP=` 11518 return vec4(lessThanEqual(a, b)); 11519`,fP=Ct({opSnippet:pP,packedOpSnippet:hP,cpuKernelImpl:qE,dtype:"bool"}),mP={kernelName:dd,backendName:"webgl",kernelFunc:fP};/** 11520 * @license 11521 * Copyright 2020 Google LLC. All Rights Reserved. 11522 * Licensed under the Apache License, Version 2.0 (the "License"); 11523 * you may not use this file except in compliance with the License. 11524 * You may obtain a copy of the License at 11525 * 11526 * http://www.apache.org/licenses/LICENSE-2.0 11527 * 11528 * Unless required by applicable law or agreed to in writing, software 11529 * distributed under the License is distributed on an "AS IS" BASIS, 11530 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11531 * See the License for the specific language governing permissions and 11532 * limitations under the License. 11533 * ============================================================================= 11534 */function gP(n){const{backend:e,attrs:t}=n,{start:r,stop:s,num:a}=t,o=KE(r,s,a);return e.makeTensorInfo([o.length],"float32",o)}const yP={kernelName:iu,backendName:"webgl",kernelFunc:gP};/** 11535 * @license 11536 * Copyright 2020 Google LLC. All Rights Reserved. 11537 * Licensed under the Apache License, Version 2.0 (the "License"); 11538 * you may not use this file except in compliance with the License. 11539 * You may obtain a copy of the License at 11540 * 11541 * http://www.apache.org/licenses/LICENSE-2.0 11542 * 11543 * Unless required by applicable law or agreed to in writing, software 11544 * distributed under the License is distributed on an "AS IS" BASIS, 11545 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11546 * See the License for the specific language governing permissions and 11547 * limitations under the License. 11548 * ============================================================================= 11549 */const bP=Ma+` 11550 return x < 0.0 ? 0./0. : log(x); 11551`,xP=` 11552 vec4 result = log(x); 11553 bvec4 isNaN = isnan(x); 11554 result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r); 11555 result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g); 11556 result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b); 11557 result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a); 11558 return result; 11559`,wP=De({opSnippet:bP,packedOpSnippet:xP,cpuKernelImpl:XE}),vP={kernelName:pd,backendName:"webgl",kernelFunc:wP};/** 11560 * @license 11561 * Copyright 2020 Google LLC. All Rights Reserved. 11562 * Licensed under the Apache License, Version 2.0 (the "License"); 11563 * you may not use this file except in compliance with the License. 11564 * You may obtain a copy of the License at 11565 * 11566 * http://www.apache.org/licenses/LICENSE-2.0 11567 * 11568 * Unless required by applicable law or agreed to in writing, softw
11568are 11569 * distributed under the License is distributed on an "AS IS" BASIS, 11570 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11571 * See the License for the specific language governing permissions and 11572 * limitations under the License. 11573 * ============================================================================= 11574 */const IP=Ma+` 11575 return log(1.0 + x); 11576`,$P=De({opSnippet:IP}),SP={kernelName:hd,backendName:"webgl",kernelFunc:$P};/** 11577 * @license 11578 * Copyright 2020 Google LLC. All Rights Reserved. 11579 * Licensed under the Apache License, Version 2.0 (the "License"); 11580 * you may not use this file except in compliance with the License. 11581 * You may obtain a copy of the License at 11582 * 11583 * http://www.apache.org/licenses/LICENSE-2.0 11584 * 11585 * Unless required by applicable law or agreed to in writing, software 11586 * distributed under the License is distributed on an "AS IS" BASIS, 11587 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11588 * See the License for the specific language governing permissions and 11589 * limitations under the License. 11590 * ============================================================================= 11591 */const CP="return float(a >= 1.0 && b >= 1.0);",_P=` 11592 return vec4( 11593 vec4(greaterThanEqual(a, vec4(1.0))) * 11594 vec4(greaterThanEqual(b, vec4(1.0)))); 11595`,NP=Ct({opSnippet:CP,packedOpSnippet:_P,dtype:"bool"}),TP={kernelName:fd,backendName:"webgl",kernelFunc:NP};/** 11596 * @license 11597 * Copyright 2020 Google LLC. All Rights Reserved. 11598 * Licensed under the Apache License, Version 2.0 (the "License"); 11599 * you may not use this file except in compliance with the License. 11600 * You may obtain a copy of the License at 11601 * 11602 * http://www.apache.org/licenses/LICENSE-2.0 11603 * 11604 * Unless required by applicable law or agreed to in writing, software 11605 * distributed under the License is distributed on an "AS IS" BASIS, 11606 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11607 * See the License for the specific language governing permissions and 11608 * limitations under the License. 11609 * ============================================================================= 11610 */const kP="return float(!(x >= 1.0));",EP=De({opSnippet:kP}),RP={kernelName:md,backendName:"webgl",kernelFunc:EP};/** 11611 * @license 11612 * Copyright 2020 Google LLC. All Rights Reserved. 11613 * Licensed under the Apache License, Version 2.0 (the "License"); 11614 * you may not use this file except in compliance with the License. 11615 * You may obtain a copy of the License at 11616 * 11617 * http://www.apache.org/licenses/LICENSE-2.0 11618 * 11619 * Unless required by applicable law or agreed to in writing, software 11620 * distributed under the License is distributed on an "AS IS" BASIS, 11621 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11622 * See the License for the specific language governing permissions and 11623 * limitations under the License. 11624 * ============================================================================= 11625 */const AP="return float(a >= 1.0 || b >= 1.0);",DP=` 11626 return min( 11627 vec4(greaterThanEqual(a, vec4(1.0))) + 11628 vec4(greaterThanEqual(b, vec4(1.0))), 11629 vec4(1.0)); 11630`,OP=Ct({opSnippet:AP,packedOpSnippet:DP,dtype:"bool"}),FP={kernelName:gd,backendName:"webgl",kernelFunc:OP};/** 11631 * @license 11632 * Copyright 2017 Google LLC. All Rights Reserved. 11633 * Licensed under the Apache License, Version 2.0 (the "License"); 11634 * you may not use this file except in compliance with the License. 11635 * You may obtain a copy of the License at 11636 * 11637 * http://www.apache.org/licenses/LICENSE-2.0 11638 * 11639 * Unless required by applicable law or agreed to in writing, software 11640 * distributed under the License is distributed on an "AS IS" BASIS, 11641 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11642 * See the License for the specific language governing permissions and 11643 * limitations under the License. 11644 * ============================================================================= 11645 */class PP{constructor(e,t,r,s,a){this.variableNames=["x"],this.outputShape=[];const o=t,i=e[3]-1;this.outputShape=e;let c;const l=`float(${r}) + float(${s}) * sum`;a===.5?c=`inversesqrt(${l})`:a===1?c=`1.0/(${l})`:c=`exp(log(${l}) * float(-${a}));`,this.userCode=` 11646 void main() { 11647 ivec4 coords = getOutputCoords(); 11648 int b = coords[0]; 11649 int r = coords[1]; 11650 int c = coords[2]; 11651 int d = coords[3]; 11652 float x = getX(b, r, c, d); 11653 float sum = 0.0;
11654 for (int j = -${o}; j <= ${o}; j++) { 11655 int idx = d + j; 11656 if (idx >= 0 && idx <= ${i}) { 11657 float z = getX(b, r, c, idx); 11658 sum += z * z; 11659 } 11660 } 11661 float val = x * ${c}; 11662 setOutput(val); 11663 } 11664 `}}/** 11665 * @license 11666 * Copyright 2019 Google LLC. All Rights Reserved. 11667 * Licensed under the Apache License, Version 2.0 (the "License"); 11668 * you may not use this file except in compliance with the License. 11669 * You may obtain a copy of the License at 11670 * 11671 * http://www.apache.org/licenses/LICENSE-2.0 11672 * 11673 * Unless required by applicable law or agreed to in writing, software 11674 * distributed under the License is distributed on an "AS IS" BASIS, 11675 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11676 * See the License for the specific language governing permissions and 11677 * limitations under the License. 11678 * ============================================================================= 11679 */class LP{constructor(e,t,r,s,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const o=t,i=e[3]-1;this.outputShape=e;let c;const l=`float(${r}) + float(${s}) * sum`;a===.5?c=`inversesqrt(${l})`:a===1?c=`1.0/(${l})`:c=`exp(log(${l}) * float(-${a}));`,this.userCode=` 11680 void main() { 11681 ivec4 coords = getOutputCoords(); 11682 int b = coords.x; 11683 int r = coords.y; 11684 int c = coords.z; 11685 int d = coords.w; 11686 11687 bool hasNextCol = d < ${this.outputShape[3]}; 11688 bool hasNextRow = c < ${this.outputShape[2]}; 11689 11690 vec4 sum = vec4(0.); 11691 vec4 xFragAtOutputCoords = getX(b, r, c, d); 11692 11693 vec4 xAtOutputCoords = vec4( 11694 getChannel(xFragAtOutputCoords, vec2(c, d)), 11695 hasNextCol ? 11696 getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0, 11697 hasNextRow ? 11698 getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0, 11699 (hasNextRow && hasNextCol) ? 11700 getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0 11701 ); 11702 11703 int firstChannel = d - ${o}; 11704 vec2 cache = vec2(0.); 11705 if(firstChannel >= 0){ 11706 vec4 firstChannelFrag = getX(b, r, c, firstChannel); 11707 cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel)); 11708 if(hasNextRow){ 11709 cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel)); 11710 } 11711 } 11712 11713 ivec2 depth = ivec2(d, d + 1); 11714 for (int j = - ${o}; j <= ${o}; j++) { 11715 ivec2 idx = depth + j; 11716 bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0)); 11717 bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${i})); 11718 11719 bool depthInRange = aboveLowerBound.x && belowUpperBound.x; 11720 bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y; 11721 11722 if(depthInRange || depthPlusOneInRange){ 11723 vec4 z = vec4(0.); 11724 vec4 xFragAtCurrentDepth; 11725 z.xz = cache.xy; 11726 if(depthPlusOneInRange && hasNextCol){ 11727 xFragAtCurrentDepth = idx.y != d ? 11728 getX(b, r, c, idx.y) : xFragAtOutputCoords; 11729 z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y)); 11730 if(hasNextRow){ 11731 z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y)); 11732 } 11733 } 11734 cache.xy = z.yw; 11735 sum += z * z; 11736 } 11737 } 11738 vec4 result = xAtOutputCoords * ${c}; 11739 setOutput(result); 11740 } 11741 `}}/** 11742 * @license 11743 * Copyright 2020 Google LLC. All Rights Reserved. 11744 * Licensed under the Apache License, Version 2.0 (the "License"); 11745 * you may not use this file except in compliance with the License. 11746 * You may obtain a copy of the License at 11747 * 11748 * http://www.apache.org/licenses/LICENSE-2.0 11749 * 11750 * Unless required by applicable law or agreed to in writing, software 11751 * distributed under the License is distributed on an "AS IS" BASIS, 11752 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11753 * See the License for the specific language governing permissions and 11754 * limitations under the License. 11755 * ============================================================================= 11756 */const MP=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}
vendor: 4,763 bytes, lines 11756-11859
11756=e,{depthRadius:a,bias:o,alpha:i,beta:c}=r,l=U().getBool("WEBGL_PACK_NORMALIZATION")?new LP(s.shape,a,o,i,c):new PP(s.shape,a,o,i,c);return t.runWebGLProgram(l,[s],s.dtype)},BP={kernelName:uu,backendName:"webgl",kernelFunc:MP};/** 11757 * @license 11758 * Copyright 2018 Google LLC. All Rights Reserved. 11759 * Licensed under the Apache License, Version 2.0 (the "License"); 11760 * you may not use this file except in compliance with the License. 11761 * You may obtain a copy of the License at 11762 * 11763 * http://www.apache.org/licenses/LICENSE-2.0 11764 * 11765 * Unless required by applicable law or agreed to in writing, software 11766 * distributed under the License is distributed on an "AS IS" BASIS, 11767 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11768 * See the License for the specific language governing permissions and 11769 * limitations under the License. 11770 * ============================================================================= 11771 */class VP{constructor(e,t,r,s,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=r,this.alpha=s,this.beta=a,this.userCode=` 11772 void main() { 11773 ivec4 coords = getOutputCoords(); 11774 int b = coords[0]; 11775 int r = coords[1]; 11776 int c = coords[2]; 11777 11778 float result = 0.0; 11779 for (int d = 0; d < ${this.depth}; ++d) { 11780 int depthBegin = int(max(0.0, float(d - ${t}))); 11781 int depthEnd = int(min(float(${this.depth}), 11782 float(d + ${t} + 1))); 11783 11784 const int MIN_DEPTH_BEGIN = 0; 11785 const int MAX_DEPTH_END = ${this.depth}; 11786 11787 float norm = 0.0; 11788 for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) { 11789 if (k < depthBegin){ 11790 continue; 11791 } 11792 else if (k >= depthBegin && k < depthEnd) { 11793 norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k); 11794 } 11795 else { 11796 break; 11797 } 11798 } 11799 11800 norm = float(${s}) * norm + float(${r}); 11801 11802 for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){ 11803 if (k < depthBegin){ 11804 continue; 11805 } 11806 else if (k >= depthBegin && k < depthEnd){ 11807 float dyi = -2.0 * float(${s}) 11808 * float(${a}) 11809 * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d) 11810 / norm; 11811 if (k == d) { 11812 dyi += pow(norm, -1.0 * ${a}); 11813 } 11814 if (k == coords[3]) { 11815 dyi *= getDy(b, r, c, d); 11816 result += dyi; 11817 } 11818 } 11819 else { 11820 break; 11821 } 11822 } 11823 } 11824 setOutput(result); 11825 } 11826 `}}/** 11827 * @license 11828 * Copyright 2020 Google LLC. All Rights Reserved. 11829 * Licensed under the Apache License, Version 2.0 (the "License"); 11830 * you may not use this file except in compliance with the License. 11831 * You may obtain a copy of the License at 11832 * 11833 * http://www.apache.org/licenses/LICENSE-2.0 11834 * 11835 * Unless required by applicable law or agreed to in writing, software 11836 * distributed under the License is distributed on an "AS IS" BASIS, 11837 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11838 * See the License for the specific language governing permissions and 11839 * limitations under the License. 11840 * ============================================================================= 11841 */const WP=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s,y:a,dy:o}=e,{depthRadius:i,bias:c,alpha:l,beta:u}=r,d=new VP(s.shape,i,c,l,u);return t.runWebGLProgram(d,[s,a,o],s.dtype)},UP={kernelName:yd,backendName:"webgl",kernelFunc:WP};/** 11842 * @license 11843 * Copyright 2020 Google LLC. All Rights Reserved. 11844 * Licensed under the Apache License, Version 2.0 (the "License"); 11845 * you may not use this file except in compliance with the License. 11846 * You may obtain a copy of the License at 11847 * 11848 * http://www.apache.org/licenses/LICENSE-2.0 11849 * 11850 * Unless required by applicable law or agreed to in writing, software 11851 * distributed under the License is distributed on an "AS IS" BASIS, 11852 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11853 * See the License for the specific language governing permissions and 11854 * limitations under the License. 11855 * ============================================================================= 11856 */function zP(n,e,t,r){const s=H(e),o=H(n.shape)/s,i=te({inputs:{x:n},attrs:{shape:[o,s]},backend:r}),c=Gs(i,n.dtype,"max",r),l=te({inputs:{x:c},attrs:{shape:t},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(c),l}/** 11857 * @license 11858 * Copyright 2020 Google LLC. All Rights Reserved. 11859 * Licensed under the Apache License, Version 2.0 (the "License");
11860 * you may not use this file except in compliance with the License. 11861 * You may obtain a copy of the License at 11862 * 11863 * http://www.apache.org/licenses/LICENSE-2.0 11864 * 11865 * Unless required by applicable law or agreed to in writing, software 11866 * distributed under the License is distributed on an "AS IS" BASIS, 11867 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11868 * See the License for the specific language governing permissions and 11869 * limitations under the License. 11870 * ============================================================================= 11871 */function bb(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{reductionIndices:a,keepDims:o}=r,i=s.shape.length,c=ot(a,s.shape);let l=c;const u=Xt(l,i),d=u!=null,p=t.shouldExecuteOnCPU([s]);let h=s;if(d){if(p){const $=t.texData.get(h.dataId).values,S=new Array(i);for(let L=0;L<S.length;L++)S[L]=s.shape[u[L]];const T=eh($,s.shape,s.dtype,u,S);h=t.makeTensorInfo(S,s.dtype);const O=t.texData.get(h.dataId);O.values=T}else h=tc(s,u,t);l=St(l.length,i)}ht("max",l,i);const[m,g]=At(h.shape,l);let y=m;o&&(y=pt(m,c));let b;if(p){const $=t.texData.get(h.dataId).values,S=YE($,H(g),y,s.dtype);b=t.makeTensorInfo(y,s.dtype);const T=t.texData.get(b.dataId);T.values=S}else b=zP(h,g,y,t);return d&&t.disposeIntermediateTensorInfo(h),b}const GP={kernelName:cu,backendName:"webgl",kernelFunc:bb};/** 11872 * @license 11873 * Copyright 2020 Google LLC. All Rights Reserved. 11874 * Licensed under the Apache License, Version 2.0 (the "License"); 11875 * you may not use this file except in compliance with the License. 11876 * You may obtain a copy of the License at 11877 * 11878 * http://www.apache.org/licenses/LICENSE-2.0 11879 * 11880 * Unless required by applicable law or agreed to in writing, software 11881 * distributed under the License is distributed on an "AS IS" BASIS, 11882 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11883 * See the License for the specific language governing permissions and 11884 * limitations under the License. 11885 * ============================================================================= 11886 */const HP=th+` 11887 return max(a, b); 11888`,jP=` 11889 vec4 result = vec4(max(a, b)); 11890 bvec4 isNaNA = isnan(a); 11891 bvec4 isNaNB = isnan(b); 11892 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 11893 `+zs+` 11894 return result; 11895`,qP=Ct({opSnippet:HP,packedOpSnippet:jP,cpuKernelImpl:QE}),KP={kernelName:bd,backendName:"webgl",kernelFunc:qP};/** 11896 * @license 11897 * Copyright 2020 Google LLC. All Rights Reserved. 11898 * Licensed under the Apache License, Version 2.0 (the "License"); 11899 * you may not use this file except in compliance with the License. 11900 * You may obtain a copy of the License at 11901 * 11902 * http://www.apache.org/licenses/LICENSE-2.0 11903 * 11904 * Unless required by applicable law or agreed to in writing, software 11905 * distributed under the License is distributed on an "AS IS" BASIS, 11906 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11907 * See the License for the specific language governing permissions and 11908 * limitations under the License. 11909 * ============================================================================= 11910 */function XP(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;Po(s,"maxPool");const{filterSize:a,strides:o,pad:i,dimRoundingMode:c}=r,l=1;N(Kt(o,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${l}'`);const u=kn(s.shape,a,o,l,i,c);if(u.filterWidth===1&&u.filterHeight===1&&st(u.inShape,u.outShape))return rn({inputs:{x:s},backend:t});const d=new $o(u,"max",!1);return t.runWebGLProgram(d,[s],s.dtype)}const YP={kernelName:lu,backendName:"webgl",kernelFunc:XP};/** 11911 * @license 11912 * Copyright 2020 Google LLC. All Rights Reserved. 11913 * Licensed under the Apache License, Version 2.0 (the "License"); 11914 * you may not use this file except in compliance with the License. 11915 * You may obtain a copy of the License at 11916 * 11917 * http://www.apache.org/licenses/LICENSE-2.0 11918 * 11919 * Unless required by applicable law or agreed to in writing, software 11920 * distributed under the License is distributed on an "AS IS" BASIS, 11921 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11922 * See the License for the specific language governing permissions and 11923 * limitations under the License. 11924 * ============================================================================= 11925 */function QP(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:a,strides:o,pad:i,dataFormat:c,dimRoundingMode:l}=r,u=[1,1,1],d=Ir(s.shape,a,o,u,i,l,c),p=new rh(d,"max",!1);return t.runWebGLProgram(p,[s],s.dtype)}const ZP={kernelName:xd,backendName:"webgl",kernelFunc:QP};/** 11926 * @license 11927 * Copyright 2017 Google LLC. All Rights Reserved. 11928 * Licensed under the Apache License, Version 2.0 (the "License");
11929 * you may not use this file except in compliance with the License. 11930 * You may obtain a copy of the License at 11931 * 11932 * http://www.apache.org/licenses/LICENSE-2.0 11933 * 11934 * Unless required by applicable law or agreed to in writing, software 11935 * distributed under the License is distributed on an "AS IS" BASIS, 11936 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11937 * See the License for the specific language governing permissions and 11938 * limitations under the License. 11939 * ============================================================================= 11940 */class JP{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,r=e.strideWidth,s=e.dilationHeight,a=e.effectiveFilterHeight,o=e.effectiveFilterWidth,i=a-1-e.padInfo.top,c=o-1-e.padInfo.left,l=a*o-1;this.userCode=` 11941 const ivec2 pads = ivec2(${i}, ${c}); 11942 11943 void main() { 11944 ivec4 coords = getOutputCoords(); 11945 int b = coords[0]; 11946 int d = coords[3]; 11947 11948 ivec2 dyRCCorner = coords.yz - pads; 11949 int dyRCorner = dyRCCorner.x; 11950 int dyCCorner = dyRCCorner.y; 11951 11952 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 11953 // ? = to be determined. : = across all values in that axis. 11954 float dotProd = 0.0; 11955 for (int wR = 0; wR < ${a}; 11956 wR += ${s}) { 11957 float dyR = float(dyRCorner + wR) / ${t}.0; 11958 11959 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 11960 continue; 11961 } 11962 int idyR = int(dyR); 11963 11964 for (int wC = 0; wC < ${o}; wC++) { 11965 float dyC = float(dyCCorner + wC) / ${r}.0; 11966 11967 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 11968 fract(dyC) > 0.0) { 11969 continue; 11970 } 11971 int idyC = int(dyC); 11972 11973 float dyValue = getDy(b, idyR, idyC, d); 11974 int maxPosValue = ${l} - int(getMaxPos(b, idyR, idyC, d)); 11975 11976 // Get the current value, check it against the value from the 11977 // position matrix. 11978 int curPosValue = wR * ${o} + wC; 11979 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 11980 11981 dotProd += dyValue * mask; 11982 } 11983 } 11984 setOutput(dotProd); 11985 } 11986 `}}class e3{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,r=e.strideHeight,s=e.strideWidth,a=e.dilationDepth,o=e.dilationHeight,i=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,u=e.effectiveFilterWidth,d=c-1-e.padInfo.front,p=l-1-e.padInfo.top,h=u-1-e.padInfo.left,m=c*l*u-1;this.userCode=` 11987 const ivec3 pads = ivec3(${d}, ${p}, ${h}); 11988 11989 void main() { 11990 ivec5 coords = getOutputCoords(); 11991 int batch = coords.x; 11992 int ch = coords.u; 11993 11994 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 11995 int dyDCorner = dyCorner.x; 11996 int dyRCorner = dyCorner.y; 11997 int dyCCorner = dyCorner.z; 11998 11999 // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get 12000 // dx(xD, xR, xC, ch). 12001 // ? = to be determined. : = across all values in that axis. 12002 float dotProd = 0.0; 12003 12004 for (int wD = 0; wD < ${c}; 12005 wD += ${a}) { 12006 float dyD = float(dyDCorner + wD) / ${t}.0; 12007 12008 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 12009 continue; 12010 } 12011 int idyD = int(dyD); 12012 12013 for (int wR = 0; wR < ${l}; 12014 wR += ${o}) { 12015 float dyR = float(dyRCorner + wR) / ${r}.0; 12016 12017 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 12018 fract(dyR) > 0.0) { 12019 continue; 12020 } 12021 int idyR = int(dyR); 12022 12023 for (int wC = 0; wC < ${u}; 12024 wC += ${i}) { 12025 float dyC = float(dyCCorner + wC) / ${s}.0; 12026 12027 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 12028 fract(dyC) > 0.0) { 12029 continue; 12030 } 12031 int idyC = int(dyC); 12032 12033 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 12034 int maxPosValue = ${m} - 12035 int(getMaxPos(batch, idyD, idyR, idyC, ch)); 12036 12037 // Get the current value, check it against the value from the 12038 // position matrix. 12039 int curPosValue = 12040 wD * ${l} * ${u} + 12041 wR * ${u} + wC; 12042 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 12043 12044 dotProd += dyValue * mask; 12045 } 12046 } 12047 } 12048 setOutput(dotProd); 12049 } 12050 `}}/** 12051 * @license 12052 * Copyright 2020 Google LLC. All Rights Reserved. 12053 * Licensed under the Apache License, Version 2.0 (the "License");
12054 * you may not use this file except in compliance with the License. 12055 * You may obtain a copy of the License at 12056 * 12057 * http://www.apache.org/licenses/LICENSE-2.0 12058 * 12059 * Unless required by applicable law or agreed to in writing, software 12060 * distributed under the License is distributed on an "AS IS" BASIS, 12061 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12062 * See the License for the specific language governing permissions and 12063 * limitations under the License. 12064 * ============================================================================= 12065 */function t3(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a}=e,o=a,{filterSize:i,strides:c,pad:l,dimRoundingMode:u}=r,d=[1,1,1],p=Ir(o.shape,i,c,d,l,u),h=new rh(p,"max",!0),m=t.runWebGLProgram(h,[o],o.dtype),g=new e3(p),y=t.runWebGLProgram(g,[s,m],o.dtype);return t.disposeIntermediateTensorInfo(m),y}const n3={kernelName:cm,backendName:"webgl",kernelFunc:t3};/** 12066 * @license 12067 * Copyright 2020 Google LLC. All Rights Reserved. 12068 * Licensed under the Apache License, Version 2.0 (the "License"); 12069 * you may not use this file except in compliance with the License. 12070 * You may obtain a copy of the License at 12071 * 12072 * http://www.apache.org/licenses/LICENSE-2.0 12073 * 12074 * Unless required by applicable law or agreed to in writing, software 12075 * distributed under the License is distributed on an "AS IS" BASIS, 12076 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12077 * See the License for the specific language governing permissions and 12078 * limitations under the License. 12079 * ============================================================================= 12080 */function r3(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a,output:o}=e,i=a;Po([a,o],"maxPoolGrad");const{filterSize:c,strides:l,pad:u,dimRoundingMode:d}=r,p=kn(i.shape,c,l,1,u,d),h=!0,m=new $o(p,"max",h),g=t.runWebGLProgram(m,[i],i.dtype),y=new JP(p),b=t.runWebGLProgram(y,[s,g],i.dtype);return t.disposeIntermediateTensorInfo(g),b}const s3={kernelName:um,backendName:"webgl",kernelFunc:r3};/** 12081 * @license 12082 * Copyright 2020 Google LLC. All Rights Reserved. 12083 * Licensed under the Apache License, Version 2.0 (the "License"); 12084 * you may not use this file except in compliance with the License. 12085 * You may obtain a copy of the License at 12086 * 12087 * http://www.apache.org/licenses/LICENSE-2.0 12088 * 12089 * Unless required by applicable law or agreed to in writing, software 12090 * distributed under the License is distributed on an "AS IS" BASIS, 12091 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12092 * See the License for the specific language governing permissions and 12093 * limitations under the License. 12094 * ============================================================================= 12095 */function a3(n,e,t,r){let s=new $o(t,"max",!1);const a=r.runWebGLProgram(s,[n],"float32");s=new $o(t,"max",!0,!0,e);const o=r.runWebGLProgram(s,[n],"float32");return[a,o]}/** 12096 * @license 12097 * Copyright 2020 Google LLC. All Rights Reserved. 12098 * Licensed under the Apache License, Version 2.0 (the "License"); 12099 * you may not use this file except in compliance with the License. 12100 * You may obtain a copy of the License at 12101 * 12102 * http://www.apache.org/licenses/LICENSE-2.0 12103 * 12104 * Unless required by applicable law or agreed to in writing, software 12105 * distributed under the License is distributed on an "AS IS" BASIS, 12106 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12107 * See the License for the specific language governing permissions and 12108 * limitations under the License. 12109 * ============================================================================= 12110 */const o3={kernelName:wd,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:r}=n,{filterSize:s,strides:a,pad:o,includeBatchInIndex:i}=e,c=t;N(r.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`);const l=[1,1];N(Kt(a,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${l}'`);const u=kn(r.shape,s,a,l,o),[d,p]=a3(r,i,u,c);return[d,p]}};/** 12111 * @license 12112 * Copyright 2020 Google LLC. All Rights Reserved. 12113 * Licensed under the Apache License, Version 2.0 (the "License");
12114 * you may not use this file except in compliance with the License. 12115 * You may obtain a copy of the License at 12116 * 12117 * http://www.apache.org/licenses/LICENSE-2.0 12118 * 12119 * Unless required by applicable law or agreed to in writing, software 12120 * distributed under the License is distributed on an "AS IS" BASIS, 12121 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12122 * See the License for the specific language governing permissions and 12123 * limitations under the License. 12124 * ============================================================================= 12125 */function i3(n,e,t,r){const s=H(e),o=H(n.shape)/s,i=te({inputs:{x:n},attrs:{shape:[o,s]},backend:r}),c=Gs(i,"float32","mean",r),l=te({inputs:{x:c},attrs:{shape:t},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(c),l}/** 12126 * @license 12127 * Copyright 2020 Google LLC. All Rights Reserved. 12128 * Licensed under the Apache License, Version 2.0 (the "License"); 12129 * you may not use this file except in compliance with the License. 12130 * You may obtain a copy of the License at 12131 * 12132 * http://www.apache.org/licenses/LICENSE-2.0 12133 * 12134 * Unless required by applicable law or agreed to in writing, software 12135 * distributed under the License is distributed on an "AS IS" BASIS, 12136 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12137 * See the License for the specific language governing permissions and 12138 * limitations under the License. 12139 * ============================================================================= 12140 */const u3={kernelName:du,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:r}=n,{keepDims:s,axis:a}=e,o=t,i=r.shape.length,c=ot(a,r.shape);let l=c;const u=Xt(l,i),d=u!=null,p=o.shouldExecuteOnCPU([r]),h=[];let m=r;if(d){if(p){const S=o.texData.get(m.dataId).values,T=new Array(i);for(let M=0;M<T.length;M++)T[M]=r.shape[u[M]];const O=eh(S,r.shape,r.dtype,u,T);m=o.makeTensorInfo(T,r.dtype);const L=o.texData.get(m.dataId);L.values=O}else m=tc(r,u,o);h.push(m),l=St(l.length,i)}ht("sum",l,i);const[g,y]=At(m.shape,l);let b=g;s&&(b=pt(g,c));const v=i3(m,y,b,o);for(const $ of h)o.disposeIntermediateTensorInfo($);return v}};/** 12141 * @license 12142 * Copyright 2020 Google LLC. All Rights Reserved. 12143 * Licensed under the Apache License, Version 2.0 (the "License"); 12144 * you may not use this file except in compliance with the License. 12145 * You may obtain a copy of the License at 12146 * 12147 * http://www.apache.org/licenses/LICENSE-2.0 12148 * 12149 * Unless required by applicable law or agreed to in writing, software 12150 * distributed under the License is distributed on an "AS IS" BASIS, 12151 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12152 * See the License for the specific language governing permissions and 12153 * limitations under the License. 12154 * ============================================================================= 12155 */function c3(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,keepDims:o}=r,i=s.shape.length,c=ot(a,s.shape);let l=c;const u=Xt(l,i);let d=s;u!=null&&(d=Vt({inputs:{x:s},backend:t,attrs:{perm:u}}),l=St(l.length,s.shape.length)),ht("min",l,i);const[p,h]=At(d.shape,l),m=H(h),g=te({inputs:{x:d},backend:t,attrs:{shape:[-1,m]}}),y=Gs(g,g.dtype,"min",t);let b;if(o){const v=pt(p,c);b=te({inputs:{x:y},backend:t,attrs:{shape:v}})}else b=te({inputs:{x:y},backend:t,attrs:{shape:p}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(y),u!=null&&t.disposeIntermediateTensorInfo(d),b}const l3={kernelName:pu,backendName:"webgl",kernelFunc:c3};/** 12156 * @license 12157 * Copyright 2020 Google LLC. All Rights Reserved. 12158 * Licensed under the Apache License, Version 2.0 (the "License"); 12159 * you may not use this file except in compliance with the License. 12160 * You may obtain a copy of the License at 12161 * 12162 * http://www.apache.org/licenses/LICENSE-2.0 12163 * 12164 * Unless required by applicable law or agreed to in writing, software 12165 * distributed under the License is distributed on an "AS IS" BASIS, 12166 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12167 * See the License for the specific language governing permissions and 12168 * limitations under the License. 12169 * ============================================================================= 12170 */const d3=th+` 12171 return min(a, b); 12172`,p3=` 12173 vec4 result = vec4(min(a, b)); 12174 bvec4 isNaNA = isnan(a); 12175 bvec4 isNaNB = isnan(b); 12176 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 12177 `+zs+` 12178 return result; 12179`,h3=Ct({opSnippet:d3,packedOpSnippet:p3,cpuKernelImpl:ZE}),f3={kernelName:vd,backendName:"webgl",kernelFunc:h3};/** 12180 * @license 12181 * Copyright 2020 Google LLC. All Rights Reserved. 12182 * Licensed under the Apache License, Version 2.0 (the "License");
12183 * you may not use this file except in compliance with the License. 12184 * You may obtain a copy of the License at 12185 * 12186 * http://www.apache.org/licenses/LICENSE-2.0 12187 * 12188 * Unless required by applicable law or agreed to in writing, software 12189 * distributed under the License is distributed on an "AS IS" BASIS, 12190 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12191 * See the License for the specific language governing permissions and 12192 * limitations under the License. 12193 * ============================================================================= 12194 */class m3{constructor(e,t,r){this.variableNames=["x"],this.outputShape=t.map((u,d)=>u[0]+e[d]+u[1]);const s=e.length,a=ze(s),o=t.map(u=>u[0]).join(","),i=t.map((u,d)=>u[0]+e[d]).join(","),c=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,s),l=r==="reflect"?0:1;if(s===1){this.userCode=` 12195 int start = ${o}; 12196 int end = ${i}; 12197 12198 void main() { 12199 int outC = getOutputCoords(); 12200 if (outC < start) { 12201 outC = start * 2 - outC - ${l}; 12202 } else if(outC >= end) { 12203 outC = (end - 1) * 2 - outC + ${l}; 12204 } 12205 setOutput(getX(outC - start)); 12206 } 12207 `;return}this.userCode=` 12208 ${a} start = ${a}(${o}); 12209 ${a} end = ${a}(${i}); 12210 12211 void main() { 12212 ${a} outC = getOutputCoords(); 12213 for (int i = 0; i < ${s}; i++) { 12214 if (outC[i] < start[i]) { 12215 outC[i] = start[i] * 2 - outC[i] - ${l}; 12216 } else if(outC[i] >= end[i]) { 12217 outC[i] = (end[i] - 1) * 2 - outC[i] + ${l}; 12218 } 12219 } 12220 ${a} coords = outC - start; 12221 setOutput(getX(${c})); 12222 } 12223 `}}/** 12224 * @license 12225 * Copyright 2020 Google LLC. All Rights Reserved. 12226 * Licensed under the Apache License, Version 2.0 (the "License"); 12227 * you may not use this file except in compliance with the License. 12228 * You may obtain a copy of the License at 12229 * 12230 * http://www.apache.org/licenses/LICENSE-2.0 12231 * 12232 * Unless required by applicable law or agreed to in writing, software 12233 * distributed under the License is distributed on an "AS IS" BASIS, 12234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12235 * See the License for the specific language governing permissions and 12236 * limitations under the License. 12237 * ============================================================================= 12238 */class g3{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((m,g)=>m[0]+e[g]+m[1]);const s=e.length,a=ze(s),o=t.map(m=>m[0]).join(","),i=t.map((m,g)=>m[0]+e[g]).join(","),c=Bt("rc",s),l=Bt("source",s),u=`${c[s-1]} < ${this.outputShape[s-1]}`,d=s===1?"source":`vec2(${l.slice(-2).join()})`,p=r==="reflect"?0:1;let h="";if(s===1){const m=` 12239 ${a} source = rc; 12240 if (source < start) { 12241 source = start * 2 - source - ${p}; 12242 } else if (source >= end) { 12243 source = (end - 1) * 2 - source + ${p}; 12244 } 12245 source -= start; 12246 `;h=` 12247 ${a} rc = outputLoc; 12248 ${m} 12249 result[0] = getChannel(getX(${l.join()}), ${d}); 12250 ${c[s-1]} += 1; 12251 if(${u}) { 12252 ${m} 12253 result[1] = getChannel(getX(${l.join()}), ${d}); 12254 } 12255 `}else{const m=` 12256 ${a} source = rc; 12257 ${a} lt = ${a}(lessThan(source, start)); 12258 ${a} gte = ${a}(greaterThanEqual(source, end)); 12259 ${a} orig = 1 - (lt + gte); 12260 source = orig * source + 12261 lt * (start * 2 - source - ${p}) + 12262 gte * ((end - 1) * 2 - source + ${p}); 12263 source -= start; 12264 `;h=` 12265 ${a} rc = outputLoc; 12266 ${m} 12267 result[0] = getChannel(getX(${l.join()}), ${d}); 12268 ${c[s-1]} += 1; 12269 if(${u}) { 12270 ${m} 12271 result[1] = getChannel(getX(${l.join()}), ${d}); 12272 } 12273 rc = outputLoc; 12274 ${c[s-2]} += 1; 12275 if(${c[s-2]} < ${this.outputShape[s-2]}) { 12276 ${m} 12277 result[2] = getChannel(getX(${l.join()}), ${d}); 12278 ${c[s-1]} += 1; 12279 if(${u}) { 12280 ${m} 12281 result[3] = getChannel(getX(${l.join()}), ${d}); 12282 } 12283 } 12284 `}this.userCode=` 12285 const ${a} start = ${a}(${o}); 12286 const ${a} end = ${a}(${i}); 12287 12288 void main() { 12289 ${a} outputLoc = getOutputCoords(); 12290 vec4 result = vec4(0.); 12291 ${h} 12292 setOutput(result); 12293 } 12294 `}}/** 12295 * @license 12296 * Copyright 2020 Google LLC. All Rights Reserved. 12297 * Licensed under the Apache License, Version 2.0 (the "License");
12298 * you may not use this file except in compliance with the License. 12299 * You may obtain a copy of the License at 12300 * 12301 * http://www.apache.org/licenses/LICENSE-2.0 12302 * 12303 * Unless required by applicable law or agreed to in writing, software 12304 * distributed under the License is distributed on an "AS IS" BASIS, 12305 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12306 * See the License for the specific language governing permissions and 12307 * limitations under the License. 12308 * ============================================================================= 12309 */const y3=({inputs:n,backend:e,attrs:t})=>{const{x:r}=n,{paddings:s,mode:a}=t,o=U().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new g3(r.shape,s,a):new m3(r.shape,s,a);return e.runWebGLProgram(o,[r],r.dtype)},b3={kernelName:hu,backendName:"webgl",kernelFunc:y3};/** 12310 * @license 12311 * Copyright 2020 Google LLC. All Rights Reserved. 12312 * Licensed under the Apache License, Version 2.0 (the "License"); 12313 * you may not use this file except in compliance with the License. 12314 * You may obtain a copy of the License at 12315 * 12316 * http://www.apache.org/licenses/LICENSE-2.0 12317 * 12318 * Unless required by applicable law or agreed to in writing, software 12319 * distributed under the License is distributed on an "AS IS" BASIS, 12320 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12321 * See the License for the specific language governing permissions and 12322 * limitations under the License. 12323 * ============================================================================= 12324 */const x3=`if (b == 0.0) return NAN; 12325 return mod(a, b);`,w3=` 12326 vec4 result = mod(a, b); 12327 bvec4 isNaN = equal(b, vec4(0.0)); 12328 `+zs+` 12329 return result; 12330`,v3=Ct({opSnippet:x3,packedOpSnippet:w3}),I3={kernelName:Id,backendName:"webgl",kernelFunc:v3};/** 12331 * @license 12332 * Copyright 2017 Google LLC. All Rights Reserved. 12333 * Licensed under the Apache License, Version 2.0 (the "License"); 12334 * you may not use this file except in compliance with the License. 12335 * You may obtain a copy of the License at 12336 * 12337 * http://www.apache.org/licenses/LICENSE-2.0 12338 * 12339 * Unless required by applicable law or agreed to in writing, software 12340 * distributed under the License is distributed on an "AS IS" BASIS, 12341 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12342 * See the License for the specific language governing permissions and 12343 * limitations under the License. 12344 * ============================================================================= 12345 */class $3{constructor(e,t,r){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,r],this.userCode=` 12346 void main() { 12347 ivec2 coords = getOutputCoords(); 12348 int batch = coords[0]; 12349 12350 float r = random(seed); 12351 float cdf = 0.0; 12352 12353 for (int i = 0; i < ${t-1}; i++) { 12354 cdf += getProbs(batch, i); 12355 12356 if (r < cdf) { 12357 setOutput(float(i)); 12358 return; 12359 } 12360 } 12361 12362 // If no other event happened, last event happened. 12363 setOutput(float(${t-1})); 12364 } 12365 `}}/** 12366 * @license 12367 * Copyright 2020 Google LLC. All Rights Reserved. 12368 * Licensed under the Apache License, Version 2.0 (the "License"); 12369 * you may not use this file except in compliance with the License. 12370 * You may obtain a copy of the License at 12371 * 12372 * http://www.apache.org/licenses/LICENSE-2.0 12373 * 12374 * Unless required by applicable law or agreed to in writing, software 12375 * distributed under the License is distributed on an "AS IS" BASIS, 12376 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12377 * See the License for the specific language governing permissions and 12378 * limitations under the License. 12379 * ============================================================================= 12380 */const S3=` 12381if (a == b) { 12382 return 1.0; 12383}; 12384return a / b;`,C3=` 12385 // vec4 one = vec4(equal(a, b)); 12386 // return one + (vec4(1.0) - one) * a / b; 12387 vec4 result = a / b; 12388 if(a.x == b.x) { 12389 result.x = 1.; 12390 } 12391 if(a.y == b.y) { 12392 result.y = 1.; 12393 } 12394 if(a.z == b.z) { 12395 result.z = 1.; 12396 } 12397 if(a.w == b.w) { 12398 result.w = 1.; 12399 } 12400 12401 return result; 12402`,xb=Ct({opSnippet:S3,packedOpSnippet:C3,checkOutOfBounds:!0}),_3={kernelName:ql,backendName:"webgl",kernelFunc:xb};/** 12403 * @license 12404 * Copyright 2020 Google LLC. All Rights Reserved. 12405 * Licensed under the Apache License, Version 2.0 (the "License");
12406 * you may not use this file except in compliance with the License. 12407 * You may obtain a copy of the License at 12408 * 12409 * http://www.apache.org/licenses/LICENSE-2.0 12410 * 12411 * Unless required by applicable law or agreed to in writing, software 12412 * distributed under the License is distributed on an "AS IS" BASIS, 12413 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12414 * See the License for the specific language governing permissions and 12415 * limitations under the License. 12416 * ============================================================================= 12417 */const vf="return a - b;",wb=Ct({opSnippet:vf,packedOpSnippet:vf,supportsComplex:!0,cpuKernelImpl:xR}),N3={kernelName:np,backendName:"webgl",kernelFunc:wb};/** 12418 * @license 12419 * Copyright 2020 Google LLC. All Rights Reserved. 12420 * Licensed under the Apache License, Version 2.0 (the "License"); 12421 * you may not use this file except in compliance with the License. 12422 * You may obtain a copy of the License at 12423 * 12424 * http://www.apache.org/licenses/LICENSE-2.0 12425 * 12426 * Unless required by applicable law or agreed to in writing, software 12427 * distributed under the License is distributed on an "AS IS" BASIS, 12428 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12429 * See the License for the specific language governing permissions and 12430 * limitations under the License. 12431 * ============================================================================= 12432 */function vb(n){const{inputs:e,backend:t,attrs:r}=n,{logits:s}=e,{dim:a}=r,o=ot([a],s.shape),i=bb({inputs:{x:s},backend:t,attrs:{reductionIndices:o,keepDims:!1}}),c=pt(i.shape,o),l=te({inputs:{x:i},backend:t,attrs:{shape:c}}),u=wb({inputs:{a:s,b:l},backend:t}),d=mb({inputs:{x:u},backend:t}),p=nc({inputs:{x:d},backend:t,attrs:{axis:o,keepDims:!1}}),h=te({inputs:{x:p},backend:t,attrs:{shape:c}}),m=xb({inputs:{a:d,b:h},backend:t});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(l),t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(h),m}const T3={kernelName:ku,backendName:"webgl",kernelFunc:vb};/** 12433 * @license 12434 * Copyright 2020 Google LLC. All Rights Reserved. 12435 * Licensed under the Apache License, Version 2.0 (the "License"); 12436 * you may not use this file except in compliance with the License. 12437 * You may obtain a copy of the License at 12438 * 12439 * http://www.apache.org/licenses/LICENSE-2.0 12440 * 12441 * Unless required by applicable law or agreed to in writing, software 12442 * distributed under the License is distributed on an "AS IS" BASIS, 12443 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12444 * See the License for the specific language governing permissions and 12445 * limitations under the License. 12446 * ============================================================================= 12447 */function k3(n){const{inputs:e,backend:t,attrs:r}=n,{logits:s}=e,{numSamples:a,seed:o,normalized:i}=r,c=i?s:vb({inputs:{logits:s},backend:t,attrs:{dim:s.shape.length-1}}),l=c.shape[0],u=c.shape[1],d=new $3(l,u,a),p=[[o]],h=t.runWebGLProgram(d,[c],"int32",p);return i||t.disposeIntermediateTensorInfo(c),h}const E3={kernelName:fu,backendName:"webgl",kernelFunc:k3};/** 12448 * @license 12449 * Copyright 2020 Google LLC. All Rights Reserved. 12450 * Licensed under the Apache License, Version 2.0 (the "License"); 12451 * you may not use this file except in compliance with the License. 12452 * You may obtain a copy of the License at 12453 * 12454 * http://www.apache.org/licenses/LICENSE-2.0 12455 * 12456 * Unless required by applicable law or agreed to in writing, software 12457 * distributed under the License is distributed on an "AS IS" BASIS, 12458 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12459 * See the License for the specific language governing permissions and 12460 * limitations under the License. 12461 * ============================================================================= 12462 */const R3=Rn+` 12463 return -x; 12464`,A3=` 12465 vec4 result = -x; 12466 bvec4 isNaN = isnan(x); 12467 12468 result.r = isNaN.r ? x.r : result.r; 12469 result.g = isNaN.g ? x.g : result.g; 12470 result.b = isNaN.b ? x.b : result.b; 12471 result.a = isNaN.a ? x.a : result.a; 12472 12473 return result; 12474`;function D3(n){const{inputs:e,backend:t}=n,{x:r}=e;if(t.shouldExecuteOnCPU([r])){const a=t.texData.get(r.dataId),[o,i]=eR(a.values,r.shape,r.dtype);return t.makeTensorInfo(i,r.dtype,o)}let s;return U().getBool("WEBGL_PACK_UNARY_OPERATIONS")?s=new Lr(r.shape,A3):s=new sr(r.shape,R3),t.runWebGLProgram(s,[r],r.dtype)}const O3={kernelName:Sd,backendName:"webgl",kernelFunc:D3};/** 12475 * @license 12476 * Copyright 2020 Google LLC. All Rights Reserved. 12477 * Licensed under the Apache License, Version 2.0 (the "License");
12478 * you may not use this file except in compliance with the License. 12479 * You may obtain a copy of the License at 12480 * 12481 * http://www.apache.org/licenses/LICENSE-2.0 12482 * 12483 * Unless required by applicable law or agreed to in writing, software 12484 * distributed under the License is distributed on an "AS IS" BASIS, 12485 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12486 * See the License for the specific language governing permissions and 12487 * limitations under the License. 12488 * ============================================================================= 12489 */const F3=zg;function P3(n){Un("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:c}=r,l=t.readSync(s.dataId),u=t.readSync(a.dataId),{selectedIndices:d}=F3(l,u,o,i,c);return t.makeTensorInfo([d.length],"int32",new Int32Array(d))}const L3={kernelName:mu,backendName:"webgl",kernelFunc:P3};/** 12490 * @license 12491 * Copyright 2020 Google LLC. All Rights Reserved. 12492 * Licensed under the Apache License, Version 2.0 (the "License"); 12493 * you may not use this file except in compliance with the License. 12494 * You may obtain a copy of the License at 12495 * 12496 * http://www.apache.org/licenses/LICENSE-2.0 12497 * 12498 * Unless required by applicable law or agreed to in writing, software 12499 * distributed under the License is distributed on an "AS IS" BASIS, 12500 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12501 * See the License for the specific language governing permissions and 12502 * limitations under the License. 12503 * ============================================================================= 12504 */const M3=Gg;function B3(n){Un("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:c,padToMaxOutputSize:l}=r,u=t.readSync(s.dataId),d=t.readSync(a.dataId),{selectedIndices:p,validOutputs:h}=M3(u,d,o,i,c,l);return[t.makeTensorInfo([p.length],"int32",new Int32Array(p)),t.makeTensorInfo([],"int32",new Int32Array([h]))]}const V3={kernelName:gu,backendName:"webgl",kernelFunc:B3};/** 12505 * @license 12506 * Copyright 2020 Google LLC. All Rights Reserved. 12507 * Licensed under the Apache License, Version 2.0 (the "License"); 12508 * you may not use this file except in compliance with the License. 12509 * You may obtain a copy of the License at 12510 * 12511 * http://www.apache.org/licenses/LICENSE-2.0 12512 * 12513 * Unless required by applicable law or agreed to in writing, software 12514 * distributed under the License is distributed on an "AS IS" BASIS, 12515 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12516 * See the License for the specific language governing permissions and 12517 * limitations under the License. 12518 * ============================================================================= 12519 */const W3=Hg;function U3(n){Un("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:c,softNmsSigma:l}=r,u=t.readSync(s.dataId),d=t.readSync(a.dataId),p=o,h=i,m=c,g=l,{selectedIndices:y,selectedScores:b}=W3(u,d,p,h,m,g);return[t.makeTensorInfo([y.length],"int32",new Int32Array(y)),t.makeTensorInfo([b.length],"float32",new Float32Array(b))]}const z3={kernelName:yu,backendName:"webgl",kernelFunc:U3};/** 12520 * @license 12521 * Copyright 2017 Google LLC. All Rights Reserved. 12522 * Licensed under the Apache License, Version 2.0 (the "License"); 12523 * you may not use this file except in compliance with the License. 12524 * You may obtain a copy of the License at 12525 * 12526 * http://www.apache.org/licenses/LICENSE-2.0 12527 * 12528 * Unless required by applicable law or agreed to in writing, software 12529 * distributed under the License is distributed on an "AS IS" BASIS, 12530 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12531 * See the License for the specific language governing permissions and 12532 * limitations under the License. 12533 * ============================================================================= 12534 */class G3{constructor(e,t,r,s){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=` 12535 void main() { 12536 ivec2 coords = getOutputCoords(); 12537 int index = round(getIndices(coords.x)); 12538 setOutput(mix(float(${s}), float(${r}), 12539 float(index == coords.y))); 12540 } 12541 `}}/** 12542 * @license 12543 * Copyright 2020 Google LLC. All Rights Reserved. 12544 * Licensed under the Apache License, Version 2.0 (the "License");
12545 * you may not use this file except in compliance with the License. 12546 * You may obtain a copy of the License at 12547 * 12548 * http://www.apache.org/licenses/LICENSE-2.0 12549 * 12550 * Unless required by applicable law or agreed to in writing, software 12551 * distributed under the License is distributed on an "AS IS" BASIS, 12552 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12553 * See the License for the specific language governing permissions and 12554 * limitations under the License. 12555 * ============================================================================= 12556 */const H3=n=>{const{inputs:e,backend:t,attrs:r}=n,{indices:s}=e,{dtype:a,depth:o,onValue:i,offValue:c}=r,l=H(s.shape),u=new G3(l,o,i,c),d=te({inputs:{x:s},backend:t,attrs:{shape:[l]}}),p=t.runWebGLProgram(u,[d],a);t.disposeIntermediateTensorInfo(d);const h=[...s.shape,o],m=te({inputs:{x:p},backend:t,attrs:{shape:h}});return t.disposeIntermediateTensorInfo(p),m},j3={kernelName:bu,backendName:"webgl",kernelFunc:H3};/** 12557 * @license 12558 * Copyright 2020 Google LLC. All Rights Reserved. 12559 * Licensed under the Apache License, Version 2.0 (the "License"); 12560 * you may not use this file except in compliance with the License. 12561 * You may obtain a copy of the License at 12562 * 12563 * http://www.apache.org/licenses/LICENSE-2.0 12564 * 12565 * Unless required by applicable law or agreed to in writing, software 12566 * distributed under the License is distributed on an "AS IS" BASIS, 12567 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12568 * See the License for the specific language governing permissions and 12569 * limitations under the License. 12570 * ============================================================================= 12571 */function Ri(n){const{inputs:e,backend:t}=n,{x:r}=e;if(r.dtype==="complex64"){const s=Mo({inputs:{input:r},backend:t}),a=Ri({inputs:{x:s},backend:t}),o=rc({inputs:{input:r},backend:t}),i=Ri({inputs:{x:o},backend:t}),c=Qr({inputs:{real:a,imag:i},backend:t});return t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),c}else return Bo({attrs:{shape:r.shape,dtype:r.dtype,value:r.dtype==="string"?"":0},backend:t})}const q3={kernelName:ip,backendName:"webgl",kernelFunc:Ri};/** 12572 * @license 12573 * Copyright 2020 Google LLC. All Rights Reserved. 12574 * Licensed under the Apache License, Version 2.0 (the "License"); 12575 * you may not use this file except in compliance with the License. 12576 * You may obtain a copy of the License at 12577 * 12578 * http://www.apache.org/licenses/LICENSE-2.0 12579 * 12580 * Unless required by applicable law or agreed to in writing, software 12581 * distributed under the License is distributed on an "AS IS" BASIS, 12582 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12583 * See the License for the specific language governing permissions and 12584 * limitations under the License. 12585 * ============================================================================= 12586 */function Ib(n){const{inputs:e,backend:t}=n,{x:r}=e;if(r.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(r.dtype==="complex64"){const s=Mo({inputs:{input:r},backend:t}),a=Ib({inputs:{x:s},backend:t}),o=rc({inputs:{input:r},backend:t}),i=Ri({inputs:{x:o},backend:t}),c=Qr({inputs:{real:a,imag:i},backend:t});return t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),c}else return Bo({attrs:{shape:r.shape,dtype:r.dtype,value:1},backend:t})}const K3={kernelName:_d,backendName:"webgl",kernelFunc:Ib};/** 12587 * @license 12588 * Copyright 2020 Google LLC. All Rights Reserved. 12589 * Licensed under the Apache License, Version 2.0 (the "License"); 12590 * you may not use this file except in compliance with the License. 12591 * You may obtain a copy of the License at 12592 * 12593 * http://www.apache.org/licenses/LICENSE-2.0 12594 * 12595 * Unless required by applicable law or agreed to in writing, software 12596 * distributed under the License is distributed on an "AS IS" BASIS, 12597 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12598 * See the License for the specific language governing permissions and 12599 * limitations under the License. 12600 * ============================================================================= 12601 */function X3(n){const{inputs:e,backend:t,attrs:r}=n,{axis:s}=r;if(e.length===1)return sl({inputs:{input:e[0]},backend:t,attrs:{dim:s}});const a=e[0].shape,o=e[0].dtype;e.forEach(u=>{sn(a,u.shape,"All tensors passed to stack must have matching shapes"),N(o===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const i=[],c=e.map(u=>{const d=sl({inputs:{input:u},backend:t,attrs:{dim:s}});return i.push(d),d}),l=ib({inputs:c,backend:t,attrs:{axis:s}});
vendor: 4,964 bytes, lines 12601-12698
12601return i.forEach(u=>t.disposeIntermediateTensorInfo(u)),l}const Y3={kernelName:Nd,backendName:"webgl",kernelFunc:X3};/** 12602 * @license 12603 * Copyright 2017 Google LLC. All Rights Reserved. 12604 * Licensed under the Apache License, Version 2.0 (the "License"); 12605 * you may not use this file except in compliance with the License. 12606 * You may obtain a copy of the License at 12607 * 12608 * http://www.apache.org/licenses/LICENSE-2.0 12609 * 12610 * Unless required by applicable law or agreed to in writing, software 12611 * distributed under the License is distributed on an "AS IS" BASIS, 12612 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12613 * See the License for the specific language governing permissions and 12614 * limitations under the License. 12615 * ============================================================================= 12616 */class Q3{constructor(e,t,r){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((l,u)=>l[0]+e[u]+l[1]);const s=e.length,a=ze(s),o=t.map(l=>l[0]).join(","),i=t.map((l,u)=>l[0]+e[u]).join(","),c=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,s);if(s===1){this.userCode=` 12617 int start = ${o}; 12618 int end = ${i}; 12619 12620 void main() { 12621 int outC = getOutputCoords(); 12622 if (outC < start || outC >= end) { 12623 setOutput(value); 12624 } else { 12625 setOutput(getX(outC - start)); 12626 } 12627 } 12628 `;return}this.userCode=` 12629 ${a} start = ${a}(${o}); 12630 ${a} end = ${a}(${i}); 12631 12632 void main() { 12633 ${a} outC = getOutputCoords(); 12634 if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { 12635 setOutput(value); 12636 } else { 12637 ${a} coords = outC - start; 12638 setOutput(getX(${c})); 12639 } 12640 } 12641 `}}/** 12642 * @license 12643 * Copyright 2019 Google LLC. All Rights Reserved. 12644 * Licensed under the Apache License, Version 2.0 (the "License"); 12645 * you may not use this file except in compliance with the License. 12646 * You may obtain a copy of the License at 12647 * 12648 * http://www.apache.org/licenses/LICENSE-2.0 12649 * 12650 * Unless required by applicable law or agreed to in writing, software 12651 * distributed under the License is distributed on an "AS IS" BASIS, 12652 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12653 * See the License for the specific language governing permissions and 12654 * limitations under the License. 12655 * ============================================================================= 12656 */class Z3{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((g,y)=>g[0]+e[y]+g[1]);const s=e.length,a=ze(s),o=t.map(g=>g[0]).join(","),i=t.map((g,y)=>g[0]+e[y]).join(","),c=Bt("rc",s),l=Bt("source",s),u=`${c[s-1]} < ${this.outputShape[s-1]}`,d=s===1?"source":`vec2(${l.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${c[s-1]} += 1; 12657 if(${u}) { 12658 `,s===1?"":`} 12659 rc = outputLoc; 12660 ${c[s-2]} += 1; 12661 if(${c[s-2]} < ${this.outputShape[s-2]}) {`,s===1?"":` ${c[s-1]} += 1; 12662 if(${u}) {`],h=s===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let m="";for(let g=0,y=s===1?2:4;g<y;g++)m+=` 12663 ${p[g]} 12664 if (${h}) { 12665 result[${g}] = float(value); 12666 } else { 12667 ${a} source = rc - start; 12668 result[${g}] = getChannel(getX(${l.join()}), ${d}); 12669 } 12670 `;m+=s===1?"} ":"}}",this.userCode=` 12671 const ${a} start = ${a}(${o}); 12672 const ${a} end = ${a}(${i}); 12673 12674 void main() { 12675 ${a} outputLoc = getOutputCoords(); 12676 vec4 result = vec4(0.); 12677 ${m} 12678 setOutput(result); 12679 } 12680 `}}/** 12681 * @license 12682 * Copyright 2020 Google LLC. All Rights Reserved. 12683 * Licensed under the Apache License, Version 2.0 (the "License"); 12684 * you may not use this file except in compliance with the License. 12685 * You may obtain a copy of the License at 12686 * 12687 * http://www.apache.org/licenses/LICENSE-2.0 12688 * 12689 * Unless required by applicable law or agreed to in writing, software 12690 * distributed under the License is distributed on an "AS IS" BASIS, 12691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12692 * See the License for the specific language governing permissions and 12693 * limitations under the License. 12694 * ============================================================================= 12695 */const $b=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{paddings:a,constantValue:o}=r;if(H(s.shape)===0){const l=a.map((u,d)=>u[0]+s.shape[d]+u[1]);return Bo({backend:t,attrs:{shape:l,value:o,dtype:s.dtype}})}const i=U().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Z3(s.shape,a,o):new Q3(s.shape,a,o),c=[[o]];return t.runWebGLProgram(i,[s],s.dtype,c)},J3={kernelName:xu,backendName:"webgl",kernelFunc:$b};/** 12696 * @license 12697 * Copyright 2020 Google LLC. All Rights Reserved. 12698 * Licensed under the Apache License, Version 2.0 (the "License");
12699 * you may not use this file except in compliance with the License. 12700 * You may obtain a copy of the License at 12701 * 12702 * http://www.apache.org/licenses/LICENSE-2.0 12703 * 12704 * Unless required by applicable law or agreed to in writing, software 12705 * distributed under the License is distributed on an "AS IS" BASIS, 12706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12707 * See the License for the specific language governing permissions and 12708 * limitations under the License. 12709 * ============================================================================= 12710 */const eL=` 12711 if(a < 0.0 && floor(b) < b){ 12712 return NAN; 12713 } 12714 if (b == 0.0) { 12715 return 1.0; 12716 } 12717 return (round(mod(b, 2.0)) != 1) ? 12718 pow(abs(a), b) : sign(a) * pow(abs(a), b); 12719`,tL=` 12720 // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. 12721 vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); 12722 vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); 12723 vec4 result = multiplier * pow(abs(a), b); 12724 12725 // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS 12726 bvec4 isExpZero = equal(b, vec4(0.0)); 12727 result.r = isExpZero.r ? 1.0 : result.r; 12728 result.g = isExpZero.g ? 1.0 : result.g; 12729 result.b = isExpZero.b ? 1.0 : result.b; 12730 result.a = isExpZero.a ? 1.0 : result.a; 12731 12732 bvec4 isNaN1 = lessThan(a, vec4(0.0)); 12733 bvec4 isNaN2 = lessThan(floor(b), b); 12734 bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w); 12735 `+zs+` 12736 return result; 12737`,nL=Ct({opSnippet:eL,packedOpSnippet:tL}),rL={kernelName:Td,backendName:"webgl",kernelFunc:nL};/** 12738 * @license 12739 * Copyright 2020 Google LLC. All Rights Reserved. 12740 * Licensed under the Apache License, Version 2.0 (the "License"); 12741 * you may not use this file except in compliance with the License. 12742 * You may obtain a copy of the License at 12743 * 12744 * http://www.apache.org/licenses/LICENSE-2.0 12745 * 12746 * Unless required by applicable law or agreed to in writing, software 12747 * distributed under the License is distributed on an "AS IS" BASIS, 12748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12749 * See the License for the specific language governing permissions and 12750 * limitations under the License. 12751 * ============================================================================= 12752 */function sL(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,keepDims:o}=r,i=s.shape.length,c=[],l=ot(a,s.shape);let u=l;const d=Xt(u,i);let p=s;d!=null&&(p=Vt({inputs:{x:s},backend:t,attrs:{perm:d}}),u=St(u.length,i),c.push(p)),ht("prod",u,i);let h;if(t.shouldExecuteOnCPU([p])){const m=t.texData.get(p.dataId).values,{outVals:g,outShape:y,outDtype:b}=nR(p.shape,p.dtype,m,u);h=t.makeTensorInfo(y,b,g)}else{const[m,g]=At(p.shape,u),y=H(g),b=te({inputs:{x:p},backend:t,attrs:{shape:[-1,y]}}),v=cp(s.dtype),$=Gs(b,v,"prod",t);h=te({inputs:{x:$},backend:t,attrs:{shape:m}}),c.push(b),c.push($)}if(o){c.push(h);const m=pt(h.shape,l);h=te({inputs:{x:h},backend:t,attrs:{shape:m}})}return c.forEach(m=>t.disposeIntermediateTensorInfo(m)),h}const aL={kernelName:vu,backendName:"webgl",kernelFunc:sL};/** 12753 * @license 12754 * Copyright 2022 Google LLC. All Rights Reserved. 12755 * Licensed under the Apache License, Version 2.0 (the "License"); 12756 * you may not use this file except in compliance with the License. 12757 * You may obtain a copy of the License at 12758 * 12759 * http://www.apache.org/licenses/LICENSE-2.0 12760 * 12761 * Unless required by applicable law or agreed to in writing, software 12762 * distributed under the License is distributed on an "AS IS" BASIS, 12763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12764 * See the License for the specific language governing permissions and 12765 * limitations under the License. 12766 * ============================================================================= 12767 */function oL(n){const{inputs:e,backend:t,attrs:r}=n,{paramsNestedSplits:s,paramsDenseValues:a,indices:o}=e,{outputRaggedRank:i}=r,c=s.map(b=>t.readSync(b.dataId)),l=s.map(b=>b.shape),u=t.readSync(a.dataId),d=t.readSync(o.dataId),[p,h,m]=rR(c,l,u,a.shape,a.dtype,d,o.shape,i),g=p.map(b=>t.makeTensorInfo([b.length],"int32",b)),y=t.makeTensorInfo(m,a.dtype,h);return g.concat([y])}const iL={kernelName:lm,backendName:"webgl",kernelFunc:oL};/** 12768 * @license 12769 * Copyright 2022 Google LLC. 12770 * Licensed under the Apache License, Version 2.0 (the "License");
12771 * you may not use this file except in compliance with the License. 12772 * You may obtain a copy of the License at 12773 * 12774 * http://www.apache.org/licenses/LICENSE-2.0 12775 * 12776 * Unless required by applicable law or agreed to in writing, software 12777 * distributed under the License is distributed on an "AS IS" BASIS, 12778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12779 * See the License for the specific language governing permissions and 12780 * limitations under the License. 12781 * ============================================================================= 12782 */function uL(n){const{inputs:e,backend:t}=n,{starts:r,limits:s,deltas:a}=e,o=t.readSync(r.dataId),i=t.readSync(s.dataId),c=t.readSync(a.dataId),[l,u]=sR(o,r.shape,r.dtype,i,s.shape,c,a.shape),d=t.makeTensorInfo([l.length],"int32",l),p=t.makeTensorInfo([u.length],r.dtype,u);return[d,p]}const cL={kernelName:dm,backendName:"webgl",kernelFunc:uL};/** 12783 * @license 12784 * Copyright 2022 Google LLC. All Rights Reserved. 12785 * Licensed under the Apache License, Version 2.0 (the "License"); 12786 * you may not use this file except in compliance with the License. 12787 * You may obtain a copy of the License at 12788 * 12789 * http://www.apache.org/licenses/LICENSE-2.0 12790 * 12791 * Unless required by applicable law or agreed to in writing, software 12792 * distributed under the License is distributed on an "AS IS" BASIS, 12793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12794 * See the License for the specific language governing permissions and 12795 * limitations under the License. 12796 * ============================================================================= 12797 */function lL(n){const{inputs:e,backend:t,attrs:r}=n,{shape:s,values:a,defaultValue:o,rowPartitionTensors:i}=e,{rowPartitionTypes:c}=r,l=t.readSync(s.dataId),u=t.readSync(a.dataId),d=t.readSync(o.dataId),p=i.map(y=>t.readSync(y.dataId)),h=i.map(y=>y.shape),[m,g]=aR(l,s.shape,u,a.shape,a.dtype,d,o.shape,p,h,c);return t.makeTensorInfo(m,a.dtype,g)}const dL={kernelName:pm,backendName:"webgl",kernelFunc:lL};/** 12798 * @license 12799 * Copyright 2020 Google LLC. All Rights Reserved. 12800 * Licensed under the Apache License, Version 2.0 (the "License"); 12801 * you may not use this file except in compliance with the License. 12802 * You may obtain a copy of the License at 12803 * 12804 * http://www.apache.org/licenses/LICENSE-2.0 12805 * 12806 * Unless required by applicable law or agreed to in writing, software 12807 * distributed under the License is distributed on an "AS IS" BASIS, 12808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12809 * See the License for the specific language governing permissions and 12810 * limitations under the License. 12811 * ============================================================================= 12812 */const Sb=n=>{const{backend:e,attrs:t}=n,{start:r,stop:s,step:a,dtype:o}=t,i=oR(r,s,a,o);return e.makeTensorInfo([i.length],o,i)},pL={kernelName:kd,backendName:"webgl",kernelFunc:Sb};/** 12813 * @license 12814 * Copyright 2020 Google LLC. All Rights Reserved. 12815 * Licensed under the Apache License, Version 2.0 (the "License"); 12816 * you may not use this file except in compliance with the License. 12817 * You may obtain a copy of the License at 12818 * 12819 * http://www.apache.org/licenses/LICENSE-2.0 12820 * 12821 * Unless required by applicable law or agreed to in writing, software 12822 * distributed under the License is distributed on an "AS IS" BASIS, 12823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12824 * See the License for the specific language governing permissions and 12825 * limitations under the License. 12826 * ============================================================================= 12827 */const hL="return 1.0 / x;",fL=De({opSnippet:hL}),mL={kernelName:Ed,backendName:"webgl",kernelFunc:fL};/** 12828 * @license 12829 * Copyright 2020 Google LLC. All Rights Reserved. 12830 * Licensed under the Apache License, Version 2.0 (the "License"); 12831 * you may not use this file except in compliance with the License. 12832 * You may obtain a copy of the License at 12833 * 12834 * http://www.apache.org/licenses/LICENSE-2.0 12835 * 12836 * Unless required by applicable law or agreed to in writing, software 12837 * distributed under the License is distributed on an "AS IS" BASIS, 12838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12839 * See the License for the specific language governing permissions and 12840 * limitations under the License. 12841 * ============================================================================= 12842 */const gL=Rn+` 12843 return (x < 0.0) ? 0.0 : x; 12844`,yL=` 12845 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 12846 bvec4 isNaN = isnan(x); 12847 12848 result.r = isNaN.r ? x.r : result.r; 12849 result.g = isNaN.g ? x.g : result.g; 12850 result.b = isNaN.b ? x.b : result.b; 12851 result.a = isNaN.a ? x.a : result.a; 12852 12853 return result; 12854`,bL=De({opSnippet:gL,packedOpSnippet:yL}),xL={kernelName:Rd,backendName:"webgl",kernelFunc:bL};/** 12855 * @license 12856 * Copyright 2020 Google LLC. All Rights Reserved. 12857 * Licensed under the Apache License, Version 2.0 (the "License");
12858 * you may not use this file except in compliance with the License. 12859 * You may obtain a copy of the License at 12860 * 12861 * http://www.apache.org/licenses/LICENSE-2.0 12862 * 12863 * Unless required by applicable law or agreed to in writing, software 12864 * distributed under the License is distributed on an "AS IS" BASIS, 12865 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12866 * See the License for the specific language governing permissions and 12867 * limitations under the License. 12868 * ============================================================================= 12869 */const wL=Rn+` 12870 return (x < 0.0) ? 0.0 : min(6.0, x); 12871`,vL=` 12872 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 12873 bvec4 isNaN = isnan(x); 12874 12875 result.r = isNaN.r ? x.r : result.r; 12876 result.g = isNaN.g ? x.g : result.g; 12877 result.b = isNaN.b ? x.b : result.b; 12878 result.a = isNaN.a ? x.a : result.a; 12879 12880 return result; 12881`,IL=De({opSnippet:wL,packedOpSnippet:vL}),$L={kernelName:Fd,backendName:"webgl",kernelFunc:IL};/** 12882 * @license 12883 * Copyright 2017 Google LLC. All Rights Reserved. 12884 * Licensed under the Apache License, Version 2.0 (the "License"); 12885 * you may not use this file except in compliance with the License. 12886 * You may obtain a copy of the License at 12887 * 12888 * http://www.apache.org/licenses/LICENSE-2.0 12889 * 12890 * Unless required by applicable law or agreed to in writing, software 12891 * distributed under the License is distributed on an "AS IS" BASIS, 12892 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12893 * See the License for the specific language governing permissions and 12894 * limitations under the License. 12895 * ============================================================================= 12896 */class SL{constructor(e,t,r,s,a){this.variableNames=["A"],this.outputShape=[];const[o,i,c,l]=e;this.outputShape=[o,t,r,l];const u=[s&&t>1?i-1:i,s&&r>1?c-1:c],d=[s&&t>1?t-1:t,s&&r>1?r-1:r];let p;a?p="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":p="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 12897 const vec2 effectiveInputOverOutputRatioRC = vec2( 12898 ${u[0]/d[0]}, 12899 ${u[1]/d[1]}); 12900 const vec2 inputShapeRC = vec2(${i}.0, ${c}.0); 12901 12902 void main() { 12903 ivec4 coords = getOutputCoords(); 12904 int b = coords[0]; 12905 int d = coords[3]; 12906 ivec2 yRC = coords.yz; 12907 12908 // Fractional source index. 12909 vec2 sourceFracIndexRC = ${p}; 12910 12911 // Compute the four integer indices. 12912 ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0))); 12913 ivec2 sourceCeilRC = ivec2( 12914 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 12915 12916 float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d); 12917 float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d); 12918 float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d); 12919 float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d); 12920 12921 vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC); 12922 12923 float top = topLeft + (topRight - topLeft) * fracRC.y; 12924 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y; 12925 float newValue = top + (bottom - top) * fracRC.x; 12926 12927 setOutput(newValue); 12928 } 12929 `}}/** 12930 * @license 12931 * Copyright 2019 Google LLC. All Rights Reserved. 12932 * Licensed under the Apache License, Version 2.0 (the "License"); 12933 * you may not use this file except in compliance with the License. 12934 * You may obtain a copy of the License at 12935 * 12936 * http://www.apache.org/licenses/LICENSE-2.0 12937 * 12938 * Unless required by applicable law or agreed to in writing, software 12939 * distributed under the License is distributed on an "AS IS" BASIS, 12940 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12941 * See the License for the specific language governing permissions and 12942 * limitations under the License. 12943 * ============================================================================= 12944 */class CL{constructor(e,t,r,s,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,i,c,l]=e;this.outputShape=[o,t,r,l];const u=[s&&t>1?i-1:i,s&&r>1?c-1:c],d=[s&&t>1?t-1:t,s&&r>1?r-1:r];let p;a?p="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":p="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 12945 const vec3 effectiveInputOverOutputRatioRC = vec3( 12946 ${u[0]/d[0]}, 12947 ${u[1]/d[1]}, 12948 ${u[1]/d[1]}); 12949 const vec3 inputShapeRC = vec3(${i}.0, ${c}.0, 12950 ${c}.0); 12951 12952 float getAValue(int b, int r, int c, int d) { 12953 return getChannel(getA(b, r, c, d), vec2(c, d)); 12954 } 12955 12956 void main() { 12957 ivec4 coords = getOutputCoords(); 12958 int b = coords[0]; 12959 int d = coords[3]; 12960 // Calculate values for next column in yRC.z. 12961 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 12962 12963 // Fractional source index. 12964 vec3 sourceFracIndexRC = ${p}; 12965 12966 // Compute the four integer indices. 12967 ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0))); 12968 ivec3 sourceCeilRC = ivec3( 12969 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 12970 12971 // Should we calculate next column and row elements in 2x2 packed cell. 12972 bool hasNextCol = d < ${l-1}; 12973 bool hasNextRow = coords.z < ${r-1}
vendor: 2,018 bytes, lines 12973-13021
12973; 12974 12975 // In parallel, construct four corners for all four components in 12976 // packed 2x2 cell. 12977 vec4 topLeft = vec4( 12978 getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d), 12979 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1) 12980 : 0.0, 12981 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d) 12982 : 0.0, 12983 (hasNextRow && hasNextCol) ? 12984 getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0); 12985 12986 vec4 bottomLeft = vec4( 12987 getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d), 12988 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1) 12989 : 0.0, 12990 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d) 12991 : 0.0, 12992 (hasNextRow && hasNextCol) ? 12993 getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0); 12994 12995 vec4 topRight = vec4( 12996 getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d), 12997 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1) 12998 : 0.0, 12999 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d) 13000 : 0.0, 13001 (hasNextRow && hasNextCol) ? 13002 getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0); 13003 13004 vec4 bottomRight = vec4( 13005 getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d), 13006 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1) 13007 : 0.0, 13008 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d) 13009 : 0.0, 13010 (hasNextRow && hasNextCol) ? 13011 getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0); 13012 13013 vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC); 13014 13015 vec4 top = mix(topLeft, topRight, fracRC.yyzz); 13016 vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz); 13017 vec4 newValue = mix(top, bottom, fracRC.x); 13018 13019 setOutput(newValue); 13020 } 13021 `}
vendor: 4,806 bytes, lines 13021-13135
13021}/** 13022 * @license 13023 * Copyright 2020 Google LLC. All Rights Reserved. 13024 * Licensed under the Apache License, Version 2.0 (the "License"); 13025 * you may not use this file except in compliance with the License. 13026 * You may obtain a copy of the License at 13027 * 13028 * http://www.apache.org/licenses/LICENSE-2.0 13029 * 13030 * Unless required by applicable law or agreed to in writing, software 13031 * distributed under the License is distributed on an "AS IS" BASIS, 13032 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13033 * See the License for the specific language governing permissions and 13034 * limitations under the License. 13035 * ============================================================================= 13036 */function _L(n){const{inputs:e,backend:t,attrs:r}=n,{images:s}=e,{alignCorners:a,halfPixelCenters:o,size:i}=r,[c,l]=i,u=U().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new CL(s.shape,c,l,a,o):new SL(s.shape,c,l,a,o);return t.runWebGLProgram(u,[s],"float32")}const NL={kernelName:$u,backendName:"webgl",kernelFunc:_L};/** 13037 * @license 13038 * Copyright 2018 Google LLC. All Rights Reserved. 13039 * Licensed under the Apache License, Version 2.0 (the "License"); 13040 * you may not use this file except in compliance with the License. 13041 * You may obtain a copy of the License at 13042 * 13043 * http://www.apache.org/licenses/LICENSE-2.0 13044 * 13045 * Unless required by applicable law or agreed to in writing, software 13046 * distributed under the License is distributed on an "AS IS" BASIS, 13047 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13048 * See the License for the specific language governing permissions and 13049 * limitations under the License. 13050 * ============================================================================= 13051 */class TL{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,s,a]=t,[,o,i]=e,c=[r&&o>1?s-1:s,r&&i>1?a-1:a],l=[r&&o>1?o-1:o,r&&i>1?i-1:i],u=c[0]/l[0],d=c[1]/l[1],p=1/u,h=1/d,m=Math.ceil(p)*2+2,g=Math.ceil(h)*2+2;this.userCode=` 13052 void main() { 13053 ivec4 coords = getOutputCoords(); 13054 int b = coords[0]; 13055 int d = coords[3]; 13056 int r = coords[1]; 13057 int c = coords[2]; 13058 13059 float accumulator = 0.0; 13060 13061 const float heightScale = float(${u}); 13062 const float widthScale = float(${d}); 13063 13064 const float invHeightScale = float(${p}); 13065 const float invWidthScale = float(${h}); 13066 13067 const int winHeight = int(${m}); 13068 const int winWidth = int(${g}); 13069 13070 // Compute bounds for where in dy we will look 13071 float startRLerp = floor(float(r) * invHeightScale); 13072 int startDyR = int(startRLerp - float(winHeight / 2)); 13073 13074 float startCLerp = floor(float(c) * invWidthScale); 13075 int startDyC = int(startCLerp - float(winWidth / 2)); 13076 13077 // Loop over dy 13078 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 13079 int dyR = dyROffset + startDyR; 13080 13081 // Guard against the window exceeding the bounds of dy 13082 if (dyR < 0 || dyR >= ${o}) { 13083 continue; 13084 } 13085 13086 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 13087 int dyC = dyCOffset + startDyC; 13088 13089 // Guard against the window exceeding the bounds of dy 13090 if (dyC < 0 || dyC >= ${i}) { 13091 continue; 13092 } 13093 13094 float dxR = float(dyR) * heightScale; 13095 int topDxRIndex = int(floor(dxR)); 13096 int bottomDxRIndex = int(min(ceil(dxR), ${s-1}.0)); 13097 float dxRLerp = dxR - float(topDxRIndex); 13098 float inverseDxRLerp = 1.0 - dxRLerp; 13099 13100 float dxC = float(dyC) * widthScale; 13101 int leftDxCIndex = int(floor(dxC)); 13102 int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0)); 13103 float dxCLerp = dxC - float(leftDxCIndex); 13104 float inverseDxCLerp = 1.0 - dxCLerp; 13105 13106 if (r == topDxRIndex && c == leftDxCIndex) { 13107 // topLeft 13108 accumulator += 13109 getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp; 13110 } 13111 13112 if (r == topDxRIndex && c == rightDxCIndex) { 13113 // topRight 13114 accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp; 13115 } 13116 13117 if (r == bottomDxRIndex && c == leftDxCIndex) { 13118 // bottomLeft 13119 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp; 13120 } 13121 13122 if (r == bottomDxRIndex && c == rightDxCIndex) { 13123 // bottomRight 13124 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp; 13125 } 13126 } 13127 } 13128 // End loop over dy 13129 13130 setOutput(accumulator); 13131 } 13132 `}}/** 13133 * @license 13134 * Copyright 2020 Google LLC. All Rights Reserved. 13135 * Licensed under the Apache License, Version 2.0 (the "License");
13136 * you may not use this file except in compliance with the License. 13137 * You may obtain a copy of the License at 13138 * 13139 * http://www.apache.org/licenses/LICENSE-2.0 13140 * 13141 * Unless required by applicable law or agreed to in writing, software 13142 * distributed under the License is distributed on an "AS IS" BASIS, 13143 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13144 * See the License for the specific language governing permissions and 13145 * limitations under the License. 13146 * ============================================================================= 13147 */function kL(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:a}=e,{alignCorners:o}=r,i=new TL(a.shape,s.shape,o);return t.runWebGLProgram(i,[a],a.dtype)}const EL={kernelName:Od,backendName:"webgl",kernelFunc:kL};/** 13148 * @license 13149 * Copyright 2018 Google LLC. All Rights Reserved. 13150 * Licensed under the Apache License, Version 2.0 (the "License"); 13151 * you may not use this file except in compliance with the License. 13152 * You may obtain a copy of the License at 13153 * 13154 * http://www.apache.org/licenses/LICENSE-2.0 13155 * 13156 * Unless required by applicable law or agreed to in writing, software 13157 * distributed under the License is distributed on an "AS IS" BASIS, 13158 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13159 * See the License for the specific language governing permissions and 13160 * limitations under the License. 13161 * ============================================================================= 13162 */class RL{constructor(e,t,r,s,a){this.variableNames=["A"],this.outputShape=[];const[o,i,c,l]=e;this.outputShape=[o,t,r,l];const u=[s&&t>1?i-1:i,s&&r>1?c-1:c],d=[s&&t>1?t-1:t,s&&r>1?r-1:r],p=s?"0.5":"0.0";let h;a?h="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":h="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 13163 const vec2 effectiveInputOverOutputRatioRC = vec2( 13164 ${u[0]/d[0]}, 13165 ${u[1]/d[1]}); 13166 const vec2 inputShapeRC = vec2(${i}.0, ${c}.0); 13167 13168 void main() { 13169 ivec4 coords = getOutputCoords(); 13170 int b = coords[0]; 13171 int d = coords[3]; 13172 ivec2 yRC = coords.yz; 13173 13174 // Fractional source index. 13175 vec2 sourceFracIndexRC = ${h}; 13176 13177 // Compute the coordinators of nearest neighbor point. 13178 ivec2 sourceNearestRC = ivec2( 13179 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p}))); 13180 float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d); 13181 13182 setOutput(newValue); 13183 } 13184 `}}/** 13185 * @license 13186 * Copyright 2019 Google LLC. All Rights Reserved. 13187 * Licensed under the Apache License, Version 2.0 (the "License"); 13188 * you may not use this file except in compliance with the License. 13189 * You may obtain a copy of the License at 13190 * 13191 * http://www.apache.org/licenses/LICENSE-2.0 13192 * 13193 * Unless required by applicable law or agreed to in writing, software 13194 * distributed under the License is distributed on an "AS IS" BASIS, 13195 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13196 * See the License for the specific language governing permissions and 13197 * limitations under the License. 13198 * ============================================================================= 13199 */class AL{constructor(e,t,r,s,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,i,c,l]=e;this.outputShape=[o,t,r,l];const u=[s&&t>1?i-1:i,s&&r>1?c-1:c],d=[s&&t>1?t-1:t,s&&r>1?r-1:r],p=s?"0.5":"0.0";let h;a?h="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":h="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` 13200 const vec3 effectiveInputOverOutputRatioRC = vec3( 13201 ${u[0]/d[0]}, 13202 ${u[1]/d[1]}, 13203 ${u[1]/d[1]}); 13204 const vec3 inputShapeRC = vec3(${i}.0, ${c}.0, 13205 ${c}.0); 13206 13207 float getAValue(int b, int r, int c, int d) { 13208 return getChannel(getA(b, r, c, d), vec2(c, d)); 13209 } 13210 13211 void main() { 13212 ivec4 coords = getOutputCoords(); 13213 int b = coords[0]; 13214 int d = coords[3]; 13215 // Calculate values for next column in yRC.z. 13216 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 13217 13218 // Fractional source index. 13219 vec3 sourceFracIndexRC = ${h}; 13220 13221 // Compute the coordinators of nearest neighbor point. 13222 ivec3 sourceNearestRC = ivec3( 13223 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p}))); 13224 13225 // Should we calculate next column and row elements in 2x2 packed cell. 13226 bool hasNextCol = d < ${l-1}; 13227 bool hasNextRow = coords.z < ${r-1}; 13228 13229 vec4 newValue = vec4(
13230 getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d), 13231 hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1) 13232 : 0.0, 13233 hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d) 13234 : 0.0, 13235 (hasNextRow && hasNextCol) ? 13236 getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0); 13237 13238 setOutput(newValue); 13239 } 13240 `}}/** 13241 * @license 13242 * Copyright 2020 Google LLC. All Rights Reserved. 13243 * Licensed under the Apache License, Version 2.0 (the "License"); 13244 * you may not use this file except in compliance with the License. 13245 * You may obtain a copy of the License at 13246 * 13247 * http://www.apache.org/licenses/LICENSE-2.0 13248 * 13249 * Unless required by applicable law or agreed to in writing, software 13250 * distributed under the License is distributed on an "AS IS" BASIS, 13251 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13252 * See the License for the specific language governing permissions and 13253 * limitations under the License. 13254 * ============================================================================= 13255 */function DL(n){const{inputs:e,backend:t,attrs:r}=n,{images:s}=e,{alignCorners:a,halfPixelCenters:o,size:i}=r,[c,l]=i,u=U().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new AL(s.shape,c,l,a,o):new RL(s.shape,c,l,a,o);return t.runWebGLProgram(u,[s],s.dtype)}const OL={kernelName:Iu,backendName:"webgl",kernelFunc:DL};/** 13256 * @license 13257 * Copyright 2018 Google LLC. All Rights Reserved. 13258 * Licensed under the Apache License, Version 2.0 (the "License"); 13259 * you may not use this file except in compliance with the License. 13260 * You may obtain a copy of the License at 13261 * 13262 * http://www.apache.org/licenses/LICENSE-2.0 13263 * 13264 * Unless required by applicable law or agreed to in writing, software 13265 * distributed under the License is distributed on an "AS IS" BASIS, 13266 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13267 * See the License for the specific language governing permissions and 13268 * limitations under the License. 13269 * ============================================================================= 13270 */class FL{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,s,a]=t,[,o,i]=e,c=[r&&o>1?s-1:s,r&&i>1?a-1:a],l=[r&&o>1?o-1:o,r&&i>1?i-1:i],u=c[0]/l[0],d=c[1]/l[1],p=1/u,h=1/d,m=Math.ceil(p)*2+2,g=Math.ceil(h)*2+2;this.userCode=` 13271 void main() { 13272 ivec4 coords = getOutputCoords(); 13273 int b = coords[0]; 13274 int d = coords[3]; 13275 int r = coords[1]; 13276 int c = coords[2]; 13277 13278 float accumulator = 0.0; 13279 13280 const float heightScale = float(${u}); 13281 const float widthScale = float(${d}); 13282 13283 const float invHeightScale = float(${p}); 13284 const float invWidthScale = float(${h}); 13285 13286 const int winHeight = int(${m}); 13287 const int winWidth = int(${g}); 13288 13289 // Compute bounds for where in dy we will look 13290 float startRLerp = floor(float(r) * invHeightScale); 13291 int startDyR = int(floor(startRLerp - float(winHeight / 2))); 13292 13293 float startCLerp = floor(float(c) * invWidthScale); 13294 int startDyC = int(floor(startCLerp - float(winWidth / 2))); 13295 13296 // Loop over dy 13297 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 13298 int dyR = dyROffset + startDyR; 13299 13300 // Guard against the window exceeding the bounds of dy 13301 if (dyR < 0 || dyR >= ${o}) { 13302 continue; 13303 } 13304 13305 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 13306 int dyC = dyCOffset + startDyC; 13307 13308 // Guard against the window exceeding the bounds of dy 13309 if (dyC < 0 || dyC >= ${i}) { 13310 continue; 13311 } 13312 13313 float sourceFracRow =
13314 float(${c[0]}) * 13315 (float(dyR) / float(${l[0]})); 13316 13317 float sourceFracCol = 13318 float(${c[1]}) * 13319 (float(dyC) / float(${l[1]})); 13320 13321 int sourceNearestRow = int(min( 13322 float(int(${s}) - 1), 13323 ${r} ? float(round(sourceFracRow)) : 13324 float(floor(sourceFracRow)))); 13325 13326 int sourceNearestCol = int(min( 13327 float(int(${a}) - 1), 13328 ${r} ? float(round(sourceFracCol)) : 13329 float(floor(sourceFracCol)))); 13330 13331 if (r == sourceNearestRow && c == sourceNearestCol) { 13332 accumulator += getDy(b, dyR, dyC, d); 13333 } 13334 } 13335 } 13336 // End loop over dy 13337 13338 setOutput(accumulator); 13339 } 13340 `}}/** 13341 * @license 13342 * Copyright 2020 Google LLC. All Rights Reserved. 13343 * Licensed under the Apache License, Version 2.0 (the "License"); 13344 * you may not use this file except in compliance with the License. 13345 * You may obtain a copy of the License at 13346 * 13347 * http://www.apache.org/licenses/LICENSE-2.0 13348 * 13349 * Unless required by applicable law or agreed to in writing, software 13350 * distributed under the License is distributed on an "AS IS" BASIS, 13351 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13352 * See the License for the specific language governing permissions and 13353 * limitations under the License. 13354 * ============================================================================= 13355 */function PL(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:a}=e,{alignCorners:o}=r,i=new FL(a.shape,s.shape,o);return t.runWebGLProgram(i,[a],a.dtype)}const LL={kernelName:Dd,backendName:"webgl",kernelFunc:PL};/** 13356 * @license 13357 * Copyright 2017 Google LLC. All Rights Reserved. 13358 * Licensed under the Apache License, Version 2.0 (the "License"); 13359 * you may not use this file except in compliance with the License. 13360 * You may obtain a copy of the License at 13361 * 13362 * http://www.apache.org/licenses/LICENSE-2.0 13363 * 13364 * Unless required by applicable law or agreed to in writing, software 13365 * distributed under the License is distributed on an "AS IS" BASIS, 13366 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13367 * See the License for the specific language governing permissions and 13368 * limitations under the License. 13369 * ============================================================================= 13370 */class ML{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=` 13371 void main() { 13372 int coord = getOutputCoords(); 13373 setOutput(getX(${e[0]} - coord - 1)); 13374 } 13375 `;return}const s=i=>t.indexOf(i)!==-1&&e[i]!==1?`${e[i]} - coords[${i}] - 1`:`coords[${i}]`,a=e.map((i,c)=>s(c)).join(","),o=ze(r);this.userCode=` 13376 void main() { 13377 ${o} coords = getOutputCoords(); 13378 setOutput(getX(${a})); 13379 } 13380 `}}/** 13381 * @license 13382 * Copyright 2019 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 */class BL{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 s=Bt("rc",r),a=`${s[r-1]} + 1 < ${this.outputShape[r-1]}`,o=`${s[r-2]} + 1 < ${this.outputShape[r-2]}`,i=ze(r);r===1?this.userCode=` 13396 void main(){ 13397 int rc = getOutputCoords(); 13398 vec4 result = vec4(0.); 13399 result.r = getChannel(getX(${e[0]} - rc - 1), 13400 ${e[0]} - rc - 1); 13401 if(${a}){ 13402 result.g = getChannel(getX(${e[0]} - (rc + 1) - 1), 13403 ${e[0]} - (rc + 1) - 1); 13404 } 13405 setOutput(result); 13406 } 13407 `:this.userCode=` 13408 void main() { 13409 ${i} rc = getOutputCoords(); 13410 vec4 result = vec4(0.); 13411 result.r = ${c(s.slice())}; 13412 if(${a}){ 13413 result.g = ${l(s.slice())}; 13414 } 13415 if(${o}) { 13416 result.b = ${u(s.slice())}; 13417 if(${a}) { 13418 result.a = ${d(s.slice())}; 13419 } 13420 } 13421 setOutput(result); 13422 } 13423 `;function c(m){return p(m)}function l(m){return m[r-1]="("+m[r-1]+" + 1)",p(m)}function u(m){return m[r-2]="("+m[r-2]+" + 1)",p(m)}function d(m){return m[r-1]="("+m[r-1]+" + 1)",m[r-2]="("+m[r-2]+" + 1)",p(m)}function p(m){const g=e.map((v,$)=>h($,m)),y=g.join(","),b=g.slice(-2).join(",");return`getChannel(getX(${y}), vec2(${b}))`}function h(m,g){return t.indexOf(m)!==-1&&e[m]!==1?`${e[m]} - ${g[m]} - 1`:`${g[m]}`}}}/** 13424 * @license 13425 * Copyright 2020 Google LLC. All Rights Reserved. 13426 * Licensed under the Apache License, Version 2.0 (the "License");
13427 * you may not use this file except in compliance with the License. 13428 * You may obtain a copy of the License at 13429 * 13430 * http://www.apache.org/licenses/LICENSE-2.0 13431 * 13432 * Unless required by applicable law or agreed to in writing, software 13433 * distributed under the License is distributed on an "AS IS" BASIS, 13434 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13435 * See the License for the specific language governing permissions and 13436 * limitations under the License. 13437 * ============================================================================= 13438 */function VL(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{dims:a}=r,o=s.shape.length,i=ot(a,s.shape);if(o===0)return rn({inputs:{x:s},backend:t});const c=U().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new BL(s.shape,i):new ML(s.shape,i);return t.runWebGLProgram(c,[s],s.dtype)}const WL={kernelName:Su,backendName:"webgl",kernelFunc:VL};/** 13439 * @license 13440 * Copyright 2020 Google LLC. All Rights Reserved. 13441 * Licensed under the Apache License, Version 2.0 (the "License"); 13442 * you may not use this file except in compliance with the License. 13443 * You may obtain a copy of the License at 13444 * 13445 * http://www.apache.org/licenses/LICENSE-2.0 13446 * 13447 * Unless required by applicable law or agreed to in writing, software 13448 * distributed under the License is distributed on an "AS IS" BASIS, 13449 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13450 * See the License for the specific language governing permissions and 13451 * limitations under the License. 13452 * ============================================================================= 13453 */class UL{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const r=e[1],s=e[2];this.outputShape=e;let a="";typeof t=="number"?a=`float outputValue = ${t.toFixed(2)};`:a=` 13454 vec3 fill = vec3(${t.join(",")}); 13455 float outputValue = fill[coords[3]];`,this.userCode=` 13456 void main() { 13457 ivec4 coords = getOutputCoords(); 13458 int x = coords[2]; 13459 int y = coords[1]; 13460 float coordXFloat = (float(x) - params[0]) * params[3] - 13461 (float(y) - params[1]) * params[2]; 13462 float coordYFloat = (float(x) - params[0]) * params[2] + 13463 (float(y) - params[1]) * params[3];
13464 int coordX = int(round(coordXFloat + params[0])); 13465 int coordY = int(round(coordYFloat + params[1])); 13466 ${a} 13467 if(coordX >= 0 && coordX < ${s} && coordY >= 0 && coordY < ${r}) { 13468 outputValue = getImage(coords[0], coordY, coordX, coords[3]); 13469 } 13470 setOutput(outputValue); 13471 } 13472 `}}/** 13473 * @license 13474 * Copyright 2020 Google LLC. All Rights Reserved. 13475 * Licensed under the Apache License, Version 2.0 (the "License"); 13476 * you may not use this file except in compliance with the License. 13477 * You may obtain a copy of the License at 13478 * 13479 * http://www.apache.org/licenses/LICENSE-2.0 13480 * 13481 * Unless required by applicable law or agreed to in writing, software 13482 * distributed under the License is distributed on an "AS IS" BASIS, 13483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13484 * See the License for the specific language governing permissions and 13485 * limitations under the License. 13486 * ============================================================================= 13487 */const zL={kernelName:Pu,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:r}=n,{radians:s,fillValue:a,center:o}=e,i=t,c=new UL(r.shape,a),[l,u]=Dp(o,r.shape[1],r.shape[2]),d=[[l,u,Math.sin(s),Math.cos(s)]];return i.runWebGLProgram(c,[r],r.dtype,d)}};/** 13488 * @license 13489 * Copyright 2020 Google LLC. All Rights Reserved. 13490 * Licensed under the Apache License, Version 2.0 (the "License"); 13491 * you may not use this file except in compliance with the License. 13492 * You may obtain a copy of the License at 13493 * 13494 * http://www.apache.org/licenses/LICENSE-2.0 13495 * 13496 * Unless required by applicable law or agreed to in writing, software 13497 * distributed under the License is distributed on an "AS IS" BASIS, 13498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13499 * See the License for the specific language governing permissions and 13500 * limitations under the License. 13501 * ============================================================================= 13502 */const GL=` 13503 // OpenGL ES does not support round function. 13504 // The algorithm is based on banker's rounding. 13505 float base = floor(x); 13506 if ((x - base) < 0.5) { 13507 return floor(x); 13508 } else if ((x - base) > 0.5) { 13509 return ceil(x); 13510 } else { 13511 if (mod(base, 2.0) == 0.0) { 13512 return base; 13513 } else { 13514 return base + 1.0; 13515 } 13516 } 13517`,HL=De({opSnippet:GL}),jL={kernelName:Pd,backendName:"webgl",kernelFunc:HL};/** 13518 * @license 13519 * Copyright 2020 Google LLC. All Rights Reserved. 13520 * Licensed under the Apache License, Version 2.0 (the "License"); 13521 * you may not use this file except in compliance with the License. 13522 * You may obtain a copy of the License at 13523 * 13524 * http://www.apache.org/licenses/LICENSE-2.0 13525 * 13526 * Unless required by applicable law or agreed to in writing, software 13527 * distributed under the License is distributed on an "AS IS" BASIS, 13528 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13529 * See the License for the specific language governing permissions and 13530 * limitations under the License. 13531 * ============================================================================= 13532 */const qL="return inversesqrt(x);",KL=De({opSnippet:qL,cpuKernelImpl:iR}),XL={kernelName:Ld,backendName:"webgl",kernelFunc:KL};/** 13533 * @license 13534 * Copyright 2018 Google LLC. All Rights Reserved. 13535 * Licensed under the Apache License, Version 2.0 (the "License"); 13536 * you may not use this file except in compliance with the License. 13537 * You may obtain a copy of the License at 13538 * 13539 * http://www.apache.org/licenses/LICENSE-2.0 13540 * 13541 * Unless required by applicable law or agreed to in writing, software 13542 * distributed under the License is distributed on an "AS IS" BASIS, 13543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13544 * See the License for the specific language governing permissions and 13545 * limitations under the License. 13546 * ============================================================================= 13547 */class sh{constructor(e,t,r,s,a,o,i=!0,c=!1){this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;const l=ze(a.length),u=ze(o.length);let d="";r===1?d="i":r===2&&(d="i, j");const p=`getIndices(${d})`;let h="";s===1?h="i":s===2&&(h="i, coords[1]");const m=`getUpdates(${h})`;let g="";c&&(g="coords[0], coords[1]");const y=`getDefaultValue(${g})`,b=t>1?"strides[j]":"strides";this.userCode=` 13548 ${l} strides = ${l}(${a}); 13549 13550 void main() { 13551 ${u} coords = getOutputCoords(); 13552 float sum = 0.0; 13553 bool found = false;
13554 for (int i = 0; i < ${e}; i++) { 13555 int flattenedIndex = 0; 13556 for (int j = 0; j < ${t}; j++) { 13557 int index = round(${p}); 13558 flattenedIndex += index * ${b}; 13559 } 13560 if (flattenedIndex == coords[0]) { 13561 sum += ${m}; 13562 found = true; 13563 } 13564 } 13565 setOutput(mix(${y}, sum, float(found))); 13566 } 13567 `}}/** 13568 * @license 13569 * Copyright 2023 Google LLC. 13570 * Licensed under the Apache License, Version 2.0 (the "License"); 13571 * you may not use this file except in compliance with the License. 13572 * You may obtain a copy of the License at 13573 * 13574 * http://www.apache.org/licenses/LICENSE-2.0 13575 * 13576 * Unless required by applicable law or agreed to in writing, software 13577 * distributed under the License is distributed on an "AS IS" BASIS, 13578 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13579 * See the License for the specific language governing permissions and 13580 * limitations under the License. 13581 * ============================================================================= 13582 */class YL{constructor(e,t,r,s,a,o,i=!0,c=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=o;const l=ze(a.length),u=ze(o.length);let d="";r===1?d="i":r===2&&(d="i, j");const p=`getIndices(${d})`;let h="";s===1?h="i":s===2&&(h="i, coords[1]");const m=`getUpdates(${h})`;let g="";c&&(g="coords[0], coords[1]");const y=`getDefaultValue(${g})`,b=t>1?"strides[j]":"strides",v=t>1?"strides[j + 1]":"strides";this.userCode=` 13583 ${l} strides = ${l}(${a}); 13584 13585 void main() { 13586 ${u} coords = getOutputCoords(); 13587 vec4 sum = vec4(0.); 13588 vec4 found = vec4(0.); 13589 for (int i = 0; i < ${e}; i+=2) { 13590 ivec2 flattenedIndex = ivec2(0); 13591 for (int j = 0; j < ${t}; j+=2) { 13592 ivec4 index = round(${p}); 13593 flattenedIndex += index.xz * ${b}; 13594 if (j + 1 < ${t}) { 13595 flattenedIndex += index.yw * ${v}; 13596 } 13597 } 13598 if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] || 13599 flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) { 13600 vec4 updVals = ${m}; 13601 if (flattenedIndex[0] == coords[0]) { 13602 sum.xy += updVals.xy; 13603 found.xy = vec2(1.); 13604 } else if (flattenedIndex[0] == coords[0] + 1) { 13605 sum.zw += updVals.xy; 13606 found.zw = vec2(1.); 13607 } 13608 if (flattenedIndex[1] == coords[0]) { 13609 sum.xy += updVals.zw; 13610 found.xy = vec2(1.); 13611 } else if (flattenedIndex[1] == coords[0] + 1) { 13612 sum.zw += updVals.zw; 13613 found.zw = vec2(1.); 13614 } 13615 } 13616 } 13617 setOutput(mix(${y}, sum, found)); 13618 } 13619 `}}/** 13620 * @license 13621 * Copyright 2020 Google LLC. All Rights Reserved. 13622 * Licensed under the Apache License, Version 2.0 (the "License"); 13623 * you may not use this file except in compliance with the License. 13624 * You may obtain a copy of the License at 13625 * 13626 * http://www.apache.org/licenses/LICENSE-2.0 13627 * 13628 * Unless required by applicable law or agreed to in writing, software 13629 * distributed under the License is distributed on an "AS IS" BASIS, 13630 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13631 * See the License for the specific language governing permissions and 13632 * limitations under the License. 13633 * ============================================================================= 13634 */function QL(n){const{inputs:e,backend:t,attrs:r}=n,{indices:s,updates:a}=e,{shape:o}=r,{sliceRank:i,numUpdates:c,sliceSize:l,strides:u,outputSize:d}=Ms(a,s,o),p=[d/l,l];if(d===0)return t.makeTensorInfo(o,s.dtype);const h=te({inputs:{x:s},backend:t,attrs:{shape:[c,i]}}),m=te({inputs:{x:a},backend:t,attrs:{shape:[c,l]}}),g=t.makeTensorInfo([],"float32",new Float32Array([0]));let y;U().getBool("WEBGL_PACK")?y=new YL(c,i,h.shape.length,m.shape.length,u,p):y=new sh(c,i,h.shape.length,m.shape.length,u,p);const b=t.runWebGLProgram(y,[m,h,g],m.dtype),v=te({inputs:{x:b},backend:t,attrs:{shape:o}});
vendor: 4,268 bytes, lines 13634-13717
13634return t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(b),t.disposeIntermediateTensorInfo(g),v}const ZL={kernelName:Cu,backendName:"webgl",kernelFunc:QL};/** 13635 * @license 13636 * Copyright 2022 Google LLC. All Rights Reserved. 13637 * Licensed under the Apache License, Version 2.0 (the "License"); 13638 * you may not use this file except in compliance with the License. 13639 * You may obtain a copy of the License at 13640 * 13641 * http://www.apache.org/licenses/LICENSE-2.0 13642 * 13643 * Unless required by applicable law or agreed to in writing, software 13644 * distributed under the License is distributed on an "AS IS" BASIS, 13645 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13646 * See the License for the specific language governing permissions and 13647 * limitations under the License. 13648 * ============================================================================= 13649 */class JL{constructor(e,t,r,s){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,r];const a="while (left < right) {",o=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=U().getNumber("WEBGL_VERSION")===2?a:o,c=s==="left"?"<":"<=";this.userCode=` 13650 int findBound(int batch, float value) { 13651 int left = 0; 13652 int right = numInputs; 13653 int mid; 13654 ${i} 13655 mid = (left + right) / 2; 13656 if (getSortedSequence(batch, mid) ${c} value) { 13657 left = mid + 1; 13658 } else { 13659 right = mid; 13660 } 13661 } 13662 return right; 13663 } 13664 13665 void main() { 13666 ivec2 coords = getOutputCoords(); 13667 int batch = coords[0]; 13668 int valueIndex = coords[1]; 13669 13670 float value = getValues(batch, valueIndex); 13671 13672 setOutput(float(findBound(batch, value))); 13673 } 13674 `}}/** 13675 * @license 13676 * Copyright 2022 Google LLC. All Rights Reserved. 13677 * Licensed under the Apache License, Version 2.0 (the "License"); 13678 * you may not use this file except in compliance with the License. 13679 * You may obtain a copy of the License at 13680 * 13681 * http://www.apache.org/licenses/LICENSE-2.0 13682 * 13683 * Unless required by applicable law or agreed to in writing, software 13684 * distributed under the License is distributed on an "AS IS" BASIS, 13685 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13686 * See the License for the specific language governing permissions and 13687 * limitations under the License. 13688 * ============================================================================= 13689 */function eM(n){const{inputs:e,backend:t,attrs:r}=n,{sortedSequence:s,values:a}=e,{side:o}=r,i=new JL(s.shape[0],s.shape[1],a.shape[1],o),c=[[s.shape[1]]];return t.runWebGLProgram(i,[s,a],"int32",c)}const tM={kernelName:Nu,backendName:"webgl",kernelFunc:eM};/** 13690 * @license 13691 * Copyright 2017 Google LLC. All Rights Reserved. 13692 * Licensed under the Apache License, Version 2.0 (the "License"); 13693 * you may not use this file except in compliance with the License. 13694 * You may obtain a copy of the License at 13695 * 13696 * http://www.apache.org/licenses/LICENSE-2.0 13697 * 13698 * Unless required by applicable law or agreed to in writing, software 13699 * distributed under the License is distributed on an "AS IS" BASIS, 13700 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13701 * See the License for the specific language governing permissions and 13702 * limitations under the License. 13703 * ============================================================================= 13704 */class nM{constructor(e,t,r){this.variableNames=["c","a","b"],this.outputShape=t;let s,a;if(r>4)throw Error(`Where for rank ${r} is not yet supported`);if(r===1)a="resRC",s="resRC";else{const i=["resRC.x","resRC.y","resRC.z","resRC.w"],c=[],l=[];for(let u=0;u<t.length;u++)l.push(`${i[u]}`),u<e&&c.push(`${i[u]}`);s=c.join(),a=l.join()}const o=ze(r);this.userCode=` 13705 void main() { 13706 ${o} resRC = getOutputCoords(); 13707 float cVal = getC(${s}); 13708 if (cVal >= 1.0) { 13709 setOutput(getA(${a})); 13710 } else { 13711 setOutput(getB(${a})); 13712 } 13713 } 13714 `}}/** 13715 * @license 13716 * Copyright 2020 Google LLC. All Rights Reserved. 13717 * Licensed under the Apache License, Version 2.0 (the "License");
13718 * you may not use this file except in compliance with the License. 13719 * You may obtain a copy of the License at 13720 * 13721 * http://www.apache.org/licenses/LICENSE-2.0 13722 * 13723 * Unless required by applicable law or agreed to in writing, software 13724 * distributed under the License is distributed on an "AS IS" BASIS, 13725 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13726 * See the License for the specific language governing permissions and 13727 * limitations under the License. 13728 * ============================================================================= 13729 */function rM(n){const{inputs:e,backend:t}=n,{condition:r,t:s,e:a}=e,o=new nM(r.shape.length,s.shape,s.shape.length);return t.runWebGLProgram(o,[r,s,a],ir(s.dtype,a.dtype))}const sM={kernelName:Md,backendName:"webgl",kernelFunc:rM};/** 13730 * @license 13731 * Copyright 2020 Google LLC. All Rights Reserved. 13732 * Licensed under the Apache License, Version 2.0 (the "License"); 13733 * you may not use this file except in compliance with the License. 13734 * You may obtain a copy of the License at 13735 * 13736 * http://www.apache.org/licenses/LICENSE-2.0 13737 * 13738 * Unless required by applicable law or agreed to in writing, software 13739 * distributed under the License is distributed on an "AS IS" BASIS, 13740 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13741 * See the License for the specific language governing permissions and 13742 * limitations under the License. 13743 * ============================================================================= 13744 */const aM=` 13745 // Stable and Attracting Fixed Point (0, 1) for Normalized Weights. 13746 // see: https://arxiv.org/abs/1706.02515 13747 float scaleAlpha = ${py}; 13748 float scale = ${hy}; 13749 return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); 13750`,oM=De({opSnippet:aM}),iM={kernelName:Bd,backendName:"webgl",kernelFunc:oM};/** 13751 * @license 13752 * Copyright 2020 Google LLC. All Rights Reserved. 13753 * Licensed under the Apache License, Version 2.0 (the "License"); 13754 * you may not use this file except in compliance with the License. 13755 * You may obtain a copy of the License at 13756 * 13757 * http://www.apache.org/licenses/LICENSE-2.0 13758 * 13759 * Unless required by applicable law or agreed to in writing, software 13760 * distributed under the License is distributed on an "AS IS" BASIS, 13761 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13762 * See the License for the specific language governing permissions and 13763 * limitations under the License. 13764 * ============================================================================= 13765 */const uM=Ma+` 13766 return 1.0 / (1.0 + exp(-1.0 * x)); 13767`,cM=` 13768 vec4 result = 1.0 / (1.0 + exp(-1.0 * x)); 13769 bvec4 isNaN = isnan(x); 13770 13771 result.r = isNaN.r ? x.r : result.r; 13772 result.g = isNaN.g ? x.g : result.g; 13773 result.b = isNaN.b ? x.b : result.b; 13774 result.a = isNaN.a ? x.a : result.a; 13775 13776 return result; 13777`,lM=De({opSnippet:uM,packedOpSnippet:cM,cpuKernelImpl:cR}),dM={kernelName:Gd,backendName:"webgl",kernelFunc:lM};/** 13778 * @license 13779 * Copyright 2020 Google LLC. All Rights Reserved. 13780 * Licensed under the Apache License, Version 2.0 (the "License"); 13781 * you may not use this file except in compliance with the License. 13782 * You may obtain a copy of the License at 13783 * 13784 * http://www.apache.org/licenses/LICENSE-2.0 13785 * 13786 * Unless required by applicable law or agreed to in writing, software 13787 * distributed under the License is distributed on an "AS IS" BASIS, 13788 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13789 * See the License for the specific language governing permissions and 13790 * limitations under the License. 13791 * ============================================================================= 13792 */const pM=` 13793 if (isnan(x)) { return 0.0; } 13794 return sign(x); 13795`,hM=De({opSnippet:pM}),fM={kernelName:zd,backendName:"webgl",kernelFunc:hM};/** 13796 * @license 13797 * Copyright 2020 Google LLC. All Rights Reserved. 13798 * Licensed under the Apache License, Version 2.0 (the "License"); 13799 * you may not use this file except in compliance with the License. 13800 * You may obtain a copy of the License at 13801 * 13802 * http://www.apache.org/licenses/LICENSE-2.0 13803 * 13804 * Unless required by applicable law or agreed to in writing, softw
13804are 13805 * distributed under the License is distributed on an "AS IS" BASIS, 13806 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13807 * See the License for the specific language governing permissions and 13808 * limitations under the License. 13809 * ============================================================================= 13810 */const mM=Ma+` 13811 return sin(x); 13812`,gM=` 13813 vec4 result = sin(x); 13814 bvec4 isNaN = isnan(x); 13815 ${zs} 13816 return result; 13817`,yM=De({opSnippet:mM,packedOpSnippet:gM}),bM={kernelName:Wd,backendName:"webgl",kernelFunc:yM};/** 13818 * @license 13819 * Copyright 2020 Google LLC. All Rights Reserved. 13820 * Licensed under the Apache License, Version 2.0 (the "License"); 13821 * you may not use this file except in compliance with the License. 13822 * You may obtain a copy of the License at 13823 * 13824 * http://www.apache.org/licenses/LICENSE-2.0 13825 * 13826 * Unless required by applicable law or agreed to in writing, software 13827 * distributed under the License is distributed on an "AS IS" BASIS, 13828 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13829 * See the License for the specific language governing permissions and 13830 * limitations under the License. 13831 * ============================================================================= 13832 */const xM=` 13833 float e2x = exp(x); 13834 return (e2x - 1.0 / e2x) / 2.0; 13835`,wM=De({opSnippet:xM}),vM={kernelName:Ud,backendName:"webgl",kernelFunc:wM};/** 13836 * @license 13837 * Copyright 2020 Google LLC. All Rights Reserved. 13838 * Licensed under the Apache License, Version 2.0 (the "License"); 13839 * you may not use this file except in compliance with the License. 13840 * You may obtain a copy of the License at 13841 * 13842 * http://www.apache.org/licenses/LICENSE-2.0 13843 * 13844 * Unless required by applicable law or agreed to in writing, software 13845 * distributed under the License is distributed on an "AS IS" BASIS, 13846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13847 * See the License for the specific language governing permissions and 13848 * limitations under the License. 13849 * ============================================================================= 13850 */const IM=` 13851 float epsilon = 1.1920928955078125e-7; 13852 float threshold = log(epsilon) + 2.0; 13853 13854 bool too_large = x > -threshold; 13855 bool too_small = x < threshold; 13856 13857 float result; 13858 float exp_x = exp(x); 13859 13860 if (too_large){ 13861 result = x; 13862 } 13863 else if (too_small){ 13864 result = exp_x; 13865 } 13866 else{ 13867 result = log(exp_x + 1.0); 13868 } 13869 return result; 13870`,$M=De({opSnippet:IM}),SM={kernelName:Hd,backendName:"webgl",kernelFunc:$M};/** 13871 * @license 13872 * Copyright 2020 Google LLC. All Rights Reserved. 13873 * Licensed under the Apache License, Version 2.0 (the "License"); 13874 * you may not use this file except in compliance with the License. 13875 * You may obtain a copy of the License at 13876 * 13877 * http://www.apache.org/licenses/LICENSE-2.0 13878 * 13879 * Unless required by applicable law or agreed to in writing, software 13880 * distributed under the License is distributed on an "AS IS" BASIS, 13881 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13882 * See the License for the specific language governing permissions and 13883 * limitations under the License. 13884 * ============================================================================= 13885 */const CM=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockShape:a,paddings:o}=r;N(s.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const i=a.reduce((b,v)=>b*v),c=[[0,0]];c.push(...o);for(let b=1+a.length;b<s.shape.length;++b)c.push([0,0]);const l=[],u=$b({inputs:{x:s},backend:t,attrs:{paddings:c,constantValue:0}}),d=Ao(u.shape,a,i,!1),p=Do(d.length,a.length,!1),h=Oo(u.shape,a,i,!1),m=te({inputs:{x:u},backend:t,attrs:{shape:d}}),g=Vt({inputs:{x:m},backend:t,attrs:{perm:p}}),y=te({inputs:{x:g},backend:t,attrs:{shape:h}});return l.push(u),l.push(m),l.push(g),l.forEach(b=>t.disposeIntermediateTensorInfo(b)),y},_M={kernelName:qd,backendName:"webgl",kernelFunc:CM};/** 13886 * @license 13887 * Copyright 2021 Google LLC. All Rights Reserved. 13888 * Licensed under the Apache License, Version 2.0 (the "License"); 13889 * you may not use this file except in compliance with the License. 13890 * You may obtain a copy of the License at 13891 * 13892 * http://www.apache.org/licenses/LICENSE-2.0 13893 * 13894 * Unless required by applicable law or agreed to in writing, softw
13894are 13895 * distributed under the License is distributed on an "AS IS" BASIS, 13896 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13897 * See the License for the specific language governing permissions and 13898 * limitations under the License. 13899 * ============================================================================= 13900 */function NM(n){const{inputs:e,backend:t}=n,{indices:r,values:s,denseShape:a,defaultValue:o}=e;if(a.shape.length!==1)throw new Error(`Dense shape must be a vector, saw: 13901 ${a.shape}`);if(r.shape.length!==2)throw new Error(`Indices must be a matrix, saw: 13902 ${r.shape}`);if(s.shape.length!==1)throw new Error(`Values must be a vector, saw: 13903 ${s.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw: 13904 ${o.shape}`);const i=t.readSync(r.dataId),c=t.readSync(s.dataId),l=t.readSync(a.dataId),u=t.readSync(o.dataId)[0],[d,p,h,m,g]=dR(i,r.shape,r.dtype,c,s.dtype,l,u);return[t.makeTensorInfo(p,r.dtype,d),t.makeTensorInfo([p[0]],s.dtype,h),t.makeTensorInfo([m.length],"bool",new Uint8Array(m.map(y=>Number(y)))),t.makeTensorInfo([g.length],r.dtype,new Int32Array(g))]}const TM={kernelName:Xd,backendName:"webgl",kernelFunc:NM};/** 13905 * @license 13906 * Copyright 2021 Google LLC. All Rights Reserved. 13907 * Licensed under the Apache License, Version 2.0 (the "License"); 13908 * you may not use this file except in compliance with the License. 13909 * You may obtain a copy of the License at 13910 * 13911 * http://www.apache.org/licenses/LICENSE-2.0 13912 * 13913 * Unless required by applicable law or agreed to in writing, software 13914 * distributed under the License is distributed on an "AS IS" BASIS, 13915 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13916 * See the License for the specific language governing permissions and 13917 * limitations under the License. 13918 * ============================================================================= 13919 */function kM(n){const{inputs:e,backend:t}=n,{inputIndices:r,inputShape:s,newShape:a}=e;if(r.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(s.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${s.shape}`);if(a.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${a.shape}`);const o=Array.from(t.readSync(s.dataId)),i=t.readSync(r.dataId),c=Array.from(t.readSync(a.dataId)),[l,u,d]=pR(i,r.shape,r.dtype,o,c);return[t.makeTensorInfo(u,r.dtype,l),t.makeTensorInfo([d.length],a.dtype,new Int32Array(d))]}const EM={kernelName:Eu,backendName:"webgl",kernelFunc:kM};/** 13920 * @license 13921 * Copyright 2021 Google LLC. All Rights Reserved. 13922 * Licensed under the Apache License, Version 2.0 (the "License"); 13923 * you may not use this file except in compliance with the License. 13924 * You may obtain a copy of the License at 13925 * 13926 * http://www.apache.org/licenses/LICENSE-2.0 13927 * 13928 * Unless required by applicable law or agreed to in writing, software 13929 * distributed under the License is distributed on an "AS IS" BASIS, 13930 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13931 * See the License for the specific language governing permissions and 13932 * limitations under the License. 13933 * ============================================================================= 13934 */function RM(n){const{inputs:e,backend:t}=n,{data:r,indices:s,segmentIds:a}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape 13935 ${s.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape 13936 ${a.shape}`);const o=t.readSync(r.dataId),i=t.readSync(s.dataId),c=t.readSync(a.dataId),[l,u]=Ky(o,r.shape,r.dtype,i,c,!0);return t.makeTensorInfo(u,r.dtype,l)}const AM={kernelName:Yd,backendName:"webgl",kernelFunc:RM};/** 13937 * @license 13938 * Copyright 2021 Google LLC. All Rights Reserved. 13939 * Licensed under the Apache License, Version 2.0 (the "License"); 13940 * you may not use this file except in compliance with the License. 13941 * You may obtain a copy of the License at 13942 * 13943 * http://www.apache.org/licenses/LICENSE-2.0 13944 * 13945 * Unless required by applicable law or agreed to in writing, softw
vendor: 4,283 bytes, lines 13945-14001
13945are 13946 * distributed under the License is distributed on an "AS IS" BASIS, 13947 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13948 * See the License for the specific language governing permissions and 13949 * limitations under the License. 13950 * ============================================================================= 13951 */function DM(n){const{inputs:e,backend:t}=n,{data:r,indices:s,segmentIds:a}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape 13952 ${s.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape 13953 ${a.shape}`);const o=t.readSync(r.dataId),i=t.readSync(s.dataId),c=t.readSync(a.dataId),[l,u]=Ky(o,r.shape,r.dtype,i,c);return t.makeTensorInfo(u,r.dtype,l)}const OM={kernelName:Qd,backendName:"webgl",kernelFunc:DM};/** 13954 * @license 13955 * Copyright 2020 Google LLC. All Rights Reserved. 13956 * Licensed under the Apache License, Version 2.0 (the "License"); 13957 * you may not use this file except in compliance with the License. 13958 * You may obtain a copy of the License at 13959 * 13960 * http://www.apache.org/licenses/LICENSE-2.0 13961 * 13962 * Unless required by applicable law or agreed to in writing, software 13963 * distributed under the License is distributed on an "AS IS" BASIS, 13964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13965 * See the License for the specific language governing permissions and 13966 * limitations under the License. 13967 * ============================================================================= 13968 */function FM(n){const{inputs:e,backend:t,attrs:r}=n,{sparseIndices:s,sparseValues:a,defaultValue:o}=e,{outputShape:i}=r,{sliceRank:c,numUpdates:l,sliceSize:u,strides:d,outputSize:p}=Ms(a,s,i),h=!1;if(a.dtype==="string"){const b=t.bufferSync(s),v=t.bufferSync(a),$=Ia(t.readSync(o.dataId)[0]),S=uR(b,v,i,p,u,l,c,d,$,h);return t.makeTensorInfo(i,S.dtype,S.values)}const m=new sh(l,c,s.shape.length,a.shape.length,d,[p,1],h),g=t.runWebGLProgram(m,[a,s,o],a.dtype),y=te({inputs:{x:g},backend:t,attrs:{shape:i}});return t.disposeIntermediateTensorInfo(g),y}const PM={kernelName:Ru,backendName:"webgl",kernelFunc:FM};/** 13969 * @license 13970 * Copyright 2020 Google LLC. All Rights Reserved. 13971 * Licensed under the Apache License, Version 2.0 (the "License"); 13972 * you may not use this file except in compliance with the License. 13973 * You may obtain a copy of the License at 13974 * 13975 * http://www.apache.org/licenses/LICENSE-2.0 13976 * 13977 * Unless required by applicable law or agreed to in writing, software 13978 * distributed under the License is distributed on an "AS IS" BASIS, 13979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13980 * See the License for the specific language governing permissions and 13981 * limitations under the License. 13982 * ============================================================================= 13983 */function LM(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{numOrSizeSplits:a,axis:o}=r,i=ot(o,s.shape)[0],c=Pp(s,a,i),l=s.shape.length,u=new Array(l).fill(0),d=s.shape.slice();return c.map(p=>{const h=[...d];h[i]=p;const m=Ba({inputs:{x:s},backend:t,attrs:{begin:u,size:h}});return u[i]+=p,m})}const MM={kernelName:Kd,backendName:"webgl",kernelFunc:LM};/** 13984 * @license 13985 * Copyright 2020 Google LLC. All Rights Reserved. 13986 * Licensed under the Apache License, Version 2.0 (the "License"); 13987 * you may not use this file except in compliance with the License. 13988 * You may obtain a copy of the License at 13989 * 13990 * http://www.apache.org/licenses/LICENSE-2.0 13991 * 13992 * Unless required by applicable law or agreed to in writing, software 13993 * distributed under the License is distributed on an "AS IS" BASIS, 13994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13995 * See the License for the specific language governing permissions and 13996 * limitations under the License. 13997 * ============================================================================= 13998 */const If="return sqrt(x);",BM=De({opSnippet:If,packedOpSnippet:If,cpuKernelImpl:hR}),VM={kernelName:jd,backendName:"webgl",kernelFunc:BM};/** 13999 * @license 14000 * Copyright 2019 Google LLC. All Rights Reserved. 14001 * Licensed under the Apache License, Version 2.0 (the "License");
14002 * you may not use this file except in compliance with the License. 14003 * You may obtain a copy of the License at 14004 * 14005 * http://www.apache.org/licenses/LICENSE-2.0 14006 * 14007 * Unless required by applicable law or agreed to in writing, software 14008 * distributed under the License is distributed on an "AS IS" BASIS, 14009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14010 * See the License for the specific language governing permissions and 14011 * limitations under the License. 14012 * ============================================================================= 14013 */const WM="return x * x;",UM=De({opSnippet:WM}),zM={kernelName:fm,backendName:"webgl",kernelFunc:UM};/** 14014 * @license 14015 * Copyright 2020 Google LLC. All Rights Reserved. 14016 * Licensed under the Apache License, Version 2.0 (the "License"); 14017 * you may not use this file except in compliance with the License. 14018 * You may obtain a copy of the License at 14019 * 14020 * http://www.apache.org/licenses/LICENSE-2.0 14021 * 14022 * Unless required by applicable law or agreed to in writing, software 14023 * distributed under the License is distributed on an "AS IS" BASIS, 14024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14025 * See the License for the specific language governing permissions and 14026 * limitations under the License. 14027 * ============================================================================= 14028 */const $f="return (a - b) * (a - b);",GM=Ct({opSnippet:$f,packedOpSnippet:$f}),HM={kernelName:Zd,backendName:"webgl",kernelFunc:GM};/** 14029 * @license 14030 * Copyright 2023 Google LLC. 14031 * Licensed under the Apache License, Version 2.0 (the "License"); 14032 * you may not use this file except in compliance with the License. 14033 * You may obtain a copy of the License at 14034 * 14035 * http://www.apache.org/licenses/LICENSE-2.0 14036 * 14037 * Unless required by applicable law or agreed to in writing, software 14038 * distributed under the License is distributed on an "AS IS" BASIS, 14039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14040 * See the License for the specific language governing permissions and 14041 * limitations under the License. 14042 * ============================================================================= 14043 */function jM(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;if(s.dtype!=="string")throw new Error("Input must be of datatype string");const a=t.readSync(s.dataId),o=Ca(a),i=fR(o,"string",r);return t.makeTensorInfo(s.shape,"string",i)}const qM={kernelName:mm,backendName:"webgl",kernelFunc:jM};/** 14044 * @license 14045 * Copyright 2020 Google LLC. All Rights Reserved. 14046 * Licensed under the Apache License, Version 2.0 (the "License"); 14047 * you may not use this file except in compliance with the License. 14048 * You may obtain a copy of the License at 14049 * 14050 * http://www.apache.org/licenses/LICENSE-2.0 14051 * 14052 * Unless required by applicable law or agreed to in writing, software 14053 * distributed under the License is distributed on an "AS IS" BASIS, 14054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14055 * See the License for the specific language governing permissions and 14056 * limitations under the License. 14057 * ============================================================================= 14058 */function KM({inputs:n,attrs:e,backend:t}){const{x:r}=n,s=Rn+` 14059 return x > 0.0 ? 1.0 : float(${e.alpha}); 14060 `,a=new sr(r.shape,s);return t.runWebGLProgram(a,[r],r.dtype)}const XM={kernelName:Fu,backendName:"webgl",kernelFunc:KM};/** 14061 * @license 14062 * Copyright 2017 Google LLC. All Rights Reserved. 14063 * Licensed under the Apache License, Version 2.0 (the "License"); 14064 * you may not use this file except in compliance with the License. 14065 * You may obtain a copy of the License at 14066 * 14067 * http://www.apache.org/licenses/LICENSE-2.0 14068 * 14069 * Unless required by applicable law or agreed to in writing, software 14070 * distributed under the License is distributed on an "AS IS" BASIS, 14071 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14072 * See the License for the specific language governing permissions and 14073 * limitations under the License. 14074 * ============================================================================= 14075 */class YM{constructor(e,t,r){this.variableNames=["x"],this.outputShape=r;const s=r.length,a=ze(r.length),o=ze(r.length);let i="";if(s===1)i="coords * strides + begin";else{let c=0;i=r.map((l,u)=>(c++,r.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${c-1}
14075] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=` 14076 ${a} begin = ${a}(${e}); 14077 ${a} strides = ${a}(${t}); 14078 14079 void main() { 14080 ${o} coords = getOutputCoords(); 14081 setOutput(getX(${i})); 14082 } 14083 `}}/** 14084 * @license 14085 * Copyright 2020 Google LLC. All Rights Reserved. 14086 * Licensed under the Apache License, Version 2.0 (the "License"); 14087 * you may not use this file except in compliance with the License. 14088 * You may obtain a copy of the License at 14089 * 14090 * http://www.apache.org/licenses/LICENSE-2.0 14091 * 14092 * Unless required by applicable law or agreed to in writing, software 14093 * distributed under the License is distributed on an "AS IS" BASIS, 14094 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14095 * See the License for the specific language governing permissions and 14096 * limitations under the License. 14097 * ============================================================================= 14098 */function QM(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{begin:a,end:o,strides:i,beginMask:c,endMask:l,ellipsisMask:u,newAxisMask:d,shrinkAxisMask:p}=r,{finalShapeSparse:h,finalShape:m,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:v,end:$,strides:S}=Ep(s.shape,a,o,i,c,l,u,d,p);let T;if(g)T=te({inputs:{x:s},backend:t,attrs:{shape:m}});else if(y||b){N(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);const L=Tp(v,$,S),M=Ba({inputs:{x:s},backend:t,attrs:{begin:v,size:L}});T=te({inputs:{x:M},backend:t,attrs:{shape:m}}),t.disposeIntermediateTensorInfo(M)}else if(t.shouldExecuteOnCPU([s])){const M=t.readSync(s.dataId),W=at(s.shape,s.dtype,M),V=mR(h,W,S,v);T=t.makeTensorInfo(m,s.dtype,V.values)}else{const M=new YM(v,S,h);T=t.runWebGLProgram(M,[s],s.dtype)}const O=te({inputs:{x:T},backend:t,attrs:{shape:m}});return t.disposeIntermediateTensorInfo(T),O}const ZM={kernelName:Au,backendName:"webgl",kernelFunc:QM};/** 14099 * @license 14100 * Copyright 2021 Google LLC. All Rights Reserved. 14101 * Licensed under the Apache License, Version 2.0 (the "License"); 14102 * you may not use this file except in compliance with the License. 14103 * You may obtain a copy of the License at 14104 * 14105 * http://www.apache.org/licenses/LICENSE-2.0 14106 * 14107 * Unless required by applicable law or agreed to in writing, software 14108 * distributed under the License is distributed on an "AS IS" BASIS, 14109 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14110 * See the License for the specific language governing permissions and 14111 * limitations under the License. 14112 * ============================================================================= 14113 */function JM(n){const{inputs:e,backend:t,attrs:r}=n,{separator:s,nGramWidths:a,leftPad:o,rightPad:i,padWidth:c,preserveShortSequences:l}=r,{data:u,dataSplits:d}=e,p=t.readSync(u.dataId),h=t.readSync(d.dataId),[m,g]=gR(p,h,s,a,o,i,c,l);return[t.makeTensorInfo([m.length],"string",m),t.makeTensorInfo(d.shape,"int32",g)]}const eB={kernelName:Jd,backendName:"webgl",kernelFunc:JM};/** 14114 * @license 14115 * Copyright 2021 Google LLC. All Rights Reserved. 14116 * Licensed under the Apache License, Version 2.0 (the "License"); 14117 * you may not use this file except in compliance with the License. 14118 * You may obtain a copy of the License at 14119 * 14120 * http://www.apache.org/licenses/LICENSE-2.0 14121 * 14122 * Unless required by applicable law or agreed to in writing, software 14123 * distributed under the License is distributed on an "AS IS" BASIS, 14124 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14125 * See the License for the specific language governing permissions and 14126 * limitations under the License. 14127 * ============================================================================= 14128 */function tB(n){const{inputs:e,backend:t,attrs:r}=n,{skipEmpty:s}=r,{input:a,delimiter:o}=e;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(a.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${a.shape}`);if(o.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`);const i=t.readSync(a.dataId),c=t.readSync(o.dataId)[0],[l,u,d]=yR(i,c,s),p=u.length;return[t.makeTensorInfo([p,2],"int32",l),t.makeTensorInfo([p],"string",u),t.makeTensorInfo([2],"int32",new Int32Array(d))]}const nB={kernelName:ep,backendName:"webgl",kernelFunc:tB};/** 14129 * @license 14130 * Copyright 2021 Google LLC. All Rights Reserved. 14131 * Licensed under the Apache License, Version 2.0 (the "License");
14132 * you may not use this file except in compliance with the License. 14133 * You may obtain a copy of the License at 14134 * 14135 * http://www.apache.org/licenses/LICENSE-2.0 14136 * 14137 * Unless required by applicable law or agreed to in writing, software 14138 * distributed under the License is distributed on an "AS IS" BASIS, 14139 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14140 * See the License for the specific language governing permissions and 14141 * limitations under the License. 14142 * ============================================================================= 14143 */function rB(n){const{inputs:e,backend:t,attrs:r}=n,{numBuckets:s}=r,{input:a}=e;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");const o=t.readSync(a.dataId),i=bR(o,s);return t.makeTensorInfo(a.shape,"int32",i)}const sB={kernelName:tp,backendName:"webgl",kernelFunc:rB};/** 14144 * @license 14145 * Copyright 2020 Google LLC. All Rights Reserved. 14146 * Licensed under the Apache License, Version 2.0 (the "License"); 14147 * you may not use this file except in compliance with the License. 14148 * You may obtain a copy of the License at 14149 * 14150 * http://www.apache.org/licenses/LICENSE-2.0 14151 * 14152 * Unless required by applicable law or agreed to in writing, software 14153 * distributed under the License is distributed on an "AS IS" BASIS, 14154 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14155 * See the License for the specific language governing permissions and 14156 * limitations under the License. 14157 * ============================================================================= 14158 */const aB="return tan(x);",oB=De({opSnippet:aB}),iB={kernelName:rp,backendName:"webgl",kernelFunc:oB};/** 14159 * @license 14160 * Copyright 2020 Google LLC. All Rights Reserved. 14161 * Licensed under the Apache License, Version 2.0 (the "License"); 14162 * you may not use this file except in compliance with the License. 14163 * You may obtain a copy of the License at 14164 * 14165 * http://www.apache.org/licenses/LICENSE-2.0 14166 * 14167 * Unless required by applicable law or agreed to in writing, software 14168 * distributed under the License is distributed on an "AS IS" BASIS, 14169 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14170 * See the License for the specific language governing permissions and 14171 * limitations under the License. 14172 * ============================================================================= 14173 */const uB=` 14174 float e2x = exp(-2.0 * abs(x)); 14175 return sign(x) * (1.0 - e2x) / (1.0 + e2x); 14176`,cB=De({opSnippet:uB}),lB={kernelName:sp,backendName:"webgl",kernelFunc:cB};/** 14177 * @license 14178 * Copyright 2022 Google LLC. All Rights Reserved. 14179 * Licensed under the Apache License, Version 2.0 (the "License"); 14180 * you may not use this file except in compliance with the License. 14181 * You may obtain a copy of the License at 14182 * 14183 * http://www.apache.org/licenses/LICENSE-2.0 14184 * 14185 * Unless required by applicable law or agreed to in writing, software 14186 * distributed under the License is distributed on an "AS IS" BASIS, 14187 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14188 * See the License for the specific language governing permissions and 14189 * limitations under the License. 14190 * ============================================================================= 14191 */function dB(n){const{inputs:e,backend:t,attrs:r}=n,{tensor:s,indices:a,updates:o}=e,{sliceRank:i,numUpdates:c,sliceSize:l,strides:u,outputSize:d}=Ms(o,a,s.shape),p=[d/l,l];if(d===0)return t.makeTensorInfo(s.shape,a.dtype);const h=te({inputs:{x:a},backend:t,attrs:{shape:[c,i]}}),m=te({inputs:{x:o},backend:t,attrs:{shape:[c,l]}}),g=te({inputs:{x:s},backend:t,attrs:{shape:p}}),y=new sh(c,i,h.shape.length,m.shape.length,u,p,!1,!0),b=t.runWebGLProgram(y,[m,h,g],g.dtype),v=te({inputs:{x:b},backend:t,attrs:{shape:s.shape}});return t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(b),v}const pB={kernelName:_u,backendName:"webgl",kernelFunc:dB};/** 14192 * @license 14193 * Copyright 2017 Google LLC. All Rights Reserved. 14194 * Licensed under the Apache License, Version 2.0 (the "License");
14195 * you may not use this file except in compliance with the License. 14196 * You may obtain a copy of the License at 14197 * 14198 * http://www.apache.org/licenses/LICENSE-2.0 14199 * 14200 * Unless required by applicable law or agreed to in writing, software 14201 * distributed under the License is distributed on an "AS IS" BASIS, 14202 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14203 * See the License for the specific language governing permissions and 14204 * limitations under the License. 14205 * ============================================================================= 14206 */class hB{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 s=ze(this.rank),a=fB(e);this.userCode=` 14207 void main() { 14208 ${s} resRC = getOutputCoords(); 14209 setOutput(getA(${a})); 14210 } 14211 `}}function fB(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 s=0;s<n.length;s++)r.push(`imod(${t[s]}, ${n[s]})`);return r.join()}/** 14212 * @license 14213 * Copyright 2020 Google LLC. All Rights Reserved. 14214 * Licensed under the Apache License, Version 2.0 (the "License"); 14215 * you may not use this file except in compliance with the License. 14216 * You may obtain a copy of the License at 14217 * 14218 * http://www.apache.org/licenses/LICENSE-2.0 14219 * 14220 * Unless required by applicable law or agreed to in writing, software 14221 * distributed under the License is distributed on an "AS IS" BASIS, 14222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14223 * See the License for the specific language governing permissions and 14224 * limitations under the License. 14225 * ============================================================================= 14226 */function Cb(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{reps:a}=r;if(s.dtype==="string"||s.shape.length>5){const c=t.readSync(s.dataId),l=s.dtype==="string"?c.map(p=>Ia(p)):c,u=at(s.shape,s.dtype,l),d=wR(u,a);return t.makeTensorInfo(d.shape,d.dtype,d.values)}const o=new hB(s.shape,a);return t.runWebGLProgram(o,[s],s.dtype)}const mB={kernelName:_o,backendName:"webgl",kernelFunc:Cb};class gB{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=` 14227 void main() { 14228 ivec2 coords = getOutputCoords(); 14229 int batch = coords[0]; 14230 int elemIdx = coords[1]; 14231 14232 // We compare elements pair-wise within a group of size 2 * inc. 14233 // The comparing rule for each group alternates between ascending 14234 // and descending. Within each group, we compare each pair at 14235 // positions i and i+inc. To decide whether an element at position i 14236 // is x0 or x1, we mod it by 2 * inc, if the result is smaller than 14237 // inc, it is in the first half of the group, we denote it as x0, 14238 // otherwise we denote it as x1. 14239 // For example, as shown in the Bitonic top K paper referenced above, 14240 // Figure5(a) shows that element[1] is in the 14241 // second half of the group when group size is 2, but it is in the 14242 // first half of the group when group size is 4. 14243 14244 bool isFirstInPair = imod(elemIdx, 2 * inc) < inc; 14245 int i = isFirstInPair ? elemIdx : elemIdx - inc; 14246 14247 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 14248 int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc)); 14249 float x0 = i0 < n ? getX(batch, i0) : negativeInf; 14250 float x1 = i1 < n ? getX(batch, i1) : negativeInf; 14251 14252 // Denotes which direction indices are in (ascending or descending). 14253 bool reverse = imod(elemIdx, 2 * dir) >= dir; 14254 bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0); 14255 if (reverse == isGreater) { // Elements in opposite order of direction 14256 int iTemp = i0; 14257 i0 = i1; 14258 i1 = iTemp; 14259 } 14260 if (isFirstInPair) { 14261 setOutput(float(i0)); 14262 } else { 14263 setOutput(float(i1)); 14264 } 14265 } 14266 `}}class yB{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=` 14267 void main() { 14268 // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ... 14269 ivec2 coords = getOutputCoords(); 14270 int batch = coords[0]; 14271 int elemIdx = coords[1]; 14272 14273 // The output size is half of the previous size. 14274 // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4), 14275 // we only need to output the indices at positions |, the indices at 14276 // positions _ can be thrown away, see Figure5(b) After Phase 2 14277 // (Merge phase) in the Bitonic Top K paper referenced above. 14278 // For example, the paper shows we only need to output the orange bars. 14279 // The output sequence should look like this | | | | | | | |. 14280 // Because the sequence is halved, to map the output index back 14281 // to the previous sequence to find the corresponding value, 14282 // we need to double the index. When we double the index, 14283 // we basically interpolate a position, so 2i looks like 14284 // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position 14285 // of each 2k positions by - elemIdx % k. E.g. for output at 14286 // index 4,5,6,7, we want to get the corresponding element at 14287 // original index 8,9,10,11, for output at index 8,9,10,11, 14288 // we want to get the corresponding element at original index 14289 // 16,17,18,19, so on and so forth. 14290 14291 int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k)); 14292 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 14293 int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k)); 14294 14295 float x0 = getX(batch, i0); 14296 float x1 = i1 < n ? getX(batch, i1) : x0; 14297 14298 setOutput(x0 >= x1 ? float(i0) : float(i1)); 14299 } 14300 `}}/** 14301 * @license 14302 * Copyright 2020 Google LLC. All Rights Reserved. 14303 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 6,696 bytes, lines 14304-14418
14304 * you may not use this file except in compliance with the License. 14305 * You may obtain a copy of the License at 14306 * 14307 * http://www.apache.org/licenses/LICENSE-2.0 14308 * 14309 * Unless required by applicable law or agreed to in writing, software 14310 * distributed under the License is distributed on an "AS IS" BASIS, 14311 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14312 * See the License for the specific language governing permissions and 14313 * limitations under the License. 14314 * ============================================================================= 14315 */function ps(n,e){e!==null&&n.disposeIntermediateTensorInfo(e)}function Sf(n){let e=1;for(;e<n;)e*=2;return e}function bB(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{k:a,sorted:o}=r,i=U().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),c=U().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),l=s.shape,u=l[l.length-1];if(t.shouldExecuteOnCPU([s])||u<i||a>c){const V=t.readSync(s.dataId),[G,K]=vR(V,l,s.dtype,a,o);return[t.makeTensorInfo(G.shape,G.dtype,G.values),t.makeTensorInfo(K.shape,K.dtype,K.values)]}if(a===0)return l[l.length-1]=0,[t.makeTensorInfo(l,s.dtype,[]),t.makeTensorInfo(l,"int32",[])];if(u===1)return[s,Bo({attrs:{shape:l,dtype:"int32",value:0},backend:t})];const d=t.texData.get(s.dataId),p=d!==null&&d.isPacked,h=p?t.unpackTensor(s):s,g=H(l)/u,y=te({inputs:{x:h},attrs:{shape:[g,u]},backend:t});p&&ps(t,h);const b=Sf(a),v=Sf(u);let $=null;const S=()=>$===null?[y,y]:[y,$],T=(V,G,K)=>{const J=S(),ue=new gB(K),fe=[[u],[$===null?1:0],[Number.NEGATIVE_INFINITY],[V],[G]],Ie=$;$=t.runWebGLProgram(ue,J,"int32",fe),ps(t,Ie)};for(let V=1;V<b;V*=2){const G=V*2;for(let K=V;K>=1;K/=2)T(G,K,[g,v])}for(let V=v;V>b;V/=2){const G=S(),K=new yB([g,V/2]),ue=[[u],[$===null?1:0],[b]],se=$;$=t.runWebGLProgram(K,G,"int32",ue),ps(t,se);const fe=b/2,Ie=fe*2;for(let pe=fe;pe>=1;pe/=2)T(Ie,pe,$.shape)}let O=$;$=Ba({inputs:{x:$},backend:t,attrs:{begin:0,size:[g,a]}}),ps(t,O);let L=yb({inputs:{x:y,indices:$},backend:t,attrs:{axis:1,batchDims:1}});ps(t,y);const M=l.slice(0,-1);M.push(a),O=$,$=te({inputs:{x:$},attrs:{shape:M},backend:t}),ps(t,O);const W=L;return L=te({inputs:{x:L},attrs:{shape:M},backend:t}),ps(t,W),[L,$]}const xB={kernelName:Du,backendName:"webgl",kernelFunc:bB};/** 14316 * @license 14317 * Copyright 2021 Google LLC. All Rights Reserved. 14318 * Licensed under the Apache License, Version 2.0 (the "License"); 14319 * you may not use this file except in compliance with the License. 14320 * You may obtain a copy of the License at 14321 * 14322 * http://www.apache.org/licenses/LICENSE-2.0 14323 * 14324 * Unless required by applicable law or agreed to in writing, software 14325 * distributed under the License is distributed on an "AS IS" BASIS, 14326 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14327 * See the License for the specific language governing permissions and 14328 * limitations under the License. 14329 * ============================================================================= 14330 */class wB{constructor(e,t,r,s,a,o){this.variableNames=["Image","Transforms"],this.outputShape=o;const i=r==="nearest"?1:2;let c;switch(s){case"constant":c=1;break;case"reflect":c=2;break;case"wrap":c=3;break;case"nearest":c=4;break;default:c=1;break}this.userCode=` 14331 float mapCoord(float outCoord, float len) { 14332 float inCoord = outCoord; 14333 if(${c} == 2) { 14334 if (inCoord < 0.0) { 14335 if (len <= 1.0) { 14336 inCoord = 0.0; 14337 } else { 14338 float sz2 = 2.0 * len; 14339 if (inCoord < sz2) { 14340 inCoord = sz2 * float(int(float(-inCoord / sz2))) + 14341 inCoord; 14342 } 14343 inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0; 14344 } 14345 } else if (inCoord > len - 1.0) { 14346 if (len <= 1.0) { 14347 inCoord = 0.0; 14348 } else { 14349 float sz2 = 2.0 * len; 14350 inCoord -= sz2 * float(int(float(inCoord / sz2))); 14351 if (inCoord >= len) { 14352 inCoord = sz2 - inCoord - 1.0; 14353 } 14354 } 14355 } 14356 return clamp(inCoord, 0.0, len - 1.0); 14357 } else if (${c} == 3) { 14358 if (inCoord < 0.0) { 14359 if (len <= 1.0) { 14360 inCoord = 0.0; 14361 } else { 14362 float sz = len - 1.0; 14363 inCoord += len * (float(int(float(-inCoord / sz))) + 1.0); 14364 } 14365 } else if (inCoord > len - 1.0) { 14366 if (len <= 1.0) { 14367 inCoord = 0.0; 14368 } else { 14369 float sz = len - 1.0; 14370 inCoord -= len * float(int(float(inCoord / sz))); 14371 } 14372 } 14373 return clamp(inCoord, 0.0, len - 1.0); 14374 } else if (${c} == 4) { 14375 return clamp(outCoord, 0.0, len - 1.0); 14376 } else { 14377 return outCoord; 14378 } 14379 } 14380 14381 float readWithFillValue(int batch, int coordY, int coordX, 14382 int channel) { 14383 float outputValue; 14384 if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) { 14385 outputValue = getImage(batch, coordY, coordX, channel); 14386 } else { 14387 outputValue = float(${a}); 14388 } 14389 return outputValue; 14390 } 14391 14392 void main() { 14393 ivec4 coords = getOutputCoords(); 14394 float outputValue; 14395 int batch = coords[0]; 14396 int x = coords[2]; 14397 int y = coords[1]; 14398 int channel = coords[3]; 14399 float xf = float(x); 14400 float yf = float(y); 14401 float a1 = getTransforms(batch, 0); 14402 float a2 = getTransforms(batch, 1); 14403 float a3 = getTransforms(batch, 2); 14404 float b1 = getTransforms(batch, 3); 14405 float b2 = getTransforms(batch, 4); 14406 float b3 = getTransforms(batch, 5); 14407 float c1 = getTransforms(batch, 6); 14408 float c2 = getTransforms(batch, 7); 14409 float projection = c1 * xf + c2 * yf + 1.0; 14410 if (projection == 0.0) { 14411 outputValue = float(${a}); 14412 } else { 14413 float inX = (a1 * xf + a2 * yf + a3) / projection; 14414 float inY = (b1 * xf + b2 * yf + b3) / projection; 14415 float mapX = mapCoord(inX, float(${t})); 14416 float mapY = mapCoord(inY, float(${e})); 14417 14418 if (${i} == 1) {
14419 int coordY = int(round(mapY)); 14420 int coordX = int(round(mapX)); 14421 outputValue = readWithFillValue(batch, coordY, coordX, 14422 channel); 14423 } else { 14424 float yFloor = floor(mapY); 14425 float xFloor = floor(mapX); 14426 float yCeil = yFloor + 1.0; 14427 float xCeil = xFloor + 1.0; 14428 float valueYFloor = (xCeil - mapX) * 14429 readWithFillValue(batch, int(yFloor), int(xFloor), channel) + 14430 (mapX - xFloor) * 14431 readWithFillValue(batch, int(yFloor), int(xCeil), channel); 14432 float valueYCeil = (xCeil - mapX) * 14433 readWithFillValue(batch, int(yCeil), int(xFloor), channel) + 14434 (mapX - xFloor) * 14435 readWithFillValue(batch, int(yCeil), int(xCeil), channel); 14436 outputValue = (yCeil - mapY) * valueYFloor + 14437 (mapY - yFloor) * valueYCeil; 14438 } 14439 } 14440 setOutput(outputValue); 14441 } 14442 `}}/** 14443 * @license 14444 * Copyright 2021 Google LLC. All Rights Reserved. 14445 * Licensed under the Apache License, Version 2.0 (the "License"); 14446 * you may not use this file except in compliance with the License. 14447 * You may obtain a copy of the License at 14448 * 14449 * http://www.apache.org/licenses/LICENSE-2.0 14450 * 14451 * Unless required by applicable law or agreed to in writing, software 14452 * distributed under the License is distributed on an "AS IS" BASIS, 14453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14454 * See the License for the specific language governing permissions and 14455 * limitations under the License. 14456 * ============================================================================= 14457 */function vB(n){const{inputs:e,backend:t,attrs:r}=n,{image:s,transforms:a}=e,{interpolation:o,fillMode:i,fillValue:c,outputShape:l}=r,[u,d,p,h]=s.shape,[m,g]=l!=null?l:[d,p],y=[u,m,g,h],b=new wB(d,p,o,i,c,y);return t.runWebGLProgram(b,[s,a],"float32")}const IB={kernelName:Ou,backendName:"webgl",kernelFunc:vB};/** 14458 * @license 14459 * Copyright 2020 Google LLC. All Rights Reserved. 14460 * Licensed under the Apache License, Version 2.0 (the License); 14461 * you may not use this file except in compliance with the License. 14462 * You may obtain a copy of the License at 14463 * 14464 * http://www.apache.org/licenses/LICENSE-2.0 14465 * 14466 * Unless required by applicable law or agreed to in writing, software 14467 * distributed under the License is distributed on an AS IS BASIS, 14468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14469 * See the License for the specific language governing permissions and 14470 * limitations under the License. 14471 * ============================================================================= 14472 */function $B(n){const{inputs:e,attrs:t,backend:r}=n,{axis:s}=t,{x:a}=e;Po(a,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const o=r.readSync(a.dataId),{outputValues:i,outputShape:c,indices:l}=IR(o,s,a.shape,a.dtype);
vendor: 5,431 bytes, lines 14472-14611
14472return[r.makeTensorInfo(c,a.dtype,i),r.makeTensorInfo([l.length],"int32",l)]}const SB={kernelName:ap,backendName:"webgl",kernelFunc:$B};/** 14473 * @license 14474 * Copyright 2020 Google LLC. All Rights Reserved. 14475 * Licensed under the Apache License, Version 2.0 (the "License"); 14476 * you may not use this file except in compliance with the License. 14477 * You may obtain a copy of the License at 14478 * 14479 * http://www.apache.org/licenses/LICENSE-2.0 14480 * 14481 * Unless required by applicable law or agreed to in writing, software 14482 * distributed under the License is distributed on an "AS IS" BASIS, 14483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14484 * See the License for the specific language governing permissions and 14485 * limitations under the License. 14486 * ============================================================================= 14487 */function CB(n){const{inputs:e,backend:t,attrs:r}=n,{value:s}=e;let{axis:a}=r;a<0&&(a+=s.shape.length);const o=s,i=o.shape.length,c=s.shape[a],l=new Array(i-1);let u=0;for(let g=0;g<i;g++)g!==a&&(l[u++]=o.shape[g]);const d=[],p=new Array(i).fill(0),h=o.shape.slice();h[a]=1;const m=new Array(c);for(let g=0;g<m.length;g++){p[a]=g;const y=Ba({inputs:{x:o},backend:t,attrs:{begin:p,size:h}}),b=te({inputs:{x:y},backend:t,attrs:{shape:l}});m[g]=b,d.push(y)}return d.forEach(g=>t.disposeIntermediateTensorInfo(g)),m}const _B={kernelName:op,backendName:"webgl",kernelFunc:CB};/** 14488 * @license 14489 * Copyright 2018 Google LLC. All Rights Reserved. 14490 * Licensed under the Apache License, Version 2.0 (the "License"); 14491 * you may not use this file except in compliance with the License. 14492 * You may obtain a copy of the License at 14493 * 14494 * http://www.apache.org/licenses/LICENSE-2.0 14495 * 14496 * Unless required by applicable law or agreed to in writing, software 14497 * distributed under the License is distributed on an "AS IS" BASIS, 14498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14499 * See the License for the specific language governing permissions and 14500 * limitations under the License. 14501 * ============================================================================= 14502 */class NB{constructor(e,t){this.variableNames=["x","segmentIds"];const r=e.windowSize,s=e.batchSize,a=e.inSize,o=e.numSegments,i=o*Math.ceil(a/r);this.outputShape=[s,i];const c="0.0",l="sumValue",u=Math.floor(r/4)*4,d=r%4,p=` 14503 sumValue += dot(values, segFilter); 14504 `;let h="";a%r>0&&(h=` 14505 if (inIdx < 0 || inIdx >= ${a}) { 14506 return initializationValue; 14507 } 14508 `);let m="";a%r>0&&(m=` 14509 if (inIdx < 0 || inIdx >= ${a}) { 14510 return -1.0; 14511 } 14512 `),this.userCode=` 14513 const float initializationValue = ${c}; 14514 14515 float getValue(int batch, int inIdx) { 14516 ${h} 14517 return getX(batch, inIdx); 14518 } 14519 14520 float getSegmentIdAtIndex(int inIdx) { 14521 ${m} 14522 return getSegmentIds(inIdx); 14523 } 14524 14525 void main() { 14526 ivec2 coords = getOutputCoords(); 14527 int batch = coords[0]; 14528 int outIdx = coords[1]; 14529 int inOffset = int(floor(float(outIdx) / float( 14530 ${o})) * float(${r})); 14531 int currentSeg = int(mod(float(outIdx), float(${o}))); 14532 14533 float sumValue = 0.0; 14534 14535 for (int i = 0; i < ${u}; i += 4) { 14536 int inIdx = inOffset + i; 14537 vec4 values = vec4( 14538 getValue(batch, inIdx), 14539 getValue(batch, inIdx + 1), 14540 getValue(batch, inIdx + 2), 14541 getValue(batch, inIdx + 3) 14542 ); 14543 14544 vec4 segFilter = vec4( 14545 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14546 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 14547 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 14548 int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0 14549 ); 14550 14551 ${p} 14552 } 14553 14554 int inIdx = inOffset + ${u}; 14555 if (${d===1}) { 14556 vec4 values = vec4( 14557 getValue(batch, inIdx), 14558 initializationValue, 14559 initializationValue, 14560 initializationValue 14561 ); 14562 14563 int inIdxSeg = int(getSegmentIdAtIndex(inIdx)); 14564 14565 vec4 segFilter = vec4( 14566 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14567 0, 14568 0, 14569 0 14570 ); 14571 14572 ${p} 14573 } else if (${d===2}) { 14574 vec4 values = vec4( 14575 getValue(batch, inIdx), 14576 getValue(batch, inIdx + 1), 14577 initializationValue, 14578 initializationValue 14579 ); 14580 14581 vec4 segFilter = vec4( 14582 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14583 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 14584 0, 14585 0 14586 ); 14587 14588 ${p} 14589 } else if (${d===3}) { 14590 vec4 values = vec4( 14591 getValue(batch, inIdx), 14592 getValue(batch, inIdx + 1), 14593 getValue(batch, inIdx + 2), 14594 initializationValue 14595 ); 14596 14597 vec4 segFilter = vec4( 14598 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 14599 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 14600 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 14601 0 14602 ); 14603 14604 ${p} 14605 } 14606 setOutput(${l}); 14607 } 14608 `}}/** 14609 * @license 14610 * Copyright 2020 Google LLC. All Rights Reserved. 14611 * Licensed under the Apache License, Version 2.0 (the "License");
14612 * you may not use this file except in compliance with the License. 14613 * You may obtain a copy of the License at 14614 * 14615 * http://www.apache.org/licenses/LICENSE-2.0 14616 * 14617 * Unless required by applicable law or agreed to in writing, software 14618 * distributed under the License is distributed on an "AS IS" BASIS, 14619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14620 * See the License for the specific language governing permissions and 14621 * limitations under the License. 14622 * ============================================================================= 14623 */function TB(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,segmentIds:a}=e,{numSegments:o}=r,i=s.shape.length,c=[];let l=0;const u=Xt([l],i);let d=s;u!=null&&(d=Vt({inputs:{x:s},backend:t,attrs:{perm:u}}),c.push(d),l=St(1,i)[0]);const p=_y(d.shape,l,o),h=H([d.shape[l]]),m=te({inputs:{x:d},backend:t,attrs:{shape:[-1,h]}});c.push(m);const g=cp(s.dtype),y=(S,T,O,L,M)=>{const W=S.shape[0],V=S.shape[1],G=Cy(V,M),K={windowSize:G,inSize:V,batchSize:W,numSegments:M},J=new NB(K,T),ue=t.compileAndRun(J,[S,O],L);if(c.push(ue),ue.shape[1]===M)return ue;const se=Sb({backend:t,attrs:{start:0,stop:M,step:1,dtype:"float32"}}),fe=Cb({inputs:{x:se},backend:t,attrs:{reps:[V/G]}});return c.push(se),c.push(fe),y(ue,T,fe,L,M)},b=y(m,"unsortedSegmentSum",a,g,o),v=te({inputs:{x:b},backend:t,attrs:{shape:p}});let $=v;if(u!=null){c.push(v);const S=Eo(u);$=Vt({inputs:{x:$},backend:t,attrs:{perm:S}})}return c.forEach(S=>t.disposeIntermediateTensorInfo(S)),$}const kB={kernelName:gm,backendName:"webgl",kernelFunc:TB};/** 14624 * @license 14625 * Copyright 2020 Google LLC. All Rights Reserved. 14626 * Licensed under the Apache License, Version 2.0 (the "License"); 14627 * you may not use this file except in compliance with the License. 14628 * You may obtain a copy of the License at 14629 * 14630 * http://www.apache.org/licenses/LICENSE-2.0 14631 * 14632 * Unless required by applicable law or agreed to in writing, software 14633 * distributed under the License is distributed on an "AS IS" BASIS, 14634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14635 * See the License for the specific language governing permissions and 14636 * limitations under the License. 14637 * ============================================================================= 14638 */const EB=[hA,mA,bA,vA,$A,_A,TA,EA,OA,PA,BA,UA,HA,XA,ZA,eD,nD,oD,uD,lD,fD,vD,$D,ND,kD,FD,LD,WD,YR,GD,XD,JD,aO,uO,lO,pO,fO,bO,vO,SO,_O,TO,EO,DO,FO,BO,WO,GO,qO,XO,JO,rF,iF,lF,hF,fF,gF,bF,wF,IF,SF,TF,RF,OF,PF,BF,UF,jF,YF,XR,ZF,qD,tP,sP,iP,ZR,dP,mP,yP,vP,SP,TP,RP,FP,BP,UP,GP,KP,YP,ZP,n3,s3,o3,u3,l3,f3,b3,I3,E3,tA,O3,L3,V3,z3,RD,j3,K3,Y3,J3,rL,eA,aL,iL,cL,dL,pL,AD,_3,mL,xL,$L,rA,NL,EL,OL,LL,WL,zL,jL,XL,ZL,tM,sM,iM,dM,fM,bM,vM,xD,T3,SM,_M,TM,EM,AM,OM,PM,MM,VM,zM,HM,qM,XM,ZM,eB,nB,sB,N3,lA,iB,lB,pB,mB,xB,IB,dA,SB,_B,kB,q3];for(const n of EB)ym(n);/** 14639 * @license 14640 * Copyright 2019 Google LLC. All Rights Reserved. 14641 * Licensed under the Apache License, Version 2.0 (the "License"); 14642 * you may not use this file except in compliance with the License. 14643 * You may obtain a copy of the License at 14644 * 14645 * http://www.apache.org/licenses/LICENSE-2.0 14646 * 14647 * Unless required by applicable law or agreed to in writing, software 14648 * distributed under the License is distributed on an "AS IS" BASIS, 14649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14650 * See the License for the specific language governing permissions and 14651 * limitations under the License. 14652 * ============================================================================= 14653 */var Oe;(function(n){n[n.float32=0]="float32",n[n.int32=1]="int32",n[n.bool=2]="bool",n[n.string=3]="string",n[n.complex64=4]="complex64"})(Oe||(Oe={}));var Co;(function(n){n[n.linear=0]="linear",n[n.relu=1]="relu",n[n.relu6=2]="relu6",n[n.prelu=3]="prelu",n[n.leakyrelu=4]="leakyrelu",n[n.sigmoid=5]="sigmoid",n[n.elu=6]="elu"})(Co||(Co={}));/** 14654 * @license 14655 * Copyright 2019 Google LLC. All Rights Reserved. 14656 * Licensed under the Apache License, Version 2.0 (the "License"); 14657 * you may not use this file except in compliance with the License. 14658 * You may obtain a copy of the License at 14659 * 14660 * http://www.apache.org/licenses/LICENSE-2.0 14661 * 14662 * Unless required by applicable law or agreed to in writing, softw
14662are 14663 * distributed under the License is distributed on an "AS IS" BASIS, 14664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14665 * See the License for the specific language governing permissions and 14666 * limitations under the License. 14667 * ============================================================================= 14668 */let _b;function RB(n){_b=n.wasm.cwrap(uo,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function AB(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:a,bias:o,preluActivationWeights:i}=e;if(s.dtype!=="float32"||a.dtype!=="float32")throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");const{transposeA:c,transposeB:l,activation:u,leakyreluAlpha:d}=r,p=t.dataIdMap.get(s.dataId).id,h=t.dataIdMap.get(a.dataId).id;let m=0;if(o!=null){const M=t.dataIdMap.get(o.dataId);if(M.shape.length!==1)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${M.shape.length}.`);m=M.id}const g=i==null?0:t.dataIdMap.get(i.dataId).id,y=Co[u];if(y==null)throw new Error(`${u} activation not yet supported for FusedConv2D in the wasm backend.`);const b=c?s.shape[2]:s.shape[1],v=l?a.shape[1]:a.shape[2],$=ke(s.shape.slice(0,-2),a.shape.slice(0,-2)),S=t.makeOutput([...$,b,v],s.dtype),T=t.dataIdMap.get(S.dataId).id,O=new Uint8Array(new Int32Array(s.shape).buffer),L=new Uint8Array(new Int32Array(a.shape).buffer);return _b(p,O,s.shape.length,h,L,a.shape.length,c,l,y,m,g,d||0,T),S}const DB={kernelName:uo,backendName:"wasm",setupFunc:RB,kernelFunc:AB};/** 14669 * @license 14670 * Copyright 2019 Google LLC. All Rights Reserved. 14671 * Licensed under the Apache License, Version 2.0 (the "License"); 14672 * you may not use this file except in compliance with the License. 14673 * You may obtain a copy of the License at 14674 * 14675 * http://www.apache.org/licenses/LICENSE-2.0 14676 * 14677 * Unless required by applicable law or agreed to in writing, software 14678 * distributed under the License is distributed on an "AS IS" BASIS, 14679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14680 * See the License for the specific language governing permissions and 14681 * limitations under the License. 14682 * ============================================================================= 14683 */function Ae(n,e){let t;function r(a){t=a.wasm.cwrap(n,null,["number","number","number"])}function s(a){const{backend:o,inputs:{x:i}}=a,c=o.dataIdMap.get(i.dataId).id,l=o.makeOutput(i.shape,e||i.dtype),u=o.dataIdMap.get(l.dataId).id;return H(l.shape)===0||t(c,Oe[i.dtype],u),l}return{kernelName:n,backendName:"wasm",setupFunc:r,kernelFunc:s}}/** 14684 * @license 14685 * Copyright 2019 Google LLC. All Rights Reserved. 14686 * Licensed under the Apache License, Version 2.0 (the "License"); 14687 * you may not use this file except in compliance with the License. 14688 * You may obtain a copy of the License at 14689 * 14690 * http://www.apache.org/licenses/LICENSE-2.0 14691 * 14692 * Unless required by applicable law or agreed to in writing, software 14693 * distributed under the License is distributed on an "AS IS" BASIS, 14694 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14695 * See the License for the specific language governing permissions and 14696 * limitations under the License. 14697 * ============================================================================= 14698 */const OB=Ae(_l);/** 14699 * @license 14700 * Copyright 2023 Google LLC. 14701 * Licensed under the Apache License, Version 2.0 (the "License"); 14702 * you may not use this file except in compliance with the License. 14703 * You may obtain a copy of the License at 14704 * 14705 * http://www.apache.org/licenses/LICENSE-2.0 14706 * 14707 * Unless required by applicable law or agreed to in writing, software 14708 * distributed under the License is distributed on an "AS IS" BASIS, 14709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14710 * See the License for the specific language governing permissions and 14711 * limitations under the License. 14712 * ============================================================================= 14713 */const FB=Ae(Nl);/** 14714 * @license 14715 * Copyright 2023 Google LLC. 14716 * Licensed under the Apache License, Version 2.0 (the "License");
14717 * you may not use this file except in compliance with the License. 14718 * You may obtain a copy of the License at 14719 * 14720 * http://www.apache.org/licenses/LICENSE-2.0 14721 * 14722 * Unless required by applicable law or agreed to in writing, software 14723 * distributed under the License is distributed on an "AS IS" BASIS, 14724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14725 * See the License for the specific language governing permissions and 14726 * limitations under the License. 14727 * ============================================================================= 14728 */const PB=Ae(Tl);/** 14729 * @license 14730 * Copyright 2019 Google LLC. All Rights Reserved. 14731 * Licensed under the Apache License, Version 2.0 (the "License"); 14732 * you may not use this file except in compliance with the License. 14733 * You may obtain a copy of the License at 14734 * 14735 * http://www.apache.org/licenses/LICENSE-2.0 14736 * 14737 * Unless required by applicable law or agreed to in writing, software 14738 * distributed under the License is distributed on an "AS IS" BASIS, 14739 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14740 * See the License for the specific language governing permissions and 14741 * limitations under the License. 14742 * ============================================================================= 14743 */function lt(n,e,t){let r;function s(o){r=o.wasm.cwrap(n,null,["number","array","number","number","array","number","number","number"])}function a(o){const{backend:i,inputs:c}=o,{a:l,b:u}=c,d=i.dataIdMap.get(l.dataId).id,p=i.dataIdMap.get(u.dataId).id,h=t!=null?t:l.dtype,m=ke(l.shape,u.shape),g=i.makeOutput(m,h);if(H(m)===0)return g;const y=new Uint8Array(new Int32Array(l.shape).buffer),b=new Uint8Array(new Int32Array(u.shape).buffer),v=i.dataIdMap.get(g.dataId).id;return(()=>r(d,y,l.shape.length,p,b,u.shape.length,Oe[l.dtype],v))(),g}return{kernelName:n,backendName:"wasm",setupFunc:s,kernelFunc:a}}/** 14744 * @license 14745 * Copyright 2019 Google LLC. All Rights Reserved. 14746 * Licensed under the Apache License, Version 2.0 (the "License"); 14747 * you may not use this file except in compliance with the License. 14748 * You may obtain a copy of the License at 14749 * 14750 * http://www.apache.org/licenses/LICENSE-2.0 14751 * 14752 * Unless required by applicable law or agreed to in writing, software 14753 * distributed under the License is distributed on an "AS IS" BASIS, 14754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14755 * See the License for the specific language governing permissions and 14756 * limitations under the License. 14757 * ============================================================================= 14758 */const LB=lt(Li);/** 14759 * @license 14760 * Copyright 2019 Google LLC. All Rights Reserved. 14761 * Licensed under the Apache License, Version 2.0 (the "License"); 14762 * you may not use this file except in compliance with the License. 14763 * You may obtain a copy of the License at 14764 * 14765 * http://www.apache.org/licenses/LICENSE-2.0 14766 * 14767 * Unless required by applicable law or agreed to in writing, software 14768 * distributed under the License is distributed on an "AS IS" BASIS, 14769 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14770 * See the License for the specific language governing permissions and 14771 * limitations under the License. 14772 * ============================================================================= 14773 */let Nb;function MB(n){Nb=n.wasm.cwrap(Mi,null,["array","number","number","number"])}function BB(n){const{inputs:e,backend:t}=n,r=t.makeOutput(e[0].shape,e[0].dtype);if(H(r.shape)===0)return r;const s=e.map(i=>t.dataIdMap.get(i.dataId).id),a=new Uint8Array(new Int32Array(s).buffer),o=t.dataIdMap.get(r.dataId).id;return Nb(a,s.length,Oe[r.dtype],o),r}const VB={kernelName:Mi,backendName:"wasm",setupFunc:MB,kernelFunc:BB};/** 14774 * @license 14775 * Copyright 2020 Google LLC. All Rights Reserved. 14776 * Licensed under the Apache License, Version 2.0 (the "License"); 14777 * you may not use this file except in compliance with the License. 14778 * You may obtain a copy of the License at 14779 * 14780 * http://www.apache.org/licenses/LICENSE-2.0 14781 * 14782 * Unless required by applicable law or agreed to in writing, softw
14782are 14783 * distributed under the License is distributed on an "AS IS" BASIS, 14784 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14785 * See the License for the specific language governing permissions and 14786 * limitations under the License. 14787 * ============================================================================= 14788 */function sc(n){const{inputs:{x:e},backend:t}=n;if(e.dtype==="string")return zn(t.readSync(e.dataId),e.shape,e.dtype);const r=t.makeOutput(e.shape,e.dtype),s=t.typedArrayFromHeap(e);return t.typedArrayFromHeap(r).set(s),r}const WB={kernelName:au,backendName:"wasm",kernelFunc:sc};/** 14789 * @license 14790 * Copyright 2019 Google LLC. All Rights Reserved. 14791 * Licensed under the Apache License, Version 2.0 (the "License"); 14792 * you may not use this file except in compliance with the License. 14793 * You may obtain a copy of the License at 14794 * 14795 * http://www.apache.org/licenses/LICENSE-2.0 14796 * 14797 * Unless required by applicable law or agreed to in writing, software 14798 * distributed under the License is distributed on an "AS IS" BASIS, 14799 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14800 * See the License for the specific language governing permissions and 14801 * limitations under the License. 14802 * ============================================================================= 14803 */let Tb;function UB(n){Tb=n.wasm.cwrap(ma,null,["number","array","number","number","number","array","number"])}function Hr(n){const{inputs:e,backend:t,attrs:r}=n,[s,a]=GB(e.x.shape,r.perm);let o=!0;for(let m=0;m<a.length;m++)a[m]!==m&&(o=!1);const i=zB(e.x.shape,r.perm),c={dataId:e.x.dataId,shape:s,dtype:e.x.dtype};if(o){const m=sc({inputs:e,backend:t});return m.shape=i,m}const l=t.makeOutput(i,c.dtype),u=t.dataIdMap.get(c.dataId).id,d=t.dataIdMap.get(l.dataId).id,p=new Uint8Array(new Int32Array(a).buffer),h=new Uint8Array(new Int32Array(c.shape).buffer);return Tb(u,h,c.shape.length,Oe[c.dtype],d,p,a.length),l}function zB(n,e){const t=new Array(n.length);for(let r=0;r<t.length;r++)t[r]=n[e[r]];return t}function GB(n,e){const t=[],r=[];for(let s=0;s<n.length;++s)n[s]!==1&&t.push(n[s]),n[e[s]]!==1&&r.push(e[s]);for(let s=0;s<r.length;++s){let a=-1;for(let o=0;o<r.length;++o)r[o]>=s&&(a===-1||r[a]>r[o])&&(a=o);r[a]=s}return[t,r]}const HB={kernelName:ma,backendName:"wasm",kernelFunc:Hr,setupFunc:UB};/** 14804 * @license 14805 * Copyright 2020 Google Inc. All Rights Reserved. 14806 * Licensed under the Apache License, Version 2.0 (the "License"); 14807 * you may not use this file except in compliance with the License. 14808 * You may obtain a copy of the License at 14809 * 14810 * http://www.apache.org/licenses/LICENSE-2.0 14811 * 14812 * Unless required by applicable law or agreed to in writing, software 14813 * distributed under the License is distributed on an "AS IS" BASIS, 14814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14815 * See the License for the specific language governing permissions and 14816 * limitations under the License. 14817 * ============================================================================= 14818 */function Zr(n,e,t){const r=n.shape,s=n.shape.length,a=ot(e,r);let o=a;const i=Xt(o,s);let c=null,l=!1;if(i!=null){const u=new Array(s);for(let h=0;h<u.length;h++)u[h]=r[i[h]];o=St(o.length,s),c=Hr({inputs:{x:n},attrs:{perm:i},backend:t});const d=t.dataIdMap.get(n.dataId).id;t.dataIdMap.get(c.dataId).id!==d&&(l=!0)}return{transposed:c,originalAxes:a,axes:o,inputWasTransposed:l}}/** 14819 * @license 14820 * Copyright 2021 Google LLC. All Rights Reserved. 14821 * Licensed under the Apache License, Version 2.0 (the "License"); 14822 * you may not use this file except in compliance with the License. 14823 * You may obtain a copy of the License at 14824 * 14825 * http://www.apache.org/licenses/LICENSE-2.0 14826 * 14827 * Unless required by applicable law or agreed to in writing, software 14828 * distributed under the License is distributed on an "AS IS" BASIS, 14829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14830 * See the License for the specific language governing permissions and 14831 * limitations under the License. 14832 * ============================================================================= 14833 */let kb;function jB(n){kb=n.wasm.cwrap(Bi,null,["number, number, number"])}
14833function qB(n){const{backend:e,inputs:t,attrs:r}=n,{axis:s,keepDims:a}=r,{x:o}=t;let c=e.dataIdMap.get(o.dataId).id,l=o;const{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Zr(o,s,e);if(h){const $=e.dataIdMap.get(u.dataId).id;l=u,c=$}const m=l.shape.length;ht("all",d,m);const[g,y]=At(l.shape,d),b=H(y),v=e.makeOutput(g,o.dtype);if(H(l.shape)!==0){const $=e.dataIdMap.get(v.dataId).id;kb(c,b,$)}if(h&&e.disposeData(u.dataId),a){const $=pt(v.shape,p);v.shape=$}return v}const KB={kernelName:Bi,backendName:"wasm",setupFunc:jB,kernelFunc:qB};/** 14834 * @license 14835 * Copyright 2021 Google LLC. All Rights Reserved. 14836 * Licensed under the Apache License, Version 2.0 (the "License"); 14837 * you may not use this file except in compliance with the License. 14838 * You may obtain a copy of the License at 14839 * 14840 * http://www.apache.org/licenses/LICENSE-2.0 14841 * 14842 * Unless required by applicable law or agreed to in writing, software 14843 * distributed under the License is distributed on an "AS IS" BASIS, 14844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14845 * See the License for the specific language governing permissions and 14846 * limitations under the License. 14847 * ============================================================================= 14848 */let Eb;function XB(n){Eb=n.wasm.cwrap(Vi,null,["number, number, number"])}function YB(n){const{backend:e,inputs:t,attrs:r}=n,{axis:s,keepDims:a}=r,{x:o}=t;let c=e.dataIdMap.get(o.dataId).id,l=o;const{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Zr(o,s,e);if(h){const $=e.dataIdMap.get(u.dataId).id;l=u,c=$}const m=l.shape.length;ht("any",d,m);const[g,y]=At(l.shape,d),b=H(y),v=e.makeOutput(g,o.dtype);if(H(l.shape)!==0){const $=e.dataIdMap.get(v.dataId).id;Eb(c,b,$)}if(h&&e.disposeData(u.dataId),a){const $=pt(v.shape,p);v.shape=$}return v}const QB={kernelName:Vi,backendName:"wasm",setupFunc:XB,kernelFunc:YB};/** 14849 * @license 14850 * Copyright 2023 Google LLC. 14851 * Licensed under the Apache License, Version 2.0 (the "License"); 14852 * you may not use this file except in compliance with the License. 14853 * You may obtain a copy of the License at 14854 * 14855 * http://www.apache.org/licenses/LICENSE-2.0 14856 * 14857 * Unless required by applicable law or agreed to in writing, software 14858 * distributed under the License is distributed on an "AS IS" BASIS, 14859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14860 * See the License for the specific language governing permissions and 14861 * limitations under the License. 14862 * ============================================================================= 14863 */function Rb(n){let e;function t(s){e=s.wasm.cwrap(n,null,["number","number","number","number","number"])}function r(s){const{backend:a,inputs:o,attrs:i}=s,{axis:c}=i,{x:l}=o,u=a.dataIdMap.get(l.dataId).id;let d=u,p=l;const{transposed:h,axes:m,inputWasTransposed:g}=Zr(l,c,a);if(g){const T=a.dataIdMap.get(h.dataId).id;T!==u&&(p=h,d=T)}const y=p.shape.slice(0,-1),b=a.makeOutput(y,"int32"),v=a.dataIdMap.get(b.dataId).id,$=H(b.shape),S=p.shape[m[0]];return e(d,Oe[p.dtype],$,S,v),g&&a.disposeData(h.dataId),b}return{kernelName:n,backendName:"wasm",setupFunc:t,kernelFunc:r}}/** 14864 * @license 14865 * Copyright 2019 Google LLC. All Rights Reserved. 14866 * Licensed under the Apache License, Version 2.0 (the "License"); 14867 * you may not use this file except in compliance with the License. 14868 * You may obtain a copy of the License at 14869 * 14870 * http://www.apache.org/licenses/LICENSE-2.0 14871 * 14872 * Unless required by applicable law or agreed to in writing, software 14873 * distributed under the License is distributed on an "AS IS" BASIS, 14874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14875 * See the License for the specific language governing permissions and 14876 * limitations under the License. 14877 * ============================================================================= 14878 */const ZB=Rb(kl);/** 14879 * @license 14880 * Copyright 2023 Google LLC. 14881 * Licensed under the Apache License, Version 2.0 (the "License"); 14882 * you may not use this file except in compliance with the License. 14883 * You may obtain a copy of the License at 14884 * 14885 * http://www.apache.org/licenses/LICENSE-2.0 14886 * 14887 * Unless required by applicable law or agreed to in writing, softw
14887are 14888 * distributed under the License is distributed on an "AS IS" BASIS, 14889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14890 * See the License for the specific language governing permissions and 14891 * limitations under the License. 14892 * ============================================================================= 14893 */const JB=Rb(El);/** 14894 * @license 14895 * Copyright 2023 Google LLC. 14896 * Licensed under the Apache License, Version 2.0 (the "License"); 14897 * you may not use this file except in compliance with the License. 14898 * You may obtain a copy of the License at 14899 * 14900 * http://www.apache.org/licenses/LICENSE-2.0 14901 * 14902 * Unless required by applicable law or agreed to in writing, software 14903 * distributed under the License is distributed on an "AS IS" BASIS, 14904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14905 * See the License for the specific language governing permissions and 14906 * limitations under the License. 14907 * ============================================================================= 14908 */const eV=Ae(Rl);/** 14909 * @license 14910 * Copyright 2023 Google LLC. 14911 * Licensed under the Apache License, Version 2.0 (the "License"); 14912 * you may not use this file except in compliance with the License. 14913 * You may obtain a copy of the License at 14914 * 14915 * http://www.apache.org/licenses/LICENSE-2.0 14916 * 14917 * Unless required by applicable law or agreed to in writing, software 14918 * distributed under the License is distributed on an "AS IS" BASIS, 14919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14920 * See the License for the specific language governing permissions and 14921 * limitations under the License. 14922 * ============================================================================= 14923 */const tV=Ae(Al);/** 14924 * @license 14925 * Copyright 2023 Google LLC. 14926 * Licensed under the Apache License, Version 2.0 (the "License"); 14927 * you may not use this file except in compliance with the License. 14928 * You may obtain a copy of the License at 14929 * 14930 * http://www.apache.org/licenses/LICENSE-2.0 14931 * 14932 * Unless required by applicable law or agreed to in writing, software 14933 * distributed under the License is distributed on an "AS IS" BASIS, 14934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14935 * See the License for the specific language governing permissions and 14936 * limitations under the License. 14937 * ============================================================================= 14938 */const nV=Ae(Dl);/** 14939 * @license 14940 * Copyright 2023 Google LLC. 14941 * Licensed under the Apache License, Version 2.0 (the "License"); 14942 * you may not use this file except in compliance with the License. 14943 * You may obtain a copy of the License at 14944 * 14945 * http://www.apache.org/licenses/LICENSE-2.0 14946 * 14947 * Unless required by applicable law or agreed to in writing, software 14948 * distributed under the License is distributed on an "AS IS" BASIS, 14949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14950 * See the License for the specific language governing permissions and 14951 * limitations under the License. 14952 * ============================================================================= 14953 */const rV=lt(Fl);/** 14954 * @license 14955 * Copyright 2023 Google LLC. 14956 * Licensed under the Apache License, Version 2.0 (the "License"); 14957 * you may not use this file except in compliance with the License. 14958 * You may obtain a copy of the License at 14959 * 14960 * http://www.apache.org/licenses/LICENSE-2.0 14961 * 14962 * Unless required by applicable law or agreed to in writing, software 14963 * distributed under the License is distributed on an "AS IS" BASIS, 14964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14965 * See the License for the specific language governing permissions and 14966 * limitations under the License. 14967 * ============================================================================= 14968 */const sV=Ae(Ol);/** 14969 * @license 14970 * Copyright 2019 Google LLC. All Rights Reserved. 14971 * Licensed under the Apache License, Version 2.0 (the "License"); 14972 * you may not use this file except in compliance with the License. 14973 * You may obtain a copy of the License at 14974 * 14975 * http://www.apache.org/licenses/LICENSE-2.0 14976 * 14977 * Unless required by applicable law or agreed to in writing, softw
14977are 14978 * distributed under the License is distributed on an "AS IS" BASIS, 14979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14980 * See the License for the specific language governing permissions and 14981 * limitations under the License. 14982 * ============================================================================= 14983 */let Ab;function aV(n){Ab=n.wasm.cwrap(Wi,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function oV(n){const{inputs:e,attrs:t,backend:r}=n,s=e.x,a=r.dataIdMap.get(s.dataId).id,{filterSize:o,strides:i,pad:c,dimRoundingMode:l}=t,u=kn(s.shape,o,i,1,c,l),d=u.filterHeight,p=u.filterWidth,h=u.padInfo.top,m=u.padInfo.right,g=u.padInfo.bottom,y=u.padInfo.left,b=u.strideHeight,v=u.strideWidth,$=u.inChannels;if(u.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${u.dataFormat}'. Please use 'channelsLast'.`);if(u.dilationWidth!==1||u.dilationHeight!==1)throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${u.dilationHeight}, ${u.dilationWidth}].`);const S=r.makeOutput(u.outShape,"float32"),T=r.dataIdMap.get(S.dataId).id;return Ab(a,s.shape[0],s.shape[1],s.shape[2],d,p,h,m,g,y,b,v,$,T),S}const iV={kernelName:Wi,backendName:"wasm",setupFunc:aV,kernelFunc:oV};/** 14984 * @license 14985 * Copyright 2023 Google LLC. 14986 * Licensed under the Apache License, Version 2.0 (the "License"); 14987 * you may not use this file except in compliance with the License. 14988 * You may obtain a copy of the License at 14989 * 14990 * http://www.apache.org/licenses/LICENSE-2.0 14991 * 14992 * Unless required by applicable law or agreed to in writing, software 14993 * distributed under the License is distributed on an "AS IS" BASIS, 14994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14995 * See the License for the specific language governing permissions and 14996 * limitations under the License. 14997 * ============================================================================= 14998 */let Db;function uV(n){Db=n.wasm.cwrap("AvgPool3D",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function cV(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:a,strides:o,pad:i,dimRoundingMode:c,dataFormat:l}=r,u=Ir(s.shape,a,o,1,i,c,l),d=t.makeOutput(u.outShape,s.dtype);return Db(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(d.dataId).id,u.batchSize,u.inChannels,u.inDepth,u.inHeight,u.inWidth,u.outDepth,u.outHeight,u.outWidth,u.strideDepth,u.strideHeight,u.strideWidth,u.dilationDepth,u.dilationHeight,u.dilationWidth,u.effectiveFilterDepth,u.effectiveFilterHeight,u.effectiveFilterWidth,u.padInfo.front,u.padInfo.top,u.padInfo.left),d}const lV={kernelName:Pl,backendName:"wasm",setupFunc:uV,kernelFunc:cV};/** 14999 * @license 15000 * Copyright 2023 Google LLC. 15001 * Licensed under the Apache License, Version 2.0 (the "License"); 15002 * you may not use this file except in compliance with the License. 15003 * You may obtain a copy of the License at 15004 * 15005 * http://www.apache.org/licenses/LICENSE-2.0 15006 * 15007 * Unless required by applicable law or agreed to in writing, software 15008 * distributed under the License is distributed on an "AS IS" BASIS, 15009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15010 * See the License for the specific language governing permissions and 15011 * limitations under the License. 15012 * ============================================================================= 15013 */let Ob;function dV(n){Ob=n.wasm.cwrap("AvgPool3DGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function pV(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a}=e,{filterSize:o,strides:i,pad:c,dimRoundingMode:l}=r,u=Ir(a.shape,o,i,1,c,l),d=t.makeOutput(a.shape,a.dtype);return Ob(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(d.dataId).id,u.batchSize,u.inChannels,u.inDepth,u.inHeight,u.inWidth,u.outDepth,u.outHeight,u.outWidth,u.strideDepth,u.strideHeight,u.strideWidth,u.dilationDepth,u.dilationHeight,u.dilationWidth,u.effectiveFilterDepth,u.effectiveFilterHeight,u.effectiveFilterWidth,u.padInfo.front,u.padInfo.top,u.padInfo.left,u.filterDepth,u.filterHeight,u.filterWidth),d}const hV={kernelName:Yf,backendName:"wasm",setupFunc:dV,kernelFunc:pV};/** 15014 * @license 15015 * Copyright 2023 Google LLC. 15016 * Licensed under the Apache License, Version 2.0 (the "License");
15017 * you may not use this file except in compliance with the License. 15018 * You may obtain a copy of the License at 15019 * 15020 * http://www.apache.org/licenses/LICENSE-2.0 15021 * 15022 * Unless required by applicable law or agreed to in writing, software 15023 * distributed under the License is distributed on an "AS IS" BASIS, 15024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15025 * See the License for the specific language governing permissions and 15026 * limitations under the License. 15027 * ============================================================================= 15028 */let Fb;function fV(n){Fb=n.wasm.cwrap("AvgPoolGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function mV(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a}=e,{filterSize:o,strides:i,pad:c}=r,l=kn(a.shape,o,i,1,c),u=t.makeOutput(a.shape,a.dtype);return Fb(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(u.dataId).id,l.batchSize,l.inChannels,l.inHeight,l.inWidth,l.outHeight,l.outWidth,l.strideHeight,l.strideWidth,l.dilationHeight,l.dilationWidth,l.effectiveFilterHeight,l.effectiveFilterWidth,l.padInfo.top,l.padInfo.left,l.filterHeight,l.filterWidth),u}const gV={kernelName:Xf,backendName:"wasm",setupFunc:fV,kernelFunc:mV};/** 15029 * @license 15030 * Copyright 2019 Google LLC. All Rights Reserved. 15031 * Licensed under the Apache License, Version 2.0 (the "License"); 15032 * you may not use this file except in compliance with the License. 15033 * You may obtain a copy of the License at 15034 * 15035 * http://www.apache.org/licenses/LICENSE-2.0 15036 * 15037 * Unless required by applicable law or agreed to in writing, software 15038 * distributed under the License is distributed on an "AS IS" BASIS, 15039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15040 * See the License for the specific language governing permissions and 15041 * limitations under the License. 15042 * ============================================================================= 15043 */function jt(n){const{inputs:e,attrs:t}=n,{x:r}=e,{shape:s}=t,a=H(r.shape),o=Gf(s,a);return N(a===H(o),()=>`new shape: ${o}, old shape: ${r.shape}. New shape and old shape must have the same number of elements.`),n.backend.incRef(r.dataId),{dataId:r.dataId,shape:o,dtype:r.dtype}}const yV={kernelName:Ad,backendName:"wasm",kernelFunc:jt};/** 15044 * @license 15045 * Copyright 2019 Google LLC. All Rights Reserved. 15046 * Licensed under the Apache License, Version 2.0 (the "License"); 15047 * you may not use this file except in compliance with the License. 15048 * You may obtain a copy of the License at 15049 * 15050 * http://www.apache.org/licenses/LICENSE-2.0 15051 * 15052 * Unless required by applicable law or agreed to in writing, software 15053 * distributed under the License is distributed on an "AS IS" BASIS, 15054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15055 * See the License for the specific language governing permissions and 15056 * limitations under the License. 15057 * ============================================================================= 15058 */let Pb;function bV(n){Pb=n.wasm.cwrap(Ui,null,["number","array","number","number","array","number","number","number","number"])}function xV(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:a}=e,{transposeA:o,transposeB:i}=r;if(s.dtype!=="float32"||a.dtype!=="float32")throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");const c=s.shape.length,l=a.shape.length,u=o?s.shape[c-2]:s.shape[c-1],d=i?a.shape[l-1]:a.shape[l-2],p=o?s.shape[c-1]:s.shape[c-2],h=i?a.shape[l-2]:a.shape[l-1],m=s.shape.slice(0,-2),g=a.shape.slice(0,-2),y=H(m),b=H(g),$=ke(s.shape.slice(0,-2),a.shape.slice(0,-2)).concat([p,h]);N(u===d,()=>`Error in matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${s.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);const S=o?[y,u,p]:[y,p,u],T=i?[b,h,d]:[b,d,h],O=jt({inputs:{x:s},backend:t,attrs:{shape:S}}),L=jt({inputs:{x:a},backend:t,attrs:{shape:T}}),M=t.dataIdMap.get(O.dataId).id,W=t.dataIdMap.get(L.dataId).id,V=o?O.shape[2]:O.shape[1],G=i?L.shape[1]:L.shape[2],K=Math.max(y,b),J=t.makeOutput([K,V,G],O.dtype),ue=t.dataIdMap.get(J.dataId).id,se=new Uint8Array(new Int32Array(O.shape).buffer),fe=new Uint8Array(new Int32Array(L.shape).buffer);return Pb(M,se,O.shape.length,W,fe,L.shape.length,o,i,ue),t.disposeData(O.dataId),t.dis
vendor: 4,490 bytes, lines 15058-15106
15058poseData(L.dataId),J.shape=$,J}const wV={kernelName:Ui,backendName:"wasm",setupFunc:bV,kernelFunc:xV};/** 15059 * @license 15060 * Copyright 2019 Google LLC. All Rights Reserved. 15061 * Licensed under the Apache License, Version 2.0 (the "License"); 15062 * you may not use this file except in compliance with the License. 15063 * You may obtain a copy of the License at 15064 * 15065 * http://www.apache.org/licenses/LICENSE-2.0 15066 * 15067 * Unless required by applicable law or agreed to in writing, software 15068 * distributed under the License is distributed on an "AS IS" BASIS, 15069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15070 * See the License for the specific language governing permissions and 15071 * limitations under the License. 15072 * ============================================================================= 15073 */function Os(n){const{inputs:{x:e},attrs:{begin:t,size:r},backend:s}=n,[a,o]=kp(e,t,r),i=Yu(e.shape,a,o),c=s.readSync(e.dataId),l=s.makeOutput(o,e.dtype),u=Be(e.shape),d=s.dataIdMap.get(l.dataId);if(i){const m=Qu(a,u);return e.dtype==="string"?d.stringBytes=c.slice(m,m+H(o)):s.typedArrayFromHeap(l).set(c.subarray(m,m+H(o))),l}if(e.dtype==="string"){const m=tl(c,a,o,e.shape,e.dtype);return d.stringBytes=m,l}const p=s.typedArrayFromHeap(l),h=e.shape.length;if(h===2)vV(c,u[0],p,a,o);else if(h===3)IV(c,u[0],u[1],p,a,o);else if(h===4)$V(c,u[0],u[1],u[2],p,a,o);else{const m=tl(c,a,o,e.shape,e.dtype);p.set(m)}return l}function vV(n,e,t,r,s){let a=0;const o=r[0],i=r[1],c=o+s[0];for(let l=o;l<c;l++){const u=l*e+i;t.set(n.subarray(u,u+s[1]),a),a+=s[1]}}function IV(n,e,t,r,s,a){let o=0;const i=s[0],c=s[1],l=s[2],u=i+a[0],d=c+a[1];for(let p=i;p<u;p++)for(let h=c;h<d;h++){const m=p*e+h*t+l;r.set(n.subarray(m,m+a[2]),o),o+=a[2]}}function $V(n,e,t,r,s,a,o){let i=0;const c=a[0],l=a[1],u=a[2],d=c+o[0],p=l+o[1],h=u+o[2],m=a[3];for(let g=c;g<d;g++)for(let y=l;y<p;y++)for(let b=u;b<h;b++){const v=g*e+y*t+b*r+m;s.set(n.subarray(v,v+o[3]),i),i+=o[3]}}const SV={kernelName:Vd,backendName:"wasm",kernelFunc:Os};/** 15074 * @license 15075 * Copyright 2021 Google LLC. All Rights Reserved. 15076 * Licensed under the Apache License, Version 2.0 (the "License"); 15077 * you may not use this file except in compliance with the License. 15078 * You may obtain a copy of the License at 15079 * 15080 * http://www.apache.org/licenses/LICENSE-2.0 15081 * 15082 * Unless required by applicable law or agreed to in writing, software 15083 * distributed under the License is distributed on an "AS IS" BASIS, 15084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15085 * See the License for the specific language governing permissions and 15086 * limitations under the License. 15087 * ============================================================================= 15088 */function CV(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockShape:a,crops:o}=r,i=a.reduce((b,v)=>b*v),c=Ao(s.shape,a,i),l=Do(c.length,a.length),u=Oo(s.shape,a,i),d=Op(o,a.length),p=Fp(u,o,a.length),h=jt({inputs:{x:s},backend:t,attrs:{shape:c}}),m=Hr({inputs:{x:h},backend:t,attrs:{perm:l}}),g=jt({inputs:{x:m},backend:t,attrs:{shape:u}}),y=Os({inputs:{x:g},backend:t,attrs:{begin:d,size:p}});return t.disposeData(h.dataId),t.disposeData(m.dataId),t.disposeData(g.dataId),y}const _V={kernelName:Ll,backendName:"wasm",kernelFunc:CV};/** 15089 * @license 15090 * Copyright 2023 Google LLC. 15091 * Licensed under the Apache License, Version 2.0 (the "License"); 15092 * you may not use this file except in compliance with the License. 15093 * You may obtain a copy of the License at 15094 * 15095 * http://www.apache.org/licenses/LICENSE-2.0 15096 * 15097 * Unless required by applicable law or agreed to in writing, software 15098 * distributed under the License is distributed on an "AS IS" BASIS, 15099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15100 * See the License for the specific language governing permissions and 15101 * limitations under the License. 15102 * ============================================================================= 15103 */let Lb;function NV(n){Lb=n.wasm.cwrap(zi,null,["number","number","boolean","number","number","number"])}function TV(n){const{backend:e,inputs:t,attrs:r}=n,{x:s,weights:a}=t,{size:o}=r,i=a.shape.reduce((d,p)=>d*p,1)!==0,c=s.shape.length===1?[o]:[s.shape[0],o],l=e.makeOutput(c,a.dtype);function u(d){return e.dataIdMap.get(d.dataId).id}return Lb(u(s),o,i,u(a),Oe[a.dtype],u(l)),l}const kV={kernelName:zi,backendName:"wasm",setupFunc:NV,kernelFunc:TV};/** 15104 * @license 15105 * Copyright 2023 Google LLC. 15106 * Licensed under the Apache License, Version 2.0 (the "License");
15107 * you may not use this file except in compliance with the License. 15108 * You may obtain a copy of the License at 15109 * 15110 * http://www.apache.org/licenses/LICENSE-2.0 15111 * 15112 * Unless required by applicable law or agreed to in writing, software 15113 * distributed under the License is distributed on an "AS IS" BASIS, 15114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15115 * See the License for the specific language governing permissions and 15116 * limitations under the License. 15117 * ============================================================================= 15118 */const EV=lt(Ml);/** 15119 * @license 15120 * Copyright 2023 Google LLC. 15121 * Licensed under the Apache License, Version 2.0 (the "License"); 15122 * you may not use this file except in compliance with the License. 15123 * You may obtain a copy of the License at 15124 * 15125 * http://www.apache.org/licenses/LICENSE-2.0 15126 * 15127 * Unless required by applicable law or agreed to in writing, software 15128 * distributed under the License is distributed on an "AS IS" BASIS, 15129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15130 * See the License for the specific language governing permissions and 15131 * limitations under the License. 15132 * ============================================================================= 15133 */function RV(n){const{inputs:e,backend:t}=n,{s0:r,s1:s}=e,a=t.typedArrayFromHeap(r),o=t.typedArrayFromHeap(s),i=ke(Array.from(a),Array.from(o));return t.makeOutput([i.length],"int32",void 0,new Int32Array(i))}const AV={kernelName:Bl,backendName:"wasm",kernelFunc:RV};/** 15134 * @license 15135 * Copyright 2019 Google LLC. All Rights Reserved. 15136 * Licensed under the Apache License, Version 2.0 (the "License"); 15137 * you may not use this file except in compliance with the License. 15138 * You may obtain a copy of the License at 15139 * 15140 * http://www.apache.org/licenses/LICENSE-2.0 15141 * 15142 * Unless required by applicable law or agreed to in writing, software 15143 * distributed under the License is distributed on an "AS IS" BASIS, 15144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15145 * See the License for the specific language governing permissions and 15146 * limitations under the License. 15147 * ============================================================================= 15148 */function Jr(n){const{inputs:{x:e},attrs:{dtype:t},backend:r}=n,s=r.makeOutput(e.shape,t),a=r.typedArrayFromHeap(e);return r.typedArrayFromHeap(s).set(a),s}const DV={kernelName:Gi,backendName:"wasm",kernelFunc:Jr};/** 15149 * @license 15150 * Copyright 2021 Google LLC. All Rights Reserved. 15151 * Licensed under the Apache License, Version 2.0 (the "License"); 15152 * you may not use this file except in compliance with the License. 15153 * You may obtain a copy of the License at 15154 * 15155 * http://www.apache.org/licenses/LICENSE-2.0 15156 * 15157 * Unless required by applicable law or agreed to in writing, software 15158 * distributed under the License is distributed on an "AS IS" BASIS, 15159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15160 * See the License for the specific language governing permissions and 15161 * limitations under the License. 15162 * =============================================================================
15163 */const OV=Ae(Vl);/** 15164 * @license 15165 * Copyright 2019 Google LLC. All Rights Reserved. 15166 * Licensed under the Apache License, Version 2.0 (the "License"); 15167 * you may not use this file except in compliance with the License. 15168 * You may obtain a copy of the License at 15169 * 15170 * http://www.apache.org/licenses/LICENSE-2.0 15171 * 15172 * Unless required by applicable law or agreed to in writing, software 15173 * distributed under the License is distributed on an "AS IS" BASIS, 15174 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15175 * See the License for the specific language governing permissions and 15176 * limitations under the License. 15177 * ============================================================================= 15178 */let Mb;function FV(n){Mb=n.wasm.cwrap(Hi,null,["number","number","number","number"])}function PV(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{clipValueMin:a,clipValueMax:o}=r,i=t.dataIdMap.get(s.dataId).id,c=t.makeOutput(s.shape,s.dtype),l=t.dataIdMap.get(c.dataId).id;return Mb(i,a,o,l),c}const LV={kernelName:Hi,backendName:"wasm",setupFunc:FV,kernelFunc:PV};/** 15179 * @license 15180 * Copyright 2019 Google LLC. All Rights Reserved. 15181 * Licensed under the Apache License, Version 2.0 (the "License"); 15182 * you may not use this file except in compliance with the License. 15183 * You may obtain a copy of the License at 15184 * 15185 * http://www.apache.org/licenses/LICENSE-2.0 15186 * 15187 * Unless required by applicable law or agreed to in writing, software 15188 * distributed under the License is distributed on an "AS IS" BASIS, 15189 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15190 * See the License for the specific language governing permissions and 15191 * limitations under the License. 15192 * ============================================================================= 15193 */function Bb(n){const{inputs:e,backend:t}=n,r=ot(n.attrs.axis,e[0].shape)[0],s=e.map(h=>h.shape);Rp(s,r);let a=or(e.map(h=>h.shape),r);const o=e.filter(h=>H(h.shape)>0);
15193if(o.length===1)return sc({inputs:{x:o[0]},backend:t});const i=t.makeOutput(a,e[0].dtype);if(H(a)===0)return i;if(o[0].dtype==="string"){const h=o.map($=>{const T=[-1,H($.shape.slice(r))];return jt({inputs:{x:$},backend:t,attrs:{shape:T}})}),m=h.map($=>({vals:t.readSync($.dataId),shape:$.shape}));a=or(h.map($=>$.shape),1);const g=h[0].shape[0]===1,y=My(m,a,e[0].dtype,g),b=or(o.map($=>$.shape),r);i.shape=b;const v=t.dataIdMap.get(i.dataId);return v.stringBytes=Xp(y),h.forEach($=>t.disposeData($.dataId)),i}const c=H(o[0].shape.slice(0,r));let l=0;const u=o.map(h=>{const m=H(h.shape.slice(r));return l+=m,m}),d=o.map(h=>t.typedArrayFromHeap(h)),p=t.typedArrayFromHeap(i);for(let h=0;h<c;h++){let m=h*l;for(let g=0;g<d.length;g++){const y=u[g],b=h*y,v=d[g].subarray(b,b+y);p.set(v,m),m+=y}}return i}const MV={kernelName:Wl,backendName:"wasm",kernelFunc:Bb};/** 15194 * @license 15195 * Copyright 2019 Google LLC. All Rights Reserved. 15196 * Licensed under the Apache License, Version 2.0 (the "License"); 15197 * you may not use this file except in compliance with the License. 15198 * You may obtain a copy of the License at 15199 * 15200 * http://www.apache.org/licenses/LICENSE-2.0 15201 * 15202 * Unless required by applicable law or agreed to in writing, software 15203 * distributed under the License is distributed on an "AS IS" BASIS, 15204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15205 * See the License for the specific language governing permissions and 15206 * limitations under the License. 15207 * ============================================================================= 15208 */let Vb;function BV(n){Vb=n.wasm.cwrap(ji,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function VV(n){const{inputs:e,attrs:t,backend:r}=n,{x:s,filter:a}=e,o=r.dataIdMap.get(s.dataId).id,i=r.dataIdMap.get(a.dataId).id,{strides:c,dilations:l,pad:u,dimRoundingMode:d,dataFormat:p}=t,h=Yr(p),m=$t(s.shape,a.shape,c,l,u,d,!1,h),g=m.filterHeight,y=m.filterWidth,b=m.padInfo.top,v=m.padInfo.right,$=m.padInfo.bottom,S=m.padInfo.left,T=m.dilationHeight,O=m.dilationWidth,L=m.strideHeight,M=m.strideWidth,W=m.inChannels,V=m.outChannels,G=m.padInfo.type==="SAME"?1:0;if(m.dataFormat!=="channelsLast")throw new Error(`wasm backend Conv2D does not support dataFormat:'${m.dataFormat}'. Please use 'channelsLast'.`);const K=r.makeOutput(m.outShape,"float32"),J=r.dataIdMap.get(K.dataId).id;return Vb(o,s.shape[0],s.shape[1],s.shape[2],i,g,y,b,v,$,S,G,T,O,L,M,W,V,J),K}const WV={kernelName:ji,backendName:"wasm",setupFunc:BV,kernelFunc:VV};/** 15209 * @license 15210 * Copyright 2020 Google LLC. All Rights Reserved. 15211 * Licensed under the Apache License, Version 2.0 (the "License"); 15212 * you may not use this file except in compliance with the License. 15213 * You may obtain a copy of the License at 15214 * 15215 * http://www.apache.org/licenses/LICENSE-2.0 15216 * 15217 * Unless required by applicable law or agreed to in writing, software 15218 * distributed under the License is distributed on an "AS IS" BASIS, 15219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15220 * See the License for the specific language governing permissions and 15221 * limitations under the License. 15222 * ============================================================================= 15223 */let Wb;function UV(n){Wb=n.wasm.cwrap(qi,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function zV(n){const{backend:e,inputs:t,attrs:r}=n,{dy:s,filter:a}=t,{strides:o,pad:i,dataFormat:c,dimRoundingMode:l,inputShape:u}=r,d=1,p=Yr(c),h=$t(u,a.shape,o,d,i,l,!1,p),{batchSize:m,filterHeight:g,filterWidth:y,inChannels:b,inHeight:v,inWidth:$,outChannels:S,outHeight:T,outWidth:O,strideHeight:L,strideWidth:M}=h,W=g-1-h.padInfo.top,V=y-1-h.padInfo.left,G=h.dataFormat==="channelsLast",K=Be(h.inShape),J=Be(s.shape),[ue,se,fe]=Be(a.shape),Ie=K[0],pe=G?K[1]:K[2],Fe=G?K[2]:1,Qe=G?1:K[1],it=J[0],Nt=G?J[1]:J[2],He=G?J[2]:1,An=G?1:J[1],on=e.makeOutput(h.inShape,"float32"),Dn=e.dataIdMap.get(on.dataId).id,es=e.dataIdMap.get(s.dataId).id,Ze=e.dataIdMap.get(a.dataId).id;return Wb(es,Ze,m,g,y,v,$,b,T,O,S,L,M,W,V,ue,se,fe,Ie,pe,Fe,Qe,it,Nt,He,An,Dn),on}const GV={kernelName:qi,backendName:"wasm",setupFunc:UV,kernelFunc:zV};/** 15224 * @license 15225 * Copyright 2023 Google LLC. 15226 * Licensed under the Apache License, Version 2.0 (the "License");
15227 * you may not use this file except in compliance with the License. 15228 * You may obtain a copy of the License at 15229 * 15230 * http://www.apache.org/licenses/LICENSE-2.0 15231 * 15232 * Unless required by applicable law or agreed to in writing, software 15233 * distributed under the License is distributed on an "AS IS" BASIS, 15234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15235 * See the License for the specific language governing permissions and 15236 * limitations under the License. 15237 * ============================================================================= 15238 */let Ub;function HV(n){Ub=n.wasm.cwrap(Ki,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function jV(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a}=e,{strides:o,pad:i,dilations:c}=r;if(s.dtype!=="float32")throw new Error(`Tensor x must have dtype float32, got ${s.dtype}`);if(a.dtype!=="float32")throw new Error(`Tensor filter must have dtype float32, got ${a.dtype}`);const l=Xr(s.shape,a.shape,o,c,i),u=t.makeOutput(l.outShape,s.dtype);return Ub(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(u.dataId).id,l.batchSize,l.inDepth,l.inHeight,l.inWidth,l.inChannels,l.outDepth,l.outHeight,l.outWidth,l.outChannels,l.strideDepth,l.strideHeight,l.strideWidth,l.dilationDepth,l.dilationHeight,l.dilationWidth,l.filterDepth,l.filterHeight,l.filterWidth,l.padInfo.front,l.padInfo.top,l.padInfo.left),u}const qV={kernelName:Ki,backendName:"wasm",setupFunc:HV,kernelFunc:jV};/** 15239 * @license 15240 * Copyright 2023 Google LLC. 15241 * Licensed under the Apache License, Version 2.0 (the "License"); 15242 * you may not use this file except in compliance with the License. 15243 * You may obtain a copy of the License at 15244 * 15245 * http://www.apache.org/licenses/LICENSE-2.0 15246 * 15247 * Unless required by applicable law or agreed to in writing, software 15248 * distributed under the License is distributed on an "AS IS" BASIS, 15249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15250 * See the License for the specific language governing permissions and 15251 * limitations under the License. 15252 * ============================================================================= 15253 */let zb;function KV(n){zb=n.wasm.cwrap(Ul,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function XV(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:a}=e,{strides:o,pad:i,filterShape:c}=r;if(s.dtype!=="float32")throw new Error(`Tensor dy must have dtype float32, got ${s.dtype}`);if(a.dtype!=="float32")throw new Error(`Tensor filter must have dtype float32, got ${a.dtype}`);const l=Xr(s.shape,c,o,1,i),u=t.makeOutput(l.filterShape,a.dtype);return zb(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(u.dataId).id,l.batchSize,l.inDepth,l.inHeight,l.inWidth,l.inChannels,l.outDepth,l.outHeight,l.outWidth,l.outChannels,l.strideDepth,l.strideHeight,l.strideWidth,l.dilationDepth,l.dilationHeight,l.dilationWidth,l.filterDepth,l.filterHeight,l.filterWidth,l.padInfo.front,l.padInfo.top,l.padInfo.left),u}const YV={kernelName:Ul,backendName:"wasm",setupFunc:KV,kernelFunc:XV};/** 15254 * @license 15255 * Copyright 2023 Google LLC. 15256 * Licensed under the Apache License, Version 2.0 (the "License"); 15257 * you may not use this file except in compliance with the License. 15258 * You may obtain a copy of the License at 15259 * 15260 * http://www.apache.org/licenses/LICENSE-2.0 15261 * 15262 * Unless required by applicable law or agreed to in writing, software 15263 * distributed under the License is distributed on an "AS IS" BASIS, 15264 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15265 * See the License for the specific language governing permissions and 15266 * limitations under the License. 15267 * ============================================================================= 15268 */let Gb;function QV(n){Gb=n.wasm.cwrap(Xi,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function ZV(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:a}
vendor: 4,099 bytes, lines 15268-15322
15268=e,{pad:o,strides:i,inputShape:c}=r;if(s.dtype!=="float32")throw new Error(`Tensor dy must have dtype float32, got ${s.dtype}`);if(a.dtype!=="float32")throw new Error(`Tensor filter must have dtype float32, got ${a.dtype}`);const l=Xr(c,a.shape,i,1,o),u=t.makeOutput(l.inShape,s.dtype);return Gb(t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(u.dataId).id,l.batchSize,l.inDepth,l.inHeight,l.inWidth,l.inChannels,l.outDepth,l.outHeight,l.outWidth,l.outChannels,l.strideDepth,l.strideHeight,l.strideWidth,l.dilationDepth,l.dilationHeight,l.dilationWidth,l.filterDepth,l.filterHeight,l.filterWidth,l.padInfo.front,l.padInfo.top,l.padInfo.left),u}const JV={kernelName:Xi,backendName:"wasm",setupFunc:QV,kernelFunc:ZV};/** 15269 * @license 15270 * Copyright 2019 Google LLC. All Rights Reserved. 15271 * Licensed under the Apache License, Version 2.0 (the "License"); 15272 * you may not use this file except in compliance with the License. 15273 * You may obtain a copy of the License at 15274 * 15275 * http://www.apache.org/licenses/LICENSE-2.0 15276 * 15277 * Unless required by applicable law or agreed to in writing, software 15278 * distributed under the License is distributed on an "AS IS" BASIS, 15279 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15280 * See the License for the specific language governing permissions and 15281 * limitations under the License. 15282 * ============================================================================= 15283 */const e4=Ae(zl);/** 15284 * @license 15285 * Copyright 2021 Google LLC. All Rights Reserved. 15286 * Licensed under the Apache License, Version 2.0 (the "License"); 15287 * you may not use this file except in compliance with the License. 15288 * You may obtain a copy of the License at 15289 * 15290 * http://www.apache.org/licenses/LICENSE-2.0 15291 * 15292 * Unless required by applicable law or agreed to in writing, software 15293 * distributed under the License is distributed on an "AS IS" BASIS, 15294 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15295 * See the License for the specific language governing permissions and 15296 * limitations under the License. 15297 * ============================================================================= 15298 */const t4=Ae(Gl);/** 15299 * @license 15300 * Copyright 2019 Google LLC. All Rights Reserved. 15301 * Licensed under the Apache License, Version 2.0 (the "License"); 15302 * you may not use this file except in compliance with the License. 15303 * You may obtain a copy of the License at 15304 * 15305 * http://www.apache.org/licenses/LICENSE-2.0 15306 * 15307 * Unless required by applicable law or agreed to in writing, software 15308 * distributed under the License is distributed on an "AS IS" BASIS, 15309 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15310 * See the License for the specific language governing permissions and 15311 * limitations under the License. 15312 * ============================================================================= 15313 */var al;(function(n){n[n.bilinear=0]="bilinear",n[n.nearest=1]="nearest"})(al||(al={}));let Hb;function n4(n){Hb=n.wasm.cwrap(Zi,null,["number","number","number","number","array","number","number","number","number","number"])}function r4(n){const{backend:e,inputs:t,attrs:r}=n,{method:s,extrapolationValue:a,cropSize:o}=r,{image:i,boxes:c,boxInd:l}=t,u=c.shape[0],[d,p]=o,h=[u,d,p,i.shape[3]];let m=e.dataIdMap.get(i.dataId),g;i.dtype!=="float32"&&(g=Jr({backend:e,inputs:{x:i},attrs:{dtype:"float32"}}),m=e.dataIdMap.get(g.dataId));const y=m.id,b=e.dataIdMap.get(c.dataId).id,v=e.dataIdMap.get(l.dataId).id,$=e.makeOutput(h,"float32"),S=e.dataIdMap.get($.dataId).id,T=new Uint8Array(new Int32Array(i.shape).buffer);return Hb(y,b,v,u,T,d,p,al[s],a,S),g!=null&&e.disposeData(g.dataId),$}const s4={kernelName:Zi,backendName:"wasm",setupFunc:n4,kernelFunc:r4};/** 15314 * @license 15315 * Copyright 2022 Google LLC. All Rights Reserved. 15316 * Licensed under the Apache License, Version 2.0 (the "License"); 15317 * you may not use this file except in compliance with the License. 15318 * You may obtain a copy of the License at 15319 * 15320 * http://www.apache.org/licenses/LICENSE-2.0 15321 * 15322 * Unless required by applicable law or agreed to in writing, softw
15322are 15323 * distributed under the License is distributed on an "AS IS" BASIS, 15324 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15325 * See the License for the specific language governing permissions and 15326 * limitations under the License. 15327 * ============================================================================= 15328 */let jb;function a4(n){jb=n.wasm.cwrap(Yi,null,["number","number","number","number","number","number"])}function o4(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,exclusive:o,reverse:i}=r,c=s.shape.length;N(s.dtype==="float32"||s.dtype==="int32",()=>`cumprod does not support ${s.dtype} tensors in the WASM backend`);const l=Xt([a],c);let u=s;l!==null&&(u=Hr({inputs:{x:s},attrs:{perm:l},backend:t}));const d=St(1,c)[0];ht("cumprod",[d],c);const p=t.makeOutput(u.shape,u.dtype),h=u.shape[d],m=t.dataIdMap.get(u.dataId).id,g=t.dataIdMap.get(p.dataId).id;jb(m,o?1:0,i?1:0,h,g,Oe[s.dtype]);let y=p;if(l!==null){const b=Eo(l);y=Hr({inputs:{x:p},attrs:{perm:b},backend:t}),t.disposeData(u.dataId),t.disposeData(p.dataId)}return y}const i4={kernelName:Yi,backendName:"wasm",setupFunc:a4,kernelFunc:o4};/** 15329 * @license 15330 * Copyright 2020 Google LLC. All Rights Reserved. 15331 * Licensed under the Apache License, Version 2.0 (the "License"); 15332 * you may not use this file except in compliance with the License. 15333 * You may obtain a copy of the License at 15334 * 15335 * http://www.apache.org/licenses/LICENSE-2.0 15336 * 15337 * Unless required by applicable law or agreed to in writing, software 15338 * distributed under the License is distributed on an "AS IS" BASIS, 15339 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15340 * See the License for the specific language governing permissions and 15341 * limitations under the License. 15342 * ============================================================================= 15343 */let qb;function u4(n){qb=n.wasm.cwrap(Qi,null,["number","number","number","number","number","number"])}function c4(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:a,exclusive:o,reverse:i}=r,c=s.shape.length;N(s.dtype==="float32"||s.dtype==="int32",()=>`cumsum does not support ${s.dtype} tensors in the WASM backend`);const l=Xt([a],c);let u=s;l!==null&&(u=Hr({inputs:{x:s},attrs:{perm:l},backend:t}));const d=St(1,c)[0];ht("cumsum",[d],c);const p=t.makeOutput(u.shape,u.dtype),h=u.shape[d],m=t.dataIdMap.get(u.dataId).id,g=t.dataIdMap.get(p.dataId).id;qb(m,o?1:0,i?1:0,h,g,Oe[s.dtype]);let y=p;if(l!==null){const b=Eo(l);y=Hr({inputs:{x:p},attrs:{perm:b},backend:t}),t.disposeData(u.dataId),t.disposeData(p.dataId)}return y}const l4={kernelName:Qi,backendName:"wasm",setupFunc:u4,kernelFunc:c4};/** 15344 * @license 15345 * Copyright 2023 Google LLC. 15346 * Licensed under the Apache License, Version 2.0 (the "License"); 15347 * you may not use this file except in compliance with the License. 15348 * You may obtain a copy of the License at 15349 * 15350 * http://www.apache.org/licenses/LICENSE-2.0 15351 * 15352 * Unless required by applicable law or agreed to in writing, software 15353 * distributed under the License is distributed on an "AS IS" BASIS, 15354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15355 * See the License for the specific language governing permissions and 15356 * limitations under the License. 15357 * ============================================================================= 15358 */let Kb;function d4(n){Kb=n.wasm.cwrap("DenseBincount",null,["number","array","number","number","boolean","number","number","boolean","number"])}function p4(n){const{backend:e,inputs:t,attrs:r}=n,{x:s,weights:a}=t,{size:o,binaryOutput:i}=r,c=a.shape.reduce((p,h)=>p*h,1)!==0,l=s.shape.length===1?[o]:[s.shape[0],o],u=e.makeOutput(l,a.dtype);function d(p){return e.dataIdMap.get(p.dataId).id}return Kb(d(s),new Uint8Array(new Int32Array(s.shape).buffer),s.shape.length,o,c,d(a),Oe[a.dtype],i,d(u)),u}const h4={kernelName:Hl,backendName:"wasm",setupFunc:d4,kernelFunc:p4};/** 15359 * @license 15360 * Copyright 2019 Google LLC. All Rights Reserved. 15361 * Licensed under the Apache License, Version 2.0 (the "License"); 15362 * you may not use this file except in compliance with the License. 15363 * You may obtain a copy of the License at 15364 * 15365 * http://www.apache.org/licenses/LICENSE-2.0 15366 * 15367 * Unless required by applicable law or agreed to in writing, softw
15367are 15368 * distributed under the License is distributed on an "AS IS" BASIS, 15369 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15370 * See the License for the specific language governing permissions and 15371 * limitations under the License. 15372 * ============================================================================= 15373 */let Xb;function f4(n){Xb=n.wasm.cwrap(Ji,null,["number","number","number","array","number","array","array","number","number"])}function m4(n){const{backend:e,inputs:t,attrs:r}=n,{x:s}=t,{blockSize:a,dataFormat:o}=r,i=s.shape[0],c=o==="NHWC"?s.shape[1]:s.shape[2],l=o==="NHWC"?s.shape[2]:s.shape[3],u=o==="NHWC"?s.shape[3]:s.shape[1],d=c*a,p=l*a,h=u/(a*a),m=o==="NHWC"?[i,d,p,h]:[i,h,d,p],g=e.makeOutput(m,"float32"),b=e.dataIdMap.get(s.dataId).id,v=new Uint8Array(new Int32Array(Be(s.shape)).buffer),$=new Uint8Array(new Int32Array(m).buffer),S=new Uint8Array(new Int32Array(Be(m)).buffer),T=e.dataIdMap.get(g.dataId).id;return Xb(b,a,o==="NHWC"?1:0,v,s.shape.length-1,$,S,m.length,T),g}const g4={kernelName:Ji,backendName:"wasm",setupFunc:f4,kernelFunc:m4};/** 15374 * @license 15375 * Copyright 2019 Google LLC. All Rights Reserved. 15376 * Licensed under the Apache License, Version 2.0 (the "License"); 15377 * you may not use this file except in compliance with the License. 15378 * You may obtain a copy of the License at 15379 * 15380 * http://www.apache.org/licenses/LICENSE-2.0 15381 * 15382 * Unless required by applicable law or agreed to in writing, software 15383 * distributed under the License is distributed on an "AS IS" BASIS, 15384 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15385 * See the License for the specific language governing permissions and 15386 * limitations under the License. 15387 * ============================================================================= 15388 */let Yb;function y4(n){Yb=n.wasm.cwrap(eu,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function b4(n){const{inputs:e,attrs:t,backend:r}=n,{x:s,filter:a}=e,o=r.dataIdMap.get(s.dataId).id,i=r.dataIdMap.get(a.dataId).id,{strides:c,dilations:l,pad:u,dimRoundingMode:d}=t,p=l==null?[1,1]:l,h=$t(s.shape,a.shape,c,p,u,d,!0),m=h.filterHeight,g=h.filterWidth,y=h.padInfo.top,b=h.padInfo.right,v=h.padInfo.bottom,$=h.padInfo.left,S=h.dilationHeight,T=h.dilationWidth,O=h.strideHeight,L=h.strideWidth,M=h.inChannels,W=h.outChannels,V=h.padInfo.type==="SAME"?1:0;if(h.dataFormat!=="channelsLast")throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${h.dataFormat}'. Please use 'channelsLast'.`);const G=r.makeOutput(h.outShape,"float32"),K=r.dataIdMap.get(G.dataId).id;return Yb(o,s.shape[0],s.shape[1],s.shape[2],i,m,g,y,b,v,$,V,S,T,O,L,M,W,K),G}const x4={kernelName:eu,backendName:"wasm",setupFunc:y4,kernelFunc:b4};/** 15389 * @license 15390 * Copyright 2023 Google LLC. 15391 * Licensed under the Apache License, Version 2.0 (the "License"); 15392 * you may not use this file except in compliance with the License. 15393 * You may obtain a copy of the License at 15394 * 15395 * http://www.apache.org/licenses/LICENSE-2.0 15396 * 15397 * Unless required by applicable law or agreed to in writing, software 15398 * distributed under the License is distributed on an "AS IS" BASIS, 15399 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15400 * See the License for the specific language governing permissions and 15401 * limitations under the License. 15402 * ============================================================================= 15403 */let Qb;function w4(n){Qb=n.wasm.cwrap("Diag",null,["number","number","number","number"])}function v4(n){const{inputs:e,backend:t}=n,{x:r}=e,s=H(r.shape),a=t.makeOutput([...r.shape,...r.shape],r.dtype);return Qb(t.dataIdMap.get(r.dataId).id,Oe[r.dtype],s,t.dataIdMap.get(a.dataId).id),a}const I4={kernelName:jl,backendName:"wasm",setupFunc:w4,kernelFunc:v4};/** 15404 * @license 15405 * Copyright 2023 Google LLC. 15406 * Licensed under the Apache License, Version 2.0 (the "License"); 15407 * you may not use this file except in compliance with the License. 15408 * You may obtain a copy of the License at 15409 * 15410 * http://www.apache.org/licenses/LICENSE-2.0 15411 * 15412 * Unless required by applicable law or agreed to in writing, softw
15412are 15413 * distributed under the License is distributed on an "AS IS" BASIS, 15414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15415 * See the License for the specific language governing permissions and 15416 * limitations under the License. 15417 * ============================================================================= 15418 */let Zb;function $4(n){Zb=n.wasm.cwrap(tu,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function S4(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a}=e,{strides:o,pad:i,dilations:c}=r;if(s.dtype!==a.dtype)throw new Error(`Dilation2D error: x must have the same dtype as filter. Got ${s.dtype} and ${a.dtype}`);const l=To(s.shape,a.shape,o,i,"NHWC",c),u=t.makeOutput(l.outShape,s.dtype);return Zb(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(u.dataId).id,Oe[s.dtype],l.batchSize,l.inChannels,l.inHeight,l.inWidth,l.outHeight,l.outWidth,l.strideHeight,l.strideWidth,l.dilationHeight,l.dilationWidth,l.filterHeight,l.filterWidth,l.padInfo.top,l.padInfo.left),u}const C4={kernelName:tu,backendName:"wasm",setupFunc:$4,kernelFunc:S4};/** 15419 * @license 15420 * Copyright 2023 Google LLC. 15421 * Licensed under the Apache License, Version 2.0 (the "License"); 15422 * you may not use this file except in compliance with the License. 15423 * You may obtain a copy of the License at 15424 * 15425 * http://www.apache.org/licenses/LICENSE-2.0 15426 * 15427 * Unless required by applicable law or agreed to in writing, software 15428 * distributed under the License is distributed on an "AS IS" BASIS, 15429 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15430 * See the License for the specific language governing permissions and 15431 * limitations under the License. 15432 * ============================================================================= 15433 */let Jb;function _4(n){Jb=n.wasm.cwrap(rm,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function N4(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a,dy:o}=e,{strides:i,pad:c,dilations:l}=r;if(s.dtype!==a.dtype||s.dtype!==o.dtype)throw new Error(`Dilation2DBackpropFilter error: x must have the same dtype as filter and dy. Got ${s.dtype}, ${a.dtype}, and ${o.dtype}`);const u=To(s.shape,a.shape,i,c,"NHWC",l),d=t.makeOutput(a.shape,a.dtype);return Jb(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(o.dataId).id,t.dataIdMap.get(d.dataId).id,Oe[s.dtype],u.batchSize,u.inChannels,u.inHeight,u.inWidth,u.outHeight,u.outWidth,u.strideHeight,u.strideWidth,u.dilationHeight,u.dilationWidth,u.filterHeight,u.filterWidth,u.padInfo.top,u.padInfo.left),d}const T4={kernelName:rm,backendName:"wasm",setupFunc:_4,kernelFunc:N4};/** 15434 * @license 15435 * Copyright 2023 Google LLC. 15436 * Licensed under the Apache License, Version 2.0 (the "License"); 15437 * you may not use this file except in compliance with the License. 15438 * You may obtain a copy of the License at 15439 * 15440 * http://www.apache.org/licenses/LICENSE-2.0 15441 * 15442 * Unless required by applicable law or agreed to in writing, software 15443 * distributed under the License is distributed on an "AS IS" BASIS, 15444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15445 * See the License for the specific language governing permissions and 15446 * limitations under the License. 15447 * ============================================================================= 15448 */let ex;function k4(n){ex=n.wasm.cwrap(nm,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function E4(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:a,dy:o}=e,{strides:i,pad:c,dilations:l}=r;if(s.dtype!==a.dtype||s.dtype!==o.dtype)throw new Error(`Dilation2DBackpropInput error: x must have the same dtype as filter and dy. Got ${s.dtype}, ${a.dtype}, and ${o.dtype}`);const u=To(s.shape,a.shape,i,c,"NHWC",l),d=t.makeOutput(s.shape,s.dtype);return ex(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(o.dataId).id,t.dataIdMap.get(d.dataId).id,Oe[s.dtype],u.batchSize,u.inChannels,u.inHeight,u.inWidth,u.outHeight,u.outWidth,u.strideHeight,u.strideWidth,u.dilationHeight,u.dilationWidth,u.filterHeight,u.filterWidth,u.padInfo.top,u.padInfo.left),d}const R4={kernelName:nm,backendName:"wasm",setupFunc:k4,kernelFunc:E4};/** 15449 * @license 15450 * Copyright 2021 Google LLC. All Rights Reserved. 15451 * Licensed under the Apache License, Version 2.0 (the "License");
15452 * you may not use this file except in compliance with the License. 15453 * You may obtain a copy of the License at 15454 * 15455 * http://www.apache.org/licenses/LICENSE-2.0 15456 * 15457 * Unless required by applicable law or agreed to in writing, software 15458 * distributed under the License is distributed on an "AS IS" BASIS, 15459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15460 * See the License for the specific language governing permissions and 15461 * limitations under the License. 15462 * ============================================================================= 15463 */const A4=Ae(Kl);/** 15464 * @license 15465 * Copyright 2023 Google LLC. 15466 * Licensed under the Apache License, Version 2.0 (the "License"); 15467 * you may not use this file except in compliance with the License. 15468 * You may obtain a copy of the License at 15469 * 15470 * http://www.apache.org/licenses/LICENSE-2.0 15471 * 15472 * Unless required by applicable law or agreed to in writing, software 15473 * distributed under the License is distributed on an "AS IS" BASIS, 15474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15475 * See the License for the specific language governing permissions and 15476 * limitations under the License. 15477 * ============================================================================= 15478 */let tx;function D4(n){tx=n.wasm.cwrap(Xl,null,["number","number","number"])}function O4(n){const{inputs:e,backend:t}=n,{dy:r,y:s}=e,a=t.makeOutput(s.shape,"float32"),o=i=>t.dataIdMap.get(i.dataId).id;return tx(o(s),o(r),o(a)),a}const F4={kernelName:Xl,backendName:"wasm",setupFunc:D4,kernelFunc:O4};/** 15479 * @license 15480 * Copyright 2020 Google LLC. All Rights Reserved. 15481 * Licensed under the Apache License, Version 2.0 (the "License"); 15482 * you may not use this file except in compliance with the License. 15483 * You may obtain a copy of the License at 15484 * 15485 * http://www.apache.org/licenses/LICENSE-2.0 15486 * 15487 * Unless required by applicable law or agreed to in writing, software 15488 * distributed under the License is distributed on an "AS IS" BASIS, 15489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15490 * See the License for the specific language governing permissions and 15491 * limitations under the License. 15492 * ============================================================================= 15493 */const P4=!1,L4=lt(Ql,P4,"bool");/** 15494 * @license 15495 * Copyright 2023 Google LLC. 15496 * Licensed under the Apache License, Version 2.0 (the "License"); 15497 * you may not use this file except in compliance with the License. 15498 * You may obtain a copy of the License at 15499 * 15500 * http://www.apache.org/licenses/LICENSE-2.0 15501 * 15502 * Unless required by applicable law or agreed to in writing, software 15503 * distributed under the License is distributed on an "AS IS" BASIS, 15504 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15505 * See the License for the specific language governing permissions and 15506 * limitations under the License. 15507 * ============================================================================= 15508 */const M4=Ae(Yl);/** 15509 * @license 15510 * Copyright 2019 Google LLC. All Rights Reserved. 15511 * Licensed under the Apache License, Version 2.0 (the "License"); 15512 * you may not use this file except in compliance with the License. 15513 * You may obtain a copy of the License at 15514 * 15515 * http://www.apache.org/licenses/LICENSE-2.0 15516 * 15517 * Unless required by applicable law or agreed to in writing, software 15518 * distributed under the License is distributed on an "AS IS" BASIS, 15519 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15520 * See the License for the specific language governing permissions and 15521 * limitations under the License. 15522 * ============================================================================= 15523 */const B4=Ae(Zl,"float32");/** 15524 * @license 15525 * Copyright 2019 Google LLC. All Rights Reserved. 15526 * Licensed under the Apache License, Version 2.0 (the "License"); 15527 * you may not use this file except in compliance with the License. 15528 * You may obtain a copy of the License at 15529 * 15530 * http://www.apache.org/licenses/LICENSE-2.0 15531 * 15532 * Unless required by applicable law or agreed to in writing, software 15533 * distributed under the License is distributed on an "AS IS" BASIS, 15534 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15535 * See the License for the specific language governing permissions and 15536 * limitations under the License. 15537 * ============================================================================= 15538 */function ol(n){const{inputs:e,attrs:t,backend:r}=n,{input:s}=e,{dim:a}=t,o=s.shape.length,i=s.shape.slice();let c=a;return a<0&&(N(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),c=o+a+1),i.splice(c,0,1),jt({inputs:{x:s},backend:r,attrs:{shape:i}})}const V4={kernelName:Jl,backendName:"wasm",kernelFunc:ol};/** 15539 * @license 15540 * Copyright 2023 Google LLC. 15541 * Licensed under the Apache License, Version 2.0 (the "License");
15542 * you may not use this file except in compliance with the License. 15543 * You may obtain a copy of the License at 15544 * 15545 * http://www.apache.org/licenses/LICENSE-2.0 15546 * 15547 * Unless required by applicable law or agreed to in writing, software 15548 * distributed under the License is distributed on an "AS IS" BASIS, 15549 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15550 * See the License for the specific language governing permissions and 15551 * limitations under the License. 15552 * ============================================================================= 15553 */const W4=Ae(ed,"float32");/** 15554 * @license 15555 * Copyright 2020 Google LLC. All Rights Reserved. 15556 * Licensed under the Apache License, Version 2.0 (the "License"); 15557 * you may not use this file except in compliance with the License. 15558 * You may obtain a copy of the License at 15559 * 15560 * http://www.apache.org/licenses/LICENSE-2.0 15561 * 15562 * Unless required by applicable law or agreed to in writing, software 15563 * distributed under the License is distributed on an "AS IS" BASIS, 15564 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15565 * See the License for the specific language governing permissions and 15566 * limitations under the License. 15567 * ============================================================================= 15568 */function nx(n){const{attrs:{shape:e,value:t},backend:r}=n;let{attrs:{dtype:s}}=n;s=s||ka(t);const a=r.makeOutput(e,s);return r.typedArrayFromHeap(a).fill(t),a}const U4={kernelName:td,backendName:"wasm",kernelFunc:nx};/** 15569 * @license 15570 * Copyright 2019 Google LLC. All Rights Reserved. 15571 * Licensed under the Apache License, Version 2.0 (the "License"); 15572 * you may not use this file except in compliance with the License. 15573 * You may obtain a copy of the License at 15574 * 15575 * http://www.apache.org/licenses/LICENSE-2.0 15576 * 15577 * Unless required by applicable law or agreed to in writing, software 15578 * distributed under the License is distributed on an "AS IS" BASIS, 15579 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15580 * See the License for the specific language governing permissions and 15581 * limitations under the License. 15582 * ============================================================================= 15583 */let rx;function z4(n){rx=n.wasm.cwrap(nu,null,["number","number","number","number","number","number"])}function G4(n){const{inputs:e,backend:t}=n,{image:r}=e,s=t.makeOutput(r.shape,r.dtype),a=t.dataIdMap.get(r.dataId).id,o=t.dataIdMap.get(s.dataId).id,[i,c,l,u]=r.shape;return rx(a,i,c,l,u,o),s}const H4={kernelName:nu,backendName:"wasm",kernelFunc:G4,setupFunc:z4};/** 15584 * @license 15585 * Copyright 2020 Google LLC. All Rights Reserved. 15586 * Licensed under the Apache License, Version 2.0 (the "License"); 15587 * you may not use this file except in compliance with the License. 15588 * You may obtain a copy of the License at 15589 * 15590 * http://www.apache.org/licenses/LICENSE-2.0 15591 * 15592 * Unless required by applicable law or agreed to in writing, software 15593 * distributed under the License is distributed on an "AS IS" BASIS, 15594 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15595 * See the License for the specific language governing permissions and 15596 * limitations under the License. 15597 * ============================================================================= 15598 */const j4=Ae(nd);/** 15599 * @license 15600 * Copyright 2019 Google LLC. All Rights Reserved. 15601 * Licensed under the Apache License, Version 2.0 (the "License"); 15602 * you may not use this file except in compliance with the License. 15603 * You may obtain a copy of the License at 15604 * 15605 * http://www.apache.org/licenses/LICENSE-2.0 15606 * 15607 * Unless required by applicable law or agreed to in writing, software 15608 * distributed under the License is distributed on an "AS IS" BASIS, 15609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15610 * See the License for the specific language governing permissions and 15611 * limitations under the License. 15612 * ============================================================================= 15613 */const q4=lt(rd);/** 15614 * @license 15615 * Copyright 2019 Google LLC. All Rights Reserved. 15616 * Licensed under the Apache License, Version 2.0 (the "License");
15617 * you may not use this file except in compliance with the License. 15618 * You may obtain a copy of the License at 15619 * 15620 * http://www.apache.org/licenses/LICENSE-2.0 15621 * 15622 * Unless required by applicable law or agreed to in writing, software 15623 * distributed under the License is distributed on an "AS IS" BASIS, 15624 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15625 * See the License for the specific language governing permissions and 15626 * limitations under the License. 15627 * ============================================================================= 15628 */let sx;function K4(n){sx=n.wasm.cwrap(ru,null,["number","number","number","number","number","number","number"])}function X4(n){const{backend:e,inputs:t,attrs:r}=n,{varianceEpsilon:s}=r,{x:a,mean:o,variance:i,offset:c,scale:l}=t,u=e.dataIdMap.get(a.dataId).id,d=e.dataIdMap.get(o.dataId).id,p=e.dataIdMap.get(i.dataId).id,h=c!=null?e.dataIdMap.get(c.dataId).id:0,m=l!=null?e.dataIdMap.get(l.dataId).id:0,g=e.makeOutput(a.shape,a.dtype);if(H(a.shape)===0)return g;const y=e.dataIdMap.get(g.dataId).id;return sx(u,d,p,h,m,s,y),g}const Y4={kernelName:ru,backendName:"wasm",setupFunc:K4,kernelFunc:X4};/** 15629 * @license 15630 * Copyright 2019 Google LLC. All Rights Reserved. 15631 * Licensed under the Apache License, Version 2.0 (the "License"); 15632 * you may not use this file except in compliance with the License. 15633 * You may obtain a copy of the License at 15634 * 15635 * http://www.apache.org/licenses/LICENSE-2.0 15636 * 15637 * Unless required by applicable law or agreed to in writing, software 15638 * distributed under the License is distributed on an "AS IS" BASIS, 15639 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15640 * See the License for the specific language governing permissions and 15641 * limitations under the License. 15642 * ============================================================================= 15643 */let ax;function Q4(n){ax=n.wasm.cwrap(co,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function Z4(n){const{inputs:e,attrs:t,backend:r}=n,{x:s,filter:a,bias:o,preluActivationWeights:i}=e,{strides:c,pad:l,dilations:u,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:m}=t,g=$t(s.shape,a.shape,c,u,l,p),y=Co[h];if(y==null)throw new Error(`${h} activation not yet supported for FusedConv2D in the wasm backend.`);const b=r.dataIdMap.get(s.dataId).id,v=r.dataIdMap.get(a.dataId).id,$=g.outChannels;let S=0;if(o!=null){const He=r.dataIdMap.get(o.dataId);if(He.shape.length!==1)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${He.shape.length}.`);if(He.shape[0]!==$)throw new Error(`FusedConv2D bias shape (${He.shape}) does not match the number of output channels (${$})`);S=He.id}const T=g.filterHeight,O=g.filterWidth,L=g.padInfo.top,M=g.padInfo.right,W=g.padInfo.bottom,V=g.padInfo.left,G=g.dilationHeight,K=g.dilationWidth,J=g.strideHeight,ue=g.strideWidth,se=g.inChannels,fe=g.padInfo.type==="SAME"?1:0,Ie=g.batchSize,pe=g.inHeight,Fe=g.inWidth;
vendor: 6,633 bytes, lines 15643-15706
15643if(d!=="NHWC")throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);const Qe=r.makeOutput(g.outShape,"float32"),it=r.dataIdMap.get(Qe.dataId).id,Nt=i==null?0:r.dataIdMap.get(i.dataId).id;return ax(b,Ie,pe,Fe,v,T,O,S,L,M,W,V,fe,G,K,J,ue,se,$,y,Nt,m||0,it),Qe}const J4={kernelName:co,backendName:"wasm",setupFunc:Q4,kernelFunc:Z4};/** 15644 * @license 15645 * Copyright 2019 Google LLC. All Rights Reserved. 15646 * Licensed under the Apache License, Version 2.0 (the "License"); 15647 * you may not use this file except in compliance with the License. 15648 * You may obtain a copy of the License at 15649 * 15650 * http://www.apache.org/licenses/LICENSE-2.0 15651 * 15652 * Unless required by applicable law or agreed to in writing, software 15653 * distributed under the License is distributed on an "AS IS" BASIS, 15654 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15655 * See the License for the specific language governing permissions and 15656 * limitations under the License. 15657 * ============================================================================= 15658 */let ox;function eW(n){ox=n.wasm.cwrap(lo,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function tW(n){const{inputs:e,attrs:t,backend:r}=n,{x:s,filter:a,bias:o,preluActivationWeights:i}=e,{strides:c,pad:l,dilations:u,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:m}=t,g=$t(s.shape,a.shape,c,u,l,p,!0),y=Co[h];if(y==null)throw new Error(`${h} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);const b=r.dataIdMap.get(s.dataId).id,v=r.dataIdMap.get(a.dataId).id,$=g.outChannels;let S=0;if(o!=null){const He=r.dataIdMap.get(o.dataId);if(He.shape.length!==1)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${He.shape.length}.`);if(He.shape[0]!==$)throw new Error(`FusedDepthwiseConv2D bias shape (${He.shape}) does not match the number of output channels (${$})`);S=He.id}const T=g.filterHeight,O=g.filterWidth,L=g.padInfo.top,M=g.padInfo.right,W=g.padInfo.bottom,V=g.padInfo.left,G=g.dilationHeight,K=g.dilationWidth,J=g.strideHeight,ue=g.strideWidth,se=g.inChannels,fe=g.padInfo.type==="SAME"?1:0,Ie=g.batchSize,pe=g.inHeight,Fe=g.inWidth;if(d!=="NHWC")throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);const Qe=r.makeOutput(g.outShape,"float32"),it=r.dataIdMap.get(Qe.dataId).id,Nt=i==null?0:r.dataIdMap.get(i.dataId).id;return ox(b,Ie,pe,Fe,v,T,O,S,L,M,W,V,fe,G,K,J,ue,se,$,y,Nt,m||0,it),Qe}const nW={kernelName:lo,backendName:"wasm",setupFunc:eW,kernelFunc:tW};/** 15659 * @license 15660 * Copyright 2019 Google LLC. All Rights Reserved. 15661 * Licensed under the Apache License, Version 2.0 (the "License"); 15662 * you may not use this file except in compliance with the License. 15663 * You may obtain a copy of the License at 15664 * 15665 * http://www.apache.org/licenses/LICENSE-2.0 15666 * 15667 * Unless required by applicable law or agreed to in writing, software 15668 * distributed under the License is distributed on an "AS IS" BASIS, 15669 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15670 * See the License for the specific language governing permissions and 15671 * limitations under the License. 15672 * ============================================================================= 15673 */let ix;function rW(n){ix=n.wasm.cwrap(su,null,["number","number","number","number","number","number","array","number"])}function sW(n){const{backend:e,inputs:t}=n,{params:r,indices:s}=t,[a,o,i,c]=Np(r,s),l=e.makeOutput(a,r.dtype);if(o===0)return l;const u=s.shape,d=u[u.length-1],h=e.dataIdMap.get(r.dataId).id,g=e.dataIdMap.get(s.dataId).id,y=new Uint8Array(new Int32Array(c).buffer),b=e.dataIdMap.get(l.dataId).id;return ix(h,Oe[r.dtype],g,o,d,i,y,b),l}const aW={kernelName:su,backendName:"wasm",setupFunc:rW,kernelFunc:sW};/** 15674 * @license 15675 * Copyright 2019 Google LLC. All Rights Reserved. 15676 * Licensed under the Apache License, Version 2.0 (the "License"); 15677 * you may not use this file except in compliance with the License. 15678 * You may obtain a copy of the License at 15679 * 15680 * http://www.apache.org/licenses/LICENSE-2.0 15681 * 15682 * Unless required by applicable law or agreed to in writing, software 15683 * distributed under the License is distributed on an "AS IS" BASIS, 15684 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15685 * See the License for the specific language governing permissions and 15686 * limitations under the License. 15687 * ============================================================================= 15688 */let ux;function oW(n){ux=n.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])}function iW(n){const{backend:e,inputs:t,attrs:r}=n,{x:s,indices:a}=t,{axis:o,batchDims:i}=r,c=ot(o,s.shape)[0],l=e.readSync(a.dataId),u=s.shape[c];for(let W=0;W<l.length;++W){const V=l[W];N(V<=u-1&&V>=0,()=>`GatherV2: the index value ${V} is not in [0, ${u-1}]`)}const d=Kp(s,a,c,i),p=jt({inputs:{x:s},attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]},backend:e}),h=H(a.shape),m=jt({inputs:{x:a},attrs:{shape:[d.batchSize,h/d.batchSize]},backend:e}),g=[d.batchSize,d.outerSize,h/d.batchSize,d.sliceSize],y=e.makeOutput(g,s.dtype);if(H(s.shape)===0)return y;const b=p.shape.length-1,$=e.dataIdMap.get(p.dataId).id,T=e.dataIdMap.get(m.dataId).id,O=e.dataIdMap.get(y.dataId).id,L=new Uint8Array(new Int32Array(Be(p.shape)).buffer),M=new Uint8Array(new Int32Array(Be(g)).buffer);return ux($,Oe[s.dtype],L,b,T,d.batchSize,M,O),e.disposeData(p.dataId),e.disposeData(m.dataId),y.shape=d.outputShape,y}const uW={kernelName:sd,backendName:"wasm",setupFunc:oW,kernelFunc:iW};/** 15689 * @license 15690 * Copyright 2019 Google LLC. All Rights Reserved. 15691 * Licensed under the Apache License, Version 2.0 (the "License"); 15692 * you may not use this file except in compliance with the License. 15693 * You may obtain a copy of the License at 15694 * 15695 * http://www.apache.org/licenses/LICENSE-2.0 15696 * 15697 * Unless required by applicable law or agreed to in writing, software 15698 * distributed under the License is distributed on an "AS IS" BASIS, 15699 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15700 * See the License for the specific language governing permissions and 15701 * limitations under the License. 15702 * ============================================================================= 15703 */const cW=!1,lW=lt(ad,cW,"bool");/** 15704 * @license 15705 * Copyright 2019 Google LLC. All Rights Reserved. 15706 * Licensed under the Apache License, Version 2.0 (the "License");
15707 * you may not use this file except in compliance with the License. 15708 * You may obtain a copy of the License at 15709 * 15710 * http://www.apache.org/licenses/LICENSE-2.0 15711 * 15712 * Unless required by applicable law or agreed to in writing, software 15713 * distributed under the License is distributed on an "AS IS" BASIS, 15714 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15715 * See the License for the specific language governing permissions and 15716 * limitations under the License. 15717 * ============================================================================= 15718 */const dW=!1,pW=lt(od,dW,"bool");/** 15719 * @license 15720 * Copyright 2023 Google LLC. 15721 * Licensed under the Apache License, Version 2.0 (the "License"); 15722 * you may not use this file except in compliance with the License. 15723 * You may obtain a copy of the License at 15724 * 15725 * http://www.apache.org/licenses/LICENSE-2.0 15726 * 15727 * Unless required by applicable law or agreed to in writing, software 15728 * distributed under the License is distributed on an "AS IS" BASIS, 15729 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15730 * See the License for the specific language governing permissions and 15731 * limitations under the License. 15732 * ============================================================================= 15733 */const hW=Ae(id,"bool");/** 15734 * @license 15735 * Copyright 2023 Google LLC. 15736 * Licensed under the Apache License, Version 2.0 (the "License"); 15737 * you may not use this file except in compliance with the License. 15738 * You may obtain a copy of the License at 15739 * 15740 * http://www.apache.org/licenses/LICENSE-2.0 15741 * 15742 * Unless required by applicable law or agreed to in writing, software 15743 * distributed under the License is distributed on an "AS IS" BASIS, 15744 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15745 * See the License for the specific language governing permissions and 15746 * limitations under the License. 15747 * ============================================================================= 15748 */const fW=Ae(ud,"bool");/** 15749 * @license 15750 * Copyright 2022 The TensorFlow Authors. All Rights Reserved. 15751 * Licensed under the Apache License, Version 2.0 (the License); 15752 * you may not use this file except in compliance with the License. 15753 * You may obtain a copy of the License at 15754 * 15755 * http://www.apache.org/licenses/LICENSE-2.0 15756 * 15757 * Unless required by applicable law or agreed to in writing, software 15758 * distributed under the License is distributed on an AS IS BASIS, 15759 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15760 * See the License for the specific language governing permissions and 15761 * limitations under the License. 15762 * ============================================================================= 15763 */const mW=Ae(cd,"bool");/** 15764 * @license 15765 * Copyright 2019 Google LLC. All Rights Reserved. 15766 * Licensed under the Apache License, Version 2.0 (the "License"); 15767 * you may not use this file except in compliance with the License. 15768 * You may obtain a copy of the License at 15769 * 15770 * http://www.apache.org/licenses/LICENSE-2.0 15771 * 15772 * Unless required by applicable law or agreed to in writing, software 15773 * distributed under the License is distributed on an "AS IS" BASIS, 15774 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15775 * See the License for the specific language governing permissions and 15776 * limitations under the License. 15777 * ============================================================================= 15778 */let cx;function gW(n){cx=n.wasm.cwrap(ou,null,["number","number","number","number"])}function yW(n){const{inputs:{x:e},attrs:{alpha:t},backend:r}=n,s=r.dataIdMap.get(e.dataId).id,a=r.makeOutput(e.shape,"float32");if(H(e.shape)!==0){const o=r.dataIdMap.get(a.dataId).id;cx(s,Oe[e.dtype],t,o)}return a}const bW={kernelName:ou,backendName:"wasm",setupFunc:gW,kernelFunc:yW};/** 15779 * @license 15780 * Copyright 2019 Google LLC. All Rights Reserved. 15781 * Licensed under the Apache License, Version 2.0 (the "License"); 15782 * you may not use this file except in compliance with the License. 15783 * You may obtain a copy of the License at 15784 * 15785 * http://www.apache.org/licenses/LICENSE-2.0 15786 * 15787 * Unless required by applicable law or agreed to in writing, softw
15787are 15788 * distributed under the License is distributed on an "AS IS" BASIS, 15789 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15790 * See the License for the specific language governing permissions and 15791 * limitations under the License. 15792 * ============================================================================= 15793 */const xW=!1,wW=lt(ld,xW,"bool");/** 15794 * @license 15795 * Copyright 2019 Google LLC. All Rights Reserved. 15796 * Licensed under the Apache License, Version 2.0 (the "License"); 15797 * you may not use this file except in compliance with the License. 15798 * You may obtain a copy of the License at 15799 * 15800 * http://www.apache.org/licenses/LICENSE-2.0 15801 * 15802 * Unless required by applicable law or agreed to in writing, software 15803 * distributed under the License is distributed on an "AS IS" BASIS, 15804 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15805 * See the License for the specific language governing permissions and 15806 * limitations under the License. 15807 * ============================================================================= 15808 */const vW=!1,IW=lt(dd,vW,"bool");/** 15809 * @license 15810 * Copyright 2023 Google LLC. All Rights Reserved. 15811 * Licensed under the Apache License, Version 2.0 (the "License"); 15812 * you may not use this file except in compliance with the License. 15813 * You may obtain a copy of the License at 15814 * 15815 * http://www.apache.org/licenses/LICENSE-2.0 15816 * 15817 * Unless required by applicable law or agreed to in writing, software 15818 * distributed under the License is distributed on an "AS IS" BASIS, 15819 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15820 * See the License for the specific language governing permissions and 15821 * limitations under the License. 15822 * ============================================================================= 15823 */let lx;function $W(n){lx=n.wasm.cwrap(iu,null,["number","number","number","number"])}function SW(n){const{attrs:e,backend:t}=n,{start:r,stop:s,num:a}=e,o=Math.floor(a),i=t.makeOutput([o],"float32");return lx(t.dataIdMap.get(i.dataId).id,r,s,o),i}const CW={kernelName:iu,backendName:"wasm",setupFunc:$W,kernelFunc:SW};/** 15824 * @license 15825 * Copyright 2019 Google LLC. All Rights Reserved. 15826 * Licensed under the Apache License, Version 2.0 (the "License"); 15827 * you may not use this file except in compliance with the License. 15828 * You may obtain a copy of the License at 15829 * 15830 * http://www.apache.org/licenses/LICENSE-2.0 15831 * 15832 * Unless required by applicable law or agreed to in writing, software 15833 * distributed under the License is distributed on an "AS IS" BASIS, 15834 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15835 * See the License for the specific language governing permissions and 15836 * limitations under the License. 15837 * ============================================================================= 15838 */const _W=Ae(pd);/** 15839 * @license 15840 * Copyright 2023 Google LLC. 15841 * Licensed under the Apache License, Version 2.0 (the "License"); 15842 * you may not use this file except in compliance with the License. 15843 * You may obtain a copy of the License at 15844 * 15845 * http://www.apache.org/licenses/LICENSE-2.0 15846 * 15847 * Unless required by applicable law or agreed to in writing, software 15848 * distributed under the License is distributed on an "AS IS" BASIS, 15849 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15850 * See the License for the specific language governing permissions and 15851 * limitations under the License. 15852 * ============================================================================= 15853 */const NW=Ae(hd);/** 15854 * @license 15855 * Copyright 2019 Google LLC. All Rights Reserved. 15856 * Licensed under the Apache License, Version 2.0 (the "License"); 15857 * you may not use this file except in compliance with the License. 15858 * You may obtain a copy of the License at 15859 * 15860 * http://www.apache.org/licenses/LICENSE-2.0 15861 * 15862 * Unless required by applicable law or agreed to in writing, software 15863 * distributed under the License is distributed on an "AS IS" BASIS, 15864 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15865 * See the License for the specific language governing permissions and 15866 * limitations under the License. 15867 * ============================================================================= 15868 */const TW=!1,kW=lt(fd,TW,"bool");/** 15869 * @license 15870 * Copyright 2019 Google LLC. All Rights Reserved. 15871 * Licensed under the Apache License, Version 2.0 (the "License");
15872 * you may not use this file except in compliance with the License. 15873 * You may obtain a copy of the License at 15874 * 15875 * http://www.apache.org/licenses/LICENSE-2.0 15876 * 15877 * Unless required by applicable law or agreed to in writing, software 15878 * distributed under the License is distributed on an "AS IS" BASIS, 15879 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15880 * See the License for the specific language governing permissions and 15881 * limitations under the License. 15882 * ============================================================================= 15883 */const EW=Ae(md);/** 15884 * @license 15885 * Copyright 2019 Google LLC. All Rights Reserved. 15886 * Licensed under the Apache License, Version 2.0 (the "License"); 15887 * you may not use this file except in compliance with the License. 15888 * You may obtain a copy of the License at 15889 * 15890 * http://www.apache.org/licenses/LICENSE-2.0 15891 * 15892 * Unless required by applicable law or agreed to in writing, software 15893 * distributed under the License is distributed on an "AS IS" BASIS, 15894 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15895 * See the License for the specific language governing permissions and 15896 * limitations under the License. 15897 * ============================================================================= 15898 */const RW=!1,AW=lt(gd,RW,"bool");/** 15899 * @license 15900 * Copyright 2019 Google LLC. All Rights Reserved. 15901 * Licensed under the Apache License, Version 2.0 (the "License"); 15902 * you may not use this file except in compliance with the License. 15903 * You may obtain a copy of the License at 15904 * 15905 * http://www.apache.org/licenses/LICENSE-2.0 15906 * 15907 * Unless required by applicable law or agreed to in writing, software 15908 * distributed under the License is distributed on an "AS IS" BASIS, 15909 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15910 * See the License for the specific language governing permissions and 15911 * limitations under the License. 15912 * ============================================================================= 15913 */const DW=!1,OW=lt(q0,DW,"bool");/** 15914 * @license 15915 * Copyright 2023 Google LLC. 15916 * Licensed under the Apache License, Version 2.0 (the "License"); 15917 * you may not use this file except in compliance with the License. 15918 * You may obtain a copy of the License at 15919 * 15920 * http://www.apache.org/licenses/LICENSE-2.0 15921 * 15922 * Unless required by applicable law or agreed to in writing, software 15923 * distributed under the License is distributed on an "AS IS" BASIS, 15924 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15925 * See the License for the specific language governing permissions and 15926 * limitations under the License. 15927 * ============================================================================= 15928 */let dx;function FW(n){dx=n.wasm.cwrap(uu,null,["number","number","number","number","number","number","number"])}function PW(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{depthRadius:a,bias:o,alpha:i,beta:c}=r;if(s.dtype!=="float32")throw new Error("LRN error: x must have dtype float32");const l=t.makeOutput(s.shape,s.dtype);return dx(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(l.dataId).id,s.shape[3],a,o,i,c),l}const LW={kernelName:uu,backendName:"wasm",setupFunc:FW,kernelFunc:PW};/** 15929 * @license 15930 * Copyright 2023 Google LLC. 15931 * Licensed under the Apache License, Version 2.0 (the "License"); 15932 * you may not use this file except in compliance with the License. 15933 * You may obtain a copy of the License at 15934 * 15935 * http://www.apache.org/licenses/LICENSE-2.0 15936 * 15937 * Unless required by applicable law or agreed to in writing, software 15938 * distributed under the License is distributed on an "AS IS" BASIS, 15939 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15940 * See the License for the specific language governing permissions and 15941 * limitations under the License. 15942 * ============================================================================= 15943 */let px;function MW(n){px=n.wasm.cwrap(yd,null,["number","number","number","number","number","number","number","number","number"])}function BW(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,y:a,dy:o}=e,{depthRadius:i,bias:c,alpha:l,beta:u}=r;if(s.dtype!=="float32"||a.dtype!=="float32"||o.dtype!=="float32")throw new Error("LRNGrad error: x, y, and dy must have dtype float32");const d=t.makeOutput(s.shape,s.dtype);return px(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(o.dataId).id,t.dataIdMap.get(d.dataId).id,o.shape[3],i,c,l,u),d}const VW={kernelName:yd,backendName:"wasm",setupFunc:MW,kernelFunc:BW};/** 15944 * @license 15945 * Copyright 2019 Google LLC. All Rights Reserved. 15946 * Licensed under the Apache License, Version 2.0 (the "License");
15947 * you may not use this file except in compliance with the License. 15948 * You may obtain a copy of the License at 15949 * 15950 * http://www.apache.org/licenses/LICENSE-2.0 15951 * 15952 * Unless required by applicable law or agreed to in writing, software 15953 * distributed under the License is distributed on an "AS IS" BASIS, 15954 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15955 * See the License for the specific language governing permissions and 15956 * limitations under the License. 15957 * ============================================================================= 15958 */let hx;function WW(n){hx=n.wasm.cwrap(cu,null,["number","number","number","number"])}function UW(n){const{backend:e,inputs:t,attrs:r}=n,{reductionIndices:s,keepDims:a}=r,{x:o}=t;let c=e.dataIdMap.get(o.dataId).id,l=o;const{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Zr(o,s,e);if(h){const $=e.dataIdMap.get(u.dataId).id;l=u,c=$}const m=l.shape.length;ht("max",d,m);const[g,y]=At(l.shape,d),b=H(y),v=e.makeOutput(g,o.dtype);if(H(l.shape)!==0){const $=e.dataIdMap.get(v.dataId).id;hx(c,Oe[o.dtype],b,$)}if(h&&e.disposeData(u.dataId),a){const $=pt(v.shape,p);v.shape=$}return v}const zW={kernelName:cu,backendName:"wasm",setupFunc:WW,kernelFunc:UW};/** 15959 * @license 15960 * Copyright 2019 Google LLC. All Rights Reserved. 15961 * Licensed under the Apache License, Version 2.0 (the "License"); 15962 * you may not use this file except in compliance with the License. 15963 * You may obtain a copy of the License at 15964 * 15965 * http://www.apache.org/licenses/LICENSE-2.0 15966 * 15967 * Unless required by applicable law or agreed to in writing, software 15968 * distributed under the License is distributed on an "AS IS" BASIS, 15969 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15970 * See the License for the specific language governing permissions and 15971 * limitations under the License. 15972 * ============================================================================= 15973 */const GW=lt(bd);/** 15974 * @license 15975 * Copyright 2019 Google LLC. All Rights Reserved. 15976 * Licensed under the Apache License, Version 2.0 (the "License"); 15977 * you may not use this file except in compliance with the License. 15978 * You may obtain a copy of the License at 15979 * 15980 * http://www.apache.org/licenses/LICENSE-2.0 15981 * 15982 * Unless required by applicable law or agreed to in writing, software 15983 * distributed under the License is distributed on an "AS IS" BASIS, 15984 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15985 * See the License for the specific language governing permissions and 15986 * limitations under the License. 15987 * ============================================================================= 15988 */let fx;function HW(n){fx=n.wasm.cwrap(lu,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function jW(n){const{inputs:e,attrs:t,backend:r}=n,s=e.x,a=r.dataIdMap.get(s.dataId).id;N(s.dtype==="float32",()=>`Error in MaxPool: only float32 input is supported. Got ${s.dtype}.`);const{filterSize:o,strides:i,pad:c,dimRoundingMode:l}=t,u=kn(s.shape,o,i,1,c,l),d=u.filterHeight,p=u.filterWidth,h=u.padInfo.top,m=u.padInfo.right,g=u.padInfo.bottom,y=u.padInfo.left,b=u.dilationHeight,v=u.dilationWidth,$=u.strideHeight,S=u.strideWidth,T=u.inChannels,O=u.outChannels;if(u.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${u.dataFormat}'. Please use 'channelsLast'.`);const L=r.makeOutput(u.outShape,"float32"),M=r.dataIdMap.get(L.dataId).id;return fx(a,s.shape[0],s.shape[1],s.shape[2],d,p,h,m,g,y,b,v,$,S,T,O,M),L}const qW={kernelName:lu,backendName:"wasm",setupFunc:HW,kernelFunc:jW};/** 15989 * @license 15990 * Copyright 2023 Google LLC. 15991 * Licensed under the Apache License, Version 2.0 (the "License"); 15992 * you may not use this file except in compliance with the License. 15993 * You may obtain a copy of the License at 15994 * 15995 * http://www.apache.org/licenses/LICENSE-2.0 15996 * 15997 * Unless required by applicable law or agreed to in writing, software 15998 * distributed under the License is distributed on an "AS IS" BASIS, 15999 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16000 * See the License for the specific language governing permissions and 16001 * limitations under the License. 16002 * ============================================================================= 16003 */let mx;function KW(n){mx=n.wasm.cwrap("MaxPool3D",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function XW(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:a,strides:o,pad:i,dimRoundingMode:c,dataFormat:l}=r,u=Ir(s.shape,a,o,1,i,c,l),d=t.makeOutput(u.outShape,s.dtype);return mx(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(d.dataId).id,u.batchSize,u.inChannels,u.inDepth,u.inHeight,u.inWidth,u.outDepth,u.outHeight,u.outWidth,u.strideDepth,u.strideHeight,u.strideWidth,u.dilationDepth,u.dilationHeight,u.dilationWidth,u.effectiveFilterDepth,u.effectiveFilterHeight,u.effectiveFilterWidth,u.padInfo.front,u.padInfo.top,u.padInfo.left),d}const YW={kernelName:xd,backendName:"wasm",setupFunc:KW,kernelFunc:XW};/** 16004 * @license 16005 * Copyright 2023 Google LLC. 16006 * Licensed under the Apache License, Version 2.0 (the "License");
16007 * you may not use this file except in compliance with the License. 16008 * You may obtain a copy of the License at 16009 * 16010 * http://www.apache.org/licenses/LICENSE-2.0 16011 * 16012 * Unless required by applicable law or agreed to in writing, software 16013 * distributed under the License is distributed on an "AS IS" BASIS, 16014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16015 * See the License for the specific language governing permissions and 16016 * limitations under the License. 16017 * ============================================================================= 16018 */let gx;function QW(n){gx=n.wasm.cwrap("MaxPool3DGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function ZW(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a}=e,{filterSize:o,strides:i,pad:c,dimRoundingMode:l}=r,u=Ir(a.shape,o,i,1,c,l),d=t.makeOutput(a.shape,a.dtype);return gx(t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(d.dataId).id,u.batchSize,u.inChannels,u.inDepth,u.inHeight,u.inWidth,u.outDepth,u.outHeight,u.outWidth,u.strideDepth,u.strideHeight,u.strideWidth,u.dilationDepth,u.dilationHeight,u.dilationWidth,u.effectiveFilterDepth,u.effectiveFilterHeight,u.effectiveFilterWidth,u.padInfo.front,u.padInfo.top,u.padInfo.left),d}const JW={kernelName:cm,backendName:"wasm",setupFunc:QW,kernelFunc:ZW};/** 16019 * @license 16020 * Copyright 2023 Google LLC. 16021 * Licensed under the Apache License, Version 2.0 (the "License"); 16022 * you may not use this file except in compliance with the License. 16023 * You may obtain a copy of the License at 16024 * 16025 * http://www.apache.org/licenses/LICENSE-2.0 16026 * 16027 * Unless required by applicable law or agreed to in writing, software 16028 * distributed under the License is distributed on an "AS IS" BASIS, 16029 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16030 * See the License for the specific language governing permissions and 16031 * limitations under the License. 16032 * ============================================================================= 16033 */let yx;function eU(n){yx=n.wasm.cwrap("MaxPoolGrad",null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function tU(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:a}=e,{filterSize:o,strides:i,pad:c,dimRoundingMode:l}=r,u=kn(a.shape,o,i,1,c,l),d=t.makeOutput(a.shape,a.dtype);return yx(t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(d.dataId).id,u.batchSize,u.inChannels,u.inHeight,u.inWidth,u.outHeight,u.outWidth,u.strideHeight,u.strideWidth,u.dilationHeight,u.dilationWidth,u.effectiveFilterHeight,u.effectiveFilterWidth,u.padInfo.top,u.padInfo.left),d}const nU={kernelName:um,backendName:"wasm",setupFunc:eU,kernelFunc:tU};/** 16034 * @license 16035 * Copyright 2023 Google LLC. 16036 * Licensed under the Apache License, Version 2.0 (the "License"); 16037 * you may not use this file except in compliance with the License. 16038 * You may obtain a copy of the License at 16039 * 16040 * http://www.apache.org/licenses/LICENSE-2.0 16041 * 16042 * Unless required by applicable law or agreed to in writing, software 16043 * distributed under the License is distributed on an "AS IS" BASIS, 16044 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16045 * See the License for the specific language governing permissions and 16046 * limitations under the License. 16047 * ============================================================================= 16048 */let bx;function rU(n){bx=n.wasm.cwrap("MaxPoolWithArgmax",null,["number","number","number","number","boolean","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function sU(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:a,strides:o,pad:i,includeBatchInIndex:c}=r;N(s.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`);const l=[1,1];N(Kt(o,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${l}'`);const u=kn(s.shape,a,o,[1,1],i),d=t.makeOutput(u.outShape,s.dtype),p=t.makeOutput(u.outShape,"int32");return bx(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(d.dataId).id,t.dataIdMap.get(p.dataId).id,Oe[s.dtype],c,u.batchSize,u.inChannels,u.inHeight,u.inWidth,u.outHeight,u.outWidth,u.strideHeight,u.strideWidth,u.dilationHeight,u.dilationWidth,u.effectiveFilterHeight,u.effectiveFilterWidth,u.padInfo.top,u.padInfo.left),[d,p]}const aU={kernelName:wd,backendName:"wasm",setupFunc:rU,kernelFunc:sU};/** 16049 * @license 16050 * Copyright 2020 Google LLC. All Rights Reserved. 16051 * Licensed under the Apache License, Version 2.0 (the "License");
16052 * you may not use this file except in compliance with the License. 16053 * You may obtain a copy of the License at 16054 * 16055 * http://www.apache.org/licenses/LICENSE-2.0 16056 * 16057 * Unless required by applicable law or agreed to in writing, software 16058 * distributed under the License is distributed on an "AS IS" BASIS, 16059 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16060 * See the License for the specific language governing permissions and 16061 * limitations under the License. 16062 * ============================================================================= 16063 */let xx;function oU(n){xx=n.wasm.cwrap(du,null,["number, number, number"])}function iU(n){const{backend:e,inputs:t,attrs:r}=n,{axis:s,keepDims:a}=r,{x:o}=t,i=e.dataIdMap.get(o.dataId).id;let c=i,l=o;const{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Zr(o,s,e);let m=d;if(h){const S=e.dataIdMap.get(u.dataId).id;S!==i&&(l=u,c=S,m=St(m.length,l.shape.length))}ht("mean",m,l.shape.length);const[g,y]=At(l.shape,m),b=H(y);let v=l;l.dtype!=="float32"&&(v=Jr({backend:e,inputs:{x:l},attrs:{dtype:"float32"}}),c=e.dataIdMap.get(v.dataId).id);const $=e.makeOutput(g,"float32");if(H(l.shape)!==0){const S=e.dataIdMap.get($.dataId).id;xx(c,b,S)}if(h&&e.disposeData(u.dataId),a){const S=pt($.shape,p);$.shape=S}return l.dtype!=="float32"&&e.disposeData(v.dataId),$}const uU={kernelName:du,backendName:"wasm",setupFunc:oU,kernelFunc:iU};/** 16064 * @license 16065 * Copyright 2019 Google LLC. All Rights Reserved. 16066 * Licensed under the Apache License, Version 2.0 (the "License"); 16067 * you may not use this file except in compliance with the License. 16068 * You may obtain a copy of the License at 16069 * 16070 * http://www.apache.org/licenses/LICENSE-2.0 16071 * 16072 * Unless required by applicable law or agreed to in writing, software 16073 * distributed under the License is distributed on an "AS IS" BASIS, 16074 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16075 * See the License for the specific language governing permissions and 16076 * limitations under the License. 16077 * ============================================================================= 16078 */let wx;function cU(n){wx=n.wasm.cwrap(pu,null,["number","number","number","number"])}function lU(n){const{backend:e,inputs:t,attrs:r}=n,{axis:s,keepDims:a}=r,{x:o}=t,i=e.dataIdMap.get(o.dataId).id;let c=i,l=o;const{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Zr(o,s,e);if(h){const $=e.dataIdMap.get(u.dataId).id;$!==i&&(l=u,c=$)}const m=l.shape.length;ht("min",d,m);const[g,y]=At(l.shape,d),b=H(y),v=e.makeOutput(g,l.dtype);if(H(l.shape)!==0){const $=e.dataIdMap.get(v.dataId).id;wx(c,Oe[o.dtype],b,$)}if(h&&e.disposeData(u.dataId),a){const $=pt(v.shape,p);v.shape=$}return v}const dU={kernelName:pu,backendName:"wasm",setupFunc:cU,kernelFunc:lU};/** 16079 * @license 16080 * Copyright 2019 Google LLC. All Rights Reserved. 16081 * Licensed under the Apache License, Version 2.0 (the "License"); 16082 * you may not use this file except in compliance with the License. 16083 * You may obtain a copy of the License at 16084 * 16085 * http://www.apache.org/licenses/LICENSE-2.0 16086 * 16087 * Unless required by applicable law or agreed to in writing, software 16088 * distributed under the License is distributed on an "AS IS" BASIS, 16089 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16090 * See the License for the specific language governing permissions and 16091 * limitations under the License. 16092 * ============================================================================= 16093 */const pU=lt(vd);/** 16094 * @license 16095 * Copyright 2021 Google LLC. All Rights Reserved. 16096 * Licensed under the Apache License, Version 2.0 (the "License"); 16097 * you may not use this file except in compliance with the License. 16098 * You may obtain a copy of the License at 16099 * 16100 * http://www.apache.org/licenses/LICENSE-2.0 16101 * 16102 * Unless required by applicable law or agreed to in writing, software 16103 * distributed under the License is distributed on an "AS IS" BASIS, 16104 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16105 * See the License for the specific language governing permissions and 16106 * limitations under the License. 16107 * ============================================================================= 16108 */var il;(function(n){n[n.reflect=0]="reflect",n[n.symmetric=1]="symmetric"})(il||(il={}));let vx;function hU(n){vx=n.wasm.cwrap(hu,null,["number","array","number","number","array","array","number","number"])}function fU(n){const{inputs:{x:e},backend:t,attrs:{paddings:r,mode:s}}=n,a=r.map((m,g)=>m[0]+e.shape[g]+m[1]),o=t.dataIdMap.get(e.dataId).id,i=t.makeOutput(a,e.dtype),c=t.dataIdMap.get(i.dataId).id,l=new Uint8Array(new Int32Array(e.shape).buffer),u=r.map(m=>m[0]),d=r.map(m=>m[1]),p=new Uint8Array(new Int32Array(u).buffer),h=new Uint8Array(new Int32Array(d).buffer);return vx(o,l,e.shape.length,Oe[e.dtype],p,h,il[s],c),i}const mU={kernelName:hu,backendName:"wasm",kernelFunc:fU,setupFunc:hU};/** 16109 * @license 16110 * Copyright 2020 Google LLC. All Rights Reserved. 16111 * Licensed under the Apache License, Version 2.0 (the "License");
16112 * you may not use this file except in compliance with the License. 16113 * You may obtain a copy of the License at 16114 * 16115 * http://www.apache.org/licenses/LICENSE-2.0 16116 * 16117 * Unless required by applicable law or agreed to in writing, software 16118 * distributed under the License is distributed on an "AS IS" BASIS, 16119 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16120 * See the License for the specific language governing permissions and 16121 * limitations under the License. 16122 * ============================================================================= 16123 */let Ix;function gU(n){Ix=n.wasm.cwrap(ku,null,["number","number","number","number"])}function $x(n){const{backend:e,inputs:{logits:t},attrs:{dim:r}}=n,s=e.dataIdMap.get(t.dataId).id,a=e.makeOutput(t.shape,t.dtype),o=e.dataIdMap.get(a.dataId).id,i=t.shape[r],c=H(t.shape)/i;return H(a.shape)===0||Ix(s,o,i,c),a}const yU={kernelName:ku,backendName:"wasm",setupFunc:gU,kernelFunc:$x};/** 16124 * @license 16125 * Copyright 2023 Google LLC. 16126 * Licensed under the Apache License, Version 2.0 (the "License"); 16127 * you may not use this file except in compliance with the License. 16128 * You may obtain a copy of the License at 16129 * 16130 * http://www.apache.org/licenses/LICENSE-2.0 16131 * 16132 * Unless required by applicable law or agreed to in writing, software 16133 * distributed under the License is distributed on an "AS IS" BASIS, 16134 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16135 * See the License for the specific language governing permissions and 16136 * limitations under the License. 16137 * ============================================================================= 16138 */let Sx;function bU(n){Sx=n.wasm.cwrap(fu,null,["number","number","number","number","number","number"])}function xU(n){const{inputs:e,backend:t,attrs:r}=n,{logits:s}=e,{numSamples:a,seed:o,normalized:i}=r;if(s.dtype!=="float32")throw new Error(`Tensor logits must have dtype float32, got ${s.dtype}`);const c=i?s:$x({inputs:{logits:s},backend:t,attrs:{dim:s.shape.length-1}}),[l,u]=c.shape,d=t.makeOutput([l,a],"int32");return Sx(t.dataIdMap.get(c.dataId).id,l,u,a,o,t.dataIdMap.get(d.dataId).id),i||t.disposeData(c.dataId),d}const wU={kernelName:fu,backendName:"wasm",setupFunc:bU,kernelFunc:xU};/** 16139 * @license 16140 * Copyright 2023 Google LLC. 16141 * Licensed under the Apache License, Version 2.0 (the "License"); 16142 * you may not use this file except in compliance with the License. 16143 * You may obtain a copy of the License at 16144 * 16145 * http://www.apache.org/licenses/LICENSE-2.0 16146 * 16147 * Unless required by applicable law or agreed to in writing, software 16148 * distributed under the License is distributed on an "AS IS" BASIS, 16149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16150 * See the License for the specific language governing permissions and 16151 * limitations under the License. 16152 * ============================================================================= 16153 */const vU=lt(Id);/** 16154 * @license 16155 * Copyright 2019 Google LLC. All Rights Reserved. 16156 * Licensed under the Apache License, Version 2.0 (the "License"); 16157 * you may not use this file except in compliance with the License. 16158 * You may obtain a copy of the License at 16159 * 16160 * http://www.apache.org/licenses/LICENSE-2.0 16161 * 16162 * Unless required by applicable law or agreed to in writing, software 16163 * distributed under the License is distributed on an "AS IS" BASIS, 16164 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16165 * See the License for the specific language governing permissions and 16166 * limitations under the License. 16167 * ============================================================================= 16168 */const IU=lt($d);/** 16169 * @license 16170 * Copyright 2020 Google LLC. All Rights Reserved. 16171 * Licensed under the Apache License, Version 2.0 (the "License"); 16172 * you may not use this file except in compliance with the License. 16173 * You may obtain a copy of the License at 16174 * 16175 * http://www.apache.org/licenses/LICENSE-2.0 16176 * 16177 * Unless required by applicable law or agreed to in writing, software 16178 * distributed under the License is distributed on an "AS IS" BASIS, 16179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16180 * See the License for the specific language governing permissions and 16181 * limitations under the License. 16182 * ============================================================================= 16183 */const $U=Ae(Sd);/** 16184 * @license 16185 * Copyright 2019 Google LLC. All Rights Reserved. 16186 * Licensed under the Apache License, Version 2.0 (the "License");
16187 * you may not use this file except in compliance with the License. 16188 * You may obtain a copy of the License at 16189 * 16190 * http://www.apache.org/licenses/LICENSE-2.0 16191 * 16192 * Unless required by applicable law or agreed to in writing, software 16193 * distributed under the License is distributed on an "AS IS" BASIS, 16194 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16195 * See the License for the specific language governing permissions and 16196 * limitations under the License. 16197 * ============================================================================= 16198 */function ah(n,e){const t=new Int32Array(n.wasm.HEAPU8.buffer,e,4),r=t[0],s=t[1],a=t[2],o=t[3];return n.wasm._free(e),{pSelectedIndices:r,selectedSize:s,pSelectedScores:a,pValidOutputs:o}}/** 16199 * @license 16200 * Copyright 2019 Google LLC. All Rights Reserved. 16201 * Licensed under the Apache License, Version 2.0 (the "License"); 16202 * you may not use this file except in compliance with the License. 16203 * You may obtain a copy of the License at 16204 * 16205 * http://www.apache.org/licenses/LICENSE-2.0 16206 * 16207 * Unless required by applicable law or agreed to in writing, software 16208 * distributed under the License is distributed on an "AS IS" BASIS, 16209 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16210 * See the License for the specific language governing permissions and 16211 * limitations under the License. 16212 * ============================================================================= 16213 */let Cx;function SU(n){Cx=n.wasm.cwrap(mu,"number",["number","number","number","number","number"])}function CU(n){const{backend:e,inputs:t,attrs:r}=n,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o}=r,{boxes:i,scores:c}=t,l=e.dataIdMap.get(i.dataId).id,u=e.dataIdMap.get(c.dataId).id,d=Cx(l,u,a,s,o),{pSelectedIndices:p,selectedSize:h,pSelectedScores:m,pValidOutputs:g}=ah(e,d);return e.wasm._free(m),e.wasm._free(g),e.makeOutput([h],"int32",p)}const _U={kernelName:mu,backendName:"wasm",setupFunc:SU,kernelFunc:CU};/** 16214 * @license 16215 * Copyright 2020 Google LLC. All Rights Reserved. 16216 * Licensed under the Apache License, Version 2.0 (the "License"); 16217 * you may not use this file except in compliance with the License. 16218 * You may obtain a copy of the License at 16219 * 16220 * http://www.apache.org/licenses/LICENSE-2.0 16221 * 16222 * Unless required by applicable law or agreed to in writing, software 16223 * distributed under the License is distributed on an "AS IS" BASIS, 16224 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16225 * See the License for the specific language governing permissions and 16226 * limitations under the License. 16227 * ============================================================================= 16228 */let _x;function NU(n){_x=n.wasm.cwrap(gu,"number",["number","number","number","number","number","bool"])}function TU(n){const{backend:e,inputs:t,attrs:r}=n,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o,padToMaxOutputSize:i}=r,{boxes:c,scores:l}=t,u=e.dataIdMap.get(c.dataId).id,d=e.dataIdMap.get(l.dataId).id,p=_x(u,d,a,s,o,i),{pSelectedIndices:h,selectedSize:m,pSelectedScores:g,pValidOutputs:y}=ah(e,p);e.wasm._free(g);const b=e.makeOutput([m],"int32",h),v=e.makeOutput([],"int32",y);return[b,v]}const kU={kernelName:gu,backendName:"wasm",setupFunc:NU,kernelFunc:TU};/** 16229 * @license 16230 * Copyright 2019 Google LLC. All Rights Reserved. 16231 * Licensed under the Apache License, Version 2.0 (the "License"); 16232 * you may not use this file except in compliance with the License. 16233 * You may obtain a copy of the License at 16234 * 16235 * http://www.apache.org/licenses/LICENSE-2.0 16236 * 16237 * Unless required by applicable law or agreed to in writing, software 16238 * distributed under the License is distributed on an "AS IS" BASIS, 16239 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16240 * See the License for the specific language governing permissions and 16241 * limitations under the License. 16242 * ============================================================================= 16243 */let Nx;function EU(n){Nx=n.wasm.cwrap(yu,"number",["number","number","number","number","number","number"])}function RU(n){const{backend:e,inputs:t,attrs:r}=n,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o,softNmsSigma:i}=r,{boxes:c,scores:l}=t,u=e.dataIdMap.get(c.dataId).id,d=e.dataIdMap.get(l.dataId).id,p=Nx(u,d,a,s,o,i),{pSelectedIndices:h,selectedSize:m,pSelectedScores:g,pValidOutputs:y}=ah(e,p);e.wasm._free(y);const b=e.makeOutput([m],"int32",h),v=e.makeOutput([m],"float32",g);return[b,v]}const AU={kernelName:yu,backendName:"wasm",setupFunc:EU,kernelFunc:RU};/** 16244 * @license 16245 * Copyright 2020 Google LLC. All Rights Reserved. 16246 * Licensed under the Apache License, Version 2.0 (the "License");
16247 * you may not use this file except in compliance with the License. 16248 * You may obtain a copy of the License at 16249 * 16250 * http://www.apache.org/licenses/LICENSE-2.0 16251 * 16252 * Unless required by applicable law or agreed to in writing, software 16253 * distributed under the License is distributed on an "AS IS" BASIS, 16254 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16255 * See the License for the specific language governing permissions and 16256 * limitations under the License. 16257 * ============================================================================= 16258 */const DU=!1,OU=lt(Cd,DU,"bool");/** 16259 * @license 16260 * Copyright 2020 Google LLC. All Rights Reserved. 16261 * Licensed under the Apache License, Version 2.0 (the "License"); 16262 * you may not use this file except in compliance with the License. 16263 * You may obtain a copy of the License at 16264 * 16265 * http://www.apache.org/licenses/LICENSE-2.0 16266 * 16267 * Unless required by applicable law or agreed to in writing, software 16268 * distributed under the License is distributed on an "AS IS" BASIS, 16269 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16270 * See the License for the specific language governing permissions and 16271 * limitations under the License. 16272 * ============================================================================= 16273 */let Tx;function FU(n){Tx=n.wasm.cwrap(bu,null,["number","number","number","number","number"])}function PU(n){const{inputs:e,backend:t,attrs:r}=n,{indices:s}=e,{dtype:a,depth:o,onValue:i,offValue:c}=r,l=t.makeOutput([...s.shape,o],a),u=t.dataIdMap.get(l.dataId).id,p=t.dataIdMap.get(s.dataId).id;return Tx(p,o,i,c,u),l}const LU={kernelName:bu,backendName:"wasm",setupFunc:FU,kernelFunc:PU};/** 16274 * @license 16275 * Copyright 2020 Google LLC. All Rights Reserved. 16276 * Licensed under the Apache License, Version 2.0 (the "License"); 16277 * you may not use this file except in compliance with the License. 16278 * You may obtain a copy of the License at 16279 * 16280 * http://www.apache.org/licenses/LICENSE-2.0 16281 * 16282 * Unless required by applicable law or agreed to in writing, software 16283 * distributed under the License is distributed on an "AS IS" BASIS, 16284 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16285 * See the License for the specific language governing permissions and 16286 * limitations under the License. 16287 * ============================================================================= 16288 */function MU(n){const{inputs:{x:e},backend:t}=n,r=t.makeOutput(e.shape,e.dtype);return t.typedArrayFromHeap(r).fill(1),r}const BU={kernelName:_d,backendName:"wasm",kernelFunc:MU};/** 16289 * @license 16290 * Copyright 2020 Google LLC. All Rights Reserved. 16291 * Licensed under the Apache License, Version 2.0 (the "License"); 16292 * you may not use this file except in compliance with the License. 16293 * You may obtain a copy of the License at 16294 * 16295 * http://www.apache.org/licenses/LICENSE-2.0 16296 * 16297 * Unless required by applicable law or agreed to in writing, software 16298 * distributed under the License is distributed on an "AS IS" BASIS, 16299 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16300 * See the License for the specific language governing permissions and 16301 * limitations under the License. 16302 * ============================================================================= 16303 */function VU(n){const{inputs:e,backend:t,attrs:r}=n,{axis:s}=r;if(e.length===1)return ol({inputs:{input:e[0]},backend:t,attrs:{dim:s}});const a=e[0].shape,o=e[0].dtype;e.forEach(u=>{sn(a,u.shape,"All tensors passed to stack must have matching shapes"),N(o===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const i=[],c=e.map(u=>{const d=ol({inputs:{input:u},backend:t,attrs:{dim:s}});return i.push(d),d}),l=Bb({inputs:c,backend:t,attrs:{axis:s}});return i.forEach(u=>t.disposeData(u.dataId)),l}const WU={kernelName:Nd,backendName:"wasm",kernelFunc:VU};/** 16304 * @license 16305 * Copyright 2019 Google LLC. All Rights Reserved. 16306 * Licensed under the Apache License, Version 2.0 (the "License"); 16307 * you may not use this file except in compliance with the License. 16308 * You may obtain a copy of the License at 16309 * 16310 * http://www.apache.org/licenses/LICENSE-2.0 16311 * 16312 * Unless required by applicable law or agreed to in writing, softw
16312are 16313 * distributed under the License is distributed on an "AS IS" BASIS, 16314 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16315 * See the License for the specific language governing permissions and 16316 * limitations under the License. 16317 * ============================================================================= 16318 */let kx;function UU(n){kx=n.wasm.cwrap(xu,null,["number","array","number","number","array","array","number","number"])}function zU(n){const{inputs:{x:e},backend:t,attrs:{paddings:r,constantValue:s}}=n,a=r.map((g,y)=>g[0]+e.shape[y]+g[1]);if(H(e.shape)===0)return nx({backend:t,attrs:{shape:a,value:s,dtype:e.dtype}});const o=t.dataIdMap.get(e.dataId).id,i=t.makeOutput(a,e.dtype),l=t.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(e.shape).buffer),d=r.map(g=>g[0]),p=r.map(g=>g[1]),h=new Uint8Array(new Int32Array(d).buffer),m=new Uint8Array(new Int32Array(p).buffer);return kx(o,u,e.shape.length,Oe[e.dtype],h,m,s,l),i}const Ex={kernelName:xu,backendName:"wasm",kernelFunc:zU,setupFunc:UU};/** 16319 * @license 16320 * Copyright 2019 Google LLC. All Rights Reserved. 16321 * Licensed under the Apache License, Version 2.0 (the "License"); 16322 * you may not use this file except in compliance with the License. 16323 * You may obtain a copy of the License at 16324 * 16325 * http://www.apache.org/licenses/LICENSE-2.0 16326 * 16327 * Unless required by applicable law or agreed to in writing, software 16328 * distributed under the License is distributed on an "AS IS" BASIS, 16329 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16330 * See the License for the specific language governing permissions and 16331 * limitations under the License. 16332 * ============================================================================= 16333 */const GU=lt(Td);/** 16334 * @license 16335 * Copyright 2019 Google LLC. All Rights Reserved. 16336 * Licensed under the Apache License, Version 2.0 (the "License"); 16337 * you may not use this file except in compliance with the License. 16338 * You may obtain a copy of the License at 16339 * 16340 * http://www.apache.org/licenses/LICENSE-2.0 16341 * 16342 * Unless required by applicable law or agreed to in writing, software 16343 * distributed under the License is distributed on an "AS IS" BASIS, 16344 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16345 * See the License for the specific language governing permissions and 16346 * limitations under the License. 16347 * ============================================================================= 16348 */let Rx;function HU(n){Rx=n.wasm.cwrap(wu,null,["number","number","number"])}function jU(n){const{inputs:e,backend:t}=n,{x:r,alpha:s}=e,a=t.dataIdMap.get(r.dataId).id,o=t.dataIdMap.get(s.dataId).id;let i=a;const c=r;let l=c;c.dtype!=="float32"&&(l=Jr({backend:t,inputs:{x:r},attrs:{dtype:"float32"}}),i=t.dataIdMap.get(l.dataId).id);const u=t.makeOutput(r.shape,"float32"),d=t.dataIdMap.get(u.dataId).id;return Rx(i,o,d),c.dtype!=="float32"&&t.disposeData(l.dataId),u}const qU={kernelName:wu,backendName:"wasm",setupFunc:HU,kernelFunc:jU};/** 16349 * @license 16350 * Copyright 2020 Google LLC. All Rights Reserved. 16351 * Licensed under the Apache License, Version 2.0 (the "License"); 16352 * you may not use this file except in compliance with the License. 16353 * You may obtain a copy of the License at 16354 * 16355 * http://www.apache.org/licenses/LICENSE-2.0 16356 * 16357 * Unless required by applicable law or agreed to in writing, software 16358 * distributed under the License is distributed on an "AS IS" BASIS, 16359 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16360 * See the License for the specific language governing permissions and 16361 * limitations under the License. 16362 * ============================================================================= 16363 */let Ax;function KU(n){Ax=n.wasm.cwrap(vu,null,["number","number","number","number"])}function XU(n){const{backend:e,inputs:t,attrs:r}=n,{axis:s,keepDims:a}=r,{x:o}=t,i=e.dataIdMap.get(o.dataId).id;let c=i,l=o;const{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Zr(o,s,e);let m=d;if(h){const $=e.dataIdMap.get(u.dataId).id;$!==i&&(l=u,c=$,m=St(m.length,l.shape.length))}ht("prod",m,l.shape.length);const[g,y]=At(l.shape,m),b=H(y),v=e.makeOutput(g,l.dtype);if(H(l.shape)!==0){const $=e.dataIdMap.get(v.dataId).id;Ax(c,b,Oe[v.dtype],$)}if(h&&e.disposeData(u.dataId),a){const $=pt(v.shape,p);v.shape=$}return v}const YU={kernelName:vu,backendName:"wasm",setupFunc:KU,kernelFunc:XU};/** 16364 * @license 16365 * Copyright 2020 Google LLC. All Rights Reserved. 16366 * Licensed under the Apache License, Version 2.0 (the "License");
16367 * you may not use this file except in compliance with the License. 16368 * You may obtain a copy of the License at 16369 * 16370 * http://www.apache.org/licenses/LICENSE-2.0 16371 * 16372 * Unless required by applicable law or agreed to in writing, software 16373 * distributed under the License is distributed on an "AS IS" BASIS, 16374 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16375 * See the License for the specific language governing permissions and 16376 * limitations under the License. 16377 * ============================================================================= 16378 */const QU=n=>{const{backend:e,attrs:t}=n,{start:r,stop:s,step:a,dtype:o}=t,i=Vy(r,s,a,o),c=e.makeOutput([i.length],o);return e.typedArrayFromHeap(c).set(i),c},ZU={kernelName:kd,backendName:"wasm",kernelFunc:QU};/** 16379 * @license 16380 * Copyright 2019 Google LLC. All Rights Reserved. 16381 * Licensed under the Apache License, Version 2.0 (the "License"); 16382 * you may not use this file except in compliance with the License. 16383 * You may obtain a copy of the License at 16384 * 16385 * http://www.apache.org/licenses/LICENSE-2.0 16386 * 16387 * Unless required by applicable law or agreed to in writing, software 16388 * distributed under the License is distributed on an "AS IS" BASIS, 16389 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16390 * See the License for the specific language governing permissions and 16391 * limitations under the License. 16392 * ============================================================================= 16393 */const JU=lt(ql);/** 16394 * @license 16395 * Copyright 2022 The TensorFlow Authors. All Rights Reserved. 16396 * Licensed under the Apache License, Version 2.0 (the "License"); 16397 * you may not use this file except in compliance with the License. 16398 * You may obtain a copy of the License at 16399 * 16400 * http://www.apache.org/licenses/LICENSE-2.0 16401 * 16402 * Unless required by applicable law or agreed to in writing, software 16403 * distributed under the License is distributed on an "AS IS" BASIS, 16404 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16405 * See the License for the specific language governing permissions and 16406 * limitations under the License. 16407 * ============================================================================= 16408 */const ez=Ae(Ed);/** 16409 * @license 16410 * Copyright 2019 Google LLC. All Rights Reserved. 16411 * Licensed under the Apache License, Version 2.0 (the "License"); 16412 * you may not use this file except in compliance with the License. 16413 * You may obtain a copy of the License at 16414 * 16415 * http://www.apache.org/licenses/LICENSE-2.0 16416 * 16417 * Unless required by applicable law or agreed to in writing, software 16418 * distributed under the License is distributed on an "AS IS" BASIS, 16419 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16420 * See the License for the specific language governing permissions and 16421 * limitations under the License. 16422 * ============================================================================= 16423 */const tz=Ae(Rd);/** 16424 * @license 16425 * Copyright 2019 Google LLC. All Rights Reserved. 16426 * Licensed under the Apache License, Version 2.0 (the "License"); 16427 * you may not use this file except in compliance with the License. 16428 * You may obtain a copy of the License at 16429 * 16430 * http://www.apache.org/licenses/LICENSE-2.0 16431 * 16432 * Unless required by applicable law or agreed to in writing, software 16433 * distributed under the License is distributed on an "AS IS" BASIS, 16434 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16435 * See the License for the specific language governing permissions and 16436 * limitations under the License. 16437 * ============================================================================= 16438 */const nz=Ae(Fd);/** 16439 * @license 16440 * Copyright 2019 Google LLC. All Rights Reserved. 16441 * Licensed under the Apache License, Version 2.0 (the "License"); 16442 * you may not use this file except in compliance with the License. 16443 * You may obtain a copy of the License at 16444 * 16445 * http://www.apache.org/licenses/LICENSE-2.0 16446 * 16447 * Unless required by applicable law or agreed to in writing, software 16448 * distributed under the License is distributed on an "AS IS" BASIS, 16449 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16450 * See the License for the specific language governing permissions and 16451 * limitations under the License. 16452 * ============================================================================= 16453 */let Dx;function rz(n){Dx=n.wasm.cwrap($u,null,["number","number","number","number","number","number","number","number","number","number"])}
vendor: 8,796 bytes, lines 16453-16561
16453function sz(n){const{backend:e,inputs:t,attrs:r}=n,{images:s}=t,{alignCorners:a,halfPixelCenters:o,size:i}=r,[c,l]=i,[u,d,p,h]=s.shape,m=[u,c,l,h];let g=e.dataIdMap.get(s.dataId),y;g.dtype!=="float32"&&(y=Jr({backend:e,inputs:{x:s},attrs:{dtype:"float32"}}),g=e.dataIdMap.get(y.dataId));const b=g.id,v=e.makeOutput(m,"float32");if(H(s.shape)===0)return v;const $=e.dataIdMap.get(v.dataId).id;return Dx(b,u,d,p,h,c,l,a?1:0,o?1:0,$),y!=null&&e.disposeData(y.dataId),v}const az={kernelName:$u,backendName:"wasm",setupFunc:rz,kernelFunc:sz};/** 16454 * @license 16455 * Copyright 2023 Google LLC. 16456 * Licensed under the Apache License, Version 2.0 (the "License"); 16457 * you may not use this file except in compliance with the License. 16458 * You may obtain a copy of the License at 16459 * 16460 * http://www.apache.org/licenses/LICENSE-2.0 16461 * 16462 * Unless required by applicable law or agreed to in writing, software 16463 * distributed under the License is distributed on an "AS IS" BASIS, 16464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16465 * See the License for the specific language governing permissions and 16466 * limitations under the License. 16467 * ============================================================================= 16468 */let Ox;function oz(n){Ox=n.wasm.cwrap(Od,null,["number","number","number","array","array","boolean"])}function iz(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:a}=e,{alignCorners:o}=r,i=t.makeOutput(s.shape,"float32");let c=t.dataIdMap.get(s.dataId),l;return c.dtype!=="float32"&&(l=Jr({backend:t,inputs:{x:s},attrs:{dtype:"float32"}}),c=t.dataIdMap.get(l.dataId)),Ox(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(i.dataId).id,new Uint8Array(new Int32Array(s.shape).buffer),new Uint8Array(new Int32Array(a.shape).buffer),o),l!=null&&t.disposeData(l.dataId),i}const uz={kernelName:Od,backendName:"wasm",setupFunc:oz,kernelFunc:iz};/** 16469 * @license 16470 * Copyright 2019 Google LLC. All Rights Reserved. 16471 * Licensed under the Apache License, Version 2.0 (the 'License'); 16472 * you may not use this file except in compliance with the License. 16473 * You may obtain a copy of the License at 16474 * 16475 * http://www.apache.org/licenses/LICENSE-2.0 16476 * 16477 * Unless required by applicable law or agreed to in writing, software 16478 * distributed under the License is distributed on an 'AS IS' BASIS, 16479 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16480 * See the License for the specific language governing permissions and 16481 * limitations under the License. 16482 * ============================================================================= 16483 */let Fx;function cz(n){Fx=n.wasm.cwrap(Iu,null,["number","number","number","number","number","number","number","number","number","number"])}function lz(n){const{backend:e,inputs:t,attrs:r}=n,{images:s}=t,{alignCorners:a,halfPixelCenters:o,size:i}=r,[c,l]=i,[u,d,p,h]=s.shape,m=[u,c,l,h],g=e.makeOutput(m,"float32");if(H(s.shape)===0)return g;let y=e.dataIdMap.get(s.dataId),b;y.dtype!=="float32"&&(b=Jr({backend:e,inputs:{x:s},attrs:{dtype:"float32"}}),y=e.dataIdMap.get(b.dataId));const v=y.id,$=e.dataIdMap.get(g.dataId).id;return Fx(v,u,d,p,h,c,l,a?1:0,o?1:0,$),b!=null&&e.disposeData(b.dataId),g}const dz={kernelName:Iu,backendName:"wasm",setupFunc:cz,kernelFunc:lz};/** 16484 * @license 16485 * Copyright 2023 Google LLC. 16486 * Licensed under the Apache License, Version 2.0 (the "License"); 16487 * you may not use this file except in compliance with the License. 16488 * You may obtain a copy of the License at 16489 * 16490 * http://www.apache.org/licenses/LICENSE-2.0 16491 * 16492 * Unless required by applicable law or agreed to in writing, software 16493 * distributed under the License is distributed on an "AS IS" BASIS, 16494 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16495 * See the License for the specific language governing permissions and 16496 * limitations under the License. 16497 * ============================================================================= 16498 */let Px;function pz(n){Px=n.wasm.cwrap(Dd,null,["number","number","number","array","array","boolean"])}function hz(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:a}=e,{alignCorners:o}=r,i=t.makeOutput(s.shape,"float32");let c=t.dataIdMap.get(s.dataId),l;return c.dtype!=="float32"&&(l=Jr({backend:t,inputs:{x:s},attrs:{dtype:"float32"}}),c=t.dataIdMap.get(l.dataId)),Px(t.dataIdMap.get(s.dataId).id,t.dataIdMap.get(a.dataId).id,t.dataIdMap.get(i.dataId).id,new Uint8Array(new Int32Array(s.shape).buffer),new Uint8Array(new Int32Array(a.shape).buffer),o),l!=null&&t.disposeData(l.dataId),i}const fz={kernelName:Dd,backendName:"wasm",setupFunc:pz,kernelFunc:hz};/** 16499 * @license 16500 * Copyright 2020 Google LLC. All Rights Reserved. 16501 * Licensed under the Apache License, Version 2.0 (the "License"); 16502 * you may not use this file except in compliance with the License. 16503 * You may obtain a copy of the License at 16504 * 16505 * http://www.apache.org/licenses/LICENSE-2.0 16506 * 16507 * Unless required by applicable law or agreed to in writing, software 16508 * distributed under the License is distributed on an "AS IS" BASIS, 16509 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16510 * See the License for the specific language governing permissions and 16511 * limitations under the License. 16512 * ============================================================================= 16513 */let Lx;function mz(n){Lx=n.wasm.cwrap(Su,null,["number","array","number","array","number","number"])}function gz(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{dims:a}=r,o=ot(a,s.shape);if(s.shape.length===0)return sc({inputs:{x:s},backend:t});const i=t.makeOutput(s.shape,s.dtype),c=t.dataIdMap.get(s.dataId).id,l=t.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(o).buffer),d=new Uint8Array(new Int32Array(s.shape).buffer);Lx(c,u,o.length,d,s.shape.length,l);const p=jt({inputs:{x:i},attrs:{shape:s.shape},backend:t});return t.disposeData(i.dataId),p}const yz={kernelName:Su,backendName:"wasm",kernelFunc:gz,setupFunc:mz};/** 16514 * @license 16515 * Copyright 2019 Google LLC. All Rights Reserved. 16516 * Licensed under the Apache License, Version 2.0 (the "License"); 16517 * you may not use this file except in compliance with the License. 16518 * You may obtain a copy of the License at 16519 * 16520 * http://www.apache.org/licenses/LICENSE-2.0 16521 * 16522 * Unless required by applicable law or agreed to in writing, software 16523 * distributed under the License is distributed on an "AS IS" BASIS, 16524 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16525 * See the License for the specific language governing permissions and 16526 * limitations under the License. 16527 * ============================================================================= 16528 */let Mx;function bz(n){Mx=n.wasm.cwrap(Pu,null,["number","number","number","number","number","number","number","number","array","number","number"])}function xz(n){const{inputs:e,backend:t,attrs:r}=n,{image:s}=e,{radians:a,fillValue:o,center:i}=r,c=t.makeOutput(s.shape,s.dtype),l=t.dataIdMap.get(s.dataId).id,u=t.dataIdMap.get(c.dataId).id,[d,p,h,m]=s.shape,[g,y]=Dp(i,p,h),b=o===0,v=255,$=typeof o=="number"?[o,o,o,b?0:v]:[...o,v],S=new Uint8Array(new Int32Array($).buffer);return Mx(l,d,p,h,m,a,g,y,S,$.length,u),c}const wz={kernelName:Pu,backendName:"wasm",kernelFunc:xz,setupFunc:bz};/** 16529 * @license 16530 * Copyright 2021 Google LLC. All Rights Reserved. 16531 * Licensed under the Apache License, Version 2.0 (the "License"); 16532 * you may not use this file except in compliance with the License. 16533 * You may obtain a copy of the License at 16534 * 16535 * http://www.apache.org/licenses/LICENSE-2.0 16536 * 16537 * Unless required by applicable law or agreed to in writing, software 16538 * distributed under the License is distributed on an "AS IS" BASIS, 16539 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16540 * See the License for the specific language governing permissions and 16541 * limitations under the License. 16542 * ============================================================================= 16543 */const vz=Ae(Pd);/** 16544 * @license 16545 * Copyright 2019 Google LLC. All Rights Reserved. 16546 * Licensed under the Apache License, Version 2.0 (the "License"); 16547 * you may not use this file except in compliance with the License. 16548 * You may obtain a copy of the License at 16549 * 16550 * http://www.apache.org/licenses/LICENSE-2.0 16551 * 16552 * Unless required by applicable law or agreed to in writing, software 16553 * distributed under the License is distributed on an "AS IS" BASIS, 16554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16555 * See the License for the specific language governing permissions and 16556 * limitations under the License. 16557 * ============================================================================= 16558 */const Iz=Ae(Ld);/** 16559 * @license 16560 * Copyright 2019 Google LLC. All Rights Reserved. 16561 * Licensed under the Apache License, Version 2.0 (the "License");
16562 * you may not use this file except in compliance with the License. 16563 * You may obtain a copy of the License at 16564 * 16565 * http://www.apache.org/licenses/LICENSE-2.0 16566 * 16567 * Unless required by applicable law or agreed to in writing, software 16568 * distributed under the License is distributed on an "AS IS" BASIS, 16569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16570 * See the License for the specific language governing permissions and 16571 * limitations under the License. 16572 * ============================================================================= 16573 */let Bx;function $z(n){Bx=n.wasm.cwrap(Cu,null,["number","number","number","number","number","number","array","number","number"])}function Sz(n){const{backend:e,inputs:t,attrs:r}=n,{indices:s,updates:a}=t,{shape:o}=r,i=e.makeOutput(o,a.dtype);if(H(o)===0)return i;const{sliceRank:c,numUpdates:l,sliceSize:u,strides:d,outputSize:p}=Ms(a,s,o),m=e.dataIdMap.get(s.dataId).id,y=e.dataIdMap.get(a.dataId).id,b=new Uint8Array(new Int32Array(d).buffer),v=e.dataIdMap.get(i.dataId).id;return Bx(m,y,Oe[a.dtype],c,l,u,b,p,v),i}const Cz={kernelName:Cu,backendName:"wasm",setupFunc:$z,kernelFunc:Sz};/** 16574 * @license 16575 * Copyright 2023 Google LLC. 16576 * Licensed under the Apache License, Version 2.0 (the "License"); 16577 * you may not use this file except in compliance with the License. 16578 * You may obtain a copy of the License at 16579 * 16580 * http://www.apache.org/licenses/LICENSE-2.0 16581 * 16582 * Unless required by applicable law or agreed to in writing, software 16583 * distributed under the License is distributed on an "AS IS" BASIS, 16584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16585 * See the License for the specific language governing permissions and 16586 * limitations under the License. 16587 * ============================================================================= 16588 */let Vx;function _z(n){Vx=n.wasm.cwrap(Nu,null,["number","number","number","number","number","number","bool","number"])}function Nz(n){const{inputs:e,backend:t,attrs:r}=n,{sortedSequence:s,values:a}=e,{side:o}=r;if(s.dtype!==a.dtype)throw new Error(`SearchSorted error: sorted_sequence must have the same dtype as values. Got ${s.dtype} and ${a.dtype}`);const i=t.makeOutput(a.shape,"int32");function c(l){return t.dataIdMap.get(l.dataId).id}return Vx(c(s),c(a),s.shape[0],s.shape[1],a.shape[1],Oe[s.dtype],o==="left",c(i)),i}const Tz={kernelName:Nu,backendName:"wasm",setupFunc:_z,kernelFunc:Nz};/** 16589 * @license 16590 * Copyright 2020 Google LLC. All Rights Reserved. 16591 * Licensed under the Apache License, Version 2.0 (the "License"); 16592 * you may not use this file except in compliance with the License. 16593 * You may obtain a copy of the License at 16594 * 16595 * http://www.apache.org/licenses/LICENSE-2.0 16596 * 16597 * Unless required by applicable law or agreed to in writing, software 16598 * distributed under the License is distributed on an "AS IS" BASIS, 16599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16600 * See the License for the specific language governing permissions and 16601 * limitations under the License. 16602 * ============================================================================= 16603 */let Wx;function kz(n){Wx=n.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}function Ez(n){const{inputs:e,backend:t}=n,{condition:r,t:s,e:a}=e,o=t.dataIdMap.get(r.dataId).id,i=t.dataIdMap.get(s.dataId).id,c=t.dataIdMap.get(a.dataId).id,l=t.makeOutput(s.shape,s.dtype),u=t.dataIdMap.get(l.dataId).id,d=r.shape.length,p=s.shape.length,h=d===0||d>1||p===1?1:H(s.shape.slice(1));return Wx(o,i,c,h,u),l}const Rz={kernelName:Md,backendName:"wasm",kernelFunc:Ez,setupFunc:kz};/** 16604 * @license 16605 * Copyright 2023 Google LLC. 16606 * Licensed under the Apache License, Version 2.0 (the "License"); 16607 * you may not use this file except in compliance with the License. 16608 * You may obtain a copy of the License at 16609 * 16610 * http://www.apache.org/licenses/LICENSE-2.0 16611 * 16612 * Unless required by applicable law or agreed to in writing, software 16613 * distributed under the License is distributed on an "AS IS" BASIS, 16614 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16615 * See the License for the specific language governing permissions and 16616 * limitations under the License. 16617 * ============================================================================= 16618 */const Az=Ae(Bd);/** 16619 * @license 16620 * Copyright 2019 Google LLC. All Rights Reserved. 16621 * Licensed under the Apache License, Version 2.0 (the "License");
16622 * you may not use this file except in compliance with the License. 16623 * You may obtain a copy of the License at 16624 * 16625 * http://www.apache.org/licenses/LICENSE-2.0 16626 * 16627 * Unless required by applicable law or agreed to in writing, software 16628 * distributed under the License is distributed on an "AS IS" BASIS, 16629 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16630 * See the License for the specific language governing permissions and 16631 * limitations under the License. 16632 * ============================================================================= 16633 */let Ux;function Dz(n){Ux=n.wasm.cwrap(Gd,null,["number","number"])}function Oz(n){const{backend:e,inputs:{x:t}}=n,r=e.dataIdMap.get(t.dataId).id,s=e.makeOutput(t.shape,t.dtype),a=e.dataIdMap.get(s.dataId).id;return H(s.shape)===0||Ux(r,a),s}const Fz={kernelName:"Sigmoid",backendName:"wasm",setupFunc:Dz,kernelFunc:Oz};/** 16634 * @license 16635 * Copyright 2023 Google LLC. 16636 * Licensed under the Apache License, Version 2.0 (the "License"); 16637 * you may not use this file except in compliance with the License. 16638 * You may obtain a copy of the License at 16639 * 16640 * http://www.apache.org/licenses/LICENSE-2.0 16641 * 16642 * Unless required by applicable law or agreed to in writing, software 16643 * distributed under the License is distributed on an "AS IS" BASIS, 16644 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16645 * See the License for the specific language governing permissions and 16646 * limitations under the License. 16647 * ============================================================================= 16648 */const Pz=Ae(zd);/** 16649 * @license 16650 * Copyright 2019 Google LLC. All Rights Reserved. 16651 * Licensed under the Apache License, Version 2.0 (the "License"); 16652 * you may not use this file except in compliance with the License. 16653 * You may obtain a copy of the License at 16654 * 16655 * http://www.apache.org/licenses/LICENSE-2.0 16656 * 16657 * Unless required by applicable law or agreed to in writing, software 16658 * distributed under the License is distributed on an "AS IS" BASIS, 16659 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16660 * See the License for the specific language governing permissions and 16661 * limitations under the License. 16662 * ============================================================================= 16663 */const Lz=Ae(Wd);/** 16664 * @license 16665 * Copyright 2023 Google LLC. 16666 * Licensed under the Apache License, Version 2.0 (the "License"); 16667 * you may not use this file except in compliance with the License. 16668 * You may obtain a copy of the License at 16669 * 16670 * http://www.apache.org/licenses/LICENSE-2.0 16671 * 16672 * Unless required by applicable law or agreed to in writing, software 16673 * distributed under the License is distributed on an "AS IS" BASIS, 16674 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16675 * See the License for the specific language governing permissions and 16676 * limitations under the License. 16677 * ============================================================================= 16678 */const Mz=Ae(Ud);/** 16679 * @license 16680 * Copyright 2023 Google LLC. 16681 * Licensed under the Apache License, Version 2.0 (the "License"); 16682 * you may not use this file except in compliance with the License. 16683 * You may obtain a copy of the License at 16684 * 16685 * http://www.apache.org/licenses/LICENSE-2.0 16686 * 16687 * Unless required by applicable law or agreed to in writing, software 16688 * distributed under the License is distributed on an "AS IS" BASIS, 16689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16690 * See the License for the specific language governing permissions and 16691 * limitations under the License. 16692 * ============================================================================= 16693 */const Bz=Ae(Hd);/** 16694 * @license 16695 * Copyright 2021 Google LLC. All Rights Reserved. 16696 * Licensed under the Apache License, Version 2.0 (the "License"); 16697 * you may not use this file except in compliance with the License. 16698 * You may obtain a copy of the License at 16699 * 16700 * http://www.apache.org/licenses/LICENSE-2.0 16701 * 16702 * Unless required by applicable law or agreed to in writing, software 16703 * distributed under the License is distributed on an "AS IS" BASIS, 16704 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16705 * See the License for the specific language governing permissions and 16706 * limitations under the License. 16707 * ============================================================================= 16708 */function Vz(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}
vendor: 4,468 bytes, lines 16708-16740
16708=e,{blockShape:a,paddings:o}=r,i=H(a),c=[[0,0]];c.push(...o);for(let O=1+a.length;O<s.shape.length;++O)c.push([0,0]);const l=Ex.kernelFunc({inputs:{x:s},backend:t,attrs:{paddings:c,constantValue:0}}),u=Ao(l.shape,a,i,!1),d=Do(u.length,a.length,!1),p=Oo(l.shape,a,i,!1),g=jt({inputs:{x:l},backend:t,attrs:{shape:u}}),v=Hr({inputs:{x:g},backend:t,attrs:{perm:d}}),T=jt({inputs:{x:v},backend:t,attrs:{shape:p}});return t.disposeData(l.dataId),t.disposeData(g.dataId),t.disposeData(v.dataId),T}const Wz={kernelName:qd,backendName:"wasm",kernelFunc:Vz};/** 16709 * @license 16710 * Copyright 2021 Google LLC. All Rights Reserved. 16711 * Licensed under the Apache License, Version 2.0 (the "License"); 16712 * you may not use this file except in compliance with the License. 16713 * You may obtain a copy of the License at 16714 * 16715 * http://www.apache.org/licenses/LICENSE-2.0 16716 * 16717 * Unless required by applicable law or agreed to in writing, software 16718 * distributed under the License is distributed on an "AS IS" BASIS, 16719 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16720 * See the License for the specific language governing permissions and 16721 * limitations under the License. 16722 * ============================================================================= 16723 */let zx;function Uz(n){zx=n.wasm.cwrap("SparseFillEmptyRows","number",["number","number","number","number","number","number","number","number","number","number","number","number"])}function zz(n){const{backend:e,inputs:t}=n,{indices:r,values:s,denseShape:a,defaultValue:o}=t,i=r.shape[0],c=r.shape[1],l=e.readSync(a.dataId)[0],u=[i+l,c],d=e.dataIdMap.get(r.dataId).id,p=e.dataIdMap.get(s.dataId).id,h=e.dataIdMap.get(o.dataId).id,m=e.makeOutput(u,r.dtype),g=e.dataIdMap.get(m.dataId).id,y=e.makeOutput(u.slice(0,1),s.dtype),b=e.dataIdMap.get(y.dataId).id,v=e.makeOutput([l],"bool"),$=e.dataIdMap.get(v.dataId).id,S=e.makeOutput([i],r.dtype),T=e.dataIdMap.get(S.dataId).id,O=e.makeOutput([4],"int32"),L=e.dataIdMap.get(O.dataId).id,M=zx(d,p,Oe[s.dtype],i,l,c,h,g,b,$,T,L),W=e.readSync(O.dataId);let V;switch(W[0]){case 1:{V=Lp(W[1]);break}case 2:{V=Mp(W[1],W[2]);break}case 3:V=Bp(W[1],W[2],W[3]);break;default:V=""}if(e.disposeData(O.dataId),V)throw e.disposeData(m.dataId),e.disposeData(y.dataId),e.disposeData(v.dataId),e.disposeData(S.dataId),new Error(V);let G=m,K=y;return M!==u[0]&&(G=Os({inputs:{x:m},attrs:{begin:0,size:[M,c]},backend:e}),K=Os({inputs:{x:y},attrs:{begin:0,size:M},backend:e}),e.disposeData(m.dataId),e.disposeData(y.dataId)),[G,K,v,S]}const Gz={kernelName:Xd,backendName:"wasm",setupFunc:Uz,kernelFunc:zz};/** 16724 * @license 16725 * Copyright 2021 Google LLC. All Rights Reserved. 16726 * Licensed under the Apache License, Version 2.0 (the "License"); 16727 * you may not use this file except in compliance with the License. 16728 * You may obtain a copy of the License at 16729 * 16730 * http://www.apache.org/licenses/LICENSE-2.0 16731 * 16732 * Unless required by applicable law or agreed to in writing, software 16733 * distributed under the License is distributed on an "AS IS" BASIS, 16734 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16735 * See the License for the specific language governing permissions and 16736 * limitations under the License. 16737 * ============================================================================= 16738 */let Gx;function Hz(n){Gx=n.wasm.cwrap(Eu,null,["number","number","number","number","number","number","number"])}function jz(n){const{backend:e,inputs:t}=n,{inputIndices:r,inputShape:s,newShape:a}=t;if(r.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape 16739 ${r.shape}`);if(s.shape.length!==1)throw new Error(`Input shape should be a vector but received shape 16740 ${s.shape}`);if(a.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${a.shape}`);const o=e.dataIdMap.get(r.dataId).id,i=e.dataIdMap.get(s.dataId).id,c=e.dataIdMap.get(a.dataId).id,l=r.shape[0],u=H(a.shape),d=e.makeOutput([l,u],r.dtype),p=e.dataIdMap.get(d.dataId).id,h=e.makeOutput([u],a.dtype),m=e.dataIdMap.get(h.dataId).id,g=e.makeOutput([3],"int32"),y=e.dataIdMap.get(g.dataId).id;Gx(o,i,c,l,p,m,y);const b=e.readSync(g.dataId);let v;switch(b[0]){case 0:{v=Vp(b[1],b[2]);break}case 1:{v=Wp(b[1],b[2]);break}case 2:v=Up();break;case 3:{const $=Array.from(e.readSync(s.dataId)),S=Array.from(e.readSync(h.dataId));v=zp($,S);break}case 4:{const $=Array.from(e.readSync(s.dataId)),S=Array.from(e.readSync(h.dataId));v=Gp($,S);break}default:v=""}
16740if(e.disposeData(g.dataId),v)throw e.disposeData(d.dataId),e.disposeData(h.dataId),new Error(v);return[d,h]}const qz={kernelName:Eu,backendName:"wasm",setupFunc:Hz,kernelFunc:jz};/** 16741 * @license 16742 * Copyright 2021 Google LLC. All Rights Reserved. 16743 * Licensed under the Apache License, Version 2.0 (the "License"); 16744 * you may not use this file except in compliance with the License. 16745 * You may obtain a copy of the License at 16746 * 16747 * http://www.apache.org/licenses/LICENSE-2.0 16748 * 16749 * Unless required by applicable law or agreed to in writing, software 16750 * distributed under the License is distributed on an "AS IS" BASIS, 16751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16752 * See the License for the specific language governing permissions and 16753 * limitations under the License. 16754 * ============================================================================= 16755 */let Hx;function jx(n){Hx=n.wasm.cwrap("SparseSegmentReduction",null,["number","number","number","number","number","number","number","number","number"])}function qx(n,e){const{backend:t,inputs:r}=n,{data:s,indices:a,segmentIds:o}=r,i=a.shape[0],c=t.readSync(o.dataId,i-1,i)[0],u=i>0?c+1:0;if(u<0)throw new Error(wo());const d=s.shape.slice();d[0]=u;const p=t.dataIdMap.get(s.dataId).id,h=t.dataIdMap.get(a.dataId).id,m=t.dataIdMap.get(o.dataId).id,g=t.makeOutput(d,s.dtype),y=t.dataIdMap.get(g.dataId).id,b=t.makeOutput([4],"int32"),v=t.dataIdMap.get(b.dataId).id;Hx(p,Oe[s.dtype],s.shape[0],h,m,y,v,e,0);const $=t.readSync(b.dataId);let S;switch($[0]){case 0:{S=wo();break}case 1:{S=Hp();break}case 2:S=jp($[1],$[2]);break;case 3:S=qp($[1],$[2],$[3]);break;default:S=""}if(t.disposeData(b.dataId),S)throw t.disposeData(g.dataId),new Error(S);return g}/** 16756 * @license 16757 * Copyright 2021 Google LLC. All Rights Reserved. 16758 * Licensed under the Apache License, Version 2.0 (the "License"); 16759 * you may not use this file except in compliance with the License. 16760 * You may obtain a copy of the License at 16761 * 16762 * http://www.apache.org/licenses/LICENSE-2.0 16763 * 16764 * Unless required by applicable law or agreed to in writing, software 16765 * distributed under the License is distributed on an "AS IS" BASIS, 16766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16767 * See the License for the specific language governing permissions and 16768 * limitations under the License. 16769 * ============================================================================= 16770 */function Kz(n){return qx(n,!0)}const Xz={kernelName:Yd,backendName:"wasm",setupFunc:jx,kernelFunc:Kz};/** 16771 * @license 16772 * Copyright 2021 Google LLC. All Rights Reserved. 16773 * Licensed under the Apache License, Version 2.0 (the "License"); 16774 * you may not use this file except in compliance with the License. 16775 * You may obtain a copy of the License at 16776 * 16777 * http://www.apache.org/licenses/LICENSE-2.0 16778 * 16779 * Unless required by applicable law or agreed to in writing, software 16780 * distributed under the License is distributed on an "AS IS" BASIS, 16781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16782 * See the License for the specific language governing permissions and 16783 * limitations under the License. 16784 * ============================================================================= 16785 */function Yz(n){return qx(n,!1)}const Qz={kernelName:Qd,backendName:"wasm",setupFunc:jx,kernelFunc:Yz};/** 16786 * @license 16787 * Copyright 2021 Google LLC. All Rights Reserved. 16788 * Licensed under the Apache License, Version 2.0 (the "License"); 16789 * you may not use this file except in compliance with the License. 16790 * You may obtain a copy of the License at 16791 * 16792 * http://www.apache.org/licenses/LICENSE-2.0 16793 * 16794 * Unless required by applicable law or agreed to in writing, software 16795 * distributed under the License is distributed on an "AS IS" BASIS, 16796 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16797 * See the License for the specific language governing permissions and 16798 * limitations under the License. 16799 * ============================================================================= 16800 */let Kx;function Zz(n){Kx=n.wasm.cwrap(Ru,null,["number","number","number","number","number","number","number","number","array","number","number"])}
vendor: 4,108 bytes, lines 16800-16869
16800function Jz(n){const{backend:e,inputs:t,attrs:r}=n,{sparseIndices:s,sparseValues:a,defaultValue:o}=t,{outputShape:i}=r,c=e.makeOutput(i,o.dtype);if(H(i)===0)return c;const{sliceRank:l,numUpdates:u,sliceSize:d,strides:p,outputSize:h}=Ms(a,s,i),m=e.dataIdMap.get(s.dataId).id,g=e.dataIdMap.get(a.dataId).id,y=e.dataIdMap.get(o.dataId).id,b=new Uint8Array(new Int32Array(p).buffer),v=e.dataIdMap.get(c.dataId).id;return Kx(m,g,a.shape.length,y,Oe[o.dtype],l,u,d,b,h,v),c}const eG={kernelName:Ru,backendName:"wasm",setupFunc:Zz,kernelFunc:Jz};/** 16801 * @license 16802 * Copyright 2020 Google LLC. All Rights Reserved. 16803 * Licensed under the Apache License, Version 2.0 (the "License"); 16804 * you may not use this file except in compliance with the License. 16805 * You may obtain a copy of the License at 16806 * 16807 * http://www.apache.org/licenses/LICENSE-2.0 16808 * 16809 * Unless required by applicable law or agreed to in writing, software 16810 * distributed under the License is distributed on an "AS IS" BASIS, 16811 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16812 * See the License for the specific language governing permissions and 16813 * limitations under the License. 16814 * ============================================================================= 16815 */function tG(n){const{inputs:e,attrs:t,backend:r}=n,{x:s}=e,{numOrSizeSplits:a,axis:o}=t,i=ot(o,s.shape)[0],c=Pp(s,a,i),l=new Array(s.shape.length).fill(0),u=s.shape.slice();return c.map(d=>{const p=[...u];p[i]=d;const h=Os({inputs:{x:s},attrs:{begin:l,size:p},backend:r});return l[i]+=d,h})}const nG={kernelName:Kd,backendName:"wasm",kernelFunc:tG};/** 16816 * @license 16817 * Copyright 2020 Google LLC. All Rights Reserved. 16818 * Licensed under the Apache License, Version 2.0 (the "License"); 16819 * you may not use this file except in compliance with the License. 16820 * You may obtain a copy of the License at 16821 * 16822 * http://www.apache.org/licenses/LICENSE-2.0 16823 * 16824 * Unless required by applicable law or agreed to in writing, software 16825 * distributed under the License is distributed on an "AS IS" BASIS, 16826 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16827 * See the License for the specific language governing permissions and 16828 * limitations under the License. 16829 * ============================================================================= 16830 */const rG=Ae(jd);/** 16831 * @license 16832 * Copyright 2019 Google LLC. All Rights Reserved. 16833 * Licensed under the Apache License, Version 2.0 (the "License"); 16834 * you may not use this file except in compliance with the License. 16835 * You may obtain a copy of the License at 16836 * 16837 * http://www.apache.org/licenses/LICENSE-2.0 16838 * 16839 * Unless required by applicable law or agreed to in writing, software 16840 * distributed under the License is distributed on an "AS IS" BASIS, 16841 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16842 * See the License for the specific language governing permissions and 16843 * limitations under the License. 16844 * ============================================================================= 16845 */const sG=Ae(fm);/** 16846 * @license 16847 * Copyright 2019 Google LLC. All Rights Reserved. 16848 * Licensed under the Apache License, Version 2.0 (the "License"); 16849 * you may not use this file except in compliance with the License. 16850 * You may obtain a copy of the License at 16851 * 16852 * http://www.apache.org/licenses/LICENSE-2.0 16853 * 16854 * Unless required by applicable law or agreed to in writing, software 16855 * distributed under the License is distributed on an "AS IS" BASIS, 16856 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16857 * See the License for the specific language governing permissions and 16858 * limitations under the License. 16859 * ============================================================================= 16860 */const aG=lt(Zd);/** 16861 * @license 16862 * Copyright 2020 Google LLC. All Rights Reserved. 16863 * Licensed under the Apache License, Version 2.0 (the "License"); 16864 * you may not use this file except in compliance with the License. 16865 * You may obtain a copy of the License at 16866 * 16867 * http://www.apache.org/licenses/LICENSE-2.0 16868 * 16869 * Unless required by applicable law or agreed to in writing, softw
16869are 16870 * distributed under the License is distributed on an "AS IS" BASIS, 16871 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16872 * See the License for the specific language governing permissions and 16873 * limitations under the License. 16874 * ============================================================================= 16875 */let Xx;function oG(n){Xx=n.wasm.cwrap(Fu,null,["number","number","number","number"])}function iG(n){const{backend:e,inputs:t,attrs:r}=n,{alpha:s}=r,{x:a}=t,o=e.dataIdMap.get(a.dataId).id,i=e.makeOutput(a.shape,a.dtype),c=e.dataIdMap.get(i.dataId).id;return Xx(o,s,Oe[a.dtype],c),i}const uG={kernelName:Fu,backendName:"wasm",setupFunc:oG,kernelFunc:iG};/** 16876 * @license 16877 * Copyright 2021 Google LLC. All Rights Reserved. 16878 * Licensed under the Apache License, Version 2.0 (the "License"); 16879 * you may not use this file except in compliance with the License. 16880 * You may obtain a copy of the License at 16881 * 16882 * http://www.apache.org/licenses/LICENSE-2.0 16883 * 16884 * Unless required by applicable law or agreed to in writing, software 16885 * distributed under the License is distributed on an "AS IS" BASIS, 16886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16887 * See the License for the specific language governing permissions and 16888 * limitations under the License. 16889 * ============================================================================= 16890 */let Yx;function cG(n){Yx=n.wasm.cwrap(Au,null,["number","array","number","array","array","array","array","array","number","number"])}function lG(n){const{backend:e,inputs:t,attrs:r}=n,{x:s}=t,{begin:a,end:o,strides:i,beginMask:c,endMask:l,ellipsisMask:u,newAxisMask:d,shrinkAxisMask:p}=r,{finalShapeSparse:h,finalShape:m,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:v,end:$,strides:S}=Ep(s.shape,a,o,i,c,l,u,d,p);let T;if(g)T=jt({inputs:{x:s},backend:e,attrs:{shape:m}});else if(y||b){N(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);const O=Tp(v,$,S),L=Os({inputs:{x:s},backend:e,attrs:{begin:v,size:O}});T=jt({inputs:{x:L},backend:e,attrs:{shape:m}}),e.disposeData(L.dataId)}else{const O=e.makeOutput(h,"float32"),L=e.dataIdMap.get(s.dataId).id,M=new Uint8Array(new Int32Array(Be(s.shape)).buffer),W=new Uint8Array(new Int32Array(v).buffer),V=new Uint8Array(new Int32Array($).buffer),G=new Uint8Array(new Int32Array(S).buffer),K=new Uint8Array(new Int32Array(h).buffer),J=new Uint8Array(new Int32Array(Be(h)).buffer),ue=e.dataIdMap.get(O.dataId).id;Yx(L,M,s.shape.length,W,V,G,K,J,h.length,ue),T=jt({inputs:{x:O},backend:e,attrs:{shape:m}}),e.disposeData(O.dataId)}return T}const dG={kernelName:Au,backendName:"wasm",setupFunc:cG,kernelFunc:lG};/** 16891 * @license 16892 * Copyright 2021 Google LLC. All Rights Reserved. 16893 * Licensed under the Apache License, Version 2.0 (the "License"); 16894 * you may not use this file except in compliance with the License. 16895 * You may obtain a copy of the License at 16896 * 16897 * http://www.apache.org/licenses/LICENSE-2.0 16898 * 16899 * Unless required by applicable law or agreed to in writing, software 16900 * distributed under the License is distributed on an "AS IS" BASIS, 16901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16902 * See the License for the specific language governing permissions and 16903 * limitations under the License. 16904 * ============================================================================= 16905 */function pG(n){const{backend:e,inputs:t,attrs:r}=n,{data:s,dataSplits:a}=t,{separator:o,nGramWidths:i,leftPad:c,rightPad:l,padWidth:u,preserveShortSequences:d}=r,p=e.readSync(s.dataId),h=e.readSync(a.dataId),[m,g]=Wy(p,h,o,i,c,l,u,d),y=e.makeOutput([m.length],"string"),b=e.dataIdMap.get(y.dataId);b.stringBytes=m;const v=e.makeOutput(a.shape,"int32");return e.typedArrayFromHeap(v).set(g),[y,v]}const hG={kernelName:Jd,backendName:"wasm",kernelFunc:pG};/** 16906 * @license 16907 * Copyright 2021 Google LLC. All Rights Reserved. 16908 * Licensed under the Apache License, Version 2.0 (the "License"); 16909 * you may not use this file except in compliance with the License. 16910 * You may obtain a copy of the License at 16911 * 16912 * http://www.apache.org/licenses/LICENSE-2.0 16913 * 16914 * Unless required by applicable law or agreed to in writing, softw
16914are 16915 * distributed under the License is distributed on an "AS IS" BASIS, 16916 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16917 * See the License for the specific language governing permissions and 16918 * limitations under the License. 16919 * ============================================================================= 16920 */function fG(n){const{backend:e,inputs:t,attrs:r}=n,{input:s,delimiter:a}=t,{skipEmpty:o}=r,i=e.readSync(s.dataId),c=e.readSync(a.dataId),[l,u,d]=Uy(i,c[0],o),p=u.length,h=e.makeOutput([p,2],"int32");e.typedArrayFromHeap(h).set(l);const g=e.makeOutput([p],"string"),y=e.dataIdMap.get(g.dataId);y.stringBytes=u;const b=e.makeOutput([2],"int32");return e.typedArrayFromHeap(b).set(d),[h,g,b]}const mG={kernelName:ep,backendName:"wasm",kernelFunc:fG};/** 16921 * @license 16922 * Copyright 2021 Google LLC. All Rights Reserved. 16923 * Licensed under the Apache License, Version 2.0 (the "License"); 16924 * you may not use this file except in compliance with the License. 16925 * You may obtain a copy of the License at 16926 * 16927 * http://www.apache.org/licenses/LICENSE-2.0 16928 * 16929 * Unless required by applicable law or agreed to in writing, software 16930 * distributed under the License is distributed on an "AS IS" BASIS, 16931 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16932 * See the License for the specific language governing permissions and 16933 * limitations under the License. 16934 * ============================================================================= 16935 */function gG(n){const{backend:e,inputs:t,attrs:r}=n,{input:s}=t,{numBuckets:a}=r,o=e.readSync(s.dataId),i=zy(o,a),c=e.makeOutput(s.shape,"int32");return e.typedArrayFromHeap(c).set(i),c}const yG={kernelName:tp,backendName:"wasm",kernelFunc:gG};/** 16936 * @license 16937 * Copyright 2019 Google LLC. All Rights Reserved. 16938 * Licensed under the Apache License, Version 2.0 (the "License"); 16939 * you may not use this file except in compliance with the License. 16940 * You may obtain a copy of the License at 16941 * 16942 * http://www.apache.org/licenses/LICENSE-2.0 16943 * 16944 * Unless required by applicable law or agreed to in writing, software 16945 * distributed under the License is distributed on an "AS IS" BASIS, 16946 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16947 * See the License for the specific language governing permissions and 16948 * limitations under the License. 16949 * ============================================================================= 16950 */const bG=lt(np);/** 16951 * @license 16952 * Copyright 2019 Google LLC. All Rights Reserved. 16953 * Licensed under the Apache License, Version 2.0 (the "License"); 16954 * you may not use this file except in compliance with the License. 16955 * You may obtain a copy of the License at 16956 * 16957 * http://www.apache.org/licenses/LICENSE-2.0 16958 * 16959 * Unless required by applicable law or agreed to in writing, software 16960 * distributed under the License is distributed on an "AS IS" BASIS, 16961 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16962 * See the License for the specific language governing permissions and 16963 * limitations under the License. 16964 * ============================================================================= 16965 */let Qx;function xG(n){Qx=n.wasm.cwrap(Tu,null,["number","number","number","number"])}function wG(n){const{backend:e,inputs:t,attrs:r}=n,{axis:s,keepDims:a}=r,{x:o}=t,i=e.dataIdMap.get(o.dataId).id;let c=i,l=o;const{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Zr(o,s,e);let m=d;if(h){const $=e.dataIdMap.get(u.dataId).id;$!==i&&(l=u,c=$,m=St(m.length,l.shape.length))}ht("sum",m,l.shape.length);const[g,y]=At(l.shape,m),b=H(y),v=e.makeOutput(g,l.dtype);if(H(l.shape)!==0){const $=e.dataIdMap.get(v.dataId).id;Qx(c,b,Oe[v.dtype],$)}if(h&&e.disposeData(u.dataId),a){const $=pt(v.shape,p);v.shape=$}return v}const vG={kernelName:Tu,backendName:"wasm",setupFunc:xG,kernelFunc:wG};/** 16966 * @license 16967 * Copyright 2021 Google LLC. All Rights Reserved. 16968 * Licensed under the Apache License, Version 2.0 (the "License"); 16969 * you may not use this file except in compliance with the License. 16970 * You may obtain a copy of the License at 16971 * 16972 * http://www.apache.org/licenses/LICENSE-2.0 16973 * 16974 * Unless required by applicable law or agreed to in writing, softw
16974are 16975 * distributed under the License is distributed on an "AS IS" BASIS, 16976 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16977 * See the License for the specific language governing permissions and 16978 * limitations under the License. 16979 * ============================================================================= 16980 */const IG=Ae(rp);/** 16981 * @license 16982 * Copyright 2019 Google LLC. All Rights Reserved. 16983 * Licensed under the Apache License, Version 2.0 (the "License"); 16984 * you may not use this file except in compliance with the License. 16985 * You may obtain a copy of the License at 16986 * 16987 * http://www.apache.org/licenses/LICENSE-2.0 16988 * 16989 * Unless required by applicable law or agreed to in writing, software 16990 * distributed under the License is distributed on an "AS IS" BASIS, 16991 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16992 * See the License for the specific language governing permissions and 16993 * limitations under the License. 16994 * ============================================================================= 16995 */const $G=Ae(sp);/** 16996 * @license 16997 * Copyright 2022 Google LLC. All Rights Reserved. 16998 * Licensed under the Apache License, Version 2.0 (the "License"); 16999 * you may not use this file except in compliance with the License. 17000 * You may obtain a copy of the License at 17001 * 17002 * http://www.apache.org/licenses/LICENSE-2.0 17003 * 17004 * Unless required by applicable law or agreed to in writing, software 17005 * distributed under the License is distributed on an "AS IS" BASIS, 17006 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17007 * See the License for the specific language governing permissions and 17008 * limitations under the License. 17009 * ============================================================================= 17010 */let Zx;function SG(n){Zx=n.wasm.cwrap(_u,null,["number","number","number","number","number","number","array","number","number","number"])}function CG(n){const{backend:e,inputs:t,attrs:r}=n,{tensor:s,indices:a,updates:o}=t,i=e.makeOutput(s.shape,s.dtype);if(H(s.shape)===0)return i;const{sliceRank:c,numUpdates:l,sliceSize:u,strides:d,outputSize:p}=Ms(o,a,s.shape),m=e.dataIdMap.get(a.dataId).id,y=e.dataIdMap.get(o.dataId).id,v=e.dataIdMap.get(s.dataId).id,$=new Uint8Array(new Int32Array(d).buffer),S=e.dataIdMap.get(i.dataId).id;return Zx(m,y,Oe[o.dtype],c,l,u,$,p,S,v),i}const _G={kernelName:_u,backendName:"wasm",setupFunc:SG,kernelFunc:CG};/** 17011 * @license 17012 * Copyright 2019 Google LLC. All Rights Reserved. 17013 * Licensed under the Apache License, Version 2.0 (the "License"); 17014 * you may not use this file except in compliance with the License. 17015 * You may obtain a copy of the License at 17016 * 17017 * http://www.apache.org/licenses/LICENSE-2.0 17018 * 17019 * Unless required by applicable law or agreed to in writing, software 17020 * distributed under the License is distributed on an "AS IS" BASIS, 17021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17022 * See the License for the specific language governing permissions and 17023 * limitations under the License. 17024 * ============================================================================= 17025 */let Jx;function NG(n){Jx=n.wasm.cwrap(_o,null,["number","array","number","array","number","number"])}function TG(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,a=t.dataIdMap.get(s.dataId).id,{reps:o}=r,i=new Array(s.shape.length);for(let p=0;p<i.length;p++)i[p]=s.shape[p]*o[p];const c=new Uint8Array(new Int32Array(s.shape).buffer),l=new Uint8Array(new Int32Array(i).buffer),u=t.makeOutput(i,s.dtype),d=t.dataIdMap.get(u.dataId).id;return Jx(a,c,s.shape.length,l,i.length,Oe[u.dtype],d),u}const kG={kernelName:_o,backendName:"wasm",setupFunc:NG,kernelFunc:TG};/** 17026 * @license 17027 * Copyright 2020 Google LLC. All Rights Reserved. 17028 * Licensed under the Apache License, Version 2.0 (the "License"); 17029 * you may not use this file except in compliance with the License. 17030 * You may obtain a copy of the License at 17031 * 17032 * http://www.apache.org/licenses/LICENSE-2.0 17033 * 17034 * Unless required by applicable law or agreed to in writing, software 17035 * distributed under the License is distributed on an "AS IS" BASIS, 17036 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17037 * See the License for the specific language governing permissions and 17038 * limitations under the License. 17039 * ============================================================================= 17040 */let e0;function EG(n){e0=n.wasm.cwrap(Du,null,["number","array","number","number","number","bool","number","number"])}const RG=({inputs:n,backend:e,attrs:t})=>{const{x:r}=n,{k:s,sorted:a}=t,o=e.dataIdMap.get(r.dataId).id,i=new Uint8Array(new Int32Array(r.shape).buffer),c=r.shape.slice();c[c.length-1]=s;const l=e.makeOutput(c,r.dtype),u=e.dataIdMap.get(l.dataId).id,d=e.makeOutput(c,"int32"),p=e.dataIdMap.get(d.dataId).id;return e0(o,i,r.shape.length,Oe[r.dtype],s,a,u,p),[l,d]},AG={kernelName:Du,backendName:"wasm",setupFunc:EG,kernelFunc:RG};/** 17041 * @license 17042 * Copyright 2021 Google LLC. All Rights Reserved. 17043 * Licensed under the Apache License, Version 2.0 (the "License");
17044 * you may not use this file except in compliance with the License. 17045 * You may obtain a copy of the License at 17046 * 17047 * http://www.apache.org/licenses/LICENSE-2.0 17048 * 17049 * Unless required by applicable law or agreed to in writing, software 17050 * distributed under the License is distributed on an "AS IS" BASIS, 17051 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17052 * See the License for the specific language governing permissions and 17053 * limitations under the License. 17054 * ============================================================================= 17055 */let t0;function DG(n){t0=n.wasm.cwrap(Ou,null,["number","number","bool","number","number","number","number","number","number","array","number","array","number","number","number","number","number"])}function OG(n){const{backend:e,inputs:t,attrs:r}=n,{image:s,transforms:a}=t,{interpolation:o,fillMode:i,fillValue:c,outputShape:l}=r,[u,d,p,h]=s.shape,[m,g]=l!=null?l:[d,p],y=[u,m,g,h],b=new Uint8Array(new Int32Array(Be(s.shape)).buffer),v=new Uint8Array(new Int32Array(Be(y)).buffer),$=e.makeOutput(y,s.dtype),S=e.dataIdMap.get($.dataId).id,O=e.dataIdMap.get(s.dataId).id,M=e.dataIdMap.get(a.dataId).id,W=o==="nearest"?1:2;let V;switch(i){case"constant":V=1;break;case"reflect":V=2;break;case"wrap":V=3;break;case"nearest":V=4;break;default:V=1;break}return t0(O,M,a.shape[0]>1,u,m,g,h,p,d,b,s.shape.length-1,v,y.length-1,W,V,c,S),$}const FG={kernelName:Ou,backendName:"wasm",setupFunc:DG,kernelFunc:OG};/** 17056 * @license 17057 * Copyright 2023 Google LLC. 17058 * Licensed under the Apache License, Version 2.0 (the "License"); 17059 * you may not use this file except in compliance with the License. 17060 * You may obtain a copy of the License at 17061 * 17062 * http://www.apache.org/licenses/LICENSE-2.0 17063 * 17064 * Unless required by applicable law or agreed to in writing, software 17065 * distributed under the License is distributed on an "AS IS" BASIS, 17066 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17067 * See the License for the specific language governing permissions and 17068 * limitations under the License. 17069 * ============================================================================= 17070 */function PG(n){const{inputs:e,attrs:t,backend:r}=n,{axis:s}=t,{x:a}=e,{outputValues:o,outputShape:i,indices:c}=Hy(r.readSync(a.dataId),s,a.shape,a.dtype);return[r.makeOutput(i,a.dtype,void 0,o),r.makeOutput([c.length],"int32",void 0,c)]}const LG={kernelName:ap,backendName:"wasm",kernelFunc:PG};/** 17071 * @license 17072 * Copyright 2019 Google LLC. All Rights Reserved. 17073 * Licensed under the Apache License, Version 2.0 (the "License"); 17074 * you may not use this file except in compliance with the License. 17075 * You may obtain a copy of the License at 17076 * 17077 * http://www.apache.org/licenses/LICENSE-2.0 17078 * 17079 * Unless required by applicable law or agreed to in writing, software 17080 * distributed under the License is distributed on an "AS IS" BASIS, 17081 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17082 * See the License for the specific language governing permissions and 17083 * limitations under the License. 17084 * ============================================================================= 17085 */function MG(n){const{inputs:e,backend:t,attrs:r}=n,{value:s}=e;let{axis:a}=r;a<0&&(a+=s.shape.length);const o=s.shape[a],i=s.shape.length,c=new Array(i-1);let l=0;for(let h=0;h<i;h++)h!==a&&(c[l++]=s.shape[h]);const u=new Array(o),d=new Array(i).fill(0),p=s.shape.slice();p[a]=1;for(let h=0;h<u.length;h++)d[a]=h,u[h]=Os({inputs:{x:s},attrs:{begin:d,size:p},backend:t});return u.map(({dataId:h,dtype:m})=>({dataId:h,dtype:m,shape:c}))}const BG={kernelName:op,backendName:"wasm",kernelFunc:MG};/** 17086 * @license 17087 * Copyright 2020 Google LLC. All Rights Reserved. 17088 * Licensed under the Apache License, Version 2.0 (the "License"); 17089 * you may not use this file except in compliance with the License. 17090 * You may obtain a copy of the License at 17091 * 17092 * http://www.apache.org/licenses/LICENSE-2.0 17093 * 17094 * Unless required by applicable law or agreed to in writing, software 17095 * distributed under the License is distributed on an "AS IS" BASIS, 17096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17097 * See the License for the specific language governing permissions and 17098 * limitations under the License. 17099 * ============================================================================= 17100 */function VG(n){const{inputs:{x:e},backend:t}=n,r=t.makeOutput(e.shape,e.dtype);return t.typedArrayFromHeap(r).fill(0),r}const WG={kernelName:ip,backendName:"wasm",kernelFunc:VG};/** 17101 * @license 17102 * Copyright 2020 Google LLC. All Rights Reserved. 17103 * Licensed under the Apache License, Version 2.0 (the "License");
17104 * you may not use this file except in compliance with the License. 17105 * You may obtain a copy of the License at 17106 * 17107 * http://www.apache.org/licenses/LICENSE-2.0 17108 * 17109 * Unless required by applicable law or agreed to in writing, software 17110 * distributed under the License is distributed on an "AS IS" BASIS, 17111 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17112 * See the License for the specific language governing permissions and 17113 * limitations under the License. 17114 * ============================================================================= 17115 */const UG=[DB,OB,FB,PB,LB,VB,KB,QB,ZB,JB,eV,tV,nV,rV,sV,iV,gV,lV,hV,wV,_V,kV,EV,AV,DV,OV,LV,MV,WV,GV,qV,YV,JV,e4,t4,s4,i4,l4,h4,g4,x4,I4,C4,T4,R4,A4,F4,L4,M4,B4,V4,W4,U4,H4,j4,q4,Y4,J4,nW,aW,uW,lW,pW,WB,hW,fW,mW,bW,wW,IW,CW,NW,_W,kW,EW,AW,OW,LW,VW,zW,GW,qW,YW,JW,nU,aU,uU,dU,pU,mU,wU,vU,IU,$U,_U,kU,AU,OU,LU,BU,WU,Ex,GU,qU,YU,ZU,JU,ez,tz,nz,yV,az,uz,dz,fz,yz,wz,vz,Iz,Cz,Tz,Rz,Az,Fz,Pz,Lz,Mz,SV,yU,Bz,Wz,Gz,qz,Xz,Qz,eG,nG,rG,sG,aG,uG,dG,hG,mG,yG,bG,vG,IG,$G,_G,kG,AG,FG,HB,LG,BG,WG];for(const n of UG)ym(n);/** 17116 * @license 17117 * Copyright 2020 Google LLC. All Rights Reserved. 17118 * Licensed under the Apache License, Version 2.0 (the "License"); 17119 * you may not use this file except in compliance with the License. 17120 * You may obtain a copy of the License at 17121 * 17122 * http://www.apache.org/licenses/LICENSE-2.0 17123 * 17124 * Unless required by applicable law or agreed to in writing, software 17125 * distributed under the License is distributed on an "AS IS" BASIS, 17126 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17127 * See the License for the specific language governing permissions and 17128 * limitations under the License. 17129 * ============================================================================= 17130 */const ul=U();ul.registerFlag("WASM_HAS_SIMD_SUPPORT",async()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]))}catch{return!1}});ul.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",async()=>{if(ul.get("IS_NODE"))return!1;try{return new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}});var oh={exports:{}};(function(n,e){var t=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(s){s=s||{};function a(){return pe.buffer!=Ze&&je(pe.buffer),On}function o(){return pe.buffer!=Ze&&je(pe.buffer),_r}function i(){return pe.buffer!=Ze&&je(pe.buffer),Yn}function c(){return pe.buffer!=Ze&&je(pe.buffer),ur}function l(){return pe.buffer!=Ze&&je(pe.buffer),et}var u=typeof s<"u"?s:{},d,p;u.ready=new Promise(function(R,B){d=R,p=B});var h;typeof process<"u"&&process.listeners&&(h={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var m=Object.assign({},u),g=(R,B)=>{throw B},y=typeof window=="object",b=typeof importScripts=="function",v=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",$=u.ENVIRONMENT_IS_PTHREAD||!1,S="";function T(R){return u.locateFile?u.locateFile(R,S):S+R}var O,L,M;function W(R){if(R instanceof Ut)return;se("exiting due to exception: "+R)}if(v){var V=Fr,G=Fr;b?S=G.dirname(S)+"/":S=__dirname+"/",O=(B,Q)=>(B=Jn(B)?new URL(B):G.normalize(B),V.readFileSync(B,Q?void 0:"utf8")),M=B=>{var Q=O(B,!0);return Q.buffer||(Q=new Uint8Array(Q)),Q},L=(B,Q,ye)=>{B=Jn(B)?new URL(B):G.normalize(B),V.readFile(B,function(be,ve){be?ye(be):Q(ve.buffer)})},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(B){if(!(B instanceof Ut))throw B}),process.on("unhandledRejection",function(B){throw B}),g=(B,Q)=>{if(cr())throw process.exitCode=B,Q;W(Q),process.exit(B)},u.inspect=function(){return"[Emscripten Module object]"};let R;try{R=Fr}catch(B){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),B}Nn.Worker=R.Worker}else(y||b)&&(b?S=self.location.href:typeof document<"u"&&document.currentScript&&(S=document.currentScript.src),typeof r<"u"&&r&&(S=r),S.indexOf("blob:")!==0?S=S.substr(0,S.replace(/[?#].*/,"").lastIndexOf("/")+1):S="",v||(O=R=>{var B=new XMLHttpRequest;return B.open("GET",R,!1),B.send(null),B.responseText},b&&(M=R=>{var B=new XMLHttpRequest;return B.open("GET",R,!1),B.responseType="arraybuffer",B.send(null),new Uint8Array(B.response)}),L=(R,B,Q)=>{var ye=new XMLHttpRequest;ye.open("GET",R,!0),ye.responseType="arraybuffer",ye.onload=()=>
vendor: 1,394 bytes, lines 17130-17132
17130{if(ye.status==200||ye.status==0&&ye.response){B(ye.response);return}Q()},ye.onerror=Q,ye.send(null)}));v&&typeof performance>"u"&&(Nn.performance=Fr.performance);var K=console.log.bind(console),J=console.warn.bind(console);v&&(K=R=>V.writeSync(1,R+` 17131`),J=R=>V.writeSync(2,R+` 17132`));var ue=u.print||K,se=u.printErr||J;Object.assign(u,m),m=null,u.arguments&&u.arguments,u.thisProgram&&u.thisProgram,u.quit&&(g=u.quit);var fe;u.wasmBinary&&(fe=u.wasmBinary);var Ie=u.noExitRuntime||!0;typeof WebAssembly!="object"&&Zn("no native wasm support detected");var pe,Fe,Qe=!1,it;function Nt(R,B){R||Zn(B)}var He=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function An(R,B,Q){B>>>=0;for(var ye=B+Q,be=B;R[be]&&!(be>=ye);)++be;if(be-B>16&&R.buffer&&He)return He.decode(R.buffer instanceof SharedArrayBuffer?R.slice(B,be):R.subarray(B,be));for(var ve="";B<be;){var ae=R[B++];if(!(ae&128)){ve+=String.fromCharCode(ae);continue}var ce=R[B++]&63;if((ae&224)==192){ve+=String.fromCharCode((ae&31)<<6|ce);continue}var Ee=R[B++]&63;if((ae&240)==224?ae=(ae&15)<<12|ce<<6|Ee:ae=(ae&7)<<18|ce<<12|Ee<<6|R[B++]&63,ae<65536)ve+=String.fromCharCode(ae);else{var Gt=ae-65536;ve+=String.fromCharCode(55296|Gt>>10,56320|Gt&1023)}}return ve}function on(R,B){return R>>>=0,R?An(o(),R,B):""}function Dn(R,B,Q,ye){if(Q>>>=0,!(ye>0))return 0;for(var be=Q,ve=Q+ye-1,ae=0;ae<R.length;++ae){var ce=R.charCodeAt(ae);if(ce>
vendor: 1,210 bytes, line 17132
17132=55296&&ce<=57343){var Ee=R.charCodeAt(++ae);ce=65536+((ce&1023)<<10)|Ee&1023}if(ce<=127){if(Q>=ve)break;B[Q++>>>0]=ce}else if(ce<=2047){if(Q+1>=ve)break;B[Q++>>>0]=192|ce>>6,B[Q++>>>0]=128|ce&63}else if(ce<=65535){if(Q+2>=ve)break;B[Q++>>>0]=224|ce>>12,B[Q++>>>0]=128|ce>>6&63,B[Q++>>>0]=128|ce&63}else{if(Q+3>=ve)break;B[Q++>>>0]=240|ce>>18,B[Q++>>>0]=128|ce>>12&63,B[Q++>>>0]=128|ce>>6&63,B[Q++>>>0]=128|ce&63}}return B[Q>>>0]=0,Q-be}function es(R,B,Q){return Dn(R,o(),B,Q)}var Ze,On,_r,Yn,ur,et;$&&(Ze=u.buffer);function je(R){Ze=R,u.HEAP8=On=new Int8Array(R),u.HEAP16=new Int16Array(R),u.HEAP32=Yn=new Int32Array(R),u.HEAPU8=_r=new Uint8Array(R),u.HEAPU16=new Uint16Array(R),u.HEAPU32=ur=new Uint32Array(R),u.HEAPF32=new Float32Array(R),u.HEAPF64=et=new Float64Array(R)}var Qn=u.INITIAL_MEMORY||16777216;if($)pe=u.wasmMemory,Ze=u.buffer;else if(u.wasmMemory)pe=u.wasmMemory;else if(pe=new WebAssembly.Memory({initial:Qn/65536,maximum:65536,shared:!0}),!(pe.buffer instanceof SharedArrayBuffer))throw se("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may
17132need to set a flag"),v&&se("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");pe&&(Ze=pe.buffer),Qn=Ze.byteLength,je(Ze);var ft,Nr=[],ts=[],ns=[];function cr(){return Ie}function Tr(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Fn(u.preRun.shift());Ve(Nr)}function kr(){$||Ve(ts)}function rs(){if(!$){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)Er(u.postRun.shift());Ve(ns)}}function Fn(R){Nr.unshift(R)}function Hs(R){ts.unshift(R)}function Er(R){ns.unshift(R)}var un=0,lr=null;function js(R){un++,u.monitorRunDependencies&&u.monitorRunDependencies(un)}function Va(R){if(un--,u.monitorRunDependencies&&u.monitorRunDependencies(un),un==0&&lr){var B=lr;lr=null,B()}}function Zn(R){u.onAbort&&u.onAbort(R),R="Aborted("+R+")",se(R),Qe=!0,it=1,R+=". Build with -sASSERTIONS for more info.";var B=new WebAssembly.RuntimeError(R);throw p(B),B}var qs="data:application/octet-stream;base64,";function Pn(R){return R.startsWith(qs)}function Jn(R){return R.startsWith("file://")}var mt;mt="tfjs-backend-wasm-threaded-simd.wasm",Pn(mt)||(mt=T(mt));function Ks(R){try{if(R==mt&&fe)return new Uint8Array(fe);if(M)return M(R);throw"both async and sync fetching of the wasm failed"}catch(B){Zn(B)}}function ss(){if(!fe&&(y||b)){if(typeof fetch=="function"&&!Jn(mt))return fetch(mt,{credentials:"same-origin"}).then(function(R){if(!R.ok)throw"failed to load wasm binary file at '"+mt+"'";return R.arrayBuffer()}).catch(function(){return Ks(mt)});if(L)return new Promise(function(R,B){L(mt,function(Q){R(new Uint8Array(Q))},B)})}return Promise.resolve().then(function(){return Ks(mt)})}function Rr(){var R={env:qa,wasi_snapshot_preview1:qa};function B(ae,ce){var Ee=ae.exports;if(u.asm=Ee,Me(u.asm._emscripten_tls_init),ft=u.asm.__indirect_function_table,Hs(u.asm.__wasm_call_ctors),Fe=ce,!$){var Gt=ee.unusedWorkers.length;ee.unusedWorkers.forEach(function(Bn){ee.loadWasmModuleToWorker(Bn,function(){--Gt||Va()})})}}$||js();function Q(ae){B(ae.instance,ae.module)}function ye(ae){return ss().then(function(ce){return WebAssembly.instantiate(ce,R)}).then(function(ce){return ce}).then(ae,function(ce){se("failed to asynchronously prepare wasm: "+ce),Zn(ce)})}function be(){return!fe&&typeof WebAssembly.instantiateStreaming=="function"&&!Pn(mt)&&!Jn(mt)&&!v&&typeof fetch=="function"?fetch(mt,{credentials:"same-origin"}).then(function(ae){var ce=WebAssembly.instantiateStreaming(ae,R);return ce.then(Q,function(Ee){return se("wasm streaming compile failed: "+Ee),se("falling back to ArrayBuffer instantiation"),ye(Q)})}):ye(Q)}if(u.instantiateWasm)try{var ve=u.instantiateWasm(R,B);return ve}catch(ae){se("Module.instantiateWasm callback failed with error: "+ae),p(ae)}return be().catch(p),{}}var mn={};function Ut(R){this.name="ExitStatus",this.message="Program terminated with exit("+R+")",this.status=R}function dr(R){var B=ee.pthreads[R];delete ee.pthreads[R],B.terminate(),na(R),ee.runningWorkers.splice(ee.runningWorkers.indexOf(B),1),B.pthread_ptr=0}function as(R){var B=ee.pthreads[R];B.postMessage({cmd:"cancel"})}function Ln(R){var B=ee.pthreads[R];Nt(B),ee.returnWorkerToPool(B)}function er(R){var B=ee.getNewWorker();if(!B)return 6;ee.runningWorkers.push(B),ee.pthreads[R.pthread_ptr]=B,B.pthread_ptr=R.pthread_ptr;var Q={cmd:"run",start_routine:R.startRoutine,arg:R.arg,pthread_ptr:R.pthread_ptr};return B.runPthread=()=>{v&&B.ref(),B.postMessage(Q,R.transferList),delete B.runPthread},B.loaded&&B.runPthread(),0}function gn(R){if($)return Mn(1,1,R);it=R,cr()||(ee.terminateAllThreads(),u.onExit&&u.onExit(R),Qe=!0),g(R,new Ut(R))}function j(R,B){if(it=R,!B&&$)throw $e(R),"unwind";gn(R)}var Y=j;function de(R){if(R instanceof Ut||R=="unwind")return it;g(1,R)}var ee={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init:function(){$?ee.initWorker():ee.initMainThread()},initMainThread:function(){for(var R=8;R--;)ee.allocateUnusedWorker()},initWorker:function(){Ie=!1},setExitStatus:function(R){it=R},terminateAllThreads:function(){for(var R of Object.values(ee.pthreads))ee.returnWorkerToPool(R);for(var R of ee.unusedWorkers)R.terminate();ee.unusedWorkers=[]},returnWorkerToPool:function(R){var B=R.pthread_ptr;delete ee.pthreads[B],ee.unusedWorkers.push(R),ee.runningWorkers.splice(ee.runningWorkers.indexOf(R),1),R.pthread_ptr=0,v&&R.unref(),na(B)},receiveObjectTransfer:function(R){},threadInitTLS:function(){ee.tlsInitFunctions.forEach(R=>R())},loadWasmModuleToWorker:function(R,B){R.onmessage=ve=>{var ae=ve.data,ce=ae.cmd;if(R.pthread_ptr&&(ee.currentProxiedOperationCallerThread=R.pthread_ptr),ae.targetThread&&ae.targetThread!=us()){var Ee=ee.pthreads[ae.targetThread];
vendor: 6,066 bytes, line 17132
17132Ee?Ee.postMessage(ae,ae.transferList):se('Internal error! Worker sent a message "'+ce+'" to target pthread '+ae.targetThread+", but that thread no longer exists!"),ee.currentProxiedOperationCallerThread=void 0;return}ce==="processProxyingQueue"?Ys(ae.queue):ce==="spawnThread"?er(ae):ce==="cleanupThread"?Ln(ae.thread):ce==="killThread"?dr(ae.thread):ce==="cancelThread"?as(ae.thread):ce==="loaded"?(R.loaded=!0,v&&R.unref(),B&&B(R),R.runPthread&&R.runPthread()):ce==="print"?ue("Thread "+ae.threadId+": "+ae.text):ce==="printErr"?se("Thread "+ae.threadId+": "+ae.text):ce==="alert"?alert("Thread "+ae.threadId+": "+ae.text):ae.target==="setimmediate"?R.postMessage(ae):ce==="callHandler"?u[ae.handler](...ae.args):ce&&se("worker sent an unknown command "+ce),ee.currentProxiedOperationCallerThread=void 0},R.onerror=ve=>{var ae="worker sent an error!";throw se(ae+" "+ve.filename+":"+ve.lineno+": "+ve.message),ve},v&&(R.on("message",function(ve){R.onmessage({data:ve})}),R.on("error",function(ve){R.onerror(ve)}),R.on("detachedExit",function(){}));var Q=[],ye=["onExit","onAbort","print","printErr"];for(var be of ye)u.hasOwnProperty(be)&&Q.push(be);R.postMessage({cmd:"load",handlers:Q,urlOrBlob:u.mainScriptUrlOrBlob||r,wasmMemory:pe,wasmModule:Fe})},allocateUnusedWorker:function(){var R,B=T("tfjs-backend-wasm-threaded-simd.worker.js");R=new Worker(B),ee.unusedWorkers.push(R)},getNewWorker:function(){return ee.unusedWorkers.length==0&&(ee.allocateUnusedWorker(),ee.loadWasmModuleToWorker(ee.unusedWorkers[0])),ee.unusedWorkers.pop()}};u.PThread=ee;function Ve(R){for(;R.length>0;)R.shift()(u)}function Pe(){var R=us(),B=i()[R+52>>>2],Q=i()[R+56>>>2],ye=B-Q;Xa(B,ye),tr(B)}u.establishStackSpace=Pe;function $e(R){if($)return Mn(2,0,R);try{Y(R)}catch(B){de(B)}}var ge=[];function We(R){var B=ge[R];return B||(R>=ge.length&&(ge.length=R+1),ge[R]=B=ft.get(R)),B}function Ot(R,B){var Q=We(R)(B);cr()?ee.setExitStatus(Q):cs(Q)}u.invokeEntryPoint=Ot;function Me(R){ee.tlsInitFunctions.push(R)}function zt(R){Xo(R,!b,1,!y),ee.threadInitTLS()}function pr(R){$?postMessage({cmd:"cleanupThread",thread:R}):Ln(R)}function Xs(R,B,Q,ye){return $?Mn(3,1,R,B,Q,ye):ct(R,B,Q,ye)}function ct(R,B,Q,ye){if(typeof SharedArrayBuffer>"u")return se("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var be=[],ve=0;if($&&(be.length===0||ve))return Xs(R,B,Q,ye);var ae={startRoutine:Q,pthread_ptr:R,arg:ye,transferList:be};return $?(ae.cmd="spawnThread",postMessage(ae,be),0):er(ae)}function yn(){return 65536}var hr=!0;function os(){return hr}function Ys(R){Atomics.store(i(),R>>2,1),us()&&Ka(R),Atomics.compareExchange(i(),R>>2,1,0)}u.executeNotifiedProxyingQueue=Ys;function Wa(R,B,Q,ye){if(R==B)setTimeout(()=>Ys(ye));else if($)postMessage({targetThread:R,cmd:"processProxyingQueue",queue:ye});else{var be=ee.pthreads[R];if(!be)return;be.postMessage({cmd:"processProxyingQueue",queue:ye})}return 1}function Ua(R,B,Q){return-1}function Vo(){Zn("")}function Tt(R){Tt.shown||(Tt.shown={}),Tt.shown[R]||(Tt.shown[R]=1,v&&(R="warning: "+R),se(R))}function bn(){v||b||Tt("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function is(){return Date.now()}function Qs(){return 4294901760}function za(){return Qs()}var Zs;v?Zs=()=>{var R=process.hrtime();return R[0]*1e3+R[1]/1e6}:Zs=()=>performance.timeOrigin+performance.now();function Js(R,B,Q){o().copyWithin(R>>>0,B>>>0,B+Q>>>0)}function xn(){return v?Fr.cpus().length:navigator.hardwareConcurrency}function Wo(R){var B=ra(),Q=R();return tr(B),Q}function Mn(R,B){var Q=arguments.length-2,ye=arguments;return Wo(()=>{for(var be=Q,ve=sa(be*8),ae=ve>>3,ce=0;ce<Q;ce++){var Ee=ye[2+ce];l()[ae+ce>>>0]=Ee}return Yo(R,be,ve,B)})}var Qt=[];function ea(R,B,Q){Qt.length=B;for(var ye=Q>>3,be=0;be<B;be++)Qt[be]=l()[ye+be>>>0];var ve=R<0,ae=ve?mn[-R-1]:ta[R];return ae.apply(null,Qt)}function ac(R){try{return pe.grow(R-Ze.byteLength+65535>>>16),je(pe.buffer),1}catch{}}function Uo(R){var B=o().length;if(R=R>>>0,R<=B)return!1;var Q=Qs();if(R>Q)return!1;let ye=(Ee,Gt)=>Ee+(Gt-Ee%Gt)%Gt;for(var be=1;be<=4;be*=2){var ve=B*(1+.2/be);ve=Math.min(ve,R+100663296);var ae=Math.min(Q,ye(Math.max(R,ve),65536)),ce=ac(ae);if(ce)return!0}return!1}function Ga(){throw"unwind"}function zo(R){return $?Mn(4,1,R):52}function Go(R,B,Q,ye,be){return $?Mn(5,1,R,B,Q,ye,be):70}var Ho=[null,[],[]];function jo(R,B){var Q=Ho[R];B===0||B===10?((R===1?ue:se)(An(Q,0)),Q.length=0):Q.push(B)}function Ha(R,B,Q,ye){if($)return Mn(6,1,R,B,Q,ye);for(var be=0,ve=0;ve<Q;ve++){var ae=c()[B>>>2],ce=c()[B+4>>>2];B+=8;for(var Ee=0;Ee<ce;Ee++)jo(R,o()[ae+Ee>>>0]);be+=ce}return c()[ye>>>2]=be,0}function ja(R){var B=u["_"+R];return B}function Ft(R,B){a().set(R,B>>>0)}function qo(R,B,Q,ye,be){var ve={string:bt=>{var cn=0;if(bt!=null&&bt!==0){var Za=(bt.length<<2)+1;cn=sa(Za),es(bt,cn,Za)}return cn},array:bt=>{var cn=sa(bt.length);return Ft(bt,cn),cn}};function ae(bt){return B==="string"?on(bt):B==="boolean"?Boolean(bt):bt}var ce=ja(R),Ee=[],Gt=0;if(ye)for(var Bn=0;Bn<ye.length;Bn++){var Ya=ve[Q[Bn]];Ya?(Gt===0&&(Gt=ra()),Ee[Bn]=Ya(ye[Bn])):Ee[Bn]=ye[Bn]}var ia=ce.apply(null,Ee);function Qa(bt){return Gt!==0&&tr(Gt),ae(bt)}return ia=Qa(ia),ia}function Ko(R,B,Q,ye){Q=Q||[];var be=Q.every(ae=>ae==="number"||ae==="boolean"),ve=B!=="string";return ve&&be&&!ye?ja(R):function(){return qo(R,B,Q,arguments)}}ee.init();var ta=[null,gn,$e,Xs,zo,Go,Ha],qa={__emscripten_init_main_thread_js:zt,__emscripten_thread_cleanup:pr,__pthread_create_js:ct,_emscripten_default_pthread_stack_size:yn,_emscripten_get_now_is_monotonic:os,_emscripten_notify_task_queue:Wa,_emscripten_set_offscreencanvas_size:Ua,abort:Vo,emscripten_check_blocking_allowed:bn,emscripten_date_now:is,emscripten_get_heap_max:za,emscripten_get_now:Zs,emscripten_memcpy_big:Js,emscripten_num_logical_cores:xn,emscripten_receive_on_main_thread_js:ea,emscripten_resize_heap:Uo,emscripten_unwind_to_js_event_loop:Ga,exit:Y,fd_close:zo,fd_seek:Go,fd_write:Ha,memory:pe||u.wasmMemory};Rr
vendor: 12,124 bytes, line 17132
17132(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.__wasm_call_ctors).apply(null,arguments)},u._init=function(){return(u._init=u.asm.init).apply(null,arguments)},u._init_with_threads_count=function(){return(u._init_with_threads_count=u.asm.init_with_threads_count).apply(null,arguments)},u._get_threads_count=function(){return(u._get_threads_count=u.asm.get_threads_count).apply(null,arguments)},u._register_tensor=function(){return(u._register_tensor=u.asm.register_tensor).apply(null,arguments)},u._dispose_data=function(){return(u._dispose_data=u.asm.dispose_data).apply(null,arguments)},u._dispose=function(){return(u._dispose=u.asm.dispose).apply(null,arguments)},u._Abs=function(){return(u._Abs=u.asm.Abs).apply(null,arguments)},u._Acos=function(){return(u._Acos=u.asm.Acos).apply(null,arguments)},u._Acosh=function(){return(u._Acosh=u.asm.Acosh).apply(null,arguments)},u._Add=function(){return(u._Add=u.asm.Add).apply(null,arguments)},u._AddN=function(){return(u._AddN=u.asm.AddN).apply(null,arguments)},u._All=function(){return(u._All=u.asm.All).apply(null,arguments)},u._Any=function(){return(u._Any=u.asm.Any).apply(null,arguments)},u._ArgMax=function(){return(u._ArgMax=u.asm.ArgMax).apply(null,arguments)},u._ArgMin=function(){return(u._ArgMin=u.asm.ArgMin).apply(null,arguments)},u._Asin=function(){return(u._Asin=u.asm.Asin).apply(null,arguments)},u._Asinh=function(){return(u._Asinh=u.asm.Asinh).apply(null,arguments)},u._Atan=function(){return(u._Atan=u.asm.Atan).apply(null,arguments)},u._Atan2=function(){return(u._Atan2=u.asm.Atan2).apply(null,arguments)},u._Atanh=function(){return(u._Atanh=u.asm.Atanh).apply(null,arguments)},u._AvgPool=function(){return(u._AvgPool=u.asm.AvgPool).apply(null,arguments)},u._AvgPool3D=function(){return(u._AvgPool3D=u.asm.AvgPool3D).apply(null,arguments)},u._AvgPool3DGrad=function(){return(u._AvgPool3DGrad=u.asm.AvgPool3DGrad).apply(null,arguments)},u._AvgPoolGrad=function(){return(u._AvgPoolGrad=u.asm.AvgPoolGrad).apply(null,arguments)},u._BatchMatMul=function(){return(u._BatchMatMul=u.asm.BatchMatMul).apply(null,arguments)},u._Bincount=function(){return(u._Bincount=u.asm.Bincount).apply(null,arguments)},u._BitwiseAnd=function(){return(u._BitwiseAnd=u.asm.BitwiseAnd).apply(null,arguments)},u._Ceil=function(){return(u._Ceil=u.asm.Ceil).apply(null,arguments)},u._ClipByValue=function(){return(u._ClipByValue=u.asm.ClipByValue).apply(null,arguments)},u._Conv2D=function(){return(u._Conv2D=u.asm.Conv2D).apply(null,arguments)},u._Conv2DBackpropInput=function(){return(u._Conv2DBackpropInput=u.asm.Conv2DBackpropInput).apply(null,arguments)},u._Conv3D=function(){return(u._Conv3D=u.asm.Conv3D).apply(null,arguments)},u._Conv3DBackpropFilterV2=function(){return(u._Conv3DBackpropFilterV2=u.asm.Conv3DBackpropFilterV2).apply(null,arguments)},u._Conv3DBackpropInputV2=function(){return(u._Conv3DBackpropInputV2=u.asm.Conv3DBackpropInputV2).apply(null,arguments)},u._Cos=function(){return(u._Cos=u.asm.Cos).apply(null,arguments)},u._Cosh=function(){return(u._Cosh=u.asm.Cosh).apply(null,arguments)},u._CropAndResize=function(){return(u._CropAndResize=u.asm.CropAndResize).apply(null,arguments)},u._Cumprod=function(){return(u._Cumprod=u.asm.Cumprod).apply(null,arguments)},u._Cumsum=function(){return(u._Cumsum=u.asm.Cumsum).apply(null,arguments)},u._DenseBincount=function(){return(u._DenseBincount=u.asm.DenseBincount).apply(null,arguments)},u._DepthToSpace=function(){return(u._DepthToSpace=u.asm.DepthToSpace).apply(null,arguments)},u._DepthwiseConv2dNative=function(){return(u._DepthwiseConv2dNative=u.asm.DepthwiseConv2dNative).apply(null,arguments)},u._Diag=function(){return(u._Diag=u.asm.Diag).apply(null,arguments)},u._Dilation2D=function(){return(u._Dilation2D=u.asm.Dilation2D).apply(null,arguments)},u._Dilation2DBackpropFilter=function(){return(u._Dilation2DBackpropFilter=u.asm.Dilation2DBackpropFilter).apply(null,arguments)},u._Dilation2DBackpropInput=function(){return(u._Dilation2DBackpropInput=u.asm.Dilation2DBackpropInput).apply(null,arguments)},u._Elu=function(){return(u._Elu=u.asm.Elu).apply(null,arguments)},u._EluGrad=function(){return(u._EluGrad=u.asm.EluGrad).apply(null,arguments)},u._Equal=function(){return(u._Equal=u.asm.Equal).apply(null,arguments)},u._Erf=function(){return(u._Erf=u.asm.Erf).apply(null,arguments)},u._Exp=function(){return(u._Exp=u.asm.Exp).apply(null,arguments)},u._Expm1=function(){return(u._Expm1=u.asm.Expm1).apply(null,arguments)},u._FlipLeftRight=function(){return(u._FlipLeftRight=u.asm.FlipLeftRight).apply(null,arguments)},u._Floor=function(){return(u._Floor=u.asm.Floor).apply(null,arguments)},u._FloorDiv=function(){return(u._FloorDiv=u.asm.FloorDiv).apply(null,arguments)},u._FusedBatchNorm=function(){return(u._FusedBatchNorm=u.asm.FusedBatchNorm).apply(null,arguments)},u._FusedConv2D=function(){return(u._FusedConv2D=u.asm.FusedConv2D).apply(null,arguments)},u._FusedDepthwiseConv2D=function(){return(u._FusedDepthwiseConv2D=u.asm.FusedDepthwiseConv2D).apply(null,arguments)},u._Gather=function(){return(u._Gather=u.asm.Gather).apply(null,arguments)},u._GatherNd=function(){return(u._GatherNd=u.asm.GatherNd).apply(null,arguments)},u._Greater=function(){return(u._Greater=u.asm.Greater).apply(null,arguments)},u._GreaterEqual=function(){return(u._GreaterEqual=u.asm.GreaterEqual).apply(null,arguments)},u._IsFinite=function(){return(u._IsFinite=u.asm.IsFinite).apply(null,arguments)},u._IsInf=function(){return(u._IsInf=u.asm.IsInf).apply(null,arguments)},u._IsNan=function(){return(u._IsNan=u.asm.IsNan).apply(null,arguments)},u._LRN=function(){return(u._LRN=u.asm.LRN).apply(null,arguments)},u._LRNGrad=function(){return(u._LRNGrad=u.asm.LRNGrad).apply(null,arguments)},u._LeakyRelu=function(){return(u._LeakyRelu=u.asm.LeakyRelu).apply(null,arguments)},u._Less=function(){return(u._Less=u.asm.Less).apply(null,arguments)},u._LessEqual=function(){return(u._LessEqual=u.asm.LessEqual).apply(null,arguments)},u._LinSpace=function(){return(u._LinSpace=u.asm.LinSpace).apply(null,arguments)},u._Log=function(){return(u._Log=u.asm.Log).apply(null,arguments)},u._Log1p=function(){return(u._Log1p=u.asm.Log1p).apply(null,arguments)},u._LogicalAnd=function(){return(u._LogicalAnd=u.asm.LogicalAnd).apply(null,arguments)},u._LogicalNot=function(){return(u._LogicalNot=u.asm.LogicalNot).apply(null,arguments)},u._LogicalOr=function(){return(u._LogicalOr=u.asm.LogicalOr).apply(null,arguments)},u._LogicalXor=function(){return(u._LogicalXor=u.asm.LogicalXor).apply(null,arguments)},u._Max=function(){return(u._Max=u.asm.Max).apply(null,arguments)},u._MaxPool=function(){return(u._MaxPool=u.asm.MaxPool).apply(null,arguments)},u._MaxPool3D=function(){return(u._MaxPool3D=u.asm.MaxPool3D).apply(null,arguments)},u._MaxPool3DGrad=function(){return(u._MaxPool3DGrad=u.asm.MaxPool3DGrad).apply(null,arguments)},u._MaxPoolGrad=function(){return(u._MaxPoolGrad=u.asm.MaxPoolGrad).apply(null,arguments)},u._MaxPoolWithArgmax=function(){return(u._MaxPoolWithArgmax=u.asm.MaxPoolWithArgmax).apply(null,arguments)},u._Maximum=function(){return(u._Maximum=u.asm.Maximum).apply(null,arguments)},u._Mean=function(){return(u._Mean=u.asm.Mean).apply(null,arguments)},u._Min=function(){return(u._Min=u.asm.Min).apply(null,arguments)},u._Minimum=function(){return(u._Minimum=u.asm.Minimum).apply(null,arguments)},u._MirrorPad=function(){return(u._MirrorPad=u.asm.MirrorPad).apply(null,arguments)},u._Mod=function(){return(u._Mod=u.asm.Mod).apply(null,arguments)},u._Multinomial=function(){return(u._Multinomial=u.asm.Multinomial).apply(null,arguments)},u._Multiply=function(){return(u._Multiply=u.asm.Multiply).apply(null,arguments)},u._Neg=function(){return(u._Neg=u.asm.Neg).apply(null,arguments)},u._NonMaxSuppressionV3=function(){return(u._NonMaxSuppressionV3=u.asm.NonMaxSuppressionV3).apply(null,arguments)},u._NonMaxSuppressionV4=function(){return(u._NonMaxSuppressionV4=u.asm.NonMaxSuppressionV4).apply(null,arguments)},u._NonMaxSuppressionV5=function(){return(u._NonMaxSuppressionV5=u.asm.NonMaxSuppressionV5).apply(null,arguments)},u._NotEqual=function(){return(u._NotEqual=u.asm.NotEqual).apply(null,arguments)},u._OneHot=function(){return(u._OneHot=u.asm.OneHot).apply(null,arguments)},u._PadV2=function(){return(u._PadV2=u.asm.PadV2).apply(null,arguments)},u._Pow=function(){return(u._Pow=u.asm.Pow).apply(null,arguments)},u._Prelu=function(){return(u._Prelu=u.asm.Prelu).apply(null,arguments)},u._Prod=function(){return(u._Prod=u.asm.Prod).apply(null,arguments)},u._RealDiv=function(){return(u._RealDiv=u.asm.RealDiv).apply(null,arguments)},u._Reciprocal=function(){return(u._Reciprocal=u.asm.Reciprocal).apply(null,arguments)},u._Relu=function(){return(u._Relu=u.asm.Relu).apply(null,arguments)},u._Relu6=function(){return(u._Relu6=u.asm.Relu6).apply(null,arguments)},u._ResizeBilinear=function(){return(u._ResizeBilinear=u.asm.ResizeBilinear).apply(null,arguments)},u._ResizeBilinearGrad=function(){return(u._ResizeBilinearGrad=u.asm.ResizeBilinearGrad).apply(null,arguments)},u._ResizeNearestNeighbor=function(){return(u._ResizeNearestNeighbor=u.asm.ResizeNearestNeighbor).apply(null,arguments)},u._ResizeNearestNeighborGrad=function(){return(u._ResizeNearestNeighborGrad=u.asm.ResizeNearestNeighborGrad).apply(null,arguments)},u._Reverse=function(){return(u._Reverse=u.asm.Reverse).apply(null,arguments)},u._RotateWithOffset=function(){return(u._RotateWithOffset=u.asm.RotateWithOffset).apply(null,arguments)},u._Round=function(){return(u._Round=u.asm.Round).apply(null,arguments)},u._Rsqrt=function(){return(u._Rsqrt=u.asm.Rsqrt).apply(null,arguments)},u._ScatterNd=function(){return(u._ScatterNd=u.asm.ScatterNd).apply(null,arguments)},u._SearchSorted=function(){return(u._SearchSorted=u.asm.SearchSorted).apply(null,arguments)},u._SelectV2=function(){return(u._SelectV2=u.asm.SelectV2).apply(null,arguments)},u._Selu=function(){return(u._Selu=u.asm.Selu).apply(null,arguments)},u._Sigmoid=function(){return(u._Sigmoid=u.asm.Sigmoid).apply(null,arguments)},u._Sign=function(){return(u._Sign=u.asm.Sign).apply(null,arguments)},u._Sin=function(){return(u._Sin=u.asm.Sin).apply(null,arguments)},u._Sinh=function(){return(u._Sinh=u.asm.Sinh).apply(null,arguments)},u._Softmax=function(){return(u._Softmax=u.asm.Softmax).apply(null,arguments)},u._Softplus=function(){return(u._Softplus=u.asm.Softplus).apply(null,arguments)},u._SparseFillEmptyRows=function(){return(u._SparseFillEmptyRows=u.asm.SparseFillEmptyRows).apply(null,arguments)},u._SparseReshape=function(){return(u._SparseReshape=u.asm.SparseReshape).apply(null,arguments)},u._SparseSegmentReduction=function(){return(u._SparseSegmentReduction=u.asm.SparseSegmentReduction).apply(null,arguments)},u._SparseToDense=function(){return(u._SparseToDense=u.asm.SparseToDense).apply(null,arguments)},u._Sqrt=function(){return(u._Sqrt=u.asm.Sqrt).apply(null,arguments)},u._Square=function(){return(u._Square=u.asm.Square).apply(null,arguments)},u._SquaredDifference=function(){return(u._SquaredDifference=u.asm.SquaredDifference).apply(null,arguments)},u._Step=function(){return(u._Step=u.asm.Step).apply(null,arguments)},u._StridedSlice=function(){return(u._StridedSlice=u.asm.StridedSlice).apply(null,arguments)},u._Sub=function(){return(u._Sub=u.asm.Sub).apply(null,arguments)},u._Sum=function(){return(u._Sum=u.asm.Sum).apply(null,arguments)},u._Tan=function(){return(u._Tan=u.asm.Tan).apply(null,arguments)},u._Tanh=function(){return(u._Tanh=u.asm.Tanh).apply(null,arguments)},u._TensorScatterUpdate=function(){return(u._TensorScatterUpdate=u.asm.TensorScatterUpdate).apply(null,arguments)},u._Tile=function(){return(u._Tile=u.asm.Tile).apply(null,arguments)},u._TopK=function(){return(u._TopK=u.asm.TopK).apply(null,arguments)},u._Transform=function(){return(u._Transform=u.asm.Transform).apply(null,arguments)},u._Transpose=function(){return(u._Transpose=u.asm.Transpose).apply(null,arguments)},u.__FusedMatMul=function(){return(u.__FusedMatMul=u.asm._FusedMatMul).apply(null,arguments)},u._malloc=function(){return(u._malloc=u.asm.malloc).apply(null,arguments)},u._free=function(){return(u._free=u.asm.free).apply(null,arguments)},u.__
vendor: 4,338 bytes, line 17132
17132emscripten_tls_init=function(){return(u.__emscripten_tls_init=u.asm._emscripten_tls_init).apply(null,arguments)};var us=u._pthread_self=function(){return(us=u._pthread_self=u.asm.pthread_self).apply(null,arguments)};u.___errno_location=function(){return(u.___errno_location=u.asm.__errno_location).apply(null,arguments)};var Xo=u.__emscripten_thread_init=function(){return(Xo=u.__emscripten_thread_init=u.asm._emscripten_thread_init).apply(null,arguments)};u.__emscripten_thread_crashed=function(){return(u.__emscripten_thread_crashed=u.asm._emscripten_thread_crashed).apply(null,arguments)},u._emscripten_main_thread_process_queued_calls=function(){return(u._emscripten_main_thread_process_queued_calls=u.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},u._emscripten_main_browser_thread_id=function(){return(u._emscripten_main_browser_thread_id=u.asm.emscripten_main_browser_thread_id).apply(null,arguments)};var Yo=u._emscripten_run_in_main_runtime_thread_js=function(){return(Yo=u._emscripten_run_in_main_runtime_thread_js=u.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)};u._emscripten_dispatch_to_thread_=function(){return(u._emscripten_dispatch_to_thread_=u.asm.emscripten_dispatch_to_thread_).apply(null,arguments)};var Ka=u.__emscripten_proxy_execute_task_queue=function(){return(Ka=u.__emscripten_proxy_execute_task_queue=u.asm._emscripten_proxy_execute_task_queue).apply(null,arguments)},na=u.__emscripten_thread_free_data=function(){return(na=u.__emscripten_thread_free_data=u.asm._emscripten_thread_free_data).apply(null,arguments)},cs=u.__emscripten_thread_exit=function(){return(cs=u.__emscripten_thread_exit=u.asm._emscripten_thread_exit).apply(null,arguments)},Xa=u._emscripten_stack_set_limits=function(){return(Xa=u._emscripten_stack_set_limits=u.asm.emscripten_stack_set_limits).apply(null,arguments)},ra=u.stackSave=function(){return(ra=u.stackSave=u.asm.stackSave).apply(null,arguments)},tr=u.stackRestore=function(){return(tr=u.stackRestore=u.asm.stackRestore).apply(null,arguments)},sa=u.stackAlloc=function(){return(sa=u.stackAlloc=u.asm.stackAlloc).apply(null,arguments)};u.dynCall_iijjiiii=function(){return(u.dynCall_iijjiiii=u.asm.dynCall_iijjiiii).apply(null,arguments)},u.dynCall_jiji=function(){return(u.dynCall_jiji=u.asm.dynCall_jiji).apply(null,arguments)},u.keepRuntimeAlive=cr,u.wasmMemory=pe,u.cwrap=Ko,u.ExitStatus=Ut,u.PThread=ee;var aa;lr=function R(){aa||Qo(),aa||(lr=R)};function Qo(R){if(un>0)return;if($){d(u),kr(),startWorker(u);return}if(Tr(),un>0)return;function B(){aa||(aa=!0,u.calledRun=!0,!Qe&&(kr(),d(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),rs()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),B()},1)):B()}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();Qo();var oa;h&&(oa={uncaughtException:process.listeners("uncaughtException").filter(function(R){return!h.uncaughtException.indexOf(R)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(R){return!h.unhandledRejection.indexOf(R)>-1})});var Ar;if(typeof WasmBackendModule<"u")Ar=WasmBackendModule;else if(typeof s<"u")Ar=s;else throw new Error("Could not find wasm module in post.js");if(oa){var ls=Ar._dispose;Ar._dispose=function(){ls(),oa.uncaughtException.forEach(function(R){process.removeListener("uncaughtException",R)}),oa.unhandledRejection.forEach(function(R){process.removeListener("unhandledRejection",R)})}}return s.ready}})();n.exports=t})(oh);const n0=oh.exports,zG=vl({__proto__:null,default:n0},[oh.exports]);var GG=`"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8")+"//# sourceURL="+f)},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;
17132var pendingNotifiedProxyingQueues=[];function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+" 17133");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onunhandledrejection=e=>{throw e.reason??e};self.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"})};self.onmessage=e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=function(){postMessage({cmd:"callHandler",handler:handler,args:[...arguments]})}}Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module)}else if(e.data.cmd==="run"){Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){pendingNotifiedProxyingQueues.forEach(queue=>{Module["executeNotifiedProxyingQueue"](queue)});pendingNotifiedProxyingQueues=[];initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processProxyingQueue"){if(initializedJS){Module["executeNotifiedProxyingQueue"](e.data.queue)}else{pendingNotifiedProxyingQueues.push(e.data.queue)}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}};`,ih={exports:{}};(function(n,e){var t=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(s){s=s||{};var a=typeof s<"u"?s:{},o,i;a.ready=new Promise(function(j,Y){o=j,i=Y});var c;typeof process<"u"&&process.listeners&&(c={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var l=Object.assign({},a),u=typeof window=="object",d=typeof importScripts=="function",p=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",h="";function m(j){return a.locateFile?a.locateFile(j,h):h+j}var g,y,b;if(p){var v=Fr,$=Fr;d?h=$.dirname(h)+"/":h=__dirname+"/",g=(j,Y)=>(j=Qn(j)?new URL(j):$.normalize(j),v.readFileSync(j,Y?void 0:"utf8")),b=j=>{var Y=g(j,!0);return Y.buffer||(Y=new Uint8Array(Y)),Y},y=(j,Y,de)=>{j=Qn(j)?new URL(j):$.normalize(j),v.readFile(j,function(ee,Ve){ee?de(ee):Y(Ve.buffer)})},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(j){if(!(j instanceof cr))throw j}),process.on("unhandledRejection",function(j){throw j}),a.inspect=function(){return"[Emscripten Module object]"}}else(u||d)&&(d?h=self.location.href:typeof document<"u"&&document.currentScript&&(h=document.currentScript.src),r&&(h=r),h.indexOf("blob:")!==0?h=h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1):h="",g=j=>{var Y=new XMLHttpRequest;return Y.open("GET",j,!1),Y.send(null),Y.responseText},d&&(b=j=>{var Y=new XMLHttpRequest;return Y.open("GET",j,!1),Y.responseType="arraybuffer",Y.send(null),new Uint8Array(Y.response)}),y=(j,Y,de)=>{var ee=new XMLHttpRequest;ee.open("GET",j,!0),ee.responseType="arraybuffer",ee.onload=()=>
vendor: 7,331 bytes, line 17133
17133{if(ee.status==200||ee.status==0&&ee.response){Y(ee.response);return}de()},ee.onerror=de,ee.send(null)});var S=a.print||console.log.bind(console),T=a.printErr||console.warn.bind(console);Object.assign(a,l),l=null,a.arguments&&a.arguments,a.thisProgram&&a.thisProgram,a.quit&&a.quit;var O;a.wasmBinary&&(O=a.wasmBinary),a.noExitRuntime,typeof WebAssembly!="object"&&ur("no native wasm support detected");var L,M=!1,W=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function V(j,Y,de){Y>>>=0;for(var ee=Y+de,Ve=Y;j[Ve]&&!(Ve>=ee);)++Ve;if(Ve-Y>16&&j.buffer&&W)return W.decode(j.subarray(Y,Ve));for(var Pe="";Y<Ve;){var $e=j[Y++];if(!($e&128)){Pe+=String.fromCharCode($e);continue}var ge=j[Y++]&63;if(($e&224)==192){Pe+=String.fromCharCode(($e&31)<<6|ge);continue}var We=j[Y++]&63;if(($e&240)==224?$e=($e&15)<<12|ge<<6|We:$e=($e&7)<<18|ge<<12|We<<6|j[Y++]&63,$e<65536)Pe+=String.fromCharCode($e);else{var Ot=$e-65536;Pe+=String.fromCharCode(55296|Ot>>10,56320|Ot&1023)}}return Pe}function G(j,Y){return j>>>=0,j?V(fe,j,Y):""}function K(j,Y,de,ee){if(de>>>=0,!(ee>0))return 0;for(var Ve=de,Pe=de+ee-1,$e=0;$e<j.length;++$e){var ge=j.charCodeAt($e);if(ge>=55296&&ge<=57343){var We=j.charCodeAt(++$e);ge=65536+((ge&1023)<<10)|We&1023}if(ge<=127){if(de>=Pe)break;Y[de++>>>0]=ge}else if(ge<=2047){if(de+1>=Pe)break;Y[de++>>>0]=192|ge>>6,Y[de++>>>0]=128|ge&63}else if(ge<=65535){if(de+2>=Pe)break;Y[de++>>>0]=224|ge>>12,Y[de++>>>0]=128|ge>>6&63,Y[de++>>>0]=128|ge&63}else{if(de+3>=Pe)break;Y[de++>>>0]=240|ge>>18,Y[de++>>>0]=128|ge>>12&63,Y[de++>>>0]=128|ge>>6&63,Y[de++>>>0]=128|ge&63}}return Y[de>>>0]=0,de-Ve}function J(j,Y,de){return K(j,fe,Y,de)}var ue,se,fe,Ie;function pe(j){ue=j,a.HEAP8=se=new Int8Array(j),a.HEAP16=new Int16Array(j),a.HEAP32=new Int32Array(j),a.HEAPU8=fe=new Uint8Array(j),a.HEAPU16=new Uint16Array(j),a.HEAPU32=Ie=new Uint32Array(j),a.HEAPF32=new Float32Array(j),a.HEAPF64=new Float64Array(j)}a.INITIAL_MEMORY;var Fe=[],Qe=[],it=[];function Nt(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)on(a.preRun.shift());Tr(Fe)}function He(){Tr(Qe)}function An(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)es(a.postRun.shift());Tr(it)}function on(j){Fe.unshift(j)}function Dn(j){Qe.unshift(j)}function es(j){it.unshift(j)}var Ze=0,On=null;function _r(j){Ze++,a.monitorRunDependencies&&a.monitorRunDependencies(Ze)}function Yn(j){if(Ze--,a.monitorRunDependencies&&a.monitorRunDependencies(Ze),Ze==0&&On){var Y=On;On=null,Y()}}function ur(j){a.onAbort&&a.onAbort(j),j="Aborted("+j+")",T(j),M=!0,j+=". Build with -sASSERTIONS for more info.";var Y=new WebAssembly.RuntimeError(j);throw i(Y),Y}var et="data:application/octet-stream;base64,";function je(j){return j.startsWith(et)}function Qn(j){return j.startsWith("file://")}var ft;ft="tfjs-backend-wasm.wasm",je(ft)||(ft=m(ft));function Nr(j){try{if(j==ft&&O)return new Uint8Array(O);if(b)return b(j);throw"both async and sync fetching of the wasm failed"}catch(Y){ur(Y)}}function ts(){if(!O&&(u||d)){if(typeof fetch=="function"&&!Qn(ft))return fetch(ft,{credentials:"same-origin"}).then(function(j){if(!j.ok)throw"failed to load wasm binary file at '"+ft+"'";return j.arrayBuffer()}).catch(function(){return Nr(ft)});if(y)return new Promise(function(j,Y){y(ft,function(de){j(new Uint8Array(de))},Y)})}return Promise.resolve().then(function(){return Nr(ft)})}function ns(){var j={env:ss,wasi_snapshot_preview1:ss};function Y($e,ge){var We=$e.exports;a.asm=We,L=a.asm.memory,pe(L.buffer),a.asm.__indirect_function_table,Dn(a.asm.__wasm_call_ctors),Yn()}_r();function de($e){Y($e.instance)}function ee($e){return ts().then(function(ge){return WebAssembly.instantiate(ge,j)}).then(function(ge){return ge}).then($e,function(ge){T("failed to asynchronously prepare wasm: "+ge),ur(ge)})}function Ve(){return!O&&typeof WebAssembly.instantiateStreaming=="function"&&!je(ft)&&!Qn(ft)&&!p&&typeof fetch=="function"?fetch(ft,{credentials:"same-origin"}).then(function($e){var ge=WebAssembly.instantiateStreaming($e,j);return ge.then(de,function(We){return T("wasm streaming compile failed: "+We),T("falling back to ArrayBuffer instantiation"),ee(de)})}):ee(de)}if(a.instantiateWasm)try{var Pe=a.instantiateWasm(j,Y);return Pe}catch($e){T("Module.instantiateWasm callback failed with error: "+$e),i($e)}return Ve().catch(i),{}}function cr(j){this.name="ExitStatus",this.message="Program terminated with exit("+j+")",this.status=j}function Tr(j){for(;j.length>0;)j.shift()(a)}function kr(){ur("")}function rs(){return 4294901760}function Fn(){return rs()}function Hs(j,Y,de){fe.copyWithin(j>>>0,Y>>>0,Y+de>>>0)}function Er(j){try{return L.grow(j-ue.byteLength+65535>>>16),pe(L.buffer),1}catch{}}function un(j){var Y=fe.length;j=j>>>0;var de=rs();if(j>de)return!1;let ee=(We,Ot)=>We+(Ot-We%Ot)%Ot;for(var Ve=1;Ve<=4;Ve*=2){var Pe=Y*(1+.2/Ve);Pe=Math.min(Pe,j+100663296);var $e=Math.min(de,ee(Math.max(j,Pe),65536)),ge=Er($e);if(ge)return!0}return!1}function lr(j){return 52}function js(j,Y,de,ee,Ve){return 70}var Va=[null,[],[]];function Zn(j,Y){var de=Va[j];Y===0||Y===10?((j===1?S:T)(V(de,0)),de.length=0):de.push(Y)}function qs(j,Y,de,ee){for(var Ve=0,Pe=0;Pe<de;Pe++){var $e=Ie[Y>>>2],ge=Ie[Y+4>>>2];Y+=8;for(var We=0;We<ge;We++)Zn(j,fe[$e+We>>>0]);Ve+=ge}return Ie[ee>>>2]=Ve,0}function Pn(j){var Y=a["_"+j];return Y}function Jn(j,Y){se.set(j,Y>>>0)}function mt(j,Y,de,ee,Ve){var Pe={string:ct=>{var yn=0;if(ct!=null&&ct!==0){var hr=(ct.length<<2)+1;yn=Ut(hr),J(ct,yn,hr)}return yn},array:ct=>{var yn=Ut(ct.length);return Jn(ct,yn),yn}};function $e(ct){return Y==="string"?G(ct):Y==="boolean"?Boolean(ct):ct}var ge=Pn(j),We=[],Ot=0;if(ee)for(var Me=0;Me<ee.length;Me++){var zt=Pe[de[Me]];zt?(Ot===0&&(Ot=Rr()),We[Me]=zt(ee[Me])):We[Me]=ee[Me]}var pr=ge.apply(null,We);function Xs(ct){return Ot!==0&&mn(Ot),$e(ct)}return pr=Xs(pr),pr}function Ks(j,Y,de,ee){de=de||[];var Ve=de.every($e=>$e==="number"||$e==="boolean"),Pe=Y!=="string";return Pe&&Ve&&!ee?Pn(j):function(){return mt(j,Y,de,arguments)}}var ss={abort:kr,emscripten_get_heap_max:Fn,emscripten_memcpy_big:Hs,emscripten_resize_heap:un,fd_close:lr,fd_seek:js,fd_write:qs};ns(),a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.__wasm_call_ctors).apply(null,arguments)},a._init=function(){return(a._init=a.asm.init).apply(null,arguments)},a._init_with_threads_count=function(){return(a._init_with_threads_count=a.asm.init_with_threads_count).apply(null,arguments)},a._get_threads_count=function(){return(a._get_threads_count=a.asm.get_threads_count).apply(null,arguments)},a._register_tensor=function(){return(a._register_tensor=a.asm.register_tensor).apply(null,arguments)},a._dispose_data=function(){return(a._dispose_data=a.asm.dispose_data).apply(null,arguments)},a._dispose=function(){return(a._dispose=a.asm.dispose).apply(null,arguments)},a._Abs=function(){return(a._Abs=a.asm.Abs).apply(null,arguments)},a._Acos=function(){return(a._Acos=a.asm.Acos).apply(null,arguments)},a._Acosh=function(){return(a._Acosh=a.asm.Acosh).apply(null,arguments)},a._Add=function(){return(a._Add=a.asm.Add).apply(null,arguments)},a._AddN=function(){return(a._AddN=a.asm.AddN).apply(null,arguments)},a._All=function(){return(a._All=a.asm.All).apply(null,arguments)},a._Any=function(){return(a._Any=a.asm.Any).apply(null,arguments)}
17133,a._ArgMax=function(){return(a._ArgMax=a.asm.ArgMax).apply(null,arguments)},a._ArgMin=function(){return(a._ArgMin=a.asm.ArgMin).apply(null,arguments)},a._Asin=function(){return(a._Asin=a.asm.Asin).apply(null,arguments)},a._Asinh=function(){return(a._Asinh=a.asm.Asinh).apply(null,arguments)},a._Atan=function(){return(a._Atan=a.asm.Atan).apply(null,arguments)},a._Atan2=function(){return(a._Atan2=a.asm.Atan2).apply(null,arguments)},a._Atanh=function(){return(a._Atanh=a.asm.Atanh).apply(null,arguments)},a._AvgPool=function(){return(a._AvgPool=a.asm.AvgPool).apply(null,arguments)},a._AvgPool3D=function(){return(a._AvgPool3D=a.asm.AvgPool3D).apply(null,arguments)},a._AvgPool3DGrad=function(){return(a._AvgPool3DGrad=a.asm.AvgPool3DGrad).apply(null,arguments)},a._AvgPoolGrad=function(){return(a._AvgPoolGrad=a.asm.AvgPoolGrad).apply(null,arguments)},a._BatchMatMul=function(){return(a._BatchMatMul=a.asm.BatchMatMul).apply(null,arguments)},a._Bincount=function(){return(a._Bincount=a.asm.Bincount).apply(null,arguments)},a._BitwiseAnd=function(){return(a._BitwiseAnd=a.asm.BitwiseAnd).apply(null,arguments)},a._Ceil=function(){return(a._Ceil=a.asm.Ceil).apply(null,arguments)},a._ClipByValue=function(){return(a._ClipByValue=a.asm.ClipByValue).apply(null,arguments)},a._Conv2D=function(){return(a._Conv2D=a.asm.Conv2D).apply(null,arguments)},a._Conv2DBackpropInput=function(){return(a._Conv2DBackpropInput=a.asm.Conv2DBackpropInput).apply(null,arguments)},a._Conv3D=function(){return(a._Conv3D=a.asm.Conv3D).apply(null,arguments)},a._Conv3DBackpropFilterV2=function(){return(a._Conv3DBackpropFilterV2=a.asm.Conv3DBackpropFilterV2).apply(null,arguments)},a._Conv3DBackpropInputV2=function(){return(a._Conv3DBackpropInputV2=a.asm.Conv3DBackpropInputV2).apply(null,arguments)},a._Cos=function(){return(a._Cos=a.asm.Cos).apply(null,arguments)},a._Cosh=function(){return(a._Cosh=a.asm.Cosh).apply(null,arguments)},a._CropAndResize=function(){return(a._CropAndResize=a.asm.CropAndResize).apply(null,arguments)},a._Cumprod=function(){return(a._Cumprod=a.asm.Cumprod).apply(null,arguments)},a._Cumsum=function(){return(a._Cumsum=a.asm.Cumsum).apply(null,arguments)},a._DenseBincount=function(){return(a._DenseBincount=a.asm.DenseBincount).apply(null,arguments)},a._DepthToSpace=function(){return(a._DepthToSpace=a.asm.DepthToSpace).apply(null,arguments)},a._DepthwiseConv2dNative=function(){return(a._DepthwiseConv2dNative=a.asm.DepthwiseConv2dNative).apply(null,arguments)},a._Diag=function(){return(a._Diag=a.asm.Diag).apply(null,arguments)},a._Dilation2D=function(){return(a._Dilation2D=a.asm.Dilation2D).apply(null,arguments)},a._Dilation2DBackpropFilter=function(){return(a._Dilation2DBackpropFilter=a.asm.Dilation2DBackpropFilter).apply(null,arguments)},a._Dilation2DBackpropInput=function(){return(a._Dilation2DBackpropInput=a.asm.Dilation2DBackpropInput).apply(null,arguments)},a._Elu=function(){return(a._Elu=a.asm.Elu).apply(null,arguments)},a._EluGrad=function(){return(a._EluGrad=a.asm.EluGrad).apply(null,arguments)},a._Equal=function(){return(a._Equal=a.asm.Equal).apply(null,arguments)},a._Erf=function(){return(a._Erf=a.asm.Erf).apply(null,arguments)},a._Exp=function(){return(a._Exp=a.asm.Exp).apply(null,arguments)},a._Expm1=function(){return(a._Expm1=a.asm.Expm1).apply(null,arguments)},a._FlipLeftRight=function(){return(a._FlipLeftRight=a.asm.FlipLeftRight).apply(null,arguments)},a._Floor=function(){return(a._Floor=a.asm.Floor).apply(null,arguments)},a._FloorDiv=function(){return(a._FloorDiv=a.asm.FloorDiv).apply(null,arguments)},a._FusedBatchNorm=function(){return(a._FusedBatchNorm=a.asm.FusedBatchNorm).apply(null,arguments)},a._FusedConv2D=function(){return(a._FusedConv2D=a.asm.FusedConv2D).apply(null,arguments)},a._FusedDepthwiseConv2D=function(){return(a._FusedDepthwiseConv2D=a.asm.FusedDepthwiseConv2D).apply(null,arguments)},a._Gather=function(){return(a._Gather=a.asm.Gather).apply(null,arguments)},a._GatherNd=function(){return(a._GatherNd=a.asm.GatherNd).apply(null,arguments)},a._Greater=function(){return(a._Greater=a.asm.Greater).apply(null,arguments)},a._GreaterEqual=function(){return(a._GreaterEqual=a.asm.GreaterEqual).apply(null,arguments)},a._IsFinite=function(){return(a._IsFinite=a.asm.IsFinite).apply(null,arguments)},a._IsInf=function(){return(a._IsInf=a.asm.IsInf).apply(null,arguments)},a._IsNan=function(){return(a._IsNan=a.asm.IsNan).apply(null,arguments)},a._LRN=function(){return(a._LRN=a.asm.LRN).apply(null,arguments)},a._LRNGrad=function(){return(a._LRNGrad=a.asm.LRNGrad).apply(null,arguments)},a._LeakyRelu=function(){return(a._LeakyRelu=a.asm.LeakyRelu).apply(null,arguments)},a._Less=function(){return(a._Less=a.asm.Less).apply(null,arguments)},a._LessEqual=function(){return(a._LessEqual=a.asm.LessEqual).apply(null,arguments)},a._LinSpace=function(){return(a._LinSpace=a.asm.LinSpace).apply(null,arguments)},a._Log=function(){return(a._Log=a.asm.Log).apply(null,arguments)},a._Log1p=function(){return(a._Log1p=a.asm.Log1p).apply(null,arguments)},a._LogicalAnd=function(){return(a._LogicalAnd=a.asm.LogicalAnd).apply(null,arguments)},a._LogicalNot=function(){return(a._LogicalNot=a.asm.LogicalNot).apply(null,arguments)},a._LogicalOr=function(){return(a._LogicalOr=a.asm.LogicalOr).apply(null,arguments)},a._LogicalXor=function(){return(a._LogicalXor=a.asm.LogicalXor).apply(null,arguments)},a._Max=function(){return(a._Max=a.asm.Max).apply(null,arguments)},a._MaxPool=function(){return(a._MaxPool=a.asm.MaxPool).apply(null,arguments)},a._MaxPool3D=function(){return(a._MaxPool3D=a.asm.MaxPool3D).apply(null,arguments)},a._MaxPool3DGrad=function(){return(a._MaxPool3DGrad=a.asm.MaxPool3DGrad).apply(null,arguments)},a._MaxPoolGrad=function(){return(a._MaxPoolGrad=a.asm.MaxPoolGrad).apply(null,arguments)},a._MaxPoolWithArgmax=function(){return(a._MaxPoolWithArgmax=a.asm.MaxPoolWithArgmax).apply(null,arguments)},a._Maximum=function(){return(a._Maximum=a.asm.Maximum).apply(null,arguments)},a._Mean=function(){return(a._Mean=a.asm.Mean).apply(null,arguments)},a._Min=function(){return(a._Min=a.asm.Min).apply(null,arguments)},a._Minimum=function(){return(a._Minimum=a.asm.Minimum).apply(null,arguments)},a._MirrorPad=function(){return(a._MirrorPad=a.asm.MirrorPad).apply(null,arguments)},a._Mod=function(){return(a._Mod=a.asm.Mod).apply(null,arguments)},a._Multinomial=function(){return(a._Multinomial=a.asm.Multinomial).apply(null,arguments)},a._Multiply=function(){return(a._Multiply=a.asm.Multiply).apply(null,arguments)},a._Neg=function(){return(a._Neg=a.asm.Neg).apply(null,arguments)},a._NonMaxSuppressionV3=function(){return(a._NonMaxSuppressionV3=a.asm.NonMaxSuppressionV3).apply(null,arguments)},a._NonMaxSuppressionV4=function(){return(a._NonMaxSuppressionV4=a.asm.NonMaxSuppressionV4).apply(null,arguments)},a._NonMaxSuppressionV5=function(){return(a._NonMaxSuppressionV5=a.asm.NonMaxSuppressionV5).apply(null,arguments)},a._NotEqual=function(){return(a._NotEqual=a.asm.NotEqual).apply(null,arguments)},a._OneHot=function(){return(a._OneHot=a.asm.OneHot).apply(null,arguments)},a._PadV2=function(){return(a._PadV2=a.asm.PadV2).apply(null,arguments)},a._Pow=function(){return(a._Pow=a.asm.Pow).apply(null,arguments)},a._Prelu=function(){return(a._Prelu=a.asm.Prelu).apply(null,arguments)},a._Prod=function(){return(a._Prod=a.asm.Prod).apply(null,arguments)},a._RealDiv=function(){return(a._RealDiv=a.asm.RealDiv).apply(null,arguments)},a._Reciprocal=function(){return(a._Reciprocal=a.asm.Reciprocal).apply(null,arguments)},a._Relu=function(){return(a._Relu=a.asm.Relu).apply(null,arguments)},a._Relu6=function(){return(a._Relu6=a.asm.Relu6).apply(null,arguments)},a._ResizeBilinear=function(){return(a._ResizeBilinear=a.asm.ResizeBilinear).apply(null,arguments)},a._ResizeBilinearGrad=function(){return(a._ResizeBilinearGrad=a.asm.ResizeBilinearGrad).apply(null,arguments)},a._ResizeNearestNeighbor=function(){return(a._ResizeNearestNeighbor=a.asm.ResizeNearestNeighbor).apply(null,arguments)},a._ResizeNearestNeighborGrad=function(){return(a._ResizeNearestNeighborGrad=a.asm.ResizeNearestNeighborGrad).apply(null,arguments)}
vendor: 4,785 bytes, lines 17133-17136
17133,a._Reverse=function(){return(a._Reverse=a.asm.Reverse).apply(null,arguments)},a._RotateWithOffset=function(){return(a._RotateWithOffset=a.asm.RotateWithOffset).apply(null,arguments)},a._Round=function(){return(a._Round=a.asm.Round).apply(null,arguments)},a._Rsqrt=function(){return(a._Rsqrt=a.asm.Rsqrt).apply(null,arguments)},a._ScatterNd=function(){return(a._ScatterNd=a.asm.ScatterNd).apply(null,arguments)},a._SearchSorted=function(){return(a._SearchSorted=a.asm.SearchSorted).apply(null,arguments)},a._SelectV2=function(){return(a._SelectV2=a.asm.SelectV2).apply(null,arguments)},a._Selu=function(){return(a._Selu=a.asm.Selu).apply(null,arguments)},a._Sigmoid=function(){return(a._Sigmoid=a.asm.Sigmoid).apply(null,arguments)},a._Sign=function(){return(a._Sign=a.asm.Sign).apply(null,arguments)},a._Sin=function(){return(a._Sin=a.asm.Sin).apply(null,arguments)},a._Sinh=function(){return(a._Sinh=a.asm.Sinh).apply(null,arguments)},a._Softmax=function(){return(a._Softmax=a.asm.Softmax).apply(null,arguments)},a._Softplus=function(){return(a._Softplus=a.asm.Softplus).apply(null,arguments)},a._SparseFillEmptyRows=function(){return(a._SparseFillEmptyRows=a.asm.SparseFillEmptyRows).apply(null,arguments)},a._SparseReshape=function(){return(a._SparseReshape=a.asm.SparseReshape).apply(null,arguments)},a._SparseSegmentReduction=function(){return(a._SparseSegmentReduction=a.asm.SparseSegmentReduction).apply(null,arguments)},a._SparseToDense=function(){return(a._SparseToDense=a.asm.SparseToDense).apply(null,arguments)},a._Sqrt=function(){return(a._Sqrt=a.asm.Sqrt).apply(null,arguments)},a._Square=function(){return(a._Square=a.asm.Square).apply(null,arguments)},a._SquaredDifference=function(){return(a._SquaredDifference=a.asm.SquaredDifference).apply(null,arguments)},a._Step=function(){return(a._Step=a.asm.Step).apply(null,arguments)},a._StridedSlice=function(){return(a._StridedSlice=a.asm.StridedSlice).apply(null,arguments)},a._Sub=function(){return(a._Sub=a.asm.Sub).apply(null,arguments)},a._Sum=function(){return(a._Sum=a.asm.Sum).apply(null,arguments)},a._Tan=function(){return(a._Tan=a.asm.Tan).apply(null,arguments)},a._Tanh=function(){return(a._Tanh=a.asm.Tanh).apply(null,arguments)},a._TensorScatterUpdate=function(){return(a._TensorScatterUpdate=a.asm.TensorScatterUpdate).apply(null,arguments)},a._Tile=function(){return(a._Tile=a.asm.Tile).apply(null,arguments)},a._TopK=function(){return(a._TopK=a.asm.TopK).apply(null,arguments)},a._Transform=function(){return(a._Transform=a.asm.Transform).apply(null,arguments)},a._Transpose=function(){return(a._Transpose=a.asm.Transpose).apply(null,arguments)},a.__FusedMatMul=function(){return(a.__FusedMatMul=a.asm._FusedMatMul).apply(null,arguments)},a._malloc=function(){return(a._malloc=a.asm.malloc).apply(null,arguments)},a._free=function(){return(a._free=a.asm.free).apply(null,arguments)},a.___errno_location=function(){return(a.___errno_location=a.asm.__errno_location).apply(null,arguments)};var Rr=a.stackSave=function(){return(Rr=a.stackSave=a.asm.stackSave).apply(null,arguments)},mn=a.stackRestore=function(){return(mn=a.stackRestore=a.asm.stackRestore).apply(null,arguments)},Ut=a.stackAlloc=function(){return(Ut=a.stackAlloc=a.asm.stackAlloc).apply(null,arguments)};a.dynCall_iijjiiii=function(){return(a.dynCall_iijjiiii=a.asm.dynCall_iijjiiii).apply(null,arguments)},a.dynCall_jiji=function(){return(a.dynCall_jiji=a.asm.dynCall_jiji).apply(null,arguments)},a.cwrap=Ks;var dr;On=function j(){dr||as(),dr||(On=j)};function as(j){if(Ze>0||(Nt(),Ze>0))return;function Y(){dr||(dr=!0,a.calledRun=!0,!M&&(He(),o(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),An()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),Y()},1)):Y()}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();as();var Ln;c&&(Ln={uncaughtException:process.listeners("uncaughtException").filter(function(j){return!c.uncaughtException.indexOf(j)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(j){return!c.unhandledRejection.indexOf(j)>-1})});var er;if(typeof s<"u")er=s;else if(typeof WasmBackendModuleThreadedSimd<"u")er=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(Ln){var gn=er._dispose;er._dispose=function(){gn(),Ln.uncaughtException.forEach(function(j){process.removeListener("uncaughtException",j)}),Ln.unhandledRejection.forEach(function(j){process.removeListener("unhandledRejection",j)})}}return s.ready}})();n.exports=t})(ih);const r0=ih.exports,HG=vl({__proto__:null,default:r0},[ih.exports]);/** 17134 * @license 17135 * Copyright 2019 Google LLC. All Rights Reserved. 17136 * Licensed under the Apache License, Version 2.0 (the "License");
17137 * you may not use this file except in compliance with the License. 17138 * You may obtain a copy of the License at 17139 * 17140 * http://www.apache.org/licenses/LICENSE-2.0 17141 * 17142 * Unless required by applicable law or agreed to in writing, software 17143 * distributed under the License is distributed on an "AS IS" BASIS, 17144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17145 * See the License for the specific language governing permissions and 17146 * limitations under the License. 17147 * ============================================================================= 17148 */const Cf=n0||zG,jG=r0||HG;class qG extends Il{constructor(e){super(),this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(ZG),JG=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new zf(this,fr())}write(e,t,r){const s={id:this.dataIdNextNumber++};return this.move(s,e,t,r,1),s}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){const t=dn();return e(),{kernelMs:dn()-t}}move(e,t,r,s,a){const o=this.dataIdNextNumber++;if(s==="string"){const u=t;this.dataIdMap.set(e,{id:o,stringBytes:u,shape:r,dtype:s,memoryOffset:null,refCount:a});return}const i=H(r),c=i*wa(s),l=this.wasm._malloc(c)>>>0;this.dataIdMap.set(e,{id:o,memoryOffset:l,shape:r,dtype:s,refCount:a}),this.wasm.tfjs.registerTensor(o,i,l),t!=null&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,c),l)}async read(e){return this.readSync(e)}readSync(e,t,r){const{memoryOffset:s,dtype:a,shape:o,stringBytes:i}=this.dataIdMap.get(e);if(a==="string")return(t==null||t===0)&&(r==null||r>=i.length)?i:i.slice(t,r);t=t||0,r=r||H(o);const c=wa(a),l=this.wasm.HEAPU8.slice(s+t*c,s+r*c);return YG(l.buffer,a)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){const r=this.dataIdMap.get(e);if(r.refCount--,!t&&r.refCount>0)return!1;this.wasm._free(r.memoryOffset),this.wasm.tfjs.disposeData(r.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){const t=this.dataIdMap.get(e);t!=null&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,r,s){let a;if(r==null)a=this.write(s!=null?s:null,e,t);else{const o=this.dataIdNextNumber++;a={id:o},this.dataIdMap.set(a,{id:o,memoryOffset:r,shape:e,dtype:t,refCount:1});const i=H(e);this.wasm.tfjs.registerTensor(o,i,r)}return{dataId:a,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:r}){const s=this.wasm.HEAPU8.buffer,{memoryOffset:a}=this.dataIdMap.get(r),o=H(e);switch(t){case"float32":return new Float32Array(s,a,o);case"int32":return new Int32Array(s,a,o);case"bool":return new Uint8Array(s,a,o);default:throw new Error(`Unknown dtype ${t}`)}}}function KG(n,e,t){let r="tfjs-backend-wasm.wasm";return n&&e?r="tfjs-backend-wasm-threaded-simd.wasm":n&&(r="tfjs-backend-wasm-simd.wasm"),vc!=null&&vc[r]!=null?vc[r]:t+r}async function XG(){const[n,e]=await Promise.all([U().getAsync("WAS
17148M_HAS_SIMD_SUPPORT"),U().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise((t,r)=>{const s={};s.locateFile=(i,c)=>{if(i.endsWith(".worker.js")){const l=GG.replace(/\n/g,"\\n"),u=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(u)}return i.endsWith(".wasm")?KG(n,e,c):c+i};let a=!1;s.onAbort=()=>{if(a||Ic)return;Ic=!0,r({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"})};let o;e&&n&&QG==null?(s.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+Cf.toString()],{type:"text/javascript"}),o=Cf(s)):o=jG(s),o.then(i=>{a=!0,Ic=!1;const c=null;i.tfjs={init:i.cwrap("init",null,[]),initWithThreadsCount:i.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:i.cwrap("get_threads_count","number",[]),registerTensor:i.cwrap("register_tensor",null,["number","number","number"]),disposeData:i.cwrap("dispose_data",c,["number"]),dispose:i.cwrap("dispose",c,[])},t({wasm:i})}).catch(r)})}function YG(n,e){switch(e){case"float32":return new Float32Array(n);case"int32":return new Int32Array(n);case"bool":return new Uint8Array(n);default:throw new Error(`Unknown dtype ${e}`)}}let QG=null,vc={},Ic=!1,ZG=-1,JG=-1;/** 17149 * @license 17150 * Copyright 2020 Google LLC. All Rights Reserved. 17151 * Licensed under the Apache License, Version 2.0 (the "License"); 17152 * you may not use this file except in compliance with the License. 17153 * You may obtain a copy of the License at 17154 * 17155 * http://www.apache.org/licenses/LICENSE-2.0 17156 * 17157 * Unless required by applicable law or agreed to in writing, software 17158 * distributed under the License is distributed on an "AS IS" BASIS, 17159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17160 * See the License for the specific language governing permissions and 17161 * limitations under the License. 17162 * ============================================================================= 17163 */const eH=2;Lm("wasm",async()=>{const{wasm:n}=await XG();return new qG(n)},eH);var tH={};(function(){var n;function e(f){var x=0;return function(){return x<f.length?{done:!1,value:f[x++]}:{done:!0}}}var t=typeof Object.defineProperties=="function"?Object.defineProperty:function(f,x,I){return f==Array.prototype||f==Object.prototype||(f[x]=I.value),f};function r(f){f=[typeof globalThis=="object"&&globalThis,f,typeof window=="object"&&window,typeof self=="object"&&self,typeof Nn=="object"&&Nn];for(var x=0;x<f.length;++x){var I=f[x];if(I&&I.Math==Math)return I}throw Error("Cannot find global object")}var s=r(this);function a(f,x){if(x)e:{var I=s;f=f.split(".");for(var C=0;C<f.length-1;C++){var k=f[C];if(!(k in I))break e;I=I[k]}f=f[f.length-1],C=I[f],x=x(C),x!=C&&x!=null&&t(I,f,{configurable:!0,writable:!0,value:x})}}a("Symbol",function(f){function x(A){if(this instanceof x)throw new TypeError("Symbol is not a constructor");return new I(C+(A||"")+"_"+k++,A)}function I(A,E){this.h=A,t(this,"description",{configurable:!0,writable:!0,value:E})}if(f)return f;I.prototype.toString=function(){return this.h};var C="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",k=0;return x}),a("Symbol.iterator",function(f){if(f)return f;f=Symbol("Symbol.iterator");for(var x="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),I=0;I<x.length;I++){var C=s[x[I]];typeof C=="function"&&typeof C.prototype[f]!="function"&&t(C.prototype,f,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return f});function o(f){return f={next:f},f[Symbol.iterator]=function(){return this},f}function i(f){var x=typeof Symbol<"u"&&Symbol.iterator&&f[Symbol.iterator];return x?x.call(f):{next:e(f)}}function c(f){if(!(f instanceof Array)){f=i(f);for(var x,I=[];!(x=f.next()).done;)I.push(x.value);f=I}return f}var l=typeof Object.assign=="function"?Object.assign:function(f,x){for(var I=1;I<arguments.length;I++){var C=arguments[I];if(C)for(var k in C)Object.prototype.hasOwnProperty.call(C,k)&&(f[k]=C[k])}return f};a("Object.assign",function(f){return f||l});var u=typeof Object.create=="function"?Object.create:function(f){function x(){}return x.prototype=f,new x},d;
vendor: 6,097 bytes, line 17163
17163if(typeof Object.setPrototypeOf=="function")d=Object.setPrototypeOf;else{var p;e:{var h={a:!0},m={};try{m.__proto__=h,p=m.a;break e}catch{}p=!1}d=p?function(f,x){if(f.__proto__=x,f.__proto__!==x)throw new TypeError(f+" is not extensible");return f}:null}var g=d;function y(f,x){if(f.prototype=u(x.prototype),f.prototype.constructor=f,g)g(f,x);else for(var I in x)if(I!="prototype")if(Object.defineProperties){var C=Object.getOwnPropertyDescriptor(x,I);C&&Object.defineProperty(f,I,C)}else f[I]=x[I];f.ya=x.prototype}function b(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function v(f){if(f.m)throw new TypeError("Generator is already running");f.m=!0}b.prototype.u=function(f){this.i=f};function $(f,x){f.l={ma:x,na:!0},f.h=f.s||f.v}b.prototype.return=function(f){this.l={return:f},this.h=this.v};function S(f,x,I){return f.h=I,{value:x}}function T(f){this.h=new b,this.i=f}function O(f,x){v(f.h);var I=f.h.j;return I?L(f,"return"in I?I.return:function(C){return{value:C,done:!0}},x,f.h.return):(f.h.return(x),M(f))}function L(f,x,I,C){try{var k=x.call(f.h.j,I);if(!(k instanceof Object))throw new TypeError("Iterator result "+k+" is not an object");if(!k.done)return f.h.m=!1,k;var A=k.value}catch(E){return f.h.j=null,$(f.h,E),M(f)}return f.h.j=null,C.call(f.h,A),M(f)}function M(f){for(;f.h.h;)try{var x=f.i(f.h);if(x)return f.h.m=!1,{value:x.value,done:!1}}catch(I){f.h.i=void 0,$(f.h,I)}if(f.h.m=!1,f.h.l){if(x=f.h.l,f.h.l=null,x.na)throw x.ma;return{value:x.return,done:!0}}return{value:void 0,done:!0}}function W(f){this.next=function(x){return v(f.h),f.h.j?x=L(f,f.h.j.next,x,f.h.u):(f.h.u(x),x=M(f)),x},this.throw=function(x){return v(f.h),f.h.j?x=L(f,f.h.j.throw,x,f.h.u):($(f.h,x),x=M(f)),x},this.return=function(x){return O(f,x)},this[Symbol.iterator]=function(){return this}}function V(f){function x(C){return f.next(C)}function I(C){return f.throw(C)}return new Promise(function(C,k){function A(E){E.done?C(E.value):Promise.resolve(E.value).then(x,I).then(A,k)}A(f.next())})}function G(f){return V(new W(new T(f)))}a("Promise",function(f){function x(E){this.i=0,this.j=void 0,this.h=[],this.u=!1;var P=this.l();try{E(P.resolve,P.reject)}catch(z){P.reject(z)}}function I(){this.h=null}function C(E){return E instanceof x?E:new x(function(P){P(E)})}if(f)return f;I.prototype.i=function(E){if(this.h==null){this.h=[];var P=this;this.j(function(){P.m()})}this.h.push(E)};var k=s.setTimeout;I.prototype.j=function(E){k(E,0)},I.prototype.m=function(){for(;this.h&&this.h.length;){var E=this.h;this.h=[];for(var P=0;P<E.length;++P){var z=E[P];E[P]=null;try{z()}catch(X){this.l(X)}}}this.h=null},I.prototype.l=function(E){this.j(function(){throw E})},x.prototype.l=function(){function E(X){return function(ne){z||(z=!0,X.call(P,ne))}}var P=this,z=!1;return{resolve:E(this.I),reject:E(this.m)}},x.prototype.I=function(E){if(E===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(E instanceof x)this.L(E);else{e:switch(typeof E){case"object":var P=E!=null;break e;case"function":P=!0;break e;default:P=!1}P?this.F(E):this.s(E)}},x.prototype.F=function(E){var P=void 0;try{P=E.then}catch(z){this.m(z);return}typeof P=="function"?this.M(P,E):this.s(E)},x.prototype.m=function(E){this.v(2,E)},x.prototype.s=function(E){this.v(1,E)},x.prototype.v=function(E,P){if(this.i!=0)throw Error("Cannot settle("+E+", "+P+"): Promise already settled in state"+this.i);this.i=E,this.j=P,this.i===2&&this.K(),this.H()},x.prototype.K=function(){var E=this;k(function(){if(E.D()){var P=s.console;typeof P<"u"&&P.error(E.j)}},1)},x.prototype.D=function(){if(this.u)return!1;var E=s.CustomEvent,P=s.Event,z=s.dispatchEvent;return typeof z>"u"?!0:(typeof E=="function"?E=new E("unhandledrejection",{cancelable:!0}):typeof P=="function"?E=new P("unhandledrejection",{cancelable:!0}):(E=s.document.createEvent("CustomEvent"),E.initCustomEvent("unhandledrejection",!1,!0,E)),E.promise=this,E.reason=this.j,z(E))},x.prototype.H=function(){if(this.h!=null){for(var E=0;E<this.h.length;++E)A.i(this.h[E]);this.h=null}};var A=new I;return x.prototype.L=function(E){var P=this.l();E.T(P.resolve,P.reject)},x.prototype.M=function(E,P){var z=this.l();try{E.call(P,z.resolve,z.reject)}catch(X){z.reject(X)}},x.prototype.then=function(E,P){function z(he,ie){return typeof he=="function"?function(we){try{X(he(we))}catch(_e){ne(_e)}}:ie}var X,ne,xe=new x(function(he,ie){X=he,ne=ie});return this.T(z(E,X),z(P,ne)),xe},x.prototype.catch=function(E){return this.then(void 0,E)},x.prototype.T=function(E,P){function z(){switch(X.i){case 1:E(X.j);break;case 2:P(X.j);break;default:throw Error("Unexpected state: "+X.i)}}var X=this;this.h==null?A.i(z):this.h.push(z),this.u=!0},x.resolve=C,x.reject=function(E){return new x(function(P,z){z(E)})},x.race=function(E){return new x(function(P,z){for(var X=i(E),ne=X.next();!ne.done;ne=X.next())C(ne.value).T(P,z)})},x.all=function(E){var P=i(E),z=P.next();return z.done?C([]):new x(function(X,ne){function xe(we){return function(_e){he[we]=_e,ie--,ie==0&&X(he)}}var he=[],ie=0;do he.push(void 0),ie++,C(z.value).T(xe(he.length-1),ne),z=P.next();while(!z.done)})},x});function K(f,x){f instanceof String&&(f+="");var I=0,C=!1,k={next:function(){if(!C&&I<f.length){var A=I++;return{value:x(A,f[A]),done:!1}}return C=!0,{done:!0,value:void 0}}};return k[Symbol.iterator]=function(){return k},k}a("Array.prototype.keys",function(f){return f||function(){return K(this,function(x){return x})}}),a("Array.prototype.fill",function(f){return f||function(x,I,C){var k=this.length||0;for(0>I&&(I=Math.max(0,k+I)),(C==null||C>k)&&(C=k),C=Number(C),0>C&&(C=Math.max(0,k+C)),I=Number(I||0);I<C;I++)this[I]=x;return this}});function J(f){return f||Array.prototype.fill}a("Int8Array.prototype.fill",J),a("Uint8Array.prototype.fill",J),a("Uint8ClampedArray.prototype.fill",J),a("Int16Array.prototype.fill",J),a("Uint16Array.prototype.fill",J),a("Int32Array.prototype.fill",J),a("Uint32Array.prototype.fill",J),a("Float32Array.prototype.fill",J),a("Float64Array.prototype.fill",J),a("Object.is",function(f){return f||function(x,I){return x===I?x!==0||
171631/x===1/I:x!==x&&I!==I}}),a("Array.prototype.includes",function(f){return f||function(x,I){var C=this;C instanceof String&&(C=String(C));var k=C.length;for(I=I||0,0>I&&(I=Math.max(I+k,0));I<k;I++){var A=C[I];if(A===x||Object.is(A,x))return!0}return!1}}),a("String.prototype.includes",function(f){return f||function(x,I){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(x instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(x,I||0)!==-1}});var ue=this||self;function se(f,x){f=f.split(".");var I=ue;f[0]in I||typeof I.execScript>"u"||I.execScript("var "+f[0]);for(var C;f.length&&(C=f.shift());)f.length||x===void 0?I[C]&&I[C]!==Object.prototype[C]?I=I[C]:I=I[C]={}:I[C]=x}function fe(f){var x;e:{if((x=ue.navigator)&&(x=x.userAgent))break e;x=""}return x.indexOf(f)!=-1}var Ie=Array.prototype.map?function(f,x){return Array.prototype.map.call(f,x,void 0)}:function(f,x){for(var I=f.length,C=Array(I),k=typeof f=="string"?f.split(""):f,A=0;A<I;A++)A in k&&(C[A]=x.call(void 0,k[A],A,f));return C},pe={},Fe=null;function Qe(f){var x=f.length,I=3*x/4;I%3?I=Math.floor(I):"=.".indexOf(f[x-1])!=-1&&(I="=.".indexOf(f[x-2])!=-1?I-2:I-1);var C=new Uint8Array(I),k=0;return it(f,function(A){C[k++]=A}),k!==I?C.subarray(0,k):C}function it(f,x){function I(z){for(;C<f.length;){var X=f.charAt(C++),ne=Fe[X];if(ne!=null)return ne;if(!/^[\s\xa0]*$/.test(X))throw Error("Unknown base64 encoding at char: "+X)}return z}Nt();for(var C=0;;){var k=I(-1),A=I(0),E=I(64),P=I(64);if(P===64&&k===-1)break;x(k<<2|A>>4),E!=64&&(x(A<<4&240|E>>2),P!=64&&x(E<<6&192|P))}}function Nt(){if(!Fe){Fe={};for(var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),x=["+/=","+/","-_=","-_.","-_"],I=0;5>I;I++){var C=f.concat(x[I].split(""));pe[I]=C;for(var k=0;k<C.length;k++){var A=C[k];Fe[A]===void 0&&(Fe[A]=k)}}}}var He=typeof Uint8Array<"u",An=!(fe("Trident")||fe("MSIE"))&&typeof ue.btoa=="function";function on(f){if(!An){var x;x===void 0&&(x=0),Nt(),x=pe[x];for(var I=Array(Math.floor(f.length/3)),C=x[64]||"",k=0,A=0;k<f.length-2;k+=3){var E=f[k],P=f[k+1],z=f[k+2],X=x[E>>2];E=x[(E&3)<<4|P>>4],P=x[(P&15)<<2|z>>6],z=x[z&63],I[A++]=X+E+P+z}switch(X=0,z=C,f.length-k){case 2:X=f[k+1],z=x[(X&15)<<2]||C;case 1:f=f[k],I[A]=x[f>>2]+x[(f&3)<<4|X>>4]+z+C}return I.join("")}for(x="";10240<f.length;)x+=String.fromCharCode.apply(null,f.subarray(0,10240)),f=f.subarray(10240);return x+=String.fromCharCode.apply(null,f),btoa(x)}var Dn=RegExp("[-_.]","g");function es(f){switch(f){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function Ze(f){if(!An)return Qe(f);Dn.test(f)&&(f=f.replace(Dn,es)),f=atob(f);for(var x=new Uint8Array(f.length),I=0;I<f.length;I++)x[I]=f.charCodeAt(I);return x}var On;function _r(){return On||(On=new Uint8Array(0))}var Yn={},ur=typeof Uint8Array.prototype.slice=="function",et=0,je=0;function Qn(f){var x=0>f;f=Math.abs(f);var I=f>>>0;f=Math.floor((f-I)/4294967296),x&&(I=i(Nr(I,f)),x=I.next().value,f=I.next().value,I=x),et=I>>>0,je=f>>>0}var ft=typeof BigInt=="function";function Nr(f,x){return x=~x,f?f=~f+1:x+=1,[f,x]}function ts(f,x){this.i=f>>>0,this.h=x>>>0}function ns(f){if(!f)return cr||(cr=new ts(0,0));if(!/^-?\d+$/.test(f))return null;if(16>f.length)Qn(Number(f));else if(ft)f=BigInt(f),et=Number(f&BigInt(4294967295))>>>0,je=Number(f>>BigInt(32)&BigInt(4294967295));else{var x=+(f[0]==="-");je=et=0;for(var I=f.length,C=x,k=(I-x)%6+x;k<=I;C=k,k+=6)C=Number(f.slice(C,k)),je*=1e6,et=1e6*et+C,4294967296<=et&&(je+=et/4294967296|0,et%=4294967296);x&&(x=i(Nr(et,je)),f=x.next().value,x=x.next().value,et=f,je=x)}return new ts(et,je)}var cr;function Tr(f,x){return Error("Invalid wire type: "+f+" (at position "+x+")")}function kr(){return Error("Failed to read varint, encoding is invalid.")}function rs(f,x){return Error("Tried to read past the end of the data "+x+" > "+f)}function Fn(){throw Error("Invalid UTF8")}function Hs(f,x){return x=String.fromCharCode.apply(null,x),f==null?x:f+x}var Er=void 0,un,lr=typeof TextDecoder<"u",js,Va=typeof TextEncoder<"u",Zn;
17163function qs(f){if(f!==Yn)throw Error("illegal external caller")}function Pn(f,x){if(qs(x),this.V=f,f!=null&&f.length===0)throw Error("ByteString should be constructed with non-empty values")}function Jn(){return Zn||(Zn=new Pn(null,Yn))}function mt(f){qs(Yn);var x=f.V;return x=x==null||He&&x!=null&&x instanceof Uint8Array?x:typeof x=="string"?Ze(x):null,x==null?x:f.V=x}function Ks(f){if(typeof f=="string")return{buffer:Ze(f),C:!1};if(Array.isArray(f))return{buffer:new Uint8Array(f),C:!1};if(f.constructor===Uint8Array)return{buffer:f,C:!1};if(f.constructor===ArrayBuffer)return{buffer:new Uint8Array(f),C:!1};if(f.constructor===Pn)return{buffer:mt(f)||_r(),C:!0};if(f instanceof Uint8Array)return{buffer:new Uint8Array(f.buffer,f.byteOffset,f.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function ss(f,x){this.i=null,this.m=!1,this.h=this.j=this.l=0,Rr(this,f,x)}function Rr(f,x,I){I=I===void 0?{}:I,f.S=I.S===void 0?!1:I.S,x&&(x=Ks(x),f.i=x.buffer,f.m=x.C,f.l=0,f.j=f.i.length,f.h=f.l)}ss.prototype.reset=function(){this.h=this.l};function mn(f,x){if(f.h=x,x>f.j)throw rs(f.j,x)}function Ut(f){var x=f.i,I=f.h,C=x[I++],k=C&127;if(C&128&&(C=x[I++],k|=(C&127)<<7,C&128&&(C=x[I++],k|=(C&127)<<14,C&128&&(C=x[I++],k|=(C&127)<<21,C&128&&(C=x[I++],k|=C<<28,C&128&&x[I++]&128&&x[I++]&128&&x[I++]&128&&x[I++]&128&&x[I++]&128)))))throw kr();return mn(f,I),k}function dr(f,x){if(0>x)throw Error("Tried to read a negative byte length: "+x);var I=f.h,C=I+x;if(C>f.j)throw rs(x,f.j-I);return f.h=C,I}var as=[];function Ln(){this.h=[]}Ln.prototype.length=function(){return this.h.length},Ln.prototype.end=function(){var f=this.h;return this.h=[],f};function er(f,x,I){for(;0<I||127<x;)f.h.push(x&127|128),x=(x>>>7|I<<25)>>>0,I>>>=7;f.h.push(x)}function gn(f,x){for(;127<x;)f.h.push(x&127|128),x>>>=7;f.h.push(x)}function j(f,x){if(as.length){var I=as.pop();Rr(I,f,x),f=I}else f=new ss(f,x);this.h=f,this.j=this.h.h,this.i=this.l=-1,this.setOptions(x)}j.prototype.setOptions=function(f){f=f===void 0?{}:f,this.ca=f.ca===void 0?!1:f.ca},j.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};function Y(f){var x=f.h;if(x.h==x.j)return!1;f.j=f.h.h;var I=Ut(f.h)>>>0;if(x=I>>>3,I&=7,!(0<=I&&5>=I))throw Tr(I,f.j);if(1>x)throw Error("Invalid field number: "+x+" (at position "+f.j+")");return f.l=x,f.i=I,!0}function de(f){switch(f.i){case 0:if(f.i!=0)de(f);else e:{f=f.h;for(var x=f.h,I=x+10,C=f.i;x<I;)if((C[x++]&128)===0){mn(f,x);break e}throw kr()}break;case 1:f=f.h,mn(f,f.h+8);break;case 2:f.i!=2?de(f):(x=Ut(f.h)>>>0,f=f.h,mn(f,f.h+x));break;case 5:f=f.h,mn(f,f.h+4);break;case 3:x=f.l;do{if(!Y(f))throw Error("Unmatched start-group tag: stream EOF");if(f.i==4){if(f.l!=x)throw Error("Unmatched end-group tag");break}de(f)}while(1);break;default:throw Tr(f.i,f.j)}}var ee=[];function Ve(){this.j=[],this.i=0,this.h=new Ln}function Pe(f,x){x.length!==0&&(f.j.push(x),f.i+=x.length)}function $e(f,x){if(x=x.R){Pe(f,f.h.end());for(var I=0;I<x.length;I++)Pe(f,mt(x[I])||_r())}}var ge=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol():void 0;function We(f,x){return ge?f[ge]|=x:f.A!==void 0?f.A|=x:(Object.defineProperties(f,{A:{value:x,configurable:!0,writable:!0,enumerable:!1}}),x)}function Ot(f,x){ge?f[ge]&&(f[ge]&=~x):f.A!==void 0&&(f.A&=~x)}function Me(f){var x;return ge?x=f[ge]:x=f.A,x==null?0:x}function zt(f,x){ge?f[ge]=x:f.A!==void 0?f.A=x:Object.defineProperties(f,{A:{value:x,configurable:!0,writable:!0,enumerable:!1}})}function pr(f){return We(f,1),f}function Xs(f,x){zt(x,(f|0)&-51)}function ct(f,x){zt(x,(f|18)&-41)}var yn={};function hr(f){return f!==null&&typeof f=="object"&&!Array.isArray(f)&&f.constructor===Object}var os,Ys=[];zt(Ys,23),os=Object.freeze(Ys);function Wa(f){if(Me(f.o)&2)throw Error("Cannot mutate an immutable Message")}function Ua(f){var x=f.length;(x=x?f[x-1]:void 0)&&hr(x)?x.g=1:(x={},f.push((x.g=1,x)))}function Vo(f){var x=f.i+f.G;return f.B||(f.B=f.o[x]={})}function Tt(f,x){return x===-1?null:x>=f.i?f.B?f.B[x]:void 0:f.o[x+f.G]}function bn(f,x,I,C){Wa(f),is(f,x,I,C)}function is(f,x,I,C){f.j&&(f.j=void 0),x>=f.i||C?Vo(f)[x]=I:(f.o[x+f.G]=I,(f=f.B)&&x in f&&delete f[x])}function Qs(f,x,I,C){var k=Tt(f,x);Array.isArray(k)||(k=os);var A=Me(k);if(A&1||pr(k),C)A&2||We(k,2),I&1||Object.freeze(k);else{C=!(I&2);var E=A&2;I&1||!E?C&&A&16&&!E&&Ot(k,16):(k=pr(Array.prototype.slice.call(k)),is(f,x,k))}return k}function za(f,x){var I=Tt(f,x),C=I==null?I:typeof I=="number"||I==="NaN"||I==="Infinity"||I==="-Infinity"?Number(I):void 0;return C!=null&&C!==I&&is(f,x,C),C}function Zs(f,x,I,C,k){f.h||(f.h={});var A=f.h[I],E=Qs(f,I,3,k);if(!A){var P=E;A=[];var z=!!(Me(f.o)&16);E=!!(Me(P)&2);var X=P;!k&&E&&(P=Array.prototype.slice.call(P));for(var ne=E,xe=0;xe<P.length;xe++){var he=P[xe],ie=x,we=!1;if(we=we===void 0?!1:we,he=Array.isArray(he)?new ie(he):we?new ie:void 0,he!==void 0){ie=he.o;var _e=we=Me(ie);
17163E&&(_e|=2),z&&(_e|=16),_e!=we&&zt(ie,_e),ie=_e,ne=ne||!!(2&ie),A.push(he)}}return f.h[I]=A,z=Me(P),x=z|33,x=ne?x&-9:x|8,z!=x&&(ne=P,Object.isFrozen(ne)&&(ne=Array.prototype.slice.call(ne)),zt(ne,x),P=ne),X!==P&&is(f,I,P),(k||C&&E)&&We(A,2),C&&Object.freeze(A),A}return k||(k=Object.isFrozen(A),C&&!k?Object.freeze(A):!C&&k&&(A=Array.prototype.slice.call(A),f.h[I]=A)),A}function Js(f,x,I){var C=!!(Me(f.o)&2);if(x=Zs(f,x,I,C,C),f=Qs(f,I,3,C),!(C||Me(f)&8)){for(C=0;C<x.length;C++){if(I=x[C],Me(I.o)&2){var k=ja(I,!1);k.j=I}else k=I;I!==k&&(x[C]=k,f[C]=k.o)}We(f,8)}return x}function xn(f,x,I){if(I!=null&&typeof I!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+typeof I+": "+I);bn(f,x,I)}function Wo(f,x,I,C,k){Wa(f);var A=Zs(f,I,x,!1,!1);return I=C!=null?C:new I,f=Qs(f,x,2,!1),k!=null?(A.splice(k,0,I),f.splice(k,0,I.o)):(A.push(I),f.push(I.o)),I.C()&&Ot(f,8),I}function Mn(f,x){return f==null?x:f}function Qt(f,x,I){return I=I===void 0?0:I,Mn(za(f,x),I)}var ea;function ac(f){switch(typeof f){case"number":return isFinite(f)?f:String(f);case"object":if(f)if(Array.isArray(f)){if((Me(f)&128)!==0)return f=Array.prototype.slice.call(f),Ua(f),f}else{if(He&&f!=null&&f instanceof Uint8Array)return on(f);if(f instanceof Pn){var x=f.V;return x==null?"":typeof x=="string"?x:f.V=on(x)}}}return f}function Uo(f,x,I,C){if(f!=null){if(Array.isArray(f))f=Ga(f,x,I,C!==void 0);else if(hr(f)){var k={},A;for(A in f)k[A]=Uo(f[A],x,I,C);f=k}else f=x(f,C);return f}}function Ga(f,x,I,C){var k=Me(f);C=C?!!(k&16):void 0,f=Array.prototype.slice.call(f);for(var A=0;A<f.length;A++)f[A]=Uo(f[A],x,I,C);return I(k,f),f}function zo(f){return f.ja===yn?f.toJSON():ac(f)}function Go(f,x){f&128&&Ua(x)}function Ho(f,x,I){if(I=I===void 0?ct:I,f!=null){if(He&&f instanceof Uint8Array)return f.length?new Pn(new Uint8Array(f),Yn):Jn();if(Array.isArray(f)){var C=Me(f);return C&2?f:x&&!(C&32)&&(C&16||C===0)?(zt(f,C|2),f):(f=Ga(f,Ho,C&4?ct:I,!0),x=Me(f),x&4&&x&2&&Object.freeze(f),f)}return f.ja===yn?Ha(f):f}}function jo(f,x,I,C,k,A,E){if(f=f.h&&f.h[I]){if(C=Me(f),C&2?C=f:(A=Ie(f,Ha),ct(C,A),Object.freeze(A),C=A),Wa(x),E=C==null?os:pr([]),C!=null){for(A=!!C.length,f=0;f<C.length;f++){var P=C[f];A=A&&!(Me(P.o)&2),E[f]=P.o}A=(A?8:0)|1,f=Me(E),(f&A)!==A&&(Object.isFrozen(E)&&(E=Array.prototype.slice.call(E)),zt(E,f|A)),x.h||(x.h={}),x.h[I]=C}else x.h&&(x.h[I]=void 0);is(x,I,E,k)}else bn(x,I,Ho(C,A,E),k)}function Ha(f){return Me(f.o)&2||(f=ja(f,!0),We(f.o,2)),f}function ja(f,x){var I=f.o,C=[];We(C,16);var k=f.constructor.h;if(k&&C.push(k),k=f.B,k){C.length=I.length,C.fill(void 0,C.length,I.length);var A={};C[C.length-1]=A}(Me(I)&128)!==0&&Ua(C),x=x||f.C()?ct:Xs,A=f.constructor,ea=C,C=new A(C),ea=void 0,f.R&&(C.R=f.R.slice()),A=!!(Me(I)&16);for(var E=k?I.length-1:I.length,P=0;P<E;P++)jo(f,C,P-f.G,I[P],!1,A,x);if(k)for(var z in k)jo(f,C,+z,k[z],!0,A,x);return C}function Ft(f,x,I){f==null&&(f=ea),ea=void 0;var C=this.constructor.i||0,k=0<C,A=this.constructor.h,E=!1;if(f==null){f=A?[A]:[];var P=48,z=!0;k&&(C=0,P|=128),zt(f,P)}else{if(!Array.isArray(f)||A&&A!==f[0])throw Error();var X=P=We(f,0);if((z=(16&X)!==0)&&((E=(32&X)!==0)||(X|=32)),k){if(128&X)C=0;else if(0<f.length){var ne=f[f.length-1];if(hr(ne)&&"g"in ne){C=0,X|=128,delete ne.g;var xe=!0,he;for(he in ne){xe=!1;break}xe&&f.pop()}}}else if(128&X)throw Error();P!==X&&zt(f,X)}this.G=(A?0:-1)-C,this.h=void 0,this.o=f;e:{if(A=this.o.length,C=A-1,A&&(A=this.o[C],hr(A))){this.B=A,this.i=C-this.G;break e}x!==void 0&&-1<x?(this.i=Math.max(x,C+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE}if(!k&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(I){x=z&&!E&&!0,k=this.i;var ie;for(z=0;z<I.length;z++)E=I[z],E<k?(E+=this.G,(C=f[E])?qo(C,x):f[E]=os):(ie||(ie=Vo(this)),(C=ie[E])?qo(C,x):ie[E]=os)}}Ft.prototype.toJSON=function(){return Ga(this.o,zo,Go)},Ft.prototype.C=function(){return!!(Me(this.o)&2)};function qo(f,x){if(Array.isArray(f)){var I=Me(f),C=1;!x||I&2||(C|=16),(I&C)!==C&&zt(f,I|C)}}Ft.prototype.ja=yn,Ft.prototype.toString=function(){return this.o.toString()};function Ko(f,x,I){if(I){var C={},k;for(k in I){var A=I[k],E=A.qa;E||(C.J=A.wa||A.oa.W,A.ia?(C.aa=Xa(A.ia),E=function(P){return function(z,X,ne){return P.J(z,X,ne,P.aa)}}(C)):A.ka?(C.Z=ra(A.da.P,A.ka),E=function(P){return function(z,X,ne){return P.J(z,X,ne,P.Z)}}(C)):E=C.J,A.qa=E),E(x,f,A.da),C={J:C.J,aa:C.aa,Z:C.Z}}}$e(x,f)}var ta=Symbol();function qa(f,x,I){return f[ta]||(f[ta]=function(C,k){return x(C,k,I)})}function us(f){var x=f[ta];if(!x){var I=be(f);x=function(C,k){return ve(C,k,I)},f[ta]=x}return x}function Xo(f){var x=f.ia;if(x)return us(x);if(x=f.va)return qa(f.da.P,x,f.ka)}function Yo(f){var x=Xo(f),I=f.da,C=f.oa.U;return x?function(k,A){return C(k,A,I,x)}:function(k,A){return C(k,A,I)}}function Ka(f,x){var I=f[x];return typeof I=="function"&&I.length===0&&(I=I(),f[x]=I),Array.isArray(I)&&(ls in I||tr in I||0<I.length&&typeof I[0]=="function")?I:void 0}function na(f,x,I,C,k,A){x.P=f[0];var E=1;if(f.length>E&&typeof f[E]!="number"){var P=f[E++];I(x,P)}for(;E<f.length;){I=f[E++];for(var z=E+1;z<f.length&&typeof f[z]!="number";)z++;switch(P=f[E++],z-=E,z){case 0:C(x,I,P);break;case 1:(z=Ka(f,E))?(E++,k(x,I,P,z)):C(x,I,P,f[E++]);break;case 2:z=E++,z=Ka(f,z),k(x,I,P,z,f[E++]);break;case 3:A(x,I,P,f[E++],f[E++],f[E++]);break;case 4:A(x,I,P,f[E++],f[E++],f[E++],f[E++]);break;default:throw Error("unexpected number of binary field arguments: "+z)}}return x}var cs=Symbol();function Xa(f){var x=f[cs];if(!x){var I=Ar(f);x=function(C,k){return ae(C,k,I)},f[cs]=x}return x}function ra(f,x){var I=f[cs];return I||(I=function(C,k){return Ko(C,k,x)},f[cs]=I),I}var tr=Symbol();function sa(f,x){f.push(x)}function aa(f,x,I){f.push(x,I.W)}function Qo(f,x,I,C){var k=Xa(C),A=Ar(C).P,E=I.W;f.push(x,function(P,z,X){return E(P,z,X,A,k)})}function oa(f,x,I,C,k,A){var E=ra(C,A),P=I.W;f.push(x,function(z,X,ne){return P(z,X,ne,C,E)})}function Ar(f){var x=f[tr];return x||(x=na(f,f[tr]=[],sa,aa,Qo,oa),ls in f&&tr in f&&(f.length=0),x)}var ls=Symbol();function R(f,x){f[0]=x}function B(f,x,I,C){var k=I.U;f[x]=C?function(A,E,P){return k(A,E,P,C)}:k}function Q(f,x,I,C,k){var A=I.U,E=us(C),P=be(C).P;f[x]=function(z,X,ne){return A(z,X,ne,P,E,k)}}function ye(f,x,I,C,k,A,E){var P=I.U,z=qa(C,k,A);f[x]=function(X,ne,xe){return P(X,ne,xe,C,z,E)}}function be(f){var x=f[ls];return x||(x=na(f,f[ls]={},R,B,Q,ye),ls in f&&tr in f&&(f.length=0),x)}function ve(f,x,I){for(;Y(x)&&x.i!=4;){var C=x.l,k=I[C];if(!k){var A=I[0];A&&(A=A[C])&&(k=I[C]=Yo(A))}if(!k||!k(x,f,C)){k=x,C=f,A=k.j,de(k);var E=k;if(!E.ca){if(k=E.h.h-A,E.h.h=A,E=E.h,k==0)k=Jn();else{if(A=dr(E,k),E.S&&E.m)k=E.i.subarray(A,A+k);else{E=E.i;var P=A;k=A+k,k=P===k?_r():ur?E.slice(P,k):new Uint8Array(E.subarray(P,k))}k=k.length==0?Jn():new Pn(k,Yn)}(A=C.R)?A.push(k):C.R=[k]}}}return f}function ae(f,x,I){for(var C=I.length,k=C%2==1,A=k?1:0;A<C;A+=2)(0,I[A+1])(x,f,I[A]);Ko(f,x,k?I[0]:void 0)}function ce(f,x){return{U:f,W:x}}var Ee=ce(function(f,x,I){if(f.i!==5)return!1;f=f.h;
17163var C=f.i,k=f.h,A=C[k],E=C[k+1],P=C[k+2];return C=C[k+3],mn(f,f.h+4),E=(A<<0|E<<8|P<<16|C<<24)>>>0,f=2*(E>>31)+1,A=E>>>23&255,E&=8388607,bn(x,I,A==255?E?NaN:1/0*f:A==0?f*Math.pow(2,-149)*E:f*Math.pow(2,A-150)*(E+Math.pow(2,23))),!0},function(f,x,I){if(x=za(x,I),x!=null){gn(f.h,8*I+5),f=f.h;var C=+x;C===0?0<1/C?et=je=0:(je=0,et=2147483648):isNaN(C)?(je=0,et=2147483647):(C=(I=0>C?-2147483648:0)?-C:C,34028234663852886e22<C?(je=0,et=(I|2139095040)>>>0):11754943508222875e-54>C?(C=Math.round(C/Math.pow(2,-149)),je=0,et=(I|C)>>>0):(x=Math.floor(Math.log(C)/Math.LN2),C*=Math.pow(2,-x),C=Math.round(8388608*C),16777216<=C&&++x,je=0,et=(I|x+127<<23|C&8388607)>>>0)),I=et,f.h.push(I>>>0&255),f.h.push(I>>>8&255),f.h.push(I>>>16&255),f.h.push(I>>>24&255)}}),Gt=ce(function(f,x,I){if(f.i!==0)return!1;var C=f.h,k=0,A=f=0,E=C.i,P=C.h;do{var z=E[P++];k|=(z&127)<<A,A+=7}while(32>A&&z&128);for(32<A&&(f|=(z&127)>>4),A=3;32>A&&z&128;A+=7)z=E[P++],f|=(z&127)<<A;if(mn(C,P),128>z)C=k>>>0,z=f>>>0,(f=z&2147483648)&&(C=~C+1>>>0,z=~z>>>0,C==0&&(z=z+1>>>0)),C=4294967296*z+(C>>>0);else throw kr();return bn(x,I,f?-C:C),!0},function(f,x,I){x=Tt(x,I),x!=null&&(typeof x=="string"&&ns(x),x!=null&&(gn(f.h,8*I),typeof x=="number"?(f=f.h,Qn(x),er(f,et,je)):(I=ns(x),er(f.h,I.i,I.h))))}),Bn=ce(function(f,x,I){return f.i!==0?!1:(bn(x,I,Ut(f.h)),!0)},function(f,x,I){if(x=Tt(x,I),x!=null&&x!=null)if(gn(f.h,8*I),f=f.h,I=x,0<=I)gn(f,I);else{for(x=0;9>x;x++)f.h.push(I&127|128),I>>=7;f.h.push(1)}}),Ya=ce(function(f,x,I){if(f.i!==2)return!1;var C=Ut(f.h)>>>0;f=f.h;var k=dr(f,C);if(f=f.i,lr){var A=f,E;(E=un)||(E=un=new TextDecoder("utf-8",{fatal:!0})),f=k+C,A=k===0&&f===A.length?A:A.subarray(k,f);try{var P=E.decode(A)}catch(xe){if(Er===void 0){try{E.decode(new Uint8Array([128]))}catch{}try{E.decode(new Uint8Array([97])),Er=!0}catch{Er=!1}}throw!Er&&(un=void 0),xe}}else{P=k,C=P+C,k=[];for(var z=null,X,ne;P<C;)X=f[P++],128>X?k.push(X):224>X?P>=C?Fn():(ne=f[P++],194>X||(ne&192)!==128?(P--,Fn()):k.push((X&31)<<6|ne&63)):240>X?P>=C-1?Fn():(ne=f[P++],(ne&192)!==128||X===224&&160>ne||X===237&&160<=ne||((A=f[P++])&192)!==128?(P--,Fn()):k.push((X&15)<<12|(ne&63)<<6|A&63)):244>=X?P>=C-2?Fn():(ne=f[P++],(ne&192)!==128||(X<<28)+(ne-144)>>30!==0||((A=f[P++])&192)!==128||((E=f[P++])&192)!==128?(P--,Fn()):(X=(X&7)<<18|(ne&63)<<12|(A&63)<<6|E&63,X-=65536,k.push((X>>10&1023)+55296,(X&1023)+56320))):Fn(),8192<=k.length&&(z=Hs(z,k),k.length=0);P=Hs(z,k)}return bn(x,I,P),!0},function(f,x,I){if(x=Tt(x,I),x!=null){var C=!1;if(C=C===void 0?!1:C,Va){if(C&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(x))throw Error("Found an unpaired surrogate");x=(js||(js=new TextEncoder)).encode(x)}else{for(var k=0,A=new Uint8Array(3*x.length),E=0;E<x.length;E++){var P=x.charCodeAt(E);if(128>P)A[k++]=P;else{if(2048>P)A[k++]=P>>6|192;else{if(55296<=P&&57343>=P){if(56319>=P&&E<x.length){var z=x.charCodeAt(++E);if(56320<=z&&57343>=z){P=1024*(P-55296)+z-56320+65536,A[k++]=P>>18|240,A[k++]=P>>12&63|128,A[k++]=P>>6&63|128,A[k++]=P&63|128;continue}else E--}if(C)throw Error("Found an unpaired surrogate");P=65533}A[k++]=P>>12|224,A[k++]=P>>6&63|128}A[k++]=P&63|128}}x=k===A.length?A:A.subarray(0,k)}gn(f.h,8*I+2),gn(f.h,x.length),Pe(f,f.h.end()),Pe(f,x)}}),ia=ce(function(f,x,I,C,k){if(f.i!==2)return!1;x=Wo(x,I,C),I=f.h.j,C=Ut(f.h)>>>0;var A=f.h.h+C,E=A-I;if(0>=E&&(f.h.j=A,k(x,f,void 0,void 0,void 0),E=A-f.h.h),E)throw Error("Message parsing ended unexpectedly. Expected to read "+(C+" bytes, instead read "+(C-E)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return f.h.h=A,f.h.j=I,!0},function(f,x,I,C,k){if(x=Js(x,C,I),x!=null)for(C=0;C<x.length;C++){var A=f;gn(A.h,8*I+2);var E=A.h.end();Pe(A,E),E.push(A.i),A=E,k(x[C],f),E=f;var P=A.pop();for(P=E.i+E.h.length()-P;127<P;)A.push(P&127|128),P>>>=7,E.i++;A.push(P),E.i++}});function Qa(f){return function(x,I){e:{if(ee.length){var C=ee.pop();C.setOptions(I),Rr(C.h,x,I),x=C}else x=new j(x,I);try{var k=be(f),A=ve(new k.P,x,k);break e}finally{k=x.h,k.i=null,k.m=!1,k.l=0,k.j=0,k.h=0,k.S=!1,x.l=-1,x.i=-1,100>ee.length&&ee.push(x)}A=void 0}return A}}function bt(f){return function(){var x=new Ve;ae(this,x,Ar(f)),Pe(x,x.h.end());
vendor: 7,037 bytes, lines 17163-17180
17163for(var I=new Uint8Array(x.i),C=x.j,k=C.length,A=0,E=0;E<k;E++){var P=C[E];I.set(P,A),A+=P.length}return x.j=[I],I}}function cn(f){Ft.call(this,f)}y(cn,Ft);var Za=[cn,1,Bn,2,Ee,3,Ya,4,Ya];cn.prototype.l=bt(Za);function oc(f){Ft.call(this,f,-1,c0)}y(oc,Ft),oc.prototype.addClassification=function(f,x){return Wo(this,1,cn,f,x),this};var c0=[1],ch=Qa([oc,1,ia,Za]);function ua(f){Ft.call(this,f)}y(ua,Ft);var lh=[ua,1,Ee,2,Ee,3,Ee,4,Ee,5,Ee];ua.prototype.l=bt(lh);function dh(f){Ft.call(this,f,-1,l0)}y(dh,Ft);var l0=[1],ph=Qa([dh,1,ia,lh]);function Zo(f){Ft.call(this,f)}y(Zo,Ft);var hh=[Zo,1,Ee,2,Ee,3,Ee,4,Ee,5,Ee,6,Gt],d0=Qa(hh);Zo.prototype.l=bt(hh);function fh(f,x,I){if(I=f.createShader(I===0?f.VERTEX_SHADER:f.FRAGMENT_SHADER),f.shaderSource(I,x),f.compileShader(I),!f.getShaderParameter(I,f.COMPILE_STATUS))throw Error(`Could not compile WebGL shader. 17164 17165`+f.getShaderInfoLog(I));return I}function mh(f){return Js(f,cn,1).map(function(x){var I=Tt(x,1);return{index:I==null?0:I,score:Qt(x,2),label:Tt(x,3)!=null?Mn(Tt(x,3),""):void 0,displayName:Tt(x,4)!=null?Mn(Tt(x,4),""):void 0}})}function gh(f){return{x:Qt(f,1),y:Qt(f,2),z:Qt(f,3),visibility:za(f,4)!=null?Qt(f,4):void 0}}function yh(f){return f.map(function(x){return Js(ph(x),ua,1).map(gh)})}function ic(f,x){this.i=f,this.h=x,this.m=0}function bh(f,x,I){return p0(f,x),typeof f.h.canvas.transferToImageBitmap=="function"?Promise.resolve(f.h.canvas.transferToImageBitmap()):I?Promise.resolve(f.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(f.h.canvas):(f.j===void 0&&(f.j=document.createElement("canvas")),new Promise(function(C){f.j.height=f.h.canvas.height,f.j.width=f.h.canvas.width,f.j.getContext("2d",{}).drawImage(f.h.canvas,0,0,f.h.canvas.width,f.h.canvas.height),C(f.j)}))}function p0(f,x){var I=f.h;if(f.s===void 0){var C=fh(I,` 17166 attribute vec2 aVertex; 17167 attribute vec2 aTex; 17168 varying vec2 vTex; 17169 void main(void) { 17170 gl_Position = vec4(aVertex, 0.0, 1.0); 17171 vTex = aTex; 17172 }`,0),k=fh(I,` 17173 precision mediump float; 17174 varying vec2 vTex; 17175 uniform sampler2D sampler0; 17176 void main(){ 17177 gl_FragColor = texture2D(sampler0, vTex); 17178 }`,1),A=I.createProgram();if(I.attachShader(A,C),I.attachShader(A,k),I.linkProgram(A),!I.getProgramParameter(A,I.LINK_STATUS))throw Error(`Could not compile WebGL program. 17179 17180`+I.getProgramInfoLog(A));C=f.s=A,I.useProgram(C),k=I.getUniformLocation(C,"sampler0"),f.l={O:I.getAttribLocation(C,"aVertex"),N:I.getAttribLocation(C,"aTex"),xa:k},f.v=I.createBuffer(),I.bindBuffer(I.ARRAY_BUFFER,f.v),I.enableVertexAttribArray(f.l.O),I.vertexAttribPointer(f.l.O,2,I.FLOAT,!1,0,0),I.bufferData(I.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),I.STATIC_DRAW),I.bindBuffer(I.ARRAY_BUFFER,null),f.u=I.createBuffer(),I.bindBuffer(I.ARRAY_BUFFER,f.u),I.enableVertexAttribArray(f.l.N),I.vertexAttribPointer(f.l.N,2,I.FLOAT,!1,0,0),I.bufferData(I.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),I.STATIC_DRAW),I.bindBuffer(I.ARRAY_BUFFER,null),I.uniform1i(k,0)}C=f.l,I.useProgram(f.s),I.canvas.width=x.width,I.canvas.height=x.height,I.viewport(0,0,x.width,x.height),I.activeTexture(I.TEXTURE0),f.i.bindTexture2d(x.glName),I.enableVertexAttribArray(C.O),I.bindBuffer(I.ARRAY_BUFFER,f.v),I.vertexAttribPointer(C.O,2,I.FLOAT,!1,0,0),I.enableVertexAttribArray(C.N),I.bindBuffer(I.ARRAY_BUFFER,f.u),I.vertexAttribPointer(C.N,2,I.FLOAT,!1,0,0),I.bindFramebuffer(I.DRAW_FRAMEBUFFER?I.DRAW_FRAMEBUFFER:I.FRAMEBUFFER,null),I.clearColor(0,0,0,0),I.clear(I.COLOR_BUFFER_BIT),I.colorMask(!0,!0,!0,!0),I.drawArrays(I.TRIANGLE_FAN,0,4),I.disableVertexAttribArray(C.O),I.disableVertexAttribArray(C.N),I.bindBuffer(I.ARRAY_BUFFER,null),f.i.bindTexture2d(0)}function h0(f){this.h=f}var f0=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 m0(f,x){return x+f}function xh(f,x){window[f]=x}function g0(f){var x=document.createElement("script");return x.setAttribute("src",f),x.setAttribute("crossorigin","anonymous"),new Promise(function(I){x.addEventListener("load",function(){I()},!1),x.addEventListener("error",function(){I()},!1),document.body.appendChild(x)})}function y0(){return G(function(f){switch(f.h){case 1:return f.s=2,S(f,WebAssembly.instantiate(f0),4);case 4:f.h=3,f.s=0;break;case 2:return f.s=0,f.l=null,f.return(!1);case 3:return f.return(!0)}})}function uc(f){if(this.h=f,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=f&&f.locateFile||m0,typeof window=="object")var x=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")x=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.ha=x,f.options){x=i(Object.keys(f.options));for(var I=x.next();!I.done;I=x.next()){I=I.value;var C=f.options[I].default;C!==void 0&&(this.l[I]=typeof C=="function"?C():C)}}}n=uc.prototype,n.close=function(){return this.j&&this.j.delete(),Promise.resolve()};function b0(f){var x,I,C,k,A,E,P,z,X,ne,xe;return G(function(he){switch(he.h){case 1:return f.ga?(x=f.h.files===void 0?[]:typeof f.h.files=="function"?f.h.files(f.l):f.h.files,S(he,y0(),2)):he.return();case 2:if(I=he.i,typeof window=="object")return xh("createMediapipeSolutionsWasm",{locateFile:f.locateFile}),xh("createMediapipeSolutionsPackedAssets",{locateFile:f.locateFile}),E=x.filter(function(ie){return ie.data!==void 0}),P=x.filter(function(ie){return ie.data===void 0}),z=Promise.all(E.map(function(ie){var we=Jo(f,ie.url);if(ie.path!==void 0){var _e=ie.path;we=we.then(function(Je){return f.overrideFile(_e,Je),Promise.resolve(Je)})}return we})),X=Promise.all(P.map(function(ie){return ie.simd===void 0||ie.simd&&I||!ie.simd&&!I?g0(f.locateFile(ie.url,f.ha)):Promise.resolve()})).then(function(){var ie,we,_e;return G(function(Je){if(Je.h==1)return ie=window.createMediapipeSolutionsWasm,we=window.createMediapipeSolutionsPackedAssets,_e=f,S(Je,ie(we),2);_e.i=Je.i,Je.h=0})}),ne=function(){return G(function(ie){return f.h.graph&&f.h.graph.url?ie=S(ie,Jo(f,f.h.graph.url),0):(ie.h=0,ie=void 0),ie})}(),S(he,Promise.all([X,z,ne]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return C=x.filter(function(ie){return ie.simd===void 0||ie.simd&&I||!ie.simd&&!I}).map(function(ie){return f.locateFile(ie.url,f.ha)}),importScripts.apply(null,c(C)),k=f,S(he,createMediapipeSolutionsWasm(Module),6);case 6:k.i=he.i,f.m=new OffscreenCanvas(1,1),f.i.canvas=f.m,A=f.i.GL.createContext(f.m,{antialias:!1,alpha:!1,ua:typeof WebGL2RenderingContext<"u"?2:1}),f.i.GL.makeContextCurrent(A),he.h=4;break;case 7:if(f.m=document.createElement("canvas"),xe=f.m.getContext("webgl2",{}),!xe&&(xe=f.m.getContext("webgl",{}),!xe))return alert("Failed to create WebGL canvas context when passing video frame."),he.return();f.K=xe,f.i.canvas=f.m,f.i.createContext(f.m,!0,!0,{});
17180case 4:f.j=new f.i.SolutionWasm,f.ga=!1,he.h=0}})}function x0(f){var x,I,C,k,A,E,P,z;return G(function(X){if(X.h==1){if(f.h.graph&&f.h.graph.url&&f.fa===f.h.graph.url)return X.return();if(f.u=!0,!f.h.graph||!f.h.graph.url){X.h=2;return}return f.fa=f.h.graph.url,S(X,Jo(f,f.h.graph.url),3)}for(X.h!=2&&(x=X.i,f.j.loadGraph(x)),I=i(Object.keys(f.D)),C=I.next();!C.done;C=I.next())k=C.value,f.j.overrideFile(k,f.D[k]);if(f.D={},f.h.listeners)for(A=i(f.h.listeners),E=A.next();!E.done;E=A.next())P=E.value,$0(f,P);z=f.l,f.l={},f.setOptions(z),X.h=0})}n.reset=function(){var f=this;return G(function(x){f.j&&(f.j.reset(),f.s={},f.v={}),x.h=0})},n.setOptions=function(f,x){var I=this;if(x=x||this.h.options){for(var C=[],k=[],A={},E=i(Object.keys(f)),P=E.next();!P.done;A={X:A.X,Y:A.Y},P=E.next())if(P=P.value,!(P in this.l&&this.l[P]===f[P])){this.l[P]=f[P];var z=x[P];z!==void 0&&(z.onChange&&(A.X=z.onChange,A.Y=f[P],C.push(function(X){return function(){var ne;return G(function(xe){if(xe.h==1)return S(xe,X.X(X.Y),2);ne=xe.i,ne===!0&&(I.u=!0),xe.h=0})}}(A))),z.graphOptionXref&&(P=Object.assign({},{calculatorName:"",calculatorIndex:0},z.graphOptionXref,{valueNumber:z.type===1?f[P]:0,valueBoolean:z.type===0?f[P]:!1,valueString:z.type===2?f[P]:""}),k.push(P)))}(C.length!==0||k.length!==0)&&(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(k),this.F=(this.F===void 0?[]:this.F).concat(C))}};function w0(f){var x,I,C,k,A,E,P;return G(function(z){switch(z.h){case 1:if(!f.u)return z.return();if(!f.F){z.h=2;break}x=i(f.F),I=x.next();case 3:if(I.done){z.h=5;break}return C=I.value,S(z,C(),4);case 4:I=x.next(),z.h=3;break;case 5:f.F=void 0;case 2:if(f.H){for(k=new f.i.GraphOptionChangeRequestList,A=i(f.H),E=A.next();!E.done;E=A.next())P=E.value,k.push_back(P);f.j.changeOptions(k),k.delete(),f.H=void 0}f.u=!1,z.h=0}})}n.initialize=function(){var f=this;return G(function(x){return x.h==1?S(x,b0(f),2):x.h!=3?S(x,x0(f),3):S(x,w0(f),0)})};function Jo(f,x){var I,C;return G(function(k){return x in f.L?k.return(f.L[x]):(I=f.locateFile(x,""),C=fetch(I).then(function(A){return A.arrayBuffer()}),f.L[x]=C,k.return(C))})}n.overrideFile=function(f,x){this.j?this.j.overrideFile(f,x):this.D[f]=x},n.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},n.send=function(f,x){var I=this,C,k,A,E,P,z,X,ne,xe;return G(function(he){switch(he.h){case 1:return I.h.inputs?(C=1e3*(x==null?performance.now():x),S(he,I.I,2)):he.return();case 2:return S(he,I.initialize(),3);case 3:for(k=new I.i.PacketDataList,A=i(Object.keys(f)),E=A.next();!E.done;E=A.next())if(P=E.value,z=I.h.inputs[P]){e:{var ie=f[P];switch(z.type){case"video":var we=I.s[z.stream];if(we||(we=new ic(I.i,I.K),I.s[z.stream]=we),we.m===0&&(we.m=we.i.createTexture()),typeof HTMLVideoElement<"u"&&ie instanceof HTMLVideoElement)var _e=ie.videoWidth,Je=ie.videoHeight;else typeof HTMLImageElement<"u"&&ie instanceof HTMLImageElement?(_e=ie.naturalWidth,Je=ie.naturalHeight):(_e=ie.width,Je=ie.height);Je={glName:we.m,width:_e,height:Je},_e=we.h,_e.canvas.width=Je.width,_e.canvas.height=Je.height,_e.activeTexture(_e.TEXTURE0),we.i.bindTexture2d(we.m),_e.texImage2D(_e.TEXTURE_2D,0,_e.RGBA,_e.RGBA,_e.UNSIGNED_BYTE,ie),we.i.bindTexture2d(0),we=Je;break e;case"detections":for(we=I.s[z.stream],we||(we=new h0(I.i),I.s[z.stream]=we),we.data||(we.data=new we.h.DetectionListData),we.data.reset(ie.length),Je=0;Je<ie.length;++Je){_e=ie[Je];var qe=we.data,kt=qe.setBoundingBox,wn=Je,Zt=_e.la,Le=new Zo;if(xn(Le,1,Zt.ra),xn(Le,2,Zt.sa),xn(Le,3,Zt.height),xn(Le,4,Zt.width),xn(Le,5,Zt.rotation),bn(Le,6,Zt.pa),Zt=Le.l(),kt.call(qe,wn,Zt),_e.ea)for(qe=0;qe<_e.ea.length;++qe){Le=_e.ea[qe],kt=we.data,wn=kt.addNormalizedLandmark,Zt=Je,Le=Object.assign({},Le,{visibility:Le.visibility?Le.visibility:0});var Et=new ua;xn(Et,1,Le.x),xn(Et,2,Le.y),xn(Et,3,Le.z),Le.visibility&&xn(Et,4,Le.visibility),Le=Et.l(),wn.call(kt,Zt,Le)}if(_e.ba)for(qe=0;qe<_e.ba.length;++qe)kt=we.data,wn=kt.addClassification,Zt=Je,Le=_e.ba[qe],Et=new cn,xn(Et,2,Le.score),Le.index&&bn(Et,1,Le.index),Le.label&&bn(Et,3,Le.label),Le.displayName&&bn(Et,4,Le.dis
17180playName),Le=Et.l(),wn.call(kt,Zt,Le)}we=we.data;break e;default:we={}}}switch(X=we,ne=z.stream,z.type){case"video":k.pushTexture2d(Object.assign({},X,{stream:ne,timestamp:C}));break;case"detections":xe=X,xe.stream=ne,xe.timestamp=C,k.pushDetectionList(xe);break;default:throw Error("Unknown input config type: '"+z.type+"'")}}return I.j.send(k),S(he,I.I,4);case 4:k.delete(),he.h=0}})};function v0(f,x,I){var C,k,A,E,P,z,X,ne,xe,he,ie,we,_e,Je;return G(function(qe){switch(qe.h){case 1:if(!I)return qe.return(x);for(C={},k=0,A=i(Object.keys(I)),E=A.next();!E.done;E=A.next())P=E.value,z=I[P],typeof z!="string"&&z.type==="texture"&&x[z.stream]!==void 0&&++k;1<k&&(f.M=!1),X=i(Object.keys(I)),E=X.next();case 2:if(E.done){qe.h=4;break}if(ne=E.value,xe=I[ne],typeof xe=="string")return _e=C,Je=ne,S(qe,I0(f,ne,x[xe]),14);if(he=x[xe.stream],xe.type==="detection_list"){if(he){for(var kt=he.getRectList(),wn=he.getLandmarksList(),Zt=he.getClassificationsList(),Le=[],Et=0;Et<kt.size();++Et){var Dr=d0(kt.get(Et)),S0=Qt(Dr,1),C0=Qt(Dr,2),_0=Qt(Dr,3),N0=Qt(Dr,4),T0=Qt(Dr,5,0),ei=void 0;ei=ei===void 0?0:ei,Dr={la:{ra:S0,sa:C0,height:_0,width:N0,rotation:T0,pa:Mn(Tt(Dr,6),ei)},ea:Js(ph(wn.get(Et)),ua,1).map(gh),ba:mh(ch(Zt.get(Et)))},Le.push(Dr)}kt=Le}else kt=[];C[ne]=kt,qe.h=7;break}if(xe.type==="proto_list"){if(he){for(kt=Array(he.size()),wn=0;wn<he.size();wn++)kt[wn]=he.get(wn);he.delete()}else kt=[];C[ne]=kt,qe.h=7;break}if(he===void 0){qe.h=3;break}if(xe.type==="float_list"){C[ne]=he,qe.h=7;break}if(xe.type==="proto"){C[ne]=he,qe.h=7;break}if(xe.type!=="texture")throw Error("Unknown output config type: '"+xe.type+"'");return ie=f.v[ne],ie||(ie=new ic(f.i,f.K),f.v[ne]=ie),S(qe,bh(ie,he,f.M),13);case 13:we=qe.i,C[ne]=we;case 7:xe.transform&&C[ne]&&(C[ne]=xe.transform(C[ne])),qe.h=3;break;case 14:_e[Je]=qe.i;case 3:E=X.next(),qe.h=2;break;case 4:return qe.return(C)}})}function I0(f,x,I){var C;return G(function(k){return typeof I=="number"||I instanceof Uint8Array||I instanceof f.i.Uint8BlobList?k.return(I):I instanceof f.i.Texture2dDataOut?(C=f.v[x],C||(C=new ic(f.i,f.K),f.v[x]=C),k.return(bh(C,I,f.M))):k.return(void 0)})}function $0(f,x){for(var I=x.name||"$",C=[].concat(c(x.wants)),k=new f.i.StringList,A=i(x.wants),E=A.next();!E.done;E=A.next())k.push_back(E.value);A=f.i.PacketListener.implement({onResults:function(P){for(var z={},X=0;X<x.wants.length;++X)z[C[X]]=P.get(X);var ne=f.listeners[I];ne&&(f.I=v0(f,z,x.outs).then(function(xe){xe=ne(xe);for(var he=0;he<x.wants.length;++he){var ie=z[C[he]];typeof ie=="object"&&ie.hasOwnProperty&&ie.hasOwnProperty("delete")&&ie.delete()}xe&&(f.I=xe)}))}}),f.j.attachMultiListener(k,A),k.delete()}n.onResults=function(f,x){this.listeners[x||"$"]=f},se("Solution",uc),se("OptionType",{BOOL:0,NUMBER:1,ta:2,0:"BOOL",1:"NUMBER",2:"STRING"});function wh(f){return f===void 0&&(f=0),f===1?"hand_landmark_full.tflite":"hand_landmark_lite.tflite"}function vh(f){var x=this;f=f||{},this.h=new uc({locateFile:f.locateFile,files:function(I){return[{url:"hands_solution_packed_assets_loader.js"},{simd:!1,url:"hands_solution_wasm_bin.js"},{simd:!0,url:"hands_solution_simd_wasm_bin.js"},{data:!0,url:wh(I.modelComplexity)}]},graph:{url:"hands.binarypb"},inputs:{image:{type:"video",stream:"input_frames_gpu"}},listeners:[{wants:["multi_hand_landmarks","multi_hand_world_landmarks","image_transformed","multi_handedness"],outs:{image:"image_transformed",multiHandLandmarks:{type:"proto_list",stream:"multi_hand_landmarks",transform:yh},multiHandWorldLandmarks:{type:"proto_list",stream:"multi_hand_world_landmarks",transform:yh},multiHandedness:{type:"proto_list",stream:"multi_handedness",transform:function(I){return I.map(function(C){return mh(ch(C))[0]})}}}}],options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:typeof window!="object"||window.navigator===void 0?!1:"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"}},maxNumHands:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculator",fieldName:"int_value"}},modelComplexity:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelComplexity",fieldName:"int_value"},onChange:function(I){var C,k,A;return G(function(E){return E.h==1?(C=wh(I),k="third_party/mediapipe/modules/hand_landmark/"+C,S(E,Jo(x.h,C),2)):(A=E.i,x.h.overrideFile(k,A),E.return(!0))})}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"handlandmarktrackinggpu__palmdetectiongpu__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"handlandmarktrackinggpu__handlandmarkgpu__ThresholdingCalculator",fieldName:"threshold"}}}})}n=vh.prototype,n.close=function(){return this.h.close(),Promise.resolve()},n.onResults=function(f){this.h.onResults(f)},n.initialize=function(){var f=this;return G(function(x){return S(x,f.h.initialize(),0)})},n.reset=function(){this.h.reset()},n.send=function(f){var x=this;return G(function(I){return S(I,x.h.send(f),0)})},n.setOptions=function(f){this.h.setOptions(f)},se("Hands",vh),se("HAND_CONNECTIONS",[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]]),se("VERSION","0.4.1675469240")}).call(Nn);/** 17181 * @license 17182 * Copyright 2021 Google LLC. All Rights Reserved. 17183 * Licensed under the Apache License, Version 2.0 (the "License");
17184 * you may not use this file except in compliance with the License. 17185 * You may obtain a copy of the License at 17186 * 17187 * http://www.apache.org/licenses/LICENSE-2.0 17188 * 17189 * Unless required by applicable law or agreed to in writing, software 17190 * distributed under the License is distributed on an "AS IS" BASIS, 17191 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17192 * See the License for the specific language governing permissions and 17193 * limitations under the License. 17194 * ============================================================================= 17195 */const nH=U();nH.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.")});/** 17196 * @license 17197 * Copyright 2019 Google LLC. All Rights Reserved. 17198 * Licensed under the Apache License, Version 2.0 (the "License"); 17199 * you may not use this file except in compliance with the License. 17200 * You may obtain a copy of the License at 17201 * 17202 * http://www.apache.org/licenses/LICENSE-2.0 17203 * 17204 * Unless required by applicable law or agreed to in writing, software 17205 * distributed under the License is distributed on an "AS IS" BASIS, 17206 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17207 * See the License for the specific language governing permissions and 17208 * limitations under the License. 17209 * 17210 * ============================================================================= 17211 */var en;(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=21]="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"})(en||(en={}));var _f;(function(n){(function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"})(n.CheckpointFormatVersion||(n.CheckpointFormatVersion={}))})(_f||(_f={}));/** 17212 * @license 17213 * Copyright 2019 Google LLC. All Rights Reserved. 17214 * Licensed under the Apache License, Version 2.0 (the "License"); 17215 * you may not use this file except in compliance with the License. 17216 * You may obtain a copy of the License at 17217 * 17218 * http://www.apache.org/licenses/LICENSE-2.0 17219 * 17220 * Unless required by applicable law or agreed to in writing, software 17221 * distributed under the License is distributed on an "AS IS" BASIS, 17222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17223 * See the License for the specific language governing permissions and 17224 * limitations under the License. 17225 * ============================================================================= 17226 */const rH={};function s0(n){return rH[n]}/** 17227 * @license 17228 * Copyright 2018 Google LLC. All Rights Reserved. 17229 * Licensed under the Apache License, Version 2.0 (the "License");
17230 * you may not use this file except in compliance with the License. 17231 * You may obtain a copy of the License at 17232 * 17233 * http://www.apache.org/licenses/LICENSE-2.0 17234 * 17235 * Unless required by applicable law or agreed to in writing, software 17236 * distributed under the License is distributed on an "AS IS" BASIS, 17237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17238 * See the License for the specific language governing permissions and 17239 * limitations under the License. 17240 * ============================================================================= 17241 */function w(n,e,t,r,s){const a=e.inputParams[n];if(a&&a.inputIndexStart!==void 0){const i=a.inputIndexStart,c=a.inputIndexEnd===0?void 0:a.inputIndexEnd===void 0?i+1:a.inputIndexEnd,l=i<0?e.inputNames.length+i:i;if(a.type==="tensor")return vt(e.inputNames[l],t,r,s);if(a.type==="tensors"){const p=e.inputs.slice(i,c);return e.inputNames.slice(i,c).filter((m,g)=>{var y;return((y=p[g])===null||y===void 0?void 0:y.op)!=="NoOp"}).map(m=>vt(m,t,r,s))}const u=vt(e.inputNames[l],t,r,s),d=u.dataSync();return a.type==="number"?d[0]:Ac(u.shape,d)}const o=e.attrParams[n];return o&&o.value}function vt(n,e,t,r){const[s,a]=tn(n,t);if(r!=null){const i=r.getHashTableHandleByName(s);if(i!=null)return i}const o=t.currentContextIds.find(i=>!!e[Ai(s,i)]);return o!==void 0?e[Ai(s,o)][a]:void 0}function Nf(n,e,t){return e[Ai(n,t.currentContextId)]}function mr(n,e){const[t,r,s]=tn(n,e);return[Ai(t,e&&e.currentContextId),r,s]}function Ai(n,e){return e?`${n}-${e}`:n}function tn(n,e){if(n==="")return["",0,void 0];const t=e!=null&&e.parseNodeNameCache!=null;if(t){const a=e.parseNodeNameCache.get(n);if(a!=null)return a}const r=n.split(":");let s;if(r.length===1)s=[n,0,void 0];else{const a=r[0],o=r.length===3?r[1]:void 0,i=Number(r[r.length-1]);s=[a,i,o]}return t&&e.parseNodeNameCache.set(n,s),s}function mi(n,e,t){let r=w("pad",n,e,t);if(r==="explicit"){r=w("explicitPaddings",n,e,t);const s=[[0,0],[0,0],[0,0],[0,0]];for(let a=0;a<4;a++)s[a][0]=r[a*2],s[a][1]=r[a*2+1];return s}return r}function gr(n){return n.kept?n:Br(n)}/** 17242 * @license 17243 * Copyright 2023 Google LLC. All Rights Reserved. 17244 * Licensed under the Apache License, Version 2.0 (the "License"); 17245 * you may not use this file except in compliance with the License. 17246 * You may obtain a copy of the License at 17247 * 17248 * http://www.apache.org/licenses/LICENSE-2.0 17249 * 17250 * Unless required by applicable law or agreed to in writing, software 17251 * distributed under the License is distributed on an "AS IS" BASIS, 17252 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17253 * See the License for the specific language governing permissions and 17254 * limitations under the License. 17255 * ============================================================================= 17256 */const sH=[{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}
17256]},{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}]}],aH=Object.freeze(Object.defineProperty({__proto__:null,json:sH},Symbol.toStringTag,{value:"Module"}));/** 17257 * @license 17258 * Copyright 2023 Google LLC. All Rights Reserved. 17259 * Licensed under the Apache License, Version 2.0 (the "License"); 17260 * you may not use this file except in compliance with the License. 17261 * You may obtain a copy of the License at 17262 * 17263 * http://www.apache.org/licenses/LICENSE-2.0 17264 * 17265 * Unless required by applicable law or agreed to in writing, software 17266 * distributed under the License is distributed on an "AS IS" BASIS, 17267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17268 * See the License for the specific language governing permissions and 17269 * limitations under the License. 17270 * ============================================================================= 17271 */const oH=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
17271]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
17271]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],iH=Object.freeze(Object.defineProperty({__proto__:null,json:oH},Symbol.toStringTag,{value:"Module"}));/** 17272 * @license 17273 * Copyright 2023 Google LLC. All Rights Reserved. 17274 * Licensed under the Apache License, Version 2.0 (the "License"); 17275 * you may not use this file except in compliance with the License. 17276 * You may obtain a copy of the License at 17277 * 17278 * http://www.apache.org/licenses/LICENSE-2.0 17279 * 17280 * Unless required by applicable law or agreed to in writing, software 17281 * distributed under the License is distributed on an "AS IS" BASIS, 17282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17283 * See the License for the specific language governing permissions and 17284 * limitations under the License. 17285 * ============================================================================= 17286 */const uH
vendor: 7,591 bytes, line 17286
17286=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],c
17286H=Object.freeze(Object.defineProperty({__proto__:null,json:uH},Symbol.toStringTag,{value:"Module"}));/** 17287 * @license 17288 * Copyright 2023 Google LLC. All Rights Reserved. 17289 * Licensed under the Apache License, Version 2.0 (the "License"); 17290 * you may not use this file except in compliance with the License. 17291 * You may obtain a copy of the License at 17292 * 17293 * http://www.apache.org/licenses/LICENSE-2.0 17294 * 17295 * Unless required by applicable law or agreed to in writing, software 17296 * distributed under the License is distributed on an "AS IS" BASIS, 17297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17298 * See the License for the specific language governing permissions and 17299 * limitations under the License. 17300 * ============================================================================= 17301 */const lH=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
vendor: 4,262 bytes, lines 17301-17304
17301,{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},{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"}]}],dH=Object.freeze(Object.defineProperty({__proto__:null,json:lH},Symbol.toStringTag,{value:"Module"}));/** 17302 * @license 17303 * Copyright 2023 Google LLC. All Rights Reserved. 17304 * Licensed under the Apache License, Version 2.0 (the "License");
17305 * you may not use this file except in compliance with the License. 17306 * You may obtain a copy of the License at 17307 * 17308 * http://www.apache.org/licenses/LICENSE-2.0 17309 * 17310 * Unless required by applicable law or agreed to in writing, software 17311 * distributed under the License is distributed on an "AS IS" BASIS, 17312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17313 * See the License for the specific language governing permissions and 17314 * limitations under the License. 17315 * ============================================================================= 17316 */const pH=[{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:"RandomUniformInt",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number"},{tfName:"maxval",name:"maxval",type:"number"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],hH=Object.freeze(Object.defineProperty({__proto__:null,json:pH},Symbol.toStringTag,{value:"Module"}));/** 17317 * @license 17318 * Copyright 2023 Google LLC. All Rights Reserved. 17319 * Licensed under the Apache License, Version 2.0 (the "License");
17320 * you may not use this file except in compliance with the License. 17321 * You may obtain a copy of the License at 17322 * 17323 * http://www.apache.org/licenses/LICENSE-2.0 17324 * 17325 * Unless required by applicable law or agreed to in writing, software 17326 * distributed under the License is distributed on an "AS IS" BASIS, 17327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17328 * See the License for the specific language governing permissions and 17329 * limitations under the License. 17330 * ============================================================================= 17331 */const fH=[{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}]}],mH=Object.freeze(Object.defineProperty({__proto__:null,json:fH},Symbol.toStringTag,{value:"Module"}));/** 17332 * @license 17333 * Copyright 2023 Google LLC. All Rights Reserved. 17334 * Licensed under the Apache License, Version 2.0 (the "License"); 17335 * you may not use this file except in compliance with the License. 17336 * You may obtain a copy of the License at 17337 * 17338 * http://www.apache.org/licenses/LICENSE-2.0 17339 * 17340 * Unless required by applicable law or agreed to in writing, software 17341 * distributed under the License is distributed on an "AS IS" BASIS, 17342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17343 * See the License for the specific language governing permissions and 17344 * limitations under the License. 17345 * ============================================================================= 17346 */const gH=[{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"}]}],yH=Object.freeze(Object.defineProperty({__proto__:null,json:gH},Symbol.toStringTag,{value:"Module"}));/** 17347 * @license 17348 * Copyright 2023 Google LLC. All Rights Reserved. 17349 * Licensed under the Apache License, Version 2.0 (the "License"); 17350 * you may not use this file except in compliance with the License. 17351 * You may obtain a copy of the License at 17352 * 17353 * http://www.apache.org/licenses/LICENSE-2.0 17354 * 17355 * Unless required by applicable law or agreed to in writing, softw
17355are 17356 * distributed under the License is distributed on an "AS IS" BASIS, 17357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17358 * See the License for the specific language governing permissions and 17359 * limitations under the License. 17360 * ============================================================================= 17361 */const bH=[{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"}]}],xH=Object.freeze(Object.defineProperty({__proto__:null,json:bH},Symbol.toStringTag,{value:"Module"}));/** 17362 * @license 17363 * Copyright 2023 Google LLC. All Rights Reserved. 17364 * Licensed under the Apache License, Version 2.0 (the "License"); 17365 * you may not use this file except in compliance with the License. 17366 * You may obtain a copy of the License at 17367 * 17368 * http://www.apache.org/licenses/LICENSE-2.0 17369 * 17370 * Unless required by applicable law or agreed to in writing, software 17371 * distributed under the License is distributed on an "AS IS" BASIS, 17372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17373 * See the License for the specific language governing permissions and 17374 * limitations under the License. 17375 * ============================================================================= 17376 */const wH=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}
17376],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],vH=Object.freeze(Object.defineProperty({__proto__:null,json:wH},Symbol.toStringTag,{value:"Module"}));/** 17377 * @license 17378 * Copyright 2023 Google LLC. All Rights Reserved. 17379 * Licensed under the Apache License, Version 2.0 (the "License"); 17380 * you may not use this file except in compliance with the License. 17381 * You may obtain a copy of the License at 17382 * 17383 * http://www.apache.org/licenses/LICENSE-2.0 17384 * 17385 * Unless required by applicable law or agreed to in writing, software 17386 * distributed under the License is distributed on an "AS IS" BASIS, 17387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17388 * See the License for the specific language governing permissions and 17389 * limitations under the License. 17390 * ============================================================================= 17391 */const IH=[{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"}]}],$H=Object.freeze(Object.defineProperty({__proto__:null,json:IH},Symbol.toStringTag,{value:"Module"}));/** 17392 * @license 17393 * Copyright 2023 Google LLC. All Rights Reserved. 17394 * Licensed under the Apache License, Version 2.0 (the "License"); 17395 * you may not use this file except in compliance with the License. 17396 * You may obtain a copy of the License at 17397 * 17398 * http://www.apache.org/licenses/LICENSE-2.0 17399 * 17400 * Unless required by applicable law or agreed to in writing, software 17401 * distributed under the License is distributed on an "AS IS" BASIS, 17402 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17403 * See the License for the specific language governing permissions and 17404 * limitations under the License. 17405 * ============================================================================= 17406 */const SH=[{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}
17406]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BitwiseAnd",category:"logical",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}]}],CH=Object.freeze(Object.defineProperty({__proto__:null,json:SH},Symbol.toStringTag,{value:"Module"}));/** 17407 * @license 17408 * Copyright 2023 Google LLC. All Rights Reserved. 17409 * Licensed under the Apache License, Version 2.0 (the "License"); 17410 * you may not use this file except in compliance with the License. 17411 * You may obtain a copy of the License at 17412 * 17413 * http://www.apache.org/licenses/LICENSE-2.0 17414 * 17415 * Unless required by applicable law or agreed to in writing, software 17416 * distributed under the License is distributed on an "AS IS" BASIS, 17417 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17418 * See the License for the specific language governing permissions and 17419 * limitations under the License. 17420 * ============================================================================= 17421 */const _H=[{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}
vendor: 15,939 bytes, lines 17421-17514
17421]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}],NH=Object.freeze(Object.defineProperty({__proto__:null,json:_H},Symbol.toStringTag,{value:"Module"}));/** 17422 * @license 17423 * Copyright 2023 Google LLC. All Rights Reserved. 17424 * Licensed under the Apache License, Version 2.0 (the "License"); 17425 * you may not use this file except in compliance with the License. 17426 * You may obtain a copy of the License at 17427 * 17428 * http://www.apache.org/licenses/LICENSE-2.0 17429 * 17430 * Unless required by applicable law or agreed to in writing, software 17431 * distributed under the License is distributed on an "AS IS" BASIS, 17432 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17433 * See the License for the specific language governing permissions and 17434 * limitations under the License. 17435 * ============================================================================= 17436 */const TH=[{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"}]}],kH=Object.freeze(Object.defineProperty({__proto__:null,json:TH},Symbol.toStringTag,{value:"Module"}));/** 17437 * @license 17438 * Copyright 2023 Google LLC. All Rights Reserved. 17439 * Licensed under the Apache License, Version 2.0 (the "License"); 17440 * you may not use this file except in compliance with the License. 17441 * You may obtain a copy of the License at 17442 * 17443 * http://www.apache.org/licenses/LICENSE-2.0 17444 * 17445 * Unless required by applicable law or agreed to in writing, software 17446 * distributed under the License is distributed on an "AS IS" BASIS, 17447 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17448 * See the License for the specific language governing permissions and 17449 * limitations under the License. 17450 * ============================================================================= 17451 */const EH=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],RH=Object.freeze(Object.defineProperty({__proto__:null,json:EH},Symbol.toStringTag,{value:"Module"}));/** 17452 * @license 17453 * Copyright 2023 Google LLC. All Rights Reserved. 17454 * Licensed under the Apache License, Version 2.0 (the "License"); 17455 * you may not use this file except in compliance with the License. 17456 * You may obtain a copy of the License at 17457 * 17458 * http://www.apache.org/licenses/LICENSE-2.0 17459 * 17460 * Unless required by applicable law or agreed to in writing, software 17461 * distributed under the License is distributed on an "AS IS" BASIS, 17462 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17463 * See the License for the specific language governing permissions and 17464 * limitations under the License. 17465 * ============================================================================= 17466 */const AH=[{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}]},{tfOpName:"TensorScatterUpdate",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],DH=Object.freeze(Object.defineProperty({__proto__:null,json:AH},Symbol.toStringTag,{value:"Module"}));/** 17467 * @license 17468 * Copyright 2023 Google LLC. All Rights Reserved. 17469 * Licensed under the Apache License, Version 2.0 (the "License"); 17470 * you may not use this file except in compliance with the License. 17471 * You may obtain a copy of the License at 17472 * 17473 * http://www.apache.org/licenses/LICENSE-2.0 17474 * 17475 * Unless required by applicable law or agreed to in writing, software 17476 * distributed under the License is distributed on an "AS IS" BASIS, 17477 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17478 * See the License for the specific language governing permissions and 17479 * limitations under the License. 17480 * ============================================================================= 17481 */const OH=[{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"}]}],FH=Object.freeze(Object.defineProperty({__proto__:null,json:OH},Symbol.toStringTag,{value:"Module"}));/** 17482 * @license 17483 * Copyright 2023 Google LLC. All Rights Reserved. 17484 * Licensed under the Apache License, Version 2.0 (the "License"); 17485 * you may not use this file except in compliance with the License. 17486 * You may obtain a copy of the License at 17487 * 17488 * http://www.apache.org/licenses/LICENSE-2.0 17489 * 17490 * Unless required by applicable law or agreed to in writing, software 17491 * distributed under the License is distributed on an "AS IS" BASIS, 17492 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17493 * See the License for the specific language governing permissions and 17494 * limitations under the License. 17495 * ============================================================================= 17496 */const PH=[{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}]}],LH=Object.freeze(Object.defineProperty({__proto__:null,json:PH},Symbol.toStringTag,{value:"Module"}));/** 17497 * @license 17498 * Copyright 2023 Google LLC. All Rights Reserved. 17499 * Licensed under the Apache License, Version 2.0 (the "License"); 17500 * you may not use this file except in compliance with the License. 17501 * You may obtain a copy of the License at 17502 * 17503 * http://www.apache.org/licenses/LICENSE-2.0 17504 * 17505 * Unless required by applicable law or agreed to in writing, software 17506 * distributed under the License is distributed on an "AS IS" BASIS, 17507 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17508 * See the License for the specific language governing permissions and 17509 * limitations under the License. 17510 * ============================================================================= 17511 */const MH=[{tfOpName:"StaticRegexReplace",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"pattern",name:"pattern",type:"string"},{tfName:"rewrite",name:"rewrite",type:"string"},{tfName:"replace_global",name:"replaceGlobal",type:"bool"}]},{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],BH=Object.freeze(Object.defineProperty({__proto__:null,json:MH},Symbol.toStringTag,{value:"Module"}));/** 17512 * @license 17513 * Copyright 2023 Google LLC. All Rights Reserved. 17514 * Licensed under the Apache License, Version 2.0 (the "License");
17515 * you may not use this file except in compliance with the License. 17516 * You may obtain a copy of the License at 17517 * 17518 * http://www.apache.org/licenses/LICENSE-2.0 17519 * 17520 * Unless required by applicable law or agreed to in writing, software 17521 * distributed under the License is distributed on an "AS IS" BASIS, 17522 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17523 * See the License for the specific language governing permissions and 17524 * limitations under the License. 17525 * ============================================================================= 17526 */const VH=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"EnsureShape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}],WH=Object.freeze(Object.defineProperty({__proto__:null,json:VH},Symbol.toStringTag,{value:"Module"}));/** 17527 * @license 17528 * Copyright 2018 Google LLC. All Rights Reserved. 17529 * Licensed under the Apache License, Version 2.0 (the "License"); 17530 * you may not use this file except in compliance with the License. 17531 * You may obtain a copy of the License at 17532 * 17533 * http://www.apache.org/licenses/LICENSE-2.0 17534 * 17535 * Unless required by applicable law or agreed to in writing, software 17536 * distributed under the License is distributed on an "AS IS" BASIS, 17537 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17538 * See the License for the specific language governing permissions and 17539 * limitations under the License. 17540 * ============================================================================= 17541 */class Tf{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[aH,iH,cH,dH,hH,mH,yH,xH,vH,$H,CH,NH,kH,RH,DH,FH,LH,BH,WH],t=[].concat(...e.map(r=>r.json));this.opMappers=t.reduce((r,s)=>(r[s.tfOpName]=s,r),{})}transformGraph(e,t={}){const r=e.node,s=[],a=[],o=[],i=r.reduce((g,y)=>(g[y.name]=this.mapNode(y),y.op.startsWith("Placeholder")?s.push(g[y.name]):y.op==="Const"?a.push(g[y.name]):(y.input==null||y.input.length===0)&&o.push(g[y.name]),g),{});let c=[];const l=[];let u={},d={};t!=null&&(u=this.mapSignatureEntries(t.inputs),d=this.mapSignatureEntries(t.outputs));const p=Object.keys(i);p.forEach(g=>{const y=i[g];
vendor: 6,069 bytes, lines 17541-17544
17541y.inputNames.forEach((b,v)=>{const[$,,S]=mr(b),T=i[$];if(T.outputs!=null){const O=T.outputs.indexOf(S);if(O!==-1){const L=`${$}:${O}`;y.inputNames[v]=L}}y.inputs.push(T),T.children.push(y)})}),Object.keys(d).length===0?p.forEach(g=>{const y=i[g];y.children.length===0&&l.push(y)}):Object.keys(d).forEach(g=>{const[y]=mr(g),b=i[y];b!=null&&(b.signatureKey=d[g],l.push(b))}),Object.keys(u).length>0?Object.keys(u).forEach(g=>{const[y]=mr(g),b=i[y];b&&(b.signatureKey=u[g],c.push(b))}):c=s;let h={};e.library!=null&&e.library.function!=null&&(h=e.library.function.reduce((g,y)=>(g[y.signature.name]=this.mapFunction(y),g),{}));const m={nodes:i,inputs:c,outputs:l,weights:a,placeholders:s,signature:t,functions:h};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=s0(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(s=>s.startsWith("^")?s.slice(1):s),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return t.inputs!=null&&(r.inputParams=t.inputs.reduce((s,a)=>(s[a.name]={type:a.type,inputIndexStart:a.start,inputIndexEnd:a.end},s),{})),t.attrs!=null&&(r.attrParams=t.attrs.reduce((s,a)=>{const o=a.type;let i;switch(a.type){case"string":i=cl(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=cl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"string[]":i=gl(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=gl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"number":i=dl(e.attr,a.tfName,a.defaultValue||0),i===void 0&&!!a.tfDeprecatedName&&(i=dl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"number[]":i=ml(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=ml(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"bool":i=ll(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=ll(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"bool[]":i=bl(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=bl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"shape":i=fl(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=fl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"shape[]":i=yl(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=yl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"dtype":i=pl(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=pl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"dtype[]":i=hl(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=hl(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"func":i=kf(e.attr,a.tfName,a.defaultValue),i===void 0&&!!a.tfDeprecatedName&&(i=kf(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${a.type} for op: ${e.op}`)}return s[a.name]={value:i,type:o},s},{})),r}mapFunction(e){const t=e.nodeDef,r=[],s=[];let a={};t!=null&&(a=t.reduce((d,p)=>(d[p.name]=this.mapNode(p),p.op==="Const"&&s.push(d[p.name]),d),{}));const o=[],i=[];e.signature.inputArg.forEach(d=>{const[p]=mr(d.name),h={name:p,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:uh(d.type),type:"dtype"}},children:[]};h.signatureKey=d.name,o.push(h),a[p]=h}),Object.keys(a).forEach(d=>{const p=a[d];p.inputNames.forEach((h,m)=>{const[g,,y]=mr(h),b=a[g];if(b.outputs!=null){const v=b.outputs.indexOf(y);if(v!==-1){const $=`${g}:${v}`;p.inputNames[m]=$}}p.inputs.push(b),b.children.push(p)})});const l=e.ret;e.signature.outputArg.forEach(d=>{const[p,h]=mr(l[d.name]),m=a[p];m!=null&&(m.defaultOutput=h,i.push(m))});const u=this.mapArgsToSignature(e);return{nodes:a,inputs:o,outputs:i,weights:s,placeholders:r,signature:u}}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 UH(n){const e=U().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 a0(n,e){const t=Array.isArray(n)?String.fromCharCode.apply(null,n):UH(n);return e?t:t.toLowerCase()}function cl(n,e,t,r=!1){const s=n[e];return s!=null?a0(s.s,r):t}function ll(n,e,t){const r=n[e];return r?r.b:t}function dl(n,e,t){const r=n[e]||{},s=r.i!=null?r.i:r.f!=null?r.f:t;return typeof s=="number"?s:parseInt(s,10)}function uh(n){switch(typeof n=="string"&&(n=en[n]),n){case en.DT_FLOAT:case en.DT_HALF:return"float32";case en.DT_INT32:case en.DT_INT64:case en.DT_INT8:case en.DT_UINT8:return"int32";case en.DT_BOOL:return"bool";case en.DT_DOUBLE:return"float32";case en.DT_STRING:return"string";case en.DT_COMPLEX64:case en.DT_COMPLEX128:return"complex64";default:return null}}function kf(n,e,t){const r=n[e];return r&&r.func?r.func.name:t}function pl(n,e,t){const r=n[e];return r&&r.type?uh(r.type):t}function hl(n,e,t){const r=n[e];return r&&r.list&&r.list.type?r.list.type.map(s=>uh(s)):t}function o0(n){if(!n.unknownRank)return n.dim!=null?n.dim.map(e=>typeof e.size=="number"?e.size:parseInt(e.size,10)):[]}function fl(n,e,t){const r=n[e];return r&&r.shape?o0(r.shape):t}function ml(n,e,t){const r=n[e];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map(s=>typeof s=="number"?s:parseInt(s,10)):t}function gl(n,e,t,r=!1){const s=n[e];return s&&s.list&&s.list.s?s.list.s.map(a=>a0(a,r)):t}function yl(n,e,t){const r=n[e];return r&&r.list&&r.list.shape?r.list.shape.map(s=>o0(s)):t}function bl(n,e,t){const r=n[e];return r&&r.list&&r.list.b?r.list.b:t}/** 17542 * @license 17543 * Copyright 2019 Google LLC. All Rights Reserved. 17544 * Licensed under the Apache License, Version 2.0 (the "License");
17545 * you may not use this file except in compliance with the License. 17546 * You may obtain a copy of the License at 17547 * 17548 * http://www.apache.org/licenses/LICENSE-2.0 17549 * 17550 * Unless required by applicable law or agreed to in writing, software 17551 * distributed under the License is distributed on an "AS IS" BASIS, 17552 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17553 * See the License for the specific language governing permissions and 17554 * limitations under the License. 17555 * ============================================================================= 17556 */class zH{constructor(e,t,r){this.node=e,this.tensorMap=t,this.context=r,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(s=>this.getInput(s)),e.rawAttrs!=null&&(this.attrs=Object.keys(e.rawAttrs).reduce((s,a)=>(s[a]=this.getAttr(a),s),{}))}getInput(e){return vt(e,this.tensorMap,this.context)}getAttr(e,t){const r=this.node.rawAttrs[e];if(r.tensor!=null)return vt(e,this.tensorMap,this.context);if(r.i!=null||r.f!=null)return dl(this.node.rawAttrs,e,t);if(r.s!=null)return cl(this.node.rawAttrs,e,t);if(r.b!=null)return ll(this.node.rawAttrs,e,t);if(r.shape!=null)return fl(this.node.rawAttrs,e,t);if(r.type!=null)return pl(this.node.rawAttrs,e,t);if(r.list!=null){if(r.list.i!=null||r.list.f!=null)return ml(this.node.rawAttrs,e,t);if(r.list.s!=null)return gl(this.node.rawAttrs,e,t);if(r.list.shape!=null)return yl(this.node.rawAttrs,e,t);if(r.list.b!=null)return bl(this.node.rawAttrs,e,t);if(r.list.type!=null)return hl(this.node.rawAttrs,e,t)}return t}}/** 17557 * @license 17558 * Copyright 2020 Google LLC. All Rights Reserved. 17559 * Licensed under the Apache License, Version 2.0 (the "License"); 17560 * you may not use this file except in compliance with the License. 17561 * You may obtain a copy of the License at 17562 * 17563 * http://www.apache.org/licenses/LICENSE-2.0 17564 * 17565 * Unless required by applicable law or agreed to in writing, software 17566 * distributed under the License is distributed on an "AS IS" BASIS, 17567 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17568 * See the License for the specific language governing permissions and 17569 * limitations under the License. 17570 * ============================================================================= 17571 */const _t=Object.freeze(Object.defineProperty({__proto__:null,abs:ln,acos:d1,acosh:h1,add:me,addN:m1,all:y1,any:x1,argMax:v1,argMin:$1,asin:C1,asinh:N1,atan:k1,atan2:R1,atanh:D1,avgPool:Zm,avgPool3d:W1,basicLSTMCell:K1,batchToSpaceND:Jm,batchNorm:Bu,batchNorm2d:J1,batchNorm3d:tv,batchNorm4d:rv,bincount:eg,bitwiseAnd:ov,broadcastArgs:uv,broadcastTo:oo,buffer:at,cast:rt,ceil:dv,clipByValue:tg,clone:Br,complex:zr,concat:It,concat1d:fv,concat2d:gv,concat3d:bv,concat4d:wv,conv1d:$v,conv2d:Vu,conv2dTranspose:_v,conv3d:Tv,conv3dTranspose:Av,cos:Ov,cosh:Pv,cumprod:Mv,cumsum:Vv,denseBincount:Uv,depthToSpace:Gv,depthwiseConv2d:hp,diag:qv,dilation2d:Xv,div:Te,divNoNan:eI,dot:nI,einsum:pa,elu:ag,ensureShape:oI,equal:sg,erf:uI,euclideanNorm:yI,exp:xr,expandDims:nr,expm1:vI,eye:ug,fill:ko,floor:cg,floorDiv:Qm,gather:lg,greater:Uu,greaterEqual:dg,imag:zu,isFinite:EI,isInf:AI,isNaN:OI,leakyRelu:pg,less:Xc,lessEqual:mp,linspace:MI,localResponseNormalization:VI,log:go,log1p:hg,logSigmoid:qI,logSoftmax:YI,logSumExp:mg,logicalAnd:$i,logicalNot:gg,logicalOr:yg,logicalXor:n$,lowerBound:s$,matMul:Ue,max:ba,maxPool:bg,maxPool3d:i$,maxPoolWithArgmax:c$,maximum:xg,mean:Si,meshgrid:p$,min:Kc,minimum:Ci,mirrorPad:m$,mod:y$,moments:x$,mul:Z,multiRNNCell:v$,multinomial:$$,neg:ar,notEqual:wg,oneHot:_$,ones:ws,onesLike:T$,outerProduct:E$,pad:Ro,pad1d:D$,pad2d:F$,pad3d:L$,pad4d:B$,pool:G$,pow:mo,prelu:Ig,print:Ym,prod:q$,raggedGather:X$,raggedRange:Q$,raggedTensorToTensor:J$,rand:tS,randomGamma:hS,randomNormal:Eg,randomStandardNormal:gS,randomUniform:xp,randomUniformInt:xS,range:yo,real:bo,reciprocal:IS,relu:Gu,relu6:Rg,reshape:q,reverse:Rs,reverse1d:NS,reverse2d:kS,reverse3d:RS,reverse4d:DS,round:Ag,rsqrt:PS,scalar:Re,selu:MS,separableConv2d:VS,setdiff1dAsync:US,sigmoid:Is,sign:GS,sin:jS,sinh:KS,slice:Se,slice1d:YS,slice2d:ZS,slice3d:e2,slice4d:n2,softmax:s2,
vendor: 4,711 bytes, lines 17571-17601
17571softplus:fg,spaceToBatchND:vg,fft:wp,ifft:_i,irfft:Dg,rfft:vp,split:xo,sqrt:br,square:Gn,squaredDifference:Og,squeeze:xt,stack:vr,step:Fg,stridedSlice:m2,sub:Ce,sum:Ke,tan:y2,tanh:qc,tensor:zn,tensor1d:Rt,tensor2d:$s,tensor3d:Pg,tensor4d:b2,tensor5d:x2,tensor6d:w2,tensorScatterUpdate:I2,tile:io,topk:S2,truncatedNormal:_2,unique:T2,unsortedSegmentSum:E2,unstack:Bs,upperBound:A2,variable:D2,where:Vr,whereAsync:Bg,zeros:Es,zerosLike:hn,op:D,OP_SCOPE_SUFFIX:Pm,booleanMaskAsync:P2,transpose:Yc,norm:Wu,movingAverage:B2,scatterND:W2,searchSorted:gp,sparseToDense:G2,gatherND:j2,dropout:X2,enclosingPowerOfTwo:Vg,cosineWindow:$p,inTopKAsync:Q2,image:Xu,linalg:z_,losses:G_,spectral:W_,fused:lC,signal:U_,sparse:H_,string:j_},Symbol.toStringTag,{value:"Module"}));/** 17572 * @license 17573 * Copyright 2018 Google LLC. All Rights Reserved. 17574 * Licensed under the Apache License, Version 2.0 (the "License"); 17575 * you may not use this file except in compliance with the License. 17576 * You may obtain a copy of the License at 17577 * 17578 * http://www.apache.org/licenses/LICENSE-2.0 17579 * 17580 * Unless required by applicable law or agreed to in writing, software 17581 * distributed under the License is distributed on an "AS IS" BASIS, 17582 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17583 * See the License for the specific language governing permissions and 17584 * limitations under the License. 17585 * ============================================================================= 17586 */const GH=(n,e,t,r=_t)=>{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`)}};/** 17587 * @license 17588 * Copyright 2018 Google LLC. All Rights Reserved. 17589 * Licensed under the Apache License, Version 2.0 (the "License"); 17590 * you may not use this file except in compliance with the License. 17591 * You may obtain a copy of the License at 17592 * 17593 * http://www.apache.org/licenses/LICENSE-2.0 17594 * 17595 * Unless required by applicable law or agreed to in writing, software 17596 * distributed under the License is distributed on an "AS IS" BASIS, 17597 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17598 * See the License for the specific language governing permissions and 17599 * limitations under the License. 17600 * ============================================================================= 17601 */const HH=(n,e,t,r=_t)=>{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(vt(n.inputNames[0],e,t))];
vendor: 12,720 bytes, lines 17601-17654
17601case"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(vt(n.inputNames[0],e,t))];case"IsInf":return[r.isInf(vt(n.inputNames[0],e,t))];case"IsFinite":return[r.isFinite(vt(n.inputNames[0],e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17602 * @license 17603 * Copyright 2020 Google LLC. All Rights Reserved. 17604 * Licensed under the Apache License, Version 2.0 (the "License"); 17605 * you may not use this file except in compliance with the License. 17606 * You may obtain a copy of the License at 17607 * 17608 * http://www.apache.org/licenses/LICENSE-2.0 17609 * 17610 * Unless required by applicable law or agreed to in writing, software 17611 * distributed under the License is distributed on an "AS IS" BASIS, 17612 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17613 * See the License for the specific language governing permissions and 17614 * limitations under the License. 17615 * ============================================================================= 17616 */function In(n,e,t=""){if(!(typeof n=="number"||typeof e=="number")){N(n.length===e.length,()=>t+` Shapes ${n} and ${e} must match`);for(let r=0;r<n.length;r++){const s=n[r],a=e[r];N(s<0||a<0||s===a,()=>t+` Shapes ${n} and ${e} must match`)}}}function Ef(n){return!(typeof n=="number"||n.some(e=>e<0))}function to(n,e,t){let r=xl(n,t);const s=!Ef(r);if(s&&e.length===0)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(s&&e.forEach(a=>{r=xl(a.shape,r)}),!Ef(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function xl(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 s=n[r],a=e[r];if(s>=0&&a>=0&&s!==a)throw new Error(`Incompatible shape during merge: ${n} vs. ${e}`);t[r]=s>=0?s:a}return t}/** 17617 * @license 17618 * Copyright 2018 Google LLC. All Rights Reserved. 17619 * Licensed under the Apache License, Version 2.0 (the "License"); 17620 * you may not use this file except in compliance with the License. 17621 * You may obtain a copy of the License at 17622 * 17623 * http://www.apache.org/licenses/LICENSE-2.0 17624 * 17625 * Unless required by applicable law or agreed to in writing, software 17626 * distributed under the License is distributed on an "AS IS" BASIS, 17627 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17628 * See the License for the specific language governing permissions and 17629 * limitations under the License. 17630 * ============================================================================= 17631 */class jH{constructor(e,t,r,s,a,o,i){this.name=e,this.dtype=t,this.maxSize=r,this.elementShape=s,this.identicalElementShapes=a,this.dynamicSize=o,this.clearAfterRead=i,this.tensors=[],this.closed_=!1,this.idTensor=Re(0),rr(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}, 17632 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),In(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,rr(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,s)=>this.write(r,t[s]))}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 s=0;s<this.size();s++)e.push(s)}if(e.length===0)return zn([],[0].concat(this.elementShape));const r=this.readMany(e);return In(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),vr(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 zn([],[0].concat(this.elementShape));const t=[];for(let s=0;s<this.size();s++)t.push(s);const r=this.readMany(t);return In(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,Bs(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 s=e.map(c=>(r+=c,r));if(r!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to 17633 tensor.shape[0], but sum of lengths is 17634 ${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 a=r===0?0:t.size/r,o=[];Ne(()=>{t=q(t,[1,r,a]);for(let c=0;c<e.length;++c){const u=[0,c===0?0:s[c-1],0],d=[1,e[c],a];o[c]=q(Se(t,u,d),this.elementShape)}return o});const i=[];for(let c=0;c<e.length;c++)i[c]=c;this.writeMany(i,o)}}/** 17635 * @license 17636 * Copyright 2020 Google LLC. All Rights Reserved. 17637 * Licensed under the Apache License, Version 2.0 (the "License"); 17638 * you may not use this file except in compliance with the License. 17639 * You may obtain a copy of the License at 17640 * 17641 * http://www.apache.org/licenses/LICENSE-2.0 17642 * 17643 * Unless required by applicable law or agreed to in writing, software 17644 * distributed under the License is distributed on an "AS IS" BASIS, 17645 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17646 * See the License for the specific language governing permissions and 17647 * limitations under the License. 17648 * ============================================================================= 17649 */class Fs{get id(){return this.idTensor.id}constructor(e,t,r,s=-1){this.tensors=e,this.elementShape=t,this.elementDtype=r,e!=null&&e.forEach(a=>{if(r!==a.dtype)throw new Error(`Invalid data types; op elements ${r}, but list elements ${a.dtype}`);In(t,a.shape,"TensorList shape mismatch: "),rr(a)}),this.idTensor=Re(0),this.maxNumElements=s,rr(this.idTensor)}copy(){return new Fs([...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.`);In(e,this.elementShape,"TensorList shape mismatch: ");const s=to(this.elementShape,this.tensors,e);return Ne(()=>{const a=this.tensors.map(o=>q(o,s));return vr(a,0)})}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(this.size()===0)throw new Error("Trying to pop from an empty list.");const r=to(this.elementShape,this.tensors,e),s=this.tensors.pop();return s.kept=!1,In(s.shape,e,"TensorList shape mismatch: "),q(s,r)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(In(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");rr(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 Fs([],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.`);In(this.tensors[e].shape,t,"TensorList shape mismatch: ");const s=to(this.elementShape,this.tensors,t);return q(this.tensors[e],s)}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.`);In(this.elementShape,t.shape,"TensorList shape mismatch: "),rr(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}`);In(this.elementShape,r,"TensorList shape mismatch: "),e=e.slice(0,this.size());const s=to(this.elementShape,this.tensors,r);return e.length===0?zn([],[0].concat(s)):Ne(()=>{const a=e.map(o=>q(this.tensors[o],s));return vr(a,0)})}concat(e,t){if(!!e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);In(this.elementShape,t,"TensorList shape mismatch: ");const r=to(this.elementShape,this.tensors,t);return this.size()===0?zn([],[0].concat(r)):Ne(()=>{const s=this.tensors.map(a=>q(a,r));return It(s,0)})}}function qH(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 s=n.shape.slice(1);In(s,e,"TensorList shape mismatch: ");const a=Bs(n);return new Fs(a,e,r)}function KH(n,e,t,r){return new Fs([],n,e,r)}function XH(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 s=Math.max(...e);if(r!=null&&r!==-1&&s>=r)throw new Error(`Max index must be < array size (${s} vs. ${r})`);const a=new Fs([],t,n.dtype,r),o=Bs(n,0);return e.forEach((i,c)=>{a.setItem(i,o[c])}),a}function YH(n,e,t){let r=0;const s=e.map(u=>(r+=u,r));if(r!==n.shape[0])throw new Error(`Expected sum of lengths to be equal to 17650 tensor.shape[0], but sum of lengths is 17651 ${r}, and tensor's shape is: ${n.shape}`);const a=n.shape.slice(1),o=xl(a,t),i=r===0?0:n.size/r,c=Ne(()=>{const u=[];n=q(n,[1,r,i]);for(let d=0;d<e.length;++d){const h=[0,d===0?0:s[d-1],0],m=[1,e[d],i];u[d]=q(Se(n,h,m),o)}return n.dispose(),u}),l=new Fs([],t,n.dtype,e.length);for(let u=0;u<c.length;u++)l.setItem(u,c[u]);return l}/** 17652 * @license 17653 * Copyright 2018 Google LLC. All Rights Reserved. 17654 * Licensed under the Apache License, Version 2.0 (the "License");
17655 * you may not use this file except in compliance with the License. 17656 * You may obtain a copy of the License at 17657 * 17658 * http://www.apache.org/licenses/LICENSE-2.0 17659 * 17660 * Unless required by applicable law or agreed to in writing, software 17661 * distributed under the License is distributed on an "AS IS" BASIS, 17662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17663 * See the License for the specific language governing permissions and 17664 * limitations under the License. 17665 * ============================================================================= 17666 */const QH=async(n,e,t)=>{switch(n.op){case"If":case"StatelessIf":{const r=w("thenBranch",n,e,t),s=w("elseBranch",n,e,t),a=w("cond",n,e,t),o=w("args",n,e,t);return(await a.data())[0]?t.functionMap[r].executeFunctionAsync(o,t.tensorArrayMap,t.tensorListMap):t.functionMap[s].executeFunctionAsync(o,t.tensorArrayMap,t.tensorListMap)}case"While":case"StatelessWhile":{const r=w("body",n,e,t),s=w("cond",n,e,t),a=w("args",n,e,t),o=await t.functionMap[s].executeFunctionAsync(a,t.tensorArrayMap,t.tensorListMap),i=a.map(u=>u.id);let c=await o[0].data();o.forEach(u=>{!u.kept&&i.indexOf(u.id)===-1&&u.dispose()});let l=a;for(;c[0];){const u=l;l=await t.functionMap[r].executeFunctionAsync(l,t.tensorArrayMap,t.tensorListMap);const d=l.map(h=>h.id);u.forEach(h=>{!h.kept&&i.indexOf(h.id)===-1&&d.indexOf(h.id)===-1&&h.dispose()});const p=await t.functionMap[s].executeFunctionAsync(l,t.tensorArrayMap,t.tensorListMap);c=await p[0].data(),p.forEach(h=>{!h.kept&&i.indexOf(h.id)===-1&&d.indexOf(h.id)===-1&&h.dispose()})}return l}case"LoopCond":{const r=w("pred",n,e,t);return[gr(r)]}case"Switch":{const r=w("pred",n,e,t);let s=w("data",n,e,t);return s.kept||(s=gr(s)),(await r.data())[0]?[void 0,s]:[s,void 0]}case"Merge":{const r=n.inputNames.find(s=>vt(s,e,t)!==void 0);if(r){const s=vt(r,e,t);return[gr(s)]}return}case"Enter":{const r=w("frameName",n,e,t),s=w("tensor",n,e,t);return t.enterFrame(r),[gr(s)]}case"Exit":{const r=w("tensor",n,e,t);return t.exitFrame(),[gr(r)]}case"NextIteration":{const r=w("tensor",n,e,t);return t.nextIteration(),[gr(r)]}case"TensorArrayV3":{const r=w("size",n,e,t),s=w("dtype",n,e,t),a=w("elementShape",n,e,t),o=w("dynamicSize",n,e,t),i=w("clearAfterRead",n,e,t),c=w("identicalElementShapes",n,e,t),l=w("name",n,e,t),u=new jH(l,s,r,a,c,o,i);return t.addTensorArray(u),[u.idTensor,Re(1)]}case"TensorArrayWriteV3":{const r=w("tensorArrayId",n,e,t),s=w("index",n,e,t),a=w("tensor",n,e,t),o=t.getTensorArray(r.id);return o.write(s,a),[o.idTensor]}case"TensorArrayReadV3":{const r=w("tensorArrayId",n,e,t),s=w("index",n,e,t);return[t.getTensorArray(r.id).read(s)]}case"TensorArrayGatherV3":{const r=w("tensorArrayId",n,e,t),s=w("indices",n,e,t),a=w("dtype",n,e,t);return[t.getTensorArray(r.id).gather(s,a)]}case"TensorArrayScatterV3":{const r=w("tensorArrayId",n,e,t),s=w("indices",n,e,t),a=w("tensor",n,e,t),o=t.getTensorArray(r.id);return o.scatter(s,a),[o.idTensor]}case"TensorArrayConcatV3":{const r=w("tensorArrayId",n,e,t),s=t.getTensorArray(r.id),a=w("dtype",n,e,t);return[s.concat(a)]}case"TensorArraySplitV3":{const r=w("tensorArrayId",n,e,t),s=w("tensor",n,e,t),a=w("lengths",n,e,t),o=t.getTensorArray(r.id);return o.split(a,s),[o.idTensor]}case"TensorArraySizeV3":{const r=w("tensorArrayId",n,e,t),s=t.getTensorArray(r.id);return[Re(s.size(),"int32")]}case"TensorArrayCloseV3":{const r=w("tensorArrayId",n,e,t),s=t.getTensorArray(r.id);return s.clearAndClose(),[s.idTensor]}case"TensorListSetItem":{const r=w("tensorListId",n,e,t),s=w("index",n,e,t),a=w("tensor",n,e,t),o=t.getTensorList(r.id);return o.setItem(s,a),[o.idTensor]}case"TensorListGetItem":{const r=w("tensorListId",n,e,t),s=w("index",n,e,t),a=w("elementShape",n,e,t),o=w("elementDType",n,e,t);return[t.getTensorList(r.id).getItem(s,a,o)]}case"TensorListScatterV2":case"TensorListScatter":{const r=w("indices",n,e,t),s=w("tensor",n,e,t),a=w("elementShape",n,e,t),o=w("numElements",n,e,t),i=XH(s,r,a,o);return t.addTensorList(i),[i.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=w("elementShape",n,e,t),s=w("elementDType",n,e,t);let a;n.op==="TensorListReserve"?a="numElements":a="maxNumElements";const o=w(a,n,e,t),i=n.op==="TensorListReserve"?-1:o,c=KH(r,s,o,i);return t.addTensorList(c),[c.idTensor]}case"TensorListGather":{const r=w("tensorListId",n,e,t),s=w("indices",n,e,t),a=w("elementShape",n,e,t),o=w("elementDType",n,e,t);return[t.getTensorList(r.id).gather(s,o,a)]}case"TensorListStack":{const r=w("tensorListId",n,e,t),s=w("elementShape",n,e,t),a=w("elementDType",n,e,t),o=w("numElements",n,e,t);return[t.getTensorList(r.id).stack(s,a,o)]}case"TensorListFromTensor":{const r=w("tensor",n,e,t),s=w("elementShape",n,e,t),a=w("elementDType",n,e,t),o=qH(r,s,a);return t.addTensorList(o),[o.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=w("tensorListId",n,e,t),s=t.getTensorList(r.id),a=w("dtype",n,e,t),o=w("elementShape",n,e,t);return[s.concat(a,o)]}case"TensorListPushBack":{const r=w("tensorListId",n,e,t),s=w("tensor",n,e,t),a=t.getTensorList(r.id);return a.pushBack(s),[a.idTensor]}case"TensorListPopBack":{const r=w("tensorListId",n,e,t),s=w("elementShape",n,e,t),a=w("elementDType",n,e,t);return[t.getTensorList(r.id).popBack(s,a)]}case"TensorListSplit":{const r=w("tensor",n,e,t),s=w("elementShape",n,e,t),a=w("lengths",n,e,t),o=YH(r,a,s);return t.addTensorList(o),[o.idTensor]}case"TensorListLength":{const r=w("tensorListId",n,e,t),s=t.getTensorList(r.id);return[Re(s.size(),"int32")]}case"TensorListResize":{const r=w("tensorListId",n,e,t),s=w("size",n,e,t),o=t.getTensorList(r.id).resize(s);return t.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17667 * @license 17668 * Copyright 2018 Google LLC. All Rights Reserved. 17669 * Licensed under the Apache License, Version 2.0 (the "License");
17670 * you may not use this file except in compliance with the License. 17671 * You may obtain a copy of the License at 17672 * 17673 * http://www.apache.org/licenses/LICENSE-2.0 17674 * 17675 * Unless required by applicable law or agreed to in writing, software 17676 * distributed under the License is distributed on an "AS IS" BASIS, 17677 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17678 * See the License for the specific language governing permissions and 17679 * limitations under the License. 17680 * ============================================================================= 17681 */function Rf(n,e,t){const[r,s]=w("fusedOps",n,e,t),a=r==="biasadd",o=!a,i=s==="prelu",c=r==="fusedbatchnorm",l=w("numArgs",n,e,t);if(a){if(i&&l!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&a&&l!==1)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(c)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const u=w("strides",n,e,t),d=mi(n,e,t),p=w("dataFormat",n,e,t).toUpperCase(),h=w("dilations",n,e,t);let[m,g]=w("args",n,e,t);o&&(g=m,m=void 0);const y=w("leakyreluAlpha",n,e,t);return{stride:u,pad:d,dataFormat:p,dilations:h,biasArg:m,preluArg:g,activationFunc:s,leakyreluAlpha:y}}const ZH=(n,e,t,r=_t)=>{switch(n.op){case"Conv1D":{const s=w("stride",n,e,t),a=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),s,a,o,i)]}case"Conv2D":{const s=w("strides",n,e,t),a=mi(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),[s[1],s[2]],a,o,[i[1],i[2]])]}case"_FusedConv2D":{const{stride:s,pad:a,dataFormat:o,dilations:i,biasArg:c,preluArg:l,activationFunc:u,leakyreluAlpha:d}=Rf(n,e,t);return[r.fused.conv2d({x:w("x",n,e,t),filter:w("filter",n,e,t),strides:[s[1],s[2]],pad:a,dataFormat:o,dilations:[i[1],i[2]],bias:c,activation:u,preluActivationWeights:l,leakyreluAlpha:d})]}case"FusedDepthwiseConv2dNative":{const{stride:s,pad:a,dataFormat:o,dilations:i,biasArg:c,preluArg:l,activationFunc:u,leakyreluAlpha:d}=Rf(n,e,t);return[r.fused.depthwiseConv2d({x:w("x",n,e,t),filter:w("filter",n,e,t),strides:[s[1],s[2]],pad:a,dataFormat:o,dilations:[i[1],i[2]],bias:c,activation:u,preluActivationWeights:l,leakyreluAlpha:d})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const s=w("outputShape",n,e,t),a=w("strides",n,e,t),o=mi(n,e,t);return[r.conv2dTranspose(w("x",n,e,t),w("filter",n,e,t),s,[a[1],a[2]],o)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const s=w("strides",n,e,t),a=mi(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),[s[1],s[2]],a,i,[o[1],o[2]])]}case"Conv3D":{const s=w("strides",n,e,t),a=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),[s[1],s[2],s[3]],a,o,[i[1],i[2],i[3]])]}case"AvgPool":{const s=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[r.avgPool(w("x",n,e,t),[o[1],o[2]],[s[1],s[2]],a)]}case"MaxPool":{const s=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[r.maxPool(w("x",n,e,t),[o[1],o[2]],[s[1],s[2]],a)]}case"MaxPoolWithArgmax":{const s=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t),i=w("includeBatchInIndex",n,e,t),{result:c,indexes:l}=r.maxPoolWithArgmax(w("x",n,e,t),[o[1],o[2]],[s[1],s[2]],a,i);return[c,l]}case"AvgPool3D":{const s=w("strides",n,e,t),a=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]],[s[1],s[2],s[3]],a)]}case"MaxPool3D":{const s=w("strides",n,e,t),a=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]],[s[1],s[2],s[3]],a)]}case"Dilation2D":{const s=w("strides",n,e,t),a=w("pad",n,e,t),o=w("dilations",n,e,t),i=s[1],c=s[2],l=o[1],u=o[2];return[r.dilation2d(w("x",n,e,t),w("filter",n,e,t),[i,c],a,[l,u],"NHWC")]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17682 * @license 17683 * Copyright 2018 Google LLC. All Rights Reserved. 17684 * Licensed under the Apache License, Version 2.0 (the "License");
17685 * you may not use this file except in compliance with the License. 17686 * You may obtain a copy of the License at 17687 * 17688 * http://www.apache.org/licenses/LICENSE-2.0 17689 * 17690 * Unless required by applicable law or agreed to in writing, software 17691 * distributed under the License is distributed on an "AS IS" BASIS, 17692 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17693 * See the License for the specific language governing permissions and 17694 * limitations under the License. 17695 * ============================================================================= 17696 */const JH=(n,e,t,r=_t)=>{switch(n.op){case"Fill":{const s=w("shape",n,e,t),a=w("dtype",n,e,t),o=w("value",n,e,t);return[r.fill(s,o,a)]}case"LinSpace":{const s=w("start",n,e,t),a=w("stop",n,e,t),o=w("num",n,e,t);return[r.linspace(s,a,o)]}case"Multinomial":{const s=w("logits",n,e,t),a=w("numSamples",n,e,t),o=w("seed",n,e,t);return[r.multinomial(s,a,o)]}case"OneHot":{const s=w("indices",n,e,t),a=w("depth",n,e,t),o=w("onValue",n,e,t),i=w("offValue",n,e,t),c=w("dtype",n,e,t);return[r.oneHot(s,a,o,i,c)]}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"RandomUniformInt":return[r.randomUniformInt(w("shape",n,e,t),w("minval",n,e,t),w("maxval",n,e,t),w("seed",n,e,t))];case"Range":{const s=w("start",n,e,t),a=w("stop",n,e,t),o=w("step",n,e,t);return[r.range(s,a,o,w("dtype",n,e,t))]}case"TruncatedNormal":{const s=w("shape",n,e,t),a=w("mean",n,e,t),o=w("stdDev",n,e,t),i=w("seed",n,e,t);return[r.truncatedNormal(s,a,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`)}};/** 17697 * @license 17698 * Copyright 2018 Google LLC. All Rights Reserved. 17699 * Licensed under the Apache License, Version 2.0 (the "License"); 17700 * you may not use this file except in compliance with the License. 17701 * You may obtain a copy of the License at 17702 * 17703 * http://www.apache.org/licenses/LICENSE-2.0 17704 * 17705 * Unless required by applicable law or agreed to in writing, software 17706 * distributed under the License is distributed on an "AS IS" BASIS, 17707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17708 * See the License for the specific language governing permissions and 17709 * limitations under the License. 17710 * ============================================================================= 17711 */function $c(n,e,t){const r=w("boxes",n,e,t),s=w("scores",n,e,t),a=w("maxOutputSize",n,e,t),o=w("iouThreshold",n,e,t),i=w("scoreThreshold",n,e,t),c=w("softNmsSigma",n,e,t);return{boxes:r,scores:s,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:c}}const ej=async(n,e,t,r,s=_t)=>{switch(n.op){case"NonMaxSuppressionV5":{const{boxes:a,scores:o,maxOutputSize:i,iouThreshold:c,scoreThreshold:l,softNmsSigma:u}=$c(n,e,t),d=await s.image.nonMaxSuppressionWithScoreAsync(a,o,i,c,l,u);return[d.selectedIndices,d.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:a,scores:o,maxOutputSize:i,iouThreshold:c,scoreThreshold:l}=$c(n,e,t),u=w("padToMaxOutputSize",n,e,t),d=await s.image.nonMaxSuppressionPaddedAsync(a,o,i,c,l,u);return[d.selectedIndices,d.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:a,scores:o,maxOutputSize:i,iouThreshold:c,scoreThreshold:l}=$c(n,e,t);return[await s.image.nonMaxSuppressionAsync(a,o,i,c,l)]}case"Where":{const a=s.cast(w("condition",n,e,t),"bool"),o=[await s.whereAsync(a)];return a.dispose(),o}case"ListDiff":return s.setdiff1dAsync(w("x",n,e,t),w("y",n,e,t));default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17712 * @license 17713 * Copyright 2018 Google LLC. All Rights Reserved. 17714 * Licensed under the Apache License, Version 2.0 (the "License"); 17715 * you may not use this file except in compliance with the License. 17716 * You may obtain a copy of the License at 17717 * 17718 * http://www.apache.org/licenses/LICENSE-2.0 17719 * 17720 * Unless required by applicable law or agreed to in writing, softw
17720are 17721 * distributed under the License is distributed on an "AS IS" BASIS, 17722 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17723 * See the License for the specific language governing permissions and 17724 * limitations under the License. 17725 * ============================================================================= 17726 */const tj=(n,e,t,r=_t)=>{switch(n.op){case"LowerBound":{const s=w("sortedSequence",n,e,t),a=w("values",n,e,t);return[r.lowerBound(s,a)]}case"TopKV2":{const s=w("x",n,e,t),a=w("k",n,e,t),o=w("sorted",n,e,t),i=r.topk(s,a,o);return[i.values,i.indices]}case"UpperBound":{const s=w("sortedSequence",n,e,t),a=w("values",n,e,t);return[r.upperBound(s,a)]}case"Unique":{const s=w("x",n,e,t),a=r.unique(s);return[a.values,a.indices]}case"UniqueV2":{const s=w("x",n,e,t),a=w("axis",n,e,t),o=r.unique(s,a);return[o.values,o.indices]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17727 * @license 17728 * Copyright 2018 Google LLC. All Rights Reserved. 17729 * Licensed under the Apache License, Version 2.0 (the "License"); 17730 * you may not use this file except in compliance with the License. 17731 * You may obtain a copy of the License at 17732 * 17733 * http://www.apache.org/licenses/LICENSE-2.0 17734 * 17735 * Unless required by applicable law or agreed to in writing, software 17736 * distributed under the License is distributed on an "AS IS" BASIS, 17737 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17738 * See the License for the specific language governing permissions and 17739 * limitations under the License. 17740 * ============================================================================= 17741 */const nj=(n,e,t,r=_t)=>{switch(n.op){case"Const":return e[n.name];case"PlaceholderWithDefault":const s=w("default",n,e,t);return[vt(n.name,e,t)||s];case"Placeholder":return[vt(n.name,e,t)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{const u=w("x",n,e,t);return[gr(u)]}case"IdentityN":return w("x",n,e,t).map(u=>gr(u));case"Snapshot":const a=w("x",n,e,t);return[gr(a)];case"Shape":return[r.tensor1d(w("x",n,e,t).shape,"int32")];case"ShapeN":return w("x",n,e,t).map(u=>r.tensor1d(u.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),c=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(c);for(let u=0;u<i.length;u++)console.log(Array.prototype.slice.call(i[u].dataSync()).slice(0,l));return[o];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17742 * @license 17743 * Copyright 2020 Google LLC. All Rights Reserved. 17744 * Licensed under the Apache License, Version 2.0 (the "License"); 17745 * you may not use this file except in compliance with the License. 17746 * You may obtain a copy of the License at 17747 * 17748 * http://www.apache.org/licenses/LICENSE-2.0 17749 * 17750 * Unless required by applicable law or agreed to in writing, software 17751 * distributed under the License is distributed on an "AS IS" BASIS, 17752 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17753 * See the License for the specific language governing permissions and 17754 * limitations under the License. 17755 * ============================================================================= 17756 */class rj{get id(){return this.handle.id}constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Re(0),this.tensorMap=new Map,rr(this.handle)}clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Re(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const r=await e.data();return this.tensorMap.forEach(s=>s.dispose()),this.tensorMap.clear(),Ne(()=>{const s=Bs(t),a=r.length,o=s.length;N(a===o,()=>`The number of elements doesn't match, keys has ${a} elements, the values has ${o} elements.`);for(let i=0;i<a;i++){const c=r[i],l=s[i];rr(l),this.tensorMap.set(c,l)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);const r=await e.data();return Ne(()=>{const s=[];for(let a=0;a<r.length;a++){const o=r[a],i=this.findWithDefault(o,t);s.push(i)}return vr(s)})}findWithDefault(e,t){const r=this.tensorMap.get(e);return r!=null?r: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}`)}}/** 17757 * @license 17758 * Copyright 2020 Google LLC. All Rights Reserved. 17759 * Licensed under the Apache License, Version 2.0 (the "License");
17760 * you may not use this file except in compliance with the License. 17761 * You may obtain a copy of the License at 17762 * 17763 * http://www.apache.org/licenses/LICENSE-2.0 17764 * 17765 * Unless required by applicable law or agreed to in writing, software 17766 * distributed under the License is distributed on an "AS IS" BASIS, 17767 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17768 * See the License for the specific language governing permissions and 17769 * limitations under the License. 17770 * ============================================================================= 17771 */const sj=async(n,e,t,r)=>{switch(n.op){case"HashTable":case"HashTableV2":{const s=r.getHashTableHandleByName(n.name);if(s!=null)return[s];{const a=w("keyDType",n,e,t),o=w("valueDType",n,e,t),i=new rj(a,o);return r.addHashTable(n.name,i),[i.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{const s=w("tableHandle",n,e,t,r),a=w("keys",n,e,t),o=w("values",n,e,t);return[await r.getHashTableById(s.id).import(a,o)]}case"LookupTableFind":case"LookupTableFindV2":{const s=w("tableHandle",n,e,t,r),a=w("keys",n,e,t),o=w("defaultValue",n,e,t);return[await r.getHashTableById(s.id).find(a,o)]}case"LookupTableSize":case"LookupTableSizeV2":{const s=w("tableHandle",n,e,t,r);return[r.getHashTableById(s.id).tensorSize()]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17772 * @license 17773 * Copyright 2018 Google LLC. All Rights Reserved. 17774 * Licensed under the Apache License, Version 2.0 (the "License"); 17775 * you may not use this file except in compliance with the License. 17776 * You may obtain a copy of the License at 17777 * 17778 * http://www.apache.org/licenses/LICENSE-2.0 17779 * 17780 * Unless required by applicable law or agreed to in writing, software 17781 * distributed under the License is distributed on an "AS IS" BASIS, 17782 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17783 * See the License for the specific language governing permissions and 17784 * limitations under the License. 17785 * ============================================================================= 17786 */const aj=(n,e,t,r=_t)=>{switch(n.op){case"ResizeBilinear":{const s=w("images",n,e,t),a=w("size",n,e,t),o=w("alignCorners",n,e,t),i=w("halfPixelCenters",n,e,t);return[r.image.resizeBilinear(s,[a[0],a[1]],o,i)]}case"ResizeNearestNeighbor":{const s=w("images",n,e,t),a=w("size",n,e,t),o=w("alignCorners",n,e,t),i=w("halfPixelCenters",n,e,t);return[r.image.resizeNearestNeighbor(s,[a[0],a[1]],o,i)]}case"CropAndResize":{const s=w("image",n,e,t),a=w("boxes",n,e,t),o=w("boxInd",n,e,t),i=w("cropSize",n,e,t),c=w("method",n,e,t),l=w("extrapolationValue",n,e,t);return[r.image.cropAndResize(s,a,o,i,c,l)]}case"ImageProjectiveTransformV3":{const s=w("images",n,e,t),a=w("transforms",n,e,t),o=w("outputShape",n,e,t),i=w("fillValue",n,e,t),c=w("interpolation",n,e,t),l=w("fillMode",n,e,t);return[r.image.transform(s,a,c.toLowerCase(),l.toLowerCase(),i,o)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17787 * @license 17788 * Copyright 2018 Google LLC. All Rights Reserved. 17789 * Licensed under the Apache License, Version 2.0 (the "License"); 17790 * you may not use this file except in compliance with the License. 17791 * You may obtain a copy of the License at 17792 * 17793 * http://www.apache.org/licenses/LICENSE-2.0 17794 * 17795 * Unless required by applicable law or agreed to in writing, software 17796 * distributed under the License is distributed on an "AS IS" BASIS, 17797 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17798 * See the License for the specific language governing permissions and 17799 * limitations under the License. 17800 * ============================================================================= 17801 */const oj=(n,e,t,r=_t)=>{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))];case"BitwiseAnd":return[r.bitwiseAnd(w("a",n,e,t),w("b",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17802 * @license 17803 * Copyright 2018 Google LLC. All Rights Reserved. 17804 * Licensed under the Apache License, Version 2.0 (the "License");
17805 * you may not use this file except in compliance with the License. 17806 * You may obtain a copy of the License at 17807 * 17808 * http://www.apache.org/licenses/LICENSE-2.0 17809 * 17810 * Unless required by applicable law or agreed to in writing, software 17811 * distributed under the License is distributed on an "AS IS" BASIS, 17812 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17813 * See the License for the specific language governing permissions and 17814 * limitations under the License. 17815 * ============================================================================= 17816 */const ij=(n,e,t,r=_t)=>{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[s,a]=w("fusedOps",n,e,t),o=s==="biasadd",i=a==="prelu",c=w("numArgs",n,e,t),l=w("leakyreluAlpha",n,e,t);if(o){if(i&&c!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&c!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[u,d]=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:u,activation:a,preluActivationWeights:d,leakyreluAlpha:l})];case"MatrixBandPart":return[r.linalg.bandPart(w("a",n,e,t),w("numLower",n,e,t),w("numUpper",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17817 * @license 17818 * Copyright 2018 Google LLC. All Rights Reserved. 17819 * Licensed under the Apache License, Version 2.0 (the "License"); 17820 * you may not use this file except in compliance with the License. 17821 * You may obtain a copy of the License at 17822 * 17823 * http://www.apache.org/licenses/LICENSE-2.0 17824 * 17825 * Unless required by applicable law or agreed to in writing, software 17826 * distributed under the License is distributed on an "AS IS" BASIS, 17827 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17828 * See the License for the specific language governing permissions and 17829 * limitations under the License. 17830 * ============================================================================= 17831 */const uj=(n,e,t,r=_t)=>{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))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17832 * @license 17833 * Copyright 2022 Google LLC. All Rights Reserved. 17834 * Licensed under the Apache License, Version 2.0 (the "License"); 17835 * you may not use this file except in compliance with the License. 17836 * You may obtain a copy of the License at 17837 * 17838 * http://www.apache.org/licenses/LICENSE-2.0 17839 * 17840 * Unless required by applicable law or agreed to in writing, software 17841 * distributed under the License is distributed on an "AS IS" BASIS, 17842 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17843 * See the License for the specific language governing permissions and 17844 * limitations under the License. 17845 * ============================================================================= 17846 */const cj=(n,e,t,r=_t)=>{switch(n.op){case"RaggedGather":{const{outputNestedSplits:s,outputDenseValues:a}=r.raggedGather(w("paramsNestedSplits",n,e,t),w("paramsDenseValues",n,e,t),w("indices",n,e,t),w("outputRaggedRank",n,e,t));return s.concat(a)}case"RaggedRange":{const{rtNestedSplits:s,rtDenseValues:a}=r.raggedRange(w("starts",n,e,t),w("limits",n,e,t),w("splits",n,e,t));return[s,a]}case"RaggedTensorToTensor":return[r.raggedTensorToTensor(w("shape",n,e,t),w("values",n,e,t),w("defaultValue",n,e,t),w("rowPartitionTensors",n,e,t),w("rowPartitionTypes",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17847 * @license 17848 * Copyright 2018 Google LLC. All Rights Reserved. 17849 * Licensed under the Apache License, Version 2.0 (the "License");
17850 * you may not use this file except in compliance with the License. 17851 * You may obtain a copy of the License at 17852 * 17853 * http://www.apache.org/licenses/LICENSE-2.0 17854 * 17855 * Unless required by applicable law or agreed to in writing, software 17856 * distributed under the License is distributed on an "AS IS" BASIS, 17857 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17858 * See the License for the specific language governing permissions and 17859 * limitations under the License. 17860 * ============================================================================= 17861 */const lj=(n,e,t,r=_t)=>{switch(n.op){case"Max":{const i=w("axis",n,e,t),c=w("keepDims",n,e,t);return[r.max(w("x",n,e,t),i,c)]}case"Mean":{const i=w("axis",n,e,t),c=w("keepDims",n,e,t);return[r.mean(w("x",n,e,t),i,c)]}case"Min":{const i=w("axis",n,e,t),c=w("keepDims",n,e,t);return[r.min(w("x",n,e,t),i,c)]}case"Sum":{const i=w("axis",n,e,t),c=w("keepDims",n,e,t);return[r.sum(w("x",n,e,t),i,c)]}case"All":{const i=w("axis",n,e,t),c=w("keepDims",n,e,t);return[r.all(w("x",n,e,t),i,c)]}case"Any":{const i=w("axis",n,e,t),c=w("keepDims",n,e,t);return[r.any(w("x",n,e,t),i,c)]}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),c=w("keepDims",n,e,t);return[r.prod(w("x",n,e,t),i,c)]}case"Cumprod":{const i=w("axis",n,e,t),c=w("exclusive",n,e,t),l=w("reverse",n,e,t);return[r.cumprod(w("x",n,e,t),i,c,l)]}case"Cumsum":{const i=w("axis",n,e,t),c=w("exclusive",n,e,t),l=w("reverse",n,e,t);return[r.cumsum(w("x",n,e,t),i,c,l)]}case"Bincount":const s=w("x",n,e,t),a=w("weights",n,e,t),o=w("size",n,e,t);return[r.bincount(s,a,o)];case"DenseBincount":{const i=w("x",n,e,t),c=w("weights",n,e,t),l=w("size",n,e,t),u=w("binaryOutput",n,e,t);return[r.denseBincount(i,c,l,u)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17862 * @license 17863 * Copyright 2018 Google LLC. All Rights Reserved. 17864 * Licensed under the Apache License, Version 2.0 (the "License"); 17865 * you may not use this file except in compliance with the License. 17866 * You may obtain a copy of the License at 17867 * 17868 * http://www.apache.org/licenses/LICENSE-2.0 17869 * 17870 * Unless required by applicable law or agreed to in writing, software 17871 * distributed under the License is distributed on an "AS IS" BASIS, 17872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17873 * See the License for the specific language governing permissions and 17874 * limitations under the License. 17875 * ============================================================================= 17876 */const dj=(n,e,t,r=_t)=>{switch(n.op){case"ConcatV2":case"Concat":{const s=w("n",n,e,t),a=w("axis",n,e,t);let o=w("tensors",n,e,t);return o=o.slice(0,s),[r.concat(o,a)]}case"Gather":{const s=w("x",n,e,t),a=w("indices",n,e,t);return[r.gather(s,r.cast(a,"int32"),0)]}case"GatherV2":{const s=w("axis",n,e,t),a=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"),s,a)]}case"Reverse":{const s=w("dims",n,e,t),a=[];for(let i=0;i<s.length;i++)s[i]&&a.push(i);const o=w("x",n,e,t);return[r.reverse(o,a)]}case"ReverseV2":{const s=w("axis",n,e,t),a=w("x",n,e,t);return[r.reverse(a,s)]}case"Slice":{const s=w("begin",n,e,t),a=w("size",n,e,t);return[r.slice(w("x",n,e,t),s,a)]}case"StridedSlice":{const s=w("begin",n,e,t),a=w("end",n,e,t),o=w("strides",n,e,t),i=w("beginMask",n,e,t),c=w("endMask",n,e,t),l=w("ellipsisMask",n,e,t),u=w("newAxisMask",n,e,t),d=w("shrinkAxisMask",n,e,t),p=w("x",n,e,t);return[r.stridedSlice(p,s,a,o,i,c,l,u,d)]}case"Pack":return Ne(()=>{const s=w("axis",n,e,t),a=w("tensors",n,e,t),o=a[0].shape,i=r.squeeze(a[0]).shape,c=a.map(l=>{const u=st(l.shape,o);if(!u&&!st(r.squeeze(l).shape,i))throw new Error("the input tensors shape does not match");return u?l:r.reshape(l,o)});return[r.stack(c,s)]});case"Unpack":{const s=w("axis",n,e,t),a=w("tensor",n,e,t);return r.unstack(a,s)}case"Tile":{const s=w("reps",n,e,t);return[r.tile(w("x",n,e,t),s)]}case"Split":case"SplitV":{const s=w("axis",n,e,t),a=w("numOrSizeSplits",n,e,t),o=w("x",n,e,t);return r.split(o,a,s)}case"ScatterNd":{const s=w("indices",n,e,t),a=w("values",n,e,t),o=w("shape",n,e,t);return[r.scatterND(s,a,o)]}case"GatherNd":{const s=w("x",n,e,t),a=w("indices",n,e,t);return[r.gatherND(s,a)]}case"SparseToDense":{const s=w("sparseIndices",n,e,t),a=w("outputShape",n,e,t),o=w("sparseValues",n,e,t),i=w("defaultValue",n,e,t);return[r.sparseToDense(s,o,a,o.dtype===i.dtype?i:r.cast(i,o.dtype))]}case"TensorScatterUpdate":{const s=w("indices",n,e,t),a=w("values",n,e,t),o=w("tensor",n,e,t);return[r.tensorScatterUpdate(o,s,a)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/** 17877 * @license 17878 * Copyright 2021 Google LLC. All Rights Reserved. 17879 * Licensed under the Apache License, Version 2.0 (the "License");
17880 * you may not use this file except in compliance with the License. 17881 * You may obtain a copy of the License at 17882 * 17883 * http://www.apache.org/licenses/LICENSE-2.0 17884 * 17885 * Unless required by applicable law or agreed to in writing, software 17886 * distributed under the License is distributed on an "AS IS" BASIS, 17887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17888 * See the License for the specific language governing permissions and 17889 * limitations under the License. 17890 * ============================================================================= 17891 */const pj=(n,e,t,r=_t)=>{switch(n.op){case"SparseFillEmptyRows":{const{outputIndices:s,outputValues:a,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[s,a,o,i]}case"SparseReshape":{const{outputIndices:s,outputShape:a}=r.sparse.sparseReshape(w("inputIndices",n,e,t),w("inputShape",n,e,t),w("newShape",n,e,t));return[s,a]}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`)}};/** 17892 * @license 17893 * Copyright 2018 Google LLC. All Rights Reserved. 17894 * Licensed under the Apache License, Version 2.0 (the "License"); 17895 * you may not use this file except in compliance with the License. 17896 * You may obtain a copy of the License at 17897 * 17898 * http://www.apache.org/licenses/LICENSE-2.0 17899 * 17900 * Unless required by applicable law or agreed to in writing, software 17901 * distributed under the License is distributed on an "AS IS" BASIS, 17902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17903 * See the License for the specific language governing permissions and 17904 * limitations under the License. 17905 * ============================================================================= 17906 */const hj=(n,e,t,r=_t)=>{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`)}};/** 17907 * @license 17908 * Copyright 2021 Google LLC. All Rights Reserved. 17909 * Licensed under the Apache License, Version 2.0 (the "License"); 17910 * you may not use this file except in compliance with the License. 17911 * You may obtain a copy of the License at 17912 * 17913 * http://www.apache.org/licenses/LICENSE-2.0 17914 * 17915 * Unless required by applicable law or agreed to in writing, software 17916 * distributed under the License is distributed on an "AS IS" BASIS, 17917 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17918 * See the License for the specific language governing permissions and 17919 * limitations under the License. 17920 * ============================================================================= 17921 */const fj=(n,e,t,r=_t)=>{switch(n.op){case"StaticRegexReplace":return[r.string.staticRegexReplace(w("input",n,e,t),w("pattern",n,e,t),w("rewrite",n,e,t),w("replaceGlobal",n,e,t))];case"StringNGrams":{const{nGrams:s,nGramsSplits:a}=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[s,a]}case"StringSplit":{const{indices:s,values:a,shape:o}=r.string.stringSplit(w("input",n,e,t),w("delimiter",n,e,t),w("skipEmpty",n,e,t));return[s,a,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`)}};/** 17922 * @license 17923 * Copyright 2018 Google LLC. All Rights Reserved. 17924 * Licensed under the Apache License, Version 2.0 (the "License"); 17925 * you may not use this file except in compliance with the License. 17926 * You may obtain a copy of the License at 17927 * 17928 * http://www.apache.org/licenses/LICENSE-2.0 17929 * 17930 * Unless required by applicable law or agreed to in writing, software 17931 * distributed under the License is distributed on an "AS IS" BASIS, 17932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17933 * See the License for the specific language governing permissions and 17934 * limitations under the License. 17935 * ============================================================================= 17936 */const mj=(n,e,t,r=_t)=>{switch(n.op){case"Cast":return[r.cast(w("x",n,e,t),w("dtype",n,e,t))];case"ExpandDims":{const s=w("axis",n,e,t);return[r.expandDims(w("x",n,e,t),s)]}case"Squeeze":{const s=w("axis",n,e,t);return[r.squeeze(w("x",n,e,t),s)]}case"Reshape":return[r.reshape(w("x",n,e,t),w("shape",n,e,t))];case"EnsureShape":return[r.ensureShape(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))];
vendor: 4,720 bytes, lines 17936-17954
17936case"SpaceToBatchND":{const s=w("blockShape",n,e,t),a=w("paddings",n,e,t);return[r.spaceToBatchND(w("x",n,e,t),s,a)]}case"BatchToSpaceND":{const s=w("blockShape",n,e,t),a=w("crops",n,e,t);return[r.batchToSpaceND(w("x",n,e,t),s,a)]}case"DepthToSpace":{const s=w("blockSize",n,e,t),a=w("dataFormat",n,e,t).toUpperCase();return[r.depthToSpace(w("x",n,e,t),s,a)]}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`)}};/** 17937 * @license 17938 * Copyright 2018 Google LLC. All Rights Reserved. 17939 * Licensed under the Apache License, Version 2.0 (the "License"); 17940 * you may not use this file except in compliance with the License. 17941 * You may obtain a copy of the License at 17942 * 17943 * http://www.apache.org/licenses/LICENSE-2.0 17944 * 17945 * Unless required by applicable law or agreed to in writing, software 17946 * distributed under the License is distributed on an "AS IS" BASIS, 17947 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17948 * See the License for the specific language governing permissions and 17949 * limitations under the License. 17950 * ============================================================================= 17951 */function Af(n,e,t,r,s=Ne){const a=((o,i,c)=>{switch(o.category){case"arithmetic":return s(()=>GH(o,i,c));case"basic_math":return s(()=>HH(o,i,c));case"control":return QH(o,i,c);case"convolution":return s(()=>ZH(o,i,c));case"creation":return s(()=>JH(o,i,c));case"dynamic":return ej(o,i,c);case"evaluation":return s(()=>tj(o,i,c));case"image":return s(()=>aj(o,i,c));case"graph":return s(()=>nj(o,i,c));case"logical":return s(()=>oj(o,i,c));case"matrices":return s(()=>ij(o,i,c));case"normalization":return s(()=>uj(o,i,c));case"ragged":return s(()=>cj(o,i,c));case"reduction":return s(()=>lj(o,i,c));case"slice_join":return s(()=>dj(o,i,c));case"sparse":return s(()=>pj(o,i,c));case"spectral":return s(()=>hj(o,i,c));case"string":return s(()=>fj(o,i,c));case"transformation":return s(()=>mj(o,i,c));case"hash_table":return sj(o,i,c,r);case"custom":const l=s0(o.op);if(l&&l.customExecutor)return l.customExecutor(new zH(o,i,c));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 Ss(a)?a.then(o=>[].concat(o)):[].concat(a)}class Df{constructor(e={},t={},r={},s={},a){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=r,this.functionMap=s,this.parseNodeNameCache=a,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){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)}}/** 17952 * @license 17953 * Copyright 2019 Google LLC. All Rights Reserved. 17954 * Licensed under the Apache License, Version 2.0 (the "License");
17955 * you may not use this file except in compliance with the License. 17956 * You may obtain a copy of the License at 17957 * 17958 * http://www.apache.org/licenses/LICENSE-2.0 17959 * 17960 * Unless required by applicable law or agreed to in writing, software 17961 * distributed under the License is distributed on an "AS IS" BASIS, 17962 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17963 * See the License for the specific language governing permissions and 17964 * limitations under the License. 17965 * ============================================================================= 17966 */function Of(n,e,t,r){const s=new Set,a=[];let o=null,i=null;const c=new Set,l=new Set(Object.keys(n).map(p=>tn(p)[0]));r=r||[];const u=new Set(r.map(p=>tn(p.name)[0])),d=[...e];for(;d.length>0;){const p=d.pop();if((ys(p)||$j(p)||Sj(p))&&o==null&&(o=p,i=o.children.map(h=>h.name).filter(h=>s.has(h))),s.add(p.name),t[p.name]==null&&!l.has(p.name)&&!u.has(p.name)){if(p.inputs.length===0){a.push(p.name);continue}p.inputs.forEach(h=>{c.has(h.name)||(c.add(h.name),d.push(h))})}}return{inputs:n,outputs:e,usedNodes:s,missingInputs:a,dynamicNode:o,syncInputs:i}}function gj(n,e){const{usedNodes:t,inputs:r}=e,s=Object.keys(r).map(y=>tn(y)[0]).map(y=>n.nodes[y]),a=n.initNodes||[],o=y=>t.has(typeof y=="string"?y:y.name);function i(y){return[...new Map(y.map(b=>[b.name,b])).values()]}const c=i([...s,...n.weights,...a]).filter(o),l=i([...c,...Object.values(n.nodes)]).filter(o),u=new Map(l.map(y=>[y.name,y])),d={};for(const y of l){d[y.name]=d[y.name]||0;for(const b of y.children)o(b)||(d[b.name]=Number.POSITIVE_INFINITY),d[b.name]=(d[b.name]||0)+1}const p=Object.entries(d).filter(([,y])=>y===0).map(([y])=>y),h=[...p];for(;p.length>0;){const y=p.pop(),b=u.get(y);for(const v of b.children.filter(o))--d[v.name]===0&&(h.push(v.name),p.push(v.name))}const m=h.map(y=>u.get(y)),g=yj(m,c);return bj(g,c),g}function yj(n,e){const t=new Map(n.map(o=>[o.name,o])),r=e.map(o=>o.name),s=new Set(r);for(;r.length>0;){const o=r.pop(),i=t.get(o);for(const c of i.children)!t.has(c.name)||s.has(c.name)||(s.add(c.name),r.push(c.name))}return n.filter(o=>s.has(o.name))}class di extends Error{constructor(e){super(`NodesExecutionOrderError: ${e}`)}}function bj(n,e){const t=new Map(n.map((i,c)=>[i.name,c])),r=new Set(e.map(i=>i.name)),s=i=>r.has(typeof i=="string"?i:i.name),a=new Set(n.map(i=>i.name)),o=i=>a.has(typeof i=="string"?i:i.name);for(const i of n){for(const c of i.children.filter(o)){if(!t.has(c.name))throw new di(`Child ${c.name} of node ${i.name} is unreachable.`);if(t.get(i.name)>t.get(c.name))throw new di(`Node ${i.name} is scheduled to run after its child ${c.name}.`)}if(!s(i))for(const c of i.inputs){if(!t.has(c.name))throw new di(`Input ${c.name} of node ${i.name} is unreachable.`);if(t.get(c.name)>t.get(i.name))throw new di(`Node ${i.name} is scheduled to run before its input ${c.name}.`)}}}function xj(n){const e=new Map(n.map((i,c)=>[i.name,c])),t=Number.MAX_SAFE_INTEGER,r=n.map((i,c)=>ys(i)?t:c),s=i=>{const c=r[e.get(i.name)];return c==null?-1:c},a=n.map((i,c)=>i.children.map(s).reduce((l,u)=>Math.max(l,u),r[c])),o=new Map;for(let i=0;i<n.length;++i){const c=a[i];if(c===t)continue;const l=n[i],u=n[c];o.has(u.name)||o.set(u.name,[]),o.get(u.name).push(l)}return o}const wj=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),vj=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),Ij=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function ys(n){return wj.has(n.op)}function $j(n){return vj.has(n.op)}function Sj(n){return Ij.has(n.op)}/** 17967 * @license 17968 * Copyright 2018 Google LLC. All Rights Reserved. 17969 * Licensed under the Apache License, Version 2.0 (the "License"); 17970 * you may not use this file except in compliance with the License. 17971 * You may obtain a copy of the License at 17972 * 17973 * http://www.apache.org/licenses/LICENSE-2.0 17974 * 17975 * Unless required by applicable law or agreed to in writing, software 17976 * distributed under the License is distributed on an "AS IS" BASIS, 17977 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17978 * See the License for the specific language governing permissions and 17979 * limitations under the License. 17980 * ============================================================================= 17981 */class Di{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(s=>s.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)=>
17981(e[t]=this._functions[t].signature,e),{})}constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this.parseNodeNameCache=new Map,this._weightMap={},this.SEPARATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,e.functions!=null&&Object.keys(e.functions).forEach(r=>{this._functionExecutorMap[r]=new Di(e.functions[r],this)})}getCompilationKey(e,t){const r=e.map(a=>a.name).sort(),s=t.map(a=>a.name).sort();return r.join(this.SEPARATOR)+"--"+s.join(this.SEPARATOR)}compile(e,t){const r=Of(e,t,this.weightMap,this._initNodes),{missingInputs:s,dynamicNode:a,syncInputs:o}=r;if(a!=null)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${o}]`);if(s.length>0){const l=t.map(d=>d.name),u=Object.keys(e);throw new Error(`Cannot compute the outputs [${l}] from the provided inputs [${u}]. Missing the following inputs: [${s}]`)}const i=gj(this.graph,r),c=xj(i);return{orderedNodes:i,nodeLiveUntilMap:c}}cloneAndKeepTensor(e){if(e==null)return null;const t=e.clone();return rr(t),t}cloneTensorList(e){return e?e.map(r=>this.cloneAndKeepTensor(r)):null}cloneTensorMap(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,this.cloneTensorList(r)]))}execute(e,t){this.disposeIntermediateTensors(),e=this.mapInputs(e);const r=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const s=r.map(p=>this.graph.nodes[tn(p)[0]]),a=t.map(p=>tn(p)[0]),o=new Set(a);let i=a.map(p=>this.graph.nodes[p]);i.length===0&&(i=this._outputs);const c=this.getCompilationKey(s,i);let l=this.compiledMap.get(c);l==null&&(l=this.compile(e,i),this.compiledMap.set(c,l));try{this.keepIntermediateTensors=U().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(p){this.keepIntermediateTensors=!1,console.warn(p.message)}const u={},d={};return Ne(()=>{const p=new Df(this.weightMap,u,d,this.functionExecutorMap,this.parseNodeNameCache),h=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(e).forEach(b=>{const[v,$]=tn(b,p),S=[];S[$]=e[b],h[v]=S,this.keepIntermediateTensors&&(this.clonedTensorsMap[v]=this.cloneTensorList(S))});const m=this.getFrozenTensorIds(h),{orderedNodes:g,nodeLiveUntilMap:y}=l;for(const b of g){if(h[b.name])continue;const v=Af(b,h,p,this._resourceManager);if(Ss(v))throw new Error(`The execution of the op '${b.op}' returned a promise. Please use model.executeAsync() instead.`);h[b.name]=v,this.keepIntermediateTensors&&(this.clonedTensorsMap[b.name]=this.cloneTensorList(v)),this.checkTensorForDisposalWithNodeLiveUntilInfo(b,h,p,m,o,y.get(b.name))}return this.parent==null&&p.dispose(m),t.map(b=>vt(b,h,p))})}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map(r=>e[r]).map(r=>r.map(s=>s.id)));return new Set(t)}checkTensorForDisposal(e,t,r,s,a,o,i){if(!(ys(t)||o.has(e))){for(const c of r[e])c!=null&&(i[c.id]=(i[c.id]||0)+t.children.length);for(const c of t.inputs){if(ys(c))continue;const l=Nf(c.name,r,s);if(l!=null)for(const u of l){if(!u||u.kept||a.has(u.id))continue;const d=i[u.id];d===1?(u.dispose(),delete i[u.id]):d!=null&&i[u.id]--}}}}checkTensorForDisposalWithNodeLiveUntilInfo(e,t,r,s,a,o){function i(c){return ys(c)||a.has(c.name)}if(!(ys(e)||o==null))for(const c of o){if(i(c))continue;const l=Nf(c.name,t,r);for(const u of l)!u||u.kept||s.has(u.id)||u.dispose()}}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){!this.clonedTensorsMap||(Object.values(this.clonedTensorsMap).forEach(e=>{for(const t of e)t&&!t.isDisposed&&t.dispose()}),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(e,t,r=!1,s={},a={}){this.disposeIntermediateTensors(),r||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepIntermediateTensors=U().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(p){this.keepIntermediateTensors=!1,console.warn(p.message)}const o=new Df(this.weightMap,s,a,this.functionExecutorMap,this.parseNodeNameCache);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));const i=await this.executeWithControlFlow(e,o,t,r),c=t.map(p=>vt(p,i,o)),l=c.map(p=>p.id),u=Object.keys(e).map(p=>e[p].id),d=new Set([...l,...u,...this.weightIds]);
vendor: 4,483 bytes, lines 17981-17984
17981return Object.values(i).forEach(p=>{p.forEach(h=>{h&&!h.isDisposed&&!d.has(h.id)&&h.dispose()})}),this.parent==null&&o.dispose(d),c}async executeFunctionAsync(e,t,r){const s=e.reduce((a,o,i)=>(a[this.inputs[i].name]=o,a),{});return this._executeAsync(s,this.outputNodes,!0,t,r)}async executeWithControlFlow(e,t,r,s){const a=Object.keys(e),o=a.map(S=>this.graph.nodes[tn(S)[0]]),i=r.map(S=>tn(S)[0]),c=new Set(i);let l=i.map(S=>this.graph.nodes[S]);l.length===0&&(l=this._outputs);const{usedNodes:u,missingInputs:d,dynamicNode:p,syncInputs:h}=Of(e,l,this.weightMap,this._initNodes),m=[...o,...this.graph.weights,...this._initNodes||[]].map(S=>({node:S,contexts:t.currentContext})),g=Object.assign({},this.weightMap);Object.keys(e).forEach(S=>{const[T,O]=tn(S),L=[];L[O]=e[S],g[T]=L});const y={},b=this.getFrozenTensorIds(g),v={};for(;m.length>0;){const S=this.processStack(o,m,t,g,v,b,c,y,u);await Promise.all(S)}p==null&&!s&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const $=l.filter(S=>!ys(S)&&!vt(S.name,g,t)).map(S=>S.name);if($.length>0){let S="";throw p!=null&&(S=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${h}]`),new Error(`Cannot compute the outputs [${$}] from the provided inputs [${a}]. Consider providing the following inputs: [${d}]. ${S}`)}return g}processStack(e,t,r,s,a,o,i,c,l){const u=[];for(;t.length>0;){const d=t.pop();r.currentContext=d.contexts;let p="";if(d.node.op==="Enter"&&w("isConstant",d.node,s,r)&&([p]=mr(d.node.name,r)),s[d.node.name]==null){const h=Af(d.node,s,r,this._resourceManager);p||([p]=mr(d.node.name,r));const m=r.currentContext;Ss(h)?u.push(h.then(g=>(s[p]=g,this.keepIntermediateTensors&&(this.clonedTensorsMap[p]=this.cloneTensorList(g)),r.currentContext=m,this.checkTensorForDisposal(p,d.node,s,r,o,i,c),this.processChildNodes(d.node,t,r,s,a,l),g))):(s[p]=h,this.keepIntermediateTensors&&(this.clonedTensorsMap[p]=this.cloneTensorList(h)),this.checkTensorForDisposal(p,d.node,s,r,o,i,c),this.processChildNodes(d.node,t,r,s,a,l))}else this.processChildNodes(d.node,t,r,s,a,l)}return u}processChildNodes(e,t,r,s,a,o){e.children.forEach(i=>{const[c]=mr(i.name,r);a[c]||!o.has(i.name)||(i.op==="Merge"?i.inputNames.some(l=>!!vt(l,s,r))&&(a[c]=!0,t.push({contexts:r.currentContext,node:i})):i.inputNames.every(l=>!!vt(l,s,r))&&(a[c]=!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],[s]=tn(t),a=this.graph.nodes[s];if(a.attrParams.shape&&a.attrParams.shape.value){const o=a.attrParams.shape.value,i=o.length===r.shape.length&&r.shape.every((c,l)=>o[l]===-1||o[l]===c);N(i,()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${o}], but was [${r.shape}]`)}a.attrParams.dtype&&a.attrParams.dtype.value&&N(r.dtype===a.attrParams.dtype.value,()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${r.dtype}`)})}mapInputs(e){var t,r;const s={};for(const a in e){const o=(r=(t=this._signature)===null||t===void 0?void 0:t.inputs)===null||r===void 0?void 0:r[a];o!=null?s[o.name]=e[a]:s[a]=e[a]}return s}checkInputs(e){const t=Object.keys(e).filter(r=>{const[s]=tn(r);return this.graph.nodes[s]==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=>{var r,s;const a=(s=(r=this._signature)===null||r===void 0?void 0:r.outputs)===null||s===void 0?void 0:s[t];return a!=null?a.name:t},{})}checkOutputs(e){e.forEach(t=>{const[r]=tn(t);if(!this.graph.nodes[r])throw new Error(`The output '${t}' is not found in the graph`)})}}class Cj{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]}}/** 17982 * @license 17983 * Copyright 2018 Google LLC. All Rights Reserved. 17984 * Licensed under the Apache License, Version 2.0 (the "License");
17985 * you may not use this file except in compliance with the License. 17986 * You may obtain a copy of the License at 17987 * 17988 * http://www.apache.org/licenses/LICENSE-2.0 17989 * 17990 * Unless required by applicable law or agreed to in writing, software 17991 * distributed under the License is distributed on an "AS IS" BASIS, 17992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17993 * See the License for the specific language governing permissions and 17994 * limitations under the License. 17995 * ============================================================================= 17996 */const _j="?tfjs-format=file",Nj="model.json";class Tj{get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}constructor(e,t={},r=Zg){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=r,t==null&&(this.loadOptions={}),this.resourceManager=new Cj}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 Ss(e)?e.then(t=>t.getWeightStream==null?this.loadSync(t):this.loadStreaming(t)):this.loadSync(e)}loadSync(e){const t=this.io.decodeWeights(e.weightData,e.weightSpecs);return this.loadWithWeightMap(e,t)}async loadStreaming(e){if(e.getWeightStream==null)throw new Error("Model artifacts missing streamWeights function");const t=await Vm(e.getWeightStream(),e.weightSpecs);return this.loadWithWeightMap(e,t)}loadWithWeightMap(e,t){this.artifacts=e;const r=this.artifacts.modelTopology;let s=this.artifacts.signature;if(this.artifacts.userDefinedMetadata!=null){const a=this.artifacts.userDefinedMetadata;a.signature!=null&&(s=a.signature),a.structuredOutputKeys!=null&&(this.structuredOutputKeys=a.structuredOutputKeys)}if(this.signature=s,this.version=`${r.versions.producer}.${r.versions.minConsumer}`,this.executor=new Di(Tf.Instance.transformGraph(r,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(t),this.executor.resourceManager=this.resourceManager,e.modelInitializer!=null&&e.modelInitializer.node!=null){const a=Tf.Instance.transformGraph(e.modelInitializer);this.initializer=new Di(a),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=e.initializerSignature}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)}addStructuredOutputNames(e){if(this.structuredOutputKeys){const t=e instanceof dt?[e]:e,r={};return t.forEach((s,a)=>r[this.structuredOutputKeys[a]]=s),r}return e}predict(e,t){const r=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(r)}async predictAsync(e,t){const r=await this.executeAsync(e,this.outputNodes);return this.addStructuredOutputNames(r)}normalizeInputs(e){var t;if(!(e instanceof dt)&&!Array.isArray(e)){const a=(t=this.signature)===null||t===void 0?void 0:t.inputs;if(a!=null)for(const o in a){const i=a[o];i.resourceId!=null&&(e[o]=this.resourceIdToCapturedInput[i.resourceId])}return e}e=Array.isArray(e)?e:[e];const r=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+r!==this.inputNodes.length)throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-r} non-resource placeholders, while there are ${e.length} input tensors provided.`);let s=0;return this.inputNodes.reduce((a,o)=>{var i,c,l;const u=(l=(c=(i=this.signature)===null||i===void 0?void 0:i.inputs)===null||c===void 0?void 0:c[o])===null||l===void 0?void 0:l.resourceId;return u!=null?a[o]=this.resourceIdToCapturedInput[u]:a[o]=e[s++],a},{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}executeInitializerGraph(){return this.initializer==null?[]:this.initializerSignature==null?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return this.initializer==null?[]:this.initializerSignature==null?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(e){if(this.resourceIdToCapturedInput={},this.initializerSignature){const t=this.initializerSignature.outputs,r=Object.keys(t);for(let s=0;s<r.length;s++){const a=r[s],o=t[a];this.resourceIdToCapturedInput[o.resourceId]=e[s]}}}execute(e,t){this.resourceIdToCapturedInput==null&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),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){this.resourceIdToCapturedInput==null&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),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.resourceIdToCapturedInput&&nt(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function Ff(n,e={},t=Zg){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=kj(n));const r=new Tj(n,e,t);return await r.load(),r}function kj(n){return n.endsWith("/")||(n=n+"/"),`${n}${Nj}${_j}`}/** 17997 * @license 17998 * Copyright 2023 Google LLC. All Rights Reserved. 17999 * Licensed under the Apache License, Version 2.0 (the "License");
18000 * you may not use this file except in compliance with the License. 18001 * You may obtain a copy of the License at 18002 * 18003 * http://www.apache.org/licenses/LICENSE-2.0 18004 * 18005 * Unless required by applicable law or agreed to in writing, software 18006 * distributed under the License is distributed on an "AS IS" BASIS, 18007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18008 * See the License for the specific language governing permissions and 18009 * limitations under the License. 18010 * ============================================================================= 18011 */var Mt=function(){return Mt=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var s in e=arguments[t])Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s]);return n},Mt.apply(this,arguments)};function Hn(n,e,t,r){return new(t||(t=Promise))(function(s,a){function o(l){try{c(r.next(l))}catch(u){a(u)}}function i(l){try{c(r.throw(l))}catch(u){a(u)}}function c(l){var u;l.done?s(l.value):(u=l.value,u instanceof t?u:new t(function(d){d(u)})).then(o,i)}c((r=r.apply(n,e||[])).next())})}function jn(n,e){var t,r,s,a,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function i(c){return function(l){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(t=1,r&&(s=2&u[0]?r.return:u[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;switch(r=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(s=o.trys,!((s=s.length>0&&s[s.length-1])||u[0]!==6&&u[0]!==2)){o=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){o.label=u[1];break}if(u[0]===6&&o.label<s[1]){o.label=s[1],s=u;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(u);break}s[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(n,o)}catch(d){u=[6,d],r=0}finally{t=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([c,l])}}}var Oi=["wrist","thumb_cmc","thumb_mcp","thumb_ip","thumb_tip","index_finger_mcp","index_finger_pip","index_finger_dip","index_finger_tip","middle_finger_mcp","middle_finger_pip","middle_finger_dip","middle_finger_tip","ring_finger_mcp","ring_finger_pip","ring_finger_dip","ring_finger_tip","pinky_finger_mcp","pinky_finger_pip","pinky_finger_dip","pinky_finger_tip"],Sc={runtime:"mediapipe",maxHands:2,modelType:"full"},Ej=function(){function n(e){var t,r=this;this.width=0,this.height=0,this.selfieMode=!1,this.handsSolution=new tH.Hands({locateFile:function(s,a){return e.solutionPath?e.solutionPath.replace(/\/+$/,"")+"/"+s:a+"/"+s}}),e.modelType==="lite"?t=0:t=1,this.handsSolution.setOptions({modelComplexity:t,selfieMode:this.selfieMode,maxNumHands:e.maxHands}),this.handsSolution.onResults(function(s){if(r.height=s.image.height,r.width=s.image.width,r.hands=[],s.multiHandLandmarks!==null)for(var a=s.multiHandedness,o=s.multiHandLandmarks,i=s.multiHandWorldLandmarks,c=0;c<a.length;c++)r.hands.push(Mt(Mt({},r.translateOutput(o[c],i[c])),{score:a[c].score,handedness:a[c].label}))})}return n.prototype.translateOutput=function(e,t){var r=this;return{keypoints:e.map(function(s,a){return{x:s.x*r.width,y:s.y*r.height,score:s.visibility,name:Oi[a]}}),keypoints3D:t.map(function(s,a){return{x:s.x,y:s.y,z:s.z,score:s.visibility,name:Oi[a]}})}},n.prototype.estimateHands=function(e,t){return Hn(this,void 0,void 0,function(){var r,s;return jn(this,function(a){switch(a.label){case 0:return t&&t.flipHorizontal&&t.flipHorizontal!==this.selfieMode&&(this.selfieMode=t.flipHorizontal,this.handsSolution.setOptions({selfieMode:this.selfieMode})),e instanceof dt?(s=ImageData.bind,[4,SN(e)]):[3,2];case 1:return r=new(s.apply(ImageData,[void 0,a.sent(),e.shape[1],e.shape[0]])),[3,3];case 2:r=e,a.label=3;case 3:return e=r,[4,this.handsSolution.send({image:e})];case 4:return a.sent(),[2,this.hands]}})})},n.prototype.dispose=function(){this.handsSolution.close()},n.prototype.reset=function(){this.handsSolution.reset(),this.width=0,this.height=0,this.hands=null,this.selfieMode=!1},n.prototype.initialize=function(){return this.handsSolution.initialize()},n}();function Rj(n){return Hn(this,void 0,void 0,function(){var e,t;return jn(this,function(r){switch(r.label){case 0:return e=function(s){if(s==null)return Mt({},Sc);var a=Mt({},s);return a.runtime="mediapipe",a.maxHands==null&&(a.maxHands=Sc.maxHands),a.modelType==null&&(a.modelType=Sc.modelType),a}
18011(n),[4,(t=new Ej(e)).initialize()];case 1:return r.sent(),[2,t]}})})}function Cc(n){return n.width*n.height}function Pf(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 Aj(n,e){var t=Pf(n),r=Pf(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 s=Cc(function(o,i){var c=Math.max(o.xMin,i.xMin),l=Math.min(o.xMax,i.xMax),u=Math.max(o.yMin,i.yMin),d=Math.min(o.yMax,i.yMax);return{xMin:c,xMax:l,yMin:u,yMax:d,width:Math.max(l-c,0),height:Math.max(d-u,0)}}(t,r)),a=Cc(t)+Cc(r)-s;return a>0?s/a:0}function Dj(n,e,t,r){var s=n.width,a=n.height,o=r?-1:1,i=Math.cos(n.rotation),c=Math.sin(n.rotation),l=n.xCenter,u=n.yCenter,d=1/e,p=1/t,h=new Array(16);return h[0]=s*i*o*d,h[1]=-a*c*d,h[2]=0,h[3]=(-.5*s*i*o+.5*a*c+l)*d,h[4]=s*c*o*p,h[5]=a*i*p,h[6]=0,h[7]=(-.5*a*i-.5*s*c*o+u)*p,h[8]=0,h[9]=0,h[10]=s*d,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[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]]]}(h)}function i0(n){return n instanceof dt?{height:n.shape[0],width:n.shape[1]}:{height:n.height,width:n.width}}function Fi(n){return n-2*Math.PI*Math.floor((n+Math.PI)/(2*Math.PI))}function u0(n){return n instanceof dt?n:CN(n)}function _c(n,e){N(n.width!==0,function(){return e+" width cannot be 0."}),N(n.height!==0,function(){return e+" height cannot be 0."})}function Oj(n,e){var t=function(r,s,a,o){var i=s-r,c=o-a;if(i===0)throw new Error("Original min and max are both "+r+", range cannot be 0.");var l=c/i;return{scale:l,offset:a-r*l}}(0,255,e[0],e[1]);return Ne(function(){return me(Z(n,t.scale),t.offset)})}function Lf(n,e,t){var r=e.outputTensorSize,s=e.keepAspectRatio,a=e.borderMode,o=e.outputTensorFloatRange,i=i0(n),c=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}}(i,t),l=function(p,h,m){if(m===void 0&&(m=!1),!m)return{top:0,left:0,right:0,bottom:0};var g=h.height,y=h.width;_c(h,"targetSize"),_c(p,"roi");var b,v,$=g/y,S=p.height/p.width,T=0,O=0;return $>S?(b=p.width,v=p.width*$,O=(1-S/$)/2):(b=p.height/$,v=p.height,T=(1-$/S)/2),p.width=b,p.height=v,{top:O,left:T,right:T,bottom:O}}(c,r,s),u=Dj(c,i.width,i.height,!1),d=Ne(function(){var p=u0(n),h=$s(function(y,b,v){return _c(v,"inputResolution"),[1/v.width*y[0][0]*b.width,1/v.height*y[0][1]*b.width,y[0][3]*b.width,1/v.width*y[1][0]*b.height,1/v.height*y[1][1]*b.height,y[1][3]*b.height,0,0]}(u,i,r),[1,8]),m=a==="zero"?"constant":"nearest",g=Xu.transform(nr(rt(p,"float32")),h,"bilinear",m,0,[r.height,r.width]);return o!=null?Oj(g,o):g});return{imageTensor:d,padding:l,transformationMatrix:u}}function Mf(n,e,t,r){return r===1?.5*(n+e):n+(e-n)*t/(r-1)}function Bf(n){return{xCenter:n.xMin+n.width/2,yCenter:n.yMin+n.height/2,width:n.width,height:n.height}}function Vf(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,s=Number.MIN_VALUE,a=Number.MIN_VALUE;return e.forEach(function(o){t=Math.min(t,o.x),s=Math.max(s,o.x),r=Math.min(r,o.y),a=Math.max(a,o.y)}),{xCenter:(t+s)/2,yCenter:(r+a)/2,width:s-t,height:a-r}}function Fj(n,e,t,r,s){var a=t==="rect"?function(o,i,c){var l,u=o.locationData;if(i==="boundingbox")l=Bf(u.boundingBox);else{l=Vf(u);var d=c.width,p=c.height;l.xCenter=Math.round(l.xCenter*d),l.yCenter=Math.round(l.yCenter*p),l.width=Math.round(l.width*d),l.height=Math.round(l.height*p)}return l}(n,e,r):function(o,i){var c=o.locationData;return i==="boundingbox"?Bf(c.relativeBoundingBox):Vf(c)}(n,e);return s&&(a.rotation=function(o,i,c){var l,u=o.locationData,d=c.rotationVectorStartKeypointIndex,p=c.rotationVectorEndKeypointIndex;l=c.rotationVectorTargetAngle?c.rotationVectorTargetAngle:Math.PI*c.rotationVectorTargetAngleDegree/180;var h=u.relativeKeypoints[d].x*i.width,m=u.relativeKeypoints[d].y*i.height,g=u.relativeKeypoints[p].x*i.width,y=u.relativeKeypoints[p].y*i.height;return Fi(l-Math.atan2(-(y-m),g-h))}(n,r,s)),a}function Pj(n){return Ne(function(){var e=function(s){return Ne(function(){return[Se(s,[0,0,0],[1,-1,1]),Se(s,[0,0,1],[1,-1,-1])]})}(n),t=e[0],r=e[1];return{boxes:xt(r),logits:xt(t)}})}function Lj(n,e,t,r){return Hn(this,void 0,void 0,function(){var s,a,o,i,c;return jn(this,function(l){switch(l.label){case 0:return n.sort(function(u,d){return Math.max.apply(Math,d.score)-Math.max.apply(Math,u.score)}),s=$s(n.map(function(u){return[u.locationData.relativeBoundingBox.yMin,u.locationData.relativeBoundingBox.xMin,u.locationData.relativeBoundingBox.yMax,u.locationData.relativeBoundingBox.xMax]})),a=Rt(n.map(function(u){return u.score[0]})),[4,Xu.nonMaxSuppressionAsync(s,a,e,t)];case 1:return[4,(o=l.sent()).array()];case 2:return i=l.sent(),c=n.filter(function(u,d){return i.indexOf(d)>-1}),nt([s,a,o]),[2,c]}})})}function Mj(n,e){return n.map(function(t){var r=Mt(Mt({},t),{x:t.x*e.width,y:t.y*e.height});return t.z!=null&&(r.z=t.z*e.width),r})}function Bj(n,e,t){return Hn(this,void 0,void 0,function(){var r,s,a,o,i;return jn(this,function(c){switch(c.label){case 0:return r=n[0],s=n[1],a=function(l,u,d){return Ne(function(){var p,h,m,g;
vendor: 3,068 bytes, line 18011
18011d.reverseOutputOrder?(h=xt(Se(l,[0,d.boxCoordOffset+0],[-1,1])),p=xt(Se(l,[0,d.boxCoordOffset+1],[-1,1])),g=xt(Se(l,[0,d.boxCoordOffset+2],[-1,1])),m=xt(Se(l,[0,d.boxCoordOffset+3],[-1,1]))):(p=xt(Se(l,[0,d.boxCoordOffset+0],[-1,1])),h=xt(Se(l,[0,d.boxCoordOffset+1],[-1,1])),m=xt(Se(l,[0,d.boxCoordOffset+2],[-1,1])),g=xt(Se(l,[0,d.boxCoordOffset+3],[-1,1]))),h=me(Z(Te(h,d.xScale),u.w),u.x),p=me(Z(Te(p,d.yScale),u.h),u.y),d.applyExponentialOnBoxSize?(m=Z(xr(Te(m,d.hScale)),u.h),g=Z(xr(Te(g,d.wScale)),u.w)):(m=Z(Te(m,d.hScale),u.h),g=Z(Te(g,d.wScale),u.h));var y=Ce(p,Te(m,2)),b=Ce(h,Te(g,2)),v=me(p,Te(m,2)),$=me(h,Te(g,2)),S=It([q(y,[d.numBoxes,1]),q(b,[d.numBoxes,1]),q(v,[d.numBoxes,1]),q($,[d.numBoxes,1])],1);if(d.numKeypoints)for(var T=0;T<d.numKeypoints;++T){var O=d.keypointCoordOffset+T*d.numValuesPerKeypoint,L=void 0,M=void 0;d.reverseOutputOrder?(L=xt(Se(l,[0,O],[-1,1])),M=xt(Se(l,[0,O+1],[-1,1]))):(M=xt(Se(l,[0,O],[-1,1])),L=xt(Se(l,[0,O+1],[-1,1])));var W=me(Z(Te(L,d.xScale),u.w),u.x),V=me(Z(Te(M,d.yScale),u.h),u.y);S=It([S,q(W,[d.numBoxes,1]),q(V,[d.numBoxes,1])],1)}return S})}(s,e,t),o=Ne(function(){var l=r;return t.sigmoidScore?(t.scoreClippingThresh!=null&&(l=tg(r,-t.scoreClippingThresh,t.scoreClippingThresh)),l=Is(l)):l}),[4,Vj(a,o,t)];case 1:return i=c.sent(),nt([a,o]),[2,i]}})})}function Vj(n,e,t){return Hn(this,void 0,void 0,function(){var r,s,a,o,i,c,l,u,d,p,h,m;return jn(this,function(g){switch(g.label){case 0:return r=[],[4,n.data()];case 1:return s=g.sent(),[4,e.data()];case 2:for(a=g.sent(),o=0;o<t.numBoxes;++o)if(!(t.minScoreThresh!=null&&a[o]<t.minScoreThresh||(i=o*t.numCoords,c=Wj(s[i+0],s[i+1],s[i+2],s[i+3],a[o],t.flipVertically,o),(l=c.locationData.relativeBoundingBox).width<0||l.height<0))){if(t.numKeypoints>0)for((u=c.locationData).relativeKeypoints=[],d=t.numKeypoints*t.numValuesPerKeypoint,p=0;p<d;p+=t.numValuesPerKeypoint)h=i+t.keypointCoordOffset+p,m={x:s[h+0],y:t.flipVertically?1-s[h+1]:s[h+1]},u.relativeKeypoints.push(m);r.push(c)}return[2,r]}})})}function Wj(n,e,t,r,s,a,o){return{score:[s],ind:o,locationData:{relativeBoundingBox:{xMin:e,yMin:a?1-t:n,xMax:r,yMax:a?1-n:t,width:r-e,height:t-n}}}}function Uj(n,e){return n==="none"?e:function(t){return 1/(1+Math.exp(-t))}(e)}function Wf(n,e,t,r){return Hn(this,void 0,void 0,function(){var s,a,o,i,c,l,u,d;return jn(this,function(p){switch(p.label){case 0:return t=t||e.flipHorizontally||!1,r=r||e.flipVertically||!1,s=n.size,a=s/e.numLandmarks,[4,n.data()];case 1:for(o=p.sent(),i=[],c=0;c<e.numLandmarks;++c)l=c*a,(d={x:0,y:0}).x=t?e.inputImageWidth-o[l]:o[l],a>1&&(d.y=r?e.inputImageHeight-o[l+1]:o[l+1]),a>2&&(d.z=o[l+2]),a>3&&(d.score=Uj(e.visibilityActivation,o[l+3])),i.push(d);for(u=0;u<i.length;++u)(d=i[u]).x=d.x/e.inputImageWidth,d.y=d.y/e.inputImageHeight,d.z=d.z/e.inputImageWidth/(e.normalizeZ||1);return[2,i]}})})}function Uf(n,e,t){var r=n.width,s=n.height,a=n.rotation;if(t.rotation==null&&t.rotationDegree==null||(a=function(u,d){return d.rotation!=null?u+=d.rotation:d.rotationDegree!=null&&(u+=Math.PI*d.rotationDegree/180),Fi(u)}
18011(a,t)),a===0)n.xCenter=n.xCenter+r*t.shiftX,n.yCenter=n.yCenter+s*t.shiftY;else{var o=(e.width*r*t.shiftX*Math.cos(a)-e.height*s*t.shiftY*Math.sin(a))/e.width,i=(e.width*r*t.shiftX*Math.sin(a)+e.height*s*t.shiftY*Math.cos(a))/e.height;n.xCenter=n.xCenter+o,n.yCenter=n.yCenter+i}if(t.squareLong){var c=Math.max(r*e.width,s*e.height);r=c/e.width,s=c/e.height}else if(t.squareShort){var l=Math.min(r*e.width,s*e.height);r=l/e.width,s=l/e.height}return n.width=r*t.scaleX,n.height=s*t.scaleY,n}function zj(n,e){for(var t=function(G,K){var J=G[0].x*K.width,ue=G[0].y*K.height,se=(G[4].x+G[8].x)/2,fe=(G[4].y+G[8].y)/2;return se=(se+G[6].x)/2*K.width,fe=(fe+G[6].y)/2*K.height,Fi(Math.PI/2-Math.atan2(-(fe-ue),se-J))}(n,e),r=Fi(-t),s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,c=0,l=n;c<l.length;c++){var u=(y=l[c]).x,d=y.y;s=Math.min(s,u),a=Math.max(a,u),o=Math.min(o,d),i=Math.max(i,d)}var p=(a+s)/2,h=(i+o)/2;s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(var m=0,g=n;m<g.length;m++){var y,b=((y=g[m]).x-p)*e.width,v=(y.y-h)*e.height,$=b*Math.cos(r)-v*Math.sin(r),S=b*Math.sin(r)+v*Math.cos(r);s=Math.min(s,$),a=Math.max(a,$),o=Math.min(o,S),i=Math.max(i,S)}var T=(a+s)/2,O=(i+o)/2,L=T*Math.cos(t)-O*Math.sin(t)+e.width*p,M=T*Math.sin(t)+O*Math.cos(t)+e.height*h,W=(a-s)/e.width,V=(i-o)/e.height;return{xCenter:L/e.width,yCenter:M/e.height,width:W,height:V,rotation:t}}var Gj={reduceBoxesInLowestLayer:!1,interpolatedScaleAspectRatio:1,featureMapHeight:[],featureMapWidth:[],numLayers:4,minScale:.1484375,maxScale:.75,inputSizeHeight:192,inputSizeWidth:192,anchorOffsetX:.5,anchorOffsetY:.5,strides:[8,16,16,16],aspectRatios:[1],fixedAnchorSize:!0},Nc={runtime:"tfjs",modelType:"full",maxHands:2,detectorModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/full/1",landmarkModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/full/1"},Tc={flipHorizontal:!1,staticImageMode:!1},Hj={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses:1,numBoxes:2016,numCoords:18,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:7,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:192,yScale:192,hScale:192,wScale:192,minScoreThresh:.5},jj=.3,qj={shiftX:0,shiftY:-.5,scaleX:2.6,scaleY:2.6,squareLong:!0},Kj={shiftX:0,shiftY:-.1,scaleX:2,scaleY:2,squareLong:!0},Xj={outputTensorSize:{width:192,height:192},keepAspectRatio:!0,outputTensorFloatRange:[0,1],borderMode:"zero"},Yj={outputTensorSize:{width:224,height:224},keepAspectRatio:!0,outputTensorFloatRange:[0,1],borderMode:"zero"},Qj={numLandmarks:21,inputImageWidth:224,inputImageHeight:224,normalizeZ:.4,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},Zj={numLandmarks:21,inputImageWidth:1,inputImageHeight:1,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},wl,Jj=function(){function n(e,t,r){this.detectorModel=e,this.landmarkModel=t,this.maxHands=r,this.prevHandRectsFromLandmarks=null,this.anchors=function(c){c.reduceBoxesInLowestLayer==null&&(c.reduceBoxesInLowestLayer=!1),c.interpolatedScaleAspectRatio==null&&(c.interpolatedScaleAspectRatio=1),c.fixedAnchorSize==null&&(c.fixedAnchorSize=!1);for(var l=[],u=0;u<c.numLayers;){for(var d=[],p=[],h=[],m=[],g=u;g<c.strides.length&&c.strides[g]===c.strides[u];){var y=Mf(c.minScale,c.maxScale,g,c.strides.length);if(g===0&&c.reduceBoxesInLowestLayer)h.push(1),h.push(2),h.push(.5),m.push(.1),m.push(y),m.push(y);else{for(var b=0;b<c.aspectRatios.length;++b)h.push(c.aspectRatios[b]),m.push(y);if(c.interpolatedScaleAspectRatio>0){var v=g===c.strides.length-1?1:Mf(c.minScale,c.maxScale,g+1,c.strides.length);m.push(Math.sqrt(y*v)),h.push(c.interpolatedScaleAspectRatio)}}g++}for(var $=0;$<h.length;++$){var S=Math.sqrt(h[$]);d.push(m[$]/S),p.push(m[$]*S)}var T=0,O=0;if(c.featureMapHeight.length>0)T=c.featureMapHeight[u],O=c.featureMapWidth[u];else{var L=c.strides[u];T=Math.ceil(c.inputSizeHeight/L),O=Math.ceil(c.inputSizeWidth/L)}for(var M=0;M<T;++M)for(var W=0;W<O;++W)for(var V=0;V<d.length;
18011++V){var G={xCenter:(W+c.anchorOffsetX)/O,yCenter:(M+c.anchorOffsetY)/T,width:0,height:0};c.fixedAnchorSize?(G.width=1,G.height=1):(G.width=p[V],G.height=d[V]),l.push(G)}u=g}return l}(Gj);var s=Rt(this.anchors.map(function(c){return c.width})),a=Rt(this.anchors.map(function(c){return c.height})),o=Rt(this.anchors.map(function(c){return c.xCenter})),i=Rt(this.anchors.map(function(c){return c.yCenter}));this.anchorTensor={x:o,y:i,w:s,h:a}}return n.prototype.estimateHands=function(e,t){return Hn(this,void 0,void 0,function(){var r,s,a,o,i,c,l,u,d,p,h,m,g,y,b,v,$,S,T=this;return jn(this,function(O){switch(O.label){case 0:return r=function(W){if(W==null)return Mt({},Tc);var V=Mt({},W);return V.flipHorizontal==null&&(V.flipHorizontal=Tc.flipHorizontal),V.staticImageMode==null&&(V.staticImageMode=Tc.staticImageMode),V}(t),e==null?(this.reset(),[2,[]]):(s=i0(e),a=Ne(function(){var W=rt(u0(e),"float32");return r.flipHorizontal&&(W=xt(Xu.flipLeftRight(nr(W,0)),[0])),W}),o=this.prevHandRectsFromLandmarks,r.staticImageMode||o==null||o.length<this.maxHands?[4,this.detectPalm(a)]:[3,2]);case 1:return(c=O.sent()).length===0?(this.reset(),a.dispose(),[2,[]]):(l=c.map(function(W){return T.palmDetectionToRoi(W,s)}),i=l,[3,3]);case 2:i=o,O.label=3;case 3:return L=.5,M=[],[i].forEach(function(W){return W.forEach(function(V){(M=M.filter(function(G){return Aj(V,G)<=L})).push(V)})}),i=M,[4,Promise.all(i.map(function(W){return T.handLandmarks(W,a)}))];case 4:for(u=O.sent(),d=[],this.prevHandRectsFromLandmarks=[],p=0,h=u;p<h.length;p++)(m=h[p])!=null&&(g=m.landmarks,y=m.worldLandmarks,b=m.handScore,v=m.handedness,this.prevHandRectsFromLandmarks.push(this.handLandmarksToRoi(g,s)),($=Mj(g,s))!=null&&$.forEach(function(W,V){delete W.z,W.name=Oi[V]}),(S=y)!=null&&S.forEach(function(W,V){W.name=Oi[V]}),d.push({keypoints:$,keypoints3D:S,handedness:v,score:b}));return a.dispose(),[2,d]}var L,M})})},n.prototype.dispose=function(){this.detectorModel.dispose(),this.landmarkModel.dispose(),nt([this.anchorTensor.x,this.anchorTensor.y,this.anchorTensor.
18011w,this.anchorTensor.h])},n.prototype.reset=function(){this.prevHandRectsFromLandmarks=null},n.prototype.detectPalm=function(e){return Hn(this,void 0,void 0,function(){var t,r,s,a,o,i,c,l,u,d;return jn(this,function(p){switch(p.label){case 0:return t=Lf(e,Xj),r=t.imageTensor,s=t.padding,a=this.detectorModel.predict(r),o=Pj(a),i=o.boxes,[4,Bj([c=o.logits,i],this.anchorTensor,Hj)];case 1:return(l=p.sent()).length===0?(nt([r,a,c,i]),[2,l]):[4,Lj(l,this.maxHands,jj)];case 2:return u=p.sent(),d=function(h,m){h===void 0&&(h=[]);for(var g=m.left,y=m.top,b=m.left+m.right,v=m.top+m.bottom,$=0;$<h.length;$++){var S=h[$],T=S.locationData.relativeBoundingBox,O=(T.xMin-g)/(1-b),L=(T.yMin-y)/(1-v),M=T.width/(1-b),W=T.height/(1-v);T.xMin=O,T.yMin=L,T.width=M,T.height=W,T.xMax=O+M,T.yMax=L+W;var V=S.locationData.relativeKeypoints;V&&V.forEach(function(G){var K=(G.x-g)/(1-b),J=(G.y-y)/(1-v);G.x=K,G.y=J})}return h}(u,s),nt([r,a,c,i]),[2,d]}})})},n.prototype.palmDetectionToRoi=function(e,t){return Uf(Fj(e,"boundingbox","normRect",t,{rotationVectorStartKeypointIndex:0,rotationVectorEndKeypointIndex:2,rotationVectorTargetAngleDegree:90}),t,qj)},n.prototype.handLandmarks=function(e,t){return Hn(this,void 0,void 0,function(){var r,s,a,o,i,c,l,u,d,p,h,m,g,y,b,v;return jn(this,function($){switch($.label){case 0:return r=Lf(t,Yj,e),s=r.imageTensor,a=r.padding,o=this.landmarkModel.execute(s,["Identity_2:0","Identity_1:0","Identity:0","Identity_3:0"]),i=o[0],c=o[1],l=o[2],u=o[3],[4,c.data()];case 1:return(d=$.sent()[0])<.5?(nt(o),nt(s),[2,null]):[4,l.data()];case 2:return p=$.sent()[0],h=p>=.5?"Left":"Right",[4,Wf(i,Qj)];case 3:return m=$.sent(),[4,Wf(u,Zj)];case 4:return g=$.sent(),y=function(S,T){var O=T.left,L=T.top,M=T.left+T.right,W=T.top+T.bottom;return S.map(function(V){return Mt(Mt({},V),{x:(V.x-O)/(1-M),y:(V.y-L)/(1-W),z:V.z/(1-M)})})}(m,a),b=function(S,T,O){O===void 0&&(O={ignoreRotation:!1});for(var L=[],M=0,W=S;M<W.length;M++){var V=W[M],G=V.x-.5,K=V.y-.5,J=O.ignoreRotation?0:T.rotation,ue=Math.cos(J)*G-Math.sin(J)*K,se=Math.sin(J)*G+Math.cos(J)*K;ue=ue*T.width+T.xCenter,se=se*T.height+T.yCenter;var fe=V.z*T.width,Ie=Mt({},V);Ie.x=ue,Ie.y=se,Ie.z=fe,L.push(Ie)}return L}(y,e),v=function(S,T){for(var O=[],L=0,M=S;L<M.length;L++){var W=M[L],V=W.x,G=W.y,K=T.rotation,J=Math.cos(K)*V-Math.sin(K)*G,ue=Math.sin(K)*V+Math.cos(K)*G,se=Mt({},W);se.x=J,se.y=ue,O.push(se)}return O}(g,e),nt(o),nt(s),[2,{landmarks:b,worldLandmarks:v,handScore:d,handedness:h}]}})})},n.prototype.handLandmarksToRoi=function(e,t){return Uf(zj([].concat(e.slice(0,4),e.slice(5,7),e.slice(9,11),e.slice(13,15),e.slice(17,19)),t),t,Kj)},n}();function e6(n){return Hn(this,void 0,void 0,function(){var e,t,r,s,a,o;return jn(this,function(i){switch(i.label){case 0:return e=function(c){if(c==null)return Mt({},Nc);var l=Mt({},c);if(l.runtime="tfjs",l.maxHands==null&&(l.maxHands=Nc.maxHands),l.modelType==null&&(l.modelType=Nc.modelType),l.modelType!=="lite"&&l.modelType!=="full")throw new Error("Model type must be one of lite or full, but got "+l.modelType);return l.detectorModelUrl==null&&(l.modelType==="lite"?l.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/lite/1":l.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/full/1"),l.landmarkModelUrl==null&&(l.modelType==="lite"?l.landmarkModelUrl="https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/lite/1":l.landmarkModelUrl="https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/full/1"),l}(n),t=e.detectorModelUrl.indexOf("https://tfhub.dev")>-1,r=e.landmarkModelUrl.indexOf("https://tfhub.dev")>-1,[4,Promise.all([Ff(e.detectorModelUrl,{fromTFHub:t}),Ff(e.landmarkModelUrl,{fromTFHub:r})])];case 1:return s=i.sent(),a=s[0],o=s[1],[2,new Jj(a,o,e.maxHands)]}})})}function s6(n,e){return Hn(this,void 0,void 0,function(){var t,r;return jn(this,function(s){if(n===wl.MediaPipeHands){if(r=void 0,(t=e)!=null){if(t.runtime==="tfjs")return[2,e6(t)];if(t.runtime==="mediapipe")return[2,Rj(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.MediaPipeHands="MediaPipeHands"})(wl||(wl={}));
18011export{wl as d,CN as f,vw as g,s6 as p,r6 as r,n6 as s};
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.