PageSourceSearch

https://kindredly.ai/js/indexDxjtBBUo.js

js kindredly.ai collected 2026-10-02 01:14:07 UTC 1,709,165 bytes, 20,957 lines download raw bytes

1import{cM as R,cN as N,cO as F,c as Hr,d as jr,H as I,cP as ke,f as Do,k as xu,o as bu,q as Ao,r as Oo,u as qr,v as Kr,w as Xr,cQ as At,x as Yr,y as Jr,b9 as It,cR as D,cS as Ht,z as _o,cT as ee,C as Fo,cU as Gl,cV as ts,a3 as Lo,J as Po,S as wu,cs as Zr,cW as te,cX as O,cY as Mn,P as zo,aG as Vo,Y as vu,Z as Bo,$ as Cu,cZ as qn,cu as Qr,a1 as ea,c_ as ta,a2 as na,c$ as Er,a8 as Mo,ab as Wo,ac as Uo,af as $u,ag as sa,ah as ra,aj as Nu,al as Go,am as Iu,an as Su,ao as Ho,ap as ku,aq as jo,a as xe,aw as qo,bN as Ko,d0 as he,d1 as Be,d2 as Tu,d3 as kC,ax as aa,b2 as Xo,bb as Yo,p as Ie,n as nt,d4 as rt,d5 as oe,d6 as ln,d7 as As,s as pe,d8 as Ye,ay as oa,az as Jo,aA as ia,d9 as $e,aE as la,aL as Zo,aN as Qo,aO as ua,da as Eu,aP as ca,aQ as ha,aR as da,aT as ei,aU as ti,aV as Ru,db as Ad,b0 as ni,aW as pa,aX as fa,bi as si,bT as ma,dc as Hn,dd as ie,aY as ri,aZ as ai,a_ as oi,b as H,bM as Du,b4 as ii,b5 as li,b8 as Au,ba as ui,de as Cs,df as hn,dg as qy,T as lt,bc as ga,bd as ci,bg as ya,bf as Ou,bm as hi,bn as di,bo as pi,br as fi,bU as mi,B as _n,bu as gi,dh as _u,di as Fu,dj as Lu,cD as TC,dk as kr,dl as Od,dm as Gs,dn as $s,dp as Hl,bv as Pu,dq as zu,by as xa,bF as yi,bI as ba,bJ as wa,bO as va,dr as bt,bQ as Ca,bR as $a,bS as Na,be as xi,ds as Vu,dt as Bu,ca as bi,ce as Ia,du as Os,bp as wi,cg as Mu,cr as Sa,dv as ka,dw as Ta,dx as Ky,ct as Wu,cv as Uu,cx as Gu,dy as vi,cz as Ci,bq as dn,t as L,h as Js,dz as EC,bK as Hu,c9 as ju,aJ as qu,dA as wt,g as En,dB as Ku,dC as _d,dD as Fd,aa as Ft,aH as go,dE as Ld,dF as $i,dG as Pd,dH as Xu,dI as Yu,aI as yo,_ as xo,ai as Ju,aD as Zu,bG as Qu,bj as ec,bl as tc,bk as nc,bB as Ni,bD as Ii,cw as sc,dJ as Re,dK as Kn,bV as rc,bZ as ac,c7 as oc,c8 as ic,cj as lc,cl as uc,cn as cc,dL as Si,dM as zd,dN as wg,dO as Vd,cC as W,dP as hc,dQ as Xy,dR as Bd,dS as RC,dT as Md,dU as jl,dV as Yy,dW as DC,dX as Jy,dY as Jh,dZ as Zy,d_ as Qy,d$ as ex,e0 as AC,e1 as OC,e2 as _C,e3 as FC,e4 as LC,e5 as Wd,e6 as dc,e7 as ql,e8 as tx,e9 as nx,ea as sx,eb as rx,ec as ax,ed as ox,ee as ix,A as pc,ef as Ea,e as ki,eg as vt,E as fc,F as mc,eh as lx,a0 as gc,ei as yc,ae as xc,i as Xe,as as Kl,at as Xl,au as Ti,av as bc,aF as Ei,ak as pr,I as wc,aS as vc,ej as ux,b1 as Cc,b3 as Ri,b6 as $c,b7 as Nc,m as Ct,bh as Di,bs as Ai,bt as Ic,bx as Oi,bA as _i,bz as Fi,R as Sc,bC as kc,bE as Tc,ek as Ud,el as Gd,bP as Li,K as cx,cc as Pi,cd as Ec,cf as zi,cp as Vi,cq as Rc,em as as,cA as Dc,en as hx,eo as G,ep as Bi,eq as Hd,er as Ac,es as Oc,et as jd,cH as nn,eu as dx,ev as Mi,ew as Wi,ex as K,ey as vg,ez as ct,eA as px,eB as PC,eC as Zh,eD as Zs,eE as fx,eF as mx,eG as bo,eH as Rr,eI as qd,cK as zC,cE as Kd,cF as Xd,cG as Sn,eJ as Ui,eK as Ns,eL as VC,eM as Gi,eN as ue,M as fe,eO as wo,eP as Ra,eQ as Wn,eR as Yd,eS as _c,eT as gx,eU as Dr,eV as Dt,eW as _s,eX as bn,j as st,eY as BC,eZ as MC,e_ as WC,e$ as UC,f0 as GC,bY as HC,bX as jC,bW as qC,c1 as KC,c0 as XC,c2 as YC,b$ as JC,b_ as ZC,c3 as Cg,c6 as QC,c5 as e$,c4 as t$,f1 as no,a6 as yx,bw as xx,O as n$,ck as bx,cm as wx,co as vx,cy as Cx,cL as Jd,G as $x,l as St,D as Fs,Q as Fc,U as Lc,V as Pc,W as Nx,X as Ix,f2 as Ar,a4 as Sx,a5 as ns,a9 as fr,ad as Da,ar as zc,f3 as kx,f4 as Tx,f5 as Ex,f6 as Rx,f7 as Dx,f8 as Ax,f9 as Ox,fa as _x,fb as Fx,fc as Lx,fd as Px,fe as zx,ff as Vx,fg as s$,fh as r$,fi as a$,fj as o$,fk as i$,fl as l$,aB as Zd,aC as Bx,aK as Mx,aM as Wx,bH as Ux,bL as Aa,cb as Gx,ch as Hx,ci as jx,fm as Qd,fn as u$,cB as ep,fo as Qh,fp as $g,fq as tp,fr as qx,fs as Kx,ft as Ng,fu as c$,cI as h$,fv as d$,fw as np,fx as Vc,fy as p$,L as f$,N as m$,fz as g$,fA as y$,fB as x$,fC as b$,a$ as w$,fD as v$,fE as C$,fF as $$,fG as N$,fH as I$,fI as S$,fJ as k$,fK as T$,cJ as E$,fL as R$,fM as D$,fN as A$,fO as O$,fP as _$,fQ as F$,fR as L$,fS as P$,fT as z$,fU as V$,fV as B$,fW as M$,fX as W$,fY as U$,fZ as G$,f_ as H$,f$ as j$,g0 as q$,g1 as K$,g2 as X$,g3 as Y$,g4 as J$,g5 as Z$,g6 as Q$,g7 as eN,g8 as tN,g9 as nN,ga as sN,gb as rN}from"./Unique_implDFaNoOJ5.js";import{c as mr}from"./cjs-helpersC4iS2aBk.js";/**
2 * @license
3 * Copyright 2018 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 */function aN(n){const t={x:N(n,"x","acos")};return F.runKernel(Hr,t)}const sp=R({acos_:aN});/**
17 * @license
18 * Copyright 2018 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 oN(n){const t={x:N(n,"x","acosh")};return F.runKernel(jr,t)}const rp=R({acosh_:oN});/**
32 * @license
33 * Copyright 2020 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 */function iN(n){I(Array.isArray(n),()=>"The argument passed to tf.addN() must be a list of tensors"),I(n.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${n.length}`);const e=n.map((r,a)=>N(r,`tensors${a}`,"addN")),t=e[0];e.forEach(r=>{if(r.dtype!==t.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),e.forEach(r=>{if(!ke(r.shape,t.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});const s=e;return F.runKernel(Do,s)}const Xx=R({addN_:iN});/**
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 */function lN(n,e=null,t=!1){const r={x:N(n,"x","all","bool")},a={axis:e,keepDims:t};return F.runKernel(xu,r,a)}const Bc=R({all_:lN});/**
62 * @license
63 * Copyright 2020 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,e=null,t=!1){const r={x:N(n,"x","any","bool")},a={axis:e,keepDims:t};return F.runKernel(bu,r,a)}const vo=R({any_:uN});/**
77 * @license
78 * Copyright 2020 Google Inc. All Rights Reserved.
79 * Licensed under the Apache License, Version 2.0 (the "License");
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 */function cN(n,e=0){const s={x:N(n,"x","argMax")},r={axis:e};return F.runKernel(Ao,s,r)}const nr=R({argMax_:cN});/**
92 * @license
93 * Copyright 2020 Google Inc. All Rights Reserved.
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 hN(n,e=0){const s={x:N(n,"x","argMin")},r={axis:e};return F.runKernel(Oo,s,r)}const ap=R({argMin_:hN});/**
107 * @license
108 * Copyright 2018 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 */function dN(n){const t={x:N(n,"x","asin")};return F.runKernel(qr,t)}const op=R({asin_:dN});/**
122 * @license
123 * Copyright 2018 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 pN(n){const t={x:N(n,"x","asinh")};return F.runKernel(Kr,t)}const ip=R({asinh_:pN});/**
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 */function fN(n){const t={x:N(n,"x","atan")};return F.runKernel(Xr,t)}const lp=R({atan_:fN});/**
152 * @license
153 * Copyright 2020 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, softw
160are
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 mN(n,e){let t=N(n,"a","atan2"),s=N(e,"b","atan2");[t,s]=At(t,s);const r={a:t,b:s};return F.runKernel(Yr,r)}const up=R({atan2_:mN});/**
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 */function gN(n){const t={x:N(n,"x","atanh")};return F.runKernel(Jr,t)}const cp=R({atanh_:gN});/**
182 * @license
183 * Copyright 2020 Google LLC. All Rights Reserved.
184 * Licensed under the Apache License, Version 2.0 (the "License");
185 * you may not use this file except in compliance with the License.
186 * You may obtain a copy of the License at
187 *
188 * http://www.apache.org/licenses/LICENSE-2.0
189 *
190 * Unless required by applicable law or agreed to in writing, software
191 * distributed under the License is distributed on an "AS IS" BASIS,
192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193 * See the License for the specific language governing permissions and
194 * limitations under the License.
195 * =============================================================================
196 */function yN(n,e,t,s,r){const a=N(n,"x","avgPool","float32"),o=1;I(It(t,o),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`);let i=a,l=!1;a.rank===3&&(l=!0,i=D(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(i.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${i.rank}.`),Ht("avgPool",s,r);const u={x:i},c={filterSize:e,strides:t,pad:s,dimRoundingMode:r};let h=F.runKernel(_o,u,c);return h=ee(h,a.dtype),l?D(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const Hi=R({avgPool_:yN});/**
197 * @license
198 * Copyright 2020 Google LLC. All Rights Reserved.
199 * Licensed under the Apache License, Version 2.0 (the "License");
200 * you may not use this file except in compliance with the License.
201 * You may obtain a copy of the License at
202 *
203 * http://www.apache.org/licenses/LICENSE-2.0
204 *
205 * Unless required by applicable law or agreed to in writing, software
206 * distributed under the License is distributed on an "AS IS" BASIS,
207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208 * See the License for the specific language governing permissions and
209 * limitations under the License.
210 * =============================================================================
211 */function xN(n,e,t,s,r,a="NDHWC"){const o=N(n,"x","avgPool3d","float32");let i=o,l=!1;o.rank===4&&(l=!0,i=D(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),I(i.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`),I(a==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),I(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}'`),Ht("avgPool3d",s,r);const u={x:i},c={filterSize:e,strides:t,pad:s,dimRoundingMode:r,dataFormat:a};let h=F.runKernel(Fo,u,c);return h=ee(h,i.dtype),l?D(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const hp=R({avgPool3d_:xN});/**
212 * @license
213 * Copyright 2020 Google LLC. All Rights Reserved.
214 * Licensed under the Apache License, Version 2.0 (the "License");
215 * you may not use this file except in compliance with the License.
216 * You may obtain a copy of the License at
217 *
218 * http://www.apache.org/licenses/LICENSE-2.0
219 *
220 * Unless required by applicable law or agreed to in writing, softw
220are
221 * distributed under the License is distributed on an "AS IS" BASIS,
222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
223 * See the License for the specific language governing permissions and
224 * limitations under the License.
225 * =============================================================================
226 */function bN(n,e=0){I(n.length>=1,()=>"Pass at least one tensor to concat");const t=Gl(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
227          with dtype ${a.dtype}. `)}),t.length===1)return ts(t[0]);const s=t,r={axis:e};return F.runKernel(Lo,s,r)}const Je=R({concat_:bN});/**
228 * @license
229 * Copyright 2020 Google LLC. All Rights Reserved.
230 * Licensed under the Apache License, Version 2.0 (the "License");
231 * you may not use this file except in compliance with the License.
232 * You may obtain a copy of the License at
233 *
234 * http://www.apache.org/licenses/LICENSE-2.0
235 *
236 * Unless required by applicable law or agreed to in writing, software
237 * distributed under the License is distributed on an "AS IS" BASIS,
238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239 * See the License for the specific language governing permissions and
240 * limitations under the License.
241 * =============================================================================
242 */function wN(n,e,t=!1,s=!1){let r=N(n,"a","matMul"),a=N(e,"b","matMul");[r,a]=At(r,a);const o={a:r,b:a},i={transposeA:t,transposeB:s};return F.runKernel(Po,o,i)}const ve=R({matMul_:wN});/**
243 * @license
244 * Copyright 2018 Google LLC. All Rights Reserved.
245 * Licensed under the Apache License, Version 2.0 (the "License");
246 * you may not use this file except in compliance with the License.
247 * You may obtain a copy of the License at
248 *
249 * http://www.apache.org/licenses/LICENSE-2.0
250 *
251 * Unless required by applicable law or agreed to in writing, software
252 * distributed under the License is distributed on an "AS IS" BASIS,
253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254 * See the License for the specific language governing permissions and
255 * limitations under the License.
256 * =============================================================================
257 */function vN(n,e,t){const s=N(n,"x","slice","string_or_numeric");if(s.rank===0)throw new Error("Slicing scalar is not possible");const r={x:s},a={begin:e,size:t};return F.runKernel(wu,r,a)}const Se=R({slice_:vN});/**
258 * @license
259 * Copyright 2018 Google LLC. All Rights Reserved.
260 * Licensed under the Apache License, Version 2.0 (the "License");
261 * you may not use this file except in compliance with the License.
262 * You may obtain a copy of the License at
263 *
264 * http://www.apache.org/licenses/LICENSE-2.0
265 *
266 * Unless required by applicable law or agreed to in writing, software
267 * distributed under the License is distributed on an "AS IS" BASIS,
268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
269 * See the License for the specific language governing permissions and
270 * limitations under the License.
271 * =============================================================================
272 */function CN(n){const t={x:N(n,"x","tanh","float32")};return F.runKernel(Zr,t)}const Is=R({tanh_:CN});/**
273 * @license
274 * Copyright 2020 Google LLC. All Rights Reserved.
275 * Licensed under the Apache License, Version 2.0 (the "License");
276 * you may not use this file except in compliance with the License.
277 * You may obtain a copy of the License at
278 *
279 * http://www.apache.org/licenses/LICENSE-2.0
280 *
281 * Unless required by applicable law or agreed to in writing, software
282 * distributed under the License is distributed on an "AS IS" BASIS,
283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284 * See the License for the specific language governing permissions and
285 * limitations under the License.
286 * =============================================================================
287 */function $N(n,e,t,s,r,a){const o=N(n,"forgetBias","basicLSTMCell"),i=N(e,"lstmKernel","basicLSTMCell"),l=N(t,"lstmBias","basicLSTMCell"),u=N(s,"data","basicLSTMCell"),c=N(r,"c","basicLSTMCell"),h=N(a,"h","basicLSTMCell"),d=Je([u,h],1),p=ve(d,i),f=te(p,l),g=f.shape[0],m=f.shape[1]/4,y=[g,m],x=Se(f,[0,0],y),v=Se(f,[0,m],y),b=Se(f,[0,m*2],y),C=Se(f,[0,m*3],y),$=te(O(Mn(x),Is(v)),O(c,Mn(te(o,b)))),S=O(Is($),Mn(C));return[$,S]}const Yx=R({basicLSTMCell_:$N});/**
288 * @license
289 * Copyright 2020 Google LLC. All Rights Reserved.
290 * Licensed under the Apache License, Version 2.0 (the "License");
291 * you may not use this file except in compliance with the License.
292 * You may obtain a copy of the License at
293 *
294 * http://www.apache.org/licenses/LICENSE-2.0
295 *
296 * Unless required by applicable law or agreed to in writing, software
297 * distributed under the License is distributed on an "AS IS" BASIS,
298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299 * See the License for the specific language governing permissions and
300 * limitations under the License.
301 * =============================================================================
302 */function NN(n,e,t){const s=N(n,"x","batchToSpaceND"),r=e.reduce((i,l)=>i*l);I(s.rank>=1+e.length,()=>`input rank is ${s.rank} but should be > than blockShape.length ${e.length}`),I(t.length===e.length,()=>`crops.length is ${t.length} but should be equal to blockShape.length  ${e.length}`),I(s.shape[0]%r===0,()=>`input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${r}`);const a={x:s},o={blockShape:e,crops:t};return F.runKernel(zo,a,o)}const ji=R({batchToSpaceND_:NN});function IN(n){let e;return n.rank===0||n.rank===1?e=D(n,[1,1,1,n.size]):n.rank===2?e=D(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?e=D(n,[1,n.shape[0],n.shape[1],n.shape[2]]):e=n,e}/**
303 * @license
304 * Copyright 2020 Google LLC. All Rights Reserved.
305 * Licensed under the Apache License, Version 2.0 (the "License");
306 * you may not use this file except in compliance with the License.
307 * You may obtain a copy of the License at
308 *
309 * http://www.apache.org/licenses/LICENSE-2.0
310 *
311 * Unless required by applicable law or agreed to in writing, software
312 * distributed under the License is distributed on an "AS IS" BASIS,
313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
314 * See the License for the specific language governing permissions and
315 * limitations under the License.
316 * =============================================================================
317 */function SN(n,e,t,s,r,a){a==null&&(a=.001);const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let u;r!=null&&(u=N(r,"scale","batchNorm"));let c;s!=null&&(c=N(s,"offset","batchNorm")),I(i.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(c==null||i.rank===c.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(u==null||i.rank===u.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const d={x:IN(o),scale:u,offset:c,mean:i,variance:l},p={varianceEpsilon:a},f=F.runKernel(Vo,d,p);return D(f,o.shape)}const Oa=R({batchNorm_:SN});function kN(n,e,t,s,r,a){const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let u;r!=null&&(u=N(r,"scale","batchNorm"));let c;return s!=null&&(c=N(s,"offset","batchNorm")),I(o.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`),I(i.rank===2||i.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`),I(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),u!=null&&I(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`),c!=null&&I(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`),Oa(o,i,l,c,u,a)}const dp=R({batchNorm2d_:kN});function TN(n,e,t,s,r,a){const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let u;r!=null&&(u=N(r,"scale","batchNorm"));let c;return s!=null&&(c=N(s,"offset","batchNorm")),I(o.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`),I(i.rank===3||i.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`),I(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),u!=null&&I(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`),c!=null&&I(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`),Oa(o,i,l,c,u,a)}const pp=R({batchNorm3d_:TN});function EN(n,e,t,s,r,a){const o=N(n,"x","batchNorm"),i=N(e,"mean","batchNorm"),l=N(t,"variance","batchNorm");let u;r!=null&&(u=N(r,"scale","batchNorm"));let c;return s!=null&&(c=N(s,"offset","batchNorm")),I(o.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`),I(i.rank===4||i.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}
317.`),I(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),u!=null&&I(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`),c!=null&&I(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`),Oa(o,i,l,c,u,a)}const fp=R({batchNorm4d_:EN});/**
318 * @license
319 * Copyright 2020 Google LLC. All Rights Reserved.
320 * Licensed under the Apache License, Version 2.0 (the "License");
321 * you may not use this file except in compliance with the License.
322 * You may obtain a copy of the License at
323 *
324 * http://www.apache.org/licenses/LICENSE-2.0
325 *
326 * Unless required by applicable law or agreed to in writing, software
327 * distributed under the License is distributed on an "AS IS" BASIS,
328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329 * See the License for the specific language governing permissions and
330 * limitations under the License.
331 * =============================================================================
332 */function RN(n,e,t){const s=N(n,"x","bincount"),r=N(e,"weights","bincount");I(s.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${s.dtype}`),I(t>=0,()=>`size must be non-negative, but got ${t}.`),I(r.size===s.size||r.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${r.shape}.`);const a={x:s,weights:r},o={size:t};return F.runKernel(vu,a,o)}const mp=R({bincount_:RN});/**
333 * @license
334 * Copyright 2023 Google LLC.
335 * Licensed under the Apache License, Version 2.0 (the "License");
336 * you may not use this file except in compliance with the License.
337 * You may obtain a copy of the License at
338 *
339 * http://www.apache.org/licenses/LICENSE-2.0
340 *
341 * Unless required by applicable law or agreed to in writing, software
342 * distributed under the License is distributed on an "AS IS" BASIS,
343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344 * See the License for the specific language governing permissions and
345 * limitations under the License.
346 * =============================================================================
347 */function DN(n,e){const t=N(n,"x","bitwiseAnd"),s=N(e,"y","bitwiseAnd");if(!ke(t.shape,s.shape))throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${t.shape}, y: ${s.shape}`);if(t.dtype!=="int32"||s.dtype!=="int32")throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${t.dtype} and type of y: ${s.dtype}`);const r={a:t,b:s};return F.runKernel(Bo,r)}const Jx=R({bitwiseAnd_:DN});/**
348 * @license
349 * Copyright 2021 Google LLC. All Rights Reserved.
350 * Licensed under the Apache License, Version 2.0 (the "License");
351 * you may not use this file except in compliance with the License.
352 * You may obtain a copy of the License at
353 *
354 * http://www.apache.org/licenses/LICENSE-2.0
355 *
356 * Unless required by applicable law or agreed to in writing, software
357 * distributed under the License is distributed on an "AS IS" BASIS,
358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359 * See the License for the specific language governing permissions and
360 * limitations under the License.
361 * =============================================================================
362 */function AN(n,e){const t=N(n,"s0","broadcastArgs","int32"),s=N(e,"s1","broadcastArgs","int32");if(t.rank!==1)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${t.rank}`);if(s.rank!==1)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${s.rank}`);const r={s0:t,s1:s};return F.runKernel(Cu,r)}const Zx=R({broadcastArgs_:AN});/**
363 * @license
364 * Copyright 2020 Google LLC. All Rights Reserved.
365 * Licensed under the Apache License, Version 2.0 (the "License");
366 * you may not use this file except in compliance with the License.
367 * You may obtain a copy of the License at
368 *
369 * http://www.apache.org/licenses/LICENSE-2.0
370 *
371 * Unless required by applicable law or agreed to in writing, softw
371are
372 * distributed under the License is distributed on an "AS IS" BASIS,
373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374 * See the License for the specific language governing permissions and
375 * limitations under the License.
376 * =============================================================================
377 */function ON(n,e){let t=N(n,"broadcastTo","x");const s=t.shape;if(qn(e),e.length<t.rank)throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${t.rank}.`);if(e.length>t.rank){const u=t.shape.slice();for(;u.length<e.length;)u.unshift(1);t=D(t,u)}const r=t.shape,a=Array.from(e);for(let u=e.length-1;u>=0;u--)if(r[u]===e[u])a[u]=1;else if(t.shape[u]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${e}].`);if(a.map((u,c)=>u>1?c:-1).filter(u=>u>=0).length===0)return ts(t);const i={x:t},l={reps:a};return F.runKernel(Qr,i,l)}const Qs=R({broadcastTo_:ON});/**
378 * @license
379 * Copyright 2018 Google LLC. All Rights Reserved.
380 * Licensed under the Apache License, Version 2.0 (the "License");
381 * you may not use this file except in compliance with the License.
382 * You may obtain a copy of the License at
383 *
384 * http://www.apache.org/licenses/LICENSE-2.0
385 *
386 * Unless required by applicable law or agreed to in writing, software
387 * distributed under the License is distributed on an "AS IS" BASIS,
388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
389 * See the License for the specific language governing permissions and
390 * limitations under the License.
391 * =============================================================================
392 */function _N(n){const t={x:N(n,"x","ceil","float32")};return F.runKernel(ea,t)}const gp=R({ceil_:_N});/**
393 * @license
394 * Copyright 2018 Google LLC. All Rights Reserved.
395 * Licensed under the Apache License, Version 2.0 (the "License");
396 * you may not use this file except in compliance with the License.
397 * You may obtain a copy of the License at
398 *
399 * http://www.apache.org/licenses/LICENSE-2.0
400 *
401 * Unless required by applicable law or agreed to in writing, software
402 * distributed under the License is distributed on an "AS IS" BASIS,
403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404 * See the License for the specific language governing permissions and
405 * limitations under the License.
406 * =============================================================================
407 */function FN(n,e,t){const s=N(n,"x","clipByValue");if(I(e<=t,()=>`Error in clip: min (${e}) must be less than or equal to max (${t}).`),e===t)return ta(s.shape,e,s.dtype);const r={x:s},a={clipValueMin:e,clipValueMax:t};return F.runKernel(na,r,a)}const Mt=R({clipByValue_:FN});function LN(n){return Je(n,0)}const yp=R({concat1d_:LN});function PN(n,e){return Je(n,e)}const xp=R({concat2d_:PN});function zN(n,e){return Je(n,e)}const bp=R({concat3d_:zN});function VN(n,e){return Je(n,e)}const wp=R({concat4d_:VN});/**
408 * @license
409 * Copyright 2020 Google LLC. All Rights Reserved.
410 * Licensed under the Apache License, Version 2.0 (the "License");
411 * you may not use this file except in compliance with the License.
412 * You may obtain a copy of the License at
413 *
414 * http://www.apache.org/licenses/LICENSE-2.0
415 *
416 * Unless required by applicable law or agreed to in writing, software
417 * distributed under the License is distributed on an "AS IS" BASIS,
418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419 * See the License for the specific language governing permissions and
420 * limitations under the License.
421 * =============================================================================
422 */function BN(n,e,t,s,r="NHWC",a=[1,1],o){const i=N(n,"x","conv2d","float32"),l=N(e,"filter","conv2d","float32");let u=i,c=!1;i.rank===3&&(c=!0,u=D(i,[1,i.shape[0],i.shape[1],i.shape[2]])),I(u.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${u.rank}.`),I(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),Ht("conv2d",s,o);const h=r==="NHWC"?u.shape[3]:u.shape[1];I(h===l.shape[2],()=>`Error in conv2d: depth of input (${h}) must match input depth for filter ${l.shape[2]}.`),I(It(t,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`),I(Er(a),()=>"Error in conv2D: Dilated rates should be larger than 0."),I(Er(t),()=>"Error in conv2D: Strides should be larger than 0.");const d={x:u,filter:l},p={strides:t,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o},f=F.runKernel(Mo,d,p);return c?D(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const rs=R({conv2d_:BN});function MN(n,e,t,s,r="NWC",a=1,o){const i=N(n,"x","conv1d"),l=N(e,"filter","conv1d");let u=i,c=!1;i.rank===2&&(c=!0,u=D(i,[1,i.shape[0],i.shape[1]])),I(u.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${u.rank}.`),I(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),Ht("conv1d",s,o),I(u.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`),I(It(t,a),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${t} and dilation '${a}'`),I(Er(a),()=>"Error in conv1D: Dilated rates should be larger than 0."),I(Er(t),()=>"Error in conv1D: Stride should be larger than 0."),I(r==="NWC",()=>`Error in conv1d: got dataFormat of ${r} but only NWC is currently supported.`);const h=D(l,[1,l.shape[0],l.shape[1],l.shape[2]]),d=D(u,[u.shape[0],1,u.shape[1],u.shape[2]]),m=rs(d,h,[1,t],s,"NHWC",[1,a],o);return c?D(m,[m.shape[2],m.shape[3]]):D(m,[m.shape[0],m.shape[2],m.shape[3]])}const Mc=R({conv1d_:MN});/**
423 * @license
424 * Copyright 2020 Google LLC. All Rights Reserved.
425 * Licensed under the Apache License, Version 2.0 (the "License");
426 * you may not use this file except in compliance with the License.
427 * You may obtain a copy of the License at
428 *
429 * http://www.apache.org/licenses/LICENSE-2.0
430 *
431 * Unless required by applicable law or agreed to in writing, software
432 * distributed under the License is distributed on an "AS IS" BASIS,
433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
434 * See the License for the specific language governing permissions and
435 * limitations under the License.
436 * =============================================================================
437 */function WN(n,e,t,s,r,a="NHWC",o){I(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let i=n,l=e,u=!1;e.rank===3&&(u=!0,l=D(e,[1,e.shape[0],e.shape[1],e.shape[2]]),i=[1,n[0],n[1],n[2]]),I(i.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`),I(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),I(t.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${t.rank}`);const c=a==="NHWC"?i[3]:i[1],h=a==="NHWC"?l.shape[3]:l.shape[1];I(c===t.shape[2],()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${t.shape[2]}.`),I(h===t.shape[3],()=>`Error in conv2dDerInput: depth of output (${h}) must match output depth for filter ${t.shape[3]}.`),Ht("conv2dDerInput",r,o);const d={dy:l,filter:t},p={strides:s,pad:r,dataFormat:a,dimRoundingMode:o,inputShape:i},f=F.runKernel(Wo,d,p);return u?D(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const vp=R({conv2DBackpropInput_:WN});function UN(n,e,t,s,r,a){const o=N(n,"x","conv2dTranspose"),i=N(e,"filter","conv2dTranspose");return vp(t,o,i,s,r,"NHWC",a)}const Wc=R({conv2dTranspose_:UN});/**
438 * @license
439 * Copyright 2020 Google LLC. All Rights Reserved.
440 * Licensed under the Apache License, Version 2.0 (the "License");
441 * you may not use this file except in compliance with the License.
442 * You may obtain a copy of the License at
443 *
444 * http://www.apache.org/licenses/LICENSE-2.0
445 *
446 * Unless required by applicable law or agreed to in writing, software
447 * distributed under the License is distributed on an "AS IS" BASIS,
448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
449 * See the License for the specific language governing permissions and
450 * limitations under the License.
451 * =============================================================================
452 */function GN(n,e,t,s,r="NDHWC",a=[1,1,1]){const o=N(n,"x","conv3d"),i=N(e,"filter","conv3d");let l=o,u=!1;o.rank===4&&(u=!0,l=D(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),I(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),I(i.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`),I(l.shape[4]===i.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${i.shape[3]}.`),I(It(t,a),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`),I(r==="NDHWC",()=>`Error in conv3d: got dataFormat of ${r} but only NDHWC is currently supported.`),I(Er(a),()=>"Error in conv3D: Dilated rates should be larger than 0."),I(Er(t),()=>"Error in conv3D: Strides should be larger than 0.");const c={x:l,filter:i},h={strides:t,pad:s,dataFormat:r,dilations:a},d=F.runKernel(Uo,c,h);return u?D(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const Cp=R({conv3d_:GN});/**
453 * @license
454 * Copyright 2020 Google LLC. All Rights Reserved.
455 * Licensed under the Apache License, Version 2.0 (the "License");
456 * you may not use this file except in compliance with the License.
457 * You may obtain a copy of the License at
458 *
459 * http://www.apache.org/licenses/LICENSE-2.0
460 *
461 * Unless required by applicable law or agreed to in writing, software
462 * distributed under the License is distributed on an "AS IS" BASIS,
463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464 * See the License for the specific language governing permissions and
465 * limitations under the License.
466 * =============================================================================
467 */function HN(n,e,t,s,r){I(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=D(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 l=a[4],u=o.shape[4];I(a.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${a.length}.`),I(o.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`),I(t.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${t.rank}`),I(l===t.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${t.shape[3]}.`),I(u===t.shape[4],()=>`Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${t.shape[4]}.`);const c={dy:o,filter:t},h={pad:r,strides:s,inputShape:a},d=F.runKernel($u,c,h);return i?D(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const Qx=R({conv3DBackpropInput_:HN});function jN(n,e,t,s,r){const a=N(n,"x","conv3dTranspose"),o=N(e,"filter","conv3dTranspose");return Qx(t,a,o,s,r)}const $p=R({conv3dTranspose_:jN});/**
468 * @license
469 * Copyright 2018 Google LLC. All Rights Reserved.
470 * Licensed under the Apache License, Version 2.0 (the "License");
471 * you may not use this file except in compliance with the License.
472 * You may obtain a copy of the License at
473 *
474 * http://www.apache.org/licenses/LICENSE-2.0
475 *
476 * Unless required by applicable law or agreed to in writing, software
477 * distributed under the License is distributed on an "AS IS" BASIS,
478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
479 * See the License for the specific language governing permissions and
480 * limitations under the License.
481 * =============================================================================
482 */function qN(n){const t={x:N(n,"x","cos","float32")};return F.runKernel(sa,t)}const qi=R({cos_:qN});/**
483 * @license
484 * Copyright 2018 Google LLC. All Rights Reserved.
485 * Licensed under the Apache License, Version 2.0 (the "License");
486 * you may not use this file except in compliance with the License.
487 * You may obtain a copy of the License at
488 *
489 * http://www.apache.org/licenses/LICENSE-2.0
490 *
491 * Unless required by applicable law or agreed to in writing, software
492 * distributed under the License is distributed on an "AS IS" BASIS,
493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494 * See the License for the specific language governing permissions and
495 * limitations under the License.
496 * =============================================================================
497 */function KN(n){const t={x:N(n,"x","cosh","float32")};return F.runKernel(ra,t)}const Uc=R({cosh_:KN});/**
498 * @license
499 * Copyright 2022 Google LLC. All Rights Reserved.
500 * Licensed under the Apache License, Version 2.0 (the 'License');
501 * you may not use this file except in compliance with the License.
502 * You may obtain a copy of the License at
503 *
504 * http://www.apache.org/licenses/LICENSE-2.0
505 *
506 * Unless required by applicable law or agreed to in writing, software
507 * distributed under the License is distributed on an 'AS IS' BASIS,
508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509 * See the License for the specific language governing permissions and
510 * limitations under the License.
511 * =============================================================================
512 */function XN(n,e=0,t=!1,s=!1){const a={x:N(n,"x","cumprod")},o={axis:e,exclusive:t,reverse:s};return F.runKernel(Nu,a,o)}const Co=R({cumprod_:XN});/**
513 * @license
514 * Copyright 2018 Google LLC. All Rights Reserved.
515 * Licensed under the Apache License, Version 2.0 (the "License");
516 * you may not use this file except in compliance with the License.
517 * You may obtain a copy of the License at
518 *
519 * http://www.apache.org/licenses/LICENSE-2.0
520 *
521 * Unless required by applicable law or agreed to in writing, software
522 * distributed under the License is distributed on an "AS IS" BASIS,
523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524 * See the License for the specific language governing permissions and
525 * limitations under the License.
526 * =============================================================================
527 */function YN(n,e=0,t=!1,s=!1){const a={x:N(n,"x","cumsum")},o={axis:e,exclusive:t,reverse:s};return F.runKernel(Go,a,o)}const Gc=R({cumsum_:YN});/**
528 * @license
529 * Copyright 2020 Google LLC. All Rights Reserved.
530 * Licensed under the Apache License, Version 2.0 (the "License");
531 * you may not use this file except in compliance with the License.
532 * You may obtain a copy of the License at
533 *
534 * http://www.apache.org/licenses/LICENSE-2.0
535 *
536 * Unless required by applicable law or agreed to in writing, software
537 * distributed under the License is distributed on an "AS IS" BASIS,
538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539 * See the License for the specific language governing permissions and
540 * limitations under the License.
541 * =============================================================================
542 */function JN(n,e,t,s=!1){const r=N(n,"x","denseBincount"),a=N(e,"weights","denseBincount");I(r.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${r.dtype}`),I(r.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${r.rank}.`),I(t>=0,()=>`size must be non-negative, but got ${t}.`),I(a.size===r.size||a.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${r.shape}, weights shape: ${a.shape}.`);const o={x:r,weights:a},i={size:t,binaryOutput:s};return F.runKernel(Iu,o,i)}const Yl=R({denseBincount_:JN});/**
543 * @license
544 * Copyright 2020 Google LLC. All Rights Reserved.
545 * Licensed under the Apache License, Version 2.0 (the "License");
546 * you may not use this file except in compliance with the License.
547 * You may obtain a copy of the License at
548 *
549 * http://www.apache.org/licenses/LICENSE-2.0
550 *
551 * Unless required by applicable law or agreed to in writing, software
552 * distributed under the License is distributed on an "AS IS" BASIS,
553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
554 * See the License for the specific language governing permissions and
555 * limitations under the License.
556 * =============================================================================
557 */function ZN(n,e,t="NHWC"){const s=N(n,"x","depthToSpace","float32"),r=t==="NHWC"?s.shape[1]:s.shape[2],a=t==="NHWC"?s.shape[2]:s.shape[3],o=t==="NHWC"?s.shape[3]:s.shape[1];I(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),I(r*e>=0,()=>`Negative dimension size caused by overflow when multiplying
558    ${r} and ${e}  for depthToSpace with input shape
559    ${s.shape}`),I(a*e>=0,()=>`Negative dimension size caused by overflow when multiplying
560    ${a} and ${e} for depthToSpace with input shape
561        ${s.shape}`),I(o%(e*e)===0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${o} for depthToSpace with input shape ${s.shape}`);const i={x:s},l={blockSize:e,dataFormat:t};return F.runKernel(Su,i,l)}const Np=R({depthToSpace_:ZN});/**
562 * @license
563 * Copyright 2020 Google LLC. All Rights Reserved.
564 * Licensed under the Apache License, Version 2.0 (the "License");
565 * you may not use this file except in compliance with the License.
566 * You may obtain a copy of the License at
567 *
568 * http://www.apache.org/licenses/LICENSE-2.0
569 *
570 * Unless required by applicable law or agreed to in writing, software
571 * distributed under the License is distributed on an "AS IS" BASIS,
572 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
573 * See the License for the specific language governing permissions and
574 * limitations under the License.
575 * =============================================================================
576 */function QN(n,e,t,s,r="NHWC",a=[1,1],o){const i=N(n,"x","depthwiseConv2d","float32"),l=N(e,"filter","depthwiseConv2d","float32");let u=i,c=!1;i.rank===3&&(c=!0,u=D(i,[1,i.shape[0],i.shape[1],i.shape[2]])),I(u.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`),I(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`);const h=r==="NHWC"?u.shape[3]:u.shape[1];I(h===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${h}) must match the inChannels dimension in filter ${l.shape[2]}.`),Ht("depthwiseConv2d",s,o);const d={x:u,filter:l},p={strides:t,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o},f=F.runKernel(Ho,d,p);return c?D(f,[f.shape[1],f.shape[2],f.shape[3]]):f}const _a=R({depthwiseConv2d_:QN});/**
577 * @license
578 * Copyright 2020 Google LLC. All Rights Reserved.
579 * Licensed under the Apache License, Version 2.0 (the "License");
580 * you may not use this file except in compliance with the License.
581 * You may obtain a copy of the License at
582 *
583 * http://www.apache.org/licenses/LICENSE-2.0
584 *
585 * Unless required by applicable law or agreed to in writing, software
586 * distributed under the License is distributed on an "AS IS" BASIS,
587 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
588 * See the License for the specific language governing permissions and
589 * limitations under the License.
590 * =============================================================================
591 */function eI(n){const t={x:N(n,"x","diag")};return F.runKernel(ku,t)}const eb=R({diag_:eI});/**
592 * @license
593 * Copyright 2020 Google LLC. All Rights Reserved.
594 * Licensed under the Apache License, Version 2.0 (the "License");
595 * you may not use this file except in compliance with the License.
596 * You may obtain a copy of the License at
597 *
598 * http://www.apache.org/licenses/LICENSE-2.0
599 *
600 * Unless required by applicable law or agreed to in writing, software
601 * distributed under the License is distributed on an "AS IS" BASIS,
602 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
603 * See the License for the specific language governing permissions and
604 * limitations under the License.
605 * =============================================================================
606 */function tI(n,e,t,s,r=[1,1],a="NHWC"){const o=N(n,"x","dilation2d"),i=N(e,"filter","dilation2d");I(o.rank===3||o.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`),I(i.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}
606.`),I(a==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`);let l=o,u=!1;o.rank===3&&(l=D(o,[1,o.shape[0],o.shape[1],o.shape[2]]),u=!0),I(l.shape[3]===i.shape[2],()=>`Error in dilation2d:  input and filter must have the same depth: ${l.shape[3]} vs ${i.shape[2]}`);const c={x:l,filter:i},h={strides:t,pad:s,dilations:r},d=F.runKernel(jo,c,h);return u?D(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const Ip=R({dilation2d_:tI});/**
607 * @license
608 * Copyright 2020 Google LLC. All Rights Reserved.
609 * Licensed under the Apache License, Version 2.0 (the "License");
610 * you may not use this file except in compliance with the License.
611 * You may obtain a copy of the License at
612 *
613 * http://www.apache.org/licenses/LICENSE-2.0
614 *
615 * Unless required by applicable law or agreed to in writing, software
616 * distributed under the License is distributed on an "AS IS" BASIS,
617 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
618 * See the License for the specific language governing permissions and
619 * limitations under the License.
620 * =============================================================================
621 */function nI(n,e){let t=N(n,"a","equal","string_or_numeric"),s=N(e,"b","equal","string_or_numeric");[t,s]=At(t,s),xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(qo,r)}const Yt=R({equal_:nI});/**
622 * @license
623 * Copyright 2020 Google LLC. All Rights Reserved.
624 * Licensed under the Apache License, Version 2.0 (the "License");
625 * you may not use this file except in compliance with the License.
626 * You may obtain a copy of the License at
627 *
628 * http://www.apache.org/licenses/LICENSE-2.0
629 *
630 * Unless required by applicable law or agreed to in writing, software
631 * distributed under the License is distributed on an "AS IS" BASIS,
632 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
633 * See the License for the specific language governing permissions and
634 * limitations under the License.
635 * =============================================================================
636 */function sI(n,e,t){const s=N(e,"a","where"),r=N(t,"b","where"),a=N(n,"condition","where","bool"),o=xe(xe(a.shape,s.shape),r.shape),i=Qs(a,o),l=Qs(s,o),u=Qs(r,o),c={condition:i,t:l,e:u};return F.runKernel(Ko,c)}const dt=R({where_:sI});/**
637 * @license
638 * Copyright 2020 Google LLC. All Rights Reserved.
639 * Licensed under the Apache License, Version 2.0 (the "License");
640 * you may not use this file except in compliance with the License.
641 * You may obtain a copy of the License at
642 *
643 * http://www.apache.org/licenses/LICENSE-2.0
644 *
645 * Unless required by applicable law or agreed to in writing, software
646 * distributed under the License is distributed on an "AS IS" BASIS,
647 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
648 * See the License for the specific language governing permissions and
649 * limitations under the License.
650 * =============================================================================
651 */function rI(n,e){let t=N(n,"a","div"),s=N(e,"b","div");[t,s]=At(t,s);const r=he(t,s),a=Be(r),o=Yt(s,a);return dt(o,a,r)}const Sp=R({divNoNan_:rI});/**
652 * @license
653 * Copyright 2020 Google LLC. All Rights Reserved.
654 * Licensed under the Apache License, Version 2.0 (the "License");
655 * you may not use this file except in compliance with the License.
656 * You may obtain a copy of the License at
657 *
658 * http://www.apache.org/licenses/LICENSE-2.0
659 *
660 * Unless required by applicable law or agreed to in writing, software
661 * distributed under the License is distributed on an "AS IS" BASIS,
662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
663 * See the License for the specific language governing permissions and
664 * limitations under the License.
665 * =============================================================================
666 */function aI(n,e){const t=N(n,"t1","dot"),s=N(e,"t2","dot");I((t.rank===1||t.rank===2)&&(s.rank===1||s.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${t.rank} and ${s.rank}.`);const r=t.rank===1?t.size:t.shape[1],a=s.rank===1?s.size:s.shape[0];if(I(r===a,()=>`Error in dot: inner dimensions of inputs must match, but got ${r} and ${a}.`),t.rank===1&&s.rank===1){const o=D(t,[1,-1]),i=D(s,[-1,1]),l=ve(o,i);return D(l,[])}else if(t.rank===1&&s.rank===2){const o=D(t,[1,-1]),i=D(s,[s.shape[0],s.shape[1]]),l=ve(o,i);return D(l,[l.size])}else if(t.rank===2&&s.rank===1){const o=D(s,[-1,1]),i=ve(t,o);return D(i,[i.size])}else{const o=D(s,[s.shape[0],s.shape[1]]);return ve(t,o)}}const kp=R({dot_:aI});/**
667 * @license
668 * Copyright 2021 Google LLC. All Rights Reserved.
669 * Licensed under the Apache License, Version 2.0 (the "License");
670 * you may not use this file except in compliance with the License.
671 * You may obtain a copy of the License at
672 *
673 * http://www.apache.org/licenses/LICENSE-2.0
674 *
675 * Unless required by applicable law or agreed to in writing, software
676 * distributed under the License is distributed on an "AS IS" BASIS,
677 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
678 * See the License for the specific language governing permissions and
679 * limitations under the License.
680 * =============================================================================
681 */function oI(n,...e){const t=e.map((r,a)=>N(r,`tensors${a}`,"einsum")),s={equation:n};return F.runKernel(Tu,t,s)}const js=R({einsum_:oI});/**
682 * @license
683 * Copyright 2023 Google LLC.
684 * Licensed under the Apache License, Version 2.0 (the "License");
685 * you may not use this file except in compliance with the License.
686 * You may obtain a copy of the License at
687 *
688 * http://www.apache.org/licenses/LICENSE-2.0
689 *
690 * Unless required by applicable law or agreed to in writing, software
691 * distributed under the License is distributed on an "AS IS" BASIS,
692 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
693 * See the License for the specific language governing permissions and
694 * limitations under the License.
695 * =============================================================================
696 */function iI(n,e){const t=N(n,"x","ensureShape","string_or_numeric");if(!kC(t.shape,e))throw new Error(`EnsureShape: Shape of tensor ${t.shape} is not compatible with expected shape ${e}`);return n}const tb=R({ensureShape_:iI});/**
697 * @license
698 * Copyright 2018 Google LLC. All Rights Reserved.
699 * Licensed under the Apache License, Version 2.0 (the "License");
700 * you may not use this file except in compliance with the License.
701 * You may obtain a copy of the License at
702 *
703 * http://www.apache.org/licenses/LICENSE-2.0
704 *
705 * Unless required by applicable law or agreed to in writing, software
706 * distributed under the License is distributed on an "AS IS" BASIS,
707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
708 * See the License for the specific language governing permissions and
709 * limitations under the License.
710 * =============================================================================
711 */function lI(n){let e=N(n,"x","erf");I(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=ee(e,"float32"));const t={x:e};return F.runKernel(aa,t)}const Hc=R({erf_:lI});/**
712 * @license
713 * Copyright 2020 Google LLC. All Rights Reserved.
714 * Licensed under the Apache License, Version 2.0 (the "License");
715 * you may not use this file except in compliance with the License.
716 * You may obtain a copy of the License at
717 *
718 * http://www.apache.org/licenses/LICENSE-2.0
719 *
720 * Unless required by applicable law or agreed to in writing, software
721 * distributed under the License is distributed on an "AS IS" BASIS,
722 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
723 * See the License for the specific language governing permissions and
724 * limitations under the License.
725 * =============================================================================
726 */function uI(n,e=null,t=!1){const r={x:N(n,"x","max")},a={reductionIndices:e,keepDims:t};return F.runKernel(Xo,r,a)}const on=R({max_:uI});/**
727 * @license
728 * Copyright 2020 Google Inc. All Rights Reserved.
729 * Licensed under the Apache License, Version 2.0 (the "License");
730 * you may not use this file except in compliance with the License.
731 * You may obtain a copy of the License at
732 *
733 * http://www.apache.org/licenses/LICENSE-2.0
734 *
735 * Unless required by applicable law or agreed to in writing, software
736 * distributed under the License is distributed on an "AS IS" BASIS,
737 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
738 * See the License for the specific language governing permissions and
739 * limitations under the License.
740 * =============================================================================
741 */function cI(n,e=null,t=!1){const r={x:N(n,"x","min")},a={axis:e,keepDims:t};return F.runKernel(Yo,r,a)}const Or=R({min_:cI});/**
742 * @license
743 * Copyright 2018 Google LLC. All Rights Reserved.
744 * Licensed under the Apache License, Version 2.0 (the "License");
745 * you may not use this file except in compliance with the License.
746 * You may obtain a copy of the License at
747 *
748 * http://www.apache.org/licenses/LICENSE-2.0
749 *
750 * Unless required by applicable law or agreed to in writing, software
751 * distributed under the License is distributed on an "AS IS" BASIS,
752 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
753 * See the License for the specific language governing permissions and
754 * limitations under the License.
755 * =============================================================================
756 */function hI(n,e="euclidean",t=null,s=!1){n=N(n,"x","norm");const r=nb(n,e,t);let a=r.shape;if(s){const o=Ie(t,n.shape);a=nt(r.shape,o)}return D(r,a)}function nb(n,e,t=null){if(n.rank===0)return rt(n);if(n.rank!==1&&t===null)return nb(D(n,[-1]),e,t);if(n.rank===1||typeof t=="number"||Array.isArray(t)&&t.length===1){if(e===1)return oe(rt(n),t);if(e===1/0)return on(rt(n),t);if(e===-1/0)return Or(rt(n),t);if(e==="euclidean"||e===2)return ln(oe(As(rt(n),pe(2,"int32")),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}if(Array.isArray(t)&&t.length===2){if(e===1)return on(oe(rt(n),t[0]),t[1]-1);if(e===1/0)return on(oe(rt(n),t[1]),t[0]);if(e===-1/0)return Or(oe(rt(n),t[1]),t[0]);
vendor: 4,547 bytes, lines 756-834
756if(e==="fro"||e==="euclidean")return ln(oe(Ye(n),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}throw new Error(`Error in norm: invalid axis: ${t}`)}const Fa=R({norm_:hI});/**
757 * @license
758 * Copyright 2022 Google LLC. All Rights Reserved.
759 * Licensed under the Apache License, Version 2.0 (the "License");
760 * you may not use this file except in compliance with the License.
761 * You may obtain a copy of the License at
762 *
763 * http://www.apache.org/licenses/LICENSE-2.0
764 *
765 * Unless required by applicable law or agreed to in writing, software
766 * distributed under the License is distributed on an "AS IS" BASIS,
767 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
768 * See the License for the specific language governing permissions and
769 * limitations under the License.
770 * =============================================================================
771 */function dI(n,e=null,t=!1){return Fa(n,"euclidean",e,t)}const Tp=R({euclideanNorm_:dI});/**
772 * @license
773 * Copyright 2018 Google LLC. All Rights Reserved.
774 * Licensed under the Apache License, Version 2.0 (the "License");
775 * you may not use this file except in compliance with the License.
776 * You may obtain a copy of the License at
777 *
778 * http://www.apache.org/licenses/LICENSE-2.0
779 *
780 * Unless required by applicable law or agreed to in writing, software
781 * distributed under the License is distributed on an "AS IS" BASIS,
782 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
783 * See the License for the specific language governing permissions and
784 * limitations under the License.
785 * =============================================================================
786 */function pI(n){const t={x:N(n,"x","exp")};return F.runKernel(oa,t)}const Wt=R({exp_:pI});/**
787 * @license
788 * Copyright 2020 Google LLC. All Rights Reserved.
789 * Licensed under the Apache License, Version 2.0 (the "License");
790 * you may not use this file except in compliance with the License.
791 * You may obtain a copy of the License at
792 *
793 * http://www.apache.org/licenses/LICENSE-2.0
794 *
795 * Unless required by applicable law or agreed to in writing, software
796 * distributed under the License is distributed on an "AS IS" BASIS,
797 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
798 * See the License for the specific language governing permissions and
799 * limitations under the License.
800 * =============================================================================
801 */function fI(n,e=0){const t=N(n,"x","expandDims","string_or_numeric");I(e<=t.rank,()=>"Axis must be <= rank of the tensor");const s={input:t},r={dim:e};return F.runKernel(Jo,s,r)}const mt=R({expandDims_:fI});/**
802 * @license
803 * Copyright 2018 Google LLC. All Rights Reserved.
804 * Licensed under the Apache License, Version 2.0 (the "License");
805 * you may not use this file except in compliance with the License.
806 * You may obtain a copy of the License at
807 *
808 * http://www.apache.org/licenses/LICENSE-2.0
809 *
810 * Unless required by applicable law or agreed to in writing, software
811 * distributed under the License is distributed on an "AS IS" BASIS,
812 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
813 * See the License for the specific language governing permissions and
814 * limitations under the License.
815 * =============================================================================
816 */function mI(n){const t={x:N(n,"x","expm1")};return F.runKernel(ia,t)}const Ep=R({expm1_:mI});/**
817 * @license
818 * Copyright 2020 Google LLC. All Rights Reserved.
819 * Licensed under the Apache License, Version 2.0 (the "License");
820 * you may not use this file except in compliance with the License.
821 * You may obtain a copy of the License at
822 *
823 * http://www.apache.org/licenses/LICENSE-2.0
824 *
825 * Unless required by applicable law or agreed to in writing, software
826 * distributed under the License is distributed on an "AS IS" BASIS,
827 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
828 * See the License for the specific language governing permissions and
829 * limitations under the License.
830 * =============================================================================
831 */function gI(n,e){const t=N(n,"x","tile","string_or_numeric");I(t.rank===e.length,()=>`Error in transpose: rank of input ${t.rank} must match length of reps ${e}.`);const s={x:t},r={reps:e};return F.runKernel(Qr,s,r)}const sn=R({tile_:gI});/**
832 * @license
833 * Copyright 2020 Google LLC. All Rights Reserved.
834 * Licensed under the Apache License, Version 2.0 (the "License");
835 * you may not use this file except in compliance with the License.
836 * You may obtain a copy of the License at
837 *
838 * http://www.apache.org/licenses/LICENSE-2.0
839 *
840 * Unless required by applicable law or agreed to in writing, software
841 * distributed under the License is distributed on an "AS IS" BASIS,
842 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
843 * See the License for the specific language governing permissions and
844 * limitations under the License.
845 * =============================================================================
846 */function yI(n,e,t,s="float32"){e==null&&(e=n);const r=$e([n,e],s),a=n<=e?n:e;for(let i=0;i<a;++i)r.set(1,i,i);const o=D(r.toTensor(),[n,e]);if(t==null)return o;if(t.length===1)return sn(mt(o,0),[t[0],1,1]);if(t.length===2)return sn(mt(mt(o,0),0),[t[0],t[1],1,1]);if(t.length===3)return sn(mt(mt(mt(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 jc=R({eye_:yI});/**
847 * @license
848 * Copyright 2018 Google LLC. All Rights Reserved.
849 * Licensed under the Apache License, Version 2.0 (the "License");
850 * you may not use this file except in compliance with the License.
851 * You may obtain a copy of the License at
852 *
853 * http://www.apache.org/licenses/LICENSE-2.0
854 *
855 * Unless required by applicable law or agreed to in writing, software
856 * distributed under the License is distributed on an "AS IS" BASIS,
857 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
858 * See the License for the specific language governing permissions and
859 * limitations under the License.
860 * =============================================================================
861 */function xI(n){const t={x:N(n,"x","floor","float32")};return F.runKernel(la,t)}const La=R({floor_:xI});/**
862 * @license
863 * Copyright 2018 Google LLC. All Rights Reserved.
864 * Licensed under the Apache License, Version 2.0 (the "License");
865 * you may not use this file except in compliance with the License.
866 * You may obtain a copy of the License at
867 *
868 * http://www.apache.org/licenses/LICENSE-2.0
869 *
870 * Unless required by applicable law or agreed to in writing, software
871 * distributed under the License is distributed on an "AS IS" BASIS,
872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
873 * See the License for the specific language governing permissions and
874 * limitations under the License.
875 * =============================================================================
876 */function bI(n,e,t=0,s=0){const r=N(n,"x","gather"),a=N(e,"indices","gather","int32"),o={x:r,indices:a},i={axis:t,batchDims:s};return F.runKernel(Zo,o,i)}const Pa=R({gather_:bI});/**
877 * @license
878 * Copyright 2020 Google LLC. All Rights Reserved.
879 * Licensed under the Apache License, Version 2.0 (the "License");
880 * you may not use this file except in compliance with the License.
881 * You may obtain a copy of the License at
882 *
883 * http://www.apache.org/licenses/LICENSE-2.0
884 *
885 * Unless required by applicable law or agreed to in writing, software
886 * distributed under the License is distributed on an "AS IS" BASIS,
887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
888 * See the License for the specific language governing permissions and
889 * limitations under the License.
890 * =============================================================================
891 */function wI(n,e){let t=N(n,"a","greater","string_or_numeric"),s=N(e,"b","greater","string_or_numeric");[t,s]=At(t,s),xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(Qo,r)}const Lt=R({greater_:wI});/**
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 vI(n,e){let t=N(n,"a","greaterEqual","string_or_numeric"),s=N(e,"b","greaterEqual","string_or_numeric");[t,s]=At(t,s),xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(ua,r)}const os=R({greaterEqual_:vI});/**
907 * @license
908 * Copyright 2020 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 CI(n){const t={input:N(n,"input","imag")};return F.runKernel(Eu,t)}const Ki=R({imag_:CI});/**
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 $I(n){const t={x:N(n,"x","isFinite")};return F.runKernel(ca,t)}const Rp=R({isFinite_:$I});/**
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 NI(n){const t={x:N(n,"x","isInf")};return F.runKernel(ha,t)}const Dp=R({isInf_:NI});/**
952 * @license
953 * Copyright 2018 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 II(n){const t={x:N(n,"x","isNaN")};return F.runKernel(da,t)}const Ap=R({isNaN_:II});/**
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 SI(n,e){let t=N(n,"a","less","string_or_numeric"),s=N(e,"b","less","string_or_numeric");[t,s]=At(t,s),xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(ei,r)}const _r=R({less_:SI});/**
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 kI(n,e){let t=N(n,"a","lessEqual","string_or_numeric"),s=N(e,"b","lessEqual","string_or_numeric");[t,s]=At(t,s),xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(ti,r)}const Ls=R({lessEqual_:kI});/**
997 * @license
998 * Copyright 2018 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 sb(n,e,t){if(t<=0)throw new Error("The number of values should be positive.");const s={start:n,stop:e,num:t};return F.runKernel(Ru,{},s)}/**
1012 * @license
1013 * Copyright 2020 Google LLC. All Rights Reserved.
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 TI(n,e=5,t=1,s=1,r=.5){const a=N(n,"x","localResponseNormalization");I(a.rank===4||a.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got
1027               rank ${a.rank}.`),I(Ad(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let o=a,i=!1;a.rank===3&&(i=!0,o=D(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const l={x:o},u={depthRadius:e,bias:t,alpha:s,beta:r},c=F.runKernel(ni,l,u);return i?D(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const Op=R({localResponseNormalization_:TI});/**
1028 * @license
1029 * Copyright 2018 Google LLC. All Rights Reserved.
1030 * Licensed under the Apache License, Version 2.0 (the "License");
1031 * you may not use this file except in compliance with the License.
1032 * You may obtain a copy of the License at
1033 *
1034 * http://www.apache.org/licenses/LICENSE-2.0
1035 *
1036 * Unless required by applicable law or agreed to in writing, software
1037 * distributed under the License is distributed on an "AS IS" BASIS,
1038 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1039 * See the License for the specific language governing permissions and
1040 * limitations under the License.
1041 * =============================================================================
1042 */function EI(n){const t={x:N(n,"x","log","float32")};return F.runKernel(pa,t)}const Jt=R({log_:EI});/**
1043 * @license
1044 * Copyright 2018 Google LLC. All Rights Reserved.
1045 * Licensed under the Apache License, Version 2.0 (the "License");
1046 * you may not use this file except in compliance with the License.
1047 * You may obtain a copy of the License at
1048 *
1049 * http://www.apache.org/licenses/LICENSE-2.0
1050 *
1051 * Unless required by applicable law or agreed to in writing, software
1052 * distributed under the License is distributed on an "AS IS" BASIS,
1053 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1054 * See the License for the specific language governing permissions and
1055 * limitations under the License.
1056 * =============================================================================
1057 */function RI(n){const t={x:N(n,"x","log1p")};return F.runKernel(fa,t)}const Xi=R({log1p_:RI});/**
1058 * @license
1059 * Copyright 2018 Google LLC. All Rights Reserved.
1060 * Licensed under the Apache License, Version 2.0 (the "License");
1061 * you may not use this file except in compliance with the License.
1062 * You may obtain a copy of the License at
1063 *
1064 * http://www.apache.org/licenses/LICENSE-2.0
1065 *
1066 * Unless required by applicable law or agreed to in writing, software
1067 * distributed under the License is distributed on an "AS IS" BASIS,
1068 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1069 * See the License for the specific language governing permissions and
1070 * limitations under the License.
1071 * =============================================================================
1072 */function DI(n){const t={x:N(n,"x","neg")};return F.runKernel(si,t)}const Ve=R({neg_:DI});/**
1073 * @license
1074 * Copyright 2018 Google LLC. All Rights Reserved.
1075 * Licensed under the Apache License, Version 2.0 (the "License");
1076 * you may not use this file except in compliance with the License.
1077 * You may obtain a copy of the License at
1078 *
1079 * http://www.apache.org/licenses/LICENSE-2.0
1080 *
1081 * Unless required by applicable law or agreed to in writing, software
1082 * distributed under the License is distributed on an "AS IS" BASIS,
1083 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1084 * See the License for the specific language governing permissions and
1085 * limitations under the License.
1086 * =============================================================================
1087 */function AI(n){const t={x:N(n,"x","softplus")};return F.runKernel(ma,t)}const gr=R({softplus_:AI});/**
1088 * @license
1089 * Copyright 2018 Google LLC. All Rights Reserved.
1090 * Licensed under the Apache License, Version 2.0 (the "License");
1091 * you may not use this file except in compliance with the License.
1092 * You may obtain a copy of the License at
1093 *
1094 * http://www.apache.org/licenses/LICENSE-2.0
1095 *
1096 * Unless required by applicable law or agreed to in writing, software
1097 * distributed under the License is distributed on an "AS IS" BASIS,
1098 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1099 * See the License for the specific language governing permissions and
1100 * limitations under the License.
1101 * =============================================================================
1102 */function OI(n){const e=N(n,"x","logSigmoid");return Hn(s=>({value:Ve(gr(Ve(s))),gradFunc:o=>O(o,Mn(Ve(s)))}))(e)}const _p=R({logSigmoid_:OI});/**
1103 * @license
1104 * Copyright 2020 Google Inc. All Rights Reserved.
1105 * Licensed under the Apache License, Version 2.0 (the "License");
1106 * you may not use this file except in compliance with the License.
1107 * You may obtain a copy of the License at
1108 *
1109 * http://www.apache.org/licenses/LICENSE-2.0
1110 *
1111 * Unless required by applicable law or agreed to in writing, software
1112 * distributed under the License is distributed on an "AS IS" BASIS,
1113 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1114 * See the License for the specific language governing permissions and
1115 * limitations under the License.
1116 * =============================================================================
1117 */function _I(n,e=-1){const t=N(n,"logits","logSoftmax");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and axis was ${e}`);return Hn((r,a)=>{const i=on(r,e,!0),l=ie(r,i),u=ie(ee(l,"float32"),Jt(oe(Wt(l),e,!0)));return a([u]),{value:u,gradFunc:(h,d)=>{const[p]=d,f=!0,g=Wt(p);return ie(h,O(oe(h,e,f),g))}}})(t)}const qc=R({logSoftmax_:_I});/**
1118 * @license
1119 * Copyright 2020 Google LLC. All Rights Reserved.
1120 * Licensed under the Apache License, Version 2.0 (the "License");
1121 * you may not use this file except in compliance with the License.
1122 * You may obtain a copy of the License at
1123 *
1124 * http://www.apache.org/licenses/LICENSE-2.0
1125 *
1126 * Unless required by applicable law or agreed to in writing, software
1127 * distributed under the License is distributed on an "AS IS" BASIS,
1128 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1129 * See the License for the specific language governing permissions and
1130 * limitations under the License.
1131 * =============================================================================
1132 */function FI(n,e=null,t=!1){const s=N(n,"x","logSumExp"),r=Ie(e,s.shape),a=on(s,r,!0),o=ie(s,a),i=Wt(o),l=oe(i,r),u=Jt(l),c=te(D(a,u.shape),u);if(t){const h=nt(c.shape,r);return D(c,h)}return c}const Yi=R({logSumExp_:FI});/**
1133 * @license
1134 * Copyright 2020 Google LLC. All Rights Reserved.
1135 * Licensed under the Apache License, Version 2.0 (the "License");
1136 * you may not use this file except in compliance with the License.
1137 * You may obtain a copy of the License at
1138 *
1139 * http://www.apache.org/licenses/LICENSE-2.0
1140 *
1141 * Unless required by applicable law or agreed to in writing, software
1142 * distributed under the License is distributed on an "AS IS" BASIS,
1143 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1144 * See the License for the specific language governing permissions and
1145 * limitations under the License.
1146 * =============================================================================
1147 */function LI(n,e){const t=N(n,"a","logicalAnd","bool"),s=N(e,"b","logicalAnd","bool");xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(ri,r)}const wn=R({logicalAnd_:LI});/**
1148 * @license
1149 * Copyright 2020 Google LLC. All Rights Reserved.
1150 * Licensed under the Apache License, Version 2.0 (the "License");
1151 * you may not use this file except in compliance with the License.
1152 * You may obtain a copy of the License at
1153 *
1154 * http://www.apache.org/licenses/LICENSE-2.0
1155 *
1156 * Unless required by applicable law or agreed to in writing, software
1157 * distributed under the License is distributed on an "AS IS" BASIS,
1158 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1159 * See the License for the specific language governing permissions and
1160 * limitations under the License.
1161 * =============================================================================
1162 */function PI(n){const t={x:N(n,"x","logicalNot","bool")};return F.runKernel(ai,t)}const Ji=R({logicalNot_:PI});/**
1163 * @license
1164 * Copyright 2020 Google LLC. All Rights Reserved.
1165 * Licensed under the Apache License, Version 2.0 (the "License");
1166 * you may not use this file except in compliance with the License.
1167 * You may obtain a copy of the License at
1168 *
1169 * http://www.apache.org/licenses/LICENSE-2.0
1170 *
1171 * Unless required by applicable law or agreed to in writing, software
1172 * distributed under the License is distributed on an "AS IS" BASIS,
1173 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1174 * See the License for the specific language governing permissions and
1175 * limitations under the License.
1176 * =============================================================================
1177 */function zI(n,e){const t=N(n,"a","logicalOr","bool"),s=N(e,"b","logicalOr","bool");xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(oi,r)}const Kc=R({logicalOr_:zI});/**
1178 * @license
1179 * Copyright 2020 Google LLC. All Rights Reserved.
1180 * Licensed under the Apache License, Version 2.0 (the "License");
1181 * you may not use this file except in compliance with the License.
1182 * You may obtain a copy of the License at
1183 *
1184 * http://www.apache.org/licenses/LICENSE-2.0
1185 *
1186 * Unless required by applicable law or agreed to in writing, software
1187 * distributed under the License is distributed on an "AS IS" BASIS,
1188 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1189 * See the License for the specific language governing permissions and
1190 * limitations under the License.
1191 * =============================================================================
1192 */function VI(n,e){const t=N(n,"a","logicalXor","bool"),s=N(e,"b","logicalXor","bool");return xe(t.shape,s.shape),wn(Kc(n,e),Ji(wn(n,e)))}const Fp=R({logicalXor_:VI});/**
1193 * @license
1194 * Copyright 2022 Google LLC. All Rights Reserved.
1195 * Licensed under the Apache License, Version 2.0 (the "License");
1196 * you may not use this file except in compliance with the License.
1197 * You may obtain a copy of the License at
1198 *
1199 * http://www.apache.org/licenses/LICENSE-2.0
1200 *
1201 * Unless required by applicable law or agreed to in writing, software
1202 * distributed under the License is distributed on an "AS IS" BASIS,
1203 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1204 * See the License for the specific language governing permissions and
1205 * limitations under the License.
1206 * =============================================================================
1207 */const $l=2147483648;function BI(n,e,t="left"){const s=N(n,"sortedSequence","searchSorted"),r=N(e,"values","searchSorted"),a=s.shape[s.shape.length-1],o=r.shape[r.shape.length-1],i=D(s,[-1,a]),l=D(r,[-1,o]);if(i.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(i.shape[0]!==l.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(H(l.shape)>=$l)throw new Error(`values tensor size must less than ${$l}`);if(i.shape[1]>=$l)throw new Error(`trailing dim_size must less than ${$l} for int32 output type, was ${i.shape[1]}`);const u={sortedSequence:i,values:l},c={side:t};return F.runKernel(Du,u,c)}const Xc=R({searchSorted_:BI});/**
1208 * @license
1209 * Copyright 2022 Google LLC. All Rights Reserved.
1210 * Licensed under the Apache License, Version 2.0 (the "License");
1211 * you may not use this file except in compliance with the License.
1212 * You may obtain a copy of the License at
1213 *
1214 * http://www.apache.org/licenses/LICENSE-2.0
1215 *
1216 * Unless required by applicable law or agreed to in writing, software
1217 * distributed under the License is distributed on an "AS IS" BASIS,
1218 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1219 * See the License for the specific language governing permissions and
1220 * limitations under the License.
1221 * =============================================================================
1222 */function rb(n,e){return Xc(n,e,"left")}/**
1223 * @license
1224 * Copyright 2020 Google LLC. All Rights Reserved.
1225 * Licensed under the Apache License, Version 2.0 (the "License");
1226 * you may not use this file except in compliance with the License.
1227 * You may obtain a copy of the License at
1228 *
1229 * http://www.apache.org/licenses/LICENSE-2.0
1230 *
1231 * Unless required by applicable law or agreed to in writing, software
1232 * distributed under the License is distributed on an "AS IS" BASIS,
1233 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1234 * See the License for the specific language governing permissions and
1235 * limitations under the License.
1236 * =============================================================================
1237 */function MI(n,e,t,s,r){const a=N(n,"x","maxPool"),o=1;let i=a,l=!1;a.rank===3&&(l=!0,i=D(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(i.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${i.rank}.`),I(It(t,o),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`),Ht("maxPool",s,r);const u={x:i},c={filterSize:e,strides:t,pad:s,dimRoundingMode:r},h=F.runKernel(ii,u,c);return l?D(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const Zi=R({maxPool_:MI});/**
1238 * @license
1239 * Copyright 2020 Google LLC. All Rights Reserved.
1240 * Licensed under the Apache License, Version 2.0 (the "License");
1241 * you may not use this file except in compliance with the License.
1242 * You may obtain a copy of the License at
1243 *
1244 * http://www.apache.org/licenses/LICENSE-2.0
1245 *
1246 * Unless required by applicable law or agreed to in writing, software
1247 * distributed under the License is distributed on an "AS IS" BASIS,
1248 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1249 * See the License for the specific language governing permissions and
1250 * limitations under the License.
1251 * =============================================================================
1252 */function WI(n,e=[1,1,1],t,s,r,a="NDHWC"){const o=N(n,"x","maxPool3d");let i=o,l=!1;o.rank===4&&(l=!0,i=D(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),I(i.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`),I(a==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),Ht("maxPool3d",s,r);const u={x:i},c={filterSize:e,strides:t,pad:s,dimRoundingMode:r,dataFormat:a},h=F.runKernel(li,u,c);return l?D(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const Lp=R({maxPool3d_:WI});/**
1253 * @license
1254 * Copyright 2018 Google LLC. All Rights Reserved.
1255 * Licensed under the Apache License, Version 2.0 (the "License");
1256 * you may not use this file except in compliance with the License.
1257 * You may obtain a copy of the License at
1258 *
1259 * http://www.apache.org/licenses/LICENSE-2.0
1260 *
1261 * Unless required by applicable law or agreed to in writing, software
1262 * distributed under the License is distributed on an "AS IS" BASIS,
1263 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1264 * See the License for the specific language governing permissions and
1265 * limitations under the License.
1266 * =============================================================================
1267 */function UI(n,e,t,s,r=!1){const o={x:N(n,"x","maxPoolWithArgmax")},i={filterSize:e,strides:t,pad:s,includeBatchInIndex:r},l=F.runKernel(Au,o,i);return{result:l[0],indexes:l[1]}}const ab=R({maxPoolWithArgmax_:UI});/**
1268 * @license
1269 * Copyright 2020 Google Inc. All Rights Reserved.
1270 * Licensed under the Apache License, Version 2.0 (the "License");
1271 * you may not use this file except in compliance with the License.
1272 * You may obtain a copy of the License at
1273 *
1274 * http://www.apache.org/licenses/LICENSE-2.0
1275 *
1276 * Unless required by applicable law or agreed to in writing, software
1277 * distributed under the License is distributed on an "AS IS" BASIS,
1278 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1279 * See the License for the specific language governing permissions and
1280 * limitations under the License.
1281 * =============================================================================
1282 */function GI(n,e=null,t=!1){const r={x:N(n,"x","mean")},a={axis:e,keepDims:t};return F.runKernel(ui,r,a)}const je=R({mean_:GI});/**
1283 * @license
1284 * Copyright 2018 Google LLC. All Rights Reserved.
1285 * Licensed under the Apache License, Version 2.0 (the "License");
1286 * you may not use this file except in compliance with the License.
1287 * You may obtain a copy of the License at
1288 *
1289 * http://www.apache.org/licenses/LICENSE-2.0
1290 *
1291 * Unless required by applicable law or agreed to in writing, software
1292 * distributed under the License is distributed on an "AS IS" BASIS,
1293 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1294 * See the License for the specific language governing permissions and
1295 * limitations under the License.
1296 * =============================================================================
1297 */function et(n,e="float32"){if(qn(n),e==="complex64"){const s=et(n,"float32"),r=et(n,"float32");return Cs(s,r)}const t=hn(H(n),e);return F.makeTensor(t,n,e)}/**
1298 * @license
1299 * Copyright 2018 Google LLC. All Rights Reserved.
1300 * Licensed under the Apache License, Version 2.0 (the "License");
1301 * you may not use this file except in compliance with the License.
1302 * You may obtain a copy of the License at
1303 *
1304 * http://www.apache.org/licenses/LICENSE-2.0
1305 *
1306 * Unless required by applicable law or agreed to in writing, software
1307 * distributed under the License is distributed on an "AS IS" BASIS,
1308 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1309 * See the License for the specific language governing permissions and
1310 * limitations under the License.
1311 * =============================================================================
1312 */function Vt(n,e="float32"){if(qn(n),e==="complex64"){const s=Vt(n,"float32"),r=et(n,"float32");return Cs(s,r)}const t=qy(H(n),e);return F.makeTensor(t,n,e)}/**
1313 * @license
1314 * Copyright 2021 Google LLC. All Rights Reserved.
1315 * Licensed under the Apache License, Version 2.0 (the "License");
1316 * you may not use this file except in compliance with the License.
1317 * You may obtain a copy of the License at
1318 *
1319 * http://www.apache.org/licenses/LICENSE-2.0
1320 *
1321 * Unless required by applicable law or agreed to in writing, software
1322 * distributed under the License is distributed on an "AS IS" BASIS,
1323 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1324 * See the License for the specific language governing permissions and
1325 * limitations under the License.
1326 * =============================================================================
1327 */function ob(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 s=N(n,"x","meshgrid",n instanceof lt?n.dtype:"float32");if(e===void 0)return[s];let r=N(e,"y","meshgrid",e instanceof lt?e.dtype:"float32");const a=H(s.shape),o=H(r.shape);return t==="xy"?(s=D(s,[1,-1]),r=D(r,[-1,1]),[ve(Vt([o,1],s.dtype),s),ve(r,Vt([1,a],r.dtype))]):(s=D(s,[-1,1]),r=D(r,[1,-1]),[ve(s,Vt([1,o],s.dtype)),ve(Vt([a,1],r.dtype),r)])}/**
1328 * @license
1329 * Copyright 2020 Google LLC. All Rights Reserved.
1330 * Licensed under the Apache License, Version 2.0 (the "License");
1331 * you may not use this file except in compliance with the License.
1332 * You may obtain a copy of the License at
1333 *
1334 * http://www.apache.org/licenses/LICENSE-2.0
1335 *
1336 * Unless required by applicable law or agreed to in writing, software
1337 * distributed under the License is distributed on an "AS IS" BASIS,
1338 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1339 * See the License for the specific language governing permissions and
1340 * limitations under the License.
1341 * =============================================================================
1342 */function HI(n,e){let t=N(n,"a","minimum"),s=N(e,"b","minimum");[t,s]=At(t,s),t.dtype==="bool"&&(t=ee(t,"int32"),s=ee(s,"int32")),xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(ga,r)}const Ss=R({minimum_:HI});/**
1343 * @license
1344 * Copyright 2020 Google LLC. All Rights Reserved.
1345 * Licensed under the Apache License, Version 2.0 (the "License");
1346 * you may not use this file except in compliance with the License.
1347 * You may obtain a copy of the License at
1348 *
1349 * http://www.apache.org/licenses/LICENSE-2.0
1350 *
1351 * Unless required by applicable law or agreed to in writing, software
1352 * distributed under the License is distributed on an "AS IS" BASIS,
1353 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1354 * See the License for the specific language governing permissions and
1355 * limitations under the License.
1356 * =============================================================================
1357 */function jI(n,e,t){I(t==="reflect"||t==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${t}.`);const s=N(n,"x","mirrorPad");if(s.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");I(e.length===s.rank,()=>`Padding doesn't match input. Must be ${s.rank}. Got ${e.length}.`);const r=t==="reflect"?1:0;for(let i=0;i<s.rank;i++)I(e[i].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),I(e[i][0]>=0&&e[i][0]<=s.shape[i]-r&&e[i][1]>=0&&e[i][1]<=s.shape[i]-r,()=>`Padding in dimension ${i} cannot be greater than or equal to ${s.shape[i]-r} or less than 0 for input of shape ${s.shape}`);const a={paddings:e,mode:t},o={x:s};return F.runKernel(ci,o,a)}const Pp=R({mirrorPad_:jI});/**
1358 * @license
1359 * Copyright 2020 Google LLC. All Rights Reserved.
1360 * Licensed under the Apache License, Version 2.0 (the "License");
1361 * you may not use this file except in compliance with the License.
1362 * You may obtain a copy of the License at
1363 *
1364 * http://www.apache.org/licenses/LICENSE-2.0
1365 *
1366 * Unless required by applicable law or agreed to in writing, software
1367 * distributed under the License is distributed on an "AS IS" BASIS,
1368 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1369 * See the License for the specific language governing permissions and
1370 * limitations under the License.
1371 * =============================================================================
1372 */function qI(n,e){let t=N(n,"a","mod"),s=N(e,"b","mod");[t,s]=At(t,s);const r={a:t,b:s};return F.runKernel(ya,r)}const zp=R({mod_:qI});/**
1373 * @license
1374 * Copyright 2020 Google LLC. All Rights Reserved.
1375 * Licensed under the Apache License, Version 2.0 (the "License");
1376 * you may not use this file except in compliance with the License.
1377 * You may obtain a copy of the License at
1378 *
1379 * http://www.apache.org/licenses/LICENSE-2.0
1380 *
1381 * Unless required by applicable law or agreed to in writing, software
1382 * distributed under the License is distributed on an "AS IS" BASIS,
1383 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1384 * See the License for the specific language governing permissions and
1385 * limitations under the License.
1386 * =============================================================================
1387 */function KI(n,e=null,t=!1){n=N(n,"x","moments");const s=Ie(e,n.shape),r=je(n,s,t);let a=r.shape;t||(a=nt(r.shape,s));const o=Ye(ie(ee(n,"float32"),D(r,a))),i=je(o,s,t);return{mean:r,variance:i}}const Qi=R({moments_:KI});function XI(n,e,t,s){const r=N(e,"data","multiRNNCell"),a=Gl(t,"c","multiRNNCell"),o=Gl(s,"h","multiRNNCell");let i=r;const l=[];for(let h=0;h<n.length;h++){const d=n[h](i,a[h],o[h]);l.push(d[0]),l.push(d[1]),i=d[1]}const u=[],c=[];for(let h=0;h<l.length;h+=2)u.push(l[h]),c.push(l[h+1]);return[u,c]}const ib=R({multiRNNCell_:XI});/**
1388 * @license
1389 * Copyright 2020 Google LLC. All Rights Reserved.
1390 * Licensed under the Apache License, Version 2.0 (the "License");
1391 * you may not use this file except in compliance with the License.
1392 * You may obtain a copy of the License at
1393 *
1394 * http://www.apache.org/licenses/LICENSE-2.0
1395 *
1396 * Unless required by applicable law or agreed to in writing, software
1397 * distributed under the License is distributed on an "AS IS" BASIS,
1398 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1399 * See the License for the specific language governing permissions and
1400 * limitations under the License.
1401 * =============================================================================
1402 */function YI(n,e,t,s=!1){const r=N(n,"logits","multinomial"),a=r.size,o=r.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 l={logits:o===1?D(r,[1,-1]):r},u={numSamples:e,seed:t,normalized:s},c=F.runKernel(Ou,l,u);return o===1?D(c,[c.size]):c}const lb=R({multinomial_:YI});/**
1403 * @license
1404 * Copyright 2020 Google LLC. All Rights Reserved.
1405 * Licensed under the Apache License, Version 2.0 (the "License");
1406 * you may not use this file except in compliance with the License.
1407 * You may obtain a copy of the License at
1408 *
1409 * http://www.apache.org/licenses/LICENSE-2.0
1410 *
1411 * Unless required by applicable law or agreed to in writing, software
1412 * distributed under the License is distributed on an "AS IS" BASIS,
1413 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414 * See the License for the specific language governing permissions and
1415 * limitations under the License.
1416 * =============================================================================
1417 */function JI(n,e){let t=N(n,"a","notEqual","string_or_numeric"),s=N(e,"b","notEqual","string_or_numeric");[t,s]=At(t,s),xe(t.shape,s.shape);const r={a:t,b:s};return F.runKernel(hi,r)}const sr=R({notEqual_:JI});/**
1418 * @license
1419 * Copyright 2020 Google LLC. All Rights Reserved.
1420 * Licensed under the Apache License, Version 2.0 (the "License");
1421 * you may not use this file except in compliance with the License.
1422 * You may obtain a copy of the License at
1423 *
1424 * http://www.apache.org/licenses/LICENSE-2.0
1425 *
1426 * Unless required by applicable law or agreed to in writing, software
1427 * distributed under the License is distributed on an "AS IS" BASIS,
1428 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1429 * See the License for the specific language governing permissions and
1430 * limitations under the License.
1431 * =============================================================================
1432 */function ZI(n,e,t=1,s=0,r="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const o={indices:N(n,"indices","oneHot","int32")},i={dtype:r,depth:e,onValue:t,offValue:s};return F.runKernel(di,o,i)}const Fr=R({oneHot_:ZI});/**
1433 * @license
1434 * Copyright 2018 Google LLC. All Rights Reserved.
1435 * Licensed under the Apache License, Version 2.0 (the "License");
1436 * you may not use this file except in compliance with the License.
1437 * You may obtain a copy of the License at
1438 *
1439 * http://www.apache.org/licenses/LICENSE-2.0
1440 *
1441 * Unless required by applicable law or agreed to in writing, software
1442 * distributed under the License is distributed on an "AS IS" BASIS,
1443 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1444 * See the License for the specific language governing permissions and
1445 * limitations under the License.
1446 * =============================================================================
1447 */function QI(n){const t={x:N(n,"x","onesLike")};return F.runKernel(pi,t)}const Zt=R({onesLike_:QI});function eS(n,e){const t=N(n,"v1","outerProduct"),s=N(e,"v2","outerProduct");I(t.rank===1&&s.rank===1,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${t.rank} and ${s.rank}.`);const r=D(t,[-1,1]),a=D(s,[1,-1]);return ve(r,a)}const ub=R({outerProduct_:eS});/**
1448 * @license
1449 * Copyright 2020 Google LLC. All Rights Reserved.
1450 * Licensed under the Apache License, Version 2.0 (the "License");
1451 * you may not use this file except in compliance with the License.
1452 * You may obtain a copy of the License at
1453 *
1454 * http://www.apache.org/licenses/LICENSE-2.0
1455 *
1456 * Unless required by applicable law or agreed to in writing, software
1457 * distributed under the License is distributed on an "AS IS" BASIS,
1458 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1459 * See the License for the specific language governing permissions and
1460 * limitations under the License.
1461 * =============================================================================
1462 */function tS(n,e,t=0){const s=N(n,"x","pad");if(s.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const r={paddings:e,constantValue:t},a={x:s};return F.runKernel(fi,a,r)}const is=R({pad_:tS});function nS(n,e,t=0){return I(e.length===2,()=>"Invalid number of paddings. Must be length of 2."),is(n,[e],t)}const cb=R({pad1d_:nS});function sS(n,e,t=0){return I(e.length===2&&e[0].length===2&&e[1].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),is(n,e,t)}const hb=R({pad2d_:sS});function rS(n,e,t=0){return I(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."),is(n,e,t)}const db=R({pad3d_:rS});function aS(n,e,t=0){return I(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."),is(n,e,t)}const pb=R({pad4d_:aS});/**
1463 * @license
1464 * Copyright 2020 Google LLC. All Rights Reserved.
1465 * Licensed under the Apache License, Version 2.0 (the "License");
1466 * you may not use this file except in compliance with the License.
1467 * You may obtain a copy of the License at
1468 *
1469 * http://www.apache.org/licenses/LICENSE-2.0
1470 *
1471 * Unless required by applicable law or agreed to in writing, software
1472 * distributed under the License is distributed on an "AS IS" BASIS,
1473 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1474 * See the License for the specific language governing permissions and
1475 * limitations under the License.
1476 * =============================================================================
1477 */function oS(n,e,t){const s=N(n,"x","spaceToBatchND");I(s.rank>=1+e.length,()=>`input rank ${s.rank} should be > than [blockShape] ${e.length}`),I(t.length===e.length,()=>`paddings.shape[0] ${t.length} must be equal to [blockShape] ${e.length}`),I(s.shape.reduce((o,i,l)=>l>0&&l<=e.length?o&&(i+t[l-1][0]+t[l-1][1])%e[l-1]===0:o,!0),()=>`input spatial dimensions ${s.shape.slice(1)} with paddings ${t.toString()} must be divisible by blockShapes ${e.toString()}`);const r={x:s},a={blockShape:e,paddings:t};return F.runKernel(mi,r,a)}const el=R({spaceToBatchND_:oS});/**
1478 * @license
1479 * Copyright 2018 Google LLC. All Rights Reserved.
1480 * Licensed under the Apache License, Version 2.0 (the "License");
1481 * you may not use this file except in compliance with the License.
1482 * You may obtain a copy of the License at
1483 *
1484 * http://www.apache.org/licenses/LICENSE-2.0
1485 *
1486 * Unless required by applicable law or agreed to in writing, software
1487 * distributed under the License is distributed on an "AS IS" BASIS,
1488 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1489 * See the License for the specific language governing permissions and
1490 * limitations under the License.
1491 * =============================================================================
1492 */function iS(n,e,t,s,r,a,o){r==null&&(r=[1,1]),a==null&&(a=1),s===0&&(s="valid");const i=N(n,"x","maxPool");let l=i,u=!1;i.rank===3&&(u=!0,l=D(i,[1,i.shape[0],i.shape[1],i.shape[2]])),I(It(a,r),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${a} and dilations '${r}'`);const c=_n(l.shape,e,a,r,s),h=[c.dilationHeight,c.dilationWidth];let d;s==="same"?d=uS([c.filterHeight,c.filterWidth],h):d=[[0,0],[0,0]];const p=h[0]===1&&h[1]===1,[f,g]=lS([c.inHeight,c.inWidth],h,d),m=p?s:"valid",y=p?l:el(l,h,f),v=(t==="avg"?()=>Hi(y,e,a,m,o):()=>Zi(y,e,a,m,o))(),b=p?v:ji(v,h,g);return u?D(b,[b.shape[1],b.shape[2],b.shape[3]]):b}function lS(n,e,t){const s=t.map(c=>c[0]),r=t.map(c=>c[1]),a=n.concat(s,r),o=e.map((c,h)=>(c-a[h]%c)%c),i=r.map((c,h)=>c+o[h]),l=e.map((c,h)=>[s[h],i[h]]),u=e.map((c,h)=>[0,o[h]]);return[l,u]}function uS(n,e){const s=n.map((o,i)=>o+(o-1)*(e[i]-1)).map(o=>o-1),r=s.map(o=>Math.floor(o/2)),a=s.map((o,i)=>o-r[i]);return s.map((o,i)=>[r[i],a[i]])}const Vp=R({pool_:iS});/**
1493 * @license
1494 * Copyright 2020 Google LLC. All Rights Reserved.
1495 * Licensed under the Apache License, Version 2.0 (the "License");
1496 * you may not use this file except in compliance with the License.
1497 * You may obtain a copy of the License at
1498 *
1499 * http://www.apache.org/licenses/LICENSE-2.0
1500 *
1501 * Unless required by applicable law or agreed to in writing, software
1502 * distributed under the License is distributed on an "AS IS" BASIS,
1503 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1504 * See the License for the specific language governing permissions and
1505 * limitations under the License.
1506 * =============================================================================
1507 */function cS(n,e=null,t=!1){let s=N(n,"x","prod");s.dtype==="bool"&&(s=ee(s,"int32"));const r={x:s},a={axis:e,keepDims:t};return F.runKernel(gi,r,a)}const Bp=R({prod_:cS});/**
1508 * @license
1509 * Copyright 2022 Google LLC. All Rights Reserved.
1510 * Licensed under the Apache License, Version 2.0 (the "License");
1511 * you may not use this file except in compliance with the License.
1512 * You may obtain a copy of the License at
1513 *
1514 * http://www.apache.org/licenses/LICENSE-2.0
1515 *
1516 * Unless required by applicable law or agreed to in writing, software
1517 * distributed under the License is distributed on an "AS IS" BASIS,
1518 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1519 * See the License for the specific language governing permissions and
1520 * limitations under the License.
1521 * =============================================================================
1522 */function hS(n,e,t,s){const r=n.map((c,h)=>N(c,`tensors${h}`,"raggedGather","int32")),a=N(e,"paramsDenseValues","raggedGather"),o=N(t,"indices","raggedGather","int32"),i={paramsNestedSplits:r,paramsDenseValues:a,indices:o},l={outputRaggedRank:s},u=F.runKernel(_u,i,l);return{outputNestedSplits:u.slice(0,u.length-1),outputDenseValues:u[u.length-1]}}const fb=R({raggedGather_:hS});/**
1523 * @license
1524 * Copyright 2022 Google LLC.
1525 * Licensed under the Apache License, Version 2.0 (the "License");
1526 * you may not use this file except in compliance with the License.
1527 * You may obtain a copy of the License at
1528 *
1529 * http://www.apache.org/licenses/LICENSE-2.0
1530 *
1531 * Unless required by applicable law or agreed to in writing, software
1532 * distributed under the License is distributed on an "AS IS" BASIS,
1533 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1534 * See the License for the specific language governing permissions and
1535 * limitations under the License.
1536 * =============================================================================
1537 */function dS(n,e,t){const s=N(n,"starts","raggedRange"),r=N(e,"limits","raggedRange",s.dtype),a=N(t,"deltas","raggedRange",s.dtype),o={starts:s,limits:r,deltas:a},i=F.runKernel(Fu,o);return{rtNestedSplits:i[0],rtDenseValues:i[1]}}const mb=R({raggedRange_:dS});/**
1538 * @license
1539 * Copyright 2022 Google LLC. All Rights Reserved.
1540 * Licensed under the Apache License, Version 2.0 (the "License");
1541 * you may not use this file except in compliance with the License.
1542 * You may obtain a copy of the License at
1543 *
1544 * http://www.apache.org/licenses/LICENSE-2.0
1545 *
1546 * Unless required by applicable law or agreed to in writing, software
1547 * distributed under the License is distributed on an "AS IS" BASIS,
1548 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1549 * See the License for the specific language governing permissions and
1550 * limitations under the License.
1551 * =============================================================================
1552 */function pS(n,e,t,s,r){const a=N(n,"shape","raggedTensorToTensor","int32"),o=N(e,"values","raggedTensorToTensor"),i=N(t,"defaultValue","raggedTensorToTensor",o.dtype),l=s.map((h,d)=>N(h,`tensors${d}`,"raggedTensorToTensor","int32")),u={shape:a,values:o,defaultValue:i,rowPartitionTensors:l},c={rowPartitionTypes:r};return F.runKernel(Lu,u,c)}const gb=R({raggedTensorToTensor_:pS});/**
1553 * @license
1554 * Copyright 2020 Google LLC. All Rights Reserved.
1555 * Licensed under the Apache License, Version 2.0 (the "License");
1556 * you may not use this file except in compliance with the License.
1557 * You may obtain a copy of the License at
1558 *
1559 * http://www.apache.org/licenses/LICENSE-2.0
1560 *
1561 * Unless required by applicable law or agreed to in writing, software
1562 * distributed under the License is distributed on an "AS IS" BASIS,
1563 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1564 * See the License for the specific language governing permissions and
1565 * limitations under the License.
1566 * =============================================================================
1567 */function fS(n,e,t){qn(n);const s=H(n);let r=null;if(t==null||t==="float32")r=new Float32Array(s);else if(t==="int32")r=new Int32Array(s);else if(t==="bool")r=new Uint8Array(s);else throw new Error(`Unknown data type ${t}`);for(let a=0;a<s;a++)r[a]=e();return F.makeTensor(r,n,t)}const yb=R({rand_:fS});var Mp={exports:{}};Mp.exports;(function(n){(function(e,t,s){function r(l){var u=this,c=i();u.next=function(){var h=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=h-(u.c=h|0)},u.c=1,u.s0=c(" "),u.s1=c(" "),u.s2=c(" "),u.s0-=c(l),u.s0<0&&(u.s0+=1),u.s1-=c(l),u.s1<0&&(u.s1+=1),u.s2-=c(l),u.s2<0&&(u.s2+=1),c=null}function a(l,u){return u.c=l.c,u.s0=l.s0,u.s1=l.s1,u.s2=l.s2,u}function o(l,u){var c=new r(l),h=u&&u.state,d=c.next;return d.int32=function(){return c.next()*4294967296|0},d.double=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.quick=d,h&&(typeof h=="object"&&a(h,c),d.state=function(){return a(c,{})}),d}function i(){var l=4022871197,u=function(c){c=String(c);for(var h=0;h<c.length;h++){l+=c.charCodeAt(h);var d=.02519603282416938*l;l=d>>>0,d-=l,d*=l,l=d>>>0,d-=l,l+=d*4294967296}return(l>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=o:this.alea=o})(mr,n)})(Mp);var mS=Mp.exports,Wp={exports:{}};Wp.exports;(function(n){(function(e,t,s){function r(i){var l=this,u="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var h=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^h^h>>>8},i===(i|0)?l.x=i:u+=i;for(var c=0;c<u.length+64;c++)l.x^=u.charCodeAt(c)|0,l.next()}function a(i,l){return l.x=i.x,l.y=i.y,l.z=i.z,l.w=i.w,l}function o(i,l){var u=new r(i),c=l&&l.state,h=function(){return(u.next()>>>0)/4294967296};return h.double=function(){do var d=u.next()>>>11,p=(u.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=u.next,h.quick=h,c&&(typeof c=="object"&&a(c,u),h.state=function(){return a(u,{})}),h}t&&t.exports?t.exports=o:this.xor128=o})(mr,n)})(Wp);
vendor: 4,755 bytes, line 1567
1567var gS=Wp.exports,Up={exports:{}};Up.exports;(function(n){(function(e,t,s){function r(i){var l=this,u="";l.next=function(){var h=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(h^h<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,i===(i|0)?l.x=i:u+=i;for(var c=0;c<u.length+64;c++)l.x^=u.charCodeAt(c)|0,c==u.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function a(i,l){return l.x=i.x,l.y=i.y,l.z=i.z,l.w=i.w,l.v=i.v,l.d=i.d,l}function o(i,l){var u=new r(i),c=l&&l.state,h=function(){return(u.next()>>>0)/4294967296};return h.double=function(){do var d=u.next()>>>11,p=(u.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=u.next,h.quick=h,c&&(typeof c=="object"&&a(c,u),h.state=function(){return a(u,{})}),h}t&&t.exports?t.exports=o:this.xorwow=o})(mr,n)})(Up);var yS=Up.exports,Gp={exports:{}};Gp.exports;(function(n){(function(e,t,s){function r(i){var l=this;l.next=function(){var c=l.x,h=l.i,d,p;return d=c[h],d^=d>>>7,p=d^d<<24,d=c[h+1&7],p^=d^d>>>10,d=c[h+3&7],p^=d^d>>>3,d=c[h+4&7],p^=d^d<<7,d=c[h+7&7],d=d^d<<13,p^=d^d<<9,c[h]=p,l.i=h+1&7,p};function u(c,h){var d,p=[];if(h===(h|0))p[0]=h;else for(h=""+h,d=0;d<h.length;++d)p[d&7]=p[d&7]<<15^h.charCodeAt(d)+p[d+1&7]<<13;for(;p.length<8;)p.push(0);for(d=0;d<8&&p[d]===0;++d);for(d==8?p[7]=-1:p[d],c.x=p,c.i=0,d=256;d>0;--d)c.next()}u(l,i)}function a(i,l){return l.x=i.x.slice(),l.i=i.i,l}function o(i,l){i==null&&(i=+new Date);var u=new r(i),c=l&&l.state,h=function(){return(u.next()>>>0)/4294967296};return h.double=function(){do var d=u.next()>>>11,p=(u.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=u.next,h.quick=h,c&&(c.x&&a(c,u),h.state=function(){return a(u,{})}),h}t&&t.exports?t.exports=o:this.xorshift7=o})(mr,n)})(Gp);var xS=Gp.exports,Hp={exports:{}};Hp.exports;(function(n){(function(e,t,s){function r(i){var l=this;l.next=function(){var c=l.w,h=l.X,d=l.i,p,f;return l.w=c=c+1640531527|0,f=h[d+34&127],p=h[d=d+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=h[d]=f^p,l.i=d,f+(c^c>>>16)|0};function u(c,h){var d,p,f,g,m,y=[],x=128;for(h===(h|0)?(p=h,h=null):(h=h+"\0",p=0,x=Math.max(x,h.length)),f=0,g=-32;g<x;++g)h&&(p^=h.charCodeAt((g+32)%h.length)),g===0&&(m=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,g>=0&&(m=m+1640531527|0,d=y[g&127]^=p+m,f=d==0?f+1:0);for(f>=128&&(y[(h&&h.length||0)&127]=-1),f=127,g=4*128;g>0;--g)p=y[f+34&127],d=y[f=f+1&127],p^=p<<13,d^=d<<17,p^=p>>>15,d^=d>>>12,y[f]=p^d;c.w=m,c.X=y,c.i=f}u(l,i)}function a(i,l){return l.i=i.i,l.w=i.w,l.X=i.X.slice(),l}function o(i,l){i==null&&(i=+new Date);var u=new r(i),c=l&&l.state,h=function(){return(u.next()>>>0)/4294967296};return h.double=function(){do var d=u.next()>>>11,p=(u.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=u.next,h.quick=h,c&&(c.X&&a(c,u),h.state=function(){return a(u,{})}),h}t&&t.exports?t.exports=o:this.xor4096=o})(mr,n)})(Hp);var bS=Hp.exports,jp={exports:{}};jp.exports;(function(n){(function(e,t,s){function r(i){var l=this,u="";l.next=function(){var h=l.b,d=l.c,p=l.d,f=l.a;return h=h<<25^h>>>7^d,d=d-p|0,p=p<<24^p>>>8^f,f=f-h|0,l.b=h=h<<20^h>>>12^d,l.c=d=d-p|0,l.d=p<<16^d>>>16^f,l.a=f-h|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,i===Math.floor(i)?(l.a=i/4294967296|0,l.b=i|0):u+=i;for(var c=0;c<u.length+20;c++)l.b^=u.charCodeAt(c)|0,l.next()}function a(i,l){return l.a=i.a,l.b=i.b,l.c=i.c,l.d=i.d,l}function o(i,l){var u=new r(i),c=l&&l.state,h=function(){return(u.next()>>>0)/4294967296};return h.double=function(){do var d=u.next()>>>11,p=(u.next()>>>0)/4294967296,f=(d+p)/(1<<21);while(f===0);return f},h.int32=u.next,h.quick=h,c&&(typeof c=="object"&&a(c,u),h.state=function(){return a(u,{})}),h}t&&t.exports?t.exports=o:this.tychei=o})(mr,n)})(jp);var wS=jp.exports,xb={exports:{}};(function(n){(function(e,t,s){var r=256,a=6,o=52,i="random",l=s.pow(r,a),u=s.pow(2,o),c=u*2,h=r-1,d;function p(b,C,$){var S=[];C=C==!0?{entropy:!0}:C||{};var k=y(m(C.entropy?[b,v(t)]:b??x(),3),S),T=new f(S),E=function(){for(var _=T.g(a),z=l,P=0;_<u;)_=(_+P)*r,z*=r,P=T.g(1);for(;_>=c;)_/=2,z/=2,P>>>=1;return(_+P)/z};return E.int32=function(){return T.g(4)|0},E.quick=function(){return T.g(4)/4294967296},E.double=E,y(v(T.S),t),(C.pass||$||function(_,z,P,V){return V&&(V.S&&g(V,T),_.state=function(){return g(T,{})}),P?(s[i]=_,z):_})(E,k,"global"in C?C.global:this==s,C.state)}function f(b){var C,$=b.length,S=this,k=0,T=S.i=S.j=0,E=S.S=[];for($||(b=[$++]);k<r;)E[k]=k++;for(k=0;k<r;k++)E[k]=E[T=h&T+b[k%$]+(C=E[k])],E[T]=C;(S.g=function(_){for(var z,P=0,V=S.i,B=S.j,M=S.S;_--;)z=M[V=h&V+1],P=P*r+M[h&(M[V]=M[B=h&B+z])+(M[B]=z)];return S.i=V,S.j=B,P})(r)}function g(b,C){return C.i=b.i,C.j=b.j,C.S=b.S.slice(),C}function m(b,C){var $=[],S=typeof b,k;if(C&&S=="object")for(k in b)try{$.push(m(b[k],C-1))}catch{}
1567return $.length?$:S=="string"?b:b+"\0"}function y(b,C){for(var $=b+"",S,k=0;k<$.length;)C[h&k]=h&(S^=C[h&k]*19)+$.charCodeAt(k++);return v(C)}function x(){try{var b;return d&&(b=d.randomBytes)?b=b(r):(b=new Uint8Array(r),(e.crypto||e.msCrypto).getRandomValues(b)),v(b)}catch{var C=e.navigator,$=C&&C.plugins;return[+new Date,e,$,e.screen,v(t)]}}function v(b){return String.fromCharCode.apply(0,b)}if(y(s.random(),t),n.exports){n.exports=p;try{d=TC}catch{}}else s["seed"+i]=p})(typeof self<"u"?self:mr,[],Math)})(xb);var vS=xb.exports,CS=mS,$S=gS,NS=yS,IS=xS,SS=bS,kS=wS,yr=vS;yr.alea=CS;yr.xor128=$S;yr.xorwow=NS;yr.xorshift7=IS;yr.xor4096=SS;yr.tychei=kS;var za=yr;/**
1568 * @license
1569 * Copyright 2017 Google LLC. All Rights Reserved.
1570 * Licensed under the Apache License, Version 2.0 (the "License");
1571 * you may not use this file except in compliance with the License.
1572 * You may obtain a copy of the License at
1573 *
1574 * http://www.apache.org/licenses/LICENSE-2.0
1575 *
1576 * Unless required by applicable law or agreed to in writing, software
1577 * distributed under the License is distributed on an "AS IS" BASIS,
1578 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1579 * See the License for the specific language governing permissions and
1580 * limitations under the License.
1581 * =============================================================================
1582 */const TS=.001,bb=.1;function ES(n,e,t){return t==null&&(t=qp()),ed(n,e,(s,r)=>Kp(s,r,t))}function qp(){return F.backend.floatPrecision()===32?TS:bb}function ed(n,e,t){let s=!0;if((Gs(n)||Gs(e))&&(s=!1),Gs(n)&&Gs(e)&&(s=!0),s){const o=n.constructor.name,i=e.constructor.name;if(o!==i)throw new Error(`Arrays are of different type. Actual: ${o}. Expected: ${i}`)}if(Array.isArray(n)&&Array.isArray(e)){const o=$s(n),i=$s(e);if(!ke(o,i))throw new Error(`Arrays have different shapes. Actual: [${o}]. Expected: [${i}]`)}const r=Gs(n)?n:Hl(n),a=Gs(e)?e:Hl(e);if(r.length!==a.length)throw new Error(`Arrays have different lengths actual: ${r.length} vs expected: ${a.length}.
1583Actual:   ${r}.
1584Expected: ${a}.`);for(let o=0;o<a.length;++o){const i=r[o],l=a[o];if(!t(i,l))throw new Error(`Arrays differ: actual[${o}] = ${i}, expected[${o}] = ${l}.
1585Actual:   ${r}.
1586Expected: ${a}.`)}typeof expect<"u"&&expect().nothing()}function RS(n,e){n().then(()=>e.fail(),()=>e()),typeof expect<"u"&&expect().nothing()}function DS(n,e){const t=typeof e=="string"||typeof e=="number"||typeof e=="boolean"?[e]:e;return kr(n)||kr(n[0])||kr(e)||kr(e[0])?ed(n,t,(s,r)=>s==r):ed(n,e,(s,r)=>Kp(s,r,0))}function AS(n,e,t){if(t==null&&(t=qp()),!Kp(n,e,t))throw new Error(`Numbers differ: actual === ${n}, expected === ${e}`);typeof expect<"u"&&expect().nothing()}function Kp(n,e,t){return!isFinite(n)&&!isFinite(e)?!0:!(isNaN(n)||isNaN(e)||Math.abs(n-e)>t)}function OS(n,e,t){for(let s=0;s<n.length;s++)if(n[s]<e||n[s]>t)throw new Error(`Value out of range:${n[s]} low: ${e}, high: ${t}`)}function _S(n,e){const t=new Float32Array(n),s=new Float32Array(e);if(t.length!==s.length)throw new Error(`Expected ArrayBuffer to be of length ${s.length}, but it was ${t.length}`);for(let r=0;r<s.length;r++)if(t[r]!==s[r])throw new Error(`Expected ArrayBuffer value at ${r} to be ${s[r]} but got ${t[r]} instead`)}function wb(n){for(let e=0;e<n.length;e++){const t=n[e];Array.isArray(t)?wb(t):n[e]=Od(t)}return n}function FS(n){const e=document.createElement("video");return"playsInline"in e&&(e.playsInline=!0),e.muted=!0,e.loop=!0,e.style.position="fixed",e.style.left="0px",e.style.top="0px",e.preload="auto",e.appendChild(n),new Promise(t=>{e.addEventListener("loadeddata",s=>t(e)),e.load()})}async function LS(n){await n.play(),"requestVideoFrameCallback"in n&&await new Promise(e=>{n.requestVideoFrameCallback(e)})}const PS=Object.freeze(Object.defineProperty({__proto__:null,TEST_EPSILON_FLOAT16:bb,createVideoElement:FS,encodeStrings:wb,expectArrayBuffersEqual:_S,expectArraysClose:ES,expectArraysEqual:DS,expectNumbersClose:AS,expectPromiseToFail:RS,expectValuesInRange:OS,play:LS,testEpsilon:qp},Symbol.toStringTag,{value:"Module"}));/**
1587 * @license
1588 * Copyright 2018 Google LLC. All Rights Reserved.
1589 * Licensed under the Apache License, Version 2.0 (the "License");
1590 * you may not use this file except in compliance with the License.
1591 * You may obtain a copy of the License at
1592 *
1593 * http://www.apache.org/licenses/LICENSE-2.0
1594 *
1595 * Unless required by applicable law or agreed to in writing, software
1596 * distributed under the License is distributed on an "AS IS" BASIS,
1597 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1598 * See the License for the specific language governing permissions and
1599 * limitations under the License.
1600 * =============================================================================
1601 */class Xp{constructor(e,t,s,r,a){this.mean=e,this.stdDev=t,this.dtype=s,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);const o=a||Math.random();this.random=za.alea(o.toString())}nextValue(){if(!isNaN(this.nextVal)){const r=this.nextVal;return this.nextVal=NaN,r}let e,t,s=!1;for(;!s;){let r,a,o;do r=2*this.random()-1,a=2*this.random()-1,o=r*r+a*a;while(o>=1||o===0);const i=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*r*i,t=this.mean+this.stdDev*a*i,(!this.truncated||this.isValidTruncated(e))&&(s=!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 zS{constructor(e,t,s,r){this.alpha=e,this.beta=1/t,this.dtype=s;const a=r||Math.random();this.randu=za.alea(a.toString()),this.randn=new Xp(0,1,s,!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,s,r,a,o;for(;;){do r=this.randn.nextValue(),o=1+this.c*r;while(o<=0);if(o*=o*o,e=r*r,t=1-.331*e*e,s=.5*e+this.d*(1-o+Math.log(o)),a=this.randu(),a<t||Math.log(a)<s)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 VS{constructor(e=0,t=1,s,r){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=s,r==null&&(r=Math.random()),typeof r=="number"&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=za.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}/**
1602 * @license
1603 * Copyright 2020 Google LLC. All Rights Reserved.
1604 * Licensed under the Apache License, Version 2.0 (the "License");
1605 * you may not use this file except in compliance with the License.
1606 * You may obtain a copy of the License at
1607 *
1608 * http://www.apache.org/licenses/LICENSE-2.0
1609 *
1610 * Unless required by applicable law or agreed to in writing, software
1611 * distributed under the License is distributed on an "AS IS" BASIS,
1612 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1613 * See the License for the specific language governing permissions and
1614 * limitations under the License.
1615 * =============================================================================
1616 */function BS(n,e,t=1,s="float32",r){if(qn(n),t==null&&(t=1),s==null&&(s="float32"),s!=="float32"&&s!=="int32")throw new Error(`Unsupported data type ${s}`);const a=new zS(e,t,s,r),o=$e(n,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}const vb=R({randomGamma_:BS});/**
1617 * @license
1618 * Copyright 2020 Google LLC. All Rights Reserved.
1619 * Licensed under the Apache License, Version 2.0 (the "License");
1620 * you may not use this file except in compliance with the License.
1621 * You may obtain a copy of the License at
1622 *
1623 * http://www.apache.org/licenses/LICENSE-2.0
1624 *
1625 * Unless required by applicable law or agreed to in writing, software
1626 * distributed under the License is distributed on an "AS IS" BASIS,
1627 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1628 * See the License for the specific language governing permissions and
1629 * limitations under the License.
1630 * =============================================================================
1631 */function MS(n,e=0,t=1,s,r){if(qn(n),s!=null&&s==="bool")throw new Error(`Unsupported data type ${s}`);const a=new Xp(e,t,s,!1,r),o=$e(n,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}const Yc=R({randomNormal_:MS});/**
1632 * @license
1633 * Copyright 2022 Google LLC. All Rights Reserved.
1634 * Licensed under the Apache License, Version 2.0 (the "License");
1635 * you may not use this file except in compliance with the License.
1636 * You may obtain a copy of the License at
1637 *
1638 * http://www.apache.org/licenses/LICENSE-2.0
1639 *
1640 * Unless required by applicable law or agreed to in writing, software
1641 * distributed under the License is distributed on an "AS IS" BASIS,
1642 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1643 * See the License for the specific language governing permissions and
1644 * limitations under the License.
1645 * =============================================================================
1646 */function WS(n,e,t){if(e!=null&&e==="bool")throw new Error(`Unsupported data type ${e}`);return Yc(n,0,1,e,t)}const Cb=R({randomStandardNormal_:WS});/**
1647 * @license
1648 * Copyright 2020 Google LLC. All Rights Reserved.
1649 * Licensed under the Apache License, Version 2.0 (the "License");
1650 * you may not use this file except in compliance with the License.
1651 * You may obtain a copy of the License at
1652 *
1653 * http://www.apache.org/licenses/LICENSE-2.0
1654 *
1655 * Unless required by applicable law or agreed to in writing, software
1656 * distributed under the License is distributed on an "AS IS" BASIS,
1657 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1658 * See the License for the specific language governing permissions and
1659 * limitations under the License.
1660 * =============================================================================
1661 */function US(n,e=0,t=1,s="float32",r){qn(n);const a=$e(n,s),o=new VS(e,t,null,r);for(let i=0;i<a.values.length;i++)a.values[i]=o.nextValue();return a.toTensor()}const Ps=R({randomUniform_:US});/**
1662 * @license
1663 * Copyright 2023 Google LLC.
1664 * Licensed under the Apache License, Version 2.0 (the "License");
1665 * you may not use this file except in compliance with the License.
1666 * You may obtain a copy of the License at
1667 *
1668 * http://www.apache.org/licenses/LICENSE-2.0
1669 *
1670 * Unless required by applicable law or agreed to in writing, software
1671 * distributed under the License is distributed on an "AS IS" BASIS,
1672 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1673 * See the License for the specific language governing permissions and
1674 * limitations under the License.
1675 * =============================================================================
1676 */function GS(n,e,t,s){return Ps(n,e,t,"int32",s)}const $b=R({randomUniformInt_:GS});/**
1677 * @license
1678 * Copyright 2018 Google LLC. All Rights Reserved.
1679 * Licensed under the Apache License, Version 2.0 (the "License");
1680 * you may not use this file except in compliance with the License.
1681 * You may obtain a copy of the License at
1682 *
1683 * http://www.apache.org/licenses/LICENSE-2.0
1684 *
1685 * Unless required by applicable law or agreed to in writing, software
1686 * distributed under the License is distributed on an "AS IS" BASIS,
1687 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1688 * See the License for the specific language governing permissions and
1689 * limitations under the License.
1690 * =============================================================================
1691 */function rr(n,e,t=1,s="float32"){if(t===0)throw new Error("Cannot have a step of zero");const r={start:n,stop:e,step:t,dtype:s};return F.runKernel(Pu,{},r)}/**
1692 * @license
1693 * Copyright 2020 Google LLC. All Rights Reserved.
1694 * Licensed under the Apache License, Version 2.0 (the "License");
1695 * you may not use this file except in compliance with the License.
1696 * You may obtain a copy of the License at
1697 *
1698 * http://www.apache.org/licenses/LICENSE-2.0
1699 *
1700 * Unless required by applicable law or agreed to in writing, software
1701 * distributed under the License is distributed on an "AS IS" BASIS,
1702 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1703 * See the License for the specific language governing permissions and
1704 * limitations under the License.
1705 * =============================================================================
1706 */function HS(n){const t={input:N(n,"input","real")};return F.runKernel(zu,t)}const Lr=R({real_:HS});/**
1707 * @license
1708 * Copyright 2018 Google LLC. All Rights Reserved.
1709 * Licensed under the Apache License, Version 2.0 (the "License");
1710 * you may not use this file except in compliance with the License.
1711 * You may obtain a copy of the License at
1712 *
1713 * http://www.apache.org/licenses/LICENSE-2.0
1714 *
1715 * Unless required by applicable law or agreed to in writing, software
1716 * distributed under the License is distributed on an "AS IS" BASIS,
1717 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1718 * See the License for the specific language governing permissions and
1719 * limitations under the License.
1720 * =============================================================================
1721 */function jS(n){const t={x:N(n,"x","reciprocal")};return F.runKernel(xa,t)}const Yp=R({reciprocal_:jS});/**
1722 * @license
1723 * Copyright 2018 Google LLC. All Rights Reserved.
1724 * Licensed under the Apache License, Version 2.0 (the "License");
1725 * you may not use this file except in compliance with the License.
1726 * You may obtain a copy of the License at
1727 *
1728 * http://www.apache.org/licenses/LICENSE-2.0
1729 *
1730 * Unless required by applicable law or agreed to in writing, software
1731 * distributed under the License is distributed on an "AS IS" BASIS,
1732 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1733 * See the License for the specific language governing permissions and
1734 * limitations under the License.
1735 * =============================================================================
1736 */function qS(n,e){const s={x:N(n,"x","reverse")},r={dims:e};return F.runKernel(yi,s,r)}const un=R({reverse_:qS});/**
1737 * @license
1738 * Copyright 2020 Google LLC. All Rights Reserved.
1739 * Licensed under the Apache License, Version 2.0 (the "License");
1740 * you may not use this file except in compliance with the License.
1741 * You may obtain a copy of the License at
1742 *
1743 * http://www.apache.org/licenses/LICENSE-2.0
1744 *
1745 * Unless required by applicable law or agreed to in writing, software
1746 * distributed under the License is distributed on an "AS IS" BASIS,
1747 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1748 * See the License for the specific language governing permissions and
1749 * limitations under the License.
1750 * =============================================================================
1751 */function KS(n){const e=N(n,"x","reverse");return I(e.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`),un(e,0)}const Nb=R({reverse1d_:KS});/**
1752 * @license
1753 * Copyright 2020 Google LLC. All Rights Reserved.
1754 * Licensed under the Apache License, Version 2.0 (the "License");
1755 * you may not use this file except in compliance with the License.
1756 * You may obtain a copy of the License at
1757 *
1758 * http://www.apache.org/licenses/LICENSE-2.0
1759 *
1760 * Unless required by applicable law or agreed to in writing, software
1761 * distributed under the License is distributed on an "AS IS" BASIS,
1762 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1763 * See the License for the specific language governing permissions and
1764 * limitations under the License.
1765 * =============================================================================
1766 */function XS(n,e){const t=N(n,"x","reverse");return I(t.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${t.rank}.`),un(t,e)}const Ib=R({reverse2d_:XS});/**
1767 * @license
1768 * Copyright 2020 Google LLC. All Rights Reserved.
1769 * Licensed under the Apache License, Version 2.0 (the "License");
1770 * you may not use this file except in compliance with the License.
1771 * You may obtain a copy of the License at
1772 *
1773 * http://www.apache.org/licenses/LICENSE-2.0
1774 *
1775 * Unless required by applicable law or agreed to in writing, software
1776 * distributed under the License is distributed on an "AS IS" BASIS,
1777 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1778 * See the License for the specific language governing permissions and
1779 * limitations under the License.
1780 * =============================================================================
1781 */function YS(n,e){const t=N(n,"x","reverse");return I(t.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${t.rank}.`),un(t,e)}const Sb=R({reverse3d_:YS});/**
1782 * @license
1783 * Copyright 2020 Google LLC. All Rights Reserved.
1784 * Licensed under the Apache License, Version 2.0 (the "License");
1785 * you may not use this file except in compliance with the License.
1786 * You may obtain a copy of the License at
1787 *
1788 * http://www.apache.org/licenses/LICENSE-2.0
1789 *
1790 * Unless required by applicable law or agreed to in writing, software
1791 * distributed under the License is distributed on an "AS IS" BASIS,
1792 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1793 * See the License for the specific language governing permissions and
1794 * limitations under the License.
1795 * =============================================================================
1796 */function JS(n,e){const t=N(n,"x","reverse");return I(t.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${t.rank}.`),un(t,e)}const kb=R({reverse4d_:JS});/**
1797 * @license
1798 * Copyright 2018 Google LLC. All Rights Reserved.
1799 * Licensed under the Apache License, Version 2.0 (the "License");
1800 * you may not use this file except in compliance with the License.
1801 * You may obtain a copy of the License at
1802 *
1803 * http://www.apache.org/licenses/LICENSE-2.0
1804 *
1805 * Unless required by applicable law or agreed to in writing, software
1806 * distributed under the License is distributed on an "AS IS" BASIS,
1807 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1808 * See the License for the specific language governing permissions and
1809 * limitations under the License.
1810 * =============================================================================
1811 */function ZS(n){const t={x:N(n,"x","round")};return F.runKernel(ba,t)}const Jc=R({round_:ZS});/**
1812 * @license
1813 * Copyright 2018 Google LLC. All Rights Reserved.
1814 * Licensed under the Apache License, Version 2.0 (the "License");
1815 * you may not use this file except in compliance with the License.
1816 * You may obtain a copy of the License at
1817 *
1818 * http://www.apache.org/licenses/LICENSE-2.0
1819 *
1820 * Unless required by applicable law or agreed to in writing, software
1821 * distributed under the License is distributed on an "AS IS" BASIS,
1822 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1823 * See the License for the specific language governing permissions and
1824 * limitations under the License.
1825 * =============================================================================
1826 */function QS(n){const t={x:N(n,"x","rsqrt","float32")};return F.runKernel(wa,t)}const Zc=R({rsqrt_:QS});/**
1827 * @license
1828 * Copyright 2020 Google LLC. All Rights Reserved.
1829 * Licensed under the Apache License, Version 2.0 (the "License");
1830 * you may not use this file except in compliance with the License.
1831 * You may obtain a copy of the License at
1832 *
1833 * http://www.apache.org/licenses/LICENSE-2.0
1834 *
1835 * Unless required by applicable law or agreed to in writing, software
1836 * distributed under the License is distributed on an "AS IS" BASIS,
1837 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1838 * See the License for the specific language governing permissions and
1839 * limitations under the License.
1840 * =============================================================================
1841 */function ek(n){const t={x:N(n,"x","selu")};return F.runKernel(va,t)}const Qc=R({selu_:ek});function tk(n,e,t,s,r,a=[1,1],o="NHWC"){const i=N(n,"x","separableConv2d"),l=N(e,"depthwiseFilter","separableConv2d"),u=N(t,"pointwiseFilter","separableConv2d");let c=i,h=!1;if(i.rank===3&&(h=!0,c=D(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");I(c.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`),I(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),I(u.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),I(u.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter  must be 1, but got ${u.shape[0]}.`),I(u.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`);const d=l.shape[2],p=l.shape[3];I(u.shape[2]===d*p,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*p}, but got ${u.shape[2]}.`);const f=_a(c,l,s,r,o,a),m=rs(f,u,1,"valid",o);return h?D(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const eh=R({separableConv2d_:tk});/**
1842 * @license
1843 * Copyright 2020 Google Inc. All Rights Reserved.
1844 * Licensed under the Apache License, Version 2.0 (the "License");
1845 * you may not use this file except in compliance with the License.
1846 * You may obtain a copy of the License at
1847 *
1848 * http://www.apache.org/licenses/LICENSE-2.0
1849 *
1850 * Unless required by applicable law or agreed to in writing, software
1851 * distributed under the License is distributed on an "AS IS" BASIS,
1852 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1853 * See the License for the specific language governing permissions and
1854 * limitations under the License.
1855 * =============================================================================
1856 */async function nk(n,e){const t=N(n,"x","setdiff1d"),s=N(e,"y","setdiff1d");I(t.dtype===s.dtype,()=>`x and y should have the same dtype, but got x (${t.dtype}) and y (${s.dtype}).`),I(t.rank===1,()=>`x should be 1D tensor, but got x (${t.shape}).`),I(s.rank===1,()=>`y should be 1D tensor, but got y (${s.shape}).`);const r=await t.data(),a=await s.data(),o=new Set(a);let i=0;for(let c=0;c<r.length;c++)o.has(r[c])||i++;const l=new bt([i],t.dtype),u=new bt([i],"int32");for(let c=0,h=0;c<r.length;c++)o.has(r[c])||(l.values[h]=r[c],u.values[h]=c,h++);return[l.toTensor(),u.toTensor()]}const Tb=nk;/**
1857 * @license
1858 * Copyright 2018 Google LLC. All Rights Reserved.
1859 * Licensed under the Apache License, Version 2.0 (the "License");
1860 * you may not use this file except in compliance with the License.
1861 * You may obtain a copy of the License at
1862 *
1863 * http://www.apache.org/licenses/LICENSE-2.0
1864 *
1865 * Unless required by applicable law or agreed to in writing, software
1866 * distributed under the License is distributed on an "AS IS" BASIS,
1867 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1868 * See the License for the specific language governing permissions and
1869 * limitations under the License.
1870 * =============================================================================
1871 */function sk(n){const t={x:N(n,"x","sign")};return F.runKernel(Ca,t)}const Jp=R({sign_:sk});/**
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 rk(n){const t={x:N(n,"x","sin","float32")};return F.runKernel($a,t)}const th=R({sin_:rk});/**
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 ak(n){const t={x:N(n,"x","sinh")};return F.runKernel(Na,t)}const nh=R({sinh_:ak});/**
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 ok(n,e,t){const s=N(n,"x","slice1d");return I(s.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`),Se(s,[e],[t])}const tl=R({slice1d_:ok});/**
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 ik(n,e,t){const s=N(n,"x","slice2d");return I(s.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`),Se(s,e,t)}const sh=R({slice2d_:ik});/**
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 lk(n,e,t){const s=N(n,"x","slice3d");return I(s.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`),Se(s,e,t)}const nl=R({slice3d_:lk});/**
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 uk(n,e,t){const s=N(n,"x","slice4d");return I(s.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`),Se(s,e,t)}const Pr=R({slice4d_:uk});/**
1962 * @license
1963 * Copyright 2018 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 ck(n,e=-1){const t=N(n,"logits","softmax","float32");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${e}`);const s={logits:t},r={dim:e};return F.runKernel(xi,s,r)}const sl=R({softmax_:ck});/**
1977 * @license
1978 * Copyright 2020 Google LLC. 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 hk(n){I(n.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${n.dtype}.`);const e={input:n};return F.runKernel(Vu,e)}const rl=R({fft_:hk});/**
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 dk(n){I(n.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${n.dtype}.`);const e={input:n};return F.runKernel(Bu,e)}const zr=R({ifft_:dk});/**
2007 * @license
2008 * Copyright 2018 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 pk(n){const e=n.shape[n.shape.length-1],t=n.size/e;let s;if(e<=2){const r=D(n,[t,e]);s=zr(r)}else{const r=[t,2*(e-1)],a=D(Lr(n),[t,e]),o=D(Ki(n),[t,e]),i=un(Se(a,[0,1],[t,e-2]),1),l=O(un(Se(o,[0,1],[t,e-2]),1),pe(-1)),u=Je([a,i],1),c=Je([o,l],1),h=D(Cs(u,c),[r[0],r[1]]);s=zr(h)}if(s=Lr(s),n.rank===3&&n.shape[0]!==0){const r=s,a=n.shape[0];s=D(s,[a,s.shape[0]/a,s.shape[1]]),r.dispose()}return s}const rh=R({irfft_:pk});/**
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 fk(n,e,t=0){const r={x:N(n,"x","split")},a={numOrSizeSplits:e,axis:t};return F.runKernel(bi,r,a)}const Bt=R({split_:fk});/**
2037 * @license
2038 * Copyright 2018 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 mk(n,e){I(n.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${n.dtype}`);let t=n.shape[n.shape.length-1];const s=n.size/t;let r;if(e!=null&&e<t){const f=n.shape.map(m=>0),g=n.shape.map(m=>m);g[n.shape.length-1]=e,r=Se(n,f,g),t=e}else if(e!=null&&e>t){const f=n.shape.map(g=>g);f[n.shape.length-1]=e-t,r=Je([n,et(f)],n.shape.length-1),t=e}else r=n;const a=Be(r),o=D(Cs(r,a),[s,t]),i=rl(o),l=Math.floor(t/2)+1,u=Lr(i),c=Ki(i),h=Bt(u,[l,t-l],u.shape.length-1),d=Bt(c,[l,t-l],c.shape.length-1),p=r.shape.slice();return p[r.shape.length-1]=l,D(Cs(h[0],d[0]),p)}const al=R({rfft_:mk});/**
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 gk(n,e){let t=N(n,"a","squaredDifference"),s=N(e,"b","squaredDifference");[t,s]=At(t,s),xe(t.shape,s.shape);const r={a:t,b:s},a={};return F.runKernel(Ia,r,a)}const ah=R({squaredDifference_:gk});/**
2067 * @license
2068 * Copyright 2020 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 */function yk(n,e){const t=N(n,"x","squeeze","string_or_numeric");return D(t,Os(t.shape,e).newShape)}const zs=R({squeeze_:yk});/**
2082 * @license
2083 * Copyright 2020 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 xk(n,e=0){const t=Gl(n,"tensors","stack","string_or_numeric");I(t.length>=1,()=>"Pass at least one tensor to tf.stack"),t.length>0&&I(e<=t[0].rank,()=>"Axis must be <= rank of the tensor");const s=t,r={axis:e};return F.runKernel(wi,s,r)}const Ot=R({stack_:xk});/**
2097 * @license
2098 * Copyright 2018 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, software
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 bk(n,e,t,s,r=0,a=0,o=0,i=0,l=0){const c={x:N(n,"x","stridedSlice","string_or_numeric")},h={begin:e,end:t,strides:s,beginMask:r,endMask:a,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:l};return F.runKernel(Mu,c,h)}const Zp=R({stridedSlice_:bk});/**
2112 * @license
2113 * Copyright 2018 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 wk(n){const t={x:N(n,"x","tan","float32")};return F.runKernel(Sa,t)}const Qp=R({tan_:wk});/**
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 xt(n,e){ka(n);const t=$s(n,e);if(t.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Ta(n,null,t,e)}/**
2142 * @license
2143 * Copyright 2018 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 bs(n,e,t){if(ka(n),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");const s=$s(n,t);if(s.length!==2&&s.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Ta(n,e,s,t)}/**
2157 * @license
2158 * Copyright 2018 Google LLC. 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, software
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 ef(n,e,t){if(ka(n),e!=null&&e.length!==3)throw new Error("tensor3d() requires shape to have three numbers");const s=$s(n,t);if(s.length!==3&&s.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Ta(n,e,s,t)}/**
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 Eb(n,e,t){if(ka(n),e!=null&&e.length!==4)throw new Error("tensor4d() requires shape to have four numbers");const s=$s(n,t);if(s.length!==4&&s.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Ta(n,e,s,t)}/**
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 Rb(n,e,t){if(ka(n),e!=null&&e.length!==5)throw new Error("tensor5d() requires shape to have five numbers");const s=$s(n,t);if(s.length!==5&&s.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Ta(n,e,s,t)}/**
2202 * @license
2203 * Copyright 2018 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 Db(n,e,t){if(ka(n),e!=null&&e.length!==6)throw new Error("tensor6d() requires shape to have six numbers");const s=$s(n,t);if(s.length!==6&&s.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return e=e||s,Ta(n,e,s,t)}/**
2217 * @license
2218 * Copyright 2022 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 vk(n,e,t){const s=N(n,"tensor","tensorScatterupdate"),r=N(e,"indices","tensorScatterupdate","int32"),a=N(t,"updates","tensorScatterupdate");if(Ky(a,r,s.shape),s.dtype!==a.dtype)throw new Error(`tensor and updates must have the same dtype, instead they are ${s.dtype} and ${a.dtype}.`);const o={tensor:s,indices:r,updates:a},i={};return F.runKernel(Wu,o,i)}const Ab=R({tensorScatterUpdate_:vk});/**
2232 * @license
2233 * Copyright 2018 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 Ck(n,e=1,t=!0){const s=N(n,"x","topk");
vendor: 4,339 bytes, lines 2246-2309
2246if(s.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");const r=s.shape[s.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>r)throw new Error(`'k' passed to topk() must be <= the last dimension (${r}) but got ${e}`);const a={x:s},o={k:e,sorted:t},[i,l]=F.runKernel(Uu,a,o);return{values:i,indices:l}}const tf=R({topk_:Ck});/**
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 $k(n,e=0,t=1,s,r){if(qn(n),s!=null&&s==="bool")throw new Error("Unsupported data type $ { dtype }");const a=new Xp(e,t,s,!0,r),o=$e(n,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}const oh=R({truncatedNormal_:$k});/**
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 Nk(n,e=0){const t=N(n,"x","unique","string_or_numeric");I(t.rank>0,()=>"The input tensor must be at least 1D");const s={x:t},r={axis:e},[a,o]=F.runKernel(Gu,s,r);return{values:a,indices:o}}const nf=R({unique_:Nk});/**
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 Ik(n,e,t){const s=N(n,"x","unsortedSegmentSum"),r=N(e,"segmentIds","unsortedSegmentSum","int32");I(Ad(t),()=>"numSegments must be of dtype int");const a={x:s,segmentIds:r},o={numSegments:t};return F.runKernel(vi,a,o)}const ih=R({unsortedSegmentSum_:Ik});/**
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 Sk(n,e=0){const t=N(n,"x","unstack","string_or_numeric");I(e>=-t.shape.length&&e<t.shape.length,()=>`Axis = ${e} is not in [-${t.shape.length}, ${t.shape.length})`);const s={value:t},r={axis:e};return F.runKernel(Ci,s,r)}const cn=R({unstack_:Sk});/**
2307 * @license
2308 * Copyright 2022 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 Ob(n,e){return Xc(n,e,"right")}/**
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 sf(n,e=!0,t,s){return F.makeVariable(n,e,t,s)}/**
2337 * @license
2338 * Copyright 2018 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 lh(n,e){const t=[];for(let a=0;a<e.length;a++)e[a]&&t.push(a);const s=$e(n,"int32"),r=$e([t.length,n.length],"int32");for(let a=0;a<t.length;a++){const o=s.indexToLoc(t[a]),i=a*n.length;r.values.set(o,i)}return r.toTensor()}/**
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 */async function kk(n){const e=N(n,"condition","whereAsync","bool"),t=await e.data(),s=lh(e.shape,t);return n!==e&&e.dispose(),s}const rf=kk;/**
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 */async function Tk(n,e,t){const s=N(n,"tensor","boolMask"),r=N(e,"mask","boolMask","bool"),a=t??0,o=r.rank,i=s.shape;I(o>0,()=>"mask cannot be scalar"),dn(i.slice(a,a+o),r.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let g=a;g<a+o;g++)l*=i[g];const u=i.slice(0,a).concat([l],i.slice(a+o)),c=D(s,u),h=D(r,[-1]),d=await rf(h),p=zs(d,[1]),f=Pa(c,p,a);return n!==s&&s.dispose(),e!==r&&r.dispose(),p.dispose(),c.dispose(),h.dispose(),d.dispose(),f}const _b=Tk;/**
2382 * @license
2383 * Copyright 2018 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 Ek(n,e,t){const s=N(n,"x","transpose");if(e==null&&(e=s.shape.map((o,i)=>i).reverse()),I(s.rank===e.length,()=>`Error in transpose: rank of input ${s.rank} must match length of perm ${e}.`),e.forEach(o=>{I(o>=0&&o<s.rank,()=>`All entries in 'perm' must be between 0 and ${s.rank-1} but got ${e}`)}),s.rank<=1)return s.clone();const r={x:s},a={perm:e};return s.dtype==="complex64"?L(()=>{let o=Lr(s),i=Ki(s);return o=F.runKernel(Js,{x:o},a),i=F.runKernel(Js,{x:i},a),t&&(i=Ve(i)),Cs(o,i)}):F.runKernel(Js,r,a)}const Ne=R({transpose_:Ek});/**
2397 * @license
2398 * Copyright 2018 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 Rk(n,e,t,s,r=!0){const a=N(n,"v","movingAverage"),o=N(e,"x","movingAverage"),i=N(t,"decay","movingAverage");EC(a,o),I(ke(a.shape,o.shape),()=>"Shape mismatch in v and x");const l=pe(1),u=ie(l,i);let c=O(ie(o,a),u);if(r){I(s!=null,()=>"When using zeroDebias: true, step is required.");const h=N(s,"step","movingAverage");c=he(c,ie(l,As(i,h)))}return te(a,c)}const Fb=R({movingAverage_:Rk});/**
2412 * @license
2413 * Copyright 2018 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 Dk(n,e,t){qn(t);const s=N(n,"indices","scatterND","int32"),r=N(e,"updates","scatterND");Ky(r,s,t);const a={indices:s,updates:r},o={shape:t};return F.runKernel(Hu,a,o)}const Lb=R({scatterND_:Dk});function Ak(n,e,t,s){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 r=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===r))throw new Error(`sparseValues has incorrect shape ${e.shape}, should be [] or [${r}]`);if(e.dtype!==s.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}/**
2427 * @license
2428 * Copyright 2018 Google LLC. All Rights Reserved.
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, softw
2435are
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 Ok(n,e,t,s=0){qn(t);const r=N(n,"sparseIndices","sparseToDense","int32"),a=N(e,"sparseValues","sparseToDense","string_or_numeric"),o=N(s,"defaultValue","sparseToDense",a.dtype);Ak(r,a,t,o);const i={sparseIndices:r,sparseValues:a,defaultValue:o},l={outputShape:t};return F.runKernel(ju,i,l)}const Pb=R({sparseToDense_:Ok});/**
2442 * @license
2443 * Copyright 2018 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 _k(n,e){const t=N(e,"indices","gatherND","int32"),r={params:N(n,"x","gatherND","string_or_numeric"),indices:t};return F.runKernel(qu,r)}const zb=R({gatherND_:_k});/**
2457 * @license
2458 * Copyright 2019 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 Fk(n,e){if(e==null)return n.shape.slice();if(ke(n.shape,e))return e;if(n.shape.length===e.length){const t=[];for(let s=0;s<n.shape.length;s++)e[s]==null&&n.shape[s]!=null?t.push(n.shape[s]):t.push(e[s]);return t}return e}/**
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 */function Lk(n,e,t,s){const r=N(n,"x","dropout");if(I(r.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${r.dtype} tensor instead.`),I(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return n instanceof lt?r.clone():r;const a=Fk(r,t),o=1-e,i=he(La(te(Ps(a,0,1,"float32",s),o)),o);return O(r,i)}const af=R({dropout_:Lk});/**
2487 * @license
2488 * Copyright 2019 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 of(n){return Math.floor(Math.pow(2,Math.ceil(Math.log(n)/Math.log(2))))}function uh(n,e,t){const s=1-n%2,r=new Float32Array(n);for(let a=0;a<n;++a){const o=2*Math.PI*a/(n+s-1);r[a]=e-t*Math.cos(o)}return xt(r,"float32")}/**
2502 * @license
2503 * Copyright 2019 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 */async function Pk(n,e,t=1){const s=N(n,"predictions","inTopK"),r=N(e,"targets","inTopK");I(s.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${s.rank}`),I(s.rank-1===r.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${s.rank} and targets rank ${r.rank}`),dn(s.shape.slice(0,s.shape.length-1),r.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const a=s.shape[s.shape.length-1];I(t>0&&t<=a,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${a}), but got ${t}`);const o=await s.data(),i=await r.data(),[l,u]=[o.length/a,a],c=wt("bool",l);for(let h=0;h<l;h++){const d=h*u,p=o.subarray(d,d+u),f=[];for(let g=0;g<p.length;g++)f.push({value:p[g],index:g});f.sort((g,m)=>m.value-g.value),c[h]=0;for(let g=0;g<t;g++)if(f[g].index===i[h]){c[h]=1;break}}return n!==s&&s.dispose(),e!==r&&r.dispose(),En(c,r.shape,"bool")}const Vb=Pk;/**
2517 * @license
2518 * Copyright 2020 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 zk(n,e,t,s,r,a="NHWC",o){let i=n;n.rank===3&&(i=D(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=D(e,[1,e.shape[0],e.shape[1],e.shape[2]])),I(i.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`),I(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),I(t.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${t}.`);const u=a==="NHWC"?i.shape[3]:i.shape[1],c=a==="NHWC"?l.shape[3]:l.shape[1];I(u===t[2],()=>`Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${t[2]}.`),I(c===t[3],()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${t[3]}).`),Ht("conv2dDerFilter",r,o);const h={x:i,dy:l},d={strides:s,pad:r,dataFormat:a,dimRoundingMode:o,filterShape:t};return F.runKernel(Ku,h,d)}const lf=R({conv2DBackpropFilter_:zk});/**
2532 * @license
2533 * Copyright 2019 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 Vk({x:n,filter:e,strides:t,pad:s,dataFormat:r="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(l=l||"linear",_d(F.state.gradientDepth,l)===!1){I(r==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${r} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let $=rs(n,e,t,s,r,a,o);return i!=null&&($=te($,i)),Fd($,l,u,c)}const h=N(n,"x","conv2d","float32"),d=N(e,"filter","conv2d","float32");let p=h,f=!1;h.rank===3&&(f=!0,p=D(h,[1,h.shape[0],h.shape[1],h.shape[2]])),I(p.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${p.rank}.`),I(d.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`),Ht("fused conv2d",s,o);const g=r==="NHWC"?p.shape[3]:p.shape[1];I(d.shape[2]===g,()=>`Error in conv2d: depth of input (${g}) must match input depth for filter ${d.shape[2]}.`),I(It(t,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`);const m=Ft(p.shape,d.shape,t,a,s,o);let y;i!=null&&(y=N(i,"bias","fused conv2d"),[y]=At(y,h),r==="NHWC"?xe(m.outShape,y.shape):(I(y.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`),I(y.shape.length===0||y.shape[0]===m.outChannels||y.shape[0]===1,()=>`Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${m.outChannels})`)));let x;if(u!=null){const $=u.shape;if(I($.length<=1||$.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-${$.length}.`),$.length===1)I($[0]===1||$[0]===m.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${$}) is not compatible with the number of output channels (${m.outChannels}).`);else if($.length===3)try{xe($,m.outShape)}catch{const k=`Error in fused conv2d: PReLU activation weights (${$}) is not compatible with the output shape of the conv2d (${m.outShape}).`;throw Error(k)}x=N(u,"prelu weights","fused conv2d")}const v=($,S)=>{I(r==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${r} but only NHWC is currently supported.`);const[k,T,E,_]=S,z=Ld($,E,l);I($i(a),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`);const P=vp(T.shape,z,k,t,s),V=lf(T,z,k.shape,t,s),B=[P,V];if(_!=null){const M=Pd(_,z);B.push(M)}return B},b={x:p,filter:d,bias:y,preluActivationWeights:x},C={strides:t,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?Hn((S,k,T)=>{let E=F.runKernel(go,b,C);return T([k,S,E]),f&&(E=D(E,[E.shape[1],E.shape[2],E.shape[3]])),{value:E,gradFunc:v}})(p,d):Hn((S,k,T,E)=>{let _=F.runKernel(go,b,C);return E([k,S,_,T]),f&&(_=D(_,[_.shape[1],_.shape[2],_.shape[3]])),{value:_,gradFunc:v}})(p,d,y)}const Bb=R({fusedConv2d_:Vk});/**
2547 * @license
2548 * Copyright 2020 Google LLC. All Rights Reserved.
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 Bk(n,e,t,s,r,a=[1,1],o){let i=n;n.rank===3&&(i=D(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=D(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const u={x:i,dy:l},c={strides:s,pad:r,dimRoundingMode:o,dilations:a,filterShape:t};return F.runKernel(Xu,u,c)}const Mb=R({depthwiseConv2dNativeBackpropFilter_:Bk});/**
2562 * @license
2563 * Copyright 2020 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 Mk(n,e,t,s,r,a=[1,1],o){let i=e,l=!1;e.rank===3&&(l=!0,i=D(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const u={dy:i,filter:t},c={strides:s,pad:r,dimRoundingMode:o,dilations:a,inputShape:n},h=F.runKernel(Yu,u,c);return l?D(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const Wb=R({depthwiseConv2dNativeBackpropInput_:Mk});/**
2577 * @license
2578 * Copyright 2019 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 Wk({x:n,filter:e,strides:t,pad:s,dataFormat:r="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(_d(F.state.gradientDepth,l)===!1){let C=_a(n,e,t,s,r,a,o);return i!=null&&(C=te(C,i)),Fd(C,l,u,c)}const h=N(n,"x","depthwiseConv2d","float32"),d=N(e,"filter","depthwiseConv2d","float32");let p=h,f=!1;h.rank===3&&(f=!0,p=D(h,[1,h.shape[0],h.shape[1],h.shape[2]])),I(p.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${p.rank}.`),I(d.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${d.rank}.`),I(p.shape[3]===d.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${p.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`),a==null&&(a=[1,1]),I(It(t,a),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${t} and dilations '${a}'`),Ht("fused depthwiseConv2d",s,o);const g=Ft(p.shape,d.shape,t,a,s,o,!0);let m;i!=null&&(m=N(i,"bias","fused conv2d"),[m]=At(m,h),xe(g.outShape,m.shape));let y;u!=null&&(y=N(u,"prelu weights","fused depthwiseConv2d"));const x=(C,$)=>{I($i(a),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);const[S,k,T,E]=$,_=Ld(C,T,l),z=Wb(k.shape,_,S,t,s,a,o),P=Mb(k,_,S.shape,t,s,a,o);if(E!=null){const V=Pd(m,_);return[z,P,V]}return[z,P]},v={x:p,filter:d,bias:m,preluActivationWeights:y},b={strides:t,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?Hn(($,S,k)=>{let T=F.runKernel(yo,v,b);return k([S,$,T]),f&&(T=D(T,[T.shape[1],T.shape[2],T.shape[3]])),{value:T,gradFunc:x}})(p,d):Hn(($,S,k,T)=>{let E=F.runKernel(yo,v,b);return T([S,$,E,k]),f&&(E=D(E,[E.shape[1],E.shape[2],E.shape[3]])),{value:E,gradFunc:x}})(p,d,m)}const Uk=R({fusedDepthwiseConv2d_:Wk});/**
2592 * @license
2593 * Copyright 2019 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 Gk({a:n,b:e,transposeA:t=!1,transposeB:s=!1,bias:r,activation:a="linear",preluActivationWeights:o,leakyreluAlpha:i=.2}){if(_d(F.state.gradientDepth,a)===!1){let _=ve(n,e,t,s);return r!=null&&(_=te(_,r)),Fd(_,a,o,i)}let l=N(n,"a","fused matMul"),u=N(e,"b","fused matMul");[l,u]=At(l,u);const c=t?l.shape[l.rank-2]:l.shape[l.rank-1],h=s?u.shape[u.rank-1]:u.shape[u.rank-2],d=t?l.shape[l.rank-1]:l.shape[l.rank-2],p=s?u.shape[u.rank-2]:u.shape[u.rank-1],f=l.shape.slice(0,-2),g=u.shape.slice(0,-2),m=H(f),y=H(g);I(c===h,()=>`Error in fused matMul: inner shapes (${c}) and (${h}) of Tensors with shapes ${l.shape} and ${u.shape} and transposeA=${t} and transposeB=${s} must match.`);const v=xe(l.shape.slice(0,-2),u.shape.slice(0,-2)).concat([d,p]),b=t?D(l,[m,c,d]):D(l,[m,d,c]),C=s?D(u,[y,p,h]):D(u,[y,h,p]);let $;r!=null&&($=N(r,"bias","fused matMul"),[$]=At($,l),xe(v,$.shape));let S;o!=null&&(S=N(o,"prelu weights","fused matMul"));const k=(_,z)=>{const[P,V,B,M]=z,j=Ld(D(_,B.shape),B,a);let U,q;if(!t&&!s?(U=ve(j,V,!1,!0),q=ve(P,j,!0,!1)):!t&&s?(U=ve(j,V,!1,!1),q=ve(j,P,!0,!1)):t&&!s?(U=ve(V,j,!1,!0),q=ve(P,j,!1,!1)):(U=ve(V,j,!0,!0),q=ve(j,P,!0,!0)),r!=null){const X=Pd(M,j);return[U,q,X]}else return[U,q]},T={a:b,b:C,bias:$,preluActivationWeights:S},E={transposeA:t,transposeB:s,activation:a,leakyreluAlpha:i};return r==null?Hn((z,P,V)=>{const B=F.runKernel(xo,T,E);return V([z,P,B]),{value:D(B,v),gradFunc:k}})(b,C):Hn((z,P,V,B)=>{const M=F.runKernel(xo,T,E);return B([z,P,M,V]),{value:D(M,v),gradFunc:k}})(b,C,$)}const td=R({fusedMatMul_:Gk});/**
2607 * @license
2608 * Copyright 2019 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 */const Ub=Object.freeze(Object.defineProperty({__proto__:null,conv2d:Bb,depthwiseConv2d:Uk,matMul:td},Symbol.toStringTag,{value:"Module"}));/**
2622 * @license
2623 * Copyright 2019 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 Hk(n){return uh(n,.54,.46)}const jk=R({hammingWindow_:Hk});/**
2637 * @license
2638 * Copyright 2019 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, softw
2645are
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 qk(n){return uh(n,.5,.5)}const Gb=R({hannWindow_:qk});/**
2652 * @license
2653 * Copyright 2019 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, software
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 Kk(n,e,t,s=!1,r=0){let a=0;const o=[];for(;a+e<=n.size;)o.push(Se(n,a,e)),a+=t;if(s)for(;a<n.size;){const i=a+e-n.size,l=Je([Se(n,a,e-i),ta([i],r)]);o.push(l),a+=t}return o.length===0?bs([],[0,e]):D(Je(o),[o.length,e])}const Hb=R({frame_:Kk});/**
2667 * @license
2668 * Copyright 2019 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 Xk(n,e,t,s,r=Gb){s==null&&(s=of(e));const a=Hb(n,e,t),o=O(a,r(e));return al(o,s)}const Yk=R({stft_:Xk});/**
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 Jk(n,e,t,s,r="bilinear",a=0){const o=N(n,"image","cropAndResize"),i=N(e,"boxes","cropAndResize","float32"),l=N(t,"boxInd","cropAndResize","int32"),u=i.shape[0];I(o.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`),I(i.rank===2&&i.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${u},4] but had shape ${i.shape}.`),I(l.rank===1&&l.shape[0]===u,()=>`Error in cropAndResize: boxInd must be have size [${u}] but had shape ${i.shape}.`),I(s.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`),I(s[0]>=1&&s[1]>=1,()=>`cropSize must be atleast [1,1], but was ${s}`),I(r==="bilinear"||r==="nearest",()=>`method must be bilinear or nearest, but was ${r}`);const c={image:o,boxes:i,boxInd:l},h={method:r,extrapolationValue:a,cropSize:s};return F.runKernel(Ju,c,h)}const Zk=R({cropAndResize_:Jk});/**
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, softw
2705are
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 Qk(n){const e=N(n,"image","flipLeftRight","float32");I(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const t={image:e};return F.runKernel(Zu,t,{})}const eT=R({flipLeftRight_:Qk});/**
2712 * @license
2713 * Copyright 2021 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 tT(n){const e=N(n,"image","grayscaleToRGB"),t=e.rank-1,s=e.shape[t];I(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),I(s===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);const r=new Array(e.rank);return r.fill(1,0,t),r[t]=3,sn(e,r)}const nT=R({grayscaleToRGB_:tT});/**
2727 * @license
2728 * Copyright 2023 Google LLC.
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, software
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 sT(n){const e=N(n,"image","RGBToGrayscale"),t=e.rank-1,s=e.shape[t];I(e.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`),I(s===3,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${s}.`);const r=e.dtype,a=ee(e,"float32"),o=xt([.2989,.587,.114]);let i;switch(e.rank){case 2:i=js("ij,j->i",a,o);break;case 3:i=js("ijk,k->ij",a,o);break;case 4:i=js("ijkl,l->ijk",a,o);break;case 5:i=js("ijklm,m->ijkl",a,o);break;case 6:i=js("ijklmn,n->ijklm",a,o);break;default:throw new Error("Not a valid tensor rank.")}return i=mt(i,-1),ee(i,r)}const rT=R({rgbToGrayscale_:sT});/**
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 aT(n,e,t=0,s=.5){const r=N(n,"image","rotateWithOffset","float32");I(r.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`);const a={image:r},o={radians:e,fillValue:t,center:s};return F.runKernel(Qu,a,o)}const oT=R({rotateWithOffset_:aT});/**
2757 * @license
2758 * Copyright 2020 Google LLC. 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 */function Va(n,e,t,s,r,a){s==null&&(s=.5),r==null&&(r=Number.NEGATIVE_INFINITY),a==null&&(a=0);const o=n.shape[0];return t=Math.min(t,o),I(0<=s&&s<=1,()=>`iouThreshold must be in [0, 1], but was '${s}'`),I(n.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${n.rank}'`),I(n.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${n.shape[1]}`),I(e.rank===1,()=>"scores must be a 1D tensor"),I(e.shape[0]===o,()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${e.shape[0]}`),I(0<=a&&a<=1,()=>`softNmsSigma must be in [0, 1], but was '${a}'`),{maxOutputSize:t,iouThreshold:s,scoreThreshold:r,softNmsSigma:a}}/**
2772 * @license
2773 * Copyright 2020 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 iT(n,e,t,s=.5,r=Number.NEGATIVE_INFINITY){const a=N(n,"boxes","nonMaxSuppression","float32"),o=N(e,"scores","nonMaxSuppression","float32"),i=Va(a,o,t,s,r);t=i.maxOutputSize,s=i.iouThreshold,r=i.scoreThreshold;const l={maxOutputSize:t,iouThreshold:s,scoreThreshold:r};return F.runKernel(ec,{boxes:a,scores:o},l)}const lT=R({nonMaxSuppression_:iT});/**
2787 * @license
2788 * Copyright 2019 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 uT(n,e,t){const s=cT(n,e,t),r=s<0?-(s+1):s;n.splice(r,0,e)}function cT(n,e,t){return dT(n,e,t||hT)}function hT(n,e){return n>e?1:n<e?-1:0}function dT(n,e,t){let s=0,r=n.length,a=0,o=!1;for(;s<r;){a=s+(r-s>>>1);const i=t(e,n[a]);i>0?s=a+1:(r=a,o=!i)}return o?s:-s-1}/**
2802 * @license
2803 * Copyright 2020 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 ch(n,e,t,s,r){return uf(n,e,t,s,r,0)}function hh(n,e,t,s,r,a){return uf(n,e,t,s,r,0,!1,a,!0)}function dh(n,e,t,s,r,a){return uf(n,e,t,s,r,a,!0)}function uf(n,e,t,s,r,a,o=!1,i=!1,l=!1){const u=[];for(let m=0;m<e.length;m++)e[m]>r&&u.push({score:e[m],boxIndex:m,suppressBeginIndex:0});
vendor: 4,622 bytes, lines 2816-2864
2816u.sort(Ig);const c=a>0?-.5/a:0,h=[],d=[];for(;h.length<t&&u.length>0;){const m=u.pop(),{score:y,boxIndex:x,suppressBeginIndex:v}=m;if(y<r)break;let b=!1;for(let C=h.length-1;C>=v;--C){const $=pT(n,x,h[C]);if($>=s){b=!0;break}if(m.score=m.score*fT(s,c,$),m.score<=r)break}m.suppressBeginIndex=h.length,b||(m.score===y?(h.push(x),d.push(m.score)):m.score>r&&uT(u,m,Ig))}const p=h.length,f=t-p;i&&f>0&&(h.push(...new Array(f).fill(0)),d.push(...new Array(f).fill(0)));const g={selectedIndices:h};return o&&(g.selectedScores=d),l&&(g.validOutputs=p),g}function pT(n,e,t){const s=n.subarray(e*4,e*4+4),r=n.subarray(t*4,t*4+4),a=Math.min(s[0],s[2]),o=Math.min(s[1],s[3]),i=Math.max(s[0],s[2]),l=Math.max(s[1],s[3]),u=Math.min(r[0],r[2]),c=Math.min(r[1],r[3]),h=Math.max(r[0],r[2]),d=Math.max(r[1],r[3]),p=(i-a)*(l-o),f=(h-u)*(d-c);if(p<=0||f<=0)return 0;const g=Math.max(a,u),m=Math.max(o,c),y=Math.min(i,h),x=Math.min(l,d),v=Math.max(y-g,0)*Math.max(x-m,0);return v/(p+f-v)}function fT(n,e,t){const s=Math.exp(e*t*t);return t<=n?s:0}function Ig(n,e){return n.score-e.score||n.score===e.score&&e.boxIndex-n.boxIndex}/**
2817 * @license
2818 * Copyright 2020 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 */async function mT(n,e,t,s=.5,r=Number.NEGATIVE_INFINITY){const a=N(n,"boxes","nonMaxSuppressionAsync"),o=N(e,"scores","nonMaxSuppressionAsync"),i=Va(a,o,t,s,r);t=i.maxOutputSize,s=i.iouThreshold,r=i.scoreThreshold;const l=await Promise.all([a.data(),o.data()]),u=l[0],c=l[1],{selectedIndices:h}=ch(u,c,t,s,r);return a!==n&&a.dispose(),o!==e&&o.dispose(),xt(h,"int32")}const gT=mT;/**
2832 * @license
2833 * Copyright 2020 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 yT(n,e,t,s=.5,r=Number.NEGATIVE_INFINITY,a=0){const o=N(n,"boxes","nonMaxSuppression"),i=N(e,"scores","nonMaxSuppression"),l=Va(o,i,t,s,r,a);t=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,a=l.softNmsSigma;const u={boxes:o,scores:i},c={maxOutputSize:t,iouThreshold:s,scoreThreshold:r,softNmsSigma:a},h=F.runKernel(tc,u,c);return{selectedIndices:h[0],selectedScores:h[1]}}const xT=R({nonMaxSuppressionWithScore_:yT});/**
2847 * @license
2848 * Copyright 2020 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 */async function bT(n,e,t,s=.5,r=Number.NEGATIVE_INFINITY,a=0){const o=N(n,"boxes","nonMaxSuppressionAsync"),i=N(e,"scores","nonMaxSuppressionAsync"),l=Va(o,i,t,s,r,a);t=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,a=l.softNmsSigma;const u=await Promise.all([o.data(),i.data()]),c=u[0],h=u[1],{selectedIndices:d,selectedScores:p}=dh(c,h,t,s,r,a);return o!==n&&o.dispose(),i!==e&&i.dispose(),{selectedIndices:xt(d,"int32"),selectedScores:xt(p)}}const wT=bT;/**
2862 * @license
2863 * Copyright 2020 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 vT(n,e,t,s=.5,r=Number.NEGATIVE_INFINITY,a=!1){const o=N(n,"boxes","nonMaxSuppression"),i=N(e,"scores","nonMaxSuppression"),l=Va(o,i,t,s,r,null),u=l.maxOutputSize,c=l.iouThreshold,h=l.scoreThreshold,d={boxes:o,scores:i},p={maxOutputSize:u,iouThreshold:c,scoreThreshold:h,padToMaxOutputSize:a},f=F.runKernel(nc,d,p);return{selectedIndices:f[0],validOutputs:f[1]}}const CT=R({nonMaxSuppressionPadded_:vT});/**
2877 * @license
2878 * Copyright 2020 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 */async function $T(n,e,t,s=.5,r=Number.NEGATIVE_INFINITY,a=!1){const o=N(n,"boxes","nonMaxSuppressionAsync"),i=N(e,"scores","nonMaxSuppressionAsync"),l=Va(o,i,t,s,r,null),u=l.maxOutputSize,c=l.iouThreshold,h=l.scoreThreshold,[d,p]=await Promise.all([o.data(),i.data()]),{selectedIndices:f,validOutputs:g}=hh(d,p,u,c,h,a);return o!==n&&o.dispose(),i!==e&&i.dispose(),{selectedIndices:xt(f,"int32"),validOutputs:pe(g,"int32")}}const NT=$T;/**
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 IT(n,e,t=!1,s=!1){const r=N(n,"images","resizeBilinear");I(r.rank===3||r.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${r.rank}.`),I(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),I(s===!1||t===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let a=r,o=!1;r.rank===3&&(o=!0,a=D(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const i={images:a},l={alignCorners:t,halfPixelCenters:s,size:e},u=F.runKernel(Ni,i,l);return o?D(u,[u.shape[1],u.shape[2],u.shape[3]]):u}const jb=R({resizeBilinear_:IT});/**
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 ST(n,e,t=!1,s=!1){const r=N(n,"images","resizeNearestNeighbor");I(r.rank===3||r.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`),I(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),I(r.dtype==="float32"||r.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),I(s===!1||t===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let a=r,o=!1;r.rank===3&&(o=!0,a=D(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const i={images:a},l={alignCorners:t,halfPixelCenters:s,size:e},u=F.runKernel(Ii,i,l);return o?D(u,[u.shape[1],u.shape[2],u.shape[3]]):u}const qb=R({resizeNearestNeighbor_:ST});/**
2922 * @license
2923 * Copyright 2021 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 * https://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 kT(n,e="binary",t=!1,s=.5){const r=N(n,"image","threshold"),a=.2989,o=.587,i=.114,l=r.shape[0]*r.shape[1];let u=O(xt([s]),255),c,h,d,p;if(I(r.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${r.rank}.`),I(r.shape[2]===3||r.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${r.shape[2]}.`),I(r.dtype==="int32"||r.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${r.dtype}.`),I(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),r.shape[2]===3){[c,h,d]=Bt(r,[1,1,1],-1);const m=O(c,a),y=O(h,o),x=O(d,i);p=te(te(m,y),x)}else p=n;if(e==="otsu"){const m=mp(ee(Jc(p),"int32"),En([]),256);u=TT(m,l)}const f=t?Ls(p,u):Lt(p,u);return ee(O(f,255),"int32")}function TT(n,e){let t=xt([-1]),s=xt([0]),r=xt([0]),a,o,i,l,u,c;for(let h=0;h<n.size-1;h++){a=Se(n,0,h+1),o=Se(n,h+1),u=he(oe(a),e),c=he(oe(o),e);const d=oe(O(a,rr(0,a.size)));i=he(d,oe(a));const p=ta(o.shape,a.size),f=te(rr(0,o.size),p),g=O(o,f);l=he(oe(g),oe(o));const m=ie(i,l),y=ie(i,l),x=O(u,c);r=O(O(x,m),y);const v=Lt(r,s);s=dt(v,r,s),t=dt(v,xt([h]),t)}return t}const ET=R({threshold_:kT});/**
2937 * @license
2938 * Copyright 2021 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 RT(n,e,t="nearest",s="constant",r=0,a){const o=N(n,"image","transform","float32"),i=N(e,"transforms","transform","float32");I(o.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${o.rank}.`),I(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"),I(a==null||a.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${a}.`);const l={image:o,transforms:i},u={interpolation:t,fillMode:s,fillValue:r,outputShape:a};return F.runKernel(sc,l,u)}const DT=R({transform_:RT});/**
2952 * @license
2953 * Copyright 2020 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 AT(n,e,t){const s=N(n,"a","bandPart");I(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);const r=s.shape,[a,o]=s.shape.slice(-2);let i,l;typeof e=="number"?(I(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),I(e<=a,()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${a}).`),i=N(e<0?a:e,"numLower","bandPart")):(I(e.dtype==="int32",()=>"bandPart(): numLower's dtype must be an int32."),i=dt(_r(e,0),a,Ss(e,a))),typeof t=="number"?(I(t%1===0,()=>`bandPart(): numUpper must be an integer, got ${t}.`),I(t<=o,()=>`bandPart(): numUpper (${t}) must not be greater than the number of columns (${o}).`),l=N(t<0?o:t,"numUpper","bandPart")):(I(t.dtype==="int32",()=>"bandPart(): numUpper's dtype must be an int32."),l=dt(_r(t,0),o,Ss(t,o)));const u=D(rr(0,a,1,"int32"),[-1,1]),c=rr(0,o,1,"int32"),h=ie(u,c),d=wn(Ls(h,i),os(h,Ve(l))),p=et([a,o],s.dtype);return D(Ot(cn(D(s,[-1,a,o])).map(f=>dt(d,f,p))),r)}const OT=R({bandPart_:AT});/**
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 _T(n){let e;if(Array.isArray(n)){e=!1,I(n!=null&&n.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const r=n[0].shape[0];for(let a=1;a<n.length;++a)I(n[a].shape[0]===r,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${n[a].shape[0]} vs. ${r})`)}else e=!0,n=Bt(n,n.shape[0],0).map(r=>zs(r,[0]));I(n.length<=n[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${n.length}) exceeds number of dimensions (${n[0].shape[0]}).`);const t=[],s=n;for(let r=0;r<n.length;++r)t.push(F.tidy(()=>{let a=s[r];if(r>0)for(let o=0;o<r;++o){const i=O(oe(O(t[o],a)),t[o]);a=ie(a,i)}return he(a,Fa(a,"euclidean"))}));return e?Ot(t,0):t}const FT=R({gramSchmidt_:_T});/**
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 LT(n,e=!1){if(I(n.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${n.rank}`),n.rank===2)return Sg(n,e);{const t=n.shape.slice(0,n.shape.length-2).reduce((l,u)=>l*u),s=cn(D(n,[t,n.shape[n.shape.length-2],n.shape[n.shape.length-1]]),0),r=[],a=[];s.forEach(l=>{const[u,c]=Sg(l,e);r.push(u),a.push(c)});const o=D(Ot(r,0),n.shape),i=D(Ot(a,0),n.shape);return[o,i]}}function Sg(n,e=!1){return F.tidy(()=>{I(n.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${n.shape.length}D Tensor.`);const t=n.shape[0],s=n.shape[1];let r=jc(t),a=ts(n);const o=bs([[1]],[1,1]);let i=ts(o);const l=t>=s?s:t;for(let u=0;u<l;++u){const c=a,h=i,d=r;[i,a,r]=F.tidy(()=>{const p=Se(a,[u,u],[t-u,1]),f=Fa(p),g=Se(a,[u,u],[1,1]),m=dt(Lt(g,0),bs([[-1]]),bs([[1]])),y=ie(g,O(m,f)),x=he(p,y);x.shape[0]===1?i=ts(o):i=Je([o,Se(x,[1,0],[x.shape[0]-1,x.shape[1]])],0);const v=Ve(he(ve(m,y),f)),b=Se(a,[u,0],[t-u,s]),C=O(v,i),$=Ne(i);if(u===0)a=ie(b,ve(C,ve($,b)));else{const T=ie(b,ve(C,ve($,b)));a=Je([Se(a,[0,0],[u,s]),T],0)}const S=Ne(C),k=Se(r,[0,u],[t,r.shape[1]-u]);if(u===0)r=ie(k,ve(ve(k,i),S));else{const T=ie(k,ve(ve(k,i),S));r=Je([Se(r,[0,0],[t,u]),T],1)}return[i,a,r]}),Re([c,h,d])}return!e&&t>s&&(r=Se(r,[0,0],[t,s]),a=Se(a,[0,0],[s,s])),[r,a]})}const PT=R({qr_:LT});/**
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, software
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 */var Et;(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"})(Et||(Et={}));function zT(n,e,t=Et.SUM_BY_NONZERO_WEIGHTS){const s=N(n,"losses","computeWeightedLoss");let r=null;e!=null&&(r=N(e,"weights","computeWeightedLoss"));const a=r==null?s:O(s,r);if(t===Et.NONE)return a;
vendor: 4,223 bytes, lines 3011-3059
3011if(t===Et.SUM)return oe(a);if(t===Et.MEAN){if(r==null)return je(a);{const o=s.size/r.size,i=he(oe(a),oe(r));return o>1?he(i,pe(o)):i}}if(t===Et.SUM_BY_NONZERO_WEIGHTS){if(r==null)return he(oe(a),pe(s.size));{const o=O(r,Vt(s.shape)),i=ee(oe(sr(o,pe(0))),"float32");return he(oe(a),i)}}throw Error(`Unknown reduction: ${t}`)}const ls=R({computeWeightedLoss_:zT});/**
3012 * @license
3013 * Copyright 2020 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 VT(n,e,t,s=Et.SUM_BY_NONZERO_WEIGHTS){const r=N(n,"labels","absoluteDifference"),a=N(e,"predictions","absoluteDifference");let o=null;t!=null&&(o=N(t,"weights","absoluteDifference")),dn(r.shape,a.shape,"Error in absoluteDifference: ");const i=rt(ie(r,a));return ls(i,o,s)}const BT=R({absoluteDifference_:VT});function MT(n,e,t,s,r=Et.SUM_BY_NONZERO_WEIGHTS){const a=N(n,"labels","cosineDistance"),o=N(e,"predictions","cosineDistance");let i=null;s!=null&&(i=N(s,"weights","cosineDistance")),dn(a.shape,o.shape,"Error in cosineDistance: ");const l=pe(1),u=ie(l,oe(O(a,o),t,!0));return ls(u,i,r)}const WT=R({cosineDistance_:MT});function UT(n,e,t,s=Et.SUM_BY_NONZERO_WEIGHTS){let r=N(n,"labels","hingeLoss");const a=N(e,"predictions","hingeLoss");let o=null;t!=null&&(o=N(t,"weights","hingeLoss")),dn(r.shape,a.shape,"Error in hingeLoss: ");const i=pe(1);r=ie(O(pe(2),r),i);const l=Kn(ie(i,O(r,a)));return ls(l,o,s)}const GT=R({hingeLoss_:UT});/**
3027 * @license
3028 * Copyright 2020 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 HT(n,e,t,s=1,r=Et.SUM_BY_NONZERO_WEIGHTS){const a=N(n,"labels","huberLoss"),o=N(e,"predictions","huberLoss");let i=null;t!=null&&(i=N(t,"weights","huberLoss")),dn(a.shape,o.shape,"Error in huberLoss: ");const l=pe(s),u=rt(ie(o,a)),c=Ss(u,l),h=ie(u,c),d=te(O(pe(.5),Ye(c)),O(l,h));return ls(d,i,r)}const jT=R({huberLoss_:HT});/**
3042 * @license
3043 * Copyright 2020 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 qT(n,e,t,s=1e-7,r=Et.SUM_BY_NONZERO_WEIGHTS){const a=N(n,"labels","logLoss"),o=N(e,"predictions","logLoss");let i=null;t!=null&&(i=N(t,"weights","logLoss")),dn(a.shape,o.shape,"Error in logLoss: ");const l=pe(1),u=pe(s),c=Ve(O(a,Jt(te(o,u)))),h=O(ie(l,a),Jt(te(ie(l,o),u))),d=ie(c,h);return ls(d,i,r)}const KT=R({logLoss_:qT});/**
3057 * @license
3058 * Copyright 2020 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 XT(n,e,t,s=Et.SUM_BY_NONZERO_WEIGHTS){const r=N(n,"labels","meanSquaredError"),a=N(e,"predictions","meanSquaredError");let o=null;t!=null&&(o=N(t,"weights","meanSquaredError")),dn(r.shape,a.shape,"Error in meanSquaredError: ");const i=ah(r,a);return ls(i,o,s)}const YT=R({meanSquaredError_:XT});/**
3072 * @license
3073 * Copyright 2020 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 JT(n,e){const t=N(n,"labels","sigmoidCrossEntropyWithLogits"),s=N(e,"logits","sigmoidCrossEntropyWithLogits");dn(t.shape,s.shape,"Error in sigmoidCrossEntropyWithLogits: ");const r=Kn(s),a=O(s,t),o=Xi(Wt(Ve(rt(s))));return te(ie(r,a),o)}function ZT(n,e,t,s=0,r=Et.SUM_BY_NONZERO_WEIGHTS){let a=N(n,"multiClassLabels","sigmoidCrossEntropy");const o=N(e,"logits","sigmoidCrossEntropy");let i=null;if(t!=null&&(i=N(t,"weights","sigmoidCrossEntropy")),dn(a.shape,o.shape,"Error in sigmoidCrossEntropy: "),s>0){const u=pe(s),c=pe(1),h=pe(.5);a=te(O(a,ie(c,u)),O(h,u))}const l=JT(a,o);return ls(l,i,r)}const QT=R({sigmoidCrossEntropy_:ZT});/**
3087 * @license
3088 * Copyright 2020 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 e2(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 Hn((r,a,o)=>{const l=Yi(a,[t],!0),u=ie(ee(a,"float32"),l);o([r,u]);const c=Ve(O(u,r));return{value:oe(c,[t]),gradFunc:(p,f)=>{const[g,m]=f,y=nt(p.shape,[t]);return[O(D(p,y),ie(ee(g,"float32"),Wt(m))),O(D(p,y),ie(Wt(m),ee(g,"float32")))]}}})(n,e)}function t2(n,e,t,s=0,r=Et.SUM_BY_NONZERO_WEIGHTS){let a=N(n,"onehotLabels","softmaxCrossEntropy");const o=N(e,"logits","softmaxCrossEntropy");let i=null;if(t!=null&&(i=N(t,"weights","softmaxCrossEntropy")),dn(a.shape,o.shape,"Error in softmaxCrossEntropy: "),s>0){const u=pe(s),c=pe(1),h=pe(a.shape[1]);a=te(O(a,ie(c,u)),he(u,h))}const l=e2(a,o);return ls(l,i,r)}const n2=R({softmaxCrossEntropy_:t2});/**
3102 * @license
3103 * Copyright 2021 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, softw
3110are
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 s2(n,e,t,s){const r=N(n,"indices","sparseFillEmptyRows","int32"),a=N(e,"values","sparseFillEmptyRows"),o=N(t,"denseShape","sparseFillEmptyRows","int32"),i=N(s,"defaultValue","sparseFillEmptyRows",a.dtype);if(r.rank!==2)throw new Error(`Indices should be Tensor2D but received shape
3117        ${r.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 l={indices:r,values:a,denseShape:o,defaultValue:i},u=F.runKernel(rc,l);return{outputIndices:u[0],outputValues:u[1],emptyRowIndicator:u[2],reverseIndexMap:u[3]}}const r2=R({sparseFillEmptyRows_:s2});/**
3118 * @license
3119 * Copyright 2021 Google LLC. All Rights Reserved.
3120 * Licensed under the Apache License, Version 2.0 (the "License");
3121 * you may not use this file except in compliance with the License.
3122 * You may obtain a copy of the License at
3123 *
3124 * http://www.apache.org/licenses/LICENSE-2.0
3125 *
3126 * Unless required by applicable law or agreed to in writing, software
3127 * distributed under the License is distributed on an "AS IS" BASIS,
3128 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3129 * See the License for the specific language governing permissions and
3130 * limitations under the License.
3131 * =============================================================================
3132 */function a2(n,e,t){const s=N(n,"inputIndices","sparseReshape","int32"),r=N(e,"inputShape","sparseReshape","int32"),a=N(t,"newShape","sparseReshape","int32");if(s.rank!==2)throw new Error(`Input indices should be Tensor2D but received shape
3133        ${s.shape}`);if(r.rank!==1)throw new Error(`Input shape should be Tensor1D but received shape ${r.shape}`);if(a.rank!==1)throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`);const o={inputIndices:s,inputShape:r,newShape:a},i=F.runKernel(ac,o);return{outputIndices:i[0],outputShape:i[1]}}const o2=R({sparseReshape_:a2});/**
3134 * @license
3135 * Copyright 2021 Google LLC. All Rights Reserved.
3136 * Licensed under the Apache License, Version 2.0 (the "License");
3137 * you may not use this file except in compliance with the License.
3138 * You may obtain a copy of the License at
3139 *
3140 * http://www.apache.org/licenses/LICENSE-2.0
3141 *
3142 * Unless required by applicable law or agreed to in writing, software
3143 * distributed under the License is distributed on an "AS IS" BASIS,
3144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3145 * See the License for the specific language governing permissions and
3146 * limitations under the License.
3147 * =============================================================================
3148 */function i2(n,e,t){const s=N(n,"data","sparseSegmentMean"),r=N(e,"indices","sparseSegmentMean","int32"),a=N(t,"segmentIds","sparseSegmentMean","int32");if(s.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
3149          ${r.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
3150          ${a.shape}`);const o={data:s,indices:r,segmentIds:a};return F.runKernel(oc,o)}const l2=R({sparseSegmentMean_:i2});/**
3151 * @license
3152 * Copyright 2021 Google LLC. All Rights Reserved.
3153 * Licensed under the Apache License, Version 2.0 (the "License");
3154 * you may not use this file except in compliance with the License.
3155 * You may obtain a copy of the License at
3156 *
3157 * http://www.apache.org/licenses/LICENSE-2.0
3158 *
3159 * Unless required by applicable law or agreed to in writing, software
3160 * distributed under the License is distributed on an "AS IS" BASIS,
3161 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3162 * See the License for the specific language governing permissions and
3163 * limitations under the License.
3164 * =============================================================================
3165 */function u2(n,e,t){const s=N(n,"data","sparseSegmentSum"),r=N(e,"indices","sparseSegmentSum","int32"),a=N(t,"segmentIds","sparseSegmentSum","int32");if(s.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");
3165if(r.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
3166         ${r.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
3167         ${a.shape}`);const o={data:s,indices:r,segmentIds:a};return F.runKernel(ic,o)}const c2=R({sparseSegmentSum_:u2});/**
3168 * @license
3169 * Copyright 2021 Google LLC. All Rights Reserved.
3170 * Licensed under the Apache License, Version 2.0 (the "License");
3171 * you may not use this file except in compliance with the License.
3172 * You may obtain a copy of the License at
3173 *
3174 * http://www.apache.org/licenses/LICENSE-2.0
3175 *
3176 * Unless required by applicable law or agreed to in writing, software
3177 * distributed under the License is distributed on an "AS IS" BASIS,
3178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3179 * See the License for the specific language governing permissions and
3180 * limitations under the License.
3181 * =============================================================================
3182 */function h2(n,e,t,s,r,a,o,i){const l=N(n,"data","stringNGrams","string");if(l.dtype!=="string")throw new Error("Data must be of datatype string");if(l.shape.length!==1)throw new Error(`Data must be a vector, saw: ${l.shape}`);const u=N(e,"dataSplits","stringNGrams");if(u.dtype!=="int32")throw new Error("Data splits must be of datatype int32");const c={separator:t,nGramWidths:s,leftPad:r,rightPad:a,padWidth:o,preserveShortSequences:i},h={data:l,dataSplits:u},d=F.runKernel(lc,h,c);return{nGrams:d[0],nGramsSplits:d[1]}}const d2=R({stringNGrams_:h2});/**
3183 * @license
3184 * Copyright 2021 Google LLC. All Rights Reserved.
3185 * Licensed under the Apache License, Version 2.0 (the "License");
3186 * you may not use this file except in compliance with the License.
3187 * You may obtain a copy of the License at
3188 *
3189 * http://www.apache.org/licenses/LICENSE-2.0
3190 *
3191 * Unless required by applicable law or agreed to in writing, software
3192 * distributed under the License is distributed on an "AS IS" BASIS,
3193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3194 * See the License for the specific language governing permissions and
3195 * limitations under the License.
3196 * =============================================================================
3197 */function p2(n,e,t=!0){const s=N(n,"input","stringSplit","string"),r=N(e,"delimiter","stringSplit","string");if(s.rank!==1)throw new Error(`Input should be Tensor1D but received shape ${s.shape}`);if(r.rank!==0)throw new Error(`Delimiter should be a scalar but received shape ${r.shape}`);const a={skipEmpty:t},o={input:s,delimiter:r},i=F.runKernel(uc,o,a);return{indices:i[0],values:i[1],shape:i[2]}}const f2=R({stringSplit_:p2});/**
3198 * @license
3199 * Copyright 2021 Google LLC. All Rights Reserved.
3200 * Licensed under the Apache License, Version 2.0 (the "License");
3201 * you may not use this file except in compliance with the License.
3202 * You may obtain a copy of the License at
3203 *
3204 * http://www.apache.org/licenses/LICENSE-2.0
3205 *
3206 * Unless required by applicable law or agreed to in writing, software
3207 * distributed under the License is distributed on an "AS IS" BASIS,
3208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3209 * See the License for the specific language governing permissions and
3210 * limitations under the License.
3211 * =============================================================================
3212 */function m2(n,e){const t=N(n,"input","stringToHashBucketFast","string"),s={numBuckets:e};if(e<=0)throw new Error("Number of buckets must be at least 1");const r={input:t};return F.runKernel(cc,r,s)}const g2=R({stringToHashBucketFast_:m2});/**
3213 * @license
3214 * Copyright 2023 Google LLC.
3215 * Licensed under the Apache License, Version 2.0 (the "License");
3216 * you may not use this file except in compliance with the License.
3217 * You may obtain a copy of the License at
3218 *
3219 * http://www.apache.org/licenses/LICENSE-2.0
3220 *
3221 * Unless required by applicable law or agreed to in writing, software
3222 * distributed under the License is distributed on an "AS IS" BASIS,
3223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3224 * See the License for the specific language governing permissions and
3225 * limitations under the License.
3226 * =============================================================================
3227 */function y2(n,e,t,s=!0){const r=N(n,"input","staticRegexReplace","string"),a={pattern:e,rewrite:t,replaceGlobal:s};return F.runKernel(Si,{x:r},a)}const x2=R({staticRegexReplace_:y2});/**
3228 * @license
3229 * Copyright 2020 Google LLC. All Rights Reserved.
3230 * Licensed under the Apache License, Version 2.0 (the "License");
3231 * you may not use this file except in compliance with the License.
3232 * You may obtain a copy of the License at
3233 *
3234 * http://www.apache.org/licenses/LICENSE-2.0
3235 *
3236 * Unless required by applicable law or agreed to in writing, software
3237 * distributed under the License is distributed on an "AS IS" BASIS,
3238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3239 * See the License for the specific language governing permissions and
3240 * limitations under the License.
3241 * =============================================================================
3242 */const Kb={fft:rl,ifft:zr,rfft:al,irfft:rh},Xb={hammingWindow:jk,hannWindow:Gb,frame:Hb,stft:Yk},yn={flipLeftRight:eT,grayscaleToRGB:nT,resizeNearestNeighbor:qb,resizeBilinear:jb,rgbToGrayscale:rT,rotateWithOffset:oT,cropAndResize:Zk,nonMaxSuppression:lT,nonMaxSuppressionAsync:gT,nonMaxSuppressionWithScore:xT,nonMaxSuppressionWithScoreAsync:wT,nonMaxSuppressionPadded:CT,nonMaxSuppressionPaddedAsync:NT,threshold:ET,transform:DT},cf={bandPart:OT,gramSchmidt:FT,qr:PT},Yb={absoluteDifference:BT,computeWeightedLoss:ls,cosineDistance:WT,hingeLoss:GT,huberLoss:jT,logLoss:KT,meanSquaredError:YT,sigmoidCrossEntropy:QT,softmaxCrossEntropy:n2},Jb={sparseFillEmptyRows:r2,sparseReshape:o2,sparseSegmentMean:l2,sparseSegmentSum:c2},Zb={stringNGrams:d2,stringSplit:f2,stringToHashBucketFast:g2,staticRegexReplace:x2};/**
3243 * @license
3244 * Copyright 2018 Google LLC. All Rights Reserved.
3245 * Licensed under the Apache License, Version 2.0 (the "License");
3246 * you may not use this file except in compliance with the License.
3247 * You may obtain a copy of the License at
3248 *
3249 * http://www.apache.org/licenses/LICENSE-2.0
3250 *
3251 * Unless required by applicable law or agreed to in writing, software
3252 * distributed under the License is distributed on an "AS IS" BASIS,
3253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3254 * See the License for the specific language governing permissions and
3255 * limitations under the License.
3256 * =============================================================================
3257 */const b2="model",w2=".json",v2=".weights.bin";function kg(n){return new Promise(e=>setTimeout(e)).then(n)}class ar{constructor(e){if(!W().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(ar.URL_SCHEME)&&(e=e.slice(ar.URL_SCHEME.length)),(e==null||e.length===0)&&(e=b2),this.modelJsonFileName=e+w2,this.weightDataFileName=e+v2}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=hc.join(e.weightData),s=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 r=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],a=Xy(e,r),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 kg(()=>i.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){const l=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;l.download=this.weightDataFileName,l.href=s,await kg(()=>l.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Bd(e)}}}}ar.URL_SCHEME="downloads://";class C2{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 s=new FileReader;s.onload=r=>{const a=JSON.parse(r.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 l=zd(a,u=>this.loadWeights(u));e(l)},s.onerror=r=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),s.readAsText(this.jsonFile)})}loadWeights(e){const t=[],s=[];for(const o of e)t.push(...o.weights),s.push(...o.paths);const r=this.checkManifestAndWeightFiles(e),a=s.map(o=>this.loadWeightsFile(o,r[o]));return Promise.all(a).then(o=>[t,o])}loadWeightsFile(e,t){return new Promise((s,r)=>{const a=new FileReader;a.onload=o=>{const i=o.target.result;s(i)},a.onerror=o=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){const t=[],s=this.weightsFiles.map(a=>wg(a.name)),r={};for(const a of e)a.paths.forEach(o=>{const i=wg(o);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),s.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);r[o]=this.weightsFiles[s.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 r}}const $2=n=>
3257W().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(ar.URL_SCHEME)?N2(n.slice(ar.URL_SCHEME.length)):null;Vd.registerSaveRouter($2);function N2(n="model"){return new ar(n)}function I2(n){return new C2(n)}/**
3258 * @license
3259 * Copyright 2019 Google LLC. All Rights Reserved.
3260 * Licensed under the Apache License, Version 2.0 (the "License");
3261 * you may not use this file except in compliance with the License.
3262 * You may obtain a copy of the License at
3263 *
3264 * http://www.apache.org/licenses/LICENSE-2.0
3265 *
3266 * Unless required by applicable law or agreed to in writing, software
3267 * distributed under the License is distributed on an "AS IS" BASIS,
3268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3269 * See the License for the specific language governing permissions and
3270 * limitations under the License.
3271 * =============================================================================
3272 */function Tg(n,e,t,s){o(n),t=t??0,s=s??1,i(t,s);let r=0;const a=l=>(l.then(u=>{const c=t+ ++r/n.length*(s-t);return e(c),u}),l);function o(l){I(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function i(l,u){I(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),I(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),I(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(n.map(a))}/**
3273 * @license
3274 * Copyright 2018 Google LLC. All Rights Reserved.
3275 * Licensed under the Apache License, Version 2.0 (the "License");
3276 * you may not use this file except in compliance with the License.
3277 * You may obtain a copy of the License at
3278 *
3279 * http://www.apache.org/licenses/LICENSE-2.0
3280 *
3281 * Unless required by applicable law or agreed to in writing, software
3282 * distributed under the License is distributed on an "AS IS" BASIS,
3283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3284 * See the License for the specific language governing permissions and
3285 * limitations under the License.
3286 * =============================================================================
3287 */async function Qb(n,e){e==null&&(e={});const t=e.fetchFunc==null?W().platform.fetch:e.fetchFunc,s=n.map(h=>t(h,e.requestInit,{isBinary:!0})),i=(e.onProgress==null?await Promise.all(s):await Tg(s,e.onProgress,0,.5)).map(h=>h.arrayBuffer());return e.onProgress==null?await Promise.all(i):await Tg(i,e.onProgress,.5,1)}function S2(n,e){var t;const s=e.fetchFunc==null?W().platform.fetch:e.fetchFunc;let r=0,a;return(t=e.onProgress)===null||t===void 0||t.call(e,0),new ReadableStream({pull:async o=>{for(var i;r<n.length;){a||(a=(await s(n[r],e.requestInit,{isBinary:!0})).body.getReader());const{done:l,value:u}=await a.read();if(l){r++,a=void 0,(i=e.onProgress)===null||i===void 0||i.call(e,r/n.length);continue}o.enqueue(u);return}o.close()}})}async function ew(n,e="",t,s){return tw(o=>Qb(o,{requestInit:s}))(n,e,t)}function tw(n){return async(e,t="",s)=>{const r=e.map(()=>!1),a={},o=s!=null?s.map(()=>!1):[],i=[];if(e.forEach((p,f)=>{let g=0;p.weights.forEach(m=>{const y="quantization"in m?m.quantization.dtype:m.dtype,x=RC[y]*H(m.shape),v=()=>{r[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:m,groupOffset:g,sizeBytes:x})};
3287s!=null?s.forEach((b,C)=>{b===m.name&&(v(),o[C]=!0)}):v(),i.push(m.name),g+=x})}),!o.every(p=>p)){const p=s.filter((f,g)=>!o[g]);throw new Error(`Could not find weights in manifest with names: ${p.join(", ")}. 
3288Manifest JSON has weights with names: ${i.join(", ")}.`)}const l=r.reduce((p,f,g)=>(f&&p.push(g),p),[]),u=[];l.forEach(p=>{e[p].paths.forEach(f=>{const g=t+(t.endsWith("/")?"":"/")+f;u.push(g)})});const c=await n(u),h={};let d=0;return l.forEach(p=>{const f=e[p].paths.length,g=new hc(c.slice(d,d+f));a[p].forEach(y=>{const x=g.slice(y.groupOffset,y.groupOffset+y.sizeBytes),v=Md(x,[y.manifestEntry]);for(const b in v)h[b]=v[b]}),d+=f}),h}}/**
3289 * @license
3290 * Copyright 2018 Google LLC. All Rights Reserved.
3291 * Licensed under the Apache License, Version 2.0 (the "License");
3292 * you may not use this file except in compliance with the License.
3293 * You may obtain a copy of the License at
3294 *
3295 * http://www.apache.org/licenses/LICENSE-2.0
3296 *
3297 * Unless required by applicable law or agreed to in writing, software
3298 * distributed under the License is distributed on an "AS IS" BASIS,
3299 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3300 * See the License for the specific language governing permissions and
3301 * limitations under the License.
3302 * =============================================================================
3303 */const k2="application/octet-stream",T2="application/json";class hf{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?(I(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=W().platform.fetch,I(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&I(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 s=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],r=Xy(e,s);if(t.body.append("model.json",new Blob([JSON.stringify(r)],{type:T2}),"model.json"),e.weightData!=null){const o=hc.join(e.weightData);t.body.append("model.weights.bin",new Blob([o],{type:k2}),"model.weights.bin")}const a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:Bd(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 s=t.modelTopology,r=t.weightsManifest;if(s==null&&r==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 zd(e,t=>this.loadWeights(t))}async loadStream(){const e=await this.loadModelJSON(),t=await this.getWeightUrls(e.weightsManifest),s=jl(e.weightsManifest),r=()=>S2(t,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:s,getWeightStream:r})}async getWeightUrls(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[s,r]=E2(t),a=this.weightPathPrefix||s,o=[],i=[];for(const l of e)for(const u of l.paths)this.weightUrlConverter!=null?i.push(this.weightUrlConverter(u)):o.push(a+u+r);return this.weightUrlConverter&&o.push(...await Promise.all(i)),o}async loadWeights(e){const t=await this.getWeightUrls(e),s=jl(e),r=await Qb(t,this.loadOptions);return[s,r]}}hf.URL_SCHEME_REGEX=/^https?:\/\//;function E2(n){const e=n.lastIndexOf("/"),t=n.lastIndexOf("?"),s=n.substring(0,e),r=t>e?n.substring(t):"";return[s+"/",r]}
3303function nd(n){return n.match(hf.URL_SCHEME_REGEX)!=null}const nw=(n,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let t=!0;if(Array.isArray(n)?t=n.every(s=>nd(s)):t=nd(n),t)return df(n,e)}return null};Vd.registerSaveRouter(nw);Vd.registerLoadRouter(nw);function df(n,e){return new hf(n,e)}function sw(n,e){return df(n,e)}/**
3304 * @license
3305 * Copyright 2018 Google LLC. All Rights Reserved.
3306 * Licensed under the Apache License, Version 2.0 (the "License");
3307 * you may not use this file except in compliance with the License.
3308 * You may obtain a copy of the License at
3309 *
3310 * http://www.apache.org/licenses/LICENSE-2.0
3311 *
3312 * Unless required by applicable law or agreed to in writing, software
3313 * distributed under the License is distributed on an "AS IS" BASIS,
3314 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3315 * See the License for the specific language governing permissions and
3316 * limitations under the License.
3317 * =============================================================================
3318 */class Mh{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class rw{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class R2{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function D2(n,e,t,s){const r=arguments;return new R2(Jl(...r))}function Jl(n,e,t,s){return arguments.length===1?n.modelTopology!=null||n.weightSpecs!=null?new Mh(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 Mh({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 Mh({modelTopology:n,weightSpecs:e,weightData:t,trainingConfig:s}))}function A2(n){return new rw(n)}function O2(n){return new rw(n)}/**
3319 * @license
3320 * Copyright 2018 Google LLC. All Rights Reserved.
3321 * Licensed under the Apache License, Version 2.0 (the "License");
3322 * you may not use this file except in compliance with the License.
3323 * You may obtain a copy of the License at
3324 *
3325 * http://www.apache.org/licenses/LICENSE-2.0
3326 *
3327 * Unless required by applicable law or agreed to in writing, software
3328 * distributed under the License is distributed on an "AS IS" BASIS,
3329 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3330 * See the License for the specific language governing permissions and
3331 * limitations under the License.
3332 * =============================================================================
3333 */const pf=Object.freeze(Object.defineProperty({__proto__:null,CompositeArrayBuffer:hc,browserFiles:I2,browserHTTPRequest:sw,concatenateArrayBuffers:Yy,copyModel:DC,decodeWeights:Md,decodeWeightsStream:Jy,encodeWeights:Jh,fromMemory:D2,fromMemorySync:Jl,getLoadHandlers:Zy,getModelArtifactsForJSON:zd,getModelArtifactsForJSONSync:Qy,getModelArtifactsInfoForJSON:Bd,getSaveHandlers:ex,getWeightSpecs:jl,http:df,isHTTPScheme:nd,listModels:AC,loadWeights:ew,moveModel:OC,registerLoadRouter:_C,registerSaveRouter:FC,removeModel:LC,weightsLoaderFactory:tw,withSaveHandler:A2,withSaveHandlerSync:O2},Symbol.toStringTag,{value:"Module"}));/**
3334 * @license
3335 * Copyright 2018 Google LLC. All Rights Reserved.
3336 * Licensed under the Apache License, Version 2.0 (the "License");
3337 * you may not use this file except in compliance with the License.
3338 * You may obtain a copy of the License at
3339 *
3340 * http://www.apache.org/licenses/LICENSE-2.0
3341 *
3342 * Unless required by applicable law or agreed to in writing, software
3343 * distributed under the License is distributed on an "AS IS" BASIS,
3344 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3345 * See the License for the specific language governing permissions and
3346 * limitations under the License.
3347 * =============================================================================
3348 */function _2(n,e,t){const s=N(n,"labels","confusionMatrix"),r=N(e,"predictions","confusionMatrix");I(t==null||t>0&&Number.isInteger(t),()=>`If provided, numClasses must be a positive integer, but got ${t}`),I(s.rank===1,()=>`Expected the rank of labels to be 1, but got ${s.rank}
3348`),I(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),I(s.shape[0]===r.shape[0],()=>`Mismatch in the number of examples: ${s.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`),I(t>0&&Number.isInteger(t),()=>`numClasses is required to be a positive integer, but got ${t}`);const a=Fr(ee(s,"int32"),t),o=Fr(ee(r,"int32"),t),i=Ne(a),l=ve(i,o);return ee(l,"int32")}const F2=R({confusionMatrix_:_2});/**
3349 * @license
3350 * Copyright 2018 Google LLC. All Rights Reserved.
3351 * Licensed under the Apache License, Version 2.0 (the "License");
3352 * you may not use this file except in compliance with the License.
3353 * You may obtain a copy of the License at
3354 *
3355 * http://www.apache.org/licenses/LICENSE-2.0
3356 *
3357 * Unless required by applicable law or agreed to in writing, software
3358 * distributed under the License is distributed on an "AS IS" BASIS,
3359 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3360 * See the License for the specific language governing permissions and
3361 * limitations under the License.
3362 * =============================================================================
3363 */const L2=Object.freeze(Object.defineProperty({__proto__:null,confusionMatrix:F2},Symbol.toStringTag,{value:"Module"}));/**
3364 * @license
3365 * Copyright 2019 Google LLC. All Rights Reserved.
3366 * Licensed under the Apache License, Version 2.0 (the "License");
3367 * you may not use this file except in compliance with the License.
3368 * You may obtain a copy of the License at
3369 *
3370 * http://www.apache.org/licenses/LICENSE-2.0
3371 *
3372 * Unless required by applicable law or agreed to in writing, software
3373 * distributed under the License is distributed on an "AS IS" BASIS,
3374 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3375 * See the License for the specific language governing permissions and
3376 * limitations under the License.
3377 * =============================================================================
3378 */let Ws,Eg=!1;function aw(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,s=!1,r=!1,a=!1,o=!1,i=!1;if(n.data instanceof Uint8Array)t=!0;else if(typeof ImageData<"u"&&n instanceof ImageData)s=!0;else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)r=!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(Wd(ql,F.backendName)!=null){const f={pixels:n},g={numChannels:e};return F.runKernel(ql,f,g)}const[u,c]=r?[n.videoWidth,n.videoHeight]:[n.width,n.height];let h;if(o)h=n.getContext("2d").getImageData(0,0,u,c).data;else if(s||t)h=n.data;else if(a||r||i){if(Ws==null)if(typeof document>"u")if(typeof OffscreenCanvas<"u"&&typeof OffscreenCanvasRenderingContext2D<"u")Ws=new OffscreenCanvas(1,1).getContext("2d");else throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");else Ws=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});Ws.canvas.width=u,Ws.canvas.height=c,Ws.drawImage(n,0,0,u,c),h=Ws.getImageData(0,0,u,c).data}let d;if(e===4)d=new Int32Array(h);else{const f=u*c;d=new Int32Array(f*e);for(let g=0;g<f;g++)for(let m=0;m<e;++m)d[g*e+m]=h[g*4+m]}return ef(d,[c,u,e],"int32")}function P2(n){return n!=null&&n.data instanceof Uint8Array}function z2(){return typeof window<"u"&&typeof ImageBitmap<"u"&&window.hasOwnProperty("createImageBitmap")}function V2(n){return n!=null&&n.width!==0&&n.height!==0}function B2(n){return z2()&&!(n instanceof ImageBitmap)&&V2(n)&&!P2(n)}async function M2(n,e=3){let t=null;if(W().getBool("WRAP_TO_IMAGEBITMAP")&&B2(n)){let s;try{s=await createImageBitmap(n,{premultiplyAlpha:"none"})}catch{s=null}s!=null&&s.width===n.width&&s.height===n.height?t=s:t=n}else t=n;return aw(t,e)}
3378function ow(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.`)}function W2(n){const e=(n==null?void 0:n.alpha)||1;if(e>1||e<0)throw new Error(`Alpha value ${e} is suppoed to be in range [0 - 1].`)}async function U2(n,e){let t=N(n,"img","toPixels");if(!(n instanceof lt)){const u=t;t=ee(u,"int32"),u.dispose()}ow(t);const[s,r]=t.shape.slice(0,2),a=t.rank===2?1:t.shape[2],o=await t.data(),i=t.dtype==="float32"?255:1,l=new Uint8ClampedArray(r*s*4);for(let u=0;u<s*r;++u){const c=[0,0,0,255];for(let d=0;d<a;d++){const p=o[u*a+d];if(t.dtype==="float32"){if(p<0||p>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${p}.`)}else if(t.dtype==="int32"&&(p<0||p>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${p}.`);a===1?(c[0]=p*i,c[1]=p*i,c[2]=p*i):c[d]=p*i}const h=u*4;l[h+0]=Math.round(c[0]),l[h+1]=Math.round(c[1]),l[h+2]=Math.round(c[2]),l[h+3]=Math.round(c[3])}if(e!=null){Eg||Wd(dc,F.backendName)!=null&&(console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."),Eg=!0),e.width=r,e.height=s;const u=e.getContext("2d"),c=new ImageData(l,r,s);u.putImageData(c,0,0)}return t!==n&&t.dispose(),l}function G2(n,e,t){let s=N(n,"img","draw");if(!(n instanceof lt)){const o=s;s=ee(o,"int32"),o.dispose()}ow(s),W2(t==null?void 0:t.imageOptions);const r={image:s},a={canvas:e,options:t};F.runKernel(dc,r,a)}const iw=R({fromPixels_:aw}),H2=Object.freeze(Object.defineProperty({__proto__:null,draw:G2,fromPixels:iw,fromPixelsAsync:M2,toPixels:U2},Symbol.toStringTag,{value:"Module"}));/** @license See the LICENSE file. */const lw="4.22.0";/**
3379 * @license
3380 * Copyright 2018 Google LLC. All Rights Reserved.
3381 * Licensed under the Apache License, Version 2.0 (the "License");
3382 * you may not use this file except in compliance with the License.
3383 * You may obtain a copy of the License at
3384 *
3385 * http://www.apache.org/licenses/LICENSE-2.0
3386 *
3387 * Unless required by applicable law or agreed to in writing, software
3388 * distributed under the License is distributed on an "AS IS" BASIS,
3389 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3390 * See the License for the specific language governing permissions and
3391 * limitations under the License.
3392 * =============================================================================
3393 */class uw{static sgd(e){return new tx(e)}static momentum(e,t,s=!1){return new nx(e,t,s)}static rmsprop(e,t=.9,s=0,r=null,a=!1){return new sx(e,t,s,r,a)}static adam(e=.001,t=.9,s=.999,r=null){return new rx(e,t,s,r)}static adadelta(e=.001,t=.95,s=null){return new ax(e,t,s)}static adamax(e=.002,t=.9,s=.999,r=null,a=0){return new ox(e,t,s,r,a)}static adagrad(e,t=.1){return new ix(e,t)}}/**
3394 * @license
3395 * Copyright 2018 Google LLC. All Rights Reserved.
3396 * Licensed under the Apache License, Version 2.0 (the "License");
3397 * you may not use this file except in compliance with the License.
3398 * You may obtain a copy of the License at
3399 *
3400 * http://www.apache.org/licenses/LICENSE-2.0
3401 *
3402 * Unless required by applicable law or agreed to in writing, software
3403 * distributed under the License is distributed on an "AS IS" BASIS,
3404 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3405 * See the License for the specific language governing permissions and
3406 * limitations under the License.
3407 * =============================================================================
3408 */const Hs=uw;/**
3409 * @license
3410 * Copyright 2017 Google LLC. All Rights Reserved.
3411 * Licensed under the Apache License, Version 2.0 (the "License");
3412 * you may not use this file except in compliance with the License.
3413 * You may obtain a copy of the License at
3414 *
3415 * http://www.apache.org/licenses/LICENSE-2.0
3416 *
3417 * Unless required by applicable law or agreed to in writing, softw
3417are
3418 * distributed under the License is distributed on an "AS IS" BASIS,
3419 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3420 * See the License for the specific language governing permissions and
3421 * limitations under the License.
3422 * =============================================================================
3423 */const j2=typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:n=>n();function ff(){return new Promise(n=>j2(()=>n()))}/**
3424 * @license
3425 * Copyright 2020 Google LLC. All Rights Reserved.
3426 * Licensed under the Apache License, Version 2.0 (the "License");
3427 * you may not use this file except in compliance with the License.
3428 * You may obtain a copy of the License at
3429 *
3430 * http://www.apache.org/licenses/LICENSE-2.0
3431 *
3432 * Unless required by applicable law or agreed to in writing, software
3433 * distributed under the License is distributed on an "AS IS" BASIS,
3434 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3435 * See the License for the specific language governing permissions and
3436 * limitations under the License.
3437 * =============================================================================
3438 */const q2=Object.freeze(Object.defineProperty({__proto__:null,nonMaxSuppressionV3Impl:ch,nonMaxSuppressionV4Impl:hh,nonMaxSuppressionV5Impl:dh,whereImpl:lh},Symbol.toStringTag,{value:"Module"}));/**
3439 * @license
3440 * Copyright 2020 Google LLC. All Rights Reserved.
3441 * Licensed under the Apache License, Version 2.0 (the "License");
3442 * you may not use this file except in compliance with the License.
3443 * You may obtain a copy of the License at
3444 *
3445 * http://www.apache.org/licenses/LICENSE-2.0
3446 *
3447 * Unless required by applicable law or agreed to in writing, software
3448 * distributed under the License is distributed on an "AS IS" BASIS,
3449 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3450 * See the License for the specific language governing permissions and
3451 * limitations under the License.
3452 * =============================================================================
3453 */const cw={kernelName:pc,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(n,Ea(ee(t,"float32"),-1))}}};/**
3454 * @license
3455 * Copyright 2020 Google LLC. All Rights Reserved.
3456 * Licensed under the Apache License, Version 2.0 (the "License");
3457 * you may not use this file except in compliance with the License.
3458 * You may obtain a copy of the License at
3459 *
3460 * http://www.apache.org/licenses/LICENSE-2.0
3461 *
3462 * Unless required by applicable law or agreed to in writing, software
3463 * distributed under the License is distributed on an "AS IS" BASIS,
3464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3465 * See the License for the specific language governing permissions and
3466 * limitations under the License.
3467 * =============================================================================
3468 */const K2={kernelName:Hr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Ye(ee(t,"float32")),r=ln(ie(pe(1),s));return Ve(he(n,r))}}}};/**
3469 * @license
3470 * Copyright 2020 Google LLC. All Rights Reserved.
3471 * Licensed under the Apache License, Version 2.0 (the "License");
3472 * you may not use this file except in compliance with the License.
3473 * You may obtain a copy of the License at
3474 *
3475 * http://www.apache.org/licenses/LICENSE-2.0
3476 *
3477 * Unless required by applicable law or agreed to in writing, software
3478 * distributed under the License is distributed on an "AS IS" BASIS,
3479 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3480 * See the License for the specific language governing permissions and
3481 * limitations under the License.
3482 * =============================================================================
3483 */const X2={kernelName:jr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=ln(ie(Ye(ee(t,"float32")),1));return he(n,s)}}}};/**
3484 * @license
3485 * Copyright 2020 Google LLC. All Rights Reserved.
3486 * Licensed under the Apache License, Version 2.0 (the "License");
3487 * you may not use this file except in compliance with the License.
3488 * You may obtain a copy of the License at
3489 *
3490 * http://www.apache.org/licenses/LICENSE-2.0
3491 *
3492 * Unless required by applicable law or agreed to in writing, softw
3492are
3493 * distributed under the License is distributed on an "AS IS" BASIS,
3494 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3495 * See the License for the specific language governing permissions and
3496 * limitations under the License.
3497 * =============================================================================
3498 */const Y2={kernelName:ki,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=xe(t.shape,s.shape);return{a:()=>{let i=n;const l=vt(t.shape,r);return l.length>0&&(i=oe(i,l)),D(i,t.shape)},b:()=>{let i=n;const l=vt(s.shape,r);return l.length>0&&(i=oe(i,l)),D(i,s.shape)}}}};/**
3499 * @license
3500 * Copyright 2020 Google LLC. All Rights Reserved.
3501 * Licensed under the Apache License, Version 2.0 (the "License");
3502 * you may not use this file except in compliance with the License.
3503 * You may obtain a copy of the License at
3504 *
3505 * http://www.apache.org/licenses/LICENSE-2.0
3506 *
3507 * Unless required by applicable law or agreed to in writing, software
3508 * distributed under the License is distributed on an "AS IS" BASIS,
3509 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3510 * See the License for the specific language governing permissions and
3511 * limitations under the License.
3512 * =============================================================================
3513 */const J2={kernelName:Do,saveAllInputs:!0,gradFunc:(n,e)=>{const t={};return e.forEach((s,r)=>{t[r]=()=>n.clone()}),t}};/**
3514 * @license
3515 * Copyright 2020 Google Inc. All Rights Reserved.
3516 * Licensed under the Apache License, Version 2.0 (the "License");
3517 * you may not use this file except in compliance with the License.
3518 * You may obtain a copy of the License at
3519 *
3520 * http://www.apache.org/licenses/LICENSE-2.0
3521 *
3522 * Unless required by applicable law or agreed to in writing, software
3523 * distributed under the License is distributed on an "AS IS" BASIS,
3524 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3525 * See the License for the specific language governing permissions and
3526 * limitations under the License.
3527 * =============================================================================
3528 */const Z2={kernelName:Ao,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Be(t)}}};/**
3529 * @license
3530 * Copyright 2020 Google Inc. All Rights Reserved.
3531 * Licensed under the Apache License, Version 2.0 (the "License");
3532 * you may not use this file except in compliance with the License.
3533 * You may obtain a copy of the License at
3534 *
3535 * http://www.apache.org/licenses/LICENSE-2.0
3536 *
3537 * Unless required by applicable law or agreed to in writing, software
3538 * distributed under the License is distributed on an "AS IS" BASIS,
3539 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3540 * See the License for the specific language governing permissions and
3541 * limitations under the License.
3542 * =============================================================================
3543 */const Q2={kernelName:Oo,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Be(t)}}};/**
3544 * @license
3545 * Copyright 2020 Google LLC. All Rights Reserved.
3546 * Licensed under the Apache License, Version 2.0 (the "License");
3547 * you may not use this file except in compliance with the License.
3548 * You may obtain a copy of the License at
3549 *
3550 * http://www.apache.org/licenses/LICENSE-2.0
3551 *
3552 * Unless required by applicable law or agreed to in writing, software
3553 * distributed under the License is distributed on an "AS IS" BASIS,
3554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3555 * See the License for the specific language governing permissions and
3556 * limitations under the License.
3557 * =============================================================================
3558 */const eE={kernelName:qr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,ln(ie(pe(1),Ye(ee(t,"float32")))))}}};/**
3559 * @license
3560 * Copyright 2020 Google LLC. All Rights Reserved.
3561 * Licensed under the Apache License, Version 2.0 (the "License");
3562 * you may not use this file except in compliance with the License.
3563 * You may obtain a copy of the License at
3564 *
3565 * http://www.apache.org/licenses/LICENSE-2.0
3566 *
3567 * Unless required by applicable law or agreed to in writing, softw
3567are
3568 * distributed under the License is distributed on an "AS IS" BASIS,
3569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3570 * See the License for the specific language governing permissions and
3571 * limitations under the License.
3572 * =============================================================================
3573 */const tE={kernelName:Kr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=ln(te(pe(1),Ye(ee(t,"float32"))));return he(n,s)}}}};/**
3574 * @license
3575 * Copyright 2020 Google LLC. All Rights Reserved.
3576 * Licensed under the Apache License, Version 2.0 (the "License");
3577 * you may not use this file except in compliance with the License.
3578 * You may obtain a copy of the License at
3579 *
3580 * http://www.apache.org/licenses/LICENSE-2.0
3581 *
3582 * Unless required by applicable law or agreed to in writing, software
3583 * distributed under the License is distributed on an "AS IS" BASIS,
3584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3585 * See the License for the specific language governing permissions and
3586 * limitations under the License.
3587 * =============================================================================
3588 */const nE={kernelName:Yr,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=xe(t.shape,s.shape);return{a:()=>{const i=te(Ye(t),Ye(s));let l=O(n,he(s,i));const u=vt(t.shape,r);return u.length>0&&(l=oe(l,u)),D(l,t.shape)},b:()=>{const i=te(Ye(t),Ye(s));let l=Ve(O(n,he(t,i)));const u=vt(s.shape,r);return u.length>0&&(l=oe(l,u)),D(l,s.shape)}}}};/**
3589 * @license
3590 * Copyright 2020 Google LLC. All Rights Reserved.
3591 * Licensed under the Apache License, Version 2.0 (the "License");
3592 * you may not use this file except in compliance with the License.
3593 * You may obtain a copy of the License at
3594 *
3595 * http://www.apache.org/licenses/LICENSE-2.0
3596 *
3597 * Unless required by applicable law or agreed to in writing, software
3598 * distributed under the License is distributed on an "AS IS" BASIS,
3599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3600 * See the License for the specific language governing permissions and
3601 * limitations under the License.
3602 * =============================================================================
3603 */const sE={kernelName:Xr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,te(Ye(ee(t,"float32")),1))}}};/**
3604 * @license
3605 * Copyright 2020 Google LLC. All Rights Reserved.
3606 * Licensed under the Apache License, Version 2.0 (the "License");
3607 * you may not use this file except in compliance with the License.
3608 * You may obtain a copy of the License at
3609 *
3610 * http://www.apache.org/licenses/LICENSE-2.0
3611 *
3612 * Unless required by applicable law or agreed to in writing, software
3613 * distributed under the License is distributed on an "AS IS" BASIS,
3614 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3615 * See the License for the specific language governing permissions and
3616 * limitations under the License.
3617 * =============================================================================
3618 */const rE={kernelName:Jr,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,ie(pe(1),Ye(ee(t,"float32"))))}}};/**
3619 * @license
3620 * Copyright 2020 Google LLC. All Rights Reserved.
3621 * Licensed under the Apache License, Version 2.0 (the "License");
3622 * you may not use this file except in compliance with the License.
3623 * You may obtain a copy of the License at
3624 *
3625 * http://www.apache.org/licenses/LICENSE-2.0
3626 *
3627 * Unless required by applicable law or agreed to in writing, software
3628 * distributed under the License is distributed on an "AS IS" BASIS,
3629 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3630 * See the License for the specific language governing permissions and
3631 * limitations under the License.
3632 * =============================================================================
3633 */function aE(n,e,t,s,r,a){const o=N(n,"dy","avgPool3dGrad"),i=N(e,"input","avgPool3dGrad");let l=o,u=i,c=!1;i.rank===4&&(c=!0,l=D(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),u=D(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),I(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),I(u.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${u.rank}.`),Ht("avgPool3dGrad",r,a);const h={dy:l,input:u},d={filterSize:t,strides:s,pad:r,dimRoundingMode:a},p=F.runKernel(fc,h,d);return c?D(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const oE=R({avgPool3dGrad_:aE});/**
3634 * @license
3635 * Copyright 2020 Google LLC. All Rights Reserved.
3636 * Licensed under the Apache License, Version 2.0 (the "License");
3637 * you may not use this file except in compliance with the License.
3638 * You may obtain a copy of the License at
3639 *
3640 * http://www.apache.org/licenses/LICENSE-2.0
3641 *
3642 * Unless required by applicable law or agreed to in writing, software
3643 * distributed under the License is distributed on an "AS IS" BASIS,
3644 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3645 * See the License for the specific language governing permissions and
3646 * limitations under the License.
3647 * =============================================================================
3648 */const iE={kernelName:Fo,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:i}=t;return{x:()=>oE(n,s,r,a,o,i)}}};/**
3649 * @license
3650 * Copyright 2020 Google LLC. All Rights Reserved.
3651 * Licensed under the Apache License, Version 2.0 (the "License");
3652 * you may not use this file except in compliance with the License.
3653 * You may obtain a copy of the License at
3654 *
3655 * http://www.apache.org/licenses/LICENSE-2.0
3656 *
3657 * Unless required by applicable law or agreed to in writing, software
3658 * distributed under the License is distributed on an "AS IS" BASIS,
3659 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3660 * See the License for the specific language governing permissions and
3661 * limitations under the License.
3662 * =============================================================================
3663 */function lE(n,e,t,s,r){const a=N(n,"dy","avgPoolGrad"),o=N(e,"input","avgPoolGrad");I(o.rank===a.rank,()=>`Rank of input (${o.rank}) does not match rank of dy (${a.rank})`);let i=o,l=a,u=!1;o.rank===3&&(u=!0,i=D(o,[1,o.shape[0],o.shape[1],o.shape[2]]),l=D(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),I(i.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${i.rank}.`);const c={dy:l,input:i},h={filterSize:t,strides:s,pad:r},d=F.runKernel(mc,c,h);return u?D(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const uE=R({avgPoolGrad_:lE});/**
3664 * @license
3665 * Copyright 2020 Google LLC. All Rights Reserved.
3666 * Licensed under the Apache License, Version 2.0 (the "License");
3667 * you may not use this file except in compliance with the License.
3668 * You may obtain a copy of the License at
3669 *
3670 * http://www.apache.org/licenses/LICENSE-2.0
3671 *
3672 * Unless required by applicable law or agreed to in writing, software
3673 * distributed under the License is distributed on an "AS IS" BASIS,
3674 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3675 * See the License for the specific language governing permissions and
3676 * limitations under the License.
3677 * =============================================================================
3678 */const cE={kernelName:_o,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{filterSize:r,strides:a,pad:o}=t;return{x:()=>uE(n,s,r,a,o)}}};/**
3679 * @license
3680 * Copyright 2020 Google LLC. All Rights Reserved.
3681 * Licensed under the Apache License, Version 2.0 (the "License");
3682 * you may not use this file except in compliance with the License.
3683 * You may obtain a copy of the License at
3684 *
3685 * http://www.apache.org/licenses/LICENSE-2.0
3686 *
3687 * Unless required by applicable law or agreed to in writing, software
3688 * distributed under the License is distributed on an "AS IS" BASIS,
3689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3690 * See the License for the specific language governing permissions and
3691 * limitations under the License.
3692 * =============================================================================
3693 */const hE={kernelName:Po,inputsToSave:["a","b"],gradFunc:(n,e,t)=>{const[s,r]=e,{transposeA:a,transposeB:o}=t;return!a&&!o?{a:()=>ve(n,r,!1,!0),b:()=>ve(s,n,!0,!1)}:!a&&o?{a:()=>ve(n,r,!1,!1),b:()=>ve(n,s,!0,!1)}:a&&!o?{a:()=>ve(r,n,!1,!0),b:()=>ve(s,n,!1,!1)}:{a:()=>ve(r,n,!0,!0),b:()=>ve(n,s,!0,!0)}}};/**
3694 * @license
3695 * Copyright 2020 Google LLC. All Rights Reserved.
3696 * Licensed under the Apache License, Version 2.0 (the "License");
3697 * you may not use this file except in compliance with the License.
3698 * You may obtain a copy of the License at
3699 *
3700 * http://www.apache.org/licenses/LICENSE-2.0
3701 *
3702 * Unless required by applicable law or agreed to in writing, softw
3702are
3703 * distributed under the License is distributed on an "AS IS" BASIS,
3704 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3705 * See the License for the specific language governing permissions and
3706 * limitations under the License.
3707 * =============================================================================
3708 */const dE={kernelName:zo,gradFunc:(n,e,t)=>{const{blockShape:s,crops:r}=t;return{x:()=>el(n,s,r)}}};/**
3709 * @license
3710 * Copyright 2020 Google LLC. All Rights Reserved.
3711 * Licensed under the Apache License, Version 2.0 (the "License");
3712 * you may not use this file except in compliance with the License.
3713 * You may obtain a copy of the License at
3714 *
3715 * http://www.apache.org/licenses/LICENSE-2.0
3716 *
3717 * Unless required by applicable law or agreed to in writing, software
3718 * distributed under the License is distributed on an "AS IS" BASIS,
3719 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3720 * See the License for the specific language governing permissions and
3721 * limitations under the License.
3722 * =============================================================================
3723 */const pE={kernelName:lx,gradFunc:(n,e,t)=>{const s=t,r=s.inputShape,a=s.shape,o=Array.from(a);for(let l=r.length-1;l>=0;l--)if(r[l]===a[l])o[l]=1;else if(r[l]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${a}].`);const i=[];for(let l=0;l<o.length;l++)o[l]>1&&i.push(l);return{x:()=>oe(n,i,!0)}}};/**
3724 * @license
3725 * Copyright 2020 Google LLC. All Rights Reserved.
3726 * Licensed under the Apache License, Version 2.0 (the "License");
3727 * you may not use this file except in compliance with the License.
3728 * You may obtain a copy of the License at
3729 *
3730 * http://www.apache.org/licenses/LICENSE-2.0
3731 *
3732 * Unless required by applicable law or agreed to in writing, software
3733 * distributed under the License is distributed on an "AS IS" BASIS,
3734 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3735 * See the License for the specific language governing permissions and
3736 * limitations under the License.
3737 * =============================================================================
3738 */const fE={kernelName:gc,gradFunc:n=>({x:()=>n.clone()})};/**
3739 * @license
3740 * Copyright 2020 Google LLC. All Rights Reserved.
3741 * Licensed under the Apache License, Version 2.0 (the "License");
3742 * you may not use this file except in compliance with the License.
3743 * You may obtain a copy of the License at
3744 *
3745 * http://www.apache.org/licenses/LICENSE-2.0
3746 *
3747 * Unless required by applicable law or agreed to in writing, software
3748 * distributed under the License is distributed on an "AS IS" BASIS,
3749 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3750 * See the License for the specific language governing permissions and
3751 * limitations under the License.
3752 * =============================================================================
3753 */const mE={kernelName:ea,gradFunc:n=>({x:()=>Be(n)})};/**
3754 * @license
3755 * Copyright 2020 Google LLC. All Rights Reserved.
3756 * Licensed under the Apache License, Version 2.0 (the "License");
3757 * you may not use this file except in compliance with the License.
3758 * You may obtain a copy of the License at
3759 *
3760 * http://www.apache.org/licenses/LICENSE-2.0
3761 *
3762 * Unless required by applicable law or agreed to in writing, software
3763 * distributed under the License is distributed on an "AS IS" BASIS,
3764 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3765 * See the License for the specific language governing permissions and
3766 * limitations under the License.
3767 * =============================================================================
3768 */const gE={kernelName:na,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{clipValueMin:r,clipValueMax:a}=t;return{x:()=>dt(wn(os(s,r),Ls(s,a)),n,Be(n))}}};/**
3769 * @license
3770 * Copyright 2020 Google LLC. All Rights Reserved.
3771 * Licensed under the Apache License, Version 2.0 (the "License");
3772 * you may not use this file except in compliance with the License.
3773 * You may obtain a copy of the License at
3774 *
3775 * http://www.apache.org/licenses/LICENSE-2.0
3776 *
3777 * Unless required by applicable law or agreed to in writing, softw
3777are
3778 * distributed under the License is distributed on an "AS IS" BASIS,
3779 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3780 * See the License for the specific language governing permissions and
3781 * limitations under the License.
3782 * =============================================================================
3783 */const yE={kernelName:yc,inputsToSave:["x"],gradFunc:cw.gradFunc};/**
3784 * @license
3785 * Copyright 2020 Google LLC. All Rights Reserved.
3786 * Licensed under the Apache License, Version 2.0 (the "License");
3787 * you may not use this file except in compliance with the License.
3788 * You may obtain a copy of the License at
3789 *
3790 * http://www.apache.org/licenses/LICENSE-2.0
3791 *
3792 * Unless required by applicable law or agreed to in writing, software
3793 * distributed under the License is distributed on an "AS IS" BASIS,
3794 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3795 * See the License for the specific language governing permissions and
3796 * limitations under the License.
3797 * =============================================================================
3798 */const xE={kernelName:Lo,saveAllInputs:!0,gradFunc:(n,e,t)=>{const s=e.map(l=>l.shape),{axis:r}=t,a=Ie(r,e[0].shape)[0],o=s.map(l=>l[a]);return Bt(n,o,a).map(l=>()=>l)}};/**
3799 * @license
3800 * Copyright 2020 Google LLC. All Rights Reserved.
3801 * Licensed under the Apache License, Version 2.0 (the "License");
3802 * you may not use this file except in compliance with the License.
3803 * You may obtain a copy of the License at
3804 *
3805 * http://www.apache.org/licenses/LICENSE-2.0
3806 *
3807 * Unless required by applicable law or agreed to in writing, software
3808 * distributed under the License is distributed on an "AS IS" BASIS,
3809 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3810 * See the License for the specific language governing permissions and
3811 * limitations under the License.
3812 * =============================================================================
3813 */const bE={kernelName:Mo,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[s,r]=e,{dilations:a,strides:o,pad:i,dataFormat:l}=t;return I($i(a),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`),{x:()=>vp(s.shape,n,r,o,i,l),filter:()=>lf(s,n,r.shape,o,i,l)}}};/**
3814 * @license
3815 * Copyright 2020 Google LLC. All Rights Reserved.
3816 * Licensed under the Apache License, Version 2.0 (the "License");
3817 * you may not use this file except in compliance with the License.
3818 * You may obtain a copy of the License at
3819 *
3820 * http://www.apache.org/licenses/LICENSE-2.0
3821 *
3822 * Unless required by applicable law or agreed to in writing, software
3823 * distributed under the License is distributed on an "AS IS" BASIS,
3824 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3825 * See the License for the specific language governing permissions and
3826 * limitations under the License.
3827 * =============================================================================
3828 */const wE={kernelName:Wo,inputsToSave:["dy","filter"],gradFunc:(n,e,t)=>{const[s,r]=e,{strides:a,pad:o,dataFormat:i,dimRoundingMode:l}=t;return{dy:()=>rs(n,r,a,o,i,1,l),filter:()=>lf(n,s,r.shape,a,o,i,l)}}};/**
3829 * @license
3830 * Copyright 2020 Google LLC. All Rights Reserved.
3831 * Licensed under the Apache License, Version 2.0 (the "License");
3832 * you may not use this file except in compliance with the License.
3833 * You may obtain a copy of the License at
3834 *
3835 * http://www.apache.org/licenses/LICENSE-2.0
3836 *
3837 * Unless required by applicable law or agreed to in writing, software
3838 * distributed under the License is distributed on an "AS IS" BASIS,
3839 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3840 * See the License for the specific language governing permissions and
3841 * limitations under the License.
3842 * =============================================================================
3843 */function vE(n,e,t,s,r){let a=n;n.rank===4&&(a=D(n,[1,n.shape[0],n.shape[1],n.shape[2],n.shape[3]]));let o=e;o.rank===4&&(o=D(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),I(a.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${a.shape}.`),I(o.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${o.shape}.`),I(t.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${t}.`),I(a.shape[4]===t[3],()=>`Error in conv3dDerFilter: depth of input ${a.shape[4]}) must match input depth in filter (${t[3]}.`),I(o.shape[4]===t[4],()=>`Error in conv3dDerFilter: depth of dy (${o.shape[4]}) must match output depth for filter (${t[4]}).`);const i={x:a,dy:o},l={strides:s,pad:r,filterShape:t};return F.runKernel(xc,i,l)}const CE=R({conv3DBackpropFilter_:vE});/**
3844 * @license
3845 * Copyright 2020 Google LLC. All Rights Reserved.
3846 * Licensed under the Apache License, Version 2.0 (the "License");
3847 * you may not use this file except in compliance with the License.
3848 * You may obtain a copy of the License at
3849 *
3850 * http://www.apache.org/licenses/LICENSE-2.0
3851 *
3852 * Unless required by applicable law or agreed to in writing, software
3853 * distributed under the License is distributed on an "AS IS" BASIS,
3854 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3855 * See the License for the specific language governing permissions and
3856 * limitations under the License.
3857 * =============================================================================
3858 */const $E={kernelName:Uo,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:s,strides:r,pad:a}=t;I($i(s),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);const[o,i]=e;return{x:()=>Qx(o.shape,n,i,r,a),filter:()=>CE(o,n,i.shape,r,a)}}};/**
3859 * @license
3860 * Copyright 2020 Google LLC. All Rights Reserved.
3861 * Licensed under the Apache License, Version 2.0 (the "License");
3862 * you may not use this file except in compliance with the License.
3863 * You may obtain a copy of the License at
3864 *
3865 * http://www.apache.org/licenses/LICENSE-2.0
3866 *
3867 * Unless required by applicable law or agreed to in writing, software
3868 * distributed under the License is distributed on an "AS IS" BASIS,
3869 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3870 * See the License for the specific language governing permissions and
3871 * limitations under the License.
3872 * =============================================================================
3873 */const NE={kernelName:sa,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(Ve(th(ee(t,"float32"))),n)}}};/**
3874 * @license
3875 * Copyright 2020 Google LLC. All Rights Reserved.
3876 * Licensed under the Apache License, Version 2.0 (the "License");
3877 * you may not use this file except in compliance with the License.
3878 * You may obtain a copy of the License at
3879 *
3880 * http://www.apache.org/licenses/LICENSE-2.0
3881 *
3882 * Unless required by applicable law or agreed to in writing, software
3883 * distributed under the License is distributed on an "AS IS" BASIS,
3884 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3885 * See the License for the specific language governing permissions and
3886 * limitations under the License.
3887 * =============================================================================
3888 */const IE={kernelName:ra,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(nh(ee(t,"float32")),n)}}};/**
3889 * @license
3890 * Copyright 2020 Google LLC. All Rights Reserved.
3891 * Licensed under the Apache License, Version 2.0 (the "License");
3892 * you may not use this file except in compliance with the License.
3893 * You may obtain a copy of the License at
3894 *
3895 * http://www.apache.org/licenses/LICENSE-2.0
3896 *
3897 * Unless required by applicable law or agreed to in writing, software
3898 * distributed under the License is distributed on an "AS IS" BASIS,
3899 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3900 * See the License for the specific language governing permissions and
3901 * limitations under the License.
3902 * =============================================================================
3903 */const SE={kernelName:Go,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:r,exclusive:a,reverse:o}=t;return{x:()=>{const i=Xe([r],s.rank);let l=Gc(n,r,a,!o);return i!=null&&(l=Ne(l,i)),l}}}};/**
3904 * @license
3905 * Copyright 2020 Google LLC. All Rights Reserved.
3906 * Licensed under the Apache License, Version 2.0 (the "License");
3907 * you may not use this file except in compliance with the License.
3908 * You may obtain a copy of the License at
3909 *
3910 * http://www.apache.org/licenses/LICENSE-2.0
3911 *
3912 * Unless required by applicable law or agreed to in writing, software
3913 * distributed under the License is distributed on an "AS IS" BASIS,
3914 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3915 * See the License for the specific language governing permissions and
3916 * limitations under the License.
3917 * =============================================================================
3918 */const kE={kernelName:Ho,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:s,strides:r,pad:a,dimRoundingMode:o}=t,i=s??[1,1];I($i(i),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`);const[l,u]=e;return I(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),I(u.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${u.rank}.`),I(l.shape[3]===u.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${u.shape[2]}.`),I(It(r,i),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be  1. Got strides ${r} and dilations '${i}'.`),Ht("depthwiseConv2d",a,o),{x:()=>Wb(l.shape,n,u,r,a,i,o),filter:()=>Mb(l,n,u.shape,r,a,i,o)}}};/**
3919 * @license
3920 * Copyright 2020 Google LLC. All Rights Reserved.
3921 * Licensed under the Apache License, Version 2.0 (the "License");
3922 * you may not use this file except in compliance with the License.
3923 * You may obtain a copy of the License at
3924 *
3925 * http://www.apache.org/licenses/LICENSE-2.0
3926 *
3927 * Unless required by applicable law or agreed to in writing, software
3928 * distributed under the License is distributed on an "AS IS" BASIS,
3929 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3930 * See the License for the specific language governing permissions and
3931 * limitations under the License.
3932 * =============================================================================
3933 */const TE={kernelName:jo,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[s,r]=e,a={x:s,filter:r,dy:n},o={x:s,filter:r,dy:n};return{x:()=>F.runKernel(Xl,a,t),filter:()=>F.runKernel(Kl,o,t)}}};/**
3934 * @license
3935 * Copyright 2020 Google LLC. All Rights Reserved.
3936 * Licensed under the Apache License, Version 2.0 (the "License");
3937 * you may not use this file except in compliance with the License.
3938 * You may obtain a copy of the License at
3939 *
3940 * http://www.apache.org/licenses/LICENSE-2.0
3941 *
3942 * Unless required by applicable law or agreed to in writing, software
3943 * distributed under the License is distributed on an "AS IS" BASIS,
3944 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3945 * See the License for the specific language governing permissions and
3946 * limitations under the License.
3947 * =============================================================================
3948 */const EE={kernelName:Ti,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e,s={dy:n,y:t};return{x:()=>F.runKernel(bc,s)}}};/**
3949 * @license
3950 * Copyright 2020 Google LLC. All Rights Reserved.
3951 * Licensed under the Apache License, Version 2.0 (the "License");
3952 * you may not use this file except in compliance with the License.
3953 * You may obtain a copy of the License at
3954 *
3955 * http://www.apache.org/licenses/LICENSE-2.0
3956 *
3957 * Unless required by applicable law or agreed to in writing, software
3958 * distributed under the License is distributed on an "AS IS" BASIS,
3959 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3960 * See the License for the specific language governing permissions and
3961 * limitations under the License.
3962 * =============================================================================
3963 */const RE={kernelName:aa,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,s=O(Wt(Ve(Ye(t))),2/Math.sqrt(Math.PI));return{x:()=>O(n,s)}}};/**
3964 * @license
3965 * Copyright 2020 Google LLC. All Rights Reserved.
3966 * Licensed under the Apache License, Version 2.0 (the "License");
3967 * you may not use this file except in compliance with the License.
3968 * You may obtain a copy of the License at
3969 *
3970 * http://www.apache.org/licenses/LICENSE-2.0
3971 *
3972 * Unless required by applicable law or agreed to in writing, software
3973 * distributed under the License is distributed on an "AS IS" BASIS,
3974 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3975 * See the License for the specific language governing permissions and
3976 * limitations under the License.
3977 * =============================================================================
3978 */const DE={kernelName:oa,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(n,t)}}};/**
3979 * @license
3980 * Copyright 2020 Google LLC. All Rights Reserved.
3981 * Licensed under the Apache License, Version 2.0 (the "License");
3982 * you may not use this file except in compliance with the License.
3983 * You may obtain a copy of the License at
3984 *
3985 * http://www.apache.org/licenses/LICENSE-2.0
3986 *
3987 * Unless required by applicable law or agreed to in writing, software
3988 * distributed under the License is distributed on an "AS IS" BASIS,
3989 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3990 * See the License for the specific language governing permissions and
3991 * limitations under the License.
3992 * =============================================================================
3993 */const AE={kernelName:Jo,inputsToSave:["input"],gradFunc:(n,e)=>{const[t]=e;return{input:()=>D(n,t.shape)}}};/**
3994 * @license
3995 * Copyright 2020 Google LLC. All Rights Reserved.
3996 * Licensed under the Apache License, Version 2.0 (the "License");
3997 * you may not use this file except in compliance with the License.
3998 * You may obtain a copy of the License at
3999 *
4000 * http://www.apache.org/licenses/LICENSE-2.0
4001 *
4002 * Unless required by applicable law or agreed to in writing, software
4003 * distributed under the License is distributed on an "AS IS" BASIS,
4004 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4005 * See the License for the specific language governing permissions and
4006 * limitations under the License.
4007 * =============================================================================
4008 */const OE={kernelName:ia,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(n,Wt(t))}}};/**
4009 * @license
4010 * Copyright 2020 Google LLC. All Rights Reserved.
4011 * Licensed under the Apache License, Version 2.0 (the "License");
4012 * you may not use this file except in compliance with the License.
4013 * You may obtain a copy of the License at
4014 *
4015 * http://www.apache.org/licenses/LICENSE-2.0
4016 *
4017 * Unless required by applicable law or agreed to in writing, software
4018 * distributed under the License is distributed on an "AS IS" BASIS,
4019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4020 * See the License for the specific language governing permissions and
4021 * limitations under the License.
4022 * =============================================================================
4023 */const _E={kernelName:la,gradFunc:n=>({x:()=>Be(n)})};/**
4024 * @license
4025 * Copyright 2020 Google LLC. All Rights Reserved.
4026 * Licensed under the Apache License, Version 2.0 (the "License");
4027 * you may not use this file except in compliance with the License.
4028 * You may obtain a copy of the License at
4029 *
4030 * http://www.apache.org/licenses/LICENSE-2.0
4031 *
4032 * Unless required by applicable law or agreed to in writing, software
4033 * distributed under the License is distributed on an "AS IS" BASIS,
4034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4035 * See the License for the specific language governing permissions and
4036 * limitations under the License.
4037 * =============================================================================
4038 */const FE={kernelName:Ei,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=xe(t.shape,s.shape);return{a:()=>{const i=he(n,ee(s,"float32")),l=vt(t.shape,r);return l.length>0?D(oe(i,l),t.shape):i},b:()=>{let i=O(n,ee(t,"float32"));const l=vt(s.shape,r);l.length>0&&(i=D(oe(i,l),s.shape));const u=Ye(s);return Ve(he(i,ee(u,"float32")))}}}};/**
4039 * @license
4040 * Copyright 2020 Google LLC. All Rights Reserved.
4041 * Licensed under the Apache License, Version 2.0 (the "License");
4042 * you may not use this file except in compliance with the License.
4043 * You may obtain a copy of the License at
4044 *
4045 * http://www.apache.org/licenses/LICENSE-2.0
4046 *
4047 * Unless required by applicable law or agreed to in writing, software
4048 * distributed under the License is distributed on an "AS IS" BASIS,
4049 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4050 * See the License for the specific language governing permissions and
4051 * limitations under the License.
4052 * =============================================================================
4053 */const LE={kernelName:Vo,inputsToSave:["x","mean","variance","scale"],gradFunc:(n,e,t)=>{const{varianceEpsilon:s}=t,[r,a,o,i]=e,l=i??pe(1),u=vt(a.shape,r.shape),c=[];if(a.rank===1){for(let b=0;b<r.shape.length-1;++b)c.push(r.shape[b]);c.push(1)}const h=ie(r,a),d=O(n,l),p=Zc(te(o,pe(s))),f=O(O(O(p,p),p),pe(-.5));return{x:()=>a.rank===1?D(O(O(n,sn(D(p,[1,1,1,a.shape[0]]),c)),l),r.shape):D(O(O(n,p),l),r.shape),mean:()=>{let b=O(O(p,pe(-1)),d);return a.rank===1&&(b=oe(b,u)),D(b,a.shape)},variance:()=>{let b=O(O(f,h),d);return a.rank===1&&(b=oe(b,u)),D(b,a.shape)},scale:()=>{const b=O(h,p);let C=O(n,b);return a.rank===1&&(C=oe(C,u)),D(C,a.shape)},offset:()=>{let b=n;return a.rank===1&&(b=oe(b,u)),D(b,a.shape)}}}};/**
4054 * @license
4055 * Copyright 2020 Google LLC. All Rights Reserved.
4056 * Licensed under the Apache License, Version 2.0 (the "License");
4057 * you may not use this file except in compliance with the License.
4058 * You may obtain a copy of the License at
4059 *
4060 * http://www.apache.org/licenses/LICENSE-2.0
4061 *
4062 * Unless required by applicable law or agreed to in writing, softw
4062are
4063 * distributed under the License is distributed on an "AS IS" BASIS,
4064 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4065 * See the License for the specific language governing permissions and
4066 * limitations under the License.
4067 * =============================================================================
4068 */const PE={kernelName:Zo,inputsToSave:["x","indices"],gradFunc:(n,e,t)=>{const[s,r]=e,{axis:a,batchDims:o}=t,i=Ie(a,s.shape)[0],l=(u,c,h)=>()=>{const d=u.shape,p=c.size,f=d.slice(0,i),g=f.length,m=d.slice(a,d.length).slice(1),y=m.length,x=Rg(0,g),v=Rg(g+1,g+1+y),b=Dg([f,[p],m]),C=D(h,b),$=D(c,[p]),S=Dg([[g],x,v]),k=Ne(C,S);let T=ih(k,$,u.shape[i]);const E=pr(S);return T=Ne(T,E),T};if(o===1){const u=s.shape[0],c=s.split(u,0);return{x:()=>Ot(c.map((p,f)=>l(p,r.slice(f,1),n.slice(f,1))())).reshape(s.shape),indices:()=>r}}else return{x:l(s,r,n),indices:()=>r}}};function Rg(n,e){const t=[];for(let s=n;s<e;++s)t.push(s);return t}function Dg(n){const e=[];for(let t=0;t<n.length;++t)for(let s=0;s<n[t].length;++s)e.push(n[t][s]);return e}/**
4069 * @license
4070 * Copyright 2020 Google LLC. All Rights Reserved.
4071 * Licensed under the Apache License, Version 2.0 (the "License");
4072 * you may not use this file except in compliance with the License.
4073 * You may obtain a copy of the License at
4074 *
4075 * http://www.apache.org/licenses/LICENSE-2.0
4076 *
4077 * Unless required by applicable law or agreed to in writing, software
4078 * distributed under the License is distributed on an "AS IS" BASIS,
4079 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4080 * See the License for the specific language governing permissions and
4081 * limitations under the License.
4082 * =============================================================================
4083 */const zE={kernelName:ua,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>Be(t),b:()=>Be(s)}}};/**
4084 * @license
4085 * Copyright 2020 Google LLC. All Rights Reserved.
4086 * Licensed under the Apache License, Version 2.0 (the "License");
4087 * you may not use this file except in compliance with the License.
4088 * You may obtain a copy of the License at
4089 *
4090 * http://www.apache.org/licenses/LICENSE-2.0
4091 *
4092 * Unless required by applicable law or agreed to in writing, software
4093 * distributed under the License is distributed on an "AS IS" BASIS,
4094 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4095 * See the License for the specific language governing permissions and
4096 * limitations under the License.
4097 * =============================================================================
4098 */const VE={kernelName:wc,gradFunc:n=>({x:()=>ee(n,"float32")})};/**
4099 * @license
4100 * Copyright 2020 Google LLC. All Rights Reserved.
4101 * Licensed under the Apache License, Version 2.0 (the "License");
4102 * you may not use this file except in compliance with the License.
4103 * You may obtain a copy of the License at
4104 *
4105 * http://www.apache.org/licenses/LICENSE-2.0
4106 *
4107 * Unless required by applicable law or agreed to in writing, software
4108 * distributed under the License is distributed on an "AS IS" BASIS,
4109 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4110 * See the License for the specific language governing permissions and
4111 * limitations under the License.
4112 * =============================================================================
4113 */const BE={kernelName:ca,gradFunc:n=>({x:()=>Be(n)})};/**
4114 * @license
4115 * Copyright 2020 Google LLC. All Rights Reserved.
4116 * Licensed under the Apache License, Version 2.0 (the "License");
4117 * you may not use this file except in compliance with the License.
4118 * You may obtain a copy of the License at
4119 *
4120 * http://www.apache.org/licenses/LICENSE-2.0
4121 *
4122 * Unless required by applicable law or agreed to in writing, software
4123 * distributed under the License is distributed on an "AS IS" BASIS,
4124 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4125 * See the License for the specific language governing permissions and
4126 * limitations under the License.
4127 * =============================================================================
4128 */const ME={kernelName:ha,gradFunc:n=>({x:()=>Be(n)})};/**
4129 * @license
4130 * Copyright 2020 Google LLC. All Rights Reserved.
4131 * Licensed under the Apache License, Version 2.0 (the "License");
4132 * you may not use this file except in compliance with the License.
4133 * You may obtain a copy of the License at
4134 *
4135 * http://www.apache.org/licenses/LICENSE-2.0
4136 *
4137 * Unless required by applicable law or agreed to in writing, software
4138 * distributed under the License is distributed on an "AS IS" BASIS,
4139 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4140 * See the License for the specific language governing permissions and
4141 * limitations under the License.
4142 * =============================================================================
4143 */const WE={kernelName:da,gradFunc:n=>({x:()=>Be(n)})};/**
4144 * @license
4145 * Copyright 2020 Google LLC. All Rights Reserved.
4146 * Licensed under the Apache License, Version 2.0 (the "License");
4147 * you may not use this file except in compliance with the License.
4148 * You may obtain a copy of the License at
4149 *
4150 * http://www.apache.org/licenses/LICENSE-2.0
4151 *
4152 * Unless required by applicable law or agreed to in writing, software
4153 * distributed under the License is distributed on an "AS IS" BASIS,
4154 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4155 * See the License for the specific language governing permissions and
4156 * limitations under the License.
4157 * =============================================================================
4158 */const UE={kernelName:vc,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{alpha:r}=t,a=Lt(s,0);return{x:()=>dt(a,n,O(n,r))}}};/**
4159 * @license
4160 * Copyright 2020 Google LLC. All Rights Reserved.
4161 * Licensed under the Apache License, Version 2.0 (the "License");
4162 * you may not use this file except in compliance with the License.
4163 * You may obtain a copy of the License at
4164 *
4165 * http://www.apache.org/licenses/LICENSE-2.0
4166 *
4167 * Unless required by applicable law or agreed to in writing, software
4168 * distributed under the License is distributed on an "AS IS" BASIS,
4169 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4170 * See the License for the specific language governing permissions and
4171 * limitations under the License.
4172 * =============================================================================
4173 */const GE={kernelName:fa,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,te(t,1))}}};/**
4174 * @license
4175 * Copyright 2020 Google LLC. All Rights Reserved.
4176 * Licensed under the Apache License, Version 2.0 (the "License");
4177 * you may not use this file except in compliance with the License.
4178 * You may obtain a copy of the License at
4179 *
4180 * http://www.apache.org/licenses/LICENSE-2.0
4181 *
4182 * Unless required by applicable law or agreed to in writing, software
4183 * distributed under the License is distributed on an "AS IS" BASIS,
4184 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4185 * See the License for the specific language governing permissions and
4186 * limitations under the License.
4187 * =============================================================================
4188 */const HE={kernelName:pa,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,ee(t,"float32"))}}};/**
4189 * @license
4190 * Copyright 2020 Google LLC. All Rights Reserved.
4191 * Licensed under the Apache License, Version 2.0 (the "License");
4192 * you may not use this file except in compliance with the License.
4193 * You may obtain a copy of the License at
4194 *
4195 * http://www.apache.org/licenses/LICENSE-2.0
4196 *
4197 * Unless required by applicable law or agreed to in writing, software
4198 * distributed under the License is distributed on an "AS IS" BASIS,
4199 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4200 * See the License for the specific language governing permissions and
4201 * limitations under the License.
4202 * =============================================================================
4203 */const jE={kernelName:ux,inputsToSave:[],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s]=e,{axis:r}=t;return{logits:()=>{const o=Wt(s);return ie(n,O(oe(n,r,!0),o))}}}};/**
4204 * @license
4205 * Copyright 2020 Google LLC. All Rights Reserved.
4206 * Licensed under the Apache License, Version 2.0 (the "License");
4207 * you may not use this file except in compliance with the License.
4208 * You may obtain a copy of the License at
4209 *
4210 * http://www.apache.org/licenses/LICENSE-2.0
4211 *
4212 * Unless required by applicable law or agreed to in writing, softw
4212are
4213 * distributed under the License is distributed on an "AS IS" BASIS,
4214 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4215 * See the License for the specific language governing permissions and
4216 * limitations under the License.
4217 * =============================================================================
4218 */function qE(n,e,t,s=5,r=1,a=1,o=.5){const i={x:n,y:e,dy:t},l={depthRadius:s,bias:r,alpha:a,beta:o};return F.runKernel(Cc,i,l)}const KE=R({localResponseNormalizationBackprop_:qE});/**
4219 * @license
4220 * Copyright 2020 Google LLC. All Rights Reserved.
4221 * Licensed under the Apache License, Version 2.0 (the "License");
4222 * you may not use this file except in compliance with the License.
4223 * You may obtain a copy of the License at
4224 *
4225 * http://www.apache.org/licenses/LICENSE-2.0
4226 *
4227 * Unless required by applicable law or agreed to in writing, software
4228 * distributed under the License is distributed on an "AS IS" BASIS,
4229 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4230 * See the License for the specific language governing permissions and
4231 * limitations under the License.
4232 * =============================================================================
4233 */const XE={kernelName:ni,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,r]=e,{depthRadius:a,bias:o,alpha:i,beta:l}=t;return{x:()=>KE(s,r,n,a,o,i,l)}}};/**
4234 * @license
4235 * Copyright 2020 Google LLC. All Rights Reserved.
4236 * Licensed under the Apache License, Version 2.0 (the "License");
4237 * you may not use this file except in compliance with the License.
4238 * You may obtain a copy of the License at
4239 *
4240 * http://www.apache.org/licenses/LICENSE-2.0
4241 *
4242 * Unless required by applicable law or agreed to in writing, software
4243 * distributed under the License is distributed on an "AS IS" BASIS,
4244 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4245 * See the License for the specific language governing permissions and
4246 * limitations under the License.
4247 * =============================================================================
4248 */function hw(n,e,t,s){return e.rank<t.rank&&(e=D(e,nt(e.shape,s))),n.rank<t.rank&&(n=D(n,nt(n.shape,s))),{x:()=>O(n,ee(Yt(t,e),n.dtype))}}/**
4249 * @license
4250 * Copyright 2020 Google LLC. All Rights Reserved.
4251 * Licensed under the Apache License, Version 2.0 (the "License");
4252 * you may not use this file except in compliance with the License.
4253 * You may obtain a copy of the License at
4254 *
4255 * http://www.apache.org/licenses/LICENSE-2.0
4256 *
4257 * Unless required by applicable law or agreed to in writing, software
4258 * distributed under the License is distributed on an "AS IS" BASIS,
4259 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4260 * See the License for the specific language governing permissions and
4261 * limitations under the License.
4262 * =============================================================================
4263 */const Ag={kernelName:Xo,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const s=t,{reductionIndices:r}=s,a=e[0],o=e[1],i=Ie(r,a.shape),l=hw(n,o,a,i);return{x:()=>l.x()}}};/**
4264 * @license
4265 * Copyright 2020 Google LLC. All Rights Reserved.
4266 * Licensed under the Apache License, Version 2.0 (the "License");
4267 * you may not use this file except in compliance with the License.
4268 * You may obtain a copy of the License at
4269 *
4270 * http://www.apache.org/licenses/LICENSE-2.0
4271 *
4272 * Unless required by applicable law or agreed to in writing, software
4273 * distributed under the License is distributed on an "AS IS" BASIS,
4274 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4275 * See the License for the specific language governing permissions and
4276 * limitations under the License.
4277 * =============================================================================
4278 */const YE={kernelName:Ri,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>O(n,ee(os(t,s),"float32")),b:()=>O(n,ee(_r(t,s),"float32"))}}};/**
4279 * @license
4280 * Copyright 2020 Google LLC. All Rights Reserved.
4281 * Licensed under the Apache License, Version 2.0 (the "License");
4282 * you may not use this file except in compliance with the License.
4283 * You may obtain a copy of the License at
4284 *
4285 * http://www.apache.org/licenses/LICENSE-2.0
4286 *
4287 * Unless required by applicable law or agreed to in writing, software
4288 * distributed under the License is distributed on an "AS IS" BASIS,
4289 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4290 * See the License for the specific language governing permissions and
4291 * limitations under the License.
4292 * =============================================================================
4293 */function JE(n,e,t,s,r,a,o){const i=N(n,"dy","maxPool3dGrad"),l=N(e,"input","maxPool3dGrad"),u=N(t,"output","maxPool3dGrad");let c=i,h=l,d=u,p=!1;l.rank===4&&(p=!0,c=D(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),h=D(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),d=D(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),I(c.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`),I(h.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`),I(d.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`),Ht("maxPool3dGrad",a,o);const f={dy:c,input:h,output:d},g={filterSize:s,strides:r,pad:a,dimRoundingMode:o},m=F.runKernel($c,f,g);return p?D(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}const ZE=R({maxPool3dGrad_:JE});/**
4294 * @license
4295 * Copyright 2020 Google LLC. All Rights Reserved.
4296 * Licensed under the Apache License, Version 2.0 (the "License");
4297 * you may not use this file except in compliance with the License.
4298 * You may obtain a copy of the License at
4299 *
4300 * http://www.apache.org/licenses/LICENSE-2.0
4301 *
4302 * Unless required by applicable law or agreed to in writing, software
4303 * distributed under the License is distributed on an "AS IS" BASIS,
4304 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4305 * See the License for the specific language governing permissions and
4306 * limitations under the License.
4307 * =============================================================================
4308 */const QE={kernelName:li,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,r]=e,{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=t;return{x:()=>ZE(n,s,r,a,o,i,l)}}};/**
4309 * @license
4310 * Copyright 2020 Google LLC. All Rights Reserved.
4311 * Licensed under the Apache License, Version 2.0 (the "License");
4312 * you may not use this file except in compliance with the License.
4313 * You may obtain a copy of the License at
4314 *
4315 * http://www.apache.org/licenses/LICENSE-2.0
4316 *
4317 * Unless required by applicable law or agreed to in writing, software
4318 * distributed under the License is distributed on an "AS IS" BASIS,
4319 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4320 * See the License for the specific language governing permissions and
4321 * limitations under the License.
4322 * =============================================================================
4323 */function eR(n,e,t,s,r,a,o){const i=N(n,"dy","maxPoolGrad"),l=N(e,"input","maxPoolGrad"),u=N(t,"output","maxPoolGrad");I(l.rank===i.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${i.rank})`),I(i.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${i.rank}.`),I(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),Ht("maxPoolGrad",a,o);const c={dy:i,input:l,output:u},h={filterSize:s,strides:r,pad:a,dimRoundingMode:o};return F.runKernel(Nc,c,h)}const tR=R({maxPoolGrad_:eR});/**
4324 * @license
4325 * Copyright 2020 Google LLC. All Rights Reserved.
4326 * Licensed under the Apache License, Version 2.0 (the "License");
4327 * you may not use this file except in compliance with the License.
4328 * You may obtain a copy of the License at
4329 *
4330 * http://www.apache.org/licenses/LICENSE-2.0
4331 *
4332 * Unless required by applicable law or agreed to in writing, software
4333 * distributed under the License is distributed on an "AS IS" BASIS,
4334 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4335 * See the License for the specific language governing permissions and
4336 * limitations under the License.
4337 * =============================================================================
4338 */const nR={kernelName:ii,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s,r]=e,{filterSize:a,strides:o,pad:i}=t;return{x:()=>tR(n,s,r,a,o,i)}}};/**
4339 * @license
4340 * Copyright 2020 Google LLC. All Rights Reserved.
4341 * Licensed under the Apache License, Version 2.0 (the "License");
4342 * you may not use this file except in compliance with the License.
4343 * You may obtain a copy of the License at
4344 *
4345 * http://www.apache.org/licenses/LICENSE-2.0
4346 *
4347 * Unless required by applicable law or agreed to in writing, software
4348 * distributed under the License is distributed on an "AS IS" BASIS,
4349 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4350 * See the License for the specific language governing permissions and
4351 * limitations under the License.
4352 * =============================================================================
4353 */const sR={kernelName:ui,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:r}=t,a=Ie(r,s.shape),i=Ct(s.shape,a)[1],l=H(i);return{x:()=>{const c=s.shape.slice();a.forEach(p=>{c[p]=1});const h=D(n,c);return he(O(h,Vt(s.shape,"float32")),l)}}}};/**
4354 * @license
4355 * Copyright 2020 Google LLC. All Rights Reserved.
4356 * Licensed under the Apache License, Version 2.0 (the "License");
4357 * you may not use this file except in compliance with the License.
4358 * You may obtain a copy of the License at
4359 *
4360 * http://www.apache.org/licenses/LICENSE-2.0
4361 *
4362 * Unless required by applicable law or agreed to in writing, software
4363 * distributed under the License is distributed on an "AS IS" BASIS,
4364 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4365 * See the License for the specific language governing permissions and
4366 * limitations under the License.
4367 * =============================================================================
4368 */const rR={kernelName:Yo,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const s=t,{axis:r}=s,[a,o]=e,i=Ie(r,a.shape),l=hw(n,o,a,i);return{x:()=>l.x()}}};/**
4369 * @license
4370 * Copyright 2020 Google LLC. All Rights Reserved.
4371 * Licensed under the Apache License, Version 2.0 (the "License");
4372 * you may not use this file except in compliance with the License.
4373 * You may obtain a copy of the License at
4374 *
4375 * http://www.apache.org/licenses/LICENSE-2.0
4376 *
4377 * Unless required by applicable law or agreed to in writing, software
4378 * distributed under the License is distributed on an "AS IS" BASIS,
4379 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4380 * See the License for the specific language governing permissions and
4381 * limitations under the License.
4382 * =============================================================================
4383 */const aR={kernelName:ga,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e;return{a:()=>O(n,ee(Ls(t,s),"float32")),b:()=>O(n,ee(Lt(t,s),"float32"))}}};/**
4384 * @license
4385 * Copyright 2020 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 oR={kernelName:ci,inputsToSave:["x"],gradFunc:(n,e,t)=>{const s=e[0],{paddings:r}=t,a=r.map(o=>o[0]);return{x:()=>Se(n,a,s.shape)}}};/**
4399 * @license
4400 * Copyright 2020 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 */const iR={kernelName:ya,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=xe(t.shape,s.shape);return{a:()=>{const i=vt(t.shape,r);return i.length>0?D(oe(n,i),t.shape):n},b:()=>{const i=O(n,Ve(La(he(t,s)))),l=vt(s.shape,r);return l.length>0?D(oe(i,l),s.shape):i}}}};/**
4414 * @license
4415 * Copyright 2020 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 lR={kernelName:Di,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=xe(t.shape,s.shape);return{a:()=>{const i=O(n,ee(s,"float32")),l=vt(t.shape,r);return l.length>0?D(oe(i,l),t.shape):i},b:()=>{const i=O(n,ee(t,"float32")),l=vt(s.shape,r);return l.length>0?D(oe(i,l),s.shape):i}}}};/**
4429 * @license
4430 * Copyright 2020 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 */const uR={kernelName:si,gradFunc:n=>({x:()=>Ve(n)})};/**
4444 * @license
4445 * Copyright 2020 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 cR={kernelName:di,inputsToSave:["indices"],gradFunc:(n,e)=>{const t=e[0];return{indices:()=>et(t.shape,"float32")}}};/**
4459 * @license
4460 * Copyright 2020 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 hR={kernelName:pi,gradFunc:n=>({x:()=>Be(n)})};/**
4474 * @license
4475 * Copyright 2020 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 */const dR={kernelName:wi,saveAllInputs:!0,gradFunc:(n,e,t)=>{const{axis:s}=t;return cn(n,s).map(a=>()=>a)}};/**
4489 * @license
4490 * Copyright 2020 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 */const Og={kernelName:fi,inputsToSave:["x"],gradFunc:(n,e,t)=>{const s=e[0],{paddings:r}=t,a=r.map(o=>o[0]);return{x:()=>Se(n,a,s.shape)}}};/**
4504 * @license
4505 * Copyright 2020 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 pR={kernelName:Ai,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(n,e)=>{const[t,s,r]=e,a=t,o=s,i=xe(a.shape,o.shape);return{a:()=>{const c=ee(o,"float32");let h=O(n,O(c,As(a,ie(c,pe(1)))));const d=vt(a.shape,i);return d.length>0&&(h=oe(h,d)),D(h,a.shape)},b:()=>{const c=Lt(a,0),h=dt(c,Jt(a),Be(a));let d=O(n,O(r,h));const p=vt(o.shape,i);return p.length>0&&(d=oe(d,p)),D(d,o.shape)}}}};/**
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 */const fR={kernelName:Ic,inputsToSave:["x","alpha"],gradFunc:(n,e)=>{const[t,s]=e,r=Lt(t,0);return{x:()=>dt(r,n,O(n,s)),alpha:()=>{let a=dt(r,Be(n),O(n,t));const o=vt(s.shape,n.shape);return o.length>0&&(a=oe(a,o)),D(a,s.shape)}}}};/**
4534 * @license
4535 * Copyright 2022 Google Inc. 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 mR(n,e,t){const s=n.shape.slice();s[t]=1;const r=D(e,s),a=Co(n,t,!0,!1),o=Co(n,t,!0,!0),i=O(a,o);return O(r,i)}function gR(n,e,t){const s=n.shape.length,r=s-t.length,a=Xe(t,s);let o=n;a!=null&&(o=Ne(n,a));const i=o.shape.slice(),u=i.splice(s-t.length,t.length).reduce((d,p)=>d*p,1);i.push(u);const c=o.reshape(i);let h=mR(c,e,r);if(h=h.reshape(o.shape),a!=null){const d=pr(a);h=Ne(h,d)}return h}const yR={kernelName:gi,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{axis:r}=t;let a=[];return r==null?a=s.shape.map((o,i)=>i):typeof r=="number"?a=[r]:a=r,{x:()=>gR(s,n,a)}}};/**
4549 * @license
4550 * Copyright 2020 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 xR={kernelName:Oi,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=xe(t.shape,s.shape);return{a:()=>{const i=he(n,ee(s,"float32")),l=vt(t.shape,r);return l.length>0?D(oe(i,l),t.shape):i},b:()=>{let i=O(n,ee(t,"float32"));const l=vt(s.shape,r);l.length>0&&(i=D(oe(i,l),s.shape));const u=Ye(s);return Ve(he(i,ee(u,"float32")))}}}};/**
4564 * @license
4565 * Copyright 2020 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 bR={kernelName:xa,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,Ve(Ye(t)))}}};/**
4579 * @license
4580 * Copyright 2020 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 * =============================================================================
4593 */const wR={kernelName:_i,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,s=O(Ls(t,6),Ea(t));return{x:()=>O(n,ee(s,"float32"))}}};/**
4594 * @license
4595 * Copyright 2020 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 vR={kernelName:Fi,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(n,ee(Ea(t),"float32"))}}};/**
4609 * @license
4610 * Copyright 2020 Google Inc. 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 */const CR={kernelName:Sc,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>D(n,t.shape)}}};/**
4624 * @license
4625 * Copyright 2020 Google LLC. All Rights Reserved.
4626 * Licensed under the Apache License, Version 2.0 (the "License");
4627 * you may not use this file except in compliance with the License.
4628 * You may obtain a copy of the License at
4629 *
4630 * http://www.apache.org/licenses/LICENSE-2.0
4631 *
4632 * Unless required by applicable law or agreed to in writing, software
4633 * distributed under the License is distributed on an "AS IS" BASIS,
4634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4635 * See the License for the specific language governing permissions and
4636 * limitations under the License.
4637 * =============================================================================
4638 */const $R={kernelName:Ni,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[s]=e,r={dy:n,images:s};return{images:()=>F.runKernel(kc,r,t)}}};/**
4639 * @license
4640 * Copyright 2020 Google LLC. All Rights Reserved.
4641 * Licensed under the Apache License, Version 2.0 (the "License");
4642 * you may not use this file except in compliance with the License.
4643 * You may obtain a copy of the License at
4644 *
4645 * http://www.apache.org/licenses/LICENSE-2.0
4646 *
4647 * Unless required by applicable law or agreed to in writing, software
4648 * distributed under the License is distributed on an "AS IS" BASIS,
4649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4650 * See the License for the specific language governing permissions and
4651 * limitations under the License.
4652 * =============================================================================
4653 */const NR={kernelName:Ii,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[s]=e,r={dy:n,images:s};return{images:()=>F.runKernel(Tc,r,t)}}};/**
4654 * @license
4655 * Copyright 2020 Google LLC. All Rights Reserved.
4656 * Licensed under the Apache License, Version 2.0 (the "License");
4657 * you may not use this file except in compliance with the License.
4658 * You may obtain a copy of the License at
4659 *
4660 * http://www.apache.org/licenses/LICENSE-2.0
4661 *
4662 * Unless required by applicable law or agreed to in writing, software
4663 * distributed under the License is distributed on an "AS IS" BASIS,
4664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4665 * See the License for the specific language governing permissions and
4666 * limitations under the License.
4667 * =============================================================================
4668 */const IR={kernelName:yi,gradFunc:(n,e,t)=>{const{dims:s}=t,r=Ie(s,n.shape);return{x:()=>un(n,r)}}};/**
4669 * @license
4670 * Copyright 2020 Google LLC. All Rights Reserved.
4671 * Licensed under the Apache License, Version 2.0 (the "License");
4672 * you may not use this file except in compliance with the License.
4673 * You may obtain a copy of the License at
4674 *
4675 * http://www.apache.org/licenses/LICENSE-2.0
4676 *
4677 * Unless required by applicable law or agreed to in writing, software
4678 * distributed under the License is distributed on an "AS IS" BASIS,
4679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4680 * See the License for the specific language governing permissions and
4681 * limitations under the License.
4682 * =============================================================================
4683 */const SR={kernelName:ba,gradFunc:n=>({x:()=>Be(n)})};/**
4684 * @license
4685 * Copyright 2020 Google LLC. All Rights Reserved.
4686 * Licensed under the Apache License, Version 2.0 (the "License");
4687 * you may not use this file except in compliance with the License.
4688 * You may obtain a copy of the License at
4689 *
4690 * http://www.apache.org/licenses/LICENSE-2.0
4691 *
4692 * Unless required by applicable law or agreed to in writing, software
4693 * distributed under the License is distributed on an "AS IS" BASIS,
4694 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4695 * See the License for the specific language governing permissions and
4696 * limitations under the License.
4697 * =============================================================================
4698 */const kR={kernelName:wa,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Ve(he(n,O(As(t,1.5),2)))}}};/**
4699 * @license
4700 * Copyright 2020 Google LLC. All Rights Reserved.
4701 * Licensed under the Apache License, Version 2.0 (the "License");
4702 * you may not use this file except in compliance with the License.
4703 * You may obtain a copy of the License at
4704 *
4705 * http://www.apache.org/licenses/LICENSE-2.0
4706 *
4707 * Unless required by applicable law or agreed to in writing, softw
4707are
4708 * distributed under the License is distributed on an "AS IS" BASIS,
4709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4710 * See the License for the specific language governing permissions and
4711 * limitations under the License.
4712 * =============================================================================
4713 */const TR={kernelName:Ko,inputsToSave:["condition"],gradFunc:(n,e)=>{const[t]=e;return{condition:()=>ee(Be(t),"float32"),t:()=>O(n,ee(t,n.dtype)),e:()=>O(n,ee(Ji(t),n.dtype))}}};/**
4714 * @license
4715 * Copyright 2020 Google LLC. All Rights Reserved.
4716 * Licensed under the Apache License, Version 2.0 (the "License");
4717 * you may not use this file except in compliance with the License.
4718 * You may obtain a copy of the License at
4719 *
4720 * http://www.apache.org/licenses/LICENSE-2.0
4721 *
4722 * Unless required by applicable law or agreed to in writing, software
4723 * distributed under the License is distributed on an "AS IS" BASIS,
4724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4725 * See the License for the specific language governing permissions and
4726 * limitations under the License.
4727 * =============================================================================
4728 */const ER={kernelName:va,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const s=Lt(t,pe(0)),r=pe(Ud),a=pe(Gd),o=O(n,a),i=O(O(n,r),Wt(ee(t,"float32")));return dt(s,o,i)}}}};/**
4729 * @license
4730 * Copyright 2020 Google LLC. All Rights Reserved.
4731 * Licensed under the Apache License, Version 2.0 (the "License");
4732 * you may not use this file except in compliance with the License.
4733 * You may obtain a copy of the License at
4734 *
4735 * http://www.apache.org/licenses/LICENSE-2.0
4736 *
4737 * Unless required by applicable law or agreed to in writing, software
4738 * distributed under the License is distributed on an "AS IS" BASIS,
4739 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4740 * See the License for the specific language governing permissions and
4741 * limitations under the License.
4742 * =============================================================================
4743 */const RR={kernelName:Li,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(n,O(t,ie(pe(1),t)))}}};/**
4744 * @license
4745 * Copyright 2020 Google LLC. All Rights Reserved.
4746 * Licensed under the Apache License, Version 2.0 (the "License");
4747 * you may not use this file except in compliance with the License.
4748 * You may obtain a copy of the License at
4749 *
4750 * http://www.apache.org/licenses/LICENSE-2.0
4751 *
4752 * Unless required by applicable law or agreed to in writing, software
4753 * distributed under the License is distributed on an "AS IS" BASIS,
4754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4755 * See the License for the specific language governing permissions and
4756 * limitations under the License.
4757 * =============================================================================
4758 */const DR={kernelName:Ca,gradFunc:n=>({x:()=>Be(n)})};/**
4759 * @license
4760 * Copyright 2020 Google LLC. All Rights Reserved.
4761 * Licensed under the Apache License, Version 2.0 (the "License");
4762 * you may not use this file except in compliance with the License.
4763 * You may obtain a copy of the License at
4764 *
4765 * http://www.apache.org/licenses/LICENSE-2.0
4766 *
4767 * Unless required by applicable law or agreed to in writing, software
4768 * distributed under the License is distributed on an "AS IS" BASIS,
4769 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4770 * See the License for the specific language governing permissions and
4771 * limitations under the License.
4772 * =============================================================================
4773 */const AR={kernelName:$a,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(qi(ee(t,"float32")),n)}}};/**
4774 * @license
4775 * Copyright 2020 Google LLC. All Rights Reserved.
4776 * Licensed under the Apache License, Version 2.0 (the "License");
4777 * you may not use this file except in compliance with the License.
4778 * You may obtain a copy of the License at
4779 *
4780 * http://www.apache.org/licenses/LICENSE-2.0
4781 *
4782 * Unless required by applicable law or agreed to in writing, softw
4782are
4783 * distributed under the License is distributed on an "AS IS" BASIS,
4784 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4785 * See the License for the specific language governing permissions and
4786 * limitations under the License.
4787 * =============================================================================
4788 */const OR={kernelName:Na,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(Uc(ee(t,"float32")),n)}}};/**
4789 * @license
4790 * Copyright 2020 Google LLC. All Rights Reserved.
4791 * Licensed under the Apache License, Version 2.0 (the "License");
4792 * you may not use this file except in compliance with the License.
4793 * You may obtain a copy of the License at
4794 *
4795 * http://www.apache.org/licenses/LICENSE-2.0
4796 *
4797 * Unless required by applicable law or agreed to in writing, software
4798 * distributed under the License is distributed on an "AS IS" BASIS,
4799 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4800 * See the License for the specific language governing permissions and
4801 * limitations under the License.
4802 * =============================================================================
4803 */const _R={kernelName:wu,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{begin:r,size:a}=t,o=s.shape,[i,l]=cx(s,r,a),u=[];for(let c=0;c<n.rank;c++)u.push([i[c],o[c]-i[c]-l[c]]);return{x:()=>is(n,u)}}};/**
4804 * @license
4805 * Copyright 2020 Google LLC. All Rights Reserved.
4806 * Licensed under the Apache License, Version 2.0 (the "License");
4807 * you may not use this file except in compliance with the License.
4808 * You may obtain a copy of the License at
4809 *
4810 * http://www.apache.org/licenses/LICENSE-2.0
4811 *
4812 * Unless required by applicable law or agreed to in writing, software
4813 * distributed under the License is distributed on an "AS IS" BASIS,
4814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4815 * See the License for the specific language governing permissions and
4816 * limitations under the License.
4817 * =============================================================================
4818 */const FR={kernelName:xi,outputsToSave:[!0],gradFunc:(n,e,t)=>{const[s]=e,{dim:r}=t,a=!0,o=O(n,s);return{logits:()=>ie(o,O(oe(o,[r],a),s))}}};/**
4819 * @license
4820 * Copyright 2020 Google LLC. All Rights Reserved.
4821 * Licensed under the Apache License, Version 2.0 (the "License");
4822 * you may not use this file except in compliance with the License.
4823 * You may obtain a copy of the License at
4824 *
4825 * http://www.apache.org/licenses/LICENSE-2.0
4826 *
4827 * Unless required by applicable law or agreed to in writing, software
4828 * distributed under the License is distributed on an "AS IS" BASIS,
4829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4830 * See the License for the specific language governing permissions and
4831 * limitations under the License.
4832 * =============================================================================
4833 */const LR={kernelName:ma,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(n,Mn(t))}}};/**
4834 * @license
4835 * Copyright 2020 Google LLC. All Rights Reserved.
4836 * Licensed under the Apache License, Version 2.0 (the "License");
4837 * you may not use this file except in compliance with the License.
4838 * You may obtain a copy of the License at
4839 *
4840 * http://www.apache.org/licenses/LICENSE-2.0
4841 *
4842 * Unless required by applicable law or agreed to in writing, software
4843 * distributed under the License is distributed on an "AS IS" BASIS,
4844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4845 * See the License for the specific language governing permissions and
4846 * limitations under the License.
4847 * =============================================================================
4848 */const _g={kernelName:mi,gradFunc:(n,e,t)=>{const{blockShape:s,paddings:r}=t;return{x:()=>ji(n,s,r)}}};/**
4849 * @license
4850 * Copyright 2020 Google LLC. All Rights Reserved.
4851 * Licensed under the Apache License, Version 2.0 (the "License");
4852 * you may not use this file except in compliance with the License.
4853 * You may obtain a copy of the License at
4854 *
4855 * http://www.apache.org/licenses/LICENSE-2.0
4856 *
4857 * Unless required by applicable law or agreed to in writing, softw
4857are
4858 * distributed under the License is distributed on an "AS IS" BASIS,
4859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4860 * See the License for the specific language governing permissions and
4861 * limitations under the License.
4862 * =============================================================================
4863 */const Fg={kernelName:bi,gradFunc:(n,e,t)=>{const{axis:s}=t;return{x:()=>Je(n,s)}}};/**
4864 * @license
4865 * Copyright 2020 Google LLC. All Rights Reserved.
4866 * Licensed under the Apache License, Version 2.0 (the "License");
4867 * you may not use this file except in compliance with the License.
4868 * You may obtain a copy of the License at
4869 *
4870 * http://www.apache.org/licenses/LICENSE-2.0
4871 *
4872 * Unless required by applicable law or agreed to in writing, software
4873 * distributed under the License is distributed on an "AS IS" BASIS,
4874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4875 * See the License for the specific language governing permissions and
4876 * limitations under the License.
4877 * =============================================================================
4878 */const PR={kernelName:Pi,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,O(ln(ee(t,"float32")),2))}}};/**
4879 * @license
4880 * Copyright 2019 Google LLC. All Rights Reserved.
4881 * Licensed under the Apache License, Version 2.0 (the "License");
4882 * you may not use this file except in compliance with the License.
4883 * You may obtain a copy of the License at
4884 *
4885 * http://www.apache.org/licenses/LICENSE-2.0
4886 *
4887 * Unless required by applicable law or agreed to in writing, software
4888 * distributed under the License is distributed on an "AS IS" BASIS,
4889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4890 * See the License for the specific language governing permissions and
4891 * limitations under the License.
4892 * =============================================================================
4893 */const zR={kernelName:Ec,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(n,O(ee(t,"float32"),2))}}};/**
4894 * @license
4895 * Copyright 2020 Google LLC. All Rights Reserved.
4896 * Licensed under the Apache License, Version 2.0 (the "License");
4897 * you may not use this file except in compliance with the License.
4898 * You may obtain a copy of the License at
4899 *
4900 * http://www.apache.org/licenses/LICENSE-2.0
4901 *
4902 * Unless required by applicable law or agreed to in writing, software
4903 * distributed under the License is distributed on an "AS IS" BASIS,
4904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4905 * See the License for the specific language governing permissions and
4906 * limitations under the License.
4907 * =============================================================================
4908 */const VR={kernelName:Ia,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=pe(2);return{a:()=>O(n,O(r,ie(t,s))),b:()=>O(n,O(r,ie(s,t)))}}};/**
4909 * @license
4910 * Copyright 2020 Google LLC. All Rights Reserved.
4911 * Licensed under the Apache License, Version 2.0 (the "License");
4912 * you may not use this file except in compliance with the License.
4913 * You may obtain a copy of the License at
4914 *
4915 * http://www.apache.org/licenses/LICENSE-2.0
4916 *
4917 * Unless required by applicable law or agreed to in writing, software
4918 * distributed under the License is distributed on an "AS IS" BASIS,
4919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4920 * See the License for the specific language governing permissions and
4921 * limitations under the License.
4922 * =============================================================================
4923 */const BR={kernelName:zi,gradFunc:n=>({x:()=>Be(n)})};/**
4924 * @license
4925 * Copyright 2020 Google LLC. All Rights Reserved.
4926 * Licensed under the Apache License, Version 2.0 (the "License");
4927 * you may not use this file except in compliance with the License.
4928 * You may obtain a copy of the License at
4929 *
4930 * http://www.apache.org/licenses/LICENSE-2.0
4931 *
4932 * Unless required by applicable law or agreed to in writing, software
4933 * distributed under the License is distributed on an "AS IS" BASIS,
4934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4935 * See the License for the specific language governing permissions and
4936 * limitations under the License.
4937 * =============================================================================
4938 */const MR={kernelName:Vi,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,s]=e,r=xe(t.shape,s.shape);return{a:()=>{let i=n;const l=vt(t.shape,r);return l.length>0&&(i=oe(i,l)),D(i,t.shape)},b:()=>{let i=n;const l=vt(s.shape,r);return l.length>0&&(i=oe(i,l)),D(Ve(i),s.shape)}}}};/**
4939 * @license
4940 * Copyright 2020 Google Inc. All Rights Reserved.
4941 * Licensed under the Apache License, Version 2.0 (the "License");
4942 * you may not use this file except in compliance with the License.
4943 * You may obtain a copy of the License at
4944 *
4945 * http://www.apache.org/licenses/LICENSE-2.0
4946 *
4947 * Unless required by applicable law or agreed to in writing, software
4948 * distributed under the License is distributed on an "AS IS" BASIS,
4949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4950 * See the License for the specific language governing permissions and
4951 * limitations under the License.
4952 * =============================================================================
4953 */const WR={kernelName:Rc,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,r=s.shape.slice(),{axis:a}=t;Ie(a,s.shape).forEach(u=>{r[u]=1});const i=D(n,r),l=O(i,Vt(s.shape,"float32"));return{x:()=>l}}};/**
4954 * @license
4955 * Copyright 2020 Google LLC. All Rights Reserved.
4956 * Licensed under the Apache License, Version 2.0 (the "License");
4957 * you may not use this file except in compliance with the License.
4958 * You may obtain a copy of the License at
4959 *
4960 * http://www.apache.org/licenses/LICENSE-2.0
4961 *
4962 * Unless required by applicable law or agreed to in writing, software
4963 * distributed under the License is distributed on an "AS IS" BASIS,
4964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4965 * See the License for the specific language governing permissions and
4966 * limitations under the License.
4967 * =============================================================================
4968 */const UR={kernelName:Sa,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>he(n,Ye(qi(t)))}}};/**
4969 * @license
4970 * Copyright 2020 Google LLC. All Rights Reserved.
4971 * Licensed under the Apache License, Version 2.0 (the "License");
4972 * you may not use this file except in compliance with the License.
4973 * You may obtain a copy of the License at
4974 *
4975 * http://www.apache.org/licenses/LICENSE-2.0
4976 *
4977 * Unless required by applicable law or agreed to in writing, software
4978 * distributed under the License is distributed on an "AS IS" BASIS,
4979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4980 * See the License for the specific language governing permissions and
4981 * limitations under the License.
4982 * =============================================================================
4983 */const GR={kernelName:Zr,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>O(ie(pe(1),Ye(t)),n)}}};/**
4984 * @license
4985 * Copyright 2020 Google LLC. All Rights Reserved.
4986 * Licensed under the Apache License, Version 2.0 (the "License");
4987 * you may not use this file except in compliance with the License.
4988 * You may obtain a copy of the License at
4989 *
4990 * http://www.apache.org/licenses/LICENSE-2.0
4991 *
4992 * Unless required by applicable law or agreed to in writing, software
4993 * distributed under the License is distributed on an "AS IS" BASIS,
4994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4995 * See the License for the specific language governing permissions and
4996 * limitations under the License.
4997 * =============================================================================
4998 */const HR={kernelName:Qr,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[s]=e,{reps:r}=t;return{x:()=>{let o=Be(s);if(s.rank===1)for(let i=0;i<r[0];++i)o=te(o,Se(n,[i*s.shape[0]],[s.shape[0]]));else if(s.rank===2)for(let i=0;i<r[0];++i)for(let l=0;l<r[1];++l)o=te(o,Se(n,[i*s.shape[0],l*s.shape[1]],[s.shape[0],s.shape[1]]));else if(s.rank===3)for(let i=0;i<r[0];++i)for(let l=0;l<r[1];++l)for(let u=0;u<r[2];++u)o=te(o,Se(n,[i*s.shape[0],l*s.shape[1],u*s.shape[2]],[s.shape[0],s.shape[1],s.shape[2]]));else if(s.rank===4)for(let i=0;i<r[0];++i)for(let l=0;l<r[1];++l)for(let u=0;u<r[2];++u)for(let c=0;c<r[3];++c)o=te(o,Se(n,[i*s.shape[0],l*s.shape[1],u*s.shape[2],c*s.shape[3]],[s.shape[0],s.shape[1],s.shape[2],s.shape[3]]));else throw new Error(`Gradient for tile operation is not implemented for rank-${s.rank} tensors yet.`);return o}}}};/**
4999 * @license
5000 * Copyright 2020 Google LLC. All Rights Reserved.
5001 * Licensed under the Apache License, Version 2.0 (the "License");
5002 * you may not use this file except in compliance with the License.
5003 * You may obtain a copy of the License at
5004 *
5005 * http://www.apache.org/licenses/LICENSE-2.0
5006 *
5007 * Unless required by applicable law or agreed to in writing, softw
5007are
5008 * distributed under the License is distributed on an "AS IS" BASIS,
5009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5010 * See the License for the specific language governing permissions and
5011 * limitations under the License.
5012 * =============================================================================
5013 */const jR={kernelName:Js,gradFunc:(n,e,t)=>{const s=t,{perm:r}=s,a=pr(r);return{x:()=>Ne(n,a)}}};/**
5014 * @license
5015 * Copyright 2020 Google Inc. All Rights Reserved.
5016 * Licensed under the Apache License, Version 2.0 (the "License");
5017 * you may not use this file except in compliance with the License.
5018 * You may obtain a copy of the License at
5019 *
5020 * http://www.apache.org/licenses/LICENSE-2.0
5021 *
5022 * Unless required by applicable law or agreed to in writing, software
5023 * distributed under the License is distributed on an "AS IS" BASIS,
5024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5025 * See the License for the specific language governing permissions and
5026 * limitations under the License.
5027 * =============================================================================
5028 */const qR={kernelName:Ci,gradFunc:(n,e,t)=>{const s=t,{axis:r}=s;return{value:()=>Ot(n,r)}}};/**
5029 * @license
5030 * Copyright 2020 Google LLC. All Rights Reserved.
5031 * Licensed under the Apache License, Version 2.0 (the "License");
5032 * you may not use this file except in compliance with the License.
5033 * You may obtain a copy of the License at
5034 *
5035 * http://www.apache.org/licenses/LICENSE-2.0
5036 *
5037 * Unless required by applicable law or agreed to in writing, software
5038 * distributed under the License is distributed on an "AS IS" BASIS,
5039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5040 * See the License for the specific language governing permissions and
5041 * limitations under the License.
5042 * =============================================================================
5043 */const KR={kernelName:vi,inputsToSave:["segmentIds"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>XR(n,t)}}};function XR(n,e){const t=as(e,Be(e)),s=Pa(n,t);let r=os(e,pe(0,"int32"));const a=s.rank-r.rank;for(let i=0;i<a;++i)r=mt(r,i+1);r=wn(r,Vt(s.shape,"bool"));const o=Be(s);return dt(r,s,o)}/**
5044 * @license
5045 * Copyright 2020 Google LLC. All Rights Reserved.
5046 * Licensed under the Apache License, Version 2.0 (the "License");
5047 * you may not use this file except in compliance with the License.
5048 * You may obtain a copy of the License at
5049 *
5050 * http://www.apache.org/licenses/LICENSE-2.0
5051 *
5052 * Unless required by applicable law or agreed to in writing, software
5053 * distributed under the License is distributed on an "AS IS" BASIS,
5054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5055 * See the License for the specific language governing permissions and
5056 * limitations under the License.
5057 * =============================================================================
5058 */const YR={kernelName:Dc,gradFunc:n=>({x:()=>Be(n)})};/**
5059 * @license
5060 * Copyright 2020 Google LLC. All Rights Reserved.
5061 * Licensed under the Apache License, Version 2.0 (the "License");
5062 * you may not use this file except in compliance with the License.
5063 * You may obtain a copy of the License at
5064 *
5065 * http://www.apache.org/licenses/LICENSE-2.0
5066 *
5067 * Unless required by applicable law or agreed to in writing, software
5068 * distributed under the License is distributed on an "AS IS" BASIS,
5069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5070 * See the License for the specific language governing permissions and
5071 * limitations under the License.
5072 * =============================================================================
5073 */const JR=[cw,K2,X2,Y2,J2,Z2,Q2,eE,tE,nE,sE,rE,iE,cE,hE,dE,pE,fE,mE,gE,yE,xE,wE,bE,$E,NE,IE,SE,kE,TE,xR,EE,RE,DE,AE,OE,FE,_E,LE,PE,zE,VE,BE,ME,WE,UE,GE,HE,jE,XE,Ag,Ag,YE,QE,nR,sR,rR,aR,oR,iR,lR,uR,cR,hR,dR,Og,Og,pR,fR,yR,bR,wR,vR,CR,$R,NR,IR,SR,kR,TR,ER,RR,DR,AR,OR,_R,FR,LR,_g,_g,Fg,Fg,PR,VR,zR,BR,MR,WR,UR,GR,HR,jR,qR,KR,YR];for(const n of JR)hx(n);/**
5074 * @license
5075 * Copyright 2020 Google LLC. All Rights Reserved.
5076 * Licensed under the Apache License, Version 2.0 (the "License");
5077 * you may not use this file except in compliance with the License.
5078 * You may obtain a copy of the License at
5079 *
5080 * http://www.apache.org/licenses/LICENSE-2.0
5081 *
5082 * Unless required by applicable law or agreed to in writing, software
5083 * distributed under the License is distributed on an "AS IS" BASIS,
5084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5085 * See the License for the specific language governing permissions and
5086 * limitations under the License.
5087 * =============================================================================
5088 */G().prototype.abs=function(){return this.throwIfDisposed(),rt(this)};/**
5089 * @license
5090 * Copyright 2020 Google LLC. All Rights Reserved.
5091 * Licensed under the Apache License, Version 2.0 (the "License");
5092 * you may not use this file except in compliance with the License.
5093 * You may obtain a copy of the License at
5094 *
5095 * http://www.apache.org/licenses/LICENSE-2.0
5096 *
5097 * Unless required by applicable law or agreed to in writing, software
5098 * distributed under the License is distributed on an "AS IS" BASIS,
5099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5100 * See the License for the specific language governing permissions and
5101 * limitations under the License.
5102 * =============================================================================
5103 */G().prototype.acos=function(){return this.throwIfDisposed(),sp(this)};/**
5104 * @license
5105 * Copyright 2020 Google LLC. All Rights Reserved.
5106 * Licensed under the Apache License, Version 2.0 (the "License");
5107 * you may not use this file except in compliance with the License.
5108 * You may obtain a copy of the License at
5109 *
5110 * http://www.apache.org/licenses/LICENSE-2.0
5111 *
5112 * Unless required by applicable law or agreed to in writing, software
5113 * distributed under the License is distributed on an "AS IS" BASIS,
5114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5115 * See the License for the specific language governing permissions and
5116 * limitations under the License.
5117 * =============================================================================
5118 */G().prototype.acosh=function(){return this.throwIfDisposed(),rp(this)};/**
5119 * @license
5120 * Copyright 2020 Google LLC. All Rights Reserved.
5121 * Licensed under the Apache License, Version 2.0 (the "License");
5122 * you may not use this file except in compliance with the License.
5123 * You may obtain a copy of the License at
5124 *
5125 * http://www.apache.org/licenses/LICENSE-2.0
5126 *
5127 * Unless required by applicable law or agreed to in writing, software
5128 * distributed under the License is distributed on an "AS IS" BASIS,
5129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5130 * See the License for the specific language governing permissions and
5131 * limitations under the License.
5132 * =============================================================================
5133 */G().prototype.add=function(n){return this.throwIfDisposed(),te(this,n)};/**
5134 * @license
5135 * Copyright 2020 Google LLC. All Rights Reserved.
5136 * Licensed under the Apache License, Version 2.0 (the "License");
5137 * you may not use this file except in compliance with the License.
5138 * You may obtain a copy of the License at
5139 *
5140 * http://www.apache.org/licenses/LICENSE-2.0
5141 *
5142 * Unless required by applicable law or agreed to in writing, software
5143 * distributed under the License is distributed on an "AS IS" BASIS,
5144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5145 * See the License for the specific language governing permissions and
5146 * limitations under the License.
5147 * =============================================================================
5148 */G().prototype.all=function(n,e){return this.throwIfDisposed(),Bc(this,n,e)};/**
5149 * @license
5150 * Copyright 2020 Google LLC. All Rights Reserved.
5151 * Licensed under the Apache License, Version 2.0 (the "License");
5152 * you may not use this file except in compliance with the License.
5153 * You may obtain a copy of the License at
5154 *
5155 * http://www.apache.org/licenses/LICENSE-2.0
5156 *
5157 * Unless required by applicable law or agreed to in writing, softw
5157are
5158 * distributed under the License is distributed on an "AS IS" BASIS,
5159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5160 * See the License for the specific language governing permissions and
5161 * limitations under the License.
5162 * =============================================================================
5163 */G().prototype.any=function(n,e){return this.throwIfDisposed(),vo(this,n,e)};/**
5164 * @license
5165 * Copyright 2020 Google LLC. All Rights Reserved.
5166 * Licensed under the Apache License, Version 2.0 (the "License");
5167 * you may not use this file except in compliance with the License.
5168 * You may obtain a copy of the License at
5169 *
5170 * http://www.apache.org/licenses/LICENSE-2.0
5171 *
5172 * Unless required by applicable law or agreed to in writing, software
5173 * distributed under the License is distributed on an "AS IS" BASIS,
5174 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5175 * See the License for the specific language governing permissions and
5176 * limitations under the License.
5177 * =============================================================================
5178 */G().prototype.argMax=function(n){return this.throwIfDisposed(),nr(this,n)};/**
5179 * @license
5180 * Copyright 2020 Google LLC. All Rights Reserved.
5181 * Licensed under the Apache License, Version 2.0 (the "License");
5182 * you may not use this file except in compliance with the License.
5183 * You may obtain a copy of the License at
5184 *
5185 * http://www.apache.org/licenses/LICENSE-2.0
5186 *
5187 * Unless required by applicable law or agreed to in writing, software
5188 * distributed under the License is distributed on an "AS IS" BASIS,
5189 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5190 * See the License for the specific language governing permissions and
5191 * limitations under the License.
5192 * =============================================================================
5193 */G().prototype.argMin=function(n){return this.throwIfDisposed(),ap(this,n)};/**
5194 * @license
5195 * Copyright 2020 Google LLC. All Rights Reserved.
5196 * Licensed under the Apache License, Version 2.0 (the "License");
5197 * you may not use this file except in compliance with the License.
5198 * You may obtain a copy of the License at
5199 *
5200 * http://www.apache.org/licenses/LICENSE-2.0
5201 *
5202 * Unless required by applicable law or agreed to in writing, software
5203 * distributed under the License is distributed on an "AS IS" BASIS,
5204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5205 * See the License for the specific language governing permissions and
5206 * limitations under the License.
5207 * =============================================================================
5208 */G().prototype.asScalar=function(){return this.throwIfDisposed(),I(this.size===1,()=>"The array must have only 1 element."),D(this,[])};/**
5209 * @license
5210 * Copyright 2020 Google LLC. All Rights Reserved.
5211 * Licensed under the Apache License, Version 2.0 (the "License");
5212 * you may not use this file except in compliance with the License.
5213 * You may obtain a copy of the License at
5214 *
5215 * http://www.apache.org/licenses/LICENSE-2.0
5216 *
5217 * Unless required by applicable law or agreed to in writing, software
5218 * distributed under the License is distributed on an "AS IS" BASIS,
5219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5220 * See the License for the specific language governing permissions and
5221 * limitations under the License.
5222 * =============================================================================
5223 */G().prototype.asType=function(n){return this.throwIfDisposed(),ee(this,n)};/**
5224 * @license
5225 * Copyright 2020 Google LLC. All Rights Reserved.
5226 * Licensed under the Apache License, Version 2.0 (the "License");
5227 * you may not use this file except in compliance with the License.
5228 * You may obtain a copy of the License at
5229 *
5230 * http://www.apache.org/licenses/LICENSE-2.0
5231 *
5232 * Unless required by applicable law or agreed to in writing, software
5233 * distributed under the License is distributed on an "AS IS" BASIS,
5234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5235 * See the License for the specific language governing permissions and
5236 * limitations under the License.
5237 * =============================================================================
5238 */G().prototype.as1D=function(){return this.throwIfDisposed(),D(this,[this.size])};/**
5239 * @license
5240 * Copyright 2020 Google LLC. All Rights Reserved.
5241 * Licensed under the Apache License, Version 2.0 (the "License");
5242 * you may not use this file except in compliance with the License.
5243 * You may obtain a copy of the License at
5244 *
5245 * http://www.apache.org/licenses/LICENSE-2.0
5246 *
5247 * Unless required by applicable law or agreed to in writing, software
5248 * distributed under the License is distributed on an "AS IS" BASIS,
5249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5250 * See the License for the specific language governing permissions and
5251 * limitations under the License.
5252 * =============================================================================
5253 */G().prototype.as2D=function(n,e){return this.throwIfDisposed(),D(this,[n,e])};/**
5254 * @license
5255 * Copyright 2020 Google LLC. All Rights Reserved.
5256 * Licensed under the Apache License, Version 2.0 (the "License");
5257 * you may not use this file except in compliance with the License.
5258 * You may obtain a copy of the License at
5259 *
5260 * http://www.apache.org/licenses/LICENSE-2.0
5261 *
5262 * Unless required by applicable law or agreed to in writing, software
5263 * distributed under the License is distributed on an "AS IS" BASIS,
5264 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5265 * See the License for the specific language governing permissions and
5266 * limitations under the License.
5267 * =============================================================================
5268 */G().prototype.as3D=function(n,e,t){return this.throwIfDisposed(),D(this,[n,e,t])};/**
5269 * @license
5270 * Copyright 2020 Google LLC. All Rights Reserved.
5271 * Licensed under the Apache License, Version 2.0 (the "License");
5272 * you may not use this file except in compliance with the License.
5273 * You may obtain a copy of the License at
5274 *
5275 * http://www.apache.org/licenses/LICENSE-2.0
5276 *
5277 * Unless required by applicable law or agreed to in writing, software
5278 * distributed under the License is distributed on an "AS IS" BASIS,
5279 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5280 * See the License for the specific language governing permissions and
5281 * limitations under the License.
5282 * =============================================================================
5283 */G().prototype.as4D=function(n,e,t,s){return this.throwIfDisposed(),D(this,[n,e,t,s])};/**
5284 * @license
5285 * Copyright 2020 Google LLC. All Rights Reserved.
5286 * Licensed under the Apache License, Version 2.0 (the "License");
5287 * you may not use this file except in compliance with the License.
5288 * You may obtain a copy of the License at
5289 *
5290 * http://www.apache.org/licenses/LICENSE-2.0
5291 *
5292 * Unless required by applicable law or agreed to in writing, software
5293 * distributed under the License is distributed on an "AS IS" BASIS,
5294 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5295 * See the License for the specific language governing permissions and
5296 * limitations under the License.
5297 * =============================================================================
5298 */G().prototype.as5D=function(n,e,t,s,r){return this.throwIfDisposed(),D(this,[n,e,t,s,r])};/**
5299 * @license
5300 * Copyright 2020 Google LLC. All Rights Reserved.
5301 * Licensed under the Apache License, Version 2.0 (the "License");
5302 * you may not use this file except in compliance with the License.
5303 * You may obtain a copy of the License at
5304 *
5305 * http://www.apache.org/licenses/LICENSE-2.0
5306 *
5307 * Unless required by applicable law or agreed to in writing, software
5308 * distributed under the License is distributed on an "AS IS" BASIS,
5309 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5310 * See the License for the specific language governing permissions and
5311 * limitations under the License.
5312 * =============================================================================
5313 */G().prototype.asin=function(){return this.throwIfDisposed(),op(this)};/**
5314 * @license
5315 * Copyright 2020 Google LLC. All Rights Reserved.
5316 * Licensed under the Apache License, Version 2.0 (the "License");
5317 * you may not use this file except in compliance with the License.
5318 * You may obtain a copy of the License at
5319 *
5320 * http://www.apache.org/licenses/LICENSE-2.0
5321 *
5322 * Unless required by applicable law or agreed to in writing, softw
5322are
5323 * distributed under the License is distributed on an "AS IS" BASIS,
5324 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5325 * See the License for the specific language governing permissions and
5326 * limitations under the License.
5327 * =============================================================================
5328 */G().prototype.asinh=function(){return this.throwIfDisposed(),ip(this)};/**
5329 * @license
5330 * Copyright 2020 Google LLC. All Rights Reserved.
5331 * Licensed under the Apache License, Version 2.0 (the "License");
5332 * you may not use this file except in compliance with the License.
5333 * You may obtain a copy of the License at
5334 *
5335 * http://www.apache.org/licenses/LICENSE-2.0
5336 *
5337 * Unless required by applicable law or agreed to in writing, software
5338 * distributed under the License is distributed on an "AS IS" BASIS,
5339 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5340 * See the License for the specific language governing permissions and
5341 * limitations under the License.
5342 * =============================================================================
5343 */G().prototype.atan=function(){return this.throwIfDisposed(),lp(this)};/**
5344 * @license
5345 * Copyright 2020 Google LLC. All Rights Reserved.
5346 * Licensed under the Apache License, Version 2.0 (the "License");
5347 * you may not use this file except in compliance with the License.
5348 * You may obtain a copy of the License at
5349 *
5350 * http://www.apache.org/licenses/LICENSE-2.0
5351 *
5352 * Unless required by applicable law or agreed to in writing, software
5353 * distributed under the License is distributed on an "AS IS" BASIS,
5354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5355 * See the License for the specific language governing permissions and
5356 * limitations under the License.
5357 * =============================================================================
5358 */G().prototype.atan2=function(n){return this.throwIfDisposed(),up(this,n)};/**
5359 * @license
5360 * Copyright 2020 Google LLC. All Rights Reserved.
5361 * Licensed under the Apache License, Version 2.0 (the "License");
5362 * you may not use this file except in compliance with the License.
5363 * You may obtain a copy of the License at
5364 *
5365 * http://www.apache.org/licenses/LICENSE-2.0
5366 *
5367 * Unless required by applicable law or agreed to in writing, software
5368 * distributed under the License is distributed on an "AS IS" BASIS,
5369 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5370 * See the License for the specific language governing permissions and
5371 * limitations under the License.
5372 * =============================================================================
5373 */G().prototype.atanh=function(){return this.throwIfDisposed(),cp(this)};G().prototype.avgPool=function(n,e,t,s){return this.throwIfDisposed(),Hi(this,n,e,t,s)};/**
5374 * @license
5375 * Copyright 2020 Google LLC. All Rights Reserved.
5376 * Licensed under the Apache License, Version 2.0 (the "License");
5377 * you may not use this file except in compliance with the License.
5378 * You may obtain a copy of the License at
5379 *
5380 * http://www.apache.org/licenses/LICENSE-2.0
5381 *
5382 * Unless required by applicable law or agreed to in writing, software
5383 * distributed under the License is distributed on an "AS IS" BASIS,
5384 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5385 * See the License for the specific language governing permissions and
5386 * limitations under the License.
5387 * =============================================================================
5388 */G().prototype.batchToSpaceND=function(n,e){return this.throwIfDisposed(),ji(this,n,e)};/**
5389 * @license
5390 * Copyright 2020 Google LLC. All Rights Reserved.
5391 * Licensed under the Apache License, Version 2.0 (the "License");
5392 * you may not use this file except in compliance with the License.
5393 * You may obtain a copy of the License at
5394 *
5395 * http://www.apache.org/licenses/LICENSE-2.0
5396 *
5397 * Unless required by applicable law or agreed to in writing, software
5398 * distributed under the License is distributed on an "AS IS" BASIS,
5399 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5400 * See the License for the specific language governing permissions and
5401 * limitations under the License.
5402 * =============================================================================
5403 */G().prototype.batchNorm=function(n,e,t,s,r){return this.throwIfDisposed(),Oa(this,n,e,t,s,r)};/**
5404 * @license
5405 * Copyright 2020 Google LLC. All Rights Reserved.
5406 * Licensed under the Apache License, Version 2.0 (the "License");
5407 * you may not use this file except in compliance with the License.
5408 * You may obtain a copy of the License at
5409 *
5410 * http://www.apache.org/licenses/LICENSE-2.0
5411 *
5412 * Unless required by applicable law or agreed to in writing, software
5413 * distributed under the License is distributed on an "AS IS" BASIS,
5414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5415 * See the License for the specific language governing permissions and
5416 * limitations under the License.
5417 * =============================================================================
5418 */G().prototype.broadcastTo=function(n){return this.throwIfDisposed(),Qs(this,n)};/**
5419 * @license
5420 * Copyright 2020 Google LLC. All Rights Reserved.
5421 * Licensed under the Apache License, Version 2.0 (the "License");
5422 * you may not use this file except in compliance with the License.
5423 * You may obtain a copy of the License at
5424 *
5425 * http://www.apache.org/licenses/LICENSE-2.0
5426 *
5427 * Unless required by applicable law or agreed to in writing, software
5428 * distributed under the License is distributed on an "AS IS" BASIS,
5429 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5430 * See the License for the specific language governing permissions and
5431 * limitations under the License.
5432 * =============================================================================
5433 */G().prototype.cast=function(n){return this.throwIfDisposed(),ee(this,n)};/**
5434 * @license
5435 * Copyright 2020 Google LLC. All Rights Reserved.
5436 * Licensed under the Apache License, Version 2.0 (the "License");
5437 * you may not use this file except in compliance with the License.
5438 * You may obtain a copy of the License at
5439 *
5440 * http://www.apache.org/licenses/LICENSE-2.0
5441 *
5442 * Unless required by applicable law or agreed to in writing, software
5443 * distributed under the License is distributed on an "AS IS" BASIS,
5444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5445 * See the License for the specific language governing permissions and
5446 * limitations under the License.
5447 * =============================================================================
5448 */G().prototype.ceil=function(){return this.throwIfDisposed(),gp(this)};/**
5449 * @license
5450 * Copyright 2020 Google LLC. All Rights Reserved.
5451 * Licensed under the Apache License, Version 2.0 (the "License");
5452 * you may not use this file except in compliance with the License.
5453 * You may obtain a copy of the License at
5454 *
5455 * http://www.apache.org/licenses/LICENSE-2.0
5456 *
5457 * Unless required by applicable law or agreed to in writing, software
5458 * distributed under the License is distributed on an "AS IS" BASIS,
5459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5460 * See the License for the specific language governing permissions and
5461 * limitations under the License.
5462 * =============================================================================
5463 */G().prototype.clipByValue=function(n,e){return this.throwIfDisposed(),Mt(this,n,e)};/**
5464 * @license
5465 * Copyright 2020 Google LLC. All Rights Reserved.
5466 * Licensed under the Apache License, Version 2.0 (the "License");
5467 * you may not use this file except in compliance with the License.
5468 * You may obtain a copy of the License at
5469 *
5470 * http://www.apache.org/licenses/LICENSE-2.0
5471 *
5472 * Unless required by applicable law or agreed to in writing, software
5473 * distributed under the License is distributed on an "AS IS" BASIS,
5474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5475 * See the License for the specific language governing permissions and
5476 * limitations under the License.
5477 * =============================================================================
5478 */G().prototype.concat=function(n,e){return this.throwIfDisposed(),n instanceof lt&&(n=[n]),Je([this,...n],e)};/**
5479 * @license
5480 * Copyright 2020 Google LLC. All Rights Reserved.
5481 * Licensed under the Apache License, Version 2.0 (the "License");
5482 * you may not use this file except in compliance with the License.
5483 * You may obtain a copy of the License at
5484 *
5485 * http://www.apache.org/licenses/LICENSE-2.0
5486 *
5487 * Unless required by applicable law or agreed to in writing, softw
5487are
5488 * distributed under the License is distributed on an "AS IS" BASIS,
5489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5490 * See the License for the specific language governing permissions and
5491 * limitations under the License.
5492 * =============================================================================
5493 */G().prototype.conv1d=function(n,e,t,s,r,a){return this.throwIfDisposed(),Mc(this,n,e,t,s,r,a)};/**
5494 * @license
5495 * Copyright 2020 Google LLC. All Rights Reserved.
5496 * Licensed under the Apache License, Version 2.0 (the "License");
5497 * you may not use this file except in compliance with the License.
5498 * You may obtain a copy of the License at
5499 *
5500 * http://www.apache.org/licenses/LICENSE-2.0
5501 *
5502 * Unless required by applicable law or agreed to in writing, software
5503 * distributed under the License is distributed on an "AS IS" BASIS,
5504 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5505 * See the License for the specific language governing permissions and
5506 * limitations under the License.
5507 * =============================================================================
5508 */G().prototype.conv2dTranspose=function(n,e,t,s,r){return this.throwIfDisposed(),Wc(this,n,e,t,s,r)};/**
5509 * @license
5510 * Copyright 2020 Google LLC. All Rights Reserved.
5511 * Licensed under the Apache License, Version 2.0 (the "License");
5512 * you may not use this file except in compliance with the License.
5513 * You may obtain a copy of the License at
5514 *
5515 * http://www.apache.org/licenses/LICENSE-2.0
5516 *
5517 * Unless required by applicable law or agreed to in writing, software
5518 * distributed under the License is distributed on an "AS IS" BASIS,
5519 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5520 * See the License for the specific language governing permissions and
5521 * limitations under the License.
5522 * =============================================================================
5523 */G().prototype.conv2d=function(n,e,t,s,r,a){return this.throwIfDisposed(),rs(this,n,e,t,s,r,a)};/**
5524 * @license
5525 * Copyright 2020 Google LLC. All Rights Reserved.
5526 * Licensed under the Apache License, Version 2.0 (the "License");
5527 * you may not use this file except in compliance with the License.
5528 * You may obtain a copy of the License at
5529 *
5530 * http://www.apache.org/licenses/LICENSE-2.0
5531 *
5532 * Unless required by applicable law or agreed to in writing, software
5533 * distributed under the License is distributed on an "AS IS" BASIS,
5534 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5535 * See the License for the specific language governing permissions and
5536 * limitations under the License.
5537 * =============================================================================
5538 */G().prototype.cos=function(){return this.throwIfDisposed(),qi(this)};/**
5539 * @license
5540 * Copyright 2020 Google LLC. All Rights Reserved.
5541 * Licensed under the Apache License, Version 2.0 (the "License");
5542 * you may not use this file except in compliance with the License.
5543 * You may obtain a copy of the License at
5544 *
5545 * http://www.apache.org/licenses/LICENSE-2.0
5546 *
5547 * Unless required by applicable law or agreed to in writing, software
5548 * distributed under the License is distributed on an "AS IS" BASIS,
5549 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5550 * See the License for the specific language governing permissions and
5551 * limitations under the License.
5552 * =============================================================================
5553 */G().prototype.cosh=function(){return this.throwIfDisposed(),Uc(this)};/**
5554 * @license
5555 * Copyright 2022 Google LLC. All Rights Reserved.
5556 * Licensed under the Apache License, Version 2.0 (the 'License');
5557 * you may not use this file except in compliance with the License.
5558 * You may obtain a copy of the License at
5559 *
5560 * http://www.apache.org/licenses/LICENSE-2.0
5561 *
5562 * Unless required by applicable law or agreed to in writing, software
5563 * distributed under the License is distributed on an 'AS IS' BASIS,
5564 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5565 * See the License for the specific language governing permissions and
5566 * limitations under the License.
5567 * =============================================================================
5568 */G().prototype.cumprod=function(n,e,t){return this.throwIfDisposed(),Co(this,n,e,t)};/**
5569 * @license
5570 * Copyright 2020 Google LLC. All Rights Reserved.
5571 * Licensed under the Apache License, Version 2.0 (the "License");
5572 * you may not use this file except in compliance with the License.
5573 * You may obtain a copy of the License at
5574 *
5575 * http://www.apache.org/licenses/LICENSE-2.0
5576 *
5577 * Unless required by applicable law or agreed to in writing, software
5578 * distributed under the License is distributed on an "AS IS" BASIS,
5579 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5580 * See the License for the specific language governing permissions and
5581 * limitations under the License.
5582 * =============================================================================
5583 */G().prototype.cumsum=function(n,e,t){return this.throwIfDisposed(),Gc(this,n,e,t)};/**
5584 * @license
5585 * Copyright 2020 Google LLC. All Rights Reserved.
5586 * Licensed under the Apache License, Version 2.0 (the "License");
5587 * you may not use this file except in compliance with the License.
5588 * You may obtain a copy of the License at
5589 *
5590 * http://www.apache.org/licenses/LICENSE-2.0
5591 *
5592 * Unless required by applicable law or agreed to in writing, software
5593 * distributed under the License is distributed on an "AS IS" BASIS,
5594 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5595 * See the License for the specific language governing permissions and
5596 * limitations under the License.
5597 * =============================================================================
5598 */G().prototype.depthToSpace=function(n,e){return this.throwIfDisposed(),Np(this,n,e)};/**
5599 * @license
5600 * Copyright 2020 Google LLC. All Rights Reserved.
5601 * Licensed under the Apache License, Version 2.0 (the "License");
5602 * you may not use this file except in compliance with the License.
5603 * You may obtain a copy of the License at
5604 *
5605 * http://www.apache.org/licenses/LICENSE-2.0
5606 *
5607 * Unless required by applicable law or agreed to in writing, software
5608 * distributed under the License is distributed on an "AS IS" BASIS,
5609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5610 * See the License for the specific language governing permissions and
5611 * limitations under the License.
5612 * =============================================================================
5613 */G().prototype.depthwiseConv2d=function(n,e,t,s,r,a){return this.throwIfDisposed(),_a(this,n,e,t,s,r,a)};/**
5614 * @license
5615 * Copyright 2020 Google LLC. All Rights Reserved.
5616 * Licensed under the Apache License, Version 2.0 (the "License");
5617 * you may not use this file except in compliance with the License.
5618 * You may obtain a copy of the License at
5619 *
5620 * http://www.apache.org/licenses/LICENSE-2.0
5621 *
5622 * Unless required by applicable law or agreed to in writing, software
5623 * distributed under the License is distributed on an "AS IS" BASIS,
5624 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5625 * See the License for the specific language governing permissions and
5626 * limitations under the License.
5627 * =============================================================================
5628 */G().prototype.dilation2d=function(n,e,t,s,r){return this.throwIfDisposed(),Ip(this,n,e,t,s,r)};/**
5629 * @license
5630 * Copyright 2020 Google LLC. All Rights Reserved.
5631 * Licensed under the Apache License, Version 2.0 (the "License");
5632 * you may not use this file except in compliance with the License.
5633 * You may obtain a copy of the License at
5634 *
5635 * http://www.apache.org/licenses/LICENSE-2.0
5636 *
5637 * Unless required by applicable law or agreed to in writing, software
5638 * distributed under the License is distributed on an "AS IS" BASIS,
5639 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5640 * See the License for the specific language governing permissions and
5641 * limitations under the License.
5642 * =============================================================================
5643 */G().prototype.divNoNan=function(n){return this.throwIfDisposed(),Sp(this,n)};/**
5644 * @license
5645 * Copyright 2020 Google LLC. All Rights Reserved.
5646 * Licensed under the Apache License, Version 2.0 (the "License");
5647 * you may not use this file except in compliance with the License.
5648 * You may obtain a copy of the License at
5649 *
5650 * http://www.apache.org/licenses/LICENSE-2.0
5651 *
5652 * Unless required by applicable law or agreed to in writing, softw
5652are
5653 * distributed under the License is distributed on an "AS IS" BASIS,
5654 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5655 * See the License for the specific language governing permissions and
5656 * limitations under the License.
5657 * =============================================================================
5658 */G().prototype.div=function(n){return this.throwIfDisposed(),he(this,n)};/**
5659 * @license
5660 * Copyright 2020 Google LLC. All Rights Reserved.
5661 * Licensed under the Apache License, Version 2.0 (the "License");
5662 * you may not use this file except in compliance with the License.
5663 * You may obtain a copy of the License at
5664 *
5665 * http://www.apache.org/licenses/LICENSE-2.0
5666 *
5667 * Unless required by applicable law or agreed to in writing, software
5668 * distributed under the License is distributed on an "AS IS" BASIS,
5669 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5670 * See the License for the specific language governing permissions and
5671 * limitations under the License.
5672 * =============================================================================
5673 */G().prototype.dot=function(n){return this.throwIfDisposed(),kp(this,n)};/**
5674 * @license
5675 * Copyright 2020 Google LLC. All Rights Reserved.
5676 * Licensed under the Apache License, Version 2.0 (the "License");
5677 * you may not use this file except in compliance with the License.
5678 * You may obtain a copy of the License at
5679 *
5680 * http://www.apache.org/licenses/LICENSE-2.0
5681 *
5682 * Unless required by applicable law or agreed to in writing, software
5683 * distributed under the License is distributed on an "AS IS" BASIS,
5684 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5685 * See the License for the specific language governing permissions and
5686 * limitations under the License.
5687 * =============================================================================
5688 */G().prototype.elu=function(){return this.throwIfDisposed(),Bi(this)};/**
5689 * @license
5690 * Copyright 2020 Google LLC. All Rights Reserved.
5691 * Licensed under the Apache License, Version 2.0 (the "License");
5692 * you may not use this file except in compliance with the License.
5693 * You may obtain a copy of the License at
5694 *
5695 * http://www.apache.org/licenses/LICENSE-2.0
5696 *
5697 * Unless required by applicable law or agreed to in writing, software
5698 * distributed under the License is distributed on an "AS IS" BASIS,
5699 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5700 * See the License for the specific language governing permissions and
5701 * limitations under the License.
5702 * =============================================================================
5703 */G().prototype.equal=function(n){return this.throwIfDisposed(),Yt(this,n)};/**
5704 * @license
5705 * Copyright 2020 Google LLC. All Rights Reserved.
5706 * Licensed under the Apache License, Version 2.0 (the "License");
5707 * you may not use this file except in compliance with the License.
5708 * You may obtain a copy of the License at
5709 *
5710 * http://www.apache.org/licenses/LICENSE-2.0
5711 *
5712 * Unless required by applicable law or agreed to in writing, software
5713 * distributed under the License is distributed on an "AS IS" BASIS,
5714 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5715 * See the License for the specific language governing permissions and
5716 * limitations under the License.
5717 * =============================================================================
5718 */G().prototype.erf=function(){return this.throwIfDisposed(),Hc(this)};/**
5719 * @license
5720 * Copyright 2021 Google LLC. All Rights Reserved.
5721 * Licensed under the Apache License, Version 2.0 (the "License");
5722 * you may not use this file except in compliance with the License.
5723 * You may obtain a copy of the License at
5724 *
5725 * http://www.apache.org/licenses/LICENSE-2.0
5726 *
5727 * Unless required by applicable law or agreed to in writing, software
5728 * distributed under the License is distributed on an "AS IS" BASIS,
5729 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5730 * See the License for the specific language governing permissions and
5731 * limitations under the License.
5732 * =============================================================================
5733 */G().prototype.euclideanNorm=function(n,e){return this.throwIfDisposed(),Tp(this,n,e)};/**
5734 * @license
5735 * Copyright 2020 Google LLC. All Rights Reserved.
5736 * Licensed under the Apache License, Version 2.0 (the "License");
5737 * you may not use this file except in compliance with the License.
5738 * You may obtain a copy of the License at
5739 *
5740 * http://www.apache.org/licenses/LICENSE-2.0
5741 *
5742 * Unless required by applicable law or agreed to in writing, software
5743 * distributed under the License is distributed on an "AS IS" BASIS,
5744 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5745 * See the License for the specific language governing permissions and
5746 * limitations under the License.
5747 * =============================================================================
5748 */G().prototype.exp=function(){return this.throwIfDisposed(),Wt(this)};/**
5749 * @license
5750 * Copyright 2020 Google LLC. All Rights Reserved.
5751 * Licensed under the Apache License, Version 2.0 (the "License");
5752 * you may not use this file except in compliance with the License.
5753 * You may obtain a copy of the License at
5754 *
5755 * http://www.apache.org/licenses/LICENSE-2.0
5756 *
5757 * Unless required by applicable law or agreed to in writing, software
5758 * distributed under the License is distributed on an "AS IS" BASIS,
5759 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5760 * See the License for the specific language governing permissions and
5761 * limitations under the License.
5762 * =============================================================================
5763 */G().prototype.expandDims=function(n){return this.throwIfDisposed(),mt(this,n)};/**
5764 * @license
5765 * Copyright 2020 Google LLC. All Rights Reserved.
5766 * Licensed under the Apache License, Version 2.0 (the "License");
5767 * you may not use this file except in compliance with the License.
5768 * You may obtain a copy of the License at
5769 *
5770 * http://www.apache.org/licenses/LICENSE-2.0
5771 *
5772 * Unless required by applicable law or agreed to in writing, software
5773 * distributed under the License is distributed on an "AS IS" BASIS,
5774 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5775 * See the License for the specific language governing permissions and
5776 * limitations under the License.
5777 * =============================================================================
5778 */G().prototype.expm1=function(){return this.throwIfDisposed(),Ep(this)};/**
5779 * @license
5780 * Copyright 2020 Google LLC. All Rights Reserved.
5781 * Licensed under the Apache License, Version 2.0 (the "License");
5782 * you may not use this file except in compliance with the License.
5783 * You may obtain a copy of the License at
5784 *
5785 * http://www.apache.org/licenses/LICENSE-2.0
5786 *
5787 * Unless required by applicable law or agreed to in writing, software
5788 * distributed under the License is distributed on an "AS IS" BASIS,
5789 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5790 * See the License for the specific language governing permissions and
5791 * limitations under the License.
5792 * =============================================================================
5793 */G().prototype.fft=function(){return this.throwIfDisposed(),rl(this)};/**
5794 * @license
5795 * Copyright 2020 Google LLC. All Rights Reserved.
5796 * Licensed under the Apache License, Version 2.0 (the "License");
5797 * you may not use this file except in compliance with the License.
5798 * You may obtain a copy of the License at
5799 *
5800 * http://www.apache.org/licenses/LICENSE-2.0
5801 *
5802 * Unless required by applicable law or agreed to in writing, software
5803 * distributed under the License is distributed on an "AS IS" BASIS,
5804 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5805 * See the License for the specific language governing permissions and
5806 * limitations under the License.
5807 * =============================================================================
5808 */G().prototype.flatten=function(){return this.throwIfDisposed(),D(this,[this.size])};/**
5809 * @license
5810 * Copyright 2020 Google LLC. All Rights Reserved.
5811 * Licensed under the Apache License, Version 2.0 (the "License");
5812 * you may not use this file except in compliance with the License.
5813 * You may obtain a copy of the License at
5814 *
5815 * http://www.apache.org/licenses/LICENSE-2.0
5816 *
5817 * Unless required by applicable law or agreed to in writing, softw
5817are
5818 * distributed under the License is distributed on an "AS IS" BASIS,
5819 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5820 * See the License for the specific language governing permissions and
5821 * limitations under the License.
5822 * =============================================================================
5823 */G().prototype.floor=function(){return this.throwIfDisposed(),La(this)};/**
5824 * @license
5825 * Copyright 2020 Google LLC. All Rights Reserved.
5826 * Licensed under the Apache License, Version 2.0 (the "License");
5827 * you may not use this file except in compliance with the License.
5828 * You may obtain a copy of the License at
5829 *
5830 * http://www.apache.org/licenses/LICENSE-2.0
5831 *
5832 * Unless required by applicable law or agreed to in writing, software
5833 * distributed under the License is distributed on an "AS IS" BASIS,
5834 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5835 * See the License for the specific language governing permissions and
5836 * limitations under the License.
5837 * =============================================================================
5838 */G().prototype.floorDiv=function(n){return this.throwIfDisposed(),Hd(this,n)};/**
5839 * @license
5840 * Copyright 2020 Google LLC. All Rights Reserved.
5841 * Licensed under the Apache License, Version 2.0 (the "License");
5842 * you may not use this file except in compliance with the License.
5843 * You may obtain a copy of the License at
5844 *
5845 * http://www.apache.org/licenses/LICENSE-2.0
5846 *
5847 * Unless required by applicable law or agreed to in writing, software
5848 * distributed under the License is distributed on an "AS IS" BASIS,
5849 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5850 * See the License for the specific language governing permissions and
5851 * limitations under the License.
5852 * =============================================================================
5853 */G().prototype.gather=function(n,e,t){return this.throwIfDisposed(),Pa(this,n,e,t)};/**
5854 * @license
5855 * Copyright 2020 Google LLC. All Rights Reserved.
5856 * Licensed under the Apache License, Version 2.0 (the "License");
5857 * you may not use this file except in compliance with the License.
5858 * You may obtain a copy of the License at
5859 *
5860 * http://www.apache.org/licenses/LICENSE-2.0
5861 *
5862 * Unless required by applicable law or agreed to in writing, software
5863 * distributed under the License is distributed on an "AS IS" BASIS,
5864 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5865 * See the License for the specific language governing permissions and
5866 * limitations under the License.
5867 * =============================================================================
5868 */G().prototype.greaterEqual=function(n){return this.throwIfDisposed(),os(this,n)};/**
5869 * @license
5870 * Copyright 2020 Google LLC. All Rights Reserved.
5871 * Licensed under the Apache License, Version 2.0 (the "License");
5872 * you may not use this file except in compliance with the License.
5873 * You may obtain a copy of the License at
5874 *
5875 * http://www.apache.org/licenses/LICENSE-2.0
5876 *
5877 * Unless required by applicable law or agreed to in writing, software
5878 * distributed under the License is distributed on an "AS IS" BASIS,
5879 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5880 * See the License for the specific language governing permissions and
5881 * limitations under the License.
5882 * =============================================================================
5883 */G().prototype.greater=function(n){return this.throwIfDisposed(),Lt(this,n)};/**
5884 * @license
5885 * Copyright 2020 Google LLC. All Rights Reserved.
5886 * Licensed under the Apache License, Version 2.0 (the "License");
5887 * you may not use this file except in compliance with the License.
5888 * You may obtain a copy of the License at
5889 *
5890 * http://www.apache.org/licenses/LICENSE-2.0
5891 *
5892 * Unless required by applicable law or agreed to in writing, software
5893 * distributed under the License is distributed on an "AS IS" BASIS,
5894 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5895 * See the License for the specific language governing permissions and
5896 * limitations under the License.
5897 * =============================================================================
5898 */G().prototype.ifft=function(){return this.throwIfDisposed(),zr(this)};/**
5899 * @license
5900 * Copyright 2020 Google LLC. All Rights Reserved.
5901 * Licensed under the Apache License, Version 2.0 (the "License");
5902 * you may not use this file except in compliance with the License.
5903 * You may obtain a copy of the License at
5904 *
5905 * http://www.apache.org/licenses/LICENSE-2.0
5906 *
5907 * Unless required by applicable law or agreed to in writing, software
5908 * distributed under the License is distributed on an "AS IS" BASIS,
5909 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5910 * See the License for the specific language governing permissions and
5911 * limitations under the License.
5912 * =============================================================================
5913 */G().prototype.irfft=function(){return this.throwIfDisposed(),rh(this)};/**
5914 * @license
5915 * Copyright 2020 Google LLC. All Rights Reserved.
5916 * Licensed under the Apache License, Version 2.0 (the "License");
5917 * you may not use this file except in compliance with the License.
5918 * You may obtain a copy of the License at
5919 *
5920 * http://www.apache.org/licenses/LICENSE-2.0
5921 *
5922 * Unless required by applicable law or agreed to in writing, software
5923 * distributed under the License is distributed on an "AS IS" BASIS,
5924 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5925 * See the License for the specific language governing permissions and
5926 * limitations under the License.
5927 * =============================================================================
5928 */G().prototype.isFinite=function(){return this.throwIfDisposed(),Rp(this)};/**
5929 * @license
5930 * Copyright 2020 Google LLC. All Rights Reserved.
5931 * Licensed under the Apache License, Version 2.0 (the "License");
5932 * you may not use this file except in compliance with the License.
5933 * You may obtain a copy of the License at
5934 *
5935 * http://www.apache.org/licenses/LICENSE-2.0
5936 *
5937 * Unless required by applicable law or agreed to in writing, software
5938 * distributed under the License is distributed on an "AS IS" BASIS,
5939 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5940 * See the License for the specific language governing permissions and
5941 * limitations under the License.
5942 * =============================================================================
5943 */G().prototype.isInf=function(){return this.throwIfDisposed(),Dp(this)};/**
5944 * @license
5945 * Copyright 2020 Google LLC. All Rights Reserved.
5946 * Licensed under the Apache License, Version 2.0 (the "License");
5947 * you may not use this file except in compliance with the License.
5948 * You may obtain a copy of the License at
5949 *
5950 * http://www.apache.org/licenses/LICENSE-2.0
5951 *
5952 * Unless required by applicable law or agreed to in writing, software
5953 * distributed under the License is distributed on an "AS IS" BASIS,
5954 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5955 * See the License for the specific language governing permissions and
5956 * limitations under the License.
5957 * =============================================================================
5958 */G().prototype.isNaN=function(){return this.throwIfDisposed(),Ap(this)};/**
5959 * @license
5960 * Copyright 2020 Google LLC. All Rights Reserved.
5961 * Licensed under the Apache License, Version 2.0 (the "License");
5962 * you may not use this file except in compliance with the License.
5963 * You may obtain a copy of the License at
5964 *
5965 * http://www.apache.org/licenses/LICENSE-2.0
5966 *
5967 * Unless required by applicable law or agreed to in writing, software
5968 * distributed under the License is distributed on an "AS IS" BASIS,
5969 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5970 * See the License for the specific language governing permissions and
5971 * limitations under the License.
5972 * =============================================================================
5973 */G().prototype.leakyRelu=function(n){return this.throwIfDisposed(),Ac(this,n)};/**
5974 * @license
5975 * Copyright 2020 Google LLC. All Rights Reserved.
5976 * Licensed under the Apache License, Version 2.0 (the "License");
5977 * you may not use this file except in compliance with the License.
5978 * You may obtain a copy of the License at
5979 *
5980 * http://www.apache.org/licenses/LICENSE-2.0
5981 *
5982 * Unless required by applicable law or agreed to in writing, softw
5982are
5983 * distributed under the License is distributed on an "AS IS" BASIS,
5984 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5985 * See the License for the specific language governing permissions and
5986 * limitations under the License.
5987 * =============================================================================
5988 */G().prototype.lessEqual=function(n){return this.throwIfDisposed(),Ls(this,n)};/**
5989 * @license
5990 * Copyright 2020 Google LLC. All Rights Reserved.
5991 * Licensed under the Apache License, Version 2.0 (the "License");
5992 * you may not use this file except in compliance with the License.
5993 * You may obtain a copy of the License at
5994 *
5995 * http://www.apache.org/licenses/LICENSE-2.0
5996 *
5997 * Unless required by applicable law or agreed to in writing, software
5998 * distributed under the License is distributed on an "AS IS" BASIS,
5999 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6000 * See the License for the specific language governing permissions and
6001 * limitations under the License.
6002 * =============================================================================
6003 */G().prototype.less=function(n){return this.throwIfDisposed(),_r(this,n)};/**
6004 * @license
6005 * Copyright 2020 Google LLC. All Rights Reserved.
6006 * Licensed under the Apache License, Version 2.0 (the "License");
6007 * you may not use this file except in compliance with the License.
6008 * You may obtain a copy of the License at
6009 *
6010 * http://www.apache.org/licenses/LICENSE-2.0
6011 *
6012 * Unless required by applicable law or agreed to in writing, software
6013 * distributed under the License is distributed on an "AS IS" BASIS,
6014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6015 * See the License for the specific language governing permissions and
6016 * limitations under the License.
6017 * =============================================================================
6018 */G().prototype.localResponseNormalization=function(n,e,t,s){return this.throwIfDisposed(),Op(this,n,e,t,s)};/**
6019 * @license
6020 * Copyright 2020 Google LLC. All Rights Reserved.
6021 * Licensed under the Apache License, Version 2.0 (the "License");
6022 * you may not use this file except in compliance with the License.
6023 * You may obtain a copy of the License at
6024 *
6025 * http://www.apache.org/licenses/LICENSE-2.0
6026 *
6027 * Unless required by applicable law or agreed to in writing, software
6028 * distributed under the License is distributed on an "AS IS" BASIS,
6029 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6030 * See the License for the specific language governing permissions and
6031 * limitations under the License.
6032 * =============================================================================
6033 */G().prototype.logSigmoid=function(){return this.throwIfDisposed(),_p(this)};/**
6034 * @license
6035 * Copyright 2020 Google LLC. All Rights Reserved.
6036 * Licensed under the Apache License, Version 2.0 (the "License");
6037 * you may not use this file except in compliance with the License.
6038 * You may obtain a copy of the License at
6039 *
6040 * http://www.apache.org/licenses/LICENSE-2.0
6041 *
6042 * Unless required by applicable law or agreed to in writing, software
6043 * distributed under the License is distributed on an "AS IS" BASIS,
6044 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6045 * See the License for the specific language governing permissions and
6046 * limitations under the License.
6047 * =============================================================================
6048 */G().prototype.logSoftmax=function(n){return this.throwIfDisposed(),qc(this,n)};/**
6049 * @license
6050 * Copyright 2020 Google LLC. All Rights Reserved.
6051 * Licensed under the Apache License, Version 2.0 (the "License");
6052 * you may not use this file except in compliance with the License.
6053 * You may obtain a copy of the License at
6054 *
6055 * http://www.apache.org/licenses/LICENSE-2.0
6056 *
6057 * Unless required by applicable law or agreed to in writing, software
6058 * distributed under the License is distributed on an "AS IS" BASIS,
6059 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6060 * See the License for the specific language governing permissions and
6061 * limitations under the License.
6062 * =============================================================================
6063 */G().prototype.logSumExp=function(n,e){return this.throwIfDisposed(),Yi(this,n,e)};/**
6064 * @license
6065 * Copyright 2020 Google LLC. All Rights Reserved.
6066 * Licensed under the Apache License, Version 2.0 (the "License");
6067 * you may not use this file except in compliance with the License.
6068 * You may obtain a copy of the License at
6069 *
6070 * http://www.apache.org/licenses/LICENSE-2.0
6071 *
6072 * Unless required by applicable law or agreed to in writing, software
6073 * distributed under the License is distributed on an "AS IS" BASIS,
6074 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6075 * See the License for the specific language governing permissions and
6076 * limitations under the License.
6077 * =============================================================================
6078 */G().prototype.log=function(){return this.throwIfDisposed(),Jt(this)};/**
6079 * @license
6080 * Copyright 2020 Google LLC. All Rights Reserved.
6081 * Licensed under the Apache License, Version 2.0 (the "License");
6082 * you may not use this file except in compliance with the License.
6083 * You may obtain a copy of the License at
6084 *
6085 * http://www.apache.org/licenses/LICENSE-2.0
6086 *
6087 * Unless required by applicable law or agreed to in writing, software
6088 * distributed under the License is distributed on an "AS IS" BASIS,
6089 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6090 * See the License for the specific language governing permissions and
6091 * limitations under the License.
6092 * =============================================================================
6093 */G().prototype.log1p=function(){return this.throwIfDisposed(),Xi(this)};/**
6094 * @license
6095 * Copyright 2020 Google LLC. All Rights Reserved.
6096 * Licensed under the Apache License, Version 2.0 (the "License");
6097 * you may not use this file except in compliance with the License.
6098 * You may obtain a copy of the License at
6099 *
6100 * http://www.apache.org/licenses/LICENSE-2.0
6101 *
6102 * Unless required by applicable law or agreed to in writing, software
6103 * distributed under the License is distributed on an "AS IS" BASIS,
6104 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6105 * See the License for the specific language governing permissions and
6106 * limitations under the License.
6107 * =============================================================================
6108 */G().prototype.logicalAnd=function(n){return this.throwIfDisposed(),wn(this,n)};/**
6109 * @license
6110 * Copyright 2020 Google LLC. All Rights Reserved.
6111 * Licensed under the Apache License, Version 2.0 (the "License");
6112 * you may not use this file except in compliance with the License.
6113 * You may obtain a copy of the License at
6114 *
6115 * http://www.apache.org/licenses/LICENSE-2.0
6116 *
6117 * Unless required by applicable law or agreed to in writing, software
6118 * distributed under the License is distributed on an "AS IS" BASIS,
6119 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6120 * See the License for the specific language governing permissions and
6121 * limitations under the License.
6122 * =============================================================================
6123 */G().prototype.logicalNot=function(){return this.throwIfDisposed(),Ji(this)};/**
6124 * @license
6125 * Copyright 2020 Google LLC. All Rights Reserved.
6126 * Licensed under the Apache License, Version 2.0 (the "License");
6127 * you may not use this file except in compliance with the License.
6128 * You may obtain a copy of the License at
6129 *
6130 * http://www.apache.org/licenses/LICENSE-2.0
6131 *
6132 * Unless required by applicable law or agreed to in writing, software
6133 * distributed under the License is distributed on an "AS IS" BASIS,
6134 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6135 * See the License for the specific language governing permissions and
6136 * limitations under the License.
6137 * =============================================================================
6138 */G().prototype.logicalOr=function(n){return this.throwIfDisposed(),Kc(this,n)};/**
6139 * @license
6140 * Copyright 2020 Google LLC. All Rights Reserved.
6141 * Licensed under the Apache License, Version 2.0 (the "License");
6142 * you may not use this file except in compliance with the License.
6143 * You may obtain a copy of the License at
6144 *
6145 * http://www.apache.org/licenses/LICENSE-2.0
6146 *
6147 * Unless required by applicable law or agreed to in writing, softw
6147are
6148 * distributed under the License is distributed on an "AS IS" BASIS,
6149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6150 * See the License for the specific language governing permissions and
6151 * limitations under the License.
6152 * =============================================================================
6153 */G().prototype.logicalXor=function(n){return this.throwIfDisposed(),Fp(this,n)};/**
6154 * @license
6155 * Copyright 2020 Google LLC. All Rights Reserved.
6156 * Licensed under the Apache License, Version 2.0 (the "License");
6157 * you may not use this file except in compliance with the License.
6158 * You may obtain a copy of the License at
6159 *
6160 * http://www.apache.org/licenses/LICENSE-2.0
6161 *
6162 * Unless required by applicable law or agreed to in writing, software
6163 * distributed under the License is distributed on an "AS IS" BASIS,
6164 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6165 * See the License for the specific language governing permissions and
6166 * limitations under the License.
6167 * =============================================================================
6168 */G().prototype.matMul=function(n,e,t){return this.throwIfDisposed(),ve(this,n,e,t)};G().prototype.maxPool=function(n,e,t,s){return this.throwIfDisposed(),Zi(this,n,e,t,s)};/**
6169 * @license
6170 * Copyright 2020 Google LLC. All Rights Reserved.
6171 * Licensed under the Apache License, Version 2.0 (the "License");
6172 * you may not use this file except in compliance with the License.
6173 * You may obtain a copy of the License at
6174 *
6175 * http://www.apache.org/licenses/LICENSE-2.0
6176 *
6177 * Unless required by applicable law or agreed to in writing, software
6178 * distributed under the License is distributed on an "AS IS" BASIS,
6179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6180 * See the License for the specific language governing permissions and
6181 * limitations under the License.
6182 * =============================================================================
6183 */G().prototype.max=function(n,e){return this.throwIfDisposed(),on(this,n,e)};/**
6184 * @license
6185 * Copyright 2020 Google LLC. All Rights Reserved.
6186 * Licensed under the Apache License, Version 2.0 (the "License");
6187 * you may not use this file except in compliance with the License.
6188 * You may obtain a copy of the License at
6189 *
6190 * http://www.apache.org/licenses/LICENSE-2.0
6191 *
6192 * Unless required by applicable law or agreed to in writing, software
6193 * distributed under the License is distributed on an "AS IS" BASIS,
6194 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6195 * See the License for the specific language governing permissions and
6196 * limitations under the License.
6197 * =============================================================================
6198 */G().prototype.maximum=function(n){return this.throwIfDisposed(),as(this,n)};/**
6199 * @license
6200 * Copyright 2020 Google LLC. All Rights Reserved.
6201 * Licensed under the Apache License, Version 2.0 (the "License");
6202 * you may not use this file except in compliance with the License.
6203 * You may obtain a copy of the License at
6204 *
6205 * http://www.apache.org/licenses/LICENSE-2.0
6206 *
6207 * Unless required by applicable law or agreed to in writing, software
6208 * distributed under the License is distributed on an "AS IS" BASIS,
6209 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6210 * See the License for the specific language governing permissions and
6211 * limitations under the License.
6212 * =============================================================================
6213 */G().prototype.mean=function(n,e){return this.throwIfDisposed(),je(this,n,e)};/**
6214 * @license
6215 * Copyright 2020 Google LLC. All Rights Reserved.
6216 * Licensed under the Apache License, Version 2.0 (the "License");
6217 * you may not use this file except in compliance with the License.
6218 * You may obtain a copy of the License at
6219 *
6220 * http://www.apache.org/licenses/LICENSE-2.0
6221 *
6222 * Unless required by applicable law or agreed to in writing, software
6223 * distributed under the License is distributed on an "AS IS" BASIS,
6224 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6225 * See the License for the specific language governing permissions and
6226 * limitations under the License.
6227 * =============================================================================
6228 */G().prototype.min=function(n,e){return this.throwIfDisposed(),Or(this,n,e)};/**
6229 * @license
6230 * Copyright 2020 Google LLC. All Rights Reserved.
6231 * Licensed under the Apache License, Version 2.0 (the "License");
6232 * you may not use this file except in compliance with the License.
6233 * You may obtain a copy of the License at
6234 *
6235 * http://www.apache.org/licenses/LICENSE-2.0
6236 *
6237 * Unless required by applicable law or agreed to in writing, software
6238 * distributed under the License is distributed on an "AS IS" BASIS,
6239 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6240 * See the License for the specific language governing permissions and
6241 * limitations under the License.
6242 * =============================================================================
6243 */G().prototype.minimum=function(n){return this.throwIfDisposed(),Ss(this,n)};/**
6244 * @license
6245 * Copyright 2020 Google LLC. All Rights Reserved.
6246 * Licensed under the Apache License, Version 2.0 (the "License");
6247 * you may not use this file except in compliance with the License.
6248 * You may obtain a copy of the License at
6249 *
6250 * http://www.apache.org/licenses/LICENSE-2.0
6251 *
6252 * Unless required by applicable law or agreed to in writing, software
6253 * distributed under the License is distributed on an "AS IS" BASIS,
6254 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6255 * See the License for the specific language governing permissions and
6256 * limitations under the License.
6257 * =============================================================================
6258 */G().prototype.mirrorPad=function(n,e){return this.throwIfDisposed(),Pp(this,n,e)};/**
6259 * @license
6260 * Copyright 2020 Google LLC. All Rights Reserved.
6261 * Licensed under the Apache License, Version 2.0 (the "License");
6262 * you may not use this file except in compliance with the License.
6263 * You may obtain a copy of the License at
6264 *
6265 * http://www.apache.org/licenses/LICENSE-2.0
6266 *
6267 * Unless required by applicable law or agreed to in writing, software
6268 * distributed under the License is distributed on an "AS IS" BASIS,
6269 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6270 * See the License for the specific language governing permissions and
6271 * limitations under the License.
6272 * =============================================================================
6273 */G().prototype.mod=function(n){return this.throwIfDisposed(),zp(this,n)};/**
6274 * @license
6275 * Copyright 2020 Google LLC. All Rights Reserved.
6276 * Licensed under the Apache License, Version 2.0 (the "License");
6277 * you may not use this file except in compliance with the License.
6278 * You may obtain a copy of the License at
6279 *
6280 * http://www.apache.org/licenses/LICENSE-2.0
6281 *
6282 * Unless required by applicable law or agreed to in writing, software
6283 * distributed under the License is distributed on an "AS IS" BASIS,
6284 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6285 * See the License for the specific language governing permissions and
6286 * limitations under the License.
6287 * =============================================================================
6288 */G().prototype.mul=function(n){return this.throwIfDisposed(),O(this,n)};/**
6289 * @license
6290 * Copyright 2020 Google LLC. All Rights Reserved.
6291 * Licensed under the Apache License, Version 2.0 (the "License");
6292 * you may not use this file except in compliance with the License.
6293 * You may obtain a copy of the License at
6294 *
6295 * http://www.apache.org/licenses/LICENSE-2.0
6296 *
6297 * Unless required by applicable law or agreed to in writing, software
6298 * distributed under the License is distributed on an "AS IS" BASIS,
6299 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6300 * See the License for the specific language governing permissions and
6301 * limitations under the License.
6302 * =============================================================================
6303 */G().prototype.neg=function(){return this.throwIfDisposed(),Ve(this)};/**
6304 * @license
6305 * Copyright 2020 Google LLC. All Rights Reserved.
6306 * Licensed under the Apache License, Version 2.0 (the "License");
6307 * you may not use this file except in compliance with the License.
6308 * You may obtain a copy of the License at
6309 *
6310 * http://www.apache.org/licenses/LICENSE-2.0
6311 *
6312 * Unless required by applicable law or agreed to in writing, softw
6312are
6313 * distributed under the License is distributed on an "AS IS" BASIS,
6314 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6315 * See the License for the specific language governing permissions and
6316 * limitations under the License.
6317 * =============================================================================
6318 */G().prototype.norm=function(n,e,t){return this.throwIfDisposed(),Fa(this,n,e,t)};/**
6319 * @license
6320 * Copyright 2020 Google LLC. All Rights Reserved.
6321 * Licensed under the Apache License, Version 2.0 (the "License");
6322 * you may not use this file except in compliance with the License.
6323 * You may obtain a copy of the License at
6324 *
6325 * http://www.apache.org/licenses/LICENSE-2.0
6326 *
6327 * Unless required by applicable law or agreed to in writing, software
6328 * distributed under the License is distributed on an "AS IS" BASIS,
6329 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6330 * See the License for the specific language governing permissions and
6331 * limitations under the License.
6332 * =============================================================================
6333 */G().prototype.notEqual=function(n){return this.throwIfDisposed(),sr(this,n)};/**
6334 * @license
6335 * Copyright 2020 Google LLC. All Rights Reserved.
6336 * Licensed under the Apache License, Version 2.0 (the "License");
6337 * you may not use this file except in compliance with the License.
6338 * You may obtain a copy of the License at
6339 *
6340 * http://www.apache.org/licenses/LICENSE-2.0
6341 *
6342 * Unless required by applicable law or agreed to in writing, software
6343 * distributed under the License is distributed on an "AS IS" BASIS,
6344 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6345 * See the License for the specific language governing permissions and
6346 * limitations under the License.
6347 * =============================================================================
6348 */G().prototype.oneHot=function(n,e=1,t=0){return this.throwIfDisposed(),Fr(this,n,e,t)};/**
6349 * @license
6350 * Copyright 2020 Google LLC. All Rights Reserved.
6351 * Licensed under the Apache License, Version 2.0 (the "License");
6352 * you may not use this file except in compliance with the License.
6353 * You may obtain a copy of the License at
6354 *
6355 * http://www.apache.org/licenses/LICENSE-2.0
6356 *
6357 * Unless required by applicable law or agreed to in writing, software
6358 * distributed under the License is distributed on an "AS IS" BASIS,
6359 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6360 * See the License for the specific language governing permissions and
6361 * limitations under the License.
6362 * =============================================================================
6363 */G().prototype.onesLike=function(){return this.throwIfDisposed(),Zt(this)};/**
6364 * @license
6365 * Copyright 2020 Google LLC. All Rights Reserved.
6366 * Licensed under the Apache License, Version 2.0 (the "License");
6367 * you may not use this file except in compliance with the License.
6368 * You may obtain a copy of the License at
6369 *
6370 * http://www.apache.org/licenses/LICENSE-2.0
6371 *
6372 * Unless required by applicable law or agreed to in writing, software
6373 * distributed under the License is distributed on an "AS IS" BASIS,
6374 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6375 * See the License for the specific language governing permissions and
6376 * limitations under the License.
6377 * =============================================================================
6378 */G().prototype.pad=function(n,e){return this.throwIfDisposed(),is(this,n,e)};G().prototype.pool=function(n,e,t,s,r,a){return this.throwIfDisposed(),Vp(this,n,e,t,s,r,a)};/**
6379 * @license
6380 * Copyright 2020 Google LLC. All Rights Reserved.
6381 * Licensed under the Apache License, Version 2.0 (the "License");
6382 * you may not use this file except in compliance with the License.
6383 * You may obtain a copy of the License at
6384 *
6385 * http://www.apache.org/licenses/LICENSE-2.0
6386 *
6387 * Unless required by applicable law or agreed to in writing, software
6388 * distributed under the License is distributed on an "AS IS" BASIS,
6389 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6390 * See the License for the specific language governing permissions and
6391 * limitations under the License.
6392 * =============================================================================
6393 */G().prototype.pow=function(n){return this.throwIfDisposed(),As(this,n)};/**
6394 * @license
6395 * Copyright 2020 Google LLC. All Rights Reserved.
6396 * Licensed under the Apache License, Version 2.0 (the "License");
6397 * you may not use this file except in compliance with the License.
6398 * You may obtain a copy of the License at
6399 *
6400 * http://www.apache.org/licenses/LICENSE-2.0
6401 *
6402 * Unless required by applicable law or agreed to in writing, software
6403 * distributed under the License is distributed on an "AS IS" BASIS,
6404 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6405 * See the License for the specific language governing permissions and
6406 * limitations under the License.
6407 * =============================================================================
6408 */G().prototype.prelu=function(n){return this.throwIfDisposed(),Oc(this,n)};/**
6409 * @license
6410 * Copyright 2020 Google LLC. All Rights Reserved.
6411 * Licensed under the Apache License, Version 2.0 (the "License");
6412 * you may not use this file except in compliance with the License.
6413 * You may obtain a copy of the License at
6414 *
6415 * http://www.apache.org/licenses/LICENSE-2.0
6416 *
6417 * Unless required by applicable law or agreed to in writing, software
6418 * distributed under the License is distributed on an "AS IS" BASIS,
6419 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6420 * See the License for the specific language governing permissions and
6421 * limitations under the License.
6422 * =============================================================================
6423 */G().prototype.prod=function(n,e){return this.throwIfDisposed(),Bp(this,n,e)};/**
6424 * @license
6425 * Copyright 2020 Google LLC. All Rights Reserved.
6426 * Licensed under the Apache License, Version 2.0 (the "License");
6427 * you may not use this file except in compliance with the License.
6428 * You may obtain a copy of the License at
6429 *
6430 * http://www.apache.org/licenses/LICENSE-2.0
6431 *
6432 * Unless required by applicable law or agreed to in writing, software
6433 * distributed under the License is distributed on an "AS IS" BASIS,
6434 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6435 * See the License for the specific language governing permissions and
6436 * limitations under the License.
6437 * =============================================================================
6438 */G().prototype.reciprocal=function(){return this.throwIfDisposed(),Yp(this)};/**
6439 * @license
6440 * Copyright 2020 Google LLC. All Rights Reserved.
6441 * Licensed under the Apache License, Version 2.0 (the "License");
6442 * you may not use this file except in compliance with the License.
6443 * You may obtain a copy of the License at
6444 *
6445 * http://www.apache.org/licenses/LICENSE-2.0
6446 *
6447 * Unless required by applicable law or agreed to in writing, software
6448 * distributed under the License is distributed on an "AS IS" BASIS,
6449 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6450 * See the License for the specific language governing permissions and
6451 * limitations under the License.
6452 * =============================================================================
6453 */G().prototype.relu=function(){return this.throwIfDisposed(),Kn(this)};/**
6454 * @license
6455 * Copyright 2020 Google LLC. All Rights Reserved.
6456 * Licensed under the Apache License, Version 2.0 (the "License");
6457 * you may not use this file except in compliance with the License.
6458 * You may obtain a copy of the License at
6459 *
6460 * http://www.apache.org/licenses/LICENSE-2.0
6461 *
6462 * Unless required by applicable law or agreed to in writing, software
6463 * distributed under the License is distributed on an "AS IS" BASIS,
6464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6465 * See the License for the specific language governing permissions and
6466 * limitations under the License.
6467 * =============================================================================
6468 */G().prototype.relu6=function(){return this.throwIfDisposed(),jd(this)};/**
6469 * @license
6470 * Copyright 2020 Google LLC. All Rights Reserved.
6471 * Licensed under the Apache License, Version 2.0 (the "License");
6472 * you may not use this file except in compliance with the License.
6473 * You may obtain a copy of the License at
6474 *
6475 * http://www.apache.org/licenses/LICENSE-2.0
6476 *
6477 * Unless required by applicable law or agreed to in writing, softw
6477are
6478 * distributed under the License is distributed on an "AS IS" BASIS,
6479 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6480 * See the License for the specific language governing permissions and
6481 * limitations under the License.
6482 * =============================================================================
6483 */G().prototype.reshapeAs=function(n){return this.throwIfDisposed(),D(this,n.shape)};/**
6484 * @license
6485 * Copyright 2020 Google LLC. All Rights Reserved.
6486 * Licensed under the Apache License, Version 2.0 (the "License");
6487 * you may not use this file except in compliance with the License.
6488 * You may obtain a copy of the License at
6489 *
6490 * http://www.apache.org/licenses/LICENSE-2.0
6491 *
6492 * Unless required by applicable law or agreed to in writing, software
6493 * distributed under the License is distributed on an "AS IS" BASIS,
6494 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6495 * See the License for the specific language governing permissions and
6496 * limitations under the License.
6497 * =============================================================================
6498 */G().prototype.reshape=function(n){return this.throwIfDisposed(),D(this,n)};/**
6499 * @license
6500 * Copyright 2020 Google LLC. All Rights Reserved.
6501 * Licensed under the Apache License, Version 2.0 (the "License");
6502 * you may not use this file except in compliance with the License.
6503 * You may obtain a copy of the License at
6504 *
6505 * http://www.apache.org/licenses/LICENSE-2.0
6506 *
6507 * Unless required by applicable law or agreed to in writing, software
6508 * distributed under the License is distributed on an "AS IS" BASIS,
6509 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6510 * See the License for the specific language governing permissions and
6511 * limitations under the License.
6512 * =============================================================================
6513 */G().prototype.resizeBilinear=function(n,e,t){return this.throwIfDisposed(),jb(this,n,e,t)};/**
6514 * @license
6515 * Copyright 2020 Google LLC. All Rights Reserved.
6516 * Licensed under the Apache License, Version 2.0 (the "License");
6517 * you may not use this file except in compliance with the License.
6518 * You may obtain a copy of the License at
6519 *
6520 * http://www.apache.org/licenses/LICENSE-2.0
6521 *
6522 * Unless required by applicable law or agreed to in writing, software
6523 * distributed under the License is distributed on an "AS IS" BASIS,
6524 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6525 * See the License for the specific language governing permissions and
6526 * limitations under the License.
6527 * =============================================================================
6528 */G().prototype.resizeNearestNeighbor=function(n,e,t){return this.throwIfDisposed(),qb(this,n,e,t)};/**
6529 * @license
6530 * Copyright 2020 Google LLC. All Rights Reserved.
6531 * Licensed under the Apache License, Version 2.0 (the "License");
6532 * you may not use this file except in compliance with the License.
6533 * You may obtain a copy of the License at
6534 *
6535 * http://www.apache.org/licenses/LICENSE-2.0
6536 *
6537 * Unless required by applicable law or agreed to in writing, software
6538 * distributed under the License is distributed on an "AS IS" BASIS,
6539 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6540 * See the License for the specific language governing permissions and
6541 * limitations under the License.
6542 * =============================================================================
6543 */G().prototype.reverse=function(n){return this.throwIfDisposed(),un(this,n)};/**
6544 * @license
6545 * Copyright 2020 Google LLC. All Rights Reserved.
6546 * Licensed under the Apache License, Version 2.0 (the "License");
6547 * you may not use this file except in compliance with the License.
6548 * You may obtain a copy of the License at
6549 *
6550 * http://www.apache.org/licenses/LICENSE-2.0
6551 *
6552 * Unless required by applicable law or agreed to in writing, software
6553 * distributed under the License is distributed on an "AS IS" BASIS,
6554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6555 * See the License for the specific language governing permissions and
6556 * limitations under the License.
6557 * =============================================================================
6558 */G().prototype.rfft=function(){return this.throwIfDisposed(),al(this)};/**
6559 * @license
6560 * Copyright 2020 Google LLC. All Rights Reserved.
6561 * Licensed under the Apache License, Version 2.0 (the "License");
6562 * you may not use this file except in compliance with the License.
6563 * You may obtain a copy of the License at
6564 *
6565 * http://www.apache.org/licenses/LICENSE-2.0
6566 *
6567 * Unless required by applicable law or agreed to in writing, software
6568 * distributed under the License is distributed on an "AS IS" BASIS,
6569 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6570 * See the License for the specific language governing permissions and
6571 * limitations under the License.
6572 * =============================================================================
6573 */G().prototype.round=function(){return this.throwIfDisposed(),Jc(this)};/**
6574 * @license
6575 * Copyright 2020 Google LLC. All Rights Reserved.
6576 * Licensed under the Apache License, Version 2.0 (the "License");
6577 * you may not use this file except in compliance with the License.
6578 * You may obtain a copy of the License at
6579 *
6580 * http://www.apache.org/licenses/LICENSE-2.0
6581 *
6582 * Unless required by applicable law or agreed to in writing, software
6583 * distributed under the License is distributed on an "AS IS" BASIS,
6584 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6585 * See the License for the specific language governing permissions and
6586 * limitations under the License.
6587 * =============================================================================
6588 */G().prototype.rsqrt=function(){return this.throwIfDisposed(),Zc(this)};/**
6589 * @license
6590 * Copyright 2020 Google LLC. All Rights Reserved.
6591 * Licensed under the Apache License, Version 2.0 (the "License");
6592 * you may not use this file except in compliance with the License.
6593 * You may obtain a copy of the License at
6594 *
6595 * http://www.apache.org/licenses/LICENSE-2.0
6596 *
6597 * Unless required by applicable law or agreed to in writing, software
6598 * distributed under the License is distributed on an "AS IS" BASIS,
6599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6600 * See the License for the specific language governing permissions and
6601 * limitations under the License.
6602 * =============================================================================
6603 */G().prototype.selu=function(){return this.throwIfDisposed(),Qc(this)};/**
6604 * @license
6605 * Copyright 2020 Google LLC. All Rights Reserved.
6606 * Licensed under the Apache License, Version 2.0 (the "License");
6607 * you may not use this file except in compliance with the License.
6608 * You may obtain a copy of the License at
6609 *
6610 * http://www.apache.org/licenses/LICENSE-2.0
6611 *
6612 * Unless required by applicable law or agreed to in writing, software
6613 * distributed under the License is distributed on an "AS IS" BASIS,
6614 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6615 * See the License for the specific language governing permissions and
6616 * limitations under the License.
6617 * =============================================================================
6618 */G().prototype.separableConv2d=function(n,e,t,s,r,a){return this.throwIfDisposed(),eh(this,n,e,t,s,r,a)};/**
6619 * @license
6620 * Copyright 2020 Google LLC. All Rights Reserved.
6621 * Licensed under the Apache License, Version 2.0 (the "License");
6622 * you may not use this file except in compliance with the License.
6623 * You may obtain a copy of the License at
6624 *
6625 * http://www.apache.org/licenses/LICENSE-2.0
6626 *
6627 * Unless required by applicable law or agreed to in writing, software
6628 * distributed under the License is distributed on an "AS IS" BASIS,
6629 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6630 * See the License for the specific language governing permissions and
6631 * limitations under the License.
6632 * =============================================================================
6633 */G().prototype.sigmoid=function(){return this.throwIfDisposed(),Mn(this)};/**
6634 * @license
6635 * Copyright 2020 Google LLC. All Rights Reserved.
6636 * Licensed under the Apache License, Version 2.0 (the "License");
6637 * you may not use this file except in compliance with the License.
6638 * You may obtain a copy of the License at
6639 *
6640 * http://www.apache.org/licenses/LICENSE-2.0
6641 *
6642 * Unless required by applicable law or agreed to in writing, softw
6642are
6643 * distributed under the License is distributed on an "AS IS" BASIS,
6644 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6645 * See the License for the specific language governing permissions and
6646 * limitations under the License.
6647 * =============================================================================
6648 */G().prototype.sign=function(){return this.throwIfDisposed(),Jp(this)};/**
6649 * @license
6650 * Copyright 2020 Google LLC. All Rights Reserved.
6651 * Licensed under the Apache License, Version 2.0 (the "License");
6652 * you may not use this file except in compliance with the License.
6653 * You may obtain a copy of the License at
6654 *
6655 * http://www.apache.org/licenses/LICENSE-2.0
6656 *
6657 * Unless required by applicable law or agreed to in writing, software
6658 * distributed under the License is distributed on an "AS IS" BASIS,
6659 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6660 * See the License for the specific language governing permissions and
6661 * limitations under the License.
6662 * =============================================================================
6663 */G().prototype.sin=function(){return this.throwIfDisposed(),th(this)};/**
6664 * @license
6665 * Copyright 2020 Google LLC. All Rights Reserved.
6666 * Licensed under the Apache License, Version 2.0 (the "License");
6667 * you may not use this file except in compliance with the License.
6668 * You may obtain a copy of the License at
6669 *
6670 * http://www.apache.org/licenses/LICENSE-2.0
6671 *
6672 * Unless required by applicable law or agreed to in writing, software
6673 * distributed under the License is distributed on an "AS IS" BASIS,
6674 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6675 * See the License for the specific language governing permissions and
6676 * limitations under the License.
6677 * =============================================================================
6678 */G().prototype.sinh=function(){return this.throwIfDisposed(),nh(this)};/**
6679 * @license
6680 * Copyright 2020 Google LLC. All Rights Reserved.
6681 * Licensed under the Apache License, Version 2.0 (the "License");
6682 * you may not use this file except in compliance with the License.
6683 * You may obtain a copy of the License at
6684 *
6685 * http://www.apache.org/licenses/LICENSE-2.0
6686 *
6687 * Unless required by applicable law or agreed to in writing, software
6688 * distributed under the License is distributed on an "AS IS" BASIS,
6689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6690 * See the License for the specific language governing permissions and
6691 * limitations under the License.
6692 * =============================================================================
6693 */G().prototype.slice=function(n,e){return this.throwIfDisposed(),Se(this,n,e)};/**
6694 * @license
6695 * Copyright 2020 Google LLC. All Rights Reserved.
6696 * Licensed under the Apache License, Version 2.0 (the "License");
6697 * you may not use this file except in compliance with the License.
6698 * You may obtain a copy of the License at
6699 *
6700 * http://www.apache.org/licenses/LICENSE-2.0
6701 *
6702 * Unless required by applicable law or agreed to in writing, software
6703 * distributed under the License is distributed on an "AS IS" BASIS,
6704 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6705 * See the License for the specific language governing permissions and
6706 * limitations under the License.
6707 * =============================================================================
6708 */G().prototype.softmax=function(n){return this.throwIfDisposed(),sl(this,n)};/**
6709 * @license
6710 * Copyright 2020 Google LLC. All Rights Reserved.
6711 * Licensed under the Apache License, Version 2.0 (the "License");
6712 * you may not use this file except in compliance with the License.
6713 * You may obtain a copy of the License at
6714 *
6715 * http://www.apache.org/licenses/LICENSE-2.0
6716 *
6717 * Unless required by applicable law or agreed to in writing, software
6718 * distributed under the License is distributed on an "AS IS" BASIS,
6719 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6720 * See the License for the specific language governing permissions and
6721 * limitations under the License.
6722 * =============================================================================
6723 */G().prototype.softplus=function(){return this.throwIfDisposed(),gr(this)};/**
6724 * @license
6725 * Copyright 2020 Google LLC. All Rights Reserved.
6726 * Licensed under the Apache License, Version 2.0 (the "License");
6727 * you may not use this file except in compliance with the License.
6728 * You may obtain a copy of the License at
6729 *
6730 * http://www.apache.org/licenses/LICENSE-2.0
6731 *
6732 * Unless required by applicable law or agreed to in writing, software
6733 * distributed under the License is distributed on an "AS IS" BASIS,
6734 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6735 * See the License for the specific language governing permissions and
6736 * limitations under the License.
6737 * =============================================================================
6738 */G().prototype.spaceToBatchND=function(n,e){return this.throwIfDisposed(),el(this,n,e)};/**
6739 * @license
6740 * Copyright 2020 Google LLC. All Rights Reserved.
6741 * Licensed under the Apache License, Version 2.0 (the "License");
6742 * you may not use this file except in compliance with the License.
6743 * You may obtain a copy of the License at
6744 *
6745 * http://www.apache.org/licenses/LICENSE-2.0
6746 *
6747 * Unless required by applicable law or agreed to in writing, software
6748 * distributed under the License is distributed on an "AS IS" BASIS,
6749 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6750 * See the License for the specific language governing permissions and
6751 * limitations under the License.
6752 * =============================================================================
6753 */G().prototype.split=function(n,e){return this.throwIfDisposed(),Bt(this,n,e)};/**
6754 * @license
6755 * Copyright 2020 Google LLC. All Rights Reserved.
6756 * Licensed under the Apache License, Version 2.0 (the "License");
6757 * you may not use this file except in compliance with the License.
6758 * You may obtain a copy of the License at
6759 *
6760 * http://www.apache.org/licenses/LICENSE-2.0
6761 *
6762 * Unless required by applicable law or agreed to in writing, software
6763 * distributed under the License is distributed on an "AS IS" BASIS,
6764 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6765 * See the License for the specific language governing permissions and
6766 * limitations under the License.
6767 * =============================================================================
6768 */G().prototype.sqrt=function(){return this.throwIfDisposed(),ln(this)};/**
6769 * @license
6770 * Copyright 2020 Google LLC. All Rights Reserved.
6771 * Licensed under the Apache License, Version 2.0 (the "License");
6772 * you may not use this file except in compliance with the License.
6773 * You may obtain a copy of the License at
6774 *
6775 * http://www.apache.org/licenses/LICENSE-2.0
6776 *
6777 * Unless required by applicable law or agreed to in writing, software
6778 * distributed under the License is distributed on an "AS IS" BASIS,
6779 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6780 * See the License for the specific language governing permissions and
6781 * limitations under the License.
6782 * =============================================================================
6783 */G().prototype.square=function(){return this.throwIfDisposed(),Ye(this)};/**
6784 * @license
6785 * Copyright 2020 Google LLC. All Rights Reserved.
6786 * Licensed under the Apache License, Version 2.0 (the "License");
6787 * you may not use this file except in compliance with the License.
6788 * You may obtain a copy of the License at
6789 *
6790 * http://www.apache.org/licenses/LICENSE-2.0
6791 *
6792 * Unless required by applicable law or agreed to in writing, software
6793 * distributed under the License is distributed on an "AS IS" BASIS,
6794 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6795 * See the License for the specific language governing permissions and
6796 * limitations under the License.
6797 * =============================================================================
6798 */G().prototype.squaredDifference=function(n){return this.throwIfDisposed(),ah(this,n)};/**
6799 * @license
6800 * Copyright 2020 Google LLC. All Rights Reserved.
6801 * Licensed under the Apache License, Version 2.0 (the "License");
6802 * you may not use this file except in compliance with the License.
6803 * You may obtain a copy of the License at
6804 *
6805 * http://www.apache.org/licenses/LICENSE-2.0
6806 *
6807 * Unless required by applicable law or agreed to in writing, softw
6807are
6808 * distributed under the License is distributed on an "AS IS" BASIS,
6809 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6810 * See the License for the specific language governing permissions and
6811 * limitations under the License.
6812 * =============================================================================
6813 */G().prototype.squeeze=function(n){return this.throwIfDisposed(),zs(this,n)};/**
6814 * @license
6815 * Copyright 2020 Google LLC. All Rights Reserved.
6816 * Licensed under the Apache License, Version 2.0 (the "License");
6817 * you may not use this file except in compliance with the License.
6818 * You may obtain a copy of the License at
6819 *
6820 * http://www.apache.org/licenses/LICENSE-2.0
6821 *
6822 * Unless required by applicable law or agreed to in writing, software
6823 * distributed under the License is distributed on an "AS IS" BASIS,
6824 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6825 * See the License for the specific language governing permissions and
6826 * limitations under the License.
6827 * =============================================================================
6828 */G().prototype.stack=function(n,e){this.throwIfDisposed();const t=n instanceof lt?[this,n]:[this,...n];return Ot(t,e)};/**
6829 * @license
6830 * Copyright 2020 Google LLC. All Rights Reserved.
6831 * Licensed under the Apache License, Version 2.0 (the "License");
6832 * you may not use this file except in compliance with the License.
6833 * You may obtain a copy of the License at
6834 *
6835 * http://www.apache.org/licenses/LICENSE-2.0
6836 *
6837 * Unless required by applicable law or agreed to in writing, software
6838 * distributed under the License is distributed on an "AS IS" BASIS,
6839 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6840 * See the License for the specific language governing permissions and
6841 * limitations under the License.
6842 * =============================================================================
6843 */G().prototype.step=function(n){return this.throwIfDisposed(),Ea(this,n)};/**
6844 * @license
6845 * Copyright 2020 Google LLC. All Rights Reserved.
6846 * Licensed under the Apache License, Version 2.0 (the "License");
6847 * you may not use this file except in compliance with the License.
6848 * You may obtain a copy of the License at
6849 *
6850 * http://www.apache.org/licenses/LICENSE-2.0
6851 *
6852 * Unless required by applicable law or agreed to in writing, software
6853 * distributed under the License is distributed on an "AS IS" BASIS,
6854 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6855 * See the License for the specific language governing permissions and
6856 * limitations under the License.
6857 * =============================================================================
6858 */G().prototype.stridedSlice=function(n,e,t,s,r,a,o,i){return this.throwIfDisposed(),Zp(this,n,e,t,s,r,a,o,i)};/**
6859 * @license
6860 * Copyright 2020 Google LLC. All Rights Reserved.
6861 * Licensed under the Apache License, Version 2.0 (the "License");
6862 * you may not use this file except in compliance with the License.
6863 * You may obtain a copy of the License at
6864 *
6865 * http://www.apache.org/licenses/LICENSE-2.0
6866 *
6867 * Unless required by applicable law or agreed to in writing, software
6868 * distributed under the License is distributed on an "AS IS" BASIS,
6869 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6870 * See the License for the specific language governing permissions and
6871 * limitations under the License.
6872 * =============================================================================
6873 */G().prototype.sub=function(n){return this.throwIfDisposed(),ie(this,n)};/**
6874 * @license
6875 * Copyright 2020 Google LLC. All Rights Reserved.
6876 * Licensed under the Apache License, Version 2.0 (the "License");
6877 * you may not use this file except in compliance with the License.
6878 * You may obtain a copy of the License at
6879 *
6880 * http://www.apache.org/licenses/LICENSE-2.0
6881 *
6882 * Unless required by applicable law or agreed to in writing, software
6883 * distributed under the License is distributed on an "AS IS" BASIS,
6884 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6885 * See the License for the specific language governing permissions and
6886 * limitations under the License.
6887 * =============================================================================
6888 */G().prototype.sum=function(n,e){return this.throwIfDisposed(),oe(this,n,e)};/**
6889 * @license
6890 * Copyright 2020 Google LLC. All Rights Reserved.
6891 * Licensed under the Apache License, Version 2.0 (the "License");
6892 * you may not use this file except in compliance with the License.
6893 * You may obtain a copy of the License at
6894 *
6895 * http://www.apache.org/licenses/LICENSE-2.0
6896 *
6897 * Unless required by applicable law or agreed to in writing, software
6898 * distributed under the License is distributed on an "AS IS" BASIS,
6899 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6900 * See the License for the specific language governing permissions and
6901 * limitations under the License.
6902 * =============================================================================
6903 */G().prototype.tan=function(){return this.throwIfDisposed(),Qp(this)};/**
6904 * @license
6905 * Copyright 2020 Google LLC. All Rights Reserved.
6906 * Licensed under the Apache License, Version 2.0 (the "License");
6907 * you may not use this file except in compliance with the License.
6908 * You may obtain a copy of the License at
6909 *
6910 * http://www.apache.org/licenses/LICENSE-2.0
6911 *
6912 * Unless required by applicable law or agreed to in writing, software
6913 * distributed under the License is distributed on an "AS IS" BASIS,
6914 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6915 * See the License for the specific language governing permissions and
6916 * limitations under the License.
6917 * =============================================================================
6918 */G().prototype.tanh=function(){return this.throwIfDisposed(),Is(this)};/**
6919 * @license
6920 * Copyright 2020 Google LLC. All Rights Reserved.
6921 * Licensed under the Apache License, Version 2.0 (the "License");
6922 * you may not use this file except in compliance with the License.
6923 * You may obtain a copy of the License at
6924 *
6925 * http://www.apache.org/licenses/LICENSE-2.0
6926 *
6927 * Unless required by applicable law or agreed to in writing, software
6928 * distributed under the License is distributed on an "AS IS" BASIS,
6929 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6930 * See the License for the specific language governing permissions and
6931 * limitations under the License.
6932 * =============================================================================
6933 */G().prototype.tile=function(n){return this.throwIfDisposed(),sn(this,n)};/**
6934 * @license
6935 * Copyright 2020 Google LLC. All Rights Reserved.
6936 * Licensed under the Apache License, Version 2.0 (the "License");
6937 * you may not use this file except in compliance with the License.
6938 * You may obtain a copy of the License at
6939 *
6940 * http://www.apache.org/licenses/LICENSE-2.0
6941 *
6942 * Unless required by applicable law or agreed to in writing, software
6943 * distributed under the License is distributed on an "AS IS" BASIS,
6944 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6945 * See the License for the specific language governing permissions and
6946 * limitations under the License.
6947 * =============================================================================
6948 */G().prototype.toBool=function(){return this.throwIfDisposed(),ee(this,"bool")};/**
6949 * @license
6950 * Copyright 2020 Google LLC. All Rights Reserved.
6951 * Licensed under the Apache License, Version 2.0 (the "License");
6952 * you may not use this file except in compliance with the License.
6953 * You may obtain a copy of the License at
6954 *
6955 * http://www.apache.org/licenses/LICENSE-2.0
6956 *
6957 * Unless required by applicable law or agreed to in writing, software
6958 * distributed under the License is distributed on an "AS IS" BASIS,
6959 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6960 * See the License for the specific language governing permissions and
6961 * limitations under the License.
6962 * =============================================================================
6963 */G().prototype.toFloat=function(){return this.throwIfDisposed(),ee(this,"float32")};/**
6964 * @license
6965 * Copyright 2020 Google LLC. All Rights Reserved.
6966 * Licensed under the Apache License, Version 2.0 (the "License");
6967 * you may not use this file except in compliance with the License.
6968 * You may obtain a copy of the License at
6969 *
6970 * http://www.apache.org/licenses/LICENSE-2.0
6971 *
6972 * Unless required by applicable law or agreed to in writing, softw
6972are
6973 * distributed under the License is distributed on an "AS IS" BASIS,
6974 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6975 * See the License for the specific language governing permissions and
6976 * limitations under the License.
6977 * =============================================================================
6978 */G().prototype.toInt=function(){return this.throwIfDisposed(),ee(this,"int32")};/**
6979 * @license
6980 * Copyright 2020 Google LLC. All Rights Reserved.
6981 * Licensed under the Apache License, Version 2.0 (the "License");
6982 * you may not use this file except in compliance with the License.
6983 * You may obtain a copy of the License at
6984 *
6985 * http://www.apache.org/licenses/LICENSE-2.0
6986 *
6987 * Unless required by applicable law or agreed to in writing, software
6988 * distributed under the License is distributed on an "AS IS" BASIS,
6989 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6990 * See the License for the specific language governing permissions and
6991 * limitations under the License.
6992 * =============================================================================
6993 */G().prototype.topk=function(n,e){return this.throwIfDisposed(),tf(this,n,e)};/**
6994 * @license
6995 * Copyright 2020 Google LLC. All Rights Reserved.
6996 * Licensed under the Apache License, Version 2.0 (the "License");
6997 * you may not use this file except in compliance with the License.
6998 * You may obtain a copy of the License at
6999 *
7000 * http://www.apache.org/licenses/LICENSE-2.0
7001 *
7002 * Unless required by applicable law or agreed to in writing, software
7003 * distributed under the License is distributed on an "AS IS" BASIS,
7004 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7005 * See the License for the specific language governing permissions and
7006 * limitations under the License.
7007 * =============================================================================
7008 */G().prototype.transpose=function(n){return this.throwIfDisposed(),Ne(this,n)};/**
7009 * @license
7010 * Copyright 2020 Google LLC. All Rights Reserved.
7011 * Licensed under the Apache License, Version 2.0 (the "License");
7012 * you may not use this file except in compliance with the License.
7013 * You may obtain a copy of the License at
7014 *
7015 * http://www.apache.org/licenses/LICENSE-2.0
7016 *
7017 * Unless required by applicable law or agreed to in writing, software
7018 * distributed under the License is distributed on an "AS IS" BASIS,
7019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7020 * See the License for the specific language governing permissions and
7021 * limitations under the License.
7022 * =============================================================================
7023 */G().prototype.unique=function(n){return this.throwIfDisposed(),nf(this,n)};/**
7024 * @license
7025 * Copyright 2020 Google LLC. All Rights Reserved.
7026 * Licensed under the Apache License, Version 2.0 (the "License");
7027 * you may not use this file except in compliance with the License.
7028 * You may obtain a copy of the License at
7029 *
7030 * http://www.apache.org/licenses/LICENSE-2.0
7031 *
7032 * Unless required by applicable law or agreed to in writing, software
7033 * distributed under the License is distributed on an "AS IS" BASIS,
7034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7035 * See the License for the specific language governing permissions and
7036 * limitations under the License.
7037 * =============================================================================
7038 */G().prototype.unsortedSegmentSum=function(n,e){return this.throwIfDisposed(),ih(this,n,e)};/**
7039 * @license
7040 * Copyright 2020 Google LLC. All Rights Reserved.
7041 * Licensed under the Apache License, Version 2.0 (the "License");
7042 * you may not use this file except in compliance with the License.
7043 * You may obtain a copy of the License at
7044 *
7045 * http://www.apache.org/licenses/LICENSE-2.0
7046 *
7047 * Unless required by applicable law or agreed to in writing, software
7048 * distributed under the License is distributed on an "AS IS" BASIS,
7049 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7050 * See the License for the specific language governing permissions and
7051 * limitations under the License.
7052 * =============================================================================
7053 */G().prototype.unstack=function(n){return this.throwIfDisposed(),cn(this,n)};/**
7054 * @license
7055 * Copyright 2020 Google LLC. All Rights Reserved.
7056 * Licensed under the Apache License, Version 2.0 (the "License");
7057 * you may not use this file except in compliance with the License.
7058 * You may obtain a copy of the License at
7059 *
7060 * http://www.apache.org/licenses/LICENSE-2.0
7061 *
7062 * Unless required by applicable law or agreed to in writing, software
7063 * distributed under the License is distributed on an "AS IS" BASIS,
7064 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7065 * See the License for the specific language governing permissions and
7066 * limitations under the License.
7067 * =============================================================================
7068 */G().prototype.where=function(n,e){return this.throwIfDisposed(),dt(n,this,e)};/**
7069 * @license
7070 * Copyright 2020 Google LLC. All Rights Reserved.
7071 * Licensed under the Apache License, Version 2.0 (the "License");
7072 * you may not use this file except in compliance with the License.
7073 * You may obtain a copy of the License at
7074 *
7075 * http://www.apache.org/licenses/LICENSE-2.0
7076 *
7077 * Unless required by applicable law or agreed to in writing, software
7078 * distributed under the License is distributed on an "AS IS" BASIS,
7079 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7080 * See the License for the specific language governing permissions and
7081 * limitations under the License.
7082 * =============================================================================
7083 */G().prototype.zerosLike=function(){return this.throwIfDisposed(),Be(this)};/**
7084 * @license
7085 * Copyright 2018 Google LLC
7086 *
7087 * Use of this source code is governed by an MIT-style
7088 * license that can be found in the LICENSE file or at
7089 * https://opensource.org/licenses/MIT.
7090 * =============================================================================
7091 */class Pn extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Pn.prototype)}}class xn extends Error{constructor(e){super(e),Object.setPrototypeOf(this,xn.prototype)}}class A extends Error{constructor(e){super(e),Object.setPrototypeOf(this,A.prototype)}}class ye extends Error{constructor(e){super(e),Object.setPrototypeOf(this,ye.prototype)}}class mf extends Error{constructor(e){super(e),Object.setPrototypeOf(this,mf.prototype)}}/**
7092 * @license
7093 * Copyright 2022 Google LLC
7094 *
7095 * Use of this source code is governed by an MIT-style
7096 * license that can be found in the LICENSE file or at
7097 * https://opensource.org/licenses/MIT.
7098 * =============================================================================
7099 */class dw{constructor(e){this.maxEntries=e||100,this.cache=new Map}get(e){let t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){const s=this.cache.keys().next().value;this.cache.delete(s)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;t<this.maxEntries-e;t++){const s=this.cache.keys().next().value;this.cache.delete(s)}this.maxEntries=e}}/**
7100 * @license
7101 * Copyright 2018 Google LLC
7102 *
7103 * Use of this source code is governed by an MIT-style
7104 * license that can be found in the LICENSE file or at
7105 * https://opensource.org/licenses/MIT.
7106 * =============================================================================
7107 */function or(n,e){if(Array.isArray(n)){let t=[];for(let s=0;s<e;s++)t=t.concat(n);return t}else{const t=new Array(e);return t.fill(n),t}}function zn(n,e){if(!n)throw new mf(e)}function Lg(n,e){let t=0;for(const s of n)s===e&&t++;return t}function zt(n){return n.length===1?n[0]:n}function Ae(n){return Array.isArray(n)?n:[n]}function Zn(n){const t=n.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return t[0]!=="_"?t:"private"+t}function qs(n){return n.length<=1||n.indexOf("_")===-1?n:n.replace(/[_]+(\w|$)/g,(e,t)=>t.toUpperCase())}let fn={};function gf(n){if(n==null)return null;const e={};return e.className=n.getClassName(),e.config=n.getConfig(),e}function sd(n){if(!(n==null||typeof n!="object"))if(Array.isArray(n))n.forEach(e
vendor: 41,085 bytes, lines 7107-7247
7107=>sd(e));else{const e=Object.keys(n);for(const t of e){const s=n[t];s!=null&&typeof s=="object"&&(!Array.isArray(s)&&s.type==="ndarray"&&typeof s.value=="number"?n[t]=s.value:sd(s))}}}function ol(n,e={},t={},s="object",r=!1){if(typeof n=="string"){const a=n;let o;if(a in t)o=t[a];else if(a in fn)o=fn[a];else if(o=e[a],o==null)throw new A(`Unknown ${s}: ${n}. This may be due to one of the following reasons:
71081. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
71092. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return o}else{const a=n;if(a.className==null||a.config==null)throw new A(`${s}: Improper config format: ${JSON.stringify(a)}.
7110'className' and 'config' must set.`);const o=a.className;let i,l;if(o in t?[i,l]=t[o]:o in fn?[i,l]=fn.className:o in e&&([i,l]=e[o]),i==null)throw new A(`Unknown ${s}: ${o}. This may be due to one of the following reasons:
71111. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
71122. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){const u={};for(const p of Object.keys(fn))u[p]=fn[p];for(const p of Object.keys(t))u[p]=t[p];const c=a.config;c.customObjects=u;const h=Object.assign({},fn);for(const p of Object.keys(t))fn[p]=t[p];sd(a.config);const d=l(i,a.config,t,r);return fn=Object.assign({},h),d}else{const u=Object.assign({},fn);for(const h of Object.keys(t))fn[h]=t[h];const c=new i(a.config);return fn=Object.assign({},u),c}}}function ZR(n,e){return n<e?-1:n>e?1:0}function Nl(n,e){return-1*ZR(n,e)}function ws(n){if(n==null)return n;const e=[];for(const t of n)e.indexOf(t)===-1&&e.push(t);return e}function QR(n){if(n==null)throw new A(`Invalid value in obj: ${JSON.stringify(n)}`);for(const e in n)if(n.hasOwnProperty(e))return!1;return!0}function xr(n,e,t){if(t!=null&&n.indexOf(t)<0)throw new A(`${t} is not a valid ${e}.  Valid values are ${n} or null/undefined.`)}function yf(n,e,t=0,s=1/0){return zn(t>=0),zn(s>=t),Array.isArray(n)&&n.length>=t&&n.length<=s&&n.every(r=>typeof r===e)}function ht(n,e){Array.isArray(n)?(I(n.length>0,()=>`${e} is unexpectedly an empty array.`),n.forEach((t,s)=>ht(t,`element ${s+1} of ${e}`))):I(Number.isInteger(n)&&n>0,()=>`Expected ${e} to be a positive integer, but got ${pw(n)}.`)}function pw(n){return n===null?"null":Array.isArray(n)?"["+n.map(e=>pw(e)).join(",")+"]":typeof n=="string"?`"${n}"`:`${n}`}function eD(n,e,t){let s=t!=null?t():nn(),r;return(...o)=>{const i=t!=null?t():nn();return i-s<e||(s=i,r=n(...o)),r}}function fw(n){return n==="relu"?"relu":n==="linear"?"linear":n==="elu"?"elu":null}/**
7113 * @license
7114 * Copyright 2018 Google LLC
7115 *
7116 * Use of this source code is governed by an MIT-style
7117 * license that can be found in the LICENSE file or at
7118 * https://opensource.org/licenses/MIT.
7119 * =============================================================================
7120 */let tD=0;function mw(){return tD++}const Il={};function ph(n=""){return n in Il||(Il[n]=0),Il[n]+=1,n+Il[n].toString()}/**
7121 * @license
7122 * Copyright 2018 Google LLC
7123 *
7124 * Use of this source code is governed by an MIT-style
7125 * license that can be found in the LICENSE file or at
7126 * https://opensource.org/licenses/MIT.
7127 * =============================================================================
7128 */const nD=["channelsFirst","channelsLast"],sD=["nearest","bilinear"],rD=["valid","same","causal"],aD=["max","avg"],oD=["sum","mul","concat","ave"];/**
7129 * @license
7130 * Copyright 2018 Google LLC
7131 *
7132 * Use of this source code is governed by an MIT-style
7133 * license that can be found in the LICENSE file or at
7134 * https://opensource.org/licenses/MIT.
7135 * =============================================================================
7136 */const Ir=new Map;function Ze(n){xr(nD,"DataFormat",n)}function iD(n){xr(sD,"InterpolationFormat",n)}function pn(n){xr(rD,"PaddingMode",n)}function gw(n){xr(aD,"PoolMode",n)}const mo=[],Pg="/";function er(n,e){mo.push(n);try{const t=e();return mo.pop(),t}catch(t){throw mo.pop(),t}}function lD(){return mo.length===0?"":mo.join(Pg)+Pg}function yw(n){if(!bw(n))throw new Error("Not a valid tensor name: '"+n+"'");return lD()+n}function xw(n){if(!bw(n))throw new Error("Not a valid tensor name: '"+n+"'");Ir.has(n)||Ir.set(n,0);const e=Ir.get(n);if(Ir.set(n,Ir.get(n)+1),e>0){const t=`${n}_${e}`;return Ir.set(t,1),t}else return n}const uD=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function bw(n){return!!n.match(uD)}/**
7137 * @license
7138 * Copyright 2018 Google LLC
7139 *
7140 * Use of this source code is governed by an MIT-style
7141 * license that can be found in the LICENSE file or at
7142 * https://opensource.org/licenses/MIT.
7143 * =============================================================================
7144 */function cD(n){return n===parseInt(n.toString(),10)}function vs(n,e,t){e==null&&(e=0),t==null&&(t=n.length);let s=1;for(let r=e;r<t;++r)s*=n[r];return s}function Vr(n){if(n.length===0)return Number.NaN;let e=Number.POSITIVE_INFINITY;for(let t=0;t<n.length;t++){const s=n[t];s<e&&(e=s)}return e}function ks(n){if(n.length===0)return Number.NaN;let e=Number.NEGATIVE_INFINITY;for(let t=0;t<n.length;t++){const s=n[t];s>e&&(e=s)}return e}function Rn(n,e){if(e<n)throw new A(`end (${e}) < begin (${n}) is forbidden.`);const t=[];for(let s=n;s<e;++s)t.push(s);return t}/**
7145 * @license
7146 * Copyright 2018 Google LLC
7147 *
7148 * Use of this source code is governed by an MIT-style
7149 * license that can be found in the LICENSE file or at
7150 * https://opensource.org/licenses/MIT.
7151 * =============================================================================
7152 */let Wh;function at(){return Wh==null&&(Wh=dx().epsilon()),Wh}function Dn(){return"channelsLast"}/**
7153 * @license
7154 * Copyright 2018 Google LLC
7155 *
7156 * Use of this source code is governed by an MIT-style
7157 * license that can be found in the LICENSE file or at
7158 * https://opensource.org/licenses/MIT.
7159 * =============================================================================
7160 */function Un(n,e){return ee(n,e)}function il(n,e=-1){const t=n.shape.slice();return e<0&&(e=t.length+e+1),t.splice(e,0,1),D(n,t)}function hD(n,e){return L(()=>{if(n.shape.length!==2)throw new A(`repeat() expects a rank-2 tensor, but received a rank-${n.shape.length} tensor.`);const t=il(n,1);return rd(t,[1,e,1])})}function dD(n){const e=[vs(n.shape)];return D(n,e)}function pD(n){if(n.rank<=1)throw new A(`batchFlatten requires a minimum rank of 2. Got rank: ${n.rank}.`);const e=[n.shape[0],vs(n.shape,1)];return D(n,e)}function tr(n,e,t){return L(()=>{switch(n.rank){case 1:return tl(n,e,t);case 2:return sh(n,[e,0],[t,n.shape[1]]);case 3:return nl(n,[e,0,0],[t,n.shape[1],n.shape[2]]);case 4:return Pr(n,[e,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3]]);case 5:return Se(n,[e,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4]]);case 6:return Se(n,[e,0,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4],n.shape[5]]);default:throw new A(`sliceAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}})}function Uh(n,e,t){return L(()=>{switch(n.rank){case 1:return tl(n,e,t);case 2:return sh(n,[0,e],[n.shape[0],t]);case 3:return nl(n,[0,0,e],[n.shape[0],n.shape[1],t]);case 4:return Pr(n,[0,0,0,e],[n.shape[0],n.shape[1],n.shape[2],t]);default:throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function Sl(n,e,t,s){return L(()=>{switch(n.rank){case 1:return tl(n,e,t);case 2:switch(s){case 1:return tr(n,e,t);case 2:return Uh(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}case 3:switch(s){case 1:return tr(n,e,t);case 2:return nl(n,[0,e,0],[n.shape[0],t,n.shape[2]]);case 3:return Uh(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}case 4:switch(s){case 1:return tr(n,e,t);case 2:return Pr(n,[0,e,0,0],[n.shape[0],t,n.shape[2],n.shape[3]]);case 3:return Pr(n,[0,0,e,0],[n.shape[0],n.shape[1],t,n.shape[3]]);case 4:return Uh(n,e,t);default:throw new A(`The axis is not within the rank of the tensor ${s}`)}default:throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function xf(n,e=-1){let t;return e<0&&(t=n[0].rank,t!==0?e=t:e=0),e===n[0].rank&&(e=-1),Je(n,e)}function zg(n,e){switch(n.rank){case 1:return yp([n,e]);case 2:return xp([n,e],0);case 3:return bp([n,e],0);case 4:return wp([n,e],0);default:throw new A(`concatAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}}function rd(n,e){if(Array.isArray(e)||(e=[e]),n.rank!==e.length)throw new A(`The length of input n (${e.length}) does not match the number of dimensions in input x (${n.rank})`);return sn(n,e)}function fh(n,e=0,t=1,s,r){return Yc(n,e,t,s,r)}function Gn(n,e,t,s){if(n.rank<2||e.rank<2)throw new ye(`dot requires both inputs to be rank >= 2 but got x shape = ${n.shape} and y shape = ${e.shape}`);if(e.rank>=3){const r=n.shape.slice(-1)[0],a=e.shape.slice(-2)[0];if(r!==a)throw new ye(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${n.shape} and  y shape = ${e.shape}`)}if(n.rank===2&&e.rank===2)return td({a:n,b:e,transposeA:!1,transposeB:!1,bias:s?ad(n.rank,s,Dn()):null,activation:t});{const r=n.shape.slice(),a=r.pop();n=D(n,[-1,a]);const o=e.shape.slice(),i=o.pop(),l=o.pop(),u=[...o,i],c=Array.from({length:e.rank},(f,g)=>g===0?e.rank-2:g<=e.rank-2?g-1:g);e=D(Ne(e,c),[l,-1]);const h=[...r,...u];return D(td({a:n,b:e,transposeA:!1,transposeB:!1,bias:s?ad(n.rank,s,Dn()):null,activation:t}),h)}}function ww(n,e,t){return L(()=>(Array.isArray(e)?e=xt(e,"int32"):e=ee(e,"int32"),Pa(n,e,t)))}function ll(n){return O(n,n)}function ad(n,e,t){const s=e.shape;if(e.rank!==1&&e.rank!==n)throw new A(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${n}`);if(n===5){if(t==="channelsFirst")return s.length===1?D(e,[1,s[0],1,1,1]):D(e,[1,s[3],s[0],s[1],s[2]]);if(t==="channelsLast")return s.length===1?D(e,[1,1,1,1,s[0]]):D(e,[1].concat(s))}else if(n===4){if(t==="channelsFirst")return s.length===1?D(e,[1,s[0],1,1]):D(e,[1,s[2],s[0],s[1]]);if(t==="channelsLast")return s.length===1?D(e,[1,1,1,s[0]]):D(e,[1].concat(s))}else if(n===3){if(t==="channelsFirst")return s.length===1?D(e,[1,s[0],1]):D(e,[1,s[1],s[0]]);if(t==="channelsLast")return s.length===1?D(e,[1,1,s[0]]):D(e,[1].concat(s))}else if(n<3)return e;throw new A(`Unsupported input rank by biasAdd: ${e.rank}`)}function Fn(n,e,t){return L(()=>(t==null&&(t=Dn()),Ze(t),te(n,ad(n.rank,e,t))))}function fD(n,e=1){if(e!==1)throw new ye(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return Bi(n)}function mD(n){return L(()=>he(n,te(rt(n),1)))}function vw(n,e,t,s){return L(()=>af(n,e,t,s))}function gD(n){return L(()=>{const e=te(.5,O(.2,n));return Mt(e,0,1)})}function ul(n,e,t=!1){return t?n():e()}/**
7161 * @license
7162 * Copyright 2018 Google LLC
7163 *
7164 * Use of this source code is governed by an MIT-style
7165 * license that can be found in the LICENSE file or at
7166 * https://opensource.org/licenses/MIT.
7167 * =============================================================================
7168 */const yD=["fanIn","fanOut","fanAvg"],xD=["normal","uniform","truncatedNormal"];/**
7169 * @license
7170 * Copyright 2018 Google LLC
7171 *
7172 * Use of this source code is governed by an MIT-style
7173 * license that can be found in the LICENSE file or at
7174 * https://opensource.org/licenses/MIT.
7175 * =============================================================================
7176 */function bD(n){xr(yD,"FanMode",n)}function wD(n){xr(xD,"Distribution",n)}class vn extends Mi{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class bf extends vn{apply(e,t){return et(e,t)}}bf.className="Zeros";K(bf);class mh extends vn{apply(e,t){return Vt(e,t)}}mh.className="Ones";K(mh);class wf extends vn{constructor(e){if(super(),typeof e!="object")throw new A(`Expected argument of type ConstantConfig but got ${e}`);if(e.value===void 0)throw new A(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return L(()=>O(pe(this.value),Vt(e,t)))}getConfig(){return{value:this.value}}}wf.className="Constant";K(wf);class vf extends vn{constructor(e){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return Ps(e,this.minval,this.maxval,t,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}vf.className="RandomUniform";K(vf);class Cf extends vn{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new ye(`randomNormal does not support dType ${t}.`);return fh(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}Cf.className="RandomNormal";K(Cf);class $f extends vn{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new ye(`truncatedNormal does not support dType ${t}.`);return oh(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}$f.className="TruncatedNormal";K($f);class Nf extends vn{constructor(e){super(),this.gain=e.gain!=null?e.gain:1}apply(e,t){return L(()=>{if(e.length!==2||e[0]!==e[1])throw new A("Identity matrix initializer can only be used for 2D square matrices.");return O(this.gain,jc(e[0]))})}getConfig(){return{gain:this.gain}}}Nf.className="Identity";K(Nf);function vD(n,e="channelsLast"){let t,s;if(Ze(e),n.length===2)t=n[0],s=n[1];else if([3,4,5].indexOf(n.length)!==-1){if(e==="channelsFirst"){const r=vs(n,2);t=n[1]*r,s=n[0]*r}else if(e==="channelsLast"){const r=vs(n,0,n.length-2);t=n[n.length-2]*r,s=n[n.length-1]*r}}else{const r=vs(n);t=Math.sqrt(r),s=Math.sqrt(r)}return[t,s]}class Ut extends vn{constructor(e){if(super(),e.scale<0)throw new A(`scale must be a positive float. Got: ${e.scale}`);this.scale=e.scale==null?1:e.scale,this.mode=e.mode==null?"fanIn":e.mode,bD(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,wD(this.distribution),this.seed=e.seed}apply(e,t){const s=vD(e),r=s[0],a=s[1];let o=this.scale;if(this.mode==="fanIn"?o/=Math.max(1,r):this.mode==="fanOut"?o/=Math.max(1,a):o/=Math.max(1,(r+a)/2),this.distribution==="normal"){const i=Math.sqrt(o);if(t=t||"float32",t!=="float32"&&t!=="int32")throw new ye(`${this.getClassName()} does not support dType ${t}.`);return oh(e,0,i,t,this.seed)}else{const i=Math.sqrt(3*o);return Ps(e,-i,i,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Ut.className="VarianceScaling";K(Ut);class gh extends Ut{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Ut.className}}gh.className="GlorotUniform";K(gh);class yh extends Ut{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Ut.className}}yh.className="GlorotNormal";K(yh);class xh extends Ut{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Ut.className}}xh.className="HeNormal";K(xh);class bh extends Ut{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Ut.className}}bh.className="HeUniform";K(bh);class wh extends Ut{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Ut.className}}wh.className="LeCunNormal";K(wh);class vh extends Ut{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Ut.className}}vh.className="LeCunUniform";K(vh);class If extends vn{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=e.gain==null?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return L(()=>{if(e.length<2)throw new ye("Shape must be at least 2D.");if(t!=="int32"&&t!=="float32"&&t!==void 0)throw new TypeError(`Unsupported data type ${t}.`);t=t;const s=H(e.slice(0,-1)),r=e[e.length-1],a=s*r;a>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${a}) elements: Slowness may result.`);const o=[Math.max(r,s),Math.min(r,s)],i=fh(o,0,1,t,this.seed),l=cf.qr(i,!1);let u=l[0];const h=l[1].flatten().stridedSlice([0],[Math.min(r,s)*Math.min(r,s)],[Math.min(r,s)+1]);return u=O(u,h.sign()),s<r&&(u=u.transpose()),O(pe(this.gain),u.reshape(e))})}getConfig(){return{gain:this.gain,seed:this.seed}}}If.className="Orthogonal";K(If);const Vg={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Bg(n,e={}){return ol(n,Wi.getMap().classNameMap,e,"initializer")}function qe(n){return gf(n)}function Ue(n){if(typeof n=="string"){const e=n in Vg?Vg[n]:n;if(e==="GlorotNormal")return new yh;if(e==="GlorotUniform")return new gh;if(e==="HeNormal")return new xh;if(e==="HeUniform")return new bh;if(e==="LeCunNormal")return new wh;if(e==="LeCunUniform")return new vh;{const t={};return t.className=e,t.config={},Bg(t)}}else return n instanceof vn?n:Bg(n)}/**
7177 * @license
7178 * Copyright 2018 Google LLC
7179 *
7180 * Use of this source code is governed by an MIT-style
7181 * license that can be found in the LICENSE file or at
7182 * https://opensource.org/licenses/MIT.
7183 * =============================================================================
7184 */function od(n){return Array.isArray(n)&&Array.isArray(n[0])}function Zl(n){return n.length===0?[]:Array.isArray(n[0])?n:[n]}function ge(n){let e;if(Array.isArray(n)){if(n.length!==1)throw new A(`Expected Tensor length to be 1; got ${n.length}`);e=n[0]}else e=n;return e}function Ee(n){if(Array.isArray(n)&&Array.isArray(n[0])){if(n.length===1)return n=n,n[0];throw new A(`Expected exactly 1 Shape; got ${n.length}`)}else return n}/**
7185 * @license
7186 * Copyright 2018 Google LLC
7187 *
7188 * Use of this source code is governed by an MIT-style
7189 * license that can be found in the LICENSE file or at
7190 * https://opensource.org/licenses/MIT.
7191 * =============================================================================
7192 */function Ql(n){let e=0;for(const t of n)t.shape.length===0?e+=1:e+=t.shape.reduce((s,r)=>s*r);return e}/**
7193 * @license
7194 * Copyright 2018 Google LLC
7195 *
7196 * Use of this source code is governed by an MIT-style
7197 * license that can be found in the LICENSE file or at
7198 * https://opensource.org/licenses/MIT.
7199 * =============================================================================
7200 */const Mg="Variable";class Cw{constructor(e,t="float32",s=Mg,r=!0,a=null){this.dtype=t??"float32",this.shape=e.shape,this.id=mw(),s=s??Mg,this.originalName=yw(s),this.name=xw(this.originalName),this.trainable_=r,this.constraint=a,this.val=sf(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),CD(this.val,e),this.val.id!==e.id&&(this.val.assign(e),this.constraint!=null&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function CD(n,e){if(n.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(n.shape)+" vs. "+JSON.stringify(e.shape))}function id(n){return n.map(e=>e.read())}function Sf(n){n.forEach(e=>{e[0].write(e[1])})}/**
7201 * @license
7202 * Copyright 2018 Google LLC
7203 *
7204 * Use of this source code is governed by an MIT-style
7205 * license that can be found in the LICENSE file or at
7206 * https://opensource.org/licenses/MIT.
7207 * =============================================================================
7208 */class tt{constructor(e){this.dtype=e.dtype,this.shape=e.shape,e.shape!=null?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class An{constructor(e,t,s,r,a,o,i){this.dtype=e,this.shape=t,this.sourceLayer=s,this.inputs=r,this.callArgs=a,this.outputTensorIndex=i,this.id=mw(),o!=null&&(this.originalName=yw(o),this.name=xw(this.originalName)),this.rank=t.length}}let $D=0;class Ch{constructor(e,t){this.callArgs=t,this.id=$D++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(const s of e.inboundLayers)s!=null&&s.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)t!=null?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let ND=0;class Ce extends Mi{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=ND++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){const s=this.getClassName();t=Zn(s)+"_"+ph(s)}if(this.name=t,this.trainable_=e.trainable==null?!0:e.trainable,e.inputShape!=null||e.batchInputShape!=null){let s;if(e.batchInputShape!=null)s=e.batchInputShape;else if(e.inputShape!=null){let a=null;e.batchSize!=null&&(a=e.batchSize),s=[a].concat(e.inputShape)}this.batchInputShape=s;let r=e.dtype;r==null&&(r=e.inputDType),r==null&&(r="float32"),this.dtype=r}e.weights!=null?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(this.inboundNodes.length===0)throw new xn(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new A(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return zt(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return zt(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new Pn(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(this.inboundNodes.length===0)throw new Pn(`Layer ${this.name} is not connected, no input to return.`);return zt(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new Pn(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new Pn(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return zt(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(e=>e())}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach(t=>t.trainable=e),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(e=>e.trainable):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(e=>!e.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){const t=Ae(e);if(this.inputSpec==null||this.inputSpec.length===0)return;const s=Ae(this.inputSpec);if(t.length!==s.length)throw new A(`Layer ${this.name} expects ${s.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let r=0;r<t.length;r++){const a=t[r],o=s[r];if(o==null)continue;const i=a.rank;if(o.ndim!=null&&i!==o.ndim)throw new A(`Input ${r} is incompatible with layer ${this.name}: expected ndim=${o.ndim}, found ndim=${i}`);if(o.maxNDim!=null&&i>o.maxNDim)throw new A(`Input ${r} is incompatible with layer ${this.name}: expected max_ndim=${o.maxNDim}, found ndim=${i}`);if(o.minNDim!=null&&i<o.minNDim)throw new A(`Input ${r} is incompatible with layer ${this.name}: expected min_ndim=${o.minNDim}, found ndim=${i}.`);if(o.dtype!=null&&a.dtype!==o.dtype)throw new A(`Input ${r} is incompatible with layer ${this.name} : expected dtype=${o.dtype}, found dtype=${a.dtype}.`);if(o.axes){const l=a.shape;for(const u in o.axes){const c=Number(u),h=o.axes[u],d=c>=0?l[c]:l[l.length+c];if(h!=null&&[h,null].indexOf(d)===-1)throw new A(`Input ${r} is incompatible with layer ${this.name}: expected axis ${c} of input shape to have value ${h} but got shape ${l}.`)}}if(o.shape!=null)for(let l=0;l<o.shape.length;++l){const u=o.shape[l],c=a.shape[l];if(u!=null&&c!=null&&u!==c)throw new A(`Input ${r} is incompatible with layer ${this.name}: expected shape=${o.shape}, found shape=${a.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){this._callHook!=null&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();const s=Ae(e),r=kD(e),a=TD(e);if(r===a)throw new A("Arguments to apply() must be all SymbolicTensors or all Tensors");return er(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);const o=[];for(const i of Ae(e))o.push(i.shape);this.build(zt(o)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&a&&(this._refCount=1)}if(this.assertInputCompatibility(e),a){let o=this.call(e,t);this.supportsMasking&&this.setMaskMetadata(e,o);const i=Ae(o),l=[];for(let u of i)s.indexOf(u)!==-1&&(u=u.clone()),l.push(u);if(o=zt(l),this.activityRegularizer!=null)throw new ye("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return o}else{const o=ID(e),i=this.computeOutputShape(o);let l;const u=SD(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?o[0]:o),i!=null&&i.length>0&&Array.isArray(i[0])?l=i.map((c,h)=>new An(u,c,this,Ae(e),t,this.name,h)):l=new An(u,i,this,Ae(e),t,this.name),this.addInboundNode(e,l,null,null,o,i,t),this._refCount++,this.activityRegularizer!=null)throw new ye("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return l}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach((s,r)=>{s!=null&&e[r]!=null&&e[r]!==s&&(t=!0)}),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new Pn(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const s=JSON.stringify(t.outputShapes);e.indexOf(s)===-1&&e.push(s)}if(e.length===1){const t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&t.length===1?t[0]:t}else throw new Pn(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new xn(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return Ql(this.weights)}build(e){this.built=!0}getWeights(e=!1){return id(e?this.trainableWeights:this.weights)}setWeights(e){L(()=>{const t=this.weights;if(t.length!==e.length)throw new A(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(t.length===0)return;const s=[],r=id(t);for(let a=0;a<r.length;++a){const o=r[a],i=t[a],l=e[a];if(!ke(o.shape,l.shape))throw new A(`Layer weight shape ${o.shape} not compatible with provided weight shape ${l.shape}`);s.push([i,l])}Sf(s)})}addWeight(e,t,s,r,a,o,i,l){if(this._addedWeightNames.indexOf(e)!==-1)throw new A(`Duplicate weight name ${e} for layer ${this.name}`);this._addedWeightNames.push(e),s==null&&(s="float32"),this.fastWeightInitDuringBuild&&(r=l!=null?l():Ue("zeros"));const u=r.apply(t,s),c=new Cw(u,s,e,o,i);return u.dispose(),a!=null&&this.addLoss(()=>a.apply(c.read())),o==null&&(o=!0),o?this._trainableWeights.push(c):this._nonTrainableWeights.push(c),c}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=Ae(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(t!=null)if(Array.isArray(t))t.forEach(s=>{if(s!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}setMaskMetadata(e,t,s){if(!this.supportsMasking)return;const r=this.computeMask(e,s),a=Ae(t),o=Ae(r);if(a.length!==o.length)throw new Error(`${this.name} outputs ${a.length} tensors but ${a.length} masks for those tensors`);for(let i=0;i<a.length;i++)a[i].kerasMask=o[i]}addInboundNode(e,t,s,r,a,o,i=null){const l=Ae(e);t=Ae(t),s=Ae(s),r=Ae(r),a=Zl(a),o=Zl(o);const u=[],c=[],h=[];for(const d of l)u.push(d.sourceLayer),c.push(d.nodeIndex),h.push(d.tensorIndex);new Ch({outboundLayer:this,inboundLayers:u,nodeIndices:c,tensorIndices:h,inputTensors:l,outputTensors:t,inputMasks:s,outputMasks:r,inputShapes:a,outputShapes:o},i);for(let d=0;d<t.length;d++)t[d].sourceLayer=this,t[d].nodeIndex=this.inboundNodes.length-1,t[d].tensorIndex=d}getConfig(){const e={name:this.name,trainable:this.trainable};return this.batchInputShape!=null&&(e.batchInputShape=this.batchInputShape),this.dtype!=null&&(e.dtype=this.dtype),e}disposeWeights(){return this.weights.forEach(e=>e.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount===0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function ID(n){n=Ae(n);const e=[];for(const t of n)e.push(t.shape);return zt(e)}function SD(n){return"float32"}function $w(n,e,t){if((e==null||t!=null&&t>0)&&(e=n.sourceLayer,t=n.nodeIndex),e.inboundNodes.length===0)return[n];{const s=e.inboundNodes[t];if(s.inboundLayers.length===0)return s.inputTensors;{const r=[];for(let a=0;a<s.inboundLayers.length;a++){const o=s.inputTensors[a],i=s.inboundLayers[a],l=s.nodeIndices[a],u=$w(o,i,l);for(const c of u)r.indexOf(c)===-1&&r.push(c)}return r}}}function kD(n){let e=!0;for(const t of Ae(n))if(!(t instanceof An)){e=!1;break}return e}function TD(n){let e=!0;for(const t of Ae(n))if(t instanceof An){e=!1;break}return e}/**
7209 * @license
7210 * Copyright 2018 Google LLC
7211 *
7212 * Use of this source code is governed by an MIT-style
7213 * license that can be found in the LICENSE file or at
7214 * https://opensource.org/licenses/MIT.
7215 * =============================================================================
7216 */class Ba extends Ce{constructor(e){if(super({dtype:e.dtype,name:e.name!=null?e.name:ph("input").toString()}),e.batchSize==null&&(e.batchSize=null),e.sparse==null&&(e.sparse=!1),this.trainable=!1,this.built=!0,this.sparse=e.sparse,e.inputShape!=null&&e.batchInputShape!=null)throw new A("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");let t=e.batchInputShape;if(t==null){if(e.inputShape==null)throw new A("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");t=[e.batchSize].concat(e.inputShape)}else if(e.batchSize!=null)throw new A("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");const s=e.dtype||"float32";this.batchInputShape=t,this.dtype=s,this.inputSpec=[{shape:t}];const r=new An(this.dtype,this.batchInputShape,this,[],{},this.name);r.nodeIndex=0,r.tensorIndex=0,new Ch({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[r],outputTensors:[r],inputMasks:[null],outputMasks:[null],inputShapes:[t],outputShapes:[t]})}apply(e,t){throw new A(`Cannot pass any input to an InputLayer's apply() method. InputLayer name: ${this.name}`)}dispose(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}}getConfig(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}}}Ba.className="InputLayer";K(Ba);function Nw(n){if(n.batchShape==null&&n.shape==null)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(n.batchShape!=null&&n.shape!=null)throw new A("Please provide either a `shape` or `batchShape` argument to Input, but not both.");let e=n.batchShape;n.shape!=null&&e==null&&(e=[null].concat(n.shape));let t=n.dtype;return t==null&&(t="float32"),new Ba({batchInputShape:e,name:n.name,dtype:t,sparse:n.sparse}).inboundNodes[0].outputTensors[0]}/**
7217 * @license
7218 * Copyright 2018 Google LLC
7219 *
7220 * Use of this source code is governed by an MIT-style
7221 * license that can be found in the LICENSE file or at
7222 * https://opensource.org/licenses/MIT.
7223 * =============================================================================
7224 */function ED(n,e){if(n.dtype==null||n.dtype===e.dtype)return e;try{return ee(e,n.dtype)}catch{throw new A(`The dtype of the feed (${e.dtype}) can not be cast to the dtype of the key '${n.name}' (${n.dtype}).`)}}class gs{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof gs)for(const t in e.id2Value)this.id2Value[t]=e.id2Value[t],t in e.id2Mask&&(this.id2Mask[t]=e.id2Mask[t]);else{if(e==null)return;for(const t of e)this.add(t.key,t.value)}}add(e,t,s){if(this.id2Value[e.id]==null)this.id2Value[e.id]=ED(e,t),this.name2Id[e.name]=e.id,s!=null&&(this.id2Mask[e.id]=s);else throw new A(`Duplicate key: name=${e.name}, id=${e.id}`);return this}addFeed(e){this.add(e.key,e.value)}hasKey(e){return this.id2Value[e.id]!=null}names(){return Object.keys(this.name2Id)}getValue(e){if(e instanceof An){if(this.id2Value[e.id]==null)throw new A(`Nonexistent key: ${e.name}`);return this.id2Value[e.id]}else{const t=this.name2Id[e];if(t==null)throw new A(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Value[t]}}getMask(e){if(e instanceof An){if(this.id2Value[e.id]==null)throw new A(`Nonexistent key: ${e.name}`);return this.id2Mask[e.id]}else{const t=this.name2Id[e];if(t==null)throw new A(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Mask[t]}}disposeMasks(){this.id2Mask!=null&&Re(this.id2Mask)}}const eu=new dw,tu=new dw;function RD(n){eu!=null&&eu.setMaxEntries(n),tu!=null&&tu.setMaxEntries(n)}function io(n,e,t,s){const r=t==null?!1:t.training,a=Array.isArray(n),o=a?n:[n],i=o.map(f=>f.name),l=[],u=e.names();for(const f of i)u.indexOf(f)!==-1?l.push(e.getValue(f)):l.push(null);const c=i.join(",")+"|"+e.names().sort().join(",");let h=eu.get(c),d;if(h==null){const f=DD(o,e);h=f.sorted,d=f.recipientCounts,eu.put(c,h),tu.put(c,d)}d={},r||Object.assign(d,tu.get(c));const p=new gs(e);for(let f=0;f<h.length;++f){const g=h[f],m=g.sourceLayer;if(m instanceof Ba)continue;const y=[],x=[],v=[];let b=!1;for(const T of g.inputs){const E=p.getValue(T),_=p.getMask(T);y.push(E),x.push(_),_!=null&&(b=!0),r||(d[T.name]--,d[T.name]===0&&!e.hasKey(T)&&i.indexOf(T.name)===-1&&!E.isDisposed&&T.sourceLayer.stateful!==!0&&v.push(E))}b&&(t=t||{},t.mask=x[0]);const C=Ae(m.apply(y,t));let $=null;m.supportsMasking&&($=m.computeMask(y,x));const S=OD(g),k=Array.isArray(S)?S:[S];for(let T=0;T<k.length;++T){p.hasKey(k[T])||p.add(k[T],C[T],Array.isArray($)?$[0]:$);const E=i.indexOf(k[T].name);E!==-1&&(l[E]=C[T])}r||Re(v)}return p.disposeMasks(),a?l:l[0]}function DD(n,e){I(n!=null&&n.length>0,()=>"Expected at least one fetch, got none");let t=[],s={};if(n.length===1){const r=Wg(n[0],e);t=r.sorted,s=r.recipientMap}else{const r=new Set;for(const a of n){const{sorted:o,recipientMap:i}=Wg(a,e);for(const l of o)r.has(l.name)||(t.push(l),r.add(l.name));for(const l in i)s[l]==null&&(s[l]=new Set),i[l].forEach(u=>s[l].add(u))}}return{sorted:t,recipientCounts:AD(s)}}function AD(n){const e={};for(const t in n)e[t]=n[t].size;return e}function Wg(n,e){const t=new Set,s=[],r={};for(const i of e.names())t.add(i);const a=[],o=[];for(a.push(n);a.length>0;){const i=a[a.length-1];if(t.has(i.name)){a.pop();continue}const l=o[o.length-1]===a.length-1;if(i.inputs.length===0||l)a.pop(),s.push(i),t.add(i.name),l&&o.pop();else{o.push(a.length-1);for(const u of i.inputs)r[u.name]==null&&(r[u.name]=new Set),r[u.name].add(i.name),!t.has(u.name)&&a.push(u)}}return{sorted:s,recipientMap:r}}function OD(n){let e;if(n.sourceLayer.inboundNodes.length===1)e=n.sourceLayer.output;else{let t=null;for(let s=0;s<n.sourceLayer.inboundNodes.length;++s)for(const r of n.sourceLayer.inboundNodes[s].outputTensors)if(r.id===n.id){t=s;break}e=n.sourceLayer.getOutputAt(t)}return e}/**
7225 * @license
7226 * Copyright 2022 Google LLC. All Rights Reserved.
7227 * Licensed under the Apache License, Version 2.0 (the "License");
7228 * you may not use this file except in compliance with the License.
7229 * You may obtain a copy of the License at
7230 *
7231 * http://www.apache.org/licenses/LICENSE-2.0
7232 *
7233 * Unless required by applicable law or agreed to in writing, software
7234 * distributed under the License is distributed on an "AS IS" BASIS,
7235 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7236 * See the License for the specific language governing permissions and
7237 * limitations under the License.
7238 * =============================================================================
7239 */const _D=W();_D.registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",()=>100,RD);/**
7240 * @license
7241 * Copyright 2018 Google LLC
7242 *
7243 * Use of this source code is governed by an MIT-style
7244 * license that can be found in the LICENSE file or at
7245 * https://opensource.org/licenses/MIT.
7246 * =============================================================================
7247 */function kf(n,e){return L(()=>ln(oe(O(n,n),e,!0)))}class cl extends Mi{getConfig(){return{}}}class Tf extends cl{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return L(()=>{const t=kf(e,this.axis),s=Mt(t,0,this.maxValue);return O(e,he(s,te(at(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}Tf.className="MaxNorm";K(Tf);class Ef extends cl{constructor(e){super(),this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return L(()=>he(e,te(at(),kf(e,this.axis))))}getConfig(){return{axis:this.axis}}}Ef.className="UnitNorm";K(Ef);class Rf extends cl{apply(e){return Kn(e)}}Rf.className="NonNeg";K(Rf);class Df extends cl{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return L(()=>{const t=kf(e,this.axis),s=te(O(this.rate,Mt(t,this.minValue,this.maxValue)),O(1-this.rate,t));return O(e,he(s,te(at(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}
7247Df.className="MinMaxNorm";K(Df);const Ug={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function ot(n){return gf(n)}function Gg(n,e={}){return ol(n,Wi.getMap().classNameMap,e,"constraint")}function it(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in Ug?Ug[n]:n,config:{}};return Gg(t)}else return n instanceof cl?n:Gg(n)}/**
7248 * @license
7249 * Copyright 2018 Google LLC
7250 *
7251 * Use of this source code is governed by an MIT-style
7252 * license that can be found in the LICENSE file or at
7253 * https://opensource.org/licenses/MIT.
7254 * =============================================================================
7255 */function FD(n){return new Tf(n)}function LD(n){return new Ef(n)}function PD(){return new Rf}function zD(n){return new Df(n)}const VD=Object.freeze(Object.defineProperty({__proto__:null,maxNorm:FD,minMaxNorm:zD,nonNeg:PD,unitNorm:LD},Symbol.toStringTag,{value:"Module"}));/**
7256 * @license
7257 * Copyright 2018 Google LLC
7258 *
7259 * Use of this source code is governed by an MIT-style
7260 * license that can be found in the LICENSE file or at
7261 * https://opensource.org/licenses/MIT.
7262 * =============================================================================
7263 */function BD(){return new bf}function MD(){return new mh}function WD(n){return new wf(n)}function UD(n){return new vf(n)}function GD(n){return new Cf(n)}function HD(n){return new $f(n)}function jD(n){return new Nf(n)}function qD(n){return new Ut(n)}function KD(n){return new gh(n)}function XD(n){return new yh(n)}function YD(n){return new xh(n)}function JD(n){return new bh(n)}function ZD(n){return new wh(n)}function QD(n){return new vh(n)}function eA(n){return new If(n)}const tA=Object.freeze(Object.defineProperty({__proto__:null,constant:WD,glorotNormal:XD,glorotUniform:KD,heNormal:YD,heUniform:JD,identity:jD,leCunNormal:ZD,leCunUniform:QD,ones:MD,orthogonal:eA,randomNormal:GD,randomUniform:UD,truncatedNormal:HD,varianceScaling:qD,zeros:BD},Symbol.toStringTag,{value:"Module"}));/**
7264 * @license
7265 * Copyright 2018 Google LLC
7266 *
7267 * Use of this source code is governed by an MIT-style
7268 * license that can be found in the LICENSE file or at
7269 * https://opensource.org/licenses/MIT.
7270 * =============================================================================
7271 */async function fs(n){if(n==null)return;const e=[],t=[],s=[];for(const r in n){const a=n[r];if(typeof a!="number"){const o=a;e.push(o.data()),t.push(r),s.push(o)}}if(e.length>0){const r=await Promise.all(e);for(let a=0;a<r.length;++a)n[t[a]]=r[a][0];Re(s)}}function Iw(n){if(n!=null)for(const e in n){const t=n[e];typeof t!="number"&&t.dispose()}}/**
7272 * @license
7273 * Copyright 2018 Google LLC
7274 *
7275 * Use of this source code is governed by an MIT-style
7276 * license that can be found in the LICENSE file or at
7277 * https://opensource.org/licenses/MIT.
7278 * =============================================================================
7279 */var Hg;(function(n){n[n.SILENT=0]="SILENT",n[n.VERBOSE=1]="VERBOSE"})(Hg||(Hg={}));const nA=125;class Br{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,t){}async onEpochEnd(e,t){}async onBatchBegin(e,t){}async onBatchEnd(e,t){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}}class Sw{constructor(e,t=10){e==null&&(e=[]),this.callbacks=e,this.queueLength=t}append(e){this.callbacks.push(e)}setParams(e){for(const t of this.callbacks)t.setParams(e)}setModel(e){for(const t of this.callbacks)t.setModel(e)}async onEpochBegin(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onEpochBegin(e,t)}
vendor: 51,712 bytes, lines 7279-7375
7279async onEpochEnd(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onEpochEnd(e,t)}async onBatchBegin(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onBatchBegin(e,t)}async onBatchEnd(e,t){t==null&&(t={});for(const s of this.callbacks)await s.onBatchEnd(e,t)}async onTrainBegin(e){e==null&&(e={});for(const t of this.callbacks)await t.onTrainBegin(e)}async onTrainEnd(e){e==null&&(e={});for(const t of this.callbacks)await t.onTrainEnd(e)}}class sA extends Br{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,t){t==null&&(t={});const s=t.size==null?0:t.size;this.seen+=s;for(const r in t){const a=t[r];if(typeof a=="number")this.totals.hasOwnProperty(r)||(this.totals[r]=0),this.totals[r]=this.totals[r]+a*s;else{let o;r in this.totals?o=this.totals[r]:this.totals[r]=0;const i=L(()=>te(this.totals[r],O(a,s)));this.totals[r]=i,o!=null&&o.dispose()}}}async onEpochEnd(e,t){if(t!=null)for(const s of this.params.metrics)this.totals[s]!=null&&(typeof this.totals[s]=="number"?t[s]=this.totals[s]/this.seen:L(()=>{const r=O(he(1,this.seen),this.totals[s]);t[s]=r,this.totals[s].dispose(),ct(t[s])}))}}class kw extends Br{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){t==null&&(t={}),this.epoch.push(e);for(const s in t)this.history[s]==null&&(this.history[s]=[]),this.history[s].push(t[s])}async syncData(){const e=[],t=[],s=[];for(const a in this.history){const o=this.history[a];for(let i=0;i<o.length;++i)if(typeof o[i]!="number"){const l=o[i];e.push(l.data()),t.push(a),s.push(i)}}const r=await Promise.all(e);for(let a=0;a<r.length;++a)this.history[t[a]][s[a]].dispose(),this.history[t[a]][s[a]]=r[a][0]}}class Tw extends Br{constructor(e,t){if(super(),this.currentEpoch=0,this.nowFunc=e.nowFunc,this.nextFrameFunc=e.nextFrameFunc||ff,this.yieldEvery=t||"auto",this.yieldEvery==="auto"&&(this.yieldEvery=nA),this.yieldEvery==="never"&&e.onYield!=null)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");vg(this.yieldEvery)&&(this.maybeWait=eD(this.maybeWait.bind(this),this.yieldEvery,this.nowFunc)),this.trainBegin=e.onTrainBegin,this.trainEnd=e.onTrainEnd,this.epochBegin=e.onEpochBegin,this.epochEnd=e.onEpochEnd,this.batchBegin=e.onBatchBegin,this.batchEnd=e.onBatchEnd,this.yield=e.onYield}async maybeWait(e,t,s){const r=[];this.yield!=null&&(await fs(s),r.push(this.yield(e,t,s))),r.push(this.nextFrameFunc()),await Promise.all(r)}async onEpochBegin(e,t){this.currentEpoch=e,this.epochBegin!=null&&(await fs(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){const s=[];this.epochEnd!=null&&(await fs(t),s.push(this.epochEnd(e,t))),this.yieldEvery==="epoch"&&s.push(this.nextFrameFunc()),await Promise.all(s)}async onBatchBegin(e,t){this.batchBegin!=null&&(await fs(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){const s=[];this.batchEnd!=null&&(await fs(t),s.push(this.batchEnd(e,t))),this.yieldEvery==="batch"?s.push(this.nextFrameFunc()):vg(this.yieldEvery)&&s.push(this.maybeWait(this.currentEpoch,e,t)),await Promise.all(s)}async onTrainBegin(e){this.trainBegin!=null&&(await fs(e),await this.trainBegin(e))}async onTrainEnd(e){this.trainEnd!=null&&(await fs(e),await this.trainEnd(e))}}function Ew(n,e){return n==null&&(n={}),n instanceof Br?[n]:Array.isArray(n)&&n[0]instanceof Br?n:Ae(n).map(s=>new Tw(s,e))}class tn{constructor(){}static registerCallbackConstructor(e,t){I(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),tn.checkForDuplicate(t),tn.constructors[e]==null&&(tn.constructors[e]=[]),tn.constructors[e].push(t)}static checkForDuplicate(e){for(const t in tn.constructors)tn.constructors[+t].forEach(r=>{if(r===e)throw new A("Duplicate callback constructor.")})}static clear(){tn.constructors={}}static createCallbacks(e){const t=[];for(const s in tn.constructors){const r=+s;e>=r&&t.push(...tn.constructors[r])}return t.map(s=>new s)}}tn.constructors={};function Rw(n,e,t,s,r,a,o,i,l){const u=new kw,c=[new sA,...tn.createCallbacks(e)];n!=null&&c.push(...n),c.push(u);const h=new Sw(c);return h.setParams({epochs:t,initialEpoch:s,samples:r,steps:a,batchSize:o,verbose:e,doValidation:i,metrics:l}),{callbackList:h,history:u}}/**
7280 * @license
7281 * Copyright 2018 Google LLC
7282 *
7283 * Use of this source code is governed by an MIT-style
7284 * license that can be found in the LICENSE file or at
7285 * https://opensource.org/licenses/MIT.
7286 * =============================================================================
7287 */function kn(n,e={},t=!1){return ol(n,Wi.getMap().classNameMap,e,"layer",t)}/**
7288 * @license
7289 * Copyright 2018 Google LLC
7290 *
7291 * Use of this source code is governed by an MIT-style
7292 * license that can be found in the LICENSE file or at
7293 * https://opensource.org/licenses/MIT.
7294 * =============================================================================
7295 */function nu(n,e){return L(()=>{n.dtype!=="float32"&&(n=ee(n,"float32"));const t=oe(ll(n),e,!0),s=ta(t.shape,at()),r=ln(as(t,s));return he(n,r)})}function br(n,e){return L(()=>je(ll(ie(e,n)),-1))}function $h(n,e){return L(()=>je(rt(ie(e,n)),-1))}function Ma(n,e){return L(()=>{const t=ie(n,e),s=Mt(rt(n),at(),Number.MAX_VALUE),r=rt(he(t,s));return O(100,je(r,-1))})}function rA(n,e){return L(()=>{const t=Mt(e,at(),Number.MAX_VALUE),s=Jt(te(1,t)),r=Mt(n,at(),Number.MAX_VALUE),a=Jt(te(1,r));return je(ll(ie(s,a)),-1)})}function aA(n,e){return L(()=>{const t=as(0,ie(1,O(n,e)));return je(ll(t),-1)})}function oA(n,e){return L(()=>{const t=as(0,ie(1,O(n,e)));return je(t,-1)})}function iA(n,e){return L(()=>{const t=oe(O(n,e),-1),s=on(O(ie(1,n),e),-1);return as(0,te(1,ie(s,t)))})}function lA(n,e){return L(()=>{const t=Math.log(2),s=ie(e,n),r=ie(te(s,gr(O(-2,s))),t);return je(r,-1)})}function $o(n,e,t=!1){return L(()=>{if(t)e=sl(e);else{const s=oe(e,e.shape.length-1,!0);e=he(e,s)}return e=Mt(e,at(),1-at()),Ve(oe(O(ee(n,"float32"),Jt(e)),e.shape.length-1))})}function su(n,e,t=!1){return L(()=>{const s=ee(La(dD(n)),"int32");e=Mt(e,at(),1-at());const r=e.shape,a=D(Fr(s,r[r.length-1]),r);return $o(a,e,t)})}function uA(n,e){if(!ke(n.shape,e.shape))throw new A(`logits and labels must have the same shape, but got shapes ${JSON.stringify(n.shape)} and ${JSON.stringify(e.shape)}`);return L(()=>{const t=Kn(e),s=Ve(rt(e));return te(ie(t,O(e,n)),Xi(Wt(s)))})}function Nh(n,e){return L(()=>{let t;return t=Mt(e,at(),1-at()),t=Jt(he(t,ie(1,t))),je(uA(n,t),-1)})}function cA(n,e){return L(()=>{const t=Mt(n,at(),1),s=Mt(e,at(),1);return oe(O(n,Jt(he(t,s))),-1)})}function hA(n,e){return L(()=>{const t=Jt(te(at(),e));return je(ie(e,O(n,t)),-1)})}function Af(n,e){return L(()=>{const t=nu(n,-1),s=nu(e,-1),r=O(t,s);return Ve(oe(r,-1))})}const ru={meanSquaredError:br,meanAbsoluteError:$h,meanAbsolutePercentageError:Ma,meanSquaredLogarithmicError:rA,squaredHinge:aA,hinge:oA,categoricalHinge:iA,logcosh:lA,categoricalCrossentropy:$o,sparseCategoricalCrossentropy:su,binaryCrossentropy:Nh,kullbackLeiblerDivergence:cA,poisson:hA,cosineProximity:Af};function Gh(n){if(typeof n=="string"){if(n in ru)return ru[n];let e=`Unknown loss ${n}`;throw n.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${n}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new A(e)}else return n}/**
7296 * @license
7297 * Copyright 2018 Google LLC
7298 *
7299 * Use of this source code is governed by an MIT-style
7300 * license that can be found in the LICENSE file or at
7301 * https://opensource.org/licenses/MIT.
7302 * =============================================================================
7303 */function Of(n,e){return L(()=>{const t=O(.5,Zt(e)),s=Un(Lt(e,t),n.dtype);return je(Yt(n,s),-1)})}function _f(n,e){return L(()=>Un(Yt(nr(n,-1),nr(e,-1)),"float32"))}function Dw(n,e){return L(()=>ee(oe(wn(Yt(n,1),Yt(e,1))),"float32"))}function dA(n,e){return L(()=>ee(oe(wn(Yt(n,1),Yt(e,0))),"float32"))}function pA(n,e){return L(()=>ee(oe(wn(Yt(n,0),Yt(e,1))),"float32"))}function Aw(n,e){return L(()=>{const t=Dw(n,e),s=pA(n,e),r=te(t,s);return ee(dt(Lt(r,0),he(t,r),0),"float32")})}function fA(n,e){return L(()=>{const t=Dw(n,e),s=dA(n,e),r=te(t,s);return ee(dt(Lt(r,0),he(t,r),0),"float32")})}function Ow(n,e){return Nh(n,e)}function _w(n,e){return n.rank===e.rank&&(n=zs(n,[n.rank-1])),e=nr(e,-1),e.dtype!==n.dtype&&(e=ee(e,n.dtype)),ee(Yt(n,e),"float32")}function mA(n,e){return L(()=>{const t=n.sub(e).square().sum(),s=n.sub(n.mean()).square().sum();return pe(1).sub(t.div(s))})}const gA=br,yA=br,xA=$h,bA=$h,wA=Ma,vA=Ma,Ff=$o,CA=Af,Fw=su,au={binaryAccuracy:Of,categoricalAccuracy:_f,precision:Aw,categoricalCrossentropy:Ff,sparseCategoricalCrossentropy:Fw,mse:gA,MSE:yA,mae:xA,MAE:bA,mape:wA,MAPE:vA,cosine:CA};function $A(n){if(typeof n=="string"&&n in au)return au[n];if(typeof n!="string"&&n!=null)return n;throw new A(`Unknown metric ${n}`)}function kl(n){if(zn(n!==null,`Unknown LossOrMetricFn ${n}`),typeof n=="string")return n;{let e;for(const t of Object.keys(ru))if(ru[t]===n){e=t;break}if(e!==void 0)return e;for(const t of Object.keys(au))if(au[t]===n){e=t;break}return e!==void 0?e:n.name}}/**
7304 * @license
7305 * Copyright 2018 Google LLC
7306 *
7307 * Use of this source code is governed by an MIT-style
7308 * license that can be found in the LICENSE file or at
7309 * https://opensource.org/licenses/MIT.
7310 * =============================================================================
7311 */function NA(n){const e={Adagrad:()=>Hs.adagrad(.01),Adadelta:()=>Hs.adadelta(1,.95,at()),Adam:()=>Hs.adam(.001,.9,.999,at()),Adamax:()=>Hs.adamax(.002,.9,.999,at(),0),RMSProp:()=>Hs.rmsprop(.001,.9,0,at()),SGD:()=>Hs.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,n in e)return e[n]();throw new A(`Unknown Optimizer ${n}`)}/**
7312 * @license
7313 * Copyright 2019 Google LLC
7314 *
7315 * Use of this source code is governed by an MIT-style
7316 * license that can be found in the LICENSE file or at
7317 * https://opensource.org/licenses/MIT.
7318 * =============================================================================
7319 */const jg=1*1024*1024;function qg(n,e,t=!1){if(n==null||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype||!ld(n))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(t){const s=JSON.stringify(n);s.length>jg&&console.warn(`User-defined metadata of model "${e}" is too large in size (length=${s.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= ${jg}.`)}}function ld(n){if(n===null)return!0;if(typeof n=="object")if(Object.getPrototypeOf(n)===Object.prototype){const e=Object.keys(n);for(const t of e)if(typeof t!="string"||!ld(n[t]))return!1;return!0}else if(Array.isArray(n)){for(const e of n)if(!ld(e))return!1;return!0}else return!1;else{const e=typeof n;return e==="string"||e==="number"||e==="boolean"}}/**
7320 * @license
7321 * Copyright 2018 Google LLC
7322 *
7323 * Use of this source code is governed by an MIT-style
7324 * license that can be found in the LICENSE file or at
7325 * https://opensource.org/licenses/MIT.
7326 * =============================================================================
7327 */function IA(n,e,t,s=console.log){const r=kA(n),a=["Layer (type)","Input Shape","Output shape","Param #"];r?(e=e||90,t=t||[.32,.61,.89,1]):(e=e||115,t=t||[.24,.48,.7,.8,1]),t[t.length-1]<=1&&(t=t.map(c=>Math.floor(e*c)));let o;if(!r){a.push("Receives inputs"),o=[];for(const c in n.nodesByDepth)o.push(...n.nodesByDepth[c])}s("_".repeat(e)),ou(a,t,s),s("=".repeat(e));const i=n.layers;for(let c=0;c<i.length;++c)r?TA(i[c],t,s):EA(i[c],t,o,s),s((c===i.length-1?"=":"_").repeat(e));n.checkTrainableWeightsConsistency();const l=SA(n),u=Ql(n.nonTrainableWeights);s(`Total params: ${l+u}`),s(`Trainable params: ${l}`),s(`Non-trainable params: ${u}`),s("_".repeat(e))}function SA(n){let e;return n.collectedTrainableWeights!=null?e=Ql(n.collectedTrainableWeights):e=Ql(n.trainableWeights),e}function kA(n){let e=!0;const t=[],s=[];for(const r in n.nodesByDepth)t.push(n.nodesByDepth[r]);for(const r of t){if(r.length>1||r.length===1&&r[0].inboundLayers.length>1){e=!1;break}s.push(...r)}if(e)for(const r of n.layers){let a=!1;for(const o of r.inboundNodes)if(s.indexOf(o)!==-1)if(a){e=!1;break}else a=!0;if(!e)break}return e}function ou(n,e,t=console.log){let s="";for(let r=0;r<n.length;++r)r>0&&(s=s.slice(0,s.length-1)+" "),s+=n[r],s=s.slice(0,e[r]),s+=" ".repeat(e[r]-s.length);t(s)}function TA(n,e,t){let s,r;try{r=n.inboundNodes.map(l=>JSON.stringify(l.inputShapes)).join(",")}catch{r="multiple"}try{s=JSON.stringify(n.outputShape)}catch{s="multiple"}const a=n.name,o=n.getClassName(),i=[`${a} (${o})`,r,s,n.countParams().toString()];ou(i,e,t)}function EA(n,e,t,s){let r,a;try{a=n.inboundNodes.map(h=>JSON.stringify(h.inputShapes)).join(",")}catch{a="multiple"}try{r=JSON.stringify(n.outputShape)}catch{r="multiple"}const o=[];for(const h of n.inboundNodes)if(!(t!=null&&t.length>0&&t.indexOf(h)===-1))for(let d=0;d<h.inboundLayers.length;++d){const p=h.inboundLayers[d].name,f=h.nodeIndices[d],g=h.tensorIndices[d];o.push(`${p}[${f}][${g}]`)}const i=n.name,l=n.getClassName(),u=o.length===0?"":o[0],c=[`${i} (${l})`,a,r,n.countParams().toString(),u];ou(c,e,s);for(let h=1;h<o.length;++h)ou(["","","","",o[h]],e,s)}/**
7328 * @license
7329 * Copyright 2018 Google LLC
7330 *
7331 * Use of this source code is governed by an MIT-style
7332 * license that can be found in the LICENSE file or at
7333 * https://opensource.org/licenses/MIT.
7334 * =============================================================================
7335 */function Lw(n,e,t){return(n==="inboundNodes"||n==="outputLayers"||n==="inputLayers")&&e===0&&typeof t=="string"}function No(n,e){if(n===null)return null;if(typeof n=="string")return qs(n);if(typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Array){const t=[],s=n.length;for(let r=0;r<s;++r){const a=n[r];Lw(e,r,a)?t.push(a):t.push(No(a,e))}return t}else{const t={};for(const s of Object.keys(n)){const r=n[s];if(s==="name"&&typeof r=="string")t[s]=r;else{const a=qs(s);t[a]=No(r,a)}}return t}}function ud(n,e){if(n==null)return null;if(typeof n=="string")return Zn(n);if(typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Array){const t=[],s=n.length;for(let r=0;r<s;++r){const a=n[r];Lw(e,r,a)?t.push(a):t.push(ud(a,e))}return t}else{const t={};for(const s of Object.keys(n)){const r=n[s],a=Zn(s);(s==="name"||s==="className")&&typeof r=="string"?t[a]=r:t[a]=ud(r,s)}return t}}/** @license See the LICENSE file. */const Ih="4.22.0";/**
7336 * @license
7337 * Copyright 2018 Google LLC
7338 *
7339 * Use of this source code is governed by an MIT-style
7340 * license that can be found in the LICENSE file or at
7341 * https://opensource.org/licenses/MIT.
7342 * =============================================================================
7343 */const RA=n=>{const e=Object.keys(n);if(e.length===0)return!1;const t=e[0].split("/");return!isNaN(parseInt(t[t.length-1],10))};class In extends Ce{constructor(e){if(super({}),this.containerNodes=new Set,this.name=e.name,this.name==null){const x=this.getClassName().toLowerCase();this.name=ph(x)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(e.inputs)?this.inputs=e.inputs.slice():this.inputs=[e.inputs],Array.isArray(e.outputs)?this.outputs=e.outputs.slice():this.outputs=[e.outputs],ws(this.inputs).length!==this.inputs.length)throw new A(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(x=>x.name)}`);ws(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map(x=>x.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const x of this.outputs){const v=x.sourceLayer,b=x.nodeIndex,C=x.tensorIndex;this.outputLayers.push(v),this.outputLayersNodeIndices.push(b),this.outputLayersTensorIndices.push(C)}for(const x of this.inputs){const v=x.sourceLayer,b=x.nodeIndex,C=x.tensorIndex;zn(b===0,"input layer has >1 nodes"),zn(C===0,"input layer has >1 tensors"),this.inputLayers.push(v),this.inputLayersNodeIndices.push(b),this.inputLayersTensorIndices.push(C)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let x=0;x<this.inputLayers.length;x++){const v=this.inputLayers[x];if(!(v instanceof Ba))throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${e.inputs}. Input ${x} (0-based) originates from layer type ${v.getClassName()}.`);this.inputNames.push(v.name),this.feedInputShapes.push(v.batchInputShape),this.feedInputNames.push(v.name)}for(const x of this.outputLayers)this.outputNames.push(x.name);this.internalInputShapes=this.inputs.map(x=>x.shape),this.internalOutputShapes=this.outputs.map(x=>x.shape);const t={},s={},r={},a={},o={},i=[],l=(x,v,b,C,$,S)=>{(C==null||$==null||S==null)&&(C=x.sourceLayer,$=x.nodeIndex,S=x.tensorIndex);const k=C.inboundNodes[$];if(b.indexOf(k)!==-1)throw new xn(`The tensor ${x.name} at layer "${C.name}" is part of a cycle.`);if(v.indexOf(k)!==-1)return;this.containerNodes.add(In.nodeKey(C,$)),C.id in o||(o[C.id]=Object.keys(o).length),b.indexOf(k)===-1&&b.push(k);const T=k.inboundLayers.length;for(let E=0;E<T;E++){const _=k.inputTensors[E],z=k.inboundLayers[E],P=k.nodeIndices[E],V=k.tensorIndices[E];l(_,v,b,z,P,V)}for(v.push(k);b.indexOf(k)>=0;)b.splice(b.indexOf(k),1);i.push(k)},u=[],c=[];for(const x of this.outputs)l(x,u,c);const h=i.slice().reverse();for(const x of h){s[x.id]=x,x.id in t||(t[x.id]=0);let v=t[x.id];const b=r[x.outboundLayer.id]==null?0:r[x.outboundLayer.id];v=Math.max(v,b),r[x.outboundLayer.id]=v,a[x.outboundLayer.id]=x.outboundLayer,t[x.id]=v;for(let C=0;C<x.inboundLayers.length;C++){const $=x.inboundLayers[C],S=x.nodeIndices[C],k=$.inboundNodes[S],T=t[k.id]==null?0:t[k.id];t[k.id]=Math.max(v+1,T),s[k.id]=k}}const d={};for(const x in t){const v=t[x];v in d||(d[v]=[]),d[v].push(s[x])}const p={};for(const x in r){const v=r[x];v in p||(p[v]=[]),p[v].push(a[x])}let f=Object.keys(p).map(x=>parseInt(x,10)).sort(Nl);this.layers=[];for(const x of f){const v=p[x];v.sort((b,C)=>{const $=o[b.id],S=o[C.id];return $<S?-1:$>S?1:0});for(const b of v)b instanceof In&&this.internalContainerRefs.push(b),this.layers.push(b)}this.layersByDepth=p,f=Object.keys(d).map(x=>parseInt(x,10)).sort(Nl);const g=this.inputs.slice(),m=[];for(const x of f)for(const v of d[x]){const b=v.outboundLayer;if(b!=null){for(const C of v.inputTensors)if(g.indexOf(C)===-1)throw new xn(`Graph disconnected: cannot obtain value for tensor ${C} at layer "${b.name}". The following previous layers were accessed without issue: ${m}`);for(const C of v.outputTensors)g.push(C);m.push(b.name)}}this.nodesByDepth=d;const y=this.layers.map(x=>x.name);for(const x of y){const v=y.filter(b=>b===x).length;if(v!==1)throw new xn(`The name "${x}" is used ${v} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(y))}this.outboundNodes=[],this.inboundNodes=[],new Ch({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(x=>null),outputMasks:this.outputs.map(x=>null),inputShapes:this.inputs.map(x=>x.shape),outputShapes:this.outputs.map(x=>x.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount===0){for(const t of this.layers)e.numDisposedVariables+=t.dispose().numDisposedVariables;for(const t of this.internalContainerRefs)e.numDisposedVariables+=t.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach(t=>{t._trainableWeights.forEach(s=>s.trainable=e)}),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new A("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let e=[];for(const t of this.layers)e=e.concat(t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.layers)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const s of this.layers)t.push(...s.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const s={};let r=0;const a=RA(e);a&&this.parseWeights(e);for(const i of this.layers)for(const[l,u]of i.weights.entries()){const c=a?`${u.name.split("/").slice(0,-1).join("/")+"/"}${l}`:u.originalName;if(s[c]!=null)throw new A(`Duplicate weight name: ${c}`);s[c]=u,r++}const o=[];for(const i in e){let l=i;if(s[i]==null){const u=i.split("/");l=u.slice(0,-2).concat([u[u.length-1]]).join("/")}if(s[l]!=null)o.push([s[l],e[i]]);else if(t)throw new A(`Provided weight data has no target variable: ${i}`);delete s[l]}if(t){const i=[];for(const l in s)i.push(l);if(i.length>0)throw new A(`${i.length} of ${r} weights are not set: ${i}`)}Sf(o)}parseWeights(e){for(const t in Object.keys(e)){const s=t.split("/"),r=["vars","layer_checkpoint_dependencies"],a=s.map(o=>o.startsWith("_")?o.slice(1):o).filter(o=>!r.includes(o)).join("/");a!==t&&(e[a]=e[t],delete e[t])}}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${Ih}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const s=ud(this.updatedConfig());return t?JSON.stringify(s):s}call(e,t){return L(()=>{e=Ae(e);const s=new gs;for(let r=0;r<this.inputs.length;++r)s.add(this.inputs[r],e[r]);return io(this.outputs,s,t)})}computeMask(e,t){return L(()=>{e=Ae(e);let s;return t==null?s=or(null,e.length):s=Ae(t),this.runInternalGraph(e,s)[1]})}computeOutputShape(e){const t=Zl(e);if(t.length!==this.inputLayers.length)throw new A(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const s={};for(let i=0;i<t.length;i++){const l=this.inputLayers[i],u=t[i],c=l.name+"_0_0";s[c]=u}const r=Object.keys(this.nodesByDepth).map(i=>parseInt(i,10)).sort(Nl);if(r.length>1)for(const i of r){const l=this.nodesByDepth[i];for(const u of l){const c=u.outboundLayer;if(this.inputLayers.map(g=>g.id).indexOf(c.id)!==-1)continue;const h=[];for(let g=0;g<u.inboundLayers.length;g++){const m=u.inboundLayers[g],y=u.nodeIndices[g],x=u.tensorIndices[g],v=`${m.name}_${y}_${x}`,b=s[v];h.push(b)}const d=c.computeOutputShape(zt(h)),p=Zl(d),f=c.inboundNodes.indexOf(u);for(let g=0;g<p.length;g++){const m=`${c.name}_${f}_${g}`;s[m]=p[g]}}}const a=[],o=[];for(let i=0;i<this.outputLayers.length;i++){const l=this.outputLayers[i],u=this.outputLayersNodeIndices[i],c=this.outputLayersTensorIndices[i],h=`${l.name}_${u}_${c}`;o.push(h)}for(let i=0;i<o.length;i++){const l=o[i];zn(l in s),a.push(s[l])}return zt(a)}runInternalGraph(e,t){t==null&&(t=or(null,e.length));const s={};for(let l=0;l<this.inputs.length;++l){const u=this.inputs[l],c=e[l],h=t[l];s[u.id]=[c,h]}const r=Object.keys(this.nodesByDepth).map(l=>parseInt(l,10)).sort(Nl);for(const l of r){const u=this.nodesByDepth[l];for(const c of u){const h=c.outboundLayer,d=c.inputTensors,p=c.outputTensors,f=new Array;for(const g of d)g.id in s&&f.push(s[g.id]);if(f.length===d.length){let g={},m,y,x,v;if(c.callArgs!=null&&(g=c.callArgs),f.length===1){const[b,C]=f[0];g.mask==null&&(g.mask=C),x=Ae(h.call(b,g)),v=Ae(h.computeMask(b,C)),m=[b],y=[C]}else m=f.map(b=>b[0]),y=f.map(b=>b[1]),g.mask==null&&(g.mask=y),x=Ae(h.call(m,g)),v=Ae(h.computeMask(m,y));if(h.activityRegularizer)throw new ye("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let b=0;b<p.length;++b){const C=p[b],$=x[b],S=v[b];s[C.id]=[$,S]}}}}const a=[],o=[],i=[];for(const l of this.outputs){zn(l.id in s,`Could not compute output ${l.name} : ${l.id}`);const[u,c]=s[l.id];i.push(u.shape),a.push(u),o.push(c)}return[a,o,i]}buildNodeConversionMap(e){const t={};let s;for(const r of this.layers){s=r instanceof In?1:0;for(let a=0;a<r.inboundNodes.length;a++){const o=In.nodeKey(r,a);this.containerNodes.has(o)&&(t[o]=s,s+=1)}}return t}getLayer(e,t){if(t!=null)return this.findLayer(t);if(e==null)throw new A("Provide either a layer name or layer index");if(typeof e=="number")return this.findLayer(e);for(const s of this.layers)if(s.name===e)return s;throw new A(`No such layer: ${e}`)}findLayer(e){if(this.layers.length<=e)throw new A(`Was asked to retrieve layer at index ${e}, but model only has ${this.layers.length} layer(s).`);return this.layers[e]}calculateLosses(){return L(()=>{const e=[];for(const t of this.layers)for(let s=0;s<t.inboundNodes.length;++s){const r=In.nodeKey(t,s);this.containerNodes.has(r)&&e.push(...t.calculateLosses())}return e})}getConfig(){const e={name:this.name},t=this.buildNodeConversionMap(this.layers),s=[];for(const o of this.layers){const i=o.getClassName(),l=o.getConfig(),u=[];for(let h=0;h<o.inboundNodes.length;h++){const d=o.inboundNodes[h],p=In.nodeKey(o,h);let f={};if(this.containerNodes.has(p)){if(d.callArgs)try{JSON.stringify(d.callArgs),f=d.callArgs}catch{console.warn(`Layer ${o.name} was passed non-serializable keyword arguments: ${d.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`),f={}}if(d.inboundLayers.length>0){const g=[];for(let m=0;m<d.inboundLayers.length;m++){const y=d.inboundLayers[m],x=d.nodeIndices[m],v=d.tensorIndices[m],b=In.nodeKey(y,x);let C=t[b];C==null&&(C=0),g.push([y.name,C,v,f])}u.push(g)}}}const c={};c.name=o.name,c.className=i,c.config=l,c.inboundNodes=u,s.push(c)}e.layers=s;const r=[];for(let o=0;o<this.inputLayers.length;o++){const i=this.inputLayers[o],l=this.inputLayersNodeIndices[o],u=In.nodeKey(i,l);if(!this.containerNodes.has(u))continue;let c=t[u];c==null&&(c=0);const h=this.inputLayersTensorIndices[o];r.push([i.name,c,h])}e.inputLayers=r;const a=[];for(let o=0;o<this.outputLayers.length;o++){const i=this.outputLayers[o],l=this.outputLayersNodeIndices[o],u=In.nodeKey(i,l);if(!this.containerNodes.has(u))continue;let c=t[u];c==null&&(c=0);const h=this.outputLayersTensorIndices[o];a.push([i.name,c,h])}return e.outputLayers=a,e}static fromConfig(e,t,s={},r=!1){const a={},o={};function i(m,y){m.name in o?o[m.name].push(y):o[m.name]=[y]}function l(m,y){const x=[];let v;for(const b of y){const C=b[0],$=b[1],S=b[2];if(v=b[3]==null?{}:b[3],!(C in a)){i(m,y);return}const k=a[C];if(k.inboundNodes.length<=$){i(m,y);return}const T=k.inboundNodes[$];x.push(T.outputTensors[S])}x.length>0&&m.apply(zt(x),v)}function u(m){const y=m.name,x=kn(m,t.customObjects!=null?t.customObjects:{});x.setFastWeightInitDuringBuild(r),a[y]=x,m.inboundNodes.forEach(b=>{if(!(b instanceof Array))throw new A(`Corrupted configuration, expected array for nodeData: ${b}`);i(x,b)})}const c=t.name,h=t.layers;for(const m of h)u(m);for(;!QR(o);)for(const m of h){const y=a[m.name];if(y.name in o){const x=o[y.name];delete o[y.name];for(const v of x)l(y,v)}}const d=[],p=[],f=t.inputLayers;for(const m of f){const y=m[0],x=m[1],v=m[2];zn(y in a);const C=a[y].inboundNodes[x].outputTensors;d.push(C[v])}const g=t.outputLayers;for(const m of g){const y=m[0],x=m[1],v=m[2];zn(y in a);const C=a[y].inboundNodes[x].outputTensors;p.push(C[v])}return new e({inputs:d,outputs:p,name:c})}get stateful(){if(this._stateful)throw new A("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const e of this.layers)if(e.stateful)return!0;return!1}resetStates(){L(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}}/**
7344 * @license
7345 * Copyright 2018 Google LLC
7346 *
7347 * Use of this source code is governed by an MIT-style
7348 * license that can be found in the LICENSE file or at
7349 * https://opensource.org/licenses/MIT.
7350 * =============================================================================
7351 */function DA(n,e,t){const s=e.length;if(n==null||Array.isArray(n)&&n.length===0)return e.map(r=>null);if(s===1)return Array.isArray(n)&&n.length===1?n:typeof n=="object"&&e[0]in n?[n[e[0]]]:[n];if(Array.isArray(n)){if(n.length!==s)throw new Error(`Provided ${t} is an array of ${n.length} element(s), but the model has ${s} outputs. Make sure a set of weights is provided for each model output.`);return n}else if(typeof n=="object"&&Object.keys(n).length>0&&typeof n[Object.keys(n)[0]]=="object"){const r=[];return e.forEach(a=>{a in n?r.push(n[a]):r.push(null)}),r}else throw new Error(`The model has multiple (${s}) outputs, so ${t} must be either an array with ${s} elements or an object with ${e} keys. Provided ${t} not understood: ${JSON.stringify(n)}`)}function Pw(n,e){return DA(n,e,"classWeight")}async function zw(n,e,t,s){if(t!=null){const r=L(()=>{if(n.shape.length===1)return ts(n);if(n.shape.length===2){if(n.shape[1]>1)return nr(n,1);if(n.shape[1]===1)return D(n,[n.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${n.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${n.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),a=Array.from(await r.data());Re(r);const o=[];return a.forEach(i=>{if(t[i]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${i} exists in the data but not in classWeight`);o.push(t[i])}),xt(o,"float32")}else return null}function AA(n,e){return O(n,e)}/**
7352 * @license
7353 * Copyright 2018 Google LLC
7354 *
7355 * Use of this source code is governed by an MIT-style
7356 * license that can be found in the LICENSE file or at
7357 * https://opensource.org/licenses/MIT.
7358 * =============================================================================
7359 */const OA=32;function Vw(n,e){let t,s;const r=e;t=r.xs,s=r.ys,I(t!=null&&s!=null,()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor.  The provided Dataset instead generates ${e}`);const a=Kg("input",n.inputNames,t),o=Kg("output",n.outputNames,s),i=a[0].shape[0];I(a.length===n.inputs.length,()=>`LayersModel has ${n.inputs.length} inputs, but the dataset provides ${a.length} inputs.  (Expected input keys: ${JSON.stringify(n.inputNames)})`),I(o.length===n.outputs.length,()=>`LayersModel has ${n.outputs.length} outputs, but the dataset provides ${o.length} outputs.  (Expected output keys: ${JSON.stringify(n.outputNames)})`);for(let l=0;l<a.length;l++)I(a[l].shape[0]===i,()=>`Batch size mismatch: input ${n.inputNames[l]} has ${a[l].shape[0]}; expected  ${i} based on input ${n.inputNames[0]}.`);for(let l=0;l<o.length;l++)I(o[l].shape[0]===i,()=>`Batch size mismatch: output ${n.outputNames[l]} has ${o[l].shape[0]}; expected  ${i} based on input ${n.inputNames[0]}.`);return{xs:a,ys:o}}function Kg(n,e,t){if(t instanceof lt)return[t];if(Array.isArray(t))return I(t.length===e.length,()=>`Received an array of ${t.length} Tensors, but expected ${e.length} to match the ${n} keys ${e}.`),t;{const s=[];for(const r of e){if(t[r]==null)throw new A(`The feature data generated by the dataset lacks the required ${n} key '${r}'.`);s.push(t[r])}return s}}function _A(n){if(n.length===3)throw new ye("Validation with sample weights is not implemented yet.");return{xs:n[0],ys:n[1]}}async function FA(n,e,t){const s=t.batchesPerEpoch!=null;if(I(n.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),I(t!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),I(t.epochs!=null&&t.epochs>0&&Number.isInteger(t.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${t.epochs}`),I(!s||t.batchesPerEpoch>0&&Number.isInteger(t.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${t.batchesPerEpoch}`),I(t.validationSplit==null,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),n.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");n.isTraining=!0;try{const r=t.validationData!=null;let a,o;if(r)if(Xg(t.validationData))I(t.validationBatches==null||t.validationBatches>0&&Number.isInteger(t.validationBatches),()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${t.validationBatches}`);else{const m=_A(t.validationData);a=m.xs,o=m.ys}const i=n.makeTrainFunction(),l=n.getDedupedMetricsNames();let u;r?u=l.slice().concat(l.map(m=>"val_"+m)):u=l.slice();const c=Ew(t.callbacks,t.yieldEvery),h=t.verbose==null?1:t.verbose,{callbackList:d,history:p}=Rw(c,h,t.epochs,null,null,LA(e,t),null,r,u);d.setModel(n),n.history=p,await d.onTrainBegin(),n.stopTraining_=!1;let f=t.initialEpoch==null?0:t.initialEpoch,g=await e.iterator();for(;f<t.epochs;){const m={};await d.onEpochBegin(f);let y=0,x=0;for(s||(g=await e.iterator());!s||y<t.batchesPerEpoch;){const v=await g.next();if(s&&v.done){console.warn(`You provided \`batchesPerEpoch\` as ${t.batchesPerEpoch}, but your dataset iterator ran out of data after ${y} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, ${t.batchesPerEpoch*t.epochs} batches). You may need to use the repeat() function when building your dataset.`);break}if(v.value!=null){const{xs:b,ys:C}=Vw(n,v.value),$={};$.batch=x,$.size=b[0].shape[0],await d.onBatchBegin(x,$);const S=[];if(t.classWeight!=null){const E=Pw(t.classWeight,n.outputNames);for(let _=0;_<E.length;++_)S.push(await zw(C[_],null,E[_]))}const k=b.concat(C).concat(S),T=i(k);Re(k);for(let E=0;E<l.length;++E){const _=l[E],z=T[E];$[_]=z,ct(z)}await d.onBatchEnd(x,$),Iw($),x++,y++}if(s?y>=t.batchesPerEpoch:v.done){if(r){let b;Xg(t.validationData)?b=Ae(await n.evaluateDataset(t.validationData,{batches:t.validationBatches})):b=Ae(n.evaluate(a,o,{batchSize:t.validationBatchSize==null?OA:t.validationBatchSize,verbose:0}));for(let C=0;C<n.metricsNames.length;++C)m[`val_${n.metricsNames[C]}`]=b[C]}break}if(n.stopTraining_)break}if(await d.onEpochEnd(f,m),f++,n.stopTraining_)break}return await d.onTrainEnd(),await n.history.syncData(),n.history}finally{n.isTraining=!1}}function LA(n,e){let t=null;return e.batchesPerEpoch!=null?t=e.batchesPerEpoch:Number.isFinite(n.size)&&(t=n.size),t}function Xg(n){return typeof n.iterator=="function"}function PA(n){return typeof n.next=="function"}async function zA(n,e,t){t=t||{};const s=t.batches!=null,r=n.testFunction;let a=[];if(t.verbose>0)throw new ye("Verbose mode is not implemented yet.");I(!s||t.batches>0&&Number.isInteger(t.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(t.batches)}`);const o=PA(e)?e:await e.iterator();let i=0,l=0;for(;!s||l<t.batches;){const u=await o.next();if(a=L(()=>{if(u.value){const{xs:c,ys:h}=Vw(n,u.value),d=c.concat(h),p=L(()=>r(d));if(Re(d),l===0)for(let g=0;g<p.length;++g)a.push(pe(0));const f=d[0].shape[0];for(let g=0;g<p.length;++g){const m=p[g],y=a[g];a[g]=L(()=>te(a[g],O(f,m))),l>0&&Re(y)}Re(p),i+=f,++l}return a}),u.done){s&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${t.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let u=0;u<a.length;++u){const c=a[u];a[u]=he(a[u],i),Re(c)}return zt(a)}/**
7360 * @license
7361 * Copyright 2018 Google LLC
7362 *
7363 * Use of this source code is governed by an MIT-style
7364 * license that can be found in the LICENSE file or at
7365 * https://opensource.org/licenses/MIT.
7366 * =============================================================================
7367 */function Hh(n){I(n>0&&Number.isInteger(n),()=>`batchSize is required to be a positive integer, but got ${n}`)}function so(n,e,t){return n==null?[null]:Array.isArray(n)?n.map(s=>tr(s,e,t-e)):tr(n,e,t-e)}function cd(n,e){return L(()=>n==null?null:Array.isArray(n)?n.map(t=>cd(t,e)):ww(n,e.dtype==="int32"?e:ee(e,"int32")))}function jh(n,e){const t=[];let s=0,r=null;for(;s<n;)r=s+e,r>=n&&(r=n),t.push([s,r]),s=r;return t}function Bw(n){const e=[];n instanceof lt&&(n=[n]);for(let t=0;t<n.length;++t){const s=n[t];if(s.rank===1)e.push(il(s,1));else{if(s.rank===0)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");e.push(s)}}return e}function Nn(n,e){if(n==null)return;const t=[];if(e instanceof lt)t.push(e.id);else if(Array.isArray(e))e.forEach(r=>t.push(r.id));else if(e!=null)for(const r in e){const a=e[r];t.push(a.id)}const s=[];if(n instanceof lt)t.indexOf(n.id)===-1&&s.push(n);else if(Array.isArray(n))n.forEach(r=>{t.indexOf(r.id)===-1&&s.push(r)});else if(n!=null)for(const r in n){const a=n[r];t.indexOf(a.id)===-1&&s.push(a)}s.forEach(r=>{r.isDisposed||r.dispose()})}/**
7368 * @license
7369 * Copyright 2018 Google LLC
7370 *
7371 * Use of this source code is governed by an MIT-style
7372 * license that can be found in the LICENSE file or at
7373 * https://opensource.org/licenses/MIT.
7374 * =============================================================================
7375 */function VA(n){return n instanceof lt}function hd(n){return Array.isArray(n)}function Yg(n){return!VA(n)&&!hd(n)}function Jg(n,e,t,s=!0,r=""){if(e==null||e.length===0){if(n!=null){let o=!1;if(hd(n)&&n.length>0)o=!0;else if(Yg(n)){for(const i in n)if(n.hasOwnProperty(i)){o=!0;break}}else o=!0;if(o)throw new A(`Error when checking model ${r} expected no data, but got ${n}`)}return[]}if(n==null)return e.map(o=>null);let a;if(Yg(n)){n=n,a=[];for(const o of e){if(n[o]==null)throw new A(`No data provided for "${o}". Need data for each key in: ${e}`);a.push(n[o])}}else if(hd(n)){if(n=n,n.length!==e.length)throw new A(`Error when checking model ${r}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${n}`);a=n}else{if(n=n,e.length>1)throw new A(`The model ${r} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${n.shape}`);a=[n]}if(a=Bw(a),t!=null)for(let o=0;o<e.length;++o){if(t[o]==null)continue;const i=a[o];if(i.shape.length!==t[o].length)throw new A(`Error when checking ${r}: expected ${e[o]} to have ${t[o].length} dimension(s). but got array with shape ${i.shape}`);for(let l=0;l<t[o].length;++l){if(l===0&&!s)continue;const u=i.shape[l],c=t[o][l];if(c!=null&&c>=0&&u!==c)throw new A(`${r} expected a batch of elements where each example has shape [${t[o].slice(1,t[o].length)}] (i.e.,tensor shape [*,${t[o].slice(1,t[o].length)}]) but the ${r} received an input with ${i.shape[0]} examples, each with shape [${i.shape.slice(1,i.shape.length)}] (tensor shape [${i.shape}])`)}}return a}function BA(n,e,t){const s=ws(n.map(a=>a.shape[0]));s.sort();const r=ws(e.map(a=>a.shape[0]));if(r.sort(),s.length>1)throw new A(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(n.map(a=>a.shape))}`);if(r.length>1)throw new A(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(a=>a.shape))}`);if(s.length>0&&r.length>0&&!ke(s,r))throw new A(`Input Tensors should have the same number of samples as target Tensors. Found ${s[0]} input sample(s) and ${r[0]} target sample(s).`)}function MA(n,e,t){const s=[br,Nh,$o];for(let r=0;r<n.length;++r){const a=n[r],o=e[r],i=t[r];if(o!=null){if(o===$o&&a.shape[a.shape.length-1]===1)throw new A(`You are passing a target array of shape ${a.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(s.indexOf(o)!==-1){const l=a.shape.slice(1),u=i.slice(1);for(let c=0;c<l.length;++c){const h=l[c],d=u[c];if(d!=null&&h!==d)throw new A(`A target Tensor with shape ${a.shape} was passed for an output of shape ${i}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}function Zg(n,e,t,s=!0,r=""){let a;if(Array.isArray(n)){if(n.length!==e.length)throw new A(`Error when checking model ${r}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${e.length} Tensor(s), but instead got ${n.length} Tensors(s).`);a=n}else{if(e.length>1)throw new A(`The model expects ${e.length} ${r} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(n.shape)}.`);a=[n]}if(t!=null)for(let o=0;o<e.length;++o){if(t[o]==null)continue;const i=a[o];if(i.shape.length!==t[o].length)throw new A(`Error when checking ${r}: expected ${e[o]} to have ${t[o].length} dimension(s), but got array with shape ${JSON.stringify(i.shape)}`);for(let l=0;l<t[o].length;++l){if(l===0&&!s)continue;const u=i.shape[l],c=t[o][l];if(c!=null&&c!==u)throw new A(`Error when checking ${r}: expected ${e[o]} to have shape ${JSON.stringify(t[o])} but got array with shape ${JSON.stringify(i.shape)}.`)}}}function WA(n,e){if(n==null||Array.isArray(n)&&n.length===0)return e.map(s=>[]);let t;if(typeof n=="string"||typeof n=="function")t=[n];else if(Array.isArray(n)||typeof n=="object")t=n;else throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${n}`);if(Array.isArray(t))return e.map(s=>t);{const s=[];for(const r of e){let a=t.hasOwnProperty(r)?t[r]:[];Array.isArray(a)||(a=[a]),s.push(a)}return s}}const UA="layers-model";class ss extends In{constructor(e){super(e),this.isTraining=!1}summary(e,t,s=console.log){if(!this.built)throw new A("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");IA(this,e,t,s)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=NA(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof px))throw new A("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(const o in e.loss)if(this.outputNames.indexOf(o)===-1)throw new A(`Unknown entry in loss dictionary: "${o}". Only expected the following keys: ${this.outputNames}`);for(const o of this.outputNames)e.loss[o]==null&&console.warn(`Output "${o}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${o} during training`),t.push(Gh(e.loss[o]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new A(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);t=e.loss.map(i=>Gh(i))}else{const o=Gh(e.loss);this.outputs.forEach(i=>{t.push(o)})}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let o=0;o<this.outputs.length;++o){const i=this.internalOutputShapes[o],l=this.outputNames[o];this.feedOutputNames.push(l),this.feedOutputShapes.push(i),this.feedLossFns.push(this.lossFunctions[o])}const s=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],er("loss",()=>{for(let o=0;o<this.outputs.length;++o){if(s.indexOf(o)!==-1)continue;const i=this.lossFunctions[o];this.outputs.length>1&&(this.metricsTensors.push([i,o]),this.metricsNames.push(this.outputNames[o]+"_loss"))}});const r=WA(e.metrics,this.outputNames),a=(o,i,l)=>{this.outputNames.length>1&&(i=this.outputNames[o]+"_"+i),this.metricsNames.push(i),this.metricsTensors.push([l,o])};er("metric",()=>{for(let o=0;o<this.outputs.length;++o){if(s.indexOf(o)!==-1)continue;const i=r[o];(u=>{const c="";let h,d,p;for(const f of u){if(typeof f=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(f)!==-1){const m=this.internalOutputShapes[o];m[m.length-1]===1||this.lossFunctions[o]===Nh?["accuracy","acc"].indexOf(f)!==-1?d=Of:["crossentropy","ce"].indexOf(f)!==-1&&(d=Ow):this.lossFunctions[o]===su?["accuracy","acc"].indexOf(f)!==-1?d=_w:["crossentropy","ce"].indexOf(f)!==-1&&(d=Fw):["accuracy","acc"].indexOf(f)!==-1?d=_f:["crossentropy","ce"].indexOf(f)!==-1&&(d=Ff);let y;["accuracy","acc"].indexOf(f)!==-1?y="acc":["crossentropy","ce"].indexOf(f)!==-1&&(y="ce"),p=d,h=c+y}else p=$A(f),h=c+kl(f);let g;er(h,()=>{g=p}),a(o,h,g)}})(i)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,s={}){const r=s.batchSize==null?32:s.batchSize;Hh(r);const o=this.standardizeUserDataXY(e,t,!0,r);try{const i=o[0].concat(o[1]);this.makeTestFunction();const l=this.testFunction,u=this.testLoop(l,i,r,s.verbose,s.steps);return zt(u)}finally{Nn(o[0],e),Nn(o[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),zA(this,e,t)}checkNumSamples(e,t,s,r="steps"){let a;if(s!=null){if(a=null,t!=null)throw new A(`If ${r} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else if(e!=null)Array.isArray(e)?a=e[0].shape[0]:a=e.shape[0];else throw new A(`Either the input data should have a defined shape, or ${r} shoud be specified.`);return a}execute(e,t){if(Array.isArray(t)&&t.length===0)throw new A("`outputs` is an empty Array, which is not allowed.");const s=Array.isArray(t),r=s?t:[t],a=this.retrieveSymbolicTensors(r),o=new gs;if(e instanceof lt&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new A(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let l=0;l<this.inputs.length;++l)o.add(this.inputs[l],e[l])}else for(const l of this.inputs){const u=e[l.name];if(u==null)throw new A(`No value is provided for the model's input ${l.name}`);o.add(l,u)}const i=io(a,o);return s?i:i[0]}retrieveSymbolicTensors(e){const t=or(null,e.length);let s=e.length;for(const r of this.layers){const a=Array.isArray(r.output)?r.output:[r.output],o=a.map(i=>i.name);for(let i=0;i<e.length;++i){const l=o.indexOf(e[i]);if(l!==-1&&(t[i]=a[l],s--),s===0)break}if(s===0)break}if(s>0){const r=[];throw t.forEach((a,o)=>{a==null&&r.push(e[o])}),new A(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(r)}`)}return t}predictLoop(e,t=32,s=!1){return L(()=>{const r=this.checkNumSamples(e);if(s)throw new ye("Verbose predictLoop() is not implemented yet.");const a=jh(r,t),o=this.outputs.map(i=>[]);for(let i=0;i<a.length;++i)L(()=>{const u=a[i][0],c=a[i][1],h=so(e,u,c),d=[];if(Array.isArray(h))for(let f=0;f<h.length;++f)d.push({key:this.inputs[f],value:h[f]});else d.push({key:this.inputs[0],value:h});const p=new gs(d);return io(this.outputs,p)}).forEach((u,c)=>o[c].push(u));return zt(o.map(i=>Je(i,0)))})}predict(e,t={}){const s=Bw(e);Zg(s,this.inputNames,this.feedInputShapes,!1);try{const r=t.batchSize==null?32:t.batchSize;return Hh(r),this.predictLoop(s,r)}finally{Nn(s,e)}}predictOnBatch(e){Zg(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,s=!0,r){if(this.optimizer_==null)throw new xn("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const a=[];for(let o=0;o<this.feedOutputShapes.length;++o){const i=this.feedOutputShapes[o];this.feedLossFns[o]===su?a.push(i.slice(0,i.length-1).concat([1])):a.push(i)}if(e=Jg(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=Jg(t,this.feedOutputNames,a,!1,"target"),BA(e,t),MA(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&r!=null&&r>0&&e[0].shape[0]%r!==0)throw new A(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,s,r,a=!0,o){const[i,l]=this.standardizeUserDataXY(e,t,a,o);if(s!=null)throw new Error("sample weight is not supported yet.");let u=null;if(r!=null){const c=Pw(r,this.outputNames);u=[];for(let h=0;h<c.length;++h)u.push(await zw(l[h],null,c[h]))}return[i,l,u]}testLoop(e,t,s,r=0,a){return L(()=>{const o=this.checkNumSamples(t,s,a,"steps"),i=[];if(r>0)throw new ye("Verbose mode is not implemented yet.");if(a!=null)throw new ye("steps mode in testLoop() is not implemented yet");{const l=jh(o,s),u=xt(Rn(0,o));for(let c=0;c<l.length;++c){const h=l[c][0],d=l[c][1],p=tr(u,h,d-h),f=cd(t,p),g=e(f);if(c===0)for(let m=0;m<g.length;++m)i.push(pe(0));for(let m=0;m<g.length;++m){const y=g[m];i[m]=te(i[m],O(d-h,y))}}for(let c=0;c<i.length;++c)i[c]=he(i[c],o)}return i})}getDedupedMetricsNames(){const e=this.metricsNames,t=[];for(let s=0;s<e.length;++s){const r=e[s];let a=r;if(Lg(e,r)>1){const o=Lg(e.slice(0,s),r);a+=`_${o}`}t.push(a)}return t}makeTrainFunction(){return e=>{const t=[],s=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),a=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),o=[],i=()=>{const h=[];for(let g=0;g<this.inputs.length;++g)h.push({key:this.inputs[g],value:s[g]});const d=new gs(h),p=io(this.outputs,d,{training:!0});let f;for(let g=0;g<this.lossFunctions.length;++g){const m=this.lossFunctions[g];let y=m(r[g],p[g]);a[g]!=null&&(y=AA(y,a[g]));const x=je(y);t.push(x),g===0?f=y:f=te(f,y)}for(let g=0;g<this.metricsTensors.length;++g){let m;if(this.outputs.length>1&&g<this.outputs.length)m=t[g];else{const y=this.metricsTensors[g][0],x=this.metricsTensors[g][1];m=je(y(r[x],p[x]))}ct(m),o.push(m)}return f=je(f),this.calculateLosses().forEach(g=>{f=te(f,g)}),f},l=this.collectedTrainableWeights.map(h=>h.read());return[this.optimizer_.minimize(i,!0,l)].concat(o)}}makeTestFunction(){this.testFunction=e=>L(()=>{const t=[];let s;const r=e.slice(0,this.inputs.length),a=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),o=[];for(let u=0;u<this.inputs.length;++u)o.push({key:this.inputs[u],value:r[u]});const i=new gs(o),l=io(this.outputs,i);for(let u=0;u<this.lossFunctions.length;++u){const c=this.lossFunctions[u],h=je(c(a[u],l[u]));u===0?s=h:s=te(s,h),t.push(s)}for(let u=0;u<this.metricsTensors.length;++u){const c=this.metricsTensors[u][0],h=this.metricsTensors[u][1],d=je(c(a[h],l[h]));t.push(d)}return t})}async fit(e,t,s={}){if(this.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");this.isTraining=!0;let r,a,o,i,l,u,c,h,d;try{const p=s.batchSize==null?32:s.batchSize;Hh(p);const g=await this.standardizeUserData(e,t,s.sampleWeight,s.classWeight,!1,p);r=g[0],a=g[1],d=g[2];let m=!1,y;
7375if(s.validationData!=null&&s.validationData.length>0){if(m=!0,s.validationData.length===2)l=s.validationData[0],u=s.validationData[1];else throw s.validationData.length===3?new ye("validationData including sample weights is not supported yet."):new A(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${s.validationData} is invalid.`);const E=await this.standardizeUserData(l,u,null,null,!0,p);c=E[0],h=E[1],y=c.concat(h)}else if(s.validationSplit!=null&&s.validationSplit>0&&s.validationSplit<1){m=!0;const T=Math.floor(r[0].shape[0]*(1-s.validationSplit)),E=r[0].shape[0];c=so(r,T,E),o=r,r=so(r,0,T),h=so(a,T,E),i=a,a=so(a,0,T),y=c.concat(h)}else s.validationSteps!=null&&(m=!0);const x=r.concat(a).concat(d);this.checkTrainableWeightsConsistency();const v=this.makeTrainFunction(),b=this.getDedupedMetricsNames();let C,$;m?(this.makeTestFunction(),C=this.testFunction,$=b.slice().concat(b.map(T=>"val_"+T))):(C=null,y=[],$=b.slice());const S=Ew(s.callbacks,s.yieldEvery);return await this.fitLoop(v,x,b,p,s.epochs,s.verbose,S,C,y,s.shuffle,$,s.initialEpoch,null,null)}finally{this.isTraining=!1,Nn(r,e),Nn(a,t),Nn(o,e),Nn(i,t),Nn(c,l),Nn(h,u),d!=null&&Re(d)}}async fitLoop(e,t,s,r,a,o,i,l,u,c,h,d,p,f){r==null&&(r=32),a==null&&(a=1),c==null&&(c=!0),d==null&&(d=0);let g=!1;if(l!=null&&u!=null&&(g=!0),f!=null&&(g=!0,p==null))throw new A("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const m=this.checkNumSamples(t,r,p,"steps_per_epoch");let y;m!=null&&(y=Rn(0,m)),o==null&&(o=1);const{callbackList:x,history:v}=Rw(i,o,a,d,m,p,r,g,h);x.setModel(this),this.history=v,await x.onTrainBegin(),this.stopTraining_=!1;for(let b=d;b<a;++b){await x.onEpochBegin(b);const C={};if(p!=null)throw new ye("stepsPerEpoch mode is not implemented yet.");{if(c==="batch")throw new ye("batch shuffling is not implemneted yet");c&&PC(y);const $=xt(y),S=jh(m,r);for(let k=0;k<S.length;++k){const T={};if(await x.onBatchBegin(k,T),L(()=>{const E=S[k][0],_=S[k][1],z=tr($,E,_-E);T.batch=k,T.size=_-E;const P=cd(t,z),V=e(P);for(let B=0;B<s.length;++B){const M=s[B],j=V[B];T[M]=j,ct(j)}if(k===S.length-1&&g){const B=this.testLoop(l,u,r);for(let M=0;M<s.length;++M){const j=s[M],U=B[M];ct(U),C["val_"+j]=U}}}),await x.onBatchEnd(k,T),Iw(T),this.stopTraining_)break}$.dispose()}if(await x.onEpochEnd(b,C),this.stopTraining_)break}return await x.onTrainEnd(),await this.history.syncData(),this.history}async fitDataset(e,t){return FA(this,e,t)}async trainOnBatch(e,t){const s=await this.standardizeUserData(e,t),r=s[0],a=s[1],i=this.makeTrainFunction()(r.concat(a)),l=[];for(const u of i){const c=await u.data();l.push(c[0])}return Re(i),Nn(s[0],e),Nn(s[1],t),zt(l)}getNamedWeights(e){const t=[],s=e!=null&&e.trainableOnly,r=s?this.trainableWeights:this.weights,a=this.getWeights(s);for(let o=0;o<r.length;++o)s&&!r[o].trainable||t.push({name:r[o].originalName,tensor:a[o]});return t}set stopTraining(e){this.stopTraining_=e}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}dispose(){const e=super.dispose();if(e.refCountAfterDispose===0&&this.optimizer!=null&&this.isOptimizerOwned){const t=Zh().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-Zh().numTensors}return e}getLossIdentifiers(){let e;if(typeof this.loss=="string")e=Zn(this.loss);else if(Array.isArray(this.loss)){for(const t of this.loss)if(typeof t!="string")throw new Error("Serialization of non-string loss is not supported.");e=this.loss.map(t=>Zn(t))}else{const t=Object.keys(this.loss);e={};const s=this.loss;for(const r of t)if(typeof s[r]=="string")e[r]=Zn(s[r]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[Zn(kl(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>Zn(kl(e)));{const e={};for(const t in this.metrics)e[t]=Zn(kl(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(e.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(e.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(e.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");const t=No(e.optimizer_config),s=kn(t);let r;if(typeof e.loss=="string")r=qs(e.loss);else if(Array.isArray(e.loss))r=e.loss.map(o=>qs(o));else if(e.loss!=null){r={};for(const o in e.loss)r[o]=qs(e.loss[o])}let a;if(Array.isArray(e.metrics))a=e.metrics.map(o=>qs(o));else if(e.metrics!=null){a={};for(const o in e.metrics)a[o]=qs(e.metrics[o])}this.compile({loss:r,metrics:a,optimizer:s})}async save(e,t){if(typeof e=="string"){const u=ex(e);if(u.length===0)throw new A(`Cannot find any save handlers for URL '${e}'`);if(u.length>1)throw new A(`Found more than one (${u.length}) save handlers for URL '${e}'`);e=u[0]}if(e.save==null)throw new A("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const s=await Jh(this.getNamedWeights(t)),i={modelTopology:this.toJSON(null,!1),format:UA,generatedBy:`TensorFlow.js tfjs-layers v${Ih}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){i.trainingConfig=this.getTrainingConfig();const u="optimizer",{data:c,specs:h}=await Jh(await this.optimizer.getWeights(),u);s.specs.push(...h),s.data=Yy([s.data,c])}return this.userDefinedMetadata!=null&&(qg(this.userDefinedMetadata,this.name,!0),i.userDefinedMetadata=this.userDefinedMetadata),i.weightData=s.data,i.weightSpecs=s.specs,e.save(i)}setUserDefinedMetadata(e){qg(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}ss.className="Model";K(ss);class Mw extends ss{}Mw.className="Functional";K(Mw);/**
7376 * @license
7377 * Copyright 2018 Google LLC
7378 *
7379 * Use of this source code is governed by an MIT-style
7380 * license that can be found in the LICENSE file or at
7381 * https://opensource.org/licenses/MIT.
7382 * =============================================================================
7383 */async function GA(n,e){"modelTopology"in n||(n={modelTopology:n}),n=n;let t=n.modelTopology;t.model_config!=null&&(t=t.model_config);const s=No(t),r=kn(s,e);if(n.weightsManifest!=null){const a=await ew(n.weightsManifest,n.pathPrefix,r.weights.map(i=>i.originalName)),o={};for(const i of r.weights)o[i.originalName]=a[i.originalName];r.loadWeights(o),Re(a)}return r}async function HA(n,e){if(e==null&&(e={}),typeof n=="string"){const t=Zy(n,e);if(t.length===0)t.push(sw(n,e));else if(t.length>1)throw new A(`Found more than one (${t.length}) load handlers for URL '${n}'`);n=t[0]}return jA(n,void 0,e)}async function jA(n,e,t){if(t==null&&(t={}),n.load==null)throw new A("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const s=await n.load();let r=s.modelTopology;r.model_config!=null&&(r=r.model_config);const a=t.strict==null?!0:t.strict,o=s.weightData!=null&&s.weightSpecs!=null&&a,i=kn(No(r),e,o),l=s.trainingConfig;if(l!=null&&i.loadTrainingConfig(l),s.userDefinedMetadata!=null&&i.setUserDefinedMetadata(s.userDefinedMetadata),s.weightData!=null){if(s.weightSpecs==null)throw new A("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:u,optimizerWeights:c}=qA(s.weightData,s.weightSpecs);i.loadWeights(u,a),i.optimizer!=null&&c.length>0&&await i.optimizer.setWeights(c),Re(u),Re(c.map(h=>h.tensor))}return i}function qA(n,e){const t=Md(n,e),s={},r=[];return e.forEach(a=>{a.group==="optimizer"?r.push({name:a.name,tensor:t[a.name]}):s[a.name]=t[a.name]}),{modelWeights:s,optimizerWeights:r}}class ir extends ss{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:ph("sequential_"),e.layers!=null)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(s=>
vendor: 2,815 bytes, line 7383
7383s<0))throw new A(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof ir||e instanceof ss;let s;if(t){if(s=e,s.outputs.length!==1)throw new A("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(s.inputs.length!==1)throw new A("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(e.inboundNodes.length===0){if(e.batchInputShape==null)throw new A("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const r=Nw({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(r)}if(t)this.outputs=s.outputs,this.inputs=s.inputs;else{if(e.inboundNodes.length!==1)throw new A(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(e.inboundNodes[0].outputTensors.length!==1)throw new A("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=$w(this.outputs[0])}this.inboundNodes=[],new Ch({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:or(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(r=>r.shape),outputShapes:this.outputs[0].shape})}else{const r=e.apply(this.outputs[0]);if(Array.isArray(r))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[r],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return this.model==null&&this.build(),this.model.call(e,t)}build(e){if(Ee(e),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new ss({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supp
7383ortsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,s=console.log){this.built||this.build(),super.summary(e,t,s)}setWeights(e){this.model==null&&this.build(),this.model.setWeights(e)}evaluate(e,t,s={}){if(!this.built)throw new xn("The model needs to be compiled before being used.");return this.model.evaluate(e,t,s)}async evaluateDataset(e,t){if(!this.built)throw new xn("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return this.model==null&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return this.model==null&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return this.model==null?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,s={}){if(!this.built)throw new xn("The model needs to be compiled before being used.");return this.model.fit(e,t,s)}async fitDataset(e,t){if(!this.built)throw new xn("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,s={},r=!1){let a,o={};if(t instanceof Array){if(t[0].className==null||t[0].className==="Merge")throw new A("Legacy serialization format not supported yet.");a=t}else I(t.layers!=null,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),a=t.layers,delete t.layers,o=t;const i=new e(o);if(!(i instanceof ir))throw new ye(`Sequential.fromConfig called on non-Sequential input: ${i}`);for(const l of a){const c=kn(l,void 0,r);r&&c.setFastWeightInitDuringBuild(!0),i.add(c)}return i}set stopTraining(e){if(this.model==null)throw new A("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(this.model==null)throw new A("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const t of this.layers){const s={};s.className=t.getClassName(),s.config=t.getConfig(),e.push(s)}return{name:this.name,layers:e}}}ir.className="Sequential";K(ir);/**
7384 * @license
7385 * Copyright 2018 Google LLC
7386 *
7387 * Use of this source code is governed by an MIT-style
7388 * license that can be found in the LICENSE file or at
7389 * https://opensource.org/licenses/MIT.
7390 * =============================================================================
7391 */function KA(n){return new ss(n)}function XA(n){return new ir(n)}function Ww(n){return Nw(n)}function YA(n,e){tn.registerCallbackConstructor(n,e)}/**
7392 * @license
7393 * Copyright 2018 Google LLC
7394 *
7395 * Use of this source code is governed by an MIT-style
7396 * license that can be found in the LICENSE file or at
7397 * https://opensource.org/licenses/MIT.
7398 * =============================================================================
7399 */let kt=class extends Mi{getConfig(){return{}}};class Uw extends kt{apply(e,t=1){return fD(e,t)}}Uw.className="elu";K(Uw);class Gw extends kt{apply(e){return Qc(e)}}Gw.className="selu";K(Gw);class Hw extends kt{apply(e){return Kn(e)}}Hw.className="relu";K(Hw);class jw extends kt{apply(e){return L(()=>Ss(6,Kn(e)))}}jw.className="relu6";K(jw);class qw extends kt{apply(e){return e}}qw.className="linear";K(qw);class Kw extends kt{apply(e){return Mn(e)}}Kw.className="sigmoid";K(Kw);class Xw extends kt{apply(e){return gD(e)}}Xw.className="hardSigmoid";K(Xw);class Yw extends kt{apply(e){return gr(e)}}Yw.className="softplus";K(Yw);class Jw extends kt{apply(e){return mD(e)}}Jw.className="softsign";K(Jw);class Zw extends kt{apply(e){return Is(e)}}Zw.className="tanh";K(Zw);let Lf=class extends kt{apply(e,t=-1){return sl(e,t)}};Lf.className="softmax";K(Lf);class Qw extends kt{apply(e,t=-1){return qc(e,t)}}Qw.className="logSoftmax";K(Qw);class e0 extends kt{apply(e){return L(()=>L(()=>{const t=Math.sqrt(2),s=O(.5,te(1,Hc(he(e,t))));return O(e,s)}))}}e0.className="gelu";K(e0);class t0 extends kt{apply(e){return L(()=>O(.5,O(e,te(1,Is(O(ln(he(2,Math.PI)),te(e,O(.044715,As(e,3)))))))))}}t0.className="gelu_new";K(t0);
vendor: 14,519 bytes, lines 7399-7431
7399class n0 extends kt{apply(e){return L(()=>O(e,Is(gr(e))))}}n0.className="mish";K(n0);class s0 extends kt{apply(e,t=1){return L(()=>O(Mn(O(e,t)),e))}}s0.className="swish";K(s0);function Ts(n){return n.getClassName()}function qh(n,e={}){return ol(n,Wi.getMap().classNameMap,e,"activation")}function Es(n){if(n==null){const e={};return e.className="linear",e.config={},qh(e)}if(typeof n=="string"){const e={};return e.className=n,e.config={},qh(e)}else return n instanceof kt?n:qh(n)}/**
7400 * @license
7401 * Copyright 2018 Google LLC
7402 *
7403 * Use of this source code is governed by an MIT-style
7404 * license that can be found in the LICENSE file or at
7405 * https://opensource.org/licenses/MIT.
7406 * =============================================================================
7407 */function Pf(n){if(n!=null&&typeof n!="object")throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${n}`)}class r0 extends Mi{}class hl extends r0{constructor(e){super(),Pf(e),this.l1=e==null||e.l1==null?.01:e.l1,this.l2=e==null||e.l2==null?.01:e.l2,this.hasL1=this.l1!==0,this.hasL2=this.l2!==0}apply(e){return L(()=>{let t=et([1]);return this.hasL1&&(t=te(t,oe(O(this.l1,rt(e))))),this.hasL2&&(t=te(t,oe(O(this.l2,ll(e))))),D(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}hl.className="L1L2";K(hl);function JA(n){return Pf(n),new hl({l1:n!=null?n.l1:null,l2:0})}function ZA(n){return Pf(n),new hl({l2:n!=null?n.l2:null,l1:0})}const Qg={l1l2:"L1L2"};function Le(n){return gf(n)}function ey(n,e={}){return ol(n,Wi.getMap().classNameMap,e,"regularizer")}function Ge(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in Qg?Qg[n]:n,config:{}};return ey(t)}else return n instanceof r0?n:ey(n)}/**
7408 * @license
7409 * Copyright 2018 Google LLC
7410 *
7411 * Use of this source code is governed by an MIT-style
7412 * license that can be found in the LICENSE file or at
7413 * https://opensource.org/licenses/MIT.
7414 * =============================================================================
7415 */class zf extends Ce{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=ge(e);let s=Kn(e);return this.maxValue!=null&&(s=Mt(s,0,this.maxValue)),s}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}zf.className="ReLU";K(zf);class Vf extends Ce{constructor(e){super(e??{}),this.DEFAULT_ALPHA=.3,e==null&&(e={}),this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){const s=ge(e);return Ac(s,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}Vf.className="LeakyReLU";K(Vf);class Bf extends Ce{constructor(e){if(super(e??{}),this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Ue(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Ge(e.alphaRegularizer),this.alphaConstraint=it(e.alphaConstraint),e.sharedAxes==null)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else if(typeof e.sharedAxes=="number")this.sharedAxes=[e.sharedAxes];else throw new A(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){e=Ee(e);const t=e.slice(1);if(this.sharedAxes!=null)for(const r of this.sharedAxes)t[r-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const s={};if(this.sharedAxes!=null)for(let r=1;r<e.length;++r)s[r]=e[r];this.inputSpec=[new tt({ndim:e.length,axes:s})],this.built=!0}call(e,t){return e=ge(e),Oc(e,this.alpha.read())}getConfig(){const e={alphaInitializer:qe(this.alphaInitializer),alphaRegularizer:Le(this.alphaRegularizer),alphaConstraint:ot(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}}Bf.className="PReLU";K(Bf);let Mf=class extends Ce{constructor(e){if(super(e??{}),this.DEFAULT_ALPHA=1,e==null&&(e={}),e.alpha!=null&&e.alpha!==this.DEFAULT_ALPHA)throw new ye(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`);this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){const s=ge(e);return Bi(s)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};Mf.className="ELU";K(Mf);class Wf extends Ce{constructor(e){super(e??{}),this.DEFAULT_THETA=1,e==null&&(e={}),this.theta=e.theta==null?this.DEFAULT_THETA:e.theta}call(e,t){const s=ge(e);return O(s,ee(Lt(s,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){const e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}}Wf.className="ThresholdedReLU";K(Wf);class Uf extends Ce{constructor(e){super(e??{}),this.DEFAULT_AXIS=1,e==null&&(e={}),this.softmax=new Lf().apply,this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis}call(e,t){return L(()=>{let s=ge(e);const r=t.mask;if(r!=null){const a=O(ie(Vt(s.shape),ee(r,s.dtype)),pe(-1e9));s=te(s,a)}return this.axis instanceof Array?this.axis.length>1?Wt(ie(s,Yi(s,this.axis,!0))):this.softmax(s,this.axis[0]):this.softmax(s,this.axis)})}computeOutputShape(e){return e}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}Uf.className="Softmax";K(Uf);/**
7416 * @license
7417 * Copyright 2018 Google LLC
7418 *
7419 * Use of this source code is governed by an MIT-style
7420 * license that can be found in the LICENSE file or at
7421 * https://opensource.org/licenses/MIT.
7422 * =============================================================================
7423 */function Tr(n,e,t){if(typeof n=="number")return or(n,e);if(n.length!==e)throw new A(`The ${t} argument must be an integer or tuple of ${e} integers. Received: ${n.length} elements.`);for(let s=0;s<e;++s){const r=n[s];if(!cD(r))throw new A(`The ${t} argument must be an integer or tuple of ${e} integers. Received: ${JSON.stringify(n)} including a non-integer number ${r}`)}return n}function Tn(n,e,t,s,r=1){if(n==null)return n;const a=e+(e-1)*(r-1);let o;return t==="same"?o=n:o=n-a+1,Math.floor((o+s-1)/s)}function Vn(n,e,t,s){if(n==null)return null;if(s==="valid")n=n*e+ks([t-e,0]);else if(s==="same")n=n*e;else throw new A(`Unsupport padding mode: ${s}.`);return n}/**
7424 * @license
7425 * Copyright 2018 Google LLC
7426 *
7427 * Use of this source code is governed by an MIT-style
7428 * license that can be found in the LICENSE file or at
7429 * https://opensource.org/licenses/MIT.
7430 * =============================================================================
7431 */function Gf(n,e){return L(()=>(Ze(e),e==="channelsFirst"?Ne(n,[0,2,3,1]):n))}function a0(n,e){return L(()=>(Ze(e),e==="channelsFirst"?Ne(n,[0,2,3,4,1]):n))}function QA(n,e,t,s=1,r="valid",a,o=1){return L(()=>{if(a==null&&(a=Dn()),Ze(a),n.shape.length!==3)throw new A(`The input of a conv1dWithBias operation should be 3, but is ${n.shape.length} instead.`);if(e.shape.length!==3)throw new A(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(t!=null&&t.shape.length!==1)throw new A(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if(a==="channelsFirst"&&(n=Ne(n,[0,2,1])),r==="causal")throw new ye("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let i=Mc(n,e,s,r==="same"?"same":"valid","NWC",o);return t!=null&&(i=Fn(i,t)),i})}function ty(n,e,t,s=[1,1],r="valid",a,o,i=null){return L(()=>{if(a==null&&(a=Dn()),Ze(a),n.rank!==3&&n.rank!==4)throw new A(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${n.rank}.`);if(e.rank!==3&&e.rank!==4)throw new A(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${n.rank}.`);let l=Gf(n,a);if(r==="causal")throw new ye("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=Bb({x:l,filter:e,strides:s,pad:r==="same"?"same":"valid",dilations:o,dataFormat:"NHWC",bias:t,activation:i}),a==="channelsFirst"&&(l=Ne(l,[0,3,1,2])),l})}function eO(n,e,t,s=[1,1,1],r="valid",a,o){return L(()=>{if(a==null&&(a=Dn()),Ze(a),n.rank!==4&&n.rank!==5)throw new A(`conv3dWithBias expects input to be of rank 4 or 5, but received ${n.rank}.`);if(e.rank!==4&&e.rank!==5)throw new A(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${n.rank}.`);let i=a0(n,a);if(r==="causal")throw new ye("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return i=Cp(i,e,s,r==="same"?"same":"valid","NDHWC",o),t!=null&&(i=Fn(i,t)),a==="channelsFirst"&&(i=Ne(i,[0,4,1,2,3])),i})}class Sh extends Ce{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Sh.verifyArgs(t),this.rank=e,ht(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new ye(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Tr(t.kernelSize,e,"kernelSize"),this.strides=Tr(t.strides==null?1:t.strides,e,"strides"),this.padding=t.padding==null?"valid":t.padding,pn(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,Ze(this.dataFormat),this.activation=Es(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=Ue(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=it(t.biasConstraint),this.biasRegularizer=Ge(t.biasRegularizer),this.activityRegularizer=Ge(t.activityRegularizer),this.dilationRate=Tr(t.dilationRate==null?1:t.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new A(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new A(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new A(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(e){if(zn("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!yf(e.kernelSize,"number",1,3))throw new A(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Ts(this.activation),useBias:this.useBias,biasInitializer:qe(this.biasInitializer),biasRegularizer:Le(this.biasRegularizer),activityRegularizer:Le(this.activityRegularizer),biasConstraint:ot(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Wa extends Sh{constructor(e,t){super(e,t),this.kernel=null,Wa.verifyArgs(t),this.filters=t.filters,ht(this.filters,"filters"),this.kernelInitializer=Ue(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=it(t.kernelConstraint),this.kernelRegularizer=Ge(t.kernelRegularizer)}build(e){e=Ee(e);const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A(`The channel dimension of the input should be defined. Found ${e[t]}`);const s=e[t],r=this.kernelSize.concat([s,this.filters]);this.kernel=this.addWeight("kernel",r,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:s}}],this.built=!0}call(e,t){return L(()=>{e=ge(e);let s;const r=this.bias==null?null:this.bias.read(),a=fw(this.activation.getClassName());if(a!=null&&this.rank===2)s=ty(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate,a);else{if(this.rank===1)s=QA(e,this.kernel.read(),r,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)s=ty(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)s=eO(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new ye("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(s=this.activation.apply(s))}return s})}computeOutputShape(e){e=Ee(e);const t=[],s=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let a=0;a<s.length;++a){const o=Tn(s[a],this.kernelSize[a],this.padding,this.strides[a],typeof this.dilationRate=="number"?this.dilationRate:this.dilationRate[a]);t.push(o)}let r=[e[0]];return this.dataFormat==="channelsLast"?(r=r.concat(t),r.push(this.filters)):(r.push(this.filters),r=r.concat(t)),r}getConfig(){const e={filters:this.filters,kernelInitializer:qe(this.kernelInitializer),kernelRegularizer:Le(this.kernelRegularizer),kernelConstraint:ot(this.kernelConstraint)},t=super.getConfig();return Object.assign(e,t),e}static verifyArgs(e){if(!("filters"in e)||typeof e.filters!="number"||e.filters<1)throw new A(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`)}}class Ua extends Wa{constructor(e){super(2,e),Ua.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!yf(e.kernelSize,"number",1,2))throw new A(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Ua.className="Conv2D";K(Ua);class Ga extends Wa{constructor(e){super(3,e),Ga.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new A(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Ga.className="Conv3D";K(Ga);class Hf extends Ua{constructor(e){if(super(e),this.inputSpec=[new tt({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new A(`Conv2DTranspose currently supports only padding modes '
7431same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Ee(e),e.length!==4)throw new A("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A("The channel dimension of the inputs should be defined. Found `None`.");const s=e[t],r=this.kernelSize.concat([this.filters,s]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new tt({ndim:4,axes:{[t]:s}})],this.built=!0}call(e,t){return L(()=>{let s=ge(e);if(s.shape.length!==4)throw new A(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const r=s.shape,a=r[0];let o,i;this.dataFormat==="channelsFirst"?(o=2,i=3):(o=1,i=2);const l=r[o],u=r[i],c=this.kernelSize[0],h=this.kernelSize[1],d=this.strides[0],p=this.strides[1],f=Vn(l,d,c,this.padding),g=Vn(u,p,h,this.padding),m=[a,f,g,this.filters];this.dataFormat!=="channelsLast"&&(s=Ne(s,[0,2,3,1]));let y=Wc(s,this.kernel.read(),m,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(y=Ne(y,[0,3,1,2])),this.bias!=null&&(y=Fn(y,this.bias.read(),this.dataFormat)),this.activation!=null&&(y=this.activation.apply(y)),y})}computeOutputShape(e){e=Ee(e);const t=e.slice();let s,r,a;this.dataFormat==="channelsFirst"?(s=1,r=2,a=3):(s=3,r=1,a=2);const o=this.kernelSize[0],i=this.kernelSize[1],l=this.strides[0],u=this.strides[1];return t[s]=this.filters,t[r]=Vn(t[r],l,o,this.padding),t[a]=Vn(t[a],u,i,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}Hf.className="Conv2DTranspose";K(Hf);class jf extends Ga{constructor(e){if(super(e),this.inputSpec=[new tt({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new A(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Ee(e),e.length!==5)throw new A("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new A("The channel dimension of the inputs should be defined. Found `None`.");const s=e[t],r=this.kernelSize.concat([this.filters,s]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new tt({ndim:5,axes:{[t]:s}})],this.built=!0}call(e,t){return L(()=>{let s=ge(e);if(s.shape.length!==5)throw new A(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const r=s.shape,a=r[0];let o,i,l;this.dataFormat==="channelsFirst"?(l=2,o=3,i=4):(l=1,o=2,i=3);const u=r[l],c=r[o],h=r[i],d=this.kernelSize[0],p=this.kernelSize[1],f=this.kernelSize[2],g=this.strides[0],m=this.strides[1],y=this.strides[2],x=Vn(u,g,d,this.padding),v=Vn(c,m,p,this.padding),b=Vn(h,y,f,this.padding),C=[a,x,v,b,this.filters];this.dataFormat!=="channelsLast"&&(s=Ne(s,[0,2,3,4,1]));let $=$p(s,this.kernel.read(),C,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&($=Ne($,[0,4,1,2,3])),this.bias!==null&&($=Fn($,this.bias.read(),this.dataFormat)),this.activation!==null&&($=this.activation.apply($)),$})}computeOutputShape(e){e=Ee(e);const t=e.slice();let s,r,a,o;this.dataFormat==="channelsFirst"?(s=1,r=2,a=3,o=4):(s=4,r=1,a=2,o=3);const i=this.kernelSize[0],l=this.kernelSize[1],u=this.kernelSize[2],c=this.strides[0],h=this.strides[1],d=this.strides[2];return t[s]=this.filters,t[r]=Vn(t[r],c,i,this.padding),t[a]=Vn(t[a],h,l,this.padding),t[o]=Vn(t[o],d,u,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}jf.className="Conv3DTranspose";K(jf);class o0 extends Wa{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,t.filters==null)throw new A("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(t.kernelInitializer!=null||t.kernelRegularizer!=null||t.kernelConstraint!=null)throw new A("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(t.padding!=null&&t.padding!=="same"&&t.padding!=="valid")throw new A(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=t.depthMultiplier==null?1:t.depthMultiplier,this.depthwiseInitializer=Ue(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Ge(t.depthwiseRegularizer),this.depthwiseConstraint=it(t.depthwiseConstraint),this.pointwiseInitializer=Ue(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Ge(t.pointwiseRegularizer),this.pointwiseConstraint=it(t.pointwiseConstraint)}build(e){if(e=Ee(e),e.length<this.rank+2)throw new A(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank+2}, but received input shape: ${JSON.stringify(e)}`);const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null||e[t]<0)throw new A(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`);const s=e[t],r=this.kernelSize.concat([s,this.depthMultiplier]),a=[];for(let i=0;i<this.rank;++i)a.push(1);a.push(s*this.depthMultiplier,this.filters);const o=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",r,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,o,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",a,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,o,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,o,this.biasConstraint):this.bias=null,this.inputSpec=[new tt({ndim:this.rank+2,axes:{[t]:s}})],this.built=!0}call(e,t){return L(()=>{e=ge(e);let s;if(this.rank===1)throw new ye("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Ne(e,[0,2,3,1])),s=eh(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(s=Fn(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),this.dataFormat==="channelsFirst"&&(s=Ne(s,[0,3,1,2])),s})}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=qe(this.depthwiseInitializer),e.pointwiseInitializer=qe(this.pointwiseInitializer),e.depthwiseRegularizer=Le(this.depthwiseRegularizer),e.pointwiseRegularizer=Le(this.pointwiseRegularizer),e.depthwiseConstraint=ot(this.depthwiseConstraint),e.pointwiseConstraint=ot(this.pointwiseConstraint),e}}o0.className="SeparableConv";class qf extends o0{constructor(e){super(2,e)}}qf.className="SeparableConv2D";K(qf);class dl extends Wa{constructor(e){super(1,e),dl.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!yf(e.kernelSize,"number",1,1))throw new A(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}dl.className="Conv1D";K(dl);class Kf extends Ce{constructor(e){super(e),typeof e.cropping=="number"?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:typeof e.cropping[0]=="number"?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=e.dataFormat===void 0?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return this.dataFormat==="channelsFirst"?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return L(()=>
vendor: 4,726 bytes, lines 7431-7447
7431{if(e=ge(e),this.dataFormat==="channelsLast"){const s=Sl(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return Sl(s,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const s=Sl(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return Sl(s,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}Kf.className="Cropping2D";K(Kf);class Xf extends Ce{constructor(e){super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=e.size==null?this.DEFAULT_SIZE:e.size,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Ze(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,iD(this.interpolation)}computeOutputShape(e){if(this.dataFormat==="channelsFirst"){const t=e[2]==null?null:this.size[0]*e[2],s=e[3]==null?null:this.size[1]*e[3];return[e[0],e[1],t,s]}else{const t=e[1]==null?null:this.size[0]*e[1],s=e[2]==null?null:this.size[1]*e[2];return[e[0],t,s,e[3]]}}call(e,t){return L(()=>{let s=ge(e);const r=s.shape;if(this.dataFormat==="channelsFirst"){s=Ne(s,[0,2,3,1]);const a=this.size[0]*r[2],o=this.size[1]*r[3],i=this.interpolation==="nearest"?yn.resizeNearestNeighbor(s,[a,o]):yn.resizeBilinear(s,[a,o]);return Ne(i,[0,3,1,2])}else{const a=this.size[0]*r[1],o=this.size[1]*r[2];return this.interpolation==="nearest"?yn.resizeNearestNeighbor(s,[a,o]):yn.resizeBilinear(s,[a,o])}})}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}Xf.className="UpSampling2D";K(Xf);/**
7432 * @license
7433 * Copyright 2018 Google LLC
7434 *
7435 * Use of this source code is governed by an MIT-style
7436 * license that can be found in the LICENSE file or at
7437 * https://opensource.org/licenses/MIT.
7438 * =============================================================================
7439 */function tO(n,e,t=[1,1],s="valid",r,a){return L(()=>{r==null&&(r=Dn()),Ze(r);let o=Gf(n,r);if(n.rank!==4)throw new A(`Input for depthwiseConv2d is required to be 4-D, but is instead ${n.rank}-D`);if(e.rank!==4)throw new A(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return o=_a(o,e,t,s==="same"?"same":"valid","NHWC",a),r==="channelsFirst"&&(o=Ne(o,[0,3,1,2])),o})}class Yf extends Sh{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=Ue(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=it(e.depthwiseConstraint),this.depthwiseRegularizer=Ge(e.depthwiseRegularizer)}build(e){if(e=Ee(e),e.length<4)throw new A(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t=this.dataFormat==="channelsFirst"?1:3;if(e[t]==null||e[t]<0)throw new A(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const s=e[t],r=[this.kernelSize[0],this.kernelSize[1],s,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[s*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return L(()=>{e=ge(e);let s=tO(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(s=Fn(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),s})}computeOutputShape(e){e=Ee(e);const t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=Tn(t,this.kernelSize[0],this.padding,this.strides[0]),o=Tn(s,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],r,a,o]:[e[0],a,o,r]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=qe(this.depthwiseInitializer),e.depthwiseRegularizer=Le(this.depthwiseRegularizer),e.depthwiseConstraint=ot(this.depthwiseRegularizer),e}}Yf.className="DepthwiseConv2D";K(Yf);/**
7440 * @license
7441 * Copyright 2018 Google LLC
7442 *
7443 * Use of this source code is governed by an MIT-style
7444 * license that can be found in the LICENSE file or at
7445 * https://opensource.org/licenses/MIT.
7446 * =============================================================================
7447 */function i0(n,e,t,s){if(Array.isArray(n)){if(e!=null||t!=null)throw new A("When input
7447s is an array, neither initialState or constants should be provided");s!=null&&(t=n.slice(n.length-s,n.length),n=n.slice(0,n.length-s)),n.length>1&&(e=n.slice(1,n.length)),n=n[0]}function r(a){return a==null||Array.isArray(a)?a:[a]}return e=r(e),t=r(t),{inputs:n,initialState:e,constants:t}}function l0(n,e,t,s=!1,r,a,o=!1,i=!1){return L(()=>{const l=e.shape.length;if(l<3)throw new A(`Input should be at least 3D, but is ${l}D.`);const u=[1,0].concat(Rn(2,l));e=Ne(e,u),o&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),r!=null&&(r=ee(ee(r,"bool"),"float32"),r.rank===l-1&&(r=mt(r,-1)),r=Ne(r,u)),s&&(e=un(e,0),r!=null&&(r=un(r,0)));const c=[];let h,d=t;const p=e.shape[0],f=cn(e);let g;r!=null&&(g=cn(r));for(let y=0;y<p;++y){const x=f[y],v=L(()=>n(x,d));if(r==null)h=v[0],d=v[1];else{const b=L(()=>{const C=g[y],$=ie(Zt(C),C),S=te(O(v[0],C),O(d[0],$)),k=d.map((T,E)=>te(O(v[1][E],C),O(T,$)));return{output:S,newStates:k}});h=b.output,d=b.newStates}i&&c.push(h)}let m;return i&&(m=Ot(c,1)),[h,m,d]})}class Ln extends Ce{constructor(e){super(e);let t;if(e.cell==null)throw new A("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?t=new Eh({cells:e.cell}):t=e.cell,t.stateSize==null)throw new A("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=e.returnSequences==null?!1:e.returnSequences,this.returnState=e.returnState==null?!1:e.returnState,this.goBackwards=e.goBackwards==null?!1:e.goBackwards,this._stateful=e.stateful==null?!1:e.stateful,this.unroll=e.unroll==null?!1:e.unroll,this.supportsMasking=!0,this.inputSpec=[new tt({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return Rn(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){od(e)&&(e=e[0]),e=e;let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const s=t[0];let r;if(this.returnSequences?r=[e[0],e[1],s]:r=[e[0],s],this.returnState){const a=[];for(const o of t)a.push([e[0],o]);return[r].concat(a)}else return r}computeMask(e,t){return L(()=>{Array.isArray(t)&&(t=t[0]);const s=this.returnSequences?t:null;if(this.returnState){const r=this.states.map(a=>null);return[s].concat(r)}else return s})}get states(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let s=0;s<e;++s)t.push(null);return t}else return this.states_}set states(e){this.states_=e}build(e){if(this.numConstants!=null)throw new ye("Constants support is not implemented in RNN yet.");od(e)&&(e=e[0]),e=e;const t=this.stateful?e[0]:null,s=e.slice(2);this.inputSpec[0]=new tt({shape:[t,null,...s]});const r=[e[0]].concat(e.slice(2));this.cell.build(r);let a;if(Array.isArray(this.cell.stateSize)?a=this.cell.stateSize:a=[this.cell.stateSize],this.stateSpec!=null){if(!ke(this.stateSpec.map(o=>o.shape[o.shape.length-1]),a))throw new A(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=a.map(o=>new tt({shape:[null,o]}));this.stateful&&this.resetStates()}resetStates(e,t=!1){L(()=>{if(!this.stateful)throw new Pn("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape[0];if(s==null)throw new A("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>et([s,r])):this.states_=[et([s,this.cell.stateSize])];else if(e==null)Re(this.states_),this.keptStates!=null&&(Re(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>et([s,r])):this.states_[0]=et([s,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new A(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t===!0?this.keptStates.push(this.states_.slice()):Re(this.states_);for(let r=0;r<this.states_.length;++r){const a=e[r],o=Array.isArray(this.cell.stateSize)?this.cell.stateSize[r]:this.cell.stateSize,i=[s,o];if(!ke(a.shape,i))throw new A(`State ${r} is incompatible with layer ${this.name}: expected shape=${i}, received shape=${a.shape}`);this.states_[r]=a}}this.states_=this.states_.map(r=>ct(r.clone()))})}apply(e,t){let s=t==null?null:t.initialState,r=t==null?null:t.constants;t==null&&(t={});const a=i0(e,s,r,this.numConstants);
vendor: 23,733 bytes, lines 7447-7455
7447e=a.inputs,s=a.initialState,r=a.constants;let o=[],i=[];if(s!=null){t.initialState=s,o=o.concat(s),this.stateSpec=[];for(const u of s)this.stateSpec.push(new tt({shape:u.shape}));i=i.concat(this.stateSpec)}if(r!=null&&(t.constants=r,o=o.concat(r),this.numConstants=r.length),o[0]instanceof An){const u=[e].concat(o),c=this.inputSpec.concat(i),h=this.inputSpec;this.inputSpec=c;const d=super.apply(u,t);return this.inputSpec=h,d}else return super.apply(e,t)}call(e,t){return L(()=>{const s=t==null?null:t.mask,r=t==null?null:t.training;let a=t==null?null:t.initialState;e=ge(e),a==null&&(this.stateful?a=this.states_:a=this.getInitialState(e));const o=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(a.length!==o)throw new A(`RNN Layer has ${o} state(s) but was passed ${a.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const i={training:r},u=l0((f,g)=>{const m=this.cell.call([f].concat(g),i);return[m[0],m.slice(1)]},e,a,this.goBackwards,s,null,this.unroll,this.returnSequences),c=u[0],h=u[1],d=u[2];this.stateful&&this.resetStates(d,r);const p=this.returnSequences?h:c;return this.returnState?[p].concat(d):p})}getInitialState(e){return L(()=>{let t=et(e.shape);return t=oe(t,[1,2]),t=il(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(s=>s>1?rd(t,[1,s]):t):this.cell.stateSize>1?[rd(t,[1,this.cell.stateSize])]:[t]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(t.numConstants=this.numConstants);const s=this.cell.getConfig();return this.getClassName()===Ln.className&&(t.cell={className:this.cell.getClassName(),config:s}),Object.assign(Object.assign(Object.assign({},s),e),t)}static fromConfig(e,t,s={}){const r=t.cell,a=kn(r,s);return new e(Object.assign(t,{cell:a}))}}Ln.className="RNN";K(Ln);class pl extends Ce{}class kh extends pl{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,ht(this.units,"units"),this.activation=Es(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ue(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ue(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ue(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ge(e.kernelRegularizer),this.recurrentRegularizer=Ge(e.recurrentRegularizer),this.biasRegularizer=Ge(e.biasRegularizer),this.kernelConstraint=it(e.kernelConstraint),this.recurrentConstraint=it(e.recurrentConstraint),this.biasConstraint=it(e.biasConstraint),this.dropout=Vr([1,ks([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=Vr([1,ks([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Ee(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return L(()=>{if(e=e,e.length!==2)throw new A(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let s=e[1];e=e[0];const r=t.training==null?!1:t.training;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Rs({ones:()=>Zt(e),rate:this.dropout,training:r,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Rs({ones:()=>Zt(s),rate:this.recurrentDropout,training:r,dropoutFunc:this.dropoutFunc}));let a;const o=this.dropoutMask,i=this.recurrentDropoutMask;o!=null?a=Gn(O(e,o),this.kernel.read()):a=Gn(e,this.kernel.read()),this.bias!=null&&(a=Fn(a,this.bias.read())),i!=null&&(s=O(s,i));let l=te(a,Gn(s,this.recurrentKernel.read()));return this.activation!=null&&(l=this.activation.apply(l)),[l,l]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Ts(this.activation),useBias:this.useBias,kernelInitializer:qe(this.kernelInitializer),recurrentInitializer:qe(this.recurrentInitializer),biasInitializer:qe(this.biasInitializer),kernelRegularizer:Le(this.kernelRegularizer),recurrentRegularizer:Le(this.recurrentRegularizer),biasRegularizer:Le(this.biasRegularizer),activityRegularizer:Le(this.activityRegularizer),kernelConstraint:ot(this.kernelConstraint),recurrentConstraint:ot(this.recurrentConstraint),biasConstraint:ot(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),t)}}kh.className="SimpleRNNCell";K(kh);class Jf extends Ln{constructor(e){e.cell=new kh(e),super(e)}call(e,t){return L(()=>{this.cell.dropoutMask!=null&&(Re(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Re(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,r=t==null?null:t.training,a=t==null?null:t.initialState;return super.call(e,{mask:s,training:r,initialState:a})})}static fromConfig(e,t){return new e(t)}}Jf.className="SimpleRNN";K(Jf);class Th extends pl{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new A("GRUCell does not support reset_after parameter set to true.");this.units=e.units,ht(this.units,"units"),this.activation=Es(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Es(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ue(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ue(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ue(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Ge(e.kernelRegularizer),this.recurrentRegularizer=Ge(e.recurrentRegularizer),this.biasRegularizer=Ge(e.biasRegularizer),this.kernelConstraint=it(e.kernelConstraint),this.recurrentConstraint=it(e.recurrentConstraint),this.biasConstraint=it(e.biasConstraint),this.dropout=Vr([1,ks([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=Vr([1,ks([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Ee(e);const t=e[e.length-1];this.kernel=this.addWeight("kernel",[t,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return L(()=>{if(e=e,e.length!==2)throw new A(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const s=t.training==null?!1:t.training;let r=e[1];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Rs({ones:()=>Zt(e),rate:this.dropout,training:s,count:3,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Rs({ones:()=>Zt(r),rate:this.recurrentDropout,training:s,count:3,dropoutFunc:this.dropoutFunc}));const a=this.dropoutMask,o=this.recurrentDropoutMask;let i,l,u;0<this.dropout&&this.dropout<1&&(e=O(e,a[0]));let c=Gn(e,this.kernel.read());this.useBias&&(c=Fn(c,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(r=O(r,o[0]));const h=this.recurrentKernel.read(),[d,p]=Bt(h,[2*this.units,this.units],h.rank-1),f=Gn(r,d),[g,m,y]=Bt(c,3,c.rank-1),[x,v]=Bt(f,2,f.rank-1);i=this.recurrentActivation.apply(te(g,x)),l=this.recurrentActivation.apply(te(m,v));const b=Gn(O(l,r),p);u=this.activation.apply(te(y,b));const C=te(O(i,r),O(te(1,Ve(i)),u));return[C,C]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Ts(this.activation),recurrentActivation:Ts(this.recurrentActivation),useBias:this.useBias,kernelInitializer:qe(this.kernelInitializer),recurrentInitializer:qe(this.recurrentInitializer),biasInitializer:qe(this.biasInitializer),kernelRegularizer:Le(this.kernelRegularizer),recurrentRegularizer:Le(this.recurrentRegularizer),biasRegularizer:Le(this.biasRegularizer),activityRegularizer:Le(this.activityRegularizer),kernelConstraint:ot(this.kernelConstraint),recurrentConstraint:ot(this.recurrentConstraint),biasConstraint:ot(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign(Object.assign({},e),t)}}Th.className="GRUCell";K(Th);class Zf extends Ln{constructor(e){e.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Th(e),super(e)}call(e,t){return L(()=>{this.cell.dropoutMask!=null&&(Re(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Re(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,r=t==null?null:t.training,a=t==null?null:t.initialState;return super.call(e,{mask:s,training:r,initialState:a})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}Zf.className="GRU";K(Zf);class fl extends pl{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,ht(this.units,"units"),this.activation=Es(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Es(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ue(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ue(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ue(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Ge(e.kernelRegularizer),this.recurrentRegularizer=Ge(e.recurrentRegularizer),this.biasRegularizer=Ge(e.biasRegularizer),this.kernelConstraint=it(e.kernelConstraint),this.recurrentConstraint=it(e.recurrentConstraint),this.biasConstraint=it(e.biasConstraint),this.dropout=Vr([1,ks([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=Vr([1,ks([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;e=Ee(e);const s=e[e.length-1];this.kernel=this.addWeight("kernel",[s,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);let r;if(this.useBias){if(this.unitForgetBias){const a=this.biasInitializer,o=this.units;r=new(t=class extends vn{apply(l,u){const c=a.apply([o]),h=new mh().apply([o]),d=a.apply([o*2]);return zg(zg(c,h),d)}},t.className="CustomInit",t)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return L(()=>{const s=t.training==null?!1:t.training;if(e=e,e.length!==3)throw new A(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1];const a=e[2];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Rs({ones:()=>Zt(e),rate:this.dropout,training:s,count:4,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Rs({ones:()=>Zt(r),rate:this.recurrentDropout,training:s,count:4,dropoutFunc:this.dropoutFunc}));const o=this.dropoutMask,i=this.recurrentDropoutMask;let l,u,c,h;0<this.dropout&&this.dropout<1&&(e=O(e,o[0]));let d=Gn(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(r=O(r,i[0])),d=te(d,Gn(r,this.recurrentKernel.read())),this.useBias&&(d=Fn(d,this.bias.read()));const[p,f,g,m]=Bt(d,4,d.rank-1);l=this.recurrentActivation.apply(p),u=this.recurrentActivation.apply(f),c=te(O(u,a),O(l,this.activation.apply(g))),h=this.recurrentActivation.apply(m);const y=O(h,this.activation.apply(c));return[y,y,c]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Ts(this.activation),recurrentActivation:Ts(this.recurrentActivation),useBias:this.useBias,kernelInitializer:qe(this.kernelInitializer),recurrentInitializer:qe(this.recurrentInitializer),biasInitializer:qe(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:Le(this.kernelRegularizer),recurrentRegularizer:Le(this.recurrentRegularizer),biasRegularizer:Le(this.biasRegularizer),activityRegularizer:Le(this.activityRegularizer),kernelConstraint:ot(this.kernelConstraint),recurrentConstraint:ot(this.recurrentConstraint),biasConstraint:ot(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign(Object.assign({},e),t)}}fl.className="LSTMCell";K(fl);class Qf extends Ln{constructor(e){e.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new fl(e),super(e)}call(e,t){return L(()=>{this.cell.dropoutMask!=null&&(Re(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Re(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=t==null?null:t.mask,r=t==null?null:t.training,a=t==null?null:t.initialState;return super.call(e,{mask:s,training:r,initialState:a})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}Qf.className="LSTM";K(Qf);class Eh extends pl{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return L(()=>{e=e;let s=e.slice(1);const r=[];for(const i of this.cells.slice().reverse())Array.isArray(i.stateSize)?r.push(s.splice(0,i.stateSize.length)):r.push(s.splice(0,1));r.reverse();const a=[];let o;for(let i=0;i<this.cells.length;++i){const l=this.cells[i];s=r[i],i===0?o=[e[0]].concat(s):o=[o[0]].concat(s),o=l.call(o,t),a.push(o.slice(1))}s=[];for(const i of a.slice().reverse())s.push(...i);return[o[0]].concat(s)})}build(e){od(e)&&(e=e[0]),e=e;let t;this.cells.forEach((s,r)=>{er(`RNNCell_${r}`,()=>{s.build(e),Array.isArray(s.stateSize)?t=s.stateSize[0]:t=s.stateSize,e=[e[0],t]})}),this.built=!0}getConfig(){const e=super.getConfig(),t=a=>({className:a.getClassName(),config:a.getConfig()}),r={cells:this.cells.map(t)};return Object.assign(Object.assign({},e),r)}static fromConfig(e,t,s={}){const r=[];for(const a of t.cells)r.push(kn(a,s));return new e({cells:r})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const s of this.cells)t.push(...s.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return id(e)}setWeights(e){const t=[];for(const s of this.cells){const r=s.weights.length,a=e.splice(r);for(let o=0;o<s.weights.length;++o)t.push([s.weights[o],a[o]])}Sf(t)}}Eh.className="StackedRNNCells";K(Eh);function Rs(n){const{ones:e,rate:t,training:s=!1,count:r=1,dropoutFunc:a}=n,o=()=>a!=null?a(e(),t):vw(e(),t),i=()=>ul(o,e,s);return!r||r<=1?ct(i().clone()):Array(r).fill(void 0).map(i).map(u=>ct(u.clone()))}/**
7448 * @license
7449 * Copyright 2020 Google LLC
7450 *
7451 * Use of this source code is governed by an MIT-style
7452 * license that can be found in the LICENSE file or at
7453 * https://opensource.org/licenses/MIT.
7454 * =============================================================================
7455 */var nO=function(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t};class u0 extends Ln{constructor(e){if(e.unroll)throw new ye("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new ye("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new tt({ndim:5})]}call(e,t){return L(()=>{if(this.cell.dropoutMask!=null&&(Re(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Re(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new A("ConvRNN2D cell does not support constants");const s=t==null?null:t.mask,r=t==null?null:t.training,a=t==null?null:t.initialState;return super.call(e,{mask:s,training:r,initialState:a})})}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return L(()=>{const{stateSize:t}=this.cell,s=e.shape,r=this.computeSingleOutputShape(s),a=[r[0],...r.slice(2)],o=et(a);return Array.isArray(t)?Array(t.length).fill(o):[o]})}resetStates(e,t=!1){L(()=>{if(!this.stateful)throw new Pn("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape,r=this.computeSingleOutputShape(s),a=[r[0],...r.slice(2)];if(s[0]==null)throw new A("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.getStates()==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>et(a)):this.states_=[et(a)];else if(e==null)Re(this.states_),this.keptStates!=null&&(Re(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>et(a)):this.states_[0]=et(a);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new A(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):Re(this.states_);for(let i=0;i<this.states_.length;++i){const l=e[i],u=a;if(!ke(l.shape,u))throw new A(`State ${i} is incompatible with layer ${this.name}: expected shape=${u}, received shape=${l.shape}`);this.states_[i]=l}}this.states_=this.states_.map(i=>ct(i.clone()))})}computeSingleOutputShape(e){const{dataFormat:t,filters:s,kernelSize:r,padding:a,strides:o,dilationRate:i}=this.cell,l=t==="channelsFirst",u=e[l?3:2],c=e[l?4:3],h=Tn(u,r[0],a,o[0],i[0]),d=Tn(c,r[1],a,o[1],i[1]);return[...e.slice(0,2),...l?[s,h,d]:[h,d,s]]}}u0.className="ConvRNN2D";class Rh extends fl{constructor(e){const{filters:t,kernelSize:s,strides:r,padding:a,dataFormat:o,dilationRate:i}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,ht(this.filters,"filters"),this.kernelSize=Tr(s,2,"kernelSize"),this.kernelSize.forEach(l=>ht(l,"kernelSize")),this.strides=Tr(r||1,2,"strides"),this.strides.forEach(l=>ht(l,"strides")),this.padding=a||"valid",pn(this.padding),this.dataFormat=o||"channelsLast",Ze(this.dataFormat),this.dilationRate=Tr(i||1,2,"dilationRate"),this.dilationRate.forEach(l=>ht(l,"dilationRate"))}build(e){var t;e=Ee(e);const s=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[s]==null)throw new A(`The channel dimension of the input should be defined. Found ${e[s]}`);const r=e[s],a=4,o=this.kernelSize.concat([r,this.filters*a]);this.kernel=this.addWeight("kernel",o,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const i=this.kernelSize.concat([this.filters,this.filters*a]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let l;if(this.unitForgetBias){const u=this.biasInitializer,c=this.filters;l=new(t=class extends vn{apply(d,p){const f=u.apply([c]),g=Vt([c]),m=u.apply([c*2]);return xf([f,g,m])}},t.className="CustomInit",t)}else l=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*a],null,l,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return L(()=>{if(e.length!==3)throw new A(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const s=t.training||!1,r=e[0],a=e[1],o=e[2],i=4;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Rs({ones:()=>Zt(r),rate:this.dropout,training:s,count:i,dropoutFunc:this.dropoutFunc}));const l=this.dropoutMask,u=(X,Y,Z)=>!Y||!Y[Z]?X:O(Y[Z],X);let c=u(r,l,0),h=u(r,l,1),d=u(r,l,2),p=u(r,l,3);0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Rs({ones:()=>Zt(a),rate:this.recurrentDropout,training:s,count:i,dropoutFunc:this.dropoutFunc}));const f=this.recurrentDropoutMask;let g=u(a,f,0),m=u(a,f,1),y=u(a,f,2),x=u(a,f,3);const v=3,[b,C,$,S]=Bt(this.kernel.read(),i,v),[k,T,E,_]=this.useBias?Bt(this.bias.read(),i):[null,null,null,null];c=this.inputConv(c,b,k,this.padding),h=this.inputConv(h,C,T,this.padding),d=this.inputConv(d,$,E,this.padding),p=this.inputConv(p,S,_,this.padding);const[z,P,V,B]=Bt(this.recurrentKernel.read(),i,v);g=this.recurrentConv(g,z),m=this.recurrentConv(m,P),y=this.recurrentConv(y,V),x=this.recurrentConv(x,B);const M=this.recurrentActivation.apply(te(c,g)),j=this.recurrentActivation.apply(te(h,m)),U=te(O(j,o),O(M,this.activation.apply(te(d,y)))),q=O(this.recurrentActivation.apply(te(p,x)),this.activation.apply(U));return[q,q,U]})}getConfig(){const e=super.getConfig(),{units:t}=e,s=nO(e,["units"]),r={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},s),r)}inputConv(e,t,s,r){const a=rs(e,t,this.strides,r||"valid",this.dataFormat==="channelsFirst"?"
7455NCHW":"NHWC",this.dilationRate);return s?Fn(a,s,this.dataFormat):a}recurrentConv(e,t){return rs(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}}Rh.className="ConvLSTM2DCell";K(Rh);class em extends u0{constructor(e){const t=new Rh(e);super(Object.assign(Object.assign({},e),{cell:t}))}static fromConfig(e,t){return new e(t)}}em.className="ConvLSTM2D";K(em);/**
7456 * @license
7457 * Copyright 2018 Google LLC
7458 *
7459 * Use of this source code is governed by an MIT-style
7460 * license that can be found in the LICENSE file or at
7461 * https://opensource.org/licenses/MIT.
7462 * =============================================================================
7463 */class Dh extends Ce{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(this.noiseShape==null)return this.noiseShape;const t=e.shape,s=[];for(let r=0;r<this.noiseShape.length;++r)s.push(this.noiseShape[r]==null?t[r]:this.noiseShape[r]);return s}call(e,t){return L(()=>{this.invokeCallHook(e,t);const s=ge(e);if(0<this.rate&&this.rate<1){const r=t.training==null?!1:t.training,a=this.getNoiseShape(s);return ul(()=>vw(s,this.rate,a,this.seed),()=>s,r)}return e})}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}Dh.className="Dropout";K(Dh);class tm extends Dh{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}tm.className="SpatialDropout1D";K(tm);class nm extends Ce{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.batchInputShape==null&&e.inputShape==null&&e.inputDim!=null){let t=null;e.batchSize!=null&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,ht(this.units,"units"),this.activation=Es(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=Ue(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Ue(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=it(e.kernelConstraint),this.biasConstraint=it(e.biasConstraint),this.kernelRegularizer=Ge(e.kernelRegularizer),this.biasRegularizer=Ge(e.biasRegularizer),this.activityRegularizer=Ge(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=Ee(e);const t=e[e.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){e=Ee(e);const t=e.slice();return t[t.length-1]=this.units,t}call(e,t){return L(()=>{this.invokeCallHook(e,t);const s=ge(e),r=fw(this.activation.getClassName());let a;return r!=null?a=Gn(s,this.kernel.read(),r,this.bias?this.bias.read():null):(a=Gn(s,this.kernel.read()),this.bias!=null&&(a=Fn(a,this.bias.read())),this.activation!=null&&(a=this.activation.apply(a))),a})}getConfig(){const e={units:this.units,activation:Ts(this.activation),useBias:this.useBias,kernelInitializer:qe(this.kernelInitializer),biasInitializer:qe(this.biasInitializer),kernelRegularizer:Le(this.kernelRegularizer),biasRegularizer:Le(this.biasRegularizer),activityRegularizer:Le(this.activityRegularizer),kernelConstraint:ot(this.kernelConstraint),biasConstraint:ot(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}nm.className="Dense";K(nm);class sm extends Ce{constructor(e){e=e||{},super(e),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=Ee(e);for(const t of e.slice(1))if(t==null)throw new A(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],vs(e,1)]}call(e,t){return L(()=>{this.invokeCallHook(e,t);let s=ge(e);if(this.dataFormat==="channelsFirst"&&s.rank>1){const r=[0];for(let a=2;a<s.rank;++a)r.push(a);r.push(1),s=Ne(s,r)}return pD(s)})}getConfig(){const e={};this.dataFormat!=null&&(e.dataFormat=this.dataFormat);const t=super.getConfig();return Object.assign(e,t),e}}sm.className="Flatten";K(sm);class rm extends Ce{constructor(e){super(e),this.supportsMasking=!0,this.activation=Es(e.activation)}call(e,t){return L(()=>{this.invokeCallHook(e,t);const s=ge(e);return this.activation.apply(s)})}getConfig(){const e={activation:Ts(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}rm.className="Activation";K(rm);class am extends Ce{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return L(()=>(e=ge(e),hD(e,this.n)))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}am.className="RepeatVector";K(am);class om extends Ce{constructor(e){super(e),this.targetShape=e.targetShape;for(let t=0;t<this.targetShape.length;++t)this.isUnknown(this.targetShape[t])&&(this.targetShape[t]=null)}isUnknown(e){return e<0||e==null}fixUnknownDimension(e,t){const s="Total size of new array must be unchanged.",r=t.slice();let a=1,o=null;for(let l=0;l<r.length;++l){const u=r[l];if(this.isUnknown(u))if(o===null)o=l;else throw new A("Can only specifiy one unknown dimension.");else a*=u}const i=vs(e);if(o!==null){if(a===0||i%a!==0)throw new A(s);r[o]=i/a}else if(i!==a)throw new A(s);return r}computeOutputShape(e){let t=!1;for(let s=0;s<e.length;++s)if(this.isUnknown(e[s])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))}call(e,t){return L(()=>{this.invokeCallHook(e,t);const s=ge(e),r=s.shape,a=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return D(s,a)})}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}om.className="Reshape";K(om);class im extends Ce{constructor(e){if(super(e),e.dims==null)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=Rn(1,e.dims.length+1);if(!ke(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new tt({ndim:this.dims.length+1})]}computeOutputShape(e){e=Ee(e);const t=e.slice();
vendor: 37,964 bytes, lines 7463-7543
7463return this.dims.forEach((s,r)=>{t[r+1]=e[s]}),t}call(e,t){return Ne(ge(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}im.className="Permute";K(im);class lm extends Ce{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const s=ge(e);return vo(sr(s,this.maskValue),-1)}call(e,t){return L(()=>{this.invokeCallHook(e,t);const s=ge(e),o=vo(sr(s,this.maskValue),-1,!0);return O(s,ee(o,s.dtype))})}}lm.className="Masking";K(lm);/**
7464 * @license
7465 * Copyright 2018 Google LLC
7466 *
7467 * Use of this source code is governed by an MIT-style
7468 * license that can be found in the LICENSE file or at
7469 * https://opensource.org/licenses/MIT.
7470 * =============================================================================
7471 */class um extends Ce{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let t=null;e.batchSize!=null&&(t=e.batchSize),e.inputLength==null?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(Ae(e.inputLength))}this.inputDim=e.inputDim,ht(this.inputDim,"inputDim"),this.outputDim=e.outputDim,ht(this.outputDim,"outputDim"),this.embeddingsInitializer=Ue(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Ge(e.embeddingsRegularizer),this.activityRegularizer=Ge(e.activityRegularizer),this.embeddingsConstraint=it(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return L(()=>this.maskZero?(e=ge(e),sr(e,Be(e))):null)}computeOutputShape(e){if(e=Ee(e),this.inputLength==null)return[...e,this.outputDim];const t=Ae(this.inputLength);if(t.length!==e.length-1)throw new A(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let s=0;for(let r=0;r<t.length;++r){const a=t[r],o=e[r+1];if(a!=null&&o!=null&&a!==o)throw new A(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);a==null&&(t[s]=o),s++}}return[e[0],...t,this.outputDim]}call(e,t){return L(()=>{this.invokeCallHook(e,t);let s=ge(e);s.dtype!=="int32"&&(s=Un(s,"int32"));const r=ww(this.embeddings.read(),D(s,[s.size]));return D(r,Ee(this.computeOutputShape(s.shape)))})}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:qe(this.embeddingsInitializer),embeddingsRegularizer:Le(this.embeddingsRegularizer),activityRegularizer:Le(this.activityRegularizer),embeddingsConstraint:ot(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}um.className="Embedding";K(um);/**
7472 * @license
7473 * Copyright 2018 Google LLC
7474 *
7475 * Use of this source code is governed by an MIT-style
7476 * license that can be found in the LICENSE file or at
7477 * https://opensource.org/licenses/MIT.
7478 * =============================================================================
7479 */class wr extends Ce{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new ye}computeElementwiseOpOutputShape(e,t){if(e==null||t==null)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(t.length===0)return e;const s=e.slice(0,e.length-t.length);for(let r=0;r<t.length;++r){const a=e[e.length-t.length+r],o=t[r];if(a==null||o==null||a<0||o<0)s.push(null);else if(a===1)s.push(o);else if(o===1)s.push(a);else{if(a!==o)throw new A("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));s.push(a)}}return s}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[Ee(e)]),e=e,e.length<2)throw new A(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(const a of e)a!=null&&a[0]!==null&&t.push(a[0]);if(t=ws(t),t.length>1)throw new A(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let s=e[0]==null?null:e[0].slice(1);for(let a=1;a<e.length;++a){const o=e[a]==null?null:e[a].slice(1);s=this.computeElementwiseOpOutputShape(s,o)}const r=e.map(a=>a.length);e.indexOf(null)===-1&&ws(r).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return L(()=>{if(e=e,this.reshapeRequired){const s=[],r=e.map(a=>a.rank);if(r.indexOf(null)===-1){const a=ks(r);for(let o of e){const i=o.rank;for(let l=0;l<a-i;++l)o=il(o,1);s.push(o)}return this.mergeFunction(s)}else{let a=!1;for(const l of e){const u=l.rank;if(u==null){const c=l.shape,h=c[0],d=c.slice(1).concat([h]);let p=D(l,[h].concat(vs(c.slice(1))));p=Ne(p,[1,0]),p=D(p,d),s.push(p),a=!0}else if(u>1){const c=Rn(1,u).concat([0]);s.push(Ne(l,c)),a=!0}else s.push(l)}let o=this.mergeFunction(s);const i=o.rank;if(a){if(i==null){const l=o.shape,u=l.length,c=l[u-1],h=[c].concat(l.slice(0,l.length-1));o=D(Ne(D(o,[-1,c]),[1,0]),h)}else if(i>1){const l=[i-1].concat(Rn(0,i-1));o=Ne(o,l)}}return o}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let t;e[0]==null?t=null:t=e[0].slice(1);for(let r=1;r<e.length;++r){const a=e[r]==null?null:e[r].slice(1);t=this.computeElementwiseOpOutputShape(t,a)}let s=[];for(const r of e)r!=null&&r[0]!==null&&s.push(r[0]);return s=ws(s),s.length===1?t=s.concat(t):t=[null].concat(t),t}computeMask(e,t){return L(()=>{if(t==null)return null;if(!Array.isArray(t))throw new A("`mask` should be an Array");if(!Array.isArray(e))throw new A("`inputs` should be an Array");if(t.length!==e.length)throw new A(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(r=>r==null))return null;t=t.map(r=>r==null?r:mt(r,0));let s=t[0];for(let r=1;r<t.length-1;++r)s=wn(s,t[r]);return s})}}class cm extends wr{constructor(e){super(e)}mergeFunction(e){return L(()=>{let t=e[0].clone();for(let s=1;s<e.length;++s)t=te(t,e[s]);return t})}}cm.className="Add";K(cm);class hm extends wr{constructor(e){super(e)}mergeFunction(e){return L(()=>{let t=e[0].clone();for(let s=1;s<e.length;++s)t=O(t,e[s]);return t})}}hm.className="Multiply";K(hm);class dm extends wr{constructor(e){super(e)}mergeFunction(e){return L(()=>{let t=e[0].clone();for(let s=1;s<e.length;++s)t=te(t,e[s]);return O(1/e.length,t)})}}dm.className="Average";K(dm);class pm extends wr{constructor(e){super(e)}mergeFunction(e){return L(()=>{let t=e[0];for(let s=1;s<e.length;++s)t=as(t,e[s]);return t})}}pm.className="Maximum";K(pm);class fm extends wr{constructor(e){super(e)}mergeFunction(e){return L(()=>{let t=e[0];for(let s=1;s<e.length;++s)t=Ss(t,e[s]);return t})}}fm.className="Minimum";K(fm);class mm extends wr{constructor(e){super(e),this.DEFAULT_AXIS=-1,e==null&&(e={}),this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){if(!(Array.isArray(e)&&Array.isArray(e[0]))||e.length===1)throw new A("A `Concatenate` layer should be called on a list of at least 2 inputs");e=e;let t=!0;for(const r of e)if(r!=null){t=!1;break}if(t)return;const s=[];for(let r=0;r<e.length;++r){const a=e[r].slice();a.splice(this.axis,1);let o=!1;for(const i of s)if(ke(i,a)){o=!0;break}o||s.push(a)}if(s.length>1)throw new A("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return L(()=>xf(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new A("A `Concatenate` layer should be called on a list of inputs.");const t=e,s=t[0].slice(),r=this.axis<0?s.length+this.axis:this.axis;for(const a of t.slice(1)){if(s[r]==null||a[r]==null){s[r]=null;break}s[r]+=a[r]}return s}computeMask(e,t){if(t==null)return null;if(!Array.isArray(t))throw new A("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new A("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new A(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return L(()=>{let s=!0;if(t.forEach(o=>{if(o!=null){s=!1;return}}),s)return null;const r=[];for(let o=0;o<e.length;++o)t[o]==null?r.push(ee(Zt(e[o]),"bool")):t[o].rank<e[o].rank?r.push(mt(t[o],-1)):r.push(t[o]);const a=Je(r,this.axis);return Bc(a,-1,!1)})}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}mm.className="Concatenate";K(mm);function ro(n,e){for(;n<0;)n+=e;return n}function sO(n,e,t){if(n.shape.length>3||e.shape.length>3)throw new ye("batchDot is not implemented for tensors of 4D or higher rank yet");if(I(n.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${n.shape.length}`),I(n.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`),typeof t=="number"&&(t=[t,t]),n.dtype==="complex64"||e.dtype==="complex64")throw new ye("batchDot is not implemented for complex64-type Tensors yet.");const s=n.shape.length,r=e.shape.length;t==null&&(t=[s-1,r-2]);const a=t;return L(()=>{let o;if(s>r){o=s-r;const l=[];for(let u=0;u<o;++u)l.push(1);e=D(e,e.shape.concat(l))}else if(r>s){o=r-s;const l=[];for(let u=0;u<o;++u)l.push(1);n=D(n,n.shape.concat(l))}else o=0;let i;if(n.shape.length===2&&e.shape.length===2)a[0]===a[1]?i=oe(O(n,e),a[0]):i=oe(O(Ne(n,[1,0]),e),a[1]);else{const l=a[0]!==n.shape.length-1,u=a[1]===e.shape.length-1;i=ve(n,e,l,u)}if(o>0){let l;s>r?l=s+r-3:l=s-1;const u=[];for(let c=l;c<l+o;++c)u.push(c);i=zs(i,u)}return i.shape.length===1&&(i=mt(i,1)),i})}class gm extends wr{constructor(e){super(e),this.axes=e.axes,this.normalize=e.normalize==null?!1:e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){I(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0],s=e[1];if(t.length>3||s.length>3)throw new ye("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,s);if(t[r[0]]!==s[r[1]])throw new A(`Dimension incompatibility: ${t[r[0]]} !== ${s[r[1]]}`)}mergeFunction(e){if(e.length!==2)throw new A(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t=e[0],s=e[1],r;return Array.isArray(this.axes)?r=this.axes.map((a,o)=>ro(a,e[o].shape.length)):r=[ro(this.axes,t.shape.length),ro(this.axes,s.shape.length)],this.normalize&&(t=nu(t,r[0]),s=nu(s,r[1])),sO(t,s,r)}interpretAxes(e,t){let s;return Array.isArray(this.axes)?s=this.axes:s=[ro(this.axes,e.length),ro(this.axes,t.length)],s}computeOutputShape(e){I(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0].slice(),s=e[1].slice();if(t.length>3||s.length>3)throw new ye("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,s);t.splice(r[0],1),s.splice(r[1],1),s.splice(0,1);const a=t.concat(s);return a.length===1&&a.push(1),a}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}gm.className="Dot";K(gm);/**
7480 * @license
7481 * Copyright 2018 Google LLC
7482 *
7483 * Use of this source code is governed by an MIT-style
7484 * license that can be found in the LICENSE file or at
7485 * https://opensource.org/licenses/MIT.
7486 * =============================================================================
7487 */class ym extends Ce{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return L(()=>{this.invokeCallHook(e,t);const s=ge(e);return ul(()=>te(fh(s.shape,0,this.stddev),s),()=>s,t.training||!1)})}}ym.className="GaussianNoise";K(ym);class xm extends Ce{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return L(()=>{this.invokeCallHook(e,t);const s=ge(e);return this.rate>0&&this.rate<1?ul(()=>{const a=Math.sqrt(this.rate/(1-this.rate));return O(s,fh(s.shape,1,a))},()=>s,t.training||!1):s})}}xm.className="GaussianDropout";K(xm);class bm extends Ce{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||ge(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return L(()=>{if(this.rate<1&&this.rate>0){const s=this._getNoiseShape(e);return ul(()=>{const a=ge(e),i=-1.6732632423543772*1.0507009873554805;let l=os(Ps(s),this.rate);l=Un(l,"float32");const u=((1-this.rate)*(1+this.rate*i**2))**-.5,c=-u*i*this.rate,h=te(O(a,l),O(te(l,-1),i));return te(O(h,u),c)},()=>ge(e),t.training||!1)}return e})}}bm.className="AlphaDropout";K(bm);/**
7488 * @license
7489 * Copyright 2018 Google LLC
7490 *
7491 * Use of this source code is governed by an MIT-style
7492 * license that can be found in the LICENSE file or at
7493 * https://opensource.org/licenses/MIT.
7494 * =============================================================================
7495 */function Io(n,e,t,s,r,a=.001){let o;if(n.rank===2)o=dp(n,e,t,s,r,a);else if(n.rank===3)o=pp(n,e,t,s,r,a);else if(n.rank===4)o=fp(n,e,t,s,r,a);else throw new ye(`batchNormalization is not implemented for array of rank ${n.rank} yet`);return o}function rO(n,e,t,s,r=.001){return L(()=>{const a=Qi(n,s),o=a.mean,i=a.variance;return[Io(n,o,i,t,e,r),o,i]})}function aO(n,e,t,s,r=.001){return L(()=>{const a=Qi(n,s),o=a.mean,i=a.variance,l=[];for(const f of Rn(0,n.rank))s.indexOf(f)!==-1?l.push(1):l.push(n.shape[f]);const u=D(o,l),c=D(i,l),h=e==null?null:D(e,l),d=t==null?null:D(t,l);return[Io(n,u,c,d,h,r),o,i]})}function oO(n,e,t,s,r=.001){return ke(s.slice().sort(),Rn(0,n.rank-1))?rO(n,e,t,s,r):aO(n,e,t,s,r)}class wm extends Ce{constructor(e){e==null&&(e={}),super(e),this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=Ue(e.betaInitializer||"zeros"),this.gammaInitializer=Ue(e.gammaInitializer||"ones"),this.movingMeanInitializer=Ue(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Ue(e.movingVarianceInitializer||"ones"),this.betaConstraint=it(e.betaConstraint),this.gammaConstraint=it(e.gammaConstraint),this.betaRegularizer=Ge(e.betaRegularizer),this.gammaRegularizer=Ge(e.gammaRegularizer)}build(e){e=Ee(e);const t=this.axis>=0?this.axis:this.axis+e.length,s=e[t];if(s==null)throw new A(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new tt({ndim:e.length,axes:{[t]:s}})];const r=[s];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return L(()=>{const s=t.training==null?!1:t.training,r=ge(e),a=r.shape,o=a.length,i=Rn(0,o),l=this.axis>=0?this.axis:this.axis+o;i.splice(l,1);const u=or(1,o);u[l]=a[l];const c=i.slice();c.sort();const h=!ke(c,Rn(0,o).slice(0,o-1)),d=()=>{if(h){const x=D(this.movingMean.read(),u),v=D(this.movingVariance.read(),u),b=this.center?D(this.beta.read(),u):null,C=this.scale?D(this.gamma.read(),u):null;return Io(r,x,v,b,C,this.epsilon)}else return Io(r,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!s)return d();const[p,f,g]=oO(r,this.gamma.read(),this.beta.read(),i,this.epsilon),m=(x,v,b)=>{L(()=>{const C=1-b,$=x.read(),S=O(ie($,v),C);x.write(ie($,S))})};return(()=>{m(this.movingMean,f,this.momentum),m(this.movingVariance,g,this.momentum)})(),p})}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:qe(this.betaInitializer),gammaInitializer:qe(this.gammaInitializer),movingMeanInitializer:qe(this.movingMeanInitializer),movingVarianceInitializer:qe(this.movingVarianceInitializer),betaRegularizer:Le(this.betaRegularizer),gammaRegularizer:Le(this.gammaRegularizer),betaConstraint:ot(this.betaConstraint),gammaConstraint:ot(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}wm.className="BatchNormalization";K(wm);class vm extends Ce{constructor(e){if(e==null&&(e={}),super(e),this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(const t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=Ue(e.betaInitializer||"zeros"),this.gammaInitializer=Ue(e.gammaInitializer||"ones"),this.betaRegularizer=Ge(e.betaRegularizer),this.gammaRegularizer=Ge(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=Ee(e);const t=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let a=0;a<this.axis.length;++a)this.axis[a]<0&&(this.axis[a]+=t);for(const a of this.axis)if(a<0||a>=t)throw new Error(`Invalid axis: ${a}`);if(this.axis.length!==ws(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const s=this.axis.map(a=>e[a]),r=!0;this.scale?this.gamma=this.addWeight("gamma",s,"float32",this.gammaInitializer,this.gammaRegularizer,r):this.gamma=null,this.center?this.beta=this.addWeight("beta",s,"float32",this.betaInitializer,this.betaRegularizer,r):this.beta=null,this.built=!0}call(e,t){const s=ge(e),r=s.shape,a=r.length;return L(()=>{let{mean:i,variance:l}=Qi(s,this.axis,!0);const u=or(1,a);for(const g of this.axis)u[g]=r[g];const c=g=>g!=null&&g.shape.length!==a?D(g,u):g;let h=this.scale?c(this.gamma.read()):null,d=this.center?c(this.beta.read()):null;const p=[],f=[];for(let g=0;g<a;++g)this.axis.indexOf(g)!==-1?(p.push(r[g]),f.push(1)):(p.push(1),f.push(r[g]));return i=sn(i,p),l=sn(l,p),h!=null&&(h=sn(h,f)),d!=null&&(d=sn(d,f)),Io(s,i,l,d,h,this.epsilon)})}getConfig(){const e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:qe(this.betaInitializer),gammaInitializer:qe(this.gammaInitializer),betaRegularizer:Le(this.betaRegularizer),gammaRegularizer:Le(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}}vm.className="LayerNormalization";K(vm);/**
7496 * @license
7497 * Copyright 2018 Google LLC
7498 *
7499 * Use of this source code is governed by an MIT-style
7500 * license that can be found in the LICENSE file or at
7501 * https://opensource.org/licenses/MIT.
7502 * =============================================================================
7503 */function iO(n,e,t){return L(()=>{if(n.rank!==4)throw new A(`temporalPadding expects input tensor to be 4-D, but received a ${n.rank}-D tensor.`);if(e==null&&(e=[[1,1],[1,1]]),e.length!==2||e[0].length!==2||e[1].length!==2)throw new A("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(t==null&&(t=Dn()),t!=="channelsLast"&&t!=="channelsFirst")throw new A(`Unknown data format: ${t}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let s;return t==="channelsFirst"?s=[[0,0],[0,0],e[0],e[1]]:s=[[0,0],e[0],e[1],[0,0]],is(n,s)})}class Cm extends Ce{constructor(e){if(e==null&&(e={}),super(e),this.dataFormat=e.dataFormat==null?Dn():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new A(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let t,s;if(typeof e.padding[0]=="number")t=[e.padding[0],e.padding[0]],s=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,e.padding[0].length!==2)throw new A(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],e.padding[1].length!==2)throw new A(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);s=e.padding[1]}this.padding=[t,s]}this.inputSpec=[new tt({ndim:4})]}computeOutputShape(e){e=Ee(e);let t,s;return this.dataFormat==="channelsFirst"?(e[2]!=null&&e[2]>=0?t=e[2]+this.padding[0][0]+this.padding[0][1]:t=null,e[3]!=null&&e[3]>=0?s=e[3]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],e[1],t,s]):(e[1]!=null&&e[1]>=0?t=e[1]+this.padding[0][0]+this.padding[0][1]:t=null,e[2]!=null&&e[2]>=0?s=e[2]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],t,s,e[3]])}call(e,t){return L(()=>iO(ge(e),this.padding,this.dataFormat))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}Cm.className="ZeroPadding2D";K(Cm);/**
7504 * @license
7505 * Copyright 2018 Google LLC
7506 *
7507 * Use of this source code is governed by an MIT-style
7508 * license that can be found in the LICENSE file or at
7509 * https://opensource.org/licenses/MIT.
7510 * =============================================================================
7511 */function Ah(n,e,t,s,r,a){return L(()=>{Ze(r),gw(a),pn(s),t==null&&(t=[1,1]),s==null&&(s="valid"),r==null&&(r=Dn()),a==null&&(a="max"),n=Gf(n,r);let o;const i=s==="same"?"same":"valid";return a==="max"?o=Zi(n,e,t,i):o=Hi(n,e,t,i),r==="channelsFirst"&&(o=Ne(o,[0,3,1,2])),o})}function c0(n,e,t,s,r,a){return L(()=>{Ze(r),gw(a),pn(s),t==null&&(t=[1,1,1]),s==null&&(s="valid"),r==null&&(r=Dn()),a==null&&(a="max"),n=a0(n,r);let o;const i=s==="same"?"same":"valid";return a==="max"?o=Lp(n,e,t,i):o=hp(n,e,t,i),r==="channelsFirst"&&(o=Ne(o,[0,4,1,2,3])),o})}class h0 extends Ce{constructor(e){if(e.poolSize==null&&(e.poolSize=2),super(e),typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new A(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(ht(this.poolSize,"poolSize"),e.strides==null)this.strides=this.poolSize;else if(typeof e.strides=="number")this.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")this.strides=e.strides;else throw new A(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);ht(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,pn(this.padding),this.inputSpec=[new tt({ndim:3})]}computeOutputShape(e){e=Ee(e);const t=Tn(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return L(()=>{this.invokeCallHook(e,t),e=il(ge(e),2);const s=this.poolingFunction(ge(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return zs(s,[2])})}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class $m extends h0{constructor(e){super(e)}poolingFunction(e,t,s,r,a){return Ze(a),pn(r),Ah(e,t,s,r,a,"max")}}$m.className="MaxPooling1D";K($m);class Nm extends h0{constructor(e){super(e)}poolingFunction(e,t,s,r,a){return Ze(a),pn(r),Ah(e,t,s,r,a,"avg")}}Nm.className="AveragePooling1D";K(Nm);class d0 extends Ce{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new A(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];ht(this.poolSize,"poolSize"),ht(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Ze(this.dataFormat),pn(this.padding),this.inputSpec=[new tt({ndim:4})]}computeOutputShape(e){e=Ee(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=Tn(t,this.poolSize[0],this.padding,this.strides[0]),s=Tn(s,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,s]:[e[0],t,s,e[3]]}call(e,t){return L(()=>(this.invokeCallHook(e,t),this.poolingFunction(ge(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class Im extends d0{constructor(e){super(e)}poolingFunction(e,t,s,r,a){return Ze(a),pn(r),Ah(e,t,s,r,a,"max")}}Im.className="MaxPooling2D";K(Im);class Sm extends d0{constructor(e){super(e)}poolingFunction(e,t,s,r,a){return Ze(a),pn(r),Ah(e,t,s,r,a,"avg")}}Sm.className="AveragePooling2D";K(Sm);class p0 extends Ce{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new A(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];ht(this.poolSize,"poolSize"),ht(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Ze(this.dataFormat),pn(this.padding),this.inputSpec=[new tt({ndim:5})]}computeOutputShape(e){e=Ee(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[4]:e[3];return t=Tn(t,this.poolSize[0],this.padding,this.strides[0]),s=Tn(s,this.poolSize[1],this.padding,this.strides[1]),r=Tn(r,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,s,r]:[e[0],t,s,r,e[4]]}call(e,t){return L(()=>(this.invokeCallHook(e,t),this.poolingFunction(ge(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class km extends p0{constructor(e){super(e)}poolingFunction(e,t,s,r,a){return Ze(a),pn(r),c0(e,t,s,r,a,"max")}}km.className="MaxPooling3D";K(km);class Tm extends p0{constructor(e){super(e)}poolingFunction(e,t,s,r,a){return Ze(a),pn(r),c0(e,t,s,r,a,"avg")}}Tm.className="AveragePooling3D";K(Tm);class f0 extends Ce{constructor(e){super(e),this.inputSpec=[new tt({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new ye}}class Em extends f0{constructor(e){super(e||{})}call(e,t){return L(()=>{const s=ge(e);return je(s,1)})}}Em.className="GlobalAveragePooling1D";K(Em);class Rm extends f0{constructor(e){super(e||{})}call(e,t){return L(()=>{const s=ge(e);return on(s,1)})}}Rm.className="GlobalMaxPooling1D";K(Rm);class m0 extends Ce{constructor(e){super(e),this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Ze(this.dataFormat),this.inputSpec=[new tt({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new ye}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class Dm extends m0{call(e,t){return L(()=>{const s=ge(e);return this.dataFormat==="channelsLast"?je(s,[1,2]):je(s,[2,3])})}}Dm.className="GlobalAveragePooling2D";K(Dm);class Am extends m0{call(e,t){return L(()=>{const s=ge(e);return this.dataFormat==="channelsLast"?on(s,[1,2]):on(s,[2,3])})}}Am.className="GlobalMaxPooling2D";K(Am);/**
7512 * @license
7513 * Copyright 2018 Google LLC
7514 *
7515 * Use of this source code is governed by an MIT-style
7516 * license that can be found in the LICENSE file or at
7517 * https://opensource.org/licenses/MIT.
7518 * =============================================================================
7519 */class g0 extends Ce{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return this.layer!=null?this.layer.trainable:!1}set trainable(e){this.layer!=null&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){const e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=super.getConfig();return Object.assign(e,t),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,s={}){const r=t.layer,a=kn(r,s);delete t.layer;const o={layer:a};return Object.assign(o,t),new e(o)}}class Om extends g0{constructor(e){super(e),this.supportsMasking=!0}build(e){if(e=Ee(e),e.length<3)throw new A(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){e=Ee(e);const t=[e[0]].concat(e.slice(2)),s=this.layer.computeOutputShape(t),r=e[1];return[s[0],r].concat(s.slice(1))}call(e,t){return L(()=>(e=ge(e),l0((o,i)=>[ge(this.layer.call(o,t)),[]],e,[],!1,null,null,!1,!0)[1]))}}Om.className="TimeDistributed";K(Om);function lO(n){xr(oD,"BidirectionalMergeMode",n)}const uO="concat";class _m extends g0{constructor(e){super(e);const t=e.layer.getConfig(),s={};s.className=e.layer.getClassName(),s.config=t,this.forwardLayer=kn(s),t.goBackwards=t.goBackwards!==!0;const r={};if(r.className=e.layer.getClassName(),r.config=t,this.backwardLayer=kn(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?uO:e.mergeMode,lO(this.mergeMode),e.weights)throw new ye("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,s=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,s)),this.backwardLayer.setWeights(e.slice(s))}computeOutputShape(e){let t=this.forwardLayer.computeOutputShape(e);Array.isArray(t)&&Array.isArray(t[0])||(t=[t]),t=t;let s,r,a;return this.returnState&&(a=t.slice(1)),s=t[0],s=s,this.mergeMode==="concat"?(s[s.length-1]*=2,r=[s]):this.mergeMode==null?r=[s,s.slice()]:r=[s],this.returnState?this.mergeMode==null?r.concat(a).concat(a.slice()):[s].concat(a).concat(a.slice()):zt(r)}apply(e,t){let s=t==null?null:t.initialState,r=t==null?null:t.constants;t==null&&(t={});const a=i0(e,s,r,this.numConstants);if(e=a.inputs,s=a.initialState,r=a.constants,Array.isArray(e)&&(s=e.slice(1),e=e[0]),(s==null||s.length===0)&&r==null)return super.apply(e,t);const o=[],i=[];if(s!=null){const u=s.length;if(u%2>0)throw new A("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=s,o.push(...s);const c=s.map(h=>new tt({shape:h.shape}));this.forwardLayer.stateSpec=c.slice(0,u/2),this.backwardLayer.stateSpec=c.slice(u/2),i.push(...c)}if(r!=null)throw new ye("Support for constants in Bidirectional layers is not implemented yet.");const l=o[0]instanceof An;for(const u of o)if(u instanceof An!==l)throw new A("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(l){const u=[e].concat(o),c=this.inputSpec.concat(i),h=this.inputSpec;this.inputSpec=c;const d=super.apply(u,t);return this.inputSpec=h,d}else return super.apply(e,t)}call(e,t){return L(()=>{const s=t.initialState;let r,a;if(s==null)r=this.forwardLayer.call(e,t),a=this.backwardLayer.call(e,t);else{const l=s.slice(0,s.length/2),u=s.slice(s.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:l})),a=this.backwardLayer.call(e,Object.assign(t,{initialState:u}))}let o;this.returnState&&(Array.isArray(r)&&(o=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),this.returnSequences&&(a=un(a,1));let i;return this.mergeMode==="concat"?i=xf([r,a]):this.mergeMode==="sum"?i=te(r,a):this.mergeMode==="ave"?i=O(.5,te(r,a)):this.mergeMode==="mul"?i=O(r,a):this.mergeMode==null&&(i=[r,a]),this.returnState?this.mergeMode==null?i.concat(o):[i].concat(o):i})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){er(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),er(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,t){Array.isArray(t)&&(t=t[0]);let s;if(this.returnSequences?this.mergeMode==null?s=[t,t]:s=t:this.mergeMode==null?s=[null,null]:s=null,this.returnState){const a=this.forwardLayer.states.map(o=>null);return Array.isArray(s)?s.concat(a).concat(a):[s].concat(a).concat(a)}else return s}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(e),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const s=kn(t.layer);if(delete t.layer,t.numConstants!=null)throw new ye("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=t;return r.layer=s,new e(r)}}_m.className="Bidirectional";K(_m);/**
7520 * @license
7521 * Copyright 2022 CodeSmith LLC
7522 *
7523 * Use of this source code is governed by an MIT-style
7524 * license that can be found in the LICENSE file or at
7525 * https://opensource.org/licenses/MIT.
7526 * =============================================================================
7527 */class Fm extends Ce{constructor(e){super(e),this.scale=e.scale,e.offset?this.offset=e.offset:this.offset=0}getConfig(){const e={scale:this.scale,offset:this.offset},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return L(()=>(e=ge(e),e.dtype!=="float32"&&(e=Un(e,"float32")),te(O(e,this.scale),this.offset)))}}Fm.className="Rescaling";K(Fm);/**
7528 * @license
7529 * Copyright 2022 CodeSmith LLC
7530 *
7531 * Use of this source code is governed by an MIT-style
7532 * license that can be found in the LICENSE file or at
7533 * https://opensource.org/licenses/MIT.
7534 * =============================================================================
7535 */const{resizeBilinear:cO,cropAndResize:hO}=yn;class Lm extends Ce{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,t,s,r,a,o,i,l){return L(()=>{let u,c=!1;const h=t/o,d=s/i,p=(r+t)/o,f=(a+s)/i,g=[h,d,p,f],m=[];e.rank===3?(c=!0,u=Ot([e])):u=e;for(let C=0;C<u.shape[0];C++)m.push(g);const y=En(m,[m.length,4]),x=rr(0,m.length,1,"int32"),b=hO(u,y,x,[r,a],"nearest");return Un(c?ge(cn(b)):b,l)})}upsize(e,t,s,r){return L(()=>{const a=cO(e,[t,s]);return Un(a,r)})}call(e,t){return L(()=>{const s=ge(e),r=s.dtype,a=s.shape,o=a[a.length-3],i=a[a.length-2];let l=0;o!==this.height&&(l=Math.floor((o-this.height)/2));let u=0;return i!==this.width&&(u=Math.floor((i-this.width)/2),u===0&&(u=1)),l>=0&&u>=0?this.centerCrop(s,l,u,this.height,this.width,o,i,r):this.upsize(e,this.height,this.width,r)})}getConfig(){const e={height:this.height,width:this.width},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){e=Ee(e);const t=e.length-3,s=e.length-2;return e[t]=this.height,e[s]=this.width,e}}Lm.className="CenterCrop";K(Lm);/**
7536 * @license
7537 * Copyright 2022 CodeSmith LLC
7538 *
7539 * Use of this source code is governed by an MIT-style
7540 * license that can be found in the LICENSE file or at
7541 * https://opensource.org/licenses/MIT.
7542 * =============================================================================
7543 */function dO(n,e,t,s){let r=ge(n);if(r.dtype!=="int32"&&(r=Un(r,"int32")),e==="int")return r;const a=r.shape;if(r.rank===0&&(r=mt(r,-1)),e==="oneHot"&&r.shape[r.shape.length-1]!==1&&(r=mt(r,-1)),r.rank>2)throw new A(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${a}
7543 which would result in output rank ${r.rank}.`);const o=["multiHot","oneHot"].includes(e),i=r;let l;if(typeof s<"u"&&e==="count"?l=Yl(i,s,t,o):l=Yl(i,[],t,o),e!=="tfIdf")return l;if(s)return O(l,s);throw new A("When outputMode is 'tfIdf', weights must be provided.")}/**
7544 * @license
7545 * Copyright 2022 CodeSmith LLC
7546 *
7547 * Use of this source code is governed by an MIT-style
7548 * license that can be found in the LICENSE file or at
7549 * https://opensource.org/licenses/MIT.
7550 * =============================================================================
7551 */class Pm extends Ce{constructor(e){super(e),this.numTokens=e.numTokens,e.outputMode?this.outputMode=e.outputMode:this.outputMode="multiHot"}getConfig(){const e={numTokens:this.numTokens,outputMode:this.outputMode},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){return e=Ee(e),e==null?[this.numTokens]:this.outputMode==="oneHot"&&e[e.length-1]!==1?(e.push(this.numTokens),e):(e[e.length-1]=this.numTokens,e)}call(e,t){return L(()=>{e=ge(e),e.dtype!=="int32"&&(e=Un(e,"int32"));let s;if(typeof t.countWeights<"u"){if(this.outputMode!=="count")throw new A(`countWeights is not used when outputMode !== count.
7552              Received countWeights=${t.countWeights}`);s=ge(t.countWeights)}const r=on(e),a=Or(e),o=Lt(this.numTokens,r).bufferSync().get(0),i=os(a,0).bufferSync().get(0);if(!(o&&i))throw new A(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return dO(e,this.outputMode,this.numTokens,s)})}}Pm.className="CategoryEncoding";K(Pm);/**
7553 * @license
7554 * Copyright 2022 CodeSmith LLC
7555 *
7556 * Use of this source code is governed by an MIT-style
7557 * license that can be found in the LICENSE file or at
7558 * https://opensource.org/licenses/MIT.
7559 * =============================================================================
7560 */const pO=["bilinear","nearest"],ny=new Set(pO);class zm extends Ce{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(ny.has(e.interpolation))this.interpolation=e.interpolation;else throw new A(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){e=Ee(e);const t=e[2];return[this.height,this.width,t]}getConfig(){const e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return L(()=>{const s=[this.height,this.width];if(this.interpolation==="bilinear")return yn.resizeBilinear(e,s,!this.cropToAspectRatio);if(this.interpolation==="nearest")return yn.resizeNearestNeighbor(e,s,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...ny]} are supported`)})}}zm.className="Resizing";K(zm);/**
7561 * @license
7562 * Copyright 2023 CodeSmith LLC
7563 *
7564 * Use of this source code is governed by an MIT-style
7565 * license that can be found in the LICENSE file or at
7566 * https://opensource.org/licenses/MIT.
7567 * =============================================================================
7568 */class y0{constructor(e){this.seed=e}next(){if(this.seed!==void 0)return this.seed++}}y0.className="RandomSeed";/**
7569 * @license
7570 * Copyright 2023 CodeSmith LLC
7571 *
7572 * Use of this source code is governed by an MIT-style
7573 * license that can be found in the LICENSE file or at
7574 * https://opensource.org/licenses/MIT.
7575 * =============================================================================
7576 */class x0 extends Ce{constructor(e){super(e),this.randomGenerator=new y0(e.seed)}getConfig(){const e={seed:this.randomGenerator.seed},t=super.getConfig();return Object.assign(e,t),e}}x0.className="BaseRandomLayer";/**
7577 * @license
7578 * Copyright 2023 CodeSmith LLC
7579 *
7580 * Use of this source code is governed by an MIT-style
7581 * license that can be found in the LICENSE file or at
7582 * https://opensource.org/licenses/MIT.
7583 * =============================================================================
7584 */const fO=["bilinear","nearest"],sy=new Set(fO);class Vm extends x0{constructor(e){super(e);const{factor:t,interpolation:s="bilinear"}=e;if(this.factor=t,Array.isArray(this.factor)&&this.factor.length===2)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else if(!Array.isArray(this.factor)&&this.factor>0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new A(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new A(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper<this.widthLower)throw new A(`factor cannot have upper bound less than lower bound.
7585        Got upper bound: ${this.widthUpper}.
7586        Got lower bound: ${this.widthLower}
7587      `);if(s)if(sy.has(s))this.interpolation=s;else throw new A(`Invalid interpolation parameter: ${s} is not implemented`)}getConfig(){const e={factor:this.factor,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){e=Ee(e);const t=e[2];return[this.imgHeight,-1,t]}call(e,t){return L(()=>{const s=ge(e);this.imgHeight=s.shape[s.shape.length-3];const r=s.shape[s.shape.length-2];this.widthFactor=Ps([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let a=this.widthFactor.dataSync()[0]*r;a=Math.round(a);const o=[this.imgHeight,a];switch(this.interpolation){case"bilinear":return yn.resizeBilinear(e,o);case"nearest":return yn.resizeNearestNeighbor(e,o);default:throw new Error(`Interpolation is ${this.interpolation}
7588          but only ${[...sy]} are supported`)}})}}
7588Vm.className="RandomWidth";K(Vm);/**
7589 * @license
7590 * Copyright 2018 Google LLC
7591 *
7592 * Use of this source code is governed by an MIT-style
7593 * license that can be found in the LICENSE file or at
7594 * https://opensource.org/licenses/MIT.
7595 * =============================================================================
7596 */function mO(n){return new Ba(n)}function gO(n){return new Mf(n)}function yO(n){return new zf(n)}function xO(n){return new Vf(n)}function bO(n){return new Bf(n)}function wO(n){return new Uf(n)}function vO(n){return new Wf(n)}function CO(n){return new dl(n)}function $O(n){return new Ua(n)}function NO(n){return new Hf(n)}function IO(n){return new Ga(n)}function SO(n){return new jf(n)}function kO(n){return new qf(n)}function TO(n){return new Kf(n)}function EO(n){return new Xf(n)}function RO(n){return new Yf(n)}function DO(n){return new rm(n)}function AO(n){return new nm(n)}function OO(n){return new Dh(n)}function _O(n){return new tm(n)}function FO(n){return new sm(n)}function LO(n){return new am(n)}function PO(n){return new om(n)}function zO(n){return new im(n)}function VO(n){return new um(n)}function BO(n){return new cm(n)}function MO(n){return new dm(n)}function WO(n){return new mm(n)}function UO(n){return new pm(n)}function GO(n){return new fm(n)}function HO(n){return new hm(n)}function jO(n){return new gm(n)}function qO(n){return new wm(n)}function KO(n){return new vm(n)}function XO(n){return new Cm(n)}function Bm(n){return new Nm(n)}function YO(n){return Bm(n)}function JO(n){return Bm(n)}function Mm(n){return new Sm(n)}function ZO(n){return Mm(n)}function QO(n){return Mm(n)}function Wm(n){return new Tm(n)}function e_(n){return Wm(n)}function t_(n){return Wm(n)}function n_(n){return new Em(n)}function s_(n){return new Dm(n)}function b0(n){return new Rm(n)}function w0(n){return new Am(n)}function v0(n){return new $m(n)}function C0(n){return new Im(n)}function r_(n){return new km(n)}function a_(n){return new Zf(n)}function o_(n){return new Th(n)}function i_(n){return new Qf(n)}function l_(n){return new fl(n)}function u_(n){return new Jf(n)}function c_(n){return new kh(n)}function h_(n){return new em(n)}function d_(n){return new Rh(n)}function p_(n){return new Ln(n)}function f_(n){return new Eh(n)}function m_(n){return new _m(n)}function g_(n){return new Om(n)}const y_=b0,x_=w0,b_=v0,w_=C0;function v_(n){return new ym(n)}function C_(n){return new xm(n)}function $_(n){return new bm(n)}function N_(n){return new lm(n)}function I_(n){return new Fm(n)}function S_(n){return new Lm(n)}function k_(n){return new zm(n)}function T_(n){return new Pm(n)}function E_(n){return new Vm(n)}const R_=Object.freeze(Object.defineProperty({__proto__:null,Layer:Ce,RNN:Ln,RNNCell:pl,activation:DO,add:BO,alphaDropout:$_,average:MO,averagePooling1d:Bm,averagePooling2d:Mm,averagePooling3d:Wm,avgPool1d:YO,avgPool2d:ZO,avgPool3d:e_,avgPooling1d:JO,avgPooling2d:QO,avgPooling3d:t_,batchNormalization:qO,bidirectional:m_,categoryEncoding:T_,centerCrop:S_,concatenate:WO,conv1d:CO,conv2d:$O,conv2dTranspose:NO,conv3d:IO,conv3dTranspose:SO,convLstm2d:h_,convLstm2dCell:d_,cropping2D:TO,dense:AO,depthwiseConv2d:RO,dot:jO,dropout:OO,elu:gO,embedding:VO,flatten:FO,gaussianDropout:C_,gaussianNoise:v_,globalAveragePooling1d:n_,globalAveragePooling2d:s_,globalMaxPool1d:y_,globalMaxPool2d:x_,globalMaxPooling1d:b0,globalMaxPooling2d:w0,gru:a_,gruCell:o_,input:Ww,inputLayer:mO,layerNormalization:KO,leakyReLU:xO,lstm:i_,lstmCell:l_,masking:N_,maxPool1d:b_,maxPool2d:w_,maxPooling1d:v0,maxPooling2d:C0,maxPooling3d:r_,maximum:UO,minimum:GO,multiply:HO,permute:zO,prelu:bO,randomWidth:E_,reLU:yO,repeatVector:LO,rescaling:I_,reshape:PO,resizing:k_,rnn:p_,separableConv2d:kO,simpleRNN:u_,simpleRNNCell:c_,softmax:wO,spatialDropout1d:_O,stackedRNNCells:f_,thresholdedReLU:vO,timeDistributed:g_,upSampling2d:EO,zeroPadding2d:XO},Symbol.toStringTag,{value:"Module"}));function D_(n,e){return Of(n,e)}function A_(n,e){return Ow(n,e)}function O_(n,e){return _w(n,e)}function __(n,e){return _f(n,e)}function F_(n,e){return Ff(n,e)}function L_(n,e){return Aw(n,e)}function P_(n,e){return fA(n,e)}function z_(n,e){return Af(n,e)}function V_(n,e){return $h(n,e)}function B_(n,e){return Ma(n,e)}function M_(n,e){return Ma(n,e)}function W_(n,e){return Ma(n,e)}function U_(n,e){return br(n,e)}function G_(n,e){return br(n,e)}function H_(n,e){return br(n,e)}function j_(n,e){return mA(n,e)}const q_=Object.freeze(Object.defineProperty({__proto__:null,MAPE:M_,MSE:G_,binaryAccuracy:D_,binaryCrossentropy:A_,categoricalAccuracy:__,categoricalCrossentropy:F_,cosineProximity:z_,mape:W_,meanAbsoluteError:V_,meanAbsolutePercentageError:B_,meanSquaredError:U_,mse:H_,precision:L_,r2Score:j_,recall:P_,
7596sparseCategoricalAccuracy:O_},Symbol.toStringTag,{value:"Module"}));/**
7597 * @license
7598 * Copyright 2018 Google LLC
7599 *
7600 * Use of this source code is governed by an MIT-style
7601 * license that can be found in the LICENSE file or at
7602 * https://opensource.org/licenses/MIT.
7603 * =============================================================================
7604 */const K_=Object.freeze(Object.defineProperty({__proto__:null,modelFromJSON:GA},Symbol.toStringTag,{value:"Module"}));/**
7605 * @license
7606 * Copyright 2018 Google LLC
7607 *
7608 * Use of this source code is governed by an MIT-style
7609 * license that can be found in the LICENSE file or at
7610 * https://opensource.org/licenses/MIT.
7611 * =============================================================================
7612 */function X_(n){return new hl(n)}function Y_(n){return JA(n)}function J_(n){return ZA(n)}const Z_=Object.freeze(Object.defineProperty({__proto__:null,l1:Y_,l1l2:X_,l2:J_},Symbol.toStringTag,{value:"Module"}));/**
7613 * @license
7614 * Copyright 2018 Google LLC
7615 *
7616 * Use of this source code is governed by an MIT-style
7617 * license that can be found in the LICENSE file or at
7618 * https://opensource.org/licenses/MIT.
7619 * =============================================================================
7620 */class $0 extends Br{constructor(){super(...arguments),this.model=null}setModel(e){if(!(e instanceof ss))throw new Error("model must be a LayersModel, not some other Container");this.model=e}}function Tl(n,e){return n<e}function ry(n,e){return n>e}class N0 extends $0{constructor(e){if(super(),e==null&&(e={}),e.restoreBestWeights)throw new ye("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=e.monitor||"val_loss",this.minDelta=Math.abs(e.minDelta||0),this.patience=e.patience||0,this.verbose=e.verbose||0,this.mode=e.mode||"auto",this.baseline=e.baseline,["auto","min","max"].indexOf(this.mode)===-1&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),this.mode==="min"?this.monitorFunc=Tl:this.mode==="max"?this.monitorFunc=ry:this.monitor.indexOf("acc")!==-1?this.monitorFunc=ry:this.monitorFunc=Tl,this.monitorFunc===Tl&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===Tl?1/0:-1/0}async onEpochEnd(e,t){await fs(t);const s=this.getMonitorValue(t);s!=null&&(this.monitorFunc(s-this.minDelta,this.best)?(this.best=s,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)))}async onTrainEnd(e){this.stoppedEpoch>0&&this.verbose&&`${this.stoppedEpoch}`}getMonitorValue(e){e==null&&(e={});const t=e[this.monitor];return t==null&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}}function Q_(n){return new N0(n)}const eF={earlyStopping:Q_};/**
7621 * @license
7622 * Copyright 2021 Google LLC. All Rights Reserved.
7623 * Licensed under the Apache License, Version 2.0 (the "License");
7624 * you may not use this file except in compliance with the License.
7625 * You may obtain a copy of the License at
7626 *
7627 * http://www.apache.org/licenses/LICENSE-2.0
7628 *
7629 * Unless required by applicable law or agreed to in writing, software
7630 * distributed under the License is distributed on an "AS IS" BASIS,
7631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7632 * See the License for the specific language governing permissions and
7633 * limitations under the License.
7634 * =============================================================================
7635 */const tF=W();tF.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.")});/**
7636 * @license
7637 * Copyright 2019 Google LLC. All Rights Reserved.
7638 * Licensed under the Apache License, Version 2.0 (the "License");
7639 * you may not use this file except in compliance with the License.
7640 * You may obtain a copy of the License at
7641 *
7642 * http://www.apache.org/licenses/LICENSE-2.0
7643 *
7644 * Unless required by applicable law or agreed to in writing, softw
7644are
7645 * distributed under the License is distributed on an "AS IS" BASIS,
7646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7647 * See the License for the specific language governing permissions and
7648 * limitations under the License.
7649 *
7650 * =============================================================================
7651 */var jt;(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"})(jt||(jt={}));var ay;(function(n){(function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"})(n.CheckpointFormatVersion||(n.CheckpointFormatVersion={}))})(ay||(ay={}));/**
7652 * @license
7653 * Copyright 2019 Google LLC. All Rights Reserved.
7654 * Licensed under the Apache License, Version 2.0 (the "License");
7655 * you may not use this file except in compliance with the License.
7656 * You may obtain a copy of the License at
7657 *
7658 * http://www.apache.org/licenses/LICENSE-2.0
7659 *
7660 * Unless required by applicable law or agreed to in writing, software
7661 * distributed under the License is distributed on an "AS IS" BASIS,
7662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7663 * See the License for the specific language governing permissions and
7664 * limitations under the License.
7665 * =============================================================================
7666 */const Um={};function nF(n,e){const t={tfOpName:n,category:"custom",inputs:[],attrs:[],customExecutor:e};Um[n]=t}function I0(n){return Um[n]}function sF(n){delete Um[n]}/**
7667 * @license
7668 * Copyright 2018 Google LLC. All Rights Reserved.
7669 * Licensed under the Apache License, Version 2.0 (the "License");
7670 * you may not use this file except in compliance with the License.
7671 * You may obtain a copy of the License at
7672 *
7673 * http://www.apache.org/licenses/LICENSE-2.0
7674 *
7675 * Unless required by applicable law or agreed to in writing, software
7676 * distributed under the License is distributed on an "AS IS" BASIS,
7677 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7678 * See the License for the specific language governing permissions and
7679 * limitations under the License.
7680 * =============================================================================
7681 */function w(n,e,t,s,r){const a=e.inputParams[n];if(a&&a.inputIndexStart!==void 0){const i=a.inputIndexStart,l=a.inputIndexEnd===0?void 0:a.inputIndexEnd===void 0?i+1:a.inputIndexEnd,u=i<0?e.inputNames.length+i:i;if(a.type==="tensor")return gt(e.inputNames[u],t,s,r);if(a.type==="tensors"){const d=e.inputs.slice(i,l);return e.inputNames.slice(i,l).filter((f,g)=>{var m;return((m=d[g])===null||m===void 0?void 0:m.op)!=="NoOp"}).map(f=>gt(f,t,s,r))}const c=gt(e.inputNames[u],t,s,r),h=c.dataSync();return a.type==="number"?h[0]:Zs(c.shape,h)}const o=e.attrParams[n];return o&&o.value}function gt(n,e,t,s){const[r,a]=Kt(n,t);if(s!=null){const i=s.getHashTableHandleByName(r);if(i!=null)return i}const o=t.currentContextIds.find(i=>!!e[iu(r,i)]);return o!==void 0?e[iu(r,o)][a]:void 0}function oy(n,e,t){return e[iu(n,t.currentContextId)]}function Qn(n,e){const[t,s,r]=Kt(n,e);return[iu(t,e&&e.currentContextId),s,r]}function iu(n,e){return e?`${n}-${e}
7681`:n}function Kt(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 s=n.split(":");let r;if(s.length===1)r=[n,0,void 0];else{const a=s[0],o=s.length===3?s[1]:void 0,i=Number(s[s.length-1]);r=[a,i,o]}return t&&e.parseNodeNameCache.set(n,r),r}function Pl(n,e,t){let s=w("pad",n,e,t);if(s==="explicit"){s=w("explicitPaddings",n,e,t);const r=[[0,0],[0,0],[0,0],[0,0]];for(let a=0;a<4;a++)r[a][0]=s[a*2],r[a][1]=s[a*2+1];return r}return s}function es(n){return n.kept?n:ts(n)}/**
7682 * @license
7683 * Copyright 2023 Google LLC. All Rights Reserved.
7684 * Licensed under the Apache License, Version 2.0 (the "License");
7685 * you may not use this file except in compliance with the License.
7686 * You may obtain a copy of the License at
7687 *
7688 * http://www.apache.org/licenses/LICENSE-2.0
7689 *
7690 * Unless required by applicable law or agreed to in writing, software
7691 * distributed under the License is distributed on an "AS IS" BASIS,
7692 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7693 * See the License for the specific language governing permissions and
7694 * limitations under the License.
7695 * =============================================================================
7696 */const rF=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
7696]}],aF=Object.freeze(Object.defineProperty({__proto__:null,json:rF},Symbol.toStringTag,{value:"Module"}));/**
7697 * @license
7698 * Copyright 2023 Google LLC. All Rights Reserved.
7699 * Licensed under the Apache License, Version 2.0 (the "License");
7700 * you may not use this file except in compliance with the License.
7701 * You may obtain a copy of the License at
7702 *
7703 * http://www.apache.org/licenses/LICENSE-2.0
7704 *
7705 * Unless required by applicable law or agreed to in writing, software
7706 * distributed under the License is distributed on an "AS IS" BASIS,
7707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7708 * See the License for the specific language governing permissions and
7709 * limitations under the License.
7710 * =============================================================================
7711 */const oF=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
7711]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],iF=Object.freeze(Object.defineProperty({__proto__:null,json:oF},Symbol.toStringTag,{value:"Module"}));/**
7712 * @license
7713 * Copyright 2023 Google LLC. All Rights Reserved.
7714 * Licensed under the Apache License, Version 2.0 (the "License");
7715 * you may not use this file except in compliance with the License.
7716 * You may obtain a copy of the License at
7717 *
7718 * http://www.apache.org/licenses/LICENSE-2.0
7719 *
7720 * Unless required by applicable law or agreed to in writing, software
7721 * distributed under the License is distributed on an "AS IS" BASIS,
7722 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7723 * See the License for the specific language governing permissions and
7724 * limitations under the License.
7725 * =============================================================================
7726 */const lF=[{tfOpName:"EmptyTensorList",category:"control",input
7726s:[{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"}]}
7726,{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"}]}],uF=Object.freeze(Object.defineProperty({__proto__:null,json:lF},Symbol.toStringTag,{value:"Module"}));/**
7727 * @license
7728 * Copyright 2023 Google LLC. All Rights Reserved.
7729 * Licensed under the Apache License, Version 2.0 (the "License");
7730 * you may not use this file except in compliance with the License.
7731 * You may obtain a copy of the License at
7732 *
7733 * http://www.apache.org/licenses/LICENSE-2.0
7734 *
7735 * Unless required by applicable law or agreed to in writing, software
7736 * distributed under the License is distributed on an "AS IS" BASIS,
7737 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7738 * See the License for the specific language governing permissions and
7739 * limitations under the License.
7740 * =============================================================================
7741 */const cF=[{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}
vendor: 5,273 bytes, line 7741
7741,{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
vendor: 9,353 bytes, lines 7741-7789
7741,{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"}]}],hF=Object.freeze(Object.defineProperty({__proto__:null,json:cF},Symbol.toStringTag,{value:"Module"}));/**
7742 * @license
7743 * Copyright 2023 Google LLC. All Rights Reserved.
7744 * Licensed under the Apache License, Version 2.0 (the "License");
7745 * you may not use this file except in compliance with the License.
7746 * You may obtain a copy of the License at
7747 *
7748 * http://www.apache.org/licenses/LICENSE-2.0
7749 *
7750 * Unless required by applicable law or agreed to in writing, software
7751 * distributed under the License is distributed on an "AS IS" BASIS,
7752 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7753 * See the License for the specific language governing permissions and
7754 * limitations under the License.
7755 * =============================================================================
7756 */const dF=[{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"}]}],pF=Object.freeze(Object.defineProperty({__proto__:null,json:dF},Symbol.toStringTag,{value:"Module"}));/**
7757 * @license
7758 * Copyright 2023 Google LLC. All Rights Reserved.
7759 * Licensed under the Apache License, Version 2.0 (the "License");
7760 * you may not use this file except in compliance with the License.
7761 * You may obtain a copy of the License at
7762 *
7763 * http://www.apache.org/licenses/LICENSE-2.0
7764 *
7765 * Unless required by applicable law or agreed to in writing, software
7766 * distributed under the License is distributed on an "AS IS" BASIS,
7767 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7768 * See the License for the specific language governing permissions and
7769 * limitations under the License.
7770 * =============================================================================
7771 */const fF=[{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}]}],mF=Object.freeze(Object.defineProperty({__proto__:null,json:fF},Symbol.toStringTag,{value:"Module"}));/**
7772 * @license
7773 * Copyright 2023 Google LLC. All Rights Reserved.
7774 * Licensed under the Apache License, Version 2.0 (the "License");
7775 * you may not use this file except in compliance with the License.
7776 * You may obtain a copy of the License at
7777 *
7778 * http://www.apache.org/licenses/LICENSE-2.0
7779 *
7780 * Unless required by applicable law or agreed to in writing, software
7781 * distributed under the License is distributed on an "AS IS" BASIS,
7782 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7783 * See the License for the specific language governing permissions and
7784 * limitations under the License.
7785 * =============================================================================
7786 */const gF=[{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"}]}],yF=Object.freeze(Object.defineProperty({__proto__:null,json:gF},Symbol.toStringTag,{value:"Module"}));/**
7787 * @license
7788 * Copyright 2023 Google LLC. All Rights Reserved.
7789 * Licensed under the Apache License, Version 2.0 (the "License");
7790 * you may not use this file except in compliance with the License.
7791 * You may obtain a copy of the License at
7792 *
7793 * http://www.apache.org/licenses/LICENSE-2.0
7794 *
7795 * Unless required by applicable law or agreed to in writing, software
7796 * distributed under the License is distributed on an "AS IS" BASIS,
7797 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7798 * See the License for the specific language governing permissions and
7799 * limitations under the License.
7800 * =============================================================================
7801 */const xF=[{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"}]}],bF=Object.freeze(Object.defineProperty({__proto__:null,json:xF},Symbol.toStringTag,{value:"Module"}));/**
7802 * @license
7803 * Copyright 2023 Google LLC. All Rights Reserved.
7804 * Licensed under the Apache License, Version 2.0 (the "License");
7805 * you may not use this file except in compliance with the License.
7806 * You may obtain a copy of the License at
7807 *
7808 * http://www.apache.org/licenses/LICENSE-2.0
7809 *
7810 * Unless required by applicable law or agreed to in writing, software
7811 * distributed under the License is distributed on an "AS IS" BASIS,
7812 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7813 * See the License for the specific language governing permissions and
7814 * limitations under the License.
7815 * =============================================================================
7816 */const wF=[{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}
7816]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],vF=Object.freeze(Object.defineProperty({__proto__:null,json:wF},Symbol.toStringTag,{value:"Module"}));/**
7817 * @license
7818 * Copyright 2023 Google LLC. All Rights Reserved.
7819 * Licensed under the Apache License, Version 2.0 (the "License");
7820 * you may not use this file except in compliance with the License.
7821 * You may obtain a copy of the License at
7822 *
7823 * http://www.apache.org/licenses/LICENSE-2.0
7824 *
7825 * Unless required by applicable law or agreed to in writing, software
7826 * distributed under the License is distributed on an "AS IS" BASIS,
7827 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7828 * See the License for the specific language governing permissions and
7829 * limitations under the License.
7830 * =============================================================================
7831 */const CF=[{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"}]}],$F=Object.freeze(Object.defineProperty({__proto__:null,json:CF},Symbol.toStringTag,{value:"Module"}));/**
7832 * @license
7833 * Copyright 2023 Google LLC. All Rights Reserved.
7834 * Licensed under the Apache License, Version 2.0 (the "License");
7835 * you may not use this file except in compliance with the License.
7836 * You may obtain a copy of the License at
7837 *
7838 * http://www.apache.org/licenses/LICENSE-2.0
7839 *
7840 * Unless required by applicable law or agreed to in writing, software
7841 * distributed under the License is distributed on an "AS IS" BASIS,
7842 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7843 * See the License for the specific language governing permissions and
7844 * limitations under the License.
7845 * =============================================================================
7846 */const NF=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BitwiseAnd",category:"logical",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}]}],IF=Object.freeze(Object.defineProperty({__proto__:null,json:NF},Symbol.toStringTag,{value:"Module"}));/**
7847 * @license
7848 * Copyright 2023 Google LLC. All Rights Reserved.
7849 * Licensed under the Apache License, Version 2.0 (the "License");
7850 * you may not use this file except in compliance with the License.
7851 * You may obtain a copy of the License at
7852 *
7853 * http://www.apache.org/licenses/LICENSE-2.0
7854 *
7855 * Unless required by applicable law or agreed to in writing, software
7856 * distributed under the License is distributed on an "AS IS" BASIS,
7857 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7858 * See the License for the specific language governing permissions and
7859 * limitations under the License.
7860 * =============================================================================
7861 */const SF=[{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}
vendor: 16,250 bytes, lines 7861-7954
7861]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}],kF=Object.freeze(Object.defineProperty({__proto__:null,json:SF},Symbol.toStringTag,{value:"Module"}));/**
7862 * @license
7863 * Copyright 2023 Google LLC. All Rights Reserved.
7864 * Licensed under the Apache License, Version 2.0 (the "License");
7865 * you may not use this file except in compliance with the License.
7866 * You may obtain a copy of the License at
7867 *
7868 * http://www.apache.org/licenses/LICENSE-2.0
7869 *
7870 * Unless required by applicable law or agreed to in writing, software
7871 * distributed under the License is distributed on an "AS IS" BASIS,
7872 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7873 * See the License for the specific language governing permissions and
7874 * limitations under the License.
7875 * =============================================================================
7876 */const TF=[{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"}]}],EF=Object.freeze(Object.defineProperty({__proto__:null,json:TF},Symbol.toStringTag,{value:"Module"}));/**
7877 * @license
7878 * Copyright 2023 Google LLC. All Rights Reserved.
7879 * Licensed under the Apache License, Version 2.0 (the "License");
7880 * you may not use this file except in compliance with the License.
7881 * You may obtain a copy of the License at
7882 *
7883 * http://www.apache.org/licenses/LICENSE-2.0
7884 *
7885 * Unless required by applicable law or agreed to in writing, software
7886 * distributed under the License is distributed on an "AS IS" BASIS,
7887 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7888 * See the License for the specific language governing permissions and
7889 * limitations under the License.
7890 * =============================================================================
7891 */const RF=[{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"}]}],DF=Object.freeze(Object.defineProperty({__proto__:null,json:RF},Symbol.toStringTag,{value:"Module"}));/**
7892 * @license
7893 * Copyright 2023 Google LLC. All Rights Reserved.
7894 * Licensed under the Apache License, Version 2.0 (the "License");
7895 * you may not use this file except in compliance with the License.
7896 * You may obtain a copy of the License at
7897 *
7898 * http://www.apache.org/licenses/LICENSE-2.0
7899 *
7900 * Unless required by applicable law or agreed to in writing, software
7901 * distributed under the License is distributed on an "AS IS" BASIS,
7902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7903 * See the License for the specific language governing permissions and
7904 * limitations under the License.
7905 * =============================================================================
7906 */const AF=[{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"}]}],OF=Object.freeze(Object.defineProperty({__proto__:null,json:AF},Symbol.toStringTag,{value:"Module"}));/**
7907 * @license
7908 * Copyright 2023 Google LLC. All Rights Reserved.
7909 * Licensed under the Apache License, Version 2.0 (the "License");
7910 * you may not use this file except in compliance with the License.
7911 * You may obtain a copy of the License at
7912 *
7913 * http://www.apache.org/licenses/LICENSE-2.0
7914 *
7915 * Unless required by applicable law or agreed to in writing, software
7916 * distributed under the License is distributed on an "AS IS" BASIS,
7917 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7918 * See the License for the specific language governing permissions and
7919 * limitations under the License.
7920 * =============================================================================
7921 */const _F=[{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"}]}],FF=Object.freeze(Object.defineProperty({__proto__:null,json:_F},Symbol.toStringTag,{value:"Module"}));/**
7922 * @license
7923 * Copyright 2023 Google LLC. All Rights Reserved.
7924 * Licensed under the Apache License, Version 2.0 (the "License");
7925 * you may not use this file except in compliance with the License.
7926 * You may obtain a copy of the License at
7927 *
7928 * http://www.apache.org/licenses/LICENSE-2.0
7929 *
7930 * Unless required by applicable law or agreed to in writing, software
7931 * distributed under the License is distributed on an "AS IS" BASIS,
7932 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7933 * See the License for the specific language governing permissions and
7934 * limitations under the License.
7935 * =============================================================================
7936 */const LF=[{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}]}],PF=Object.freeze(Object.defineProperty({__proto__:null,json:LF},Symbol.toStringTag,{value:"Module"}));/**
7937 * @license
7938 * Copyright 2023 Google LLC. All Rights Reserved.
7939 * Licensed under the Apache License, Version 2.0 (the "License");
7940 * you may not use this file except in compliance with the License.
7941 * You may obtain a copy of the License at
7942 *
7943 * http://www.apache.org/licenses/LICENSE-2.0
7944 *
7945 * Unless required by applicable law or agreed to in writing, software
7946 * distributed under the License is distributed on an "AS IS" BASIS,
7947 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7948 * See the License for the specific language governing permissions and
7949 * limitations under the License.
7950 * =============================================================================
7951 */const zF=[{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"}]}],VF=Object.freeze(Object.defineProperty({__proto__:null,json:zF},Symbol.toStringTag,{value:"Module"}));/**
7952 * @license
7953 * Copyright 2023 Google LLC. All Rights Reserved.
7954 * Licensed under the Apache License, Version 2.0 (the "License");
7955 * you may not use this file except in compliance with the License.
7956 * You may obtain a copy of the License at
7957 *
7958 * http://www.apache.org/licenses/LICENSE-2.0
7959 *
7960 * Unless required by applicable law or agreed to in writing, software
7961 * distributed under the License is distributed on an "AS IS" BASIS,
7962 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7963 * See the License for the specific language governing permissions and
7964 * limitations under the License.
7965 * =============================================================================
7966 */const BF=[{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:[]}],MF=Object.freeze(Object.defineProperty({__proto__:null,json:BF},Symbol.toStringTag,{value:"Module"}));/**
7967 * @license
7968 * Copyright 2018 Google LLC. All Rights Reserved.
7969 * Licensed under the Apache License, Version 2.0 (the "License");
7970 * you may not use this file except in compliance with the License.
7971 * You may obtain a copy of the License at
7972 *
7973 * http://www.apache.org/licenses/LICENSE-2.0
7974 *
7975 * Unless required by applicable law or agreed to in writing, software
7976 * distributed under the License is distributed on an "AS IS" BASIS,
7977 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7978 * See the License for the specific language governing permissions and
7979 * limitations under the License.
7980 * =============================================================================
7981 */class iy{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[aF,iF,uF,hF,pF,mF,yF,bF,vF,$F,IF,kF,EF,DF,OF,FF,PF,VF,MF],t=[].concat(...e.map(s=>s.json));this.opMappers=t.reduce((s,r)=>(s[r.tfOpName]=r,s),{})}transformGraph(e,t={}){const s=e.node,r=[],a=[],o=[],i=s.reduce((g,m)=>(g[m.name]=this.mapNode(m),m.op.startsWith("Placeholder")?r.push(g[m.name]):m.op==="Const"?a.push(g[m.name]):(m.input==null||m.input.length===0)&&o.push(g[m.name]),g),{});let l=[];const u=[];let c={},h={};t!=null&&(c=this.mapSignatureEntries(t.inputs),h=this.mapSignatureEntries(t.outputs));const d=Object.keys(i);d.forEach(g=>{const m=i[g];
7981m.inputNames.forEach((y,x)=>{const[v,,b]=Qn(y),C=i[v];if(C.outputs!=null){const $=C.outputs.indexOf(b);if($!==-1){const S=`${v}:${$}`;m.inputNames[x]=S}}m.inputs.push(C),C.children.push(m)})}),Object.keys(h).length===0?d.forEach(g=>{const m=i[g];m.children.length===0&&u.push(m)}):Object.keys(h).forEach(g=>{const[m]=Qn(g),y=i[m];y!=null&&(y.signatureKey=h[g],u.push(y))}),Object.keys(c).length>0?Object.keys(c).forEach(g=>{const[m]=Qn(g),y=i[m];y&&(y.signatureKey=c[g],l.push(y))}):l=r;let p={};e.library!=null&&e.library.function!=null&&(p=e.library.function.reduce((g,m)=>(g[m.signature.name]=this.mapFunction(m),g),{}));const f={nodes:i,inputs:l,outputs:u,weights:a,placeholders:r,signature:t,functions:p};return o.length>0&&(f.initNodes=o),f}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,s)=>(t[e[s].name]=s,t),{})}mapNode(e){const t=I0(e.op)||this.opMappers[e.op]||{};e.attr==null&&(e.attr={});const s={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map(r=>r.startsWith("^")?r.slice(1):r),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return t.inputs!=null&&(s.inputParams=t.inputs.reduce((r,a)=>(r[a.name]={type:a.type,inputIndexStart:a.start,inputIndexEnd:a.end},r),{})),t.attrs!=null&&(s.attrParams=t.attrs.reduce((r,a)=>{const o=a.type;let i;switch(a.type){case"string":i=dd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=dd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"string[]":i=bd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=bd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"number":i=fd(e.attr,a.tfName,a.defaultValue||0),i===void 0&&a.tfDeprecatedName&&(i=fd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"number[]":i=xd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=xd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"bool":i=pd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=pd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"bool[]":i=vd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=vd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"shape":i=yd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=yd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"shape[]":i=wd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=wd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"dtype":i=md(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=md(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"dtype[]":i=gd(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=gd(e.attr,a.tfDeprecatedName,a.defaultValue));break;case"func":i=ly(e.attr,a.tfName,a.defaultValue),i===void 0&&a.tfDeprecatedName&&(i=ly(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 r[a.name]={value:i,type:o},r},{})),s}mapFunction(e){const t=e.nodeDef,s=[],r=[];let a={};t!=null&&(a=t.reduce((h,d)=>(h[d.name]=this.mapNode(d),d.op==="Const"&&r.push(h[d.name]),h),{}));const o=[],i=[];e.signature.inputArg.forEach(h=>{const[d]=Qn(h.name),p={name:d,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:Gm(h.type),type:"dtype"}},children:[]};p.signatureKey=h.name,o.push(p),a[d]=p}),Object.keys(a).forEach(h=>{const d=a[h];d.inputNames.forEach((p,f)=>{const[g,,m]=Qn(p),y=a[g];if(y.outputs!=null){const x=y.outputs.indexOf(m);if(x!==-1){const v=`${g}:${x}`;d.inputNames[f]=v}}d.inputs.push(y),y.children.push(d)})});const u=e.ret;e.signature.outputArg.forEach(h=>{const[d,p]=Qn(u[h.name]),f=a[d];f!=null&&(f.defaultOutput=p,i.push(f))});const c=this.mapArgsToSignature(e);return{nodes:a,inputs:o,outputs:i,weights:r,placeholders:s,signature:c}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((t,s)=>(t[s.name]=this.mapArgToTensorInfo(s),t),{}),outputs:e.signature.outputArg.reduce((t,s)=>(t[s.name]=this.mapArgToTensorInfo(s,e.ret),t),{})}}mapArgToTensorInfo(e,t){let s=e.name;return t!=null&&(s=t[s]),{name:s,dtype:e.type}}}function WF(n){const e=W().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 S0(n,e){const t=Array.isArray(n)?String.fromCharCode.apply(null,n):WF(n);return e?t:t.toLowerCase()}function dd(n,e,t,s=!1){const r=n[e];return r!=null?S0(r.s,s):t}function pd(n,e,t){const s=n[e];return s?s.b:t}function fd(n,e,t){const s=n[e]||{},r=s.i!=null?s.i:s.f!=null?s.f:t;return typeof r=="number"?r:parseInt(r,10)}function Gm(n){switch(typeof n=="string"&&(n=jt[n]),n){case jt.DT_FLOAT:case jt.DT_HALF:return"float32";case jt.DT_INT32:case jt.DT_INT64:case jt.DT_INT8:case jt.DT_UINT8:return"int32";case jt.DT_BOOL:return"bool";case jt.DT_DOUBLE:return"float32";case jt.DT_STRING:return"string";case jt.DT_COMPLEX64:case jt.DT_COMPLEX128:return"complex64";default:return null}}function ly(n,e,t){const s=n[e];return s&&s.func?s.func.name:t}function md(n,e,t){const s=n[e];return s&&s.type?Gm(s.type):t}function gd(n,e,t){const s=n[e];return s&&s.list&&s.list.type?s.list.type.map(r=>Gm(r)):t}function k0(n){if(!n.unknownRank)return n.dim!=null?n.dim.map(e=>typeof e.size=="number"?e.size:parseInt(e.size,10)):[]}function yd(n,e,t){const s=n[e];return s&&s.shape?k0(s.shape):t}function xd(n,e,t){const s=n[e];return s?((s.list.f&&s.list.f.length?s.list.f:s.list.i)||[]).map(r=>typeof r=="number"?r:parseInt(r,10)):t}function bd(n,e,t,s=!1){const r=n[e];return r&&r.list&&r.list.s?r.list.s.map(a=>S0(a,s)):t}function wd(n,e,t){const s=n[e];return s&&s.list&&s.list.shape?s.list.shape.map(r=>k0(r)):t}function vd(n,e,t){const s=n[e];return s&&s.list&&s.list.b?s.list.b:t}/**
7982 * @license
7983 * Copyright 2019 Google LLC. All Rights Reserved.
7984 * Licensed under the Apache License, Version 2.0 (the "License");
7985 * you may not use this file except in compliance with the License.
7986 * You may obtain a copy of the License at
7987 *
7988 * http://www.apache.org/licenses/LICENSE-2.0
7989 *
7990 * Unless required by applicable law or agreed to in writing, software
7991 * distributed under the License is distributed on an "AS IS" BASIS,
7992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7993 * See the License for the specific language governing permissions and
7994 * limitations under the License.
7995 * =============================================================================
7996 */class UF{constructor(e,t,s){this.node=e,this.tensorMap=t,this.context=s,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(r=>this.getInput(r)),e.rawAttrs!=null&&(this.attrs=Object.keys(e.rawAttrs).reduce((r,a)=>(r[a]=this.getAttr(a),r),{}))}getInput(e){return gt(e,this.tensorMap,this.context)}getAttr(e,t){const s=this.node.rawAttrs[e];if(s.tensor!=null)return gt(e,this.tensorMap,this.context);if(s.i!=null||s.f!=null)return fd(this.node.rawAttrs,e,t);if(s.s!=null)return dd(this.node.rawAttrs,e,t);if(s.b!=null)return pd(this.node.rawAttrs,e,t);if(s.shape!=null)return yd(this.node.rawAttrs,e,t);if(s.type!=null)return md(this.node.rawAttrs,e,t);if(s.list!=null){if(s.list.i!=null||s.list.f!=null)return xd(this.node.rawAttrs,e,t);if(s.list.s!=null)return bd(this.node.rawAttrs,e,t);if(s.list.shape!=null)return wd(this.node.rawAttrs,e,t);if(s.list.b!=null)return vd(this.node.rawAttrs,e,t);if(s.list.type!=null)return gd(this.node.rawAttrs,e,t)}return t}}/**
7997 * @license
7998 * Copyright 2020 Google LLC. All Rights Reserved.
7999 * Licensed under the Apache License, Version 2.0 (the "License");
8000 * you may not use this file except in compliance with the License.
8001 * You may obtain a copy of the License at
8002 *
8003 * http://www.apache.org/licenses/LICENSE-2.0
8004 *
8005 * Unless required by applicable law or agreed to in writing, software
8006 * distributed under the License is distributed on an "AS IS" BASIS,
8007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8008 * See the License for the specific language governing permissions and
8009 * limitations under the License.
8010 * =============================================================================
8011 */const $t=Object.freeze(Object.defineProperty({__proto__:null,OP_SCOPE_SUFFIX:fx,abs:rt,acos:sp,acosh:rp,add:te,addN:Xx,all:Bc,any:vo,argMax:nr,argMin:ap,asin:op,asinh:ip,atan:lp,atan2:up,atanh:cp,avgPool:Hi,avgPool3d:hp,basicLSTMCell:Yx,batchNorm:Oa,batchNorm2d:dp,batchNorm3d:pp,batchNorm4d:fp,batchToSpaceND:ji,bincount:mp,bitwiseAnd:Jx,booleanMaskAsync:_b,broadcastArgs:Zx,broadcastTo:Qs,buffer:$e,cast:ee,ceil:gp,clipByValue:Mt,clone:ts,complex:Cs,concat:Je,concat1d:yp,concat2d:xp,concat3d:bp,concat4d:wp,conv1d:Mc,conv2d:rs,conv2dTranspose:Wc,conv3d:Cp,conv3dTranspose:$p,cos:qi,cosh:Uc,cosineWindow:uh,cumprod:Co,cumsum:Gc,denseBincount:Yl,depthToSpace:Np,depthwiseConv2d:_a,diag:eb,dilation2d:Ip,div:he,divNoNan:Sp,dot:kp,dropout:af,einsum:js,elu:Bi,enclosingPowerOfTwo:of,ensureShape:tb,equal:Yt,erf:Hc,euclideanNorm:Tp,exp:Wt,expandDims:mt,expm1:Ep,eye:jc,fft:rl,fill:ta,floor:La,floorDiv:Hd,fused:Ub,gather:Pa,gatherND:zb,greater:Lt,greaterEqual:os,ifft:zr,imag:Ki,image:yn,inTopKAsync:Vb,irfft:rh,isFinite:Rp,isInf:Dp,isNaN:Ap,leakyRelu:Ac,less:_r,lessEqual:Ls,linalg:cf,linspace:sb,localResponseNormalization:Op,log:Jt,log1p:Xi,logSigmoid:_p,logSoftmax:qc,logSumExp:Yi,logicalAnd:wn,logicalNot:Ji,logicalOr:Kc,logicalXor:Fp,losses:Yb,lowerBound:rb,matMul:ve,max:on,maxPool:Zi,maxPool3d:Lp,maxPoolWithArgmax:ab,maximum:as,mean:je,meshgrid:ob,min:Or,minimum:Ss,mirrorPad:Pp,mod:zp,moments:Qi,movingAverage:Fb,mul:O,multiRNNCell:ib,multinomial:lb,neg:Ve,norm:Fa,notEqual:sr,oneHot:Fr,ones:Vt,onesLike:Zt,op:R,outerProduct:ub,pad:is,pad1d:cb,pad2d:hb,pad3d:db,pad4d:pb,pool:Vp,pow:As,prelu:Oc,print:mx,prod:Bp,raggedGather:fb,raggedRange:mb,raggedTensorToTensor:gb,rand:yb,randomGamma:vb,randomNormal:Yc,randomStandardNormal:Cb,randomUniform:Ps,randomUniformInt:$b,range:rr,real:Lr,reciprocal:Yp,relu:Kn,relu6:jd,reshape:D,reverse:un,reverse1d:Nb,reverse2d:Ib,reverse3d:Sb,reverse4d:kb,rfft:al,round:Jc,rsqrt:Zc,scalar:pe,scatterND:Lb,searchSorted:Xc,selu:Qc,separableConv2d:eh,setdiff1dAsync:Tb,sigmoid:Mn,sign:Jp,signal:Xb,sin:th,sinh:nh,slice:Se,slice1d:tl,slice2d:sh,slice3d:nl,slice4d:Pr,softmax:sl,softplus:gr,spaceToBatchND:el,sparse:Jb,sparseToDense:Pb,spectral:Kb,split:Bt,sqrt:ln,square:Ye,squaredDifference:ah,squeeze:zs,stack:Ot,step:Ea,stridedSlice:Zp,string:Zb,sub:ie,sum:oe,tan:Qp,tanh:Is,tensor:En,tensor1d:xt,tensor2d:bs,tensor3d:ef,tensor4d:Eb,tensor5d:Rb,tensor6d:Db,tensorScatterUpdate:Ab,tile:sn,topk:tf,transpose:Ne,truncatedNormal:oh,unique:nf,unsortedSegmentSum:ih,unstack:cn,upperBound:Ob,variable:sf,where:dt,whereAsync:rf,zeros:et,zerosLike:Be},Symbol.toStringTag,{value:"Module"}));/**
8012 * @license
8013 * Copyright 2018 Google LLC. All Rights Reserved.
8014 * Licensed under the Apache License, Version 2.0 (the "License");
8015 * you may not use this file except in compliance with the License.
8016 * You may obtain a copy of the License at
8017 *
8018 * http://www.apache.org/licenses/LICENSE-2.0
8019 *
8020 * Unless required by applicable law or agreed to in writing, software
8021 * distributed under the License is distributed on an "AS IS" BASIS,
8022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8023 * See the License for the specific language governing permissions and
8024 * limitations under the License.
8025 * =============================================================================
8026 */const GF=(n,e,t,s=$t)=>{switch(n.op){case"BiasAdd":case"AddV2":case"Add":return[s.add(w("a",n,e,t),w("b",n,e,t))];case"AddN":return[s.addN(w("tensors",n,e,t))];case"FloorMod":case"Mod":return[s.mod(w("a",n,e,t),w("b",n,e,t))];case"Mul":return[s.mul(w("a",n,e,t),w("b",n,e,t))];case"RealDiv":case"Div":return[s.div(w("a",n,e,t),w("b",n,e,t))];case"DivNoNan":return[s.divNoNan(w("a",n,e,t),w("b",n,e,t))];case"FloorDiv":return[s.floorDiv(w("a",n,e,t),w("b",n,e,t))];case"Sub":return[s.sub(w("a",n,e,t),w("b",n,e,t))];case"Minimum":return[s.minimum(w("a",n,e,t),w("b",n,e,t))];case"Maximum":return[s.maximum(w("a",n,e,t),w("b",n,e,t))];case"Pow":return[s.pow(w("a",n,e,t),w("b",n,e,t))];case"SquaredDifference":return[s.squaredDifference(w("a",n,e,t),w("b",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8027 * @license
8028 * Copyright 2018 Google LLC. All Rights Reserved.
8029 * Licensed under the Apache License, Version 2.0 (the "License");
8030 * you may not use this file except in compliance with the License.
8031 * You may obtain a copy of the License at
8032 *
8033 * http://www.apache.org/licenses/LICENSE-2.0
8034 *
8035 * Unless required by applicable law or agreed to in writing, software
8036 * distributed under the License is distributed on an "AS IS" BASIS,
8037 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8038 * See the License for the specific language governing permissions and
8039 * limitations under the License.
8040 * =============================================================================
8041 */const HF=(n,e,t,s=$t)=>{switch(n.op){case"Abs":case"ComplexAbs":return[s.abs(w("x",n,e,t))];case"Acos":return[s.acos(w("x",n,e,t))];case"Acosh":return[s.acosh(w("x",n,e,t))];case"Asin":return[s.asin(w("x",n,e,t))];case"Asinh":return[s.asinh(w("x",n,e,t))];case"Atan":return[s.atan(w("x",n,e,t))];case"Atan2":return[s.atan2(w("x",n,e,t),w("y",n,e,t))];case"Atanh":return[s.atanh(w("x",n,e,t))];case"Ceil":return[s.ceil(w("x",n,e,t))];case"Complex":return[s.complex(w("real",n,e,t),w("imag",n,e,t))];case"Cos":return[s.cos(w("x",n,e,t))];case"Cosh":return[s.cosh(w("x",n,e,t))];case"Elu":return[s.elu(w("x",n,e,t))];case"Erf":return[s.erf(w("x",n,e,t))];case"Exp":return[s.exp(w("x",n,e,t))];case"Expm1":return[s.expm1(w("x",n,e,t))];case"Floor":return[s.floor(w("x",n,e,t))];case"Log":return[s.log(w("x",n,e,t))];case"Log1p":return[s.log1p(w("x",n,e,t))];case"Imag":return[s.imag(w("x",n,e,t))];case"Neg":return[s.neg(w("x",n,e,t))];case"Reciprocal":return[s.reciprocal(w("x",n,e,t))];case"Real":return[s.real(w("x",n,e,t))];case"Relu":return[s.relu(w("x",n,e,t))];case"Round":return[s.round(w("x",n,e,t))];case"Selu":return[s.selu(w("x",n,e,t))];case"Sigmoid":return[s.sigmoid(w("x",n,e,t))];case"Sin":return[s.sin(w("x",n,e,t))];case"Sign":return[s.sign(w("x",n,e,t))];case"Sinh":return[s.sinh(w("x",n,e,t))];case"Softplus":return[s.softplus(w("x",n,e,t))];case"Sqrt":return[s.sqrt(w("x",n,e,t))];case"Square":return[s.square(w("x",n,e,t))];case"Tanh":return[s.tanh(w("x",n,e,t))];case"Tan":return[s.tan(w("x",n,e,t))];case"ClipByValue":return[s.clipByValue(w("x",n,e,t),w("clipValueMin",n,e,t),w("clipValueMax",n,e,t))];case"Relu6":return[s.relu6(w("x",n,e,t))];case"Rsqrt":return[s.rsqrt(gt(n.inputNames[0],e,t))];case"LeakyRelu":return[s.leakyRelu(w("x",n,e,t),w("alpha",n,e,t))];case"Prelu":return[s.prelu(w("x",n,e,t),w("alpha",n,e,t))];case"IsNan":return[s.isNaN(gt(n.inputNames[0],e,t))];case"IsInf":return[s.isInf(gt(n.inputNames[0],e,t))];case"IsFinite":return[s.isFinite(gt(n.inputNames[0],e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8042 * @license
8043 * Copyright 2020 Google LLC. All Rights Reserved.
8044 * Licensed under the Apache License, Version 2.0 (the "License");
8045 * you may not use this file except in compliance with the License.
8046 * You may obtain a copy of the License at
8047 *
8048 * http://www.apache.org/licenses/LICENSE-2.0
8049 *
8050 * Unless required by applicable law or agreed to in writing, software
8051 * distributed under the License is distributed on an "AS IS" BASIS,
8052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8053 * See the License for the specific language governing permissions and
8054 * limitations under the License.
8055 * =============================================================================
8056 */function gn(n,e,t=""){if(!(typeof n=="number"||typeof e=="number")){I(n.length===e.length,()=>t+` Shapes ${n} and ${e} must match`);for(let s=0;s<n.length;s++){const r=n[s],a=e[s];I(r<0||a<0||r===a,()=>t+` Shapes ${n} and ${e} must match`)}}}function uy(n){return!(typeof n=="number"||n.some(e=>e<0))}function ao(n,e,t){let s=Cd(n,t);const r=!uy(s);if(r&&e.length===0)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${s}`);if(r&&e.forEach(a=>{s=Cd(a.shape,s)}),!uy(s))throw new Error(`Non-fully-defined elementShape: ${s}`);return s}function Cd(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 s=0;s<n.length;++s){const r=n[s],a=e[s];if(r>=0&&a>=0&&r!==a)throw new Error(`Incompatible shape during merge: ${n} vs. ${e}`);t[s]=r>=0?r:a}return t}/**
8057 * @license
8058 * Copyright 2018 Google LLC. All Rights Reserved.
8059 * Licensed under the Apache License, Version 2.0 (the "License");
8060 * you may not use this file except in compliance with the License.
8061 * You may obtain a copy of the License at
8062 *
8063 * http://www.apache.org/licenses/LICENSE-2.0
8064 *
8065 * Unless required by applicable law or agreed to in writing, software
8066 * distributed under the License is distributed on an "AS IS" BASIS,
8067 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8068 * See the License for the specific language governing permissions and
8069 * limitations under the License.
8070 * =============================================================================
8071 */class jF{constructor(e,t,s,r,a,o,i){this.name=e,this.dtype=t,this.maxSize=s,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=o,this.clearAfterRead=i,this.tensors=[],this.closed_=!1,this.idTensor=pe(0),ct(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 s=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},
8072          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),gn(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),s.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(s.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);
8072s.tensor=t,ct(t),s.written=!0,this.tensors[e]=s}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((s,r)=>this.write(s,t[r]))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let r=0;r<this.size();r++)e.push(r)}if(e.length===0)return En([],[0].concat(this.elementShape));const s=this.readMany(e);return gn(this.elementShape,s[0].shape,"TensorArray shape mismatch: "),Ot(s,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 En([],[0].concat(this.elementShape));const t=[];for(let r=0;r<this.size();r++)t.push(r);const s=this.readMany(t);return gn(this.elementShape,s[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${s[0].shape})`),Je(s,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 s=Math.max(...e);if(!this.dynamicSize&&s>=this.maxSize)throw new Error(`Max index must be < array size (${s}  vs. ${this.maxSize})`);this.writeMany(e,cn(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 s=0;const r=e.map(l=>(s+=l,s));if(s!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to
8073          tensor.shape[0], but sum of lengths is
8074        ${s}, 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=s===0?0:t.size/s,o=[];L(()=>{t=D(t,[1,s,a]);for(let l=0;l<e.length;++l){const c=[0,l===0?0:r[l-1],0],h=[1,e[l],a];o[l]=D(Se(t,c,h),this.elementShape)}return o});const i=[];for(let l=0;l<e.length;l++)i[l]=l;this.writeMany(i,o)}}/**
8075 * @license
8076 * Copyright 2020 Google LLC. All Rights Reserved.
8077 * Licensed under the Apache License, Version 2.0 (the "License");
8078 * you may not use this file except in compliance with the License.
8079 * You may obtain a copy of the License at
8080 *
8081 * http://www.apache.org/licenses/LICENSE-2.0
8082 *
8083 * Unless required by applicable law or agreed to in writing, software
8084 * distributed under the License is distributed on an "AS IS" BASIS,
8085 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8086 * See the License for the specific language governing permissions and
8087 * limitations under the License.
8088 * =============================================================================
8089 */class lr{get id(){return this.idTensor.id}constructor(e,t,s,r=-1){this.tensors=e,this.elementShape=t,this.elementDtype=s,e!=null&&e.forEach(a=>{if(s!==a.dtype)throw new Error(`Invalid data types; op elements ${s}, but list elements ${a.dtype}`);gn(t,a.shape,"TensorList shape mismatch: "),ct(a)}),this.idTensor=pe(0),this.maxNumElements=r,ct(this.idTensor)}copy(){return new lr([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach(t=>{(e==null||!e.has(t.id))&&t.dispose()}),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,s=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(s!==-1&&this.tensors.length!==s)throw new Error(`Operation expected a list with ${s} elements but got a list with ${this.tensors.length} elements.`);gn(e,this.elementShape,"TensorList shape mismatch: ");const r=ao(this.elementShape,this.tensors,e);return L(()=>{const a=this.tensors.map(o=>D(o,r));return Ot(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 s=ao(this.elementShape,this.tensors,e),r=this.tensors.pop();return r.kept=!1,gn(r.shape,e,"TensorList shape mismatch: "),D(r,s)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(gn(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");ct(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(this.maxNumElements!==-1&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new lr([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let s=0;s<Math.min(this.tensors.length,e);++s)t.tensors[s]=this.tensors[s];return t}
8089getItem(e,t,s){if(s!==this.elementDtype)throw new Error(`Invalid data types; op elements ${s}, 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.`);gn(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=ao(this.elementShape,this.tensors,t);return D(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||this.maxNumElements!==-1&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);gn(this.elementShape,t.shape,"TensorList shape mismatch: "),ct(t),this.tensors[e]!=null&&(this.tensors[e].kept=!1),this.tensors[e]=t}gather(e,t,s){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);gn(this.elementShape,s,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=ao(this.elementShape,this.tensors,s);return e.length===0?En([],[0].concat(r)):L(()=>{const a=e.map(o=>D(this.tensors[o],r));return Ot(a,0)})}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);gn(this.elementShape,t,"TensorList shape mismatch: ");const s=ao(this.elementShape,this.tensors,t);return this.size()===0?En([],[0].concat(s)):L(()=>{const r=this.tensors.map(a=>D(a,s));return Je(r,0)})}}function qF(n,e,t){const s=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 r=n.shape.slice(1);gn(r,e,"TensorList shape mismatch: ");const a=cn(n);return new lr(a,e,s)}function KF(n,e,t,s){return new lr([],n,e,s)}function XF(n,e,t,s){if(e.length!==n.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${n.shape[0]}`);const r=Math.max(...e);if(s!=null&&s!==-1&&r>=s)throw new Error(`Max index must be < array size (${r}  vs. ${s})`);const a=new lr([],t,n.dtype,s),o=cn(n,0);return e.forEach((i,l)=>{a.setItem(i,o[l])}),a}function YF(n,e,t){let s=0;const r=e.map(c=>(s+=c,s));if(s!==n.shape[0])throw new Error(`Expected sum of lengths to be equal to
8090          tensor.shape[0], but sum of lengths is
8091        ${s}, and tensor's shape is: ${n.shape}`);const a=n.shape.slice(1),o=Cd(a,t),i=s===0?0:n.size/s,l=L(()=>{const c=[];n=D(n,[1,s,i]);for(let h=0;h<e.length;++h){const p=[0,h===0?0:r[h-1],0],f=[1,e[h],i];c[h]=D(Se(n,p,f),o)}return n.dispose(),c}),u=new lr([],t,n.dtype,e.length);for(let c=0;c<l.length;c++)u.setItem(c,l[c]);return u}/**
8092 * @license
8093 * Copyright 2018 Google LLC. All Rights Reserved.
8094 * Licensed under the Apache License, Version 2.0 (the "License");
8095 * you may not use this file except in compliance with the License.
8096 * You may obtain a copy of the License at
8097 *
8098 * http://www.apache.org/licenses/LICENSE-2.0
8099 *
8100 * Unless required by applicable law or agreed to in writing, software
8101 * distributed under the License is distributed on an "AS IS" BASIS,
8102 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8103 * See the License for the specific language governing permissions and
8104 * limitations under the License.
8105 * =============================================================================
8106 */const JF=async(n,e,t)=>{switch(n.op){case"If":case"StatelessIf":{const s=w("thenBranch",n,e,t),r=w("elseBranch",n,e,t),a=w("cond",n,e,t),o=w("args",n,e,t);return(await a.data())[0]?t.functionMap[s].executeFunctionAsync(o,t.tensorArrayMap,t.tensorListMap):t.functionMap[r].executeFunctionAsync(o,t.tensorArrayMap,t.tensorListMap)}case"While":case"StatelessWhile":{const s=w("body",n,e,t),r=w("cond",n,e,t),a=w("args",n,e,t),o=await t.functionMap[r].executeFunctionAsync(a,t.tensorArrayMap,t.tensorListMap),i=a.map(c=>c.id);let l=await o[0].data();o.forEach(c=>{!c.kept&&i.indexOf(c.id)===-1&&c.dispose()});let u=a;for(;l[0];){const c=u;u=await t.functionMap[s].executeFunctionAsync(u,t.tensorArrayMap,t.tensorListMap);const h=u.map(p=>p.id);
8106c.forEach(p=>{!p.kept&&i.indexOf(p.id)===-1&&h.indexOf(p.id)===-1&&p.dispose()});const d=await t.functionMap[r].executeFunctionAsync(u,t.tensorArrayMap,t.tensorListMap);l=await d[0].data(),d.forEach(p=>{!p.kept&&i.indexOf(p.id)===-1&&h.indexOf(p.id)===-1&&p.dispose()})}return u}case"LoopCond":{const s=w("pred",n,e,t);return[es(s)]}case"Switch":{const s=w("pred",n,e,t);let r=w("data",n,e,t);return r.kept||(r=es(r)),(await s.data())[0]?[void 0,r]:[r,void 0]}case"Merge":{const s=n.inputNames.find(r=>gt(r,e,t)!==void 0);if(s){const r=gt(s,e,t);return[es(r)]}return}case"Enter":{const s=w("frameName",n,e,t),r=w("tensor",n,e,t);return t.enterFrame(s),[es(r)]}case"Exit":{const s=w("tensor",n,e,t);return t.exitFrame(),[es(s)]}case"NextIteration":{const s=w("tensor",n,e,t);return t.nextIteration(),[es(s)]}case"TensorArrayV3":{const s=w("size",n,e,t),r=w("dtype",n,e,t),a=w("elementShape",n,e,t),o=w("dynamicSize",n,e,t),i=w("clearAfterRead",n,e,t),l=w("identicalElementShapes",n,e,t),u=w("name",n,e,t),c=new jF(u,r,s,a,l,o,i);return t.addTensorArray(c),[c.idTensor,pe(1)]}case"TensorArrayWriteV3":{const s=w("tensorArrayId",n,e,t),r=w("index",n,e,t),a=w("tensor",n,e,t),o=t.getTensorArray(s.id);return o.write(r,a),[o.idTensor]}case"TensorArrayReadV3":{const s=w("tensorArrayId",n,e,t),r=w("index",n,e,t);return[t.getTensorArray(s.id).read(r)]}case"TensorArrayGatherV3":{const s=w("tensorArrayId",n,e,t),r=w("indices",n,e,t),a=w("dtype",n,e,t);return[t.getTensorArray(s.id).gather(r,a)]}case"TensorArrayScatterV3":{const s=w("tensorArrayId",n,e,t),r=w("indices",n,e,t),a=w("tensor",n,e,t),o=t.getTensorArray(s.id);return o.scatter(r,a),[o.idTensor]}case"TensorArrayConcatV3":{const s=w("tensorArrayId",n,e,t),r=t.getTensorArray(s.id),a=w("dtype",n,e,t);return[r.concat(a)]}case"TensorArraySplitV3":{const s=w("tensorArrayId",n,e,t),r=w("tensor",n,e,t),a=w("lengths",n,e,t),o=t.getTensorArray(s.id);return o.split(a,r),[o.idTensor]}case"TensorArraySizeV3":{const s=w("tensorArrayId",n,e,t),r=t.getTensorArray(s.id);return[pe(r.size(),"int32")]}case"TensorArrayCloseV3":{const s=w("tensorArrayId",n,e,t),r=t.getTensorArray(s.id);return r.clearAndClose(),[r.idTensor]}case"TensorListSetItem":{const s=w("tensorListId",n,e,t),r=w("index",n,e,t),a=w("tensor",n,e,t),o=t.getTensorList(s.id);return o.setItem(r,a),[o.idTensor]}case"TensorListGetItem":{const s=w("tensorListId",n,e,t),r=w("index",n,e,t),a=w("elementShape",n,e,t),o=w("elementDType",n,e,t);return[t.getTensorList(s.id).getItem(r,a,o)]}case"TensorListScatterV2":case"TensorListScatter":{const s=w("indices",n,e,t),r=w("tensor",n,e,t),a=w("elementShape",n,e,t),o=w("numElements",n,e,t),i=XF(r,s,a,o);return t.addTensorList(i),[i.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const s=w("elementShape",n,e,t),r=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,l=KF(s,r,o,i);return t.addTensorList(l),[l.idTensor]}case"TensorListGather":{const s=w("tensorListId",n,e,t),r=w("indices",n,e,t),a=w("elementShape",n,e,t),o=w("elementDType",n,e,t);return[t.getTensorList(s.id).gather(r,o,a)]}case"TensorListStack":{const s=w("tensorListId",n,e,t),r=w("elementShape",n,e,t),a=w("elementDType",n,e,t),o=w("numElements",n,e,t);return[t.getTensorList(s.id).stack(r,a,o)]}case"TensorListFromTensor":{const s=w("tensor",n,e,t),r=w("elementShape",n,e,t),a=w("elementDType",n,e,t),o=qF(s,r,a);return t.addTensorList(o),[o.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const s=w("tensorListId",n,e,t),r=t.getTensorList(s.id),a=w("dtype",n,e,t),o=w("elementShape",n,e,t);return[r.concat(a,o)]}case"TensorListPushBack":{const s=w("tensorListId",n,e,t),r=w("tensor",n,e,t),a=t.getTensorList(s.id);return a.pushBack(r),[a.idTensor]}case"TensorListPopBack":{const s=w("tensorListId",n,e,t),r=w("elementShape",n,e,t),a=w("elementDType",n,e,t);return[t.getTensorList(s.id).popBack(r,a)]}case"TensorListSplit":{const s=w("tensor",n,e,t),r=w("elementShape",n,e,t),a=w("lengths",n,e,t),o=YF(s,a,r);return t.addTensorList(o),[o.idTensor]}case"TensorListLength":{const s=w("tensorListId",n,e,t),r=t.getTensorList(s.id);return[pe(r.size(),"int32")]}case"TensorListResize":{const s=w("tensorListId",n,e,t),r=w("size",n,e,t),o=t.getTensorList(s.id).resize(r);return t.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8107 * @license
8108 * Copyright 2018 Google LLC. All Rights Reserved.
8109 * Licensed under the Apache License, Version 2.0 (the "License");
8110 * you may not use this file except in compliance with the License.
8111 * You may obtain a copy of the License at
8112 *
8113 * http://www.apache.org/licenses/LICENSE-2.0
8114 *
8115 * Unless required by applicable law or agreed to in writing, software
8116 * distributed under the License is distributed on an "AS IS" BASIS,
8117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8118 * See the License for the specific language governing permissions and
8119 * limitations under the License.
8120 * =============================================================================
8121 */function cy(n,e,t){const[s,r]=w("fusedOps",n,e,t),a=s==="biasadd",o=!a,i=r==="prelu",l=s==="fusedbatchnorm",u=w("numArgs",n,e,t);if(a){if(i&&u!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&a&&u!==1)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(l)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=w("strides",n,e,t),h=Pl(n,e,t),d=w("dataFormat",n,e,t).toUpperCase(),p=w("dilations",n,e,t);let[f,g]=w("args",n,e,t);o&&(g=f,f=void 0);const m=w("leakyreluAlpha",n,e,t);return{stride:c,pad:h,dataFormat:d,dilations:p,biasArg:f,preluArg:g,activationFunc:r,leakyreluAlpha:m}}const ZF=(n,e,t,s=$t)=>{switch(n.op){case"Conv1D":{const r=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[s.conv1d(w("x",n,e,t),w("filter",n,e,t),r,a,o,i)]}case"Conv2D":{const r=w("strides",n,e,t),a=Pl(n,e,t),o=w("dataFormat",n,e,t).toUpperCase(),i=w("dilations",n,e,t);return[s.conv2d(w("x",n,e,t),w("filter",n,e,t),[r[1],r[2]],a,o,[i[1],i[2]])]}case"_FusedConv2D":{const{stride:r,pad:a,dataFormat:o,dilations:i,biasArg:l,preluArg:u,activationFunc:c,leakyreluAlpha:h}=cy(n,e,t);return[s.fused.conv2d({x:w("x",n,e,t),filter:w("filter",n,e,t),strides:[r[1],r[2]],pad:a,dataFormat:o,dilations:[i[1],i[2]],bias:l,activation:c,preluActivationWeights:u,leakyreluAlpha:h})]}case"FusedDepthwiseConv2dNative":{const{stride:r,pad:a,dataFormat:o,dilations:i,biasArg:l,preluArg:u,activationFunc:c,leakyreluAlpha:h}=cy(n,e,t);return[s.fused.depthwiseConv2d({x:w("x",n,e,t),filter:w("filter",n,e,t),strides:[r[1],r[2]],pad:a,dataFormat:o,dilations:[i[1],i[2]],bias:l,activation:c,preluActivationWeights:u,leakyreluAlpha:h})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const r=w("outputShape",n,e,t),a=w("strides",n,e,t),o=Pl(n,e,t);return[s.conv2dTranspose(w("x",n,e,t),w("filter",n,e,t),r,[a[1],a[2]],o)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const r=w("strides",n,e,t),a=Pl(n,e,t),o=w("dilations",n,e,t),i=w("dataFormat",n,e,t).toUpperCase();return[s.depthwiseConv2d(w("input",n,e,t),w("filter",n,e,t),[r[1],r[2]],a,i,[o[1],o[2]])]}case"Conv3D":{const r=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[s.conv3d(w("x",n,e,t),w("filter",n,e,t),[r[1],r[2],r[3]],a,o,[i[1],i[2],i[3]])]}case"AvgPool":{const r=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[s.avgPool(w("x",n,e,t),[o[1],o[2]],[r[1],r[2]],a)]}case"MaxPool":{const r=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[s.maxPool(w("x",n,e,t),[o[1],o[2]],[r[1],r[2]],a)]}case"MaxPoolWithArgmax":{const r=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t),i=w("includeBatchInIndex",n,e,t),{result:l,indexes:u}=s.maxPoolWithArgmax(w("x",n,e,t),[o[1],o[2]],[r[1],r[2]],a,i);return[l,u]}case"AvgPool3D":{const r=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[s.avgPool3d(w("x",n,e,t),[o[1],o[2],o[3]],[r[1],r[2],r[3]],a)]}case"MaxPool3D":{const r=w("strides",n,e,t),a=w("pad",n,e,t),o=w("kernelSize",n,e,t);return[s.maxPool3d(w("x",n,e,t),[o[1],o[2],o[3]],[r[1],r[2],r[3]],a)]}case"Dilation2D":{const r=w("strides",n,e,t),a=w("pad",n,e,t),o=w("dilations",n,e,t),i=r[1],l=r[2],u=o[1],c=o[2];return[s.dilation2d(w("x",n,e,t),w("filter",n,e,t),[i,l],a,[u,c],"NHWC")]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8122 * @license
8123 * Copyright 2018 Google LLC. All Rights Reserved.
8124 * Licensed under the Apache License, Version 2.0 (the "License");
8125 * you may not use this file except in compliance with the License.
8126 * You may obtain a copy of the License at
8127 *
8128 * http://www.apache.org/licenses/LICENSE-2.0
8129 *
8130 * Unless required by applicable law or agreed to in writing, software
8131 * distributed under the License is distributed on an "AS IS" BASIS,
8132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8133 * See the License for the specific language governing permissions and
8134 * limitations under the License.
8135 * =============================================================================
8136 */const QF=(n,e,t,s=$t)=>{switch(n.op){case"Fill":{const r=w("shape",n,e,t),a=w("dtype",n,e,t),o=w("value",n,e,t);return[s.fill(r,o,a)]}case"LinSpace":{const r=w("start",n,e,t),a=w("stop",n,e,t),o=w("num",n,e,t);return[s.linspace(r,a,o)]}case"Multinomial":{const r=w("logits",n,e,t),a=w("numSamples",n,e,t),o=w("seed",n,e,t);return[s.multinomial(r,a,o)]}case"OneHot":{const r=w("indices",n,e,t),a=w("depth",n,e,t),o=w("onValue",n,e,t),i=w("offValue",n,e,t),l=w("dtype",n,e,t);return[s.oneHot(r,a,o,i,l)]}case"Ones":return[s.ones(w("shape",n,e,t),w("dtype",n,e,t))];case"OnesLike":return[s.onesLike(w("x",n,e,t))];case"RandomStandardNormal":return[s.randomStandardNormal(w("shape",n,e,t),w("dtype",n,e,t),w("seed",n,e,t))];case"RandomUniform":return[s.randomUniform(w("shape",n,e,t),w("minval",n,e,t),w("maxval",n,e,t),w("dtype",n,e,t))];case"RandomUniformInt":return[s.randomUniformInt(w("shape",n,e,t),w("minval",n,e,t),w("maxval",n,e,t),w("seed",n,e,t))];case"Range":{const r=w("start",n,e,t),a=w("stop",n,e,t),o=w("step",n,e,t);return[s.range(r,a,o,w("dtype",n,e,t))]}case"TruncatedNormal":{const r=w("shape",n,e,t),a=w("mean",n,e,t),o=w("stdDev",n,e,t),i=w("seed",n,e,t);return[s.truncatedNormal(r,a,o,w("dtype",n,e,t),i)]}case"Zeros":return[s.zeros(w("shape",n,e,t),w("dtype",n,e,t))];case"ZerosLike":return[s.zerosLike(w("x",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8137 * @license
8138 * Copyright 2018 Google LLC. All Rights Reserved.
8139 * Licensed under the Apache License, Version 2.0 (the "License");
8140 * you may not use this file except in compliance with the License.
8141 * You may obtain a copy of the License at
8142 *
8143 * http://www.apache.org/licenses/LICENSE-2.0
8144 *
8145 * Unless required by applicable law or agreed to in writing, software
8146 * distributed under the License is distributed on an "AS IS" BASIS,
8147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8148 * See the License for the specific language governing permissions and
8149 * limitations under the License.
8150 * =============================================================================
8151 */function Kh(n,e,t){const s=w("boxes",n,e,t),r=w("scores",n,e,t),a=w("maxOutputSize",n,e,t),o=w("iouThreshold",n,e,t),i=w("scoreThreshold",n,e,t),l=w("softNmsSigma",n,e,t);return{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:l}}const eL=async(n,e,t,s,r=$t)=>{switch(n.op){case"NonMaxSuppressionV5":{const{boxes:a,scores:o,maxOutputSize:i,iouThreshold:l,scoreThreshold:u,softNmsSigma:c}=Kh(n,e,t),h=await r.image.nonMaxSuppressionWithScoreAsync(a,o,i,l,u,c);return[h.selectedIndices,h.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:a,scores:o,maxOutputSize:i,iouThreshold:l,scoreThreshold:u}=Kh(n,e,t),c=w("padToMaxOutputSize",n,e,t),h=await r.image.nonMaxSuppressionPaddedAsync(a,o,i,l,u,c);return[h.selectedIndices,h.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:a,scores:o,maxOutputSize:i,iouThreshold:l,scoreThreshold:u}=Kh(n,e,t);return[await r.image.nonMaxSuppressionAsync(a,o,i,l,u)]}case"Where":{const a=r.cast(w("condition",n,e,t),"bool"),o=[await r.whereAsync(a)];return a.dispose(),o}case"ListDiff":return r.setdiff1dAsync(w("x",n,e,t),w("y",n,e,t));default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8152 * @license
8153 * Copyright 2018 Google LLC. All Rights Reserved.
8154 * Licensed under the Apache License, Version 2.0 (the "License");
8155 * you may not use this file except in compliance with the License.
8156 * You may obtain a copy of the License at
8157 *
8158 * http://www.apache.org/licenses/LICENSE-2.0
8159 *
8160 * Unless required by applicable law or agreed to in writing, softw
8160are
8161 * distributed under the License is distributed on an "AS IS" BASIS,
8162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8163 * See the License for the specific language governing permissions and
8164 * limitations under the License.
8165 * =============================================================================
8166 */const tL=(n,e,t,s=$t)=>{switch(n.op){case"LowerBound":{const r=w("sortedSequence",n,e,t),a=w("values",n,e,t);return[s.lowerBound(r,a)]}case"TopKV2":{const r=w("x",n,e,t),a=w("k",n,e,t),o=w("sorted",n,e,t),i=s.topk(r,a,o);return[i.values,i.indices]}case"UpperBound":{const r=w("sortedSequence",n,e,t),a=w("values",n,e,t);return[s.upperBound(r,a)]}case"Unique":{const r=w("x",n,e,t),a=s.unique(r);return[a.values,a.indices]}case"UniqueV2":{const r=w("x",n,e,t),a=w("axis",n,e,t),o=s.unique(r,a);return[o.values,o.indices]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8167 * @license
8168 * Copyright 2018 Google LLC. All Rights Reserved.
8169 * Licensed under the Apache License, Version 2.0 (the "License");
8170 * you may not use this file except in compliance with the License.
8171 * You may obtain a copy of the License at
8172 *
8173 * http://www.apache.org/licenses/LICENSE-2.0
8174 *
8175 * Unless required by applicable law or agreed to in writing, software
8176 * distributed under the License is distributed on an "AS IS" BASIS,
8177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8178 * See the License for the specific language governing permissions and
8179 * limitations under the License.
8180 * =============================================================================
8181 */const nL=(n,e,t,s=$t)=>{switch(n.op){case"Const":return e[n.name];case"PlaceholderWithDefault":const r=w("default",n,e,t);return[gt(n.name,e,t)||r];case"Placeholder":return[gt(n.name,e,t)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{const c=w("x",n,e,t);return[es(c)]}case"IdentityN":return w("x",n,e,t).map(c=>es(c));case"Snapshot":const a=w("x",n,e,t);return[es(a)];case"Shape":return[s.tensor1d(w("x",n,e,t).shape,"int32")];case"ShapeN":return w("x",n,e,t).map(c=>s.tensor1d(c.shape));case"Size":return[s.scalar(w("x",n,e,t).size,"int32")];case"Rank":return[s.scalar(w("x",n,e,t).rank,"int32")];case"NoOp":return[s.scalar(1)];case"Print":const o=w("x",n,e,t),i=w("data",n,e,t),l=w("message",n,e,t),u=w("summarize",n,e,t);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance.");for(let c=0;c<i.length;c++)Array.prototype.slice.call(i[c].dataSync()).slice(0,u);return[o];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8182 * @license
8183 * Copyright 2020 Google LLC. All Rights Reserved.
8184 * Licensed under the Apache License, Version 2.0 (the "License");
8185 * you may not use this file except in compliance with the License.
8186 * You may obtain a copy of the License at
8187 *
8188 * http://www.apache.org/licenses/LICENSE-2.0
8189 *
8190 * Unless required by applicable law or agreed to in writing, software
8191 * distributed under the License is distributed on an "AS IS" BASIS,
8192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8193 * See the License for the specific language governing permissions and
8194 * limitations under the License.
8195 * =============================================================================
8196 */class sL{get id(){return this.handle.id}constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=pe(0),this.tensorMap=new Map,ct(this.handle)}clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return pe(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const s=await e.data();return this.tensorMap.forEach(r=>r.dispose()),this.tensorMap.clear(),L(()=>{const r=cn(t),a=s.length,o=r.length;I(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 l=s[i],u=r[i];ct(u),this.tensorMap.set(l,u)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);const s=await e.data();return L(()=>{const r=[];for(let a=0;a<s.length;a++){const o=s[a],i=this.findWithDefault(o,t);r.push(i)}return Ot(r)})}findWithDefault(e,t){const s=this.tensorMap.get(e);return s??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}`)}}/**
8197 * @license
8198 * Copyright 2020 Google LLC. All Rights Reserved.
8199 * Licensed under the Apache License, Version 2.0 (the "License");
8200 * you may not use this file except in compliance with the License.
8201 * You may obtain a copy of the License at
8202 *
8203 * http://www.apache.org/licenses/LICENSE-2.0
8204 *
8205 * Unless required by applicable law or agreed to in writing, software
8206 * distributed under the License is distributed on an "AS IS" BASIS,
8207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8208 * See the License for the specific language governing permissions and
8209 * limitations under the License.
8210 * =============================================================================
8211 */const rL=async(n,e,t,s)=>{switch(n.op){case"HashTable":case"HashTableV2":{const r=s.getHashTableHandleByName(n.name);if(r!=null)return[r];{const a=w("keyDType",n,e,t),o=w("valueDType",n,e,t),i=new sL(a,o);return s.addHashTable(n.name,i),[i.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{const r=w("tableHandle",n,e,t,s),a=w("keys",n,e,t),o=w("values",n,e,t);return[await s.getHashTableById(r.id).import(a,o)]}case"LookupTableFind":case"LookupTableFindV2":{const r=w("tableHandle",n,e,t,s),a=w("keys",n,e,t),o=w("defaultValue",n,e,t);return[await s.getHashTableById(r.id).find(a,o)]}case"LookupTableSize":case"LookupTableSizeV2":{const r=w("tableHandle",n,e,t,s);return[s.getHashTableById(r.id).tensorSize()]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8212 * @license
8213 * Copyright 2018 Google LLC. All Rights Reserved.
8214 * Licensed under the Apache License, Version 2.0 (the "License");
8215 * you may not use this file except in compliance with the License.
8216 * You may obtain a copy of the License at
8217 *
8218 * http://www.apache.org/licenses/LICENSE-2.0
8219 *
8220 * Unless required by applicable law or agreed to in writing, software
8221 * distributed under the License is distributed on an "AS IS" BASIS,
8222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8223 * See the License for the specific language governing permissions and
8224 * limitations under the License.
8225 * =============================================================================
8226 */const aL=(n,e,t,s=$t)=>{switch(n.op){case"ResizeBilinear":{const r=w("images",n,e,t),a=w("size",n,e,t),o=w("alignCorners",n,e,t),i=w("halfPixelCenters",n,e,t);return[s.image.resizeBilinear(r,[a[0],a[1]],o,i)]}case"ResizeNearestNeighbor":{const r=w("images",n,e,t),a=w("size",n,e,t),o=w("alignCorners",n,e,t),i=w("halfPixelCenters",n,e,t);return[s.image.resizeNearestNeighbor(r,[a[0],a[1]],o,i)]}case"CropAndResize":{const r=w("image",n,e,t),a=w("boxes",n,e,t),o=w("boxInd",n,e,t),i=w("cropSize",n,e,t),l=w("method",n,e,t),u=w("extrapolationValue",n,e,t);return[s.image.cropAndResize(r,a,o,i,l,u)]}case"ImageProjectiveTransformV3":{const r=w("images",n,e,t),a=w("transforms",n,e,t),o=w("outputShape",n,e,t),i=w("fillValue",n,e,t),l=w("interpolation",n,e,t),u=w("fillMode",n,e,t);return[s.image.transform(r,a,l.toLowerCase(),u.toLowerCase(),i,o)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8227 * @license
8228 * Copyright 2018 Google LLC. All Rights Reserved.
8229 * Licensed under the Apache License, Version 2.0 (the "License");
8230 * you may not use this file except in compliance with the License.
8231 * You may obtain a copy of the License at
8232 *
8233 * http://www.apache.org/licenses/LICENSE-2.0
8234 *
8235 * Unless required by applicable law or agreed to in writing, software
8236 * distributed under the License is distributed on an "AS IS" BASIS,
8237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8238 * See the License for the specific language governing permissions and
8239 * limitations under the License.
8240 * =============================================================================
8241 */const oL=(n,e,t,s=$t)=>{switch(n.op){case"Equal":return[s.equal(w("a",n,e,t),w("b",n,e,t))];case"NotEqual":return[s.notEqual(w("a",n,e,t),w("b",n,e,t))];case"Greater":return[s.greater(w("a",n,e,t),w("b",n,e,t))];case"GreaterEqual":return[s.greaterEqual(w("a",n,e,t),w("b",n,e,t))];case"Less":return[s.less(w("a",n,e,t),w("b",n,e,t))];case"LessEqual":return[s.lessEqual(w("a",n,e,t),w("b",n,e,t))];case"LogicalAnd":return[s.logicalAnd(w("a",n,e,t),w("b",n,e,t))];case"LogicalNot":return[s.logicalNot(w("a",n,e,t))];case"LogicalOr":return[s.logicalOr(w("a",n,e,t),w("b",n,e,t))];case"Select":case"SelectV2":return[s.where(w("condition",n,e,t),w("a",n,e,t),w("b",n,e,t))];case"BitwiseAnd":return[s.bitwiseAnd(w("a",n,e,t),w("b",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8242 * @license
8243 * Copyright 2018 Google LLC. All Rights Reserved.
8244 * Licensed under the Apache License, Version 2.0 (the "License");
8245 * you may not use this file except in compliance with the License.
8246 * You may obtain a copy of the License at
8247 *
8248 * http://www.apache.org/licenses/LICENSE-2.0
8249 *
8250 * Unless required by applicable law or agreed to in writing, software
8251 * distributed under the License is distributed on an "AS IS" BASIS,
8252 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8253 * See the License for the specific language governing permissions and
8254 * limitations under the License.
8255 * =============================================================================
8256 */const iL=(n,e,t,s=$t)=>{switch(n.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[s.matMul(w("a",n,e,t),w("b",n,e,t),w("transposeA",n,e,t),w("transposeB",n,e,t))];case"Einsum":return[s.einsum(w("equation",n,e,t),...w("tensors",n,e,t))];case"Transpose":return[s.transpose(w("x",n,e,t),w("perm",n,e,t))];case"_FusedMatMul":const[r,a]=w("fusedOps",n,e,t),o=r==="biasadd",i=a==="prelu",l=w("numArgs",n,e,t),u=w("leakyreluAlpha",n,e,t);if(o){if(i&&l!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&l!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[c,h]=w("args",n,e,t);return[s.fused.matMul({a:w("a",n,e,t),b:w("b",n,e,t),transposeA:w("transposeA",n,e,t),transposeB:w("transposeB",n,e,t),bias:c,activation:a,preluActivationWeights:h,leakyreluAlpha:u})];case"MatrixBandPart":return[s.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`)}};/**
8257 * @license
8258 * Copyright 2018 Google LLC. All Rights Reserved.
8259 * Licensed under the Apache License, Version 2.0 (the "License");
8260 * you may not use this file except in compliance with the License.
8261 * You may obtain a copy of the License at
8262 *
8263 * http://www.apache.org/licenses/LICENSE-2.0
8264 *
8265 * Unless required by applicable law or agreed to in writing, software
8266 * distributed under the License is distributed on an "AS IS" BASIS,
8267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8268 * See the License for the specific language governing permissions and
8269 * limitations under the License.
8270 * =============================================================================
8271 */const lL=(n,e,t,s=$t)=>{switch(n.op){case"EuclideanNorm":return[s.euclideanNorm(w("x",n,e,t),w("axis",n,e,t),w("keepDims",n,e,t))];case"FusedBatchNorm":case"FusedBatchNormV2":return[s.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[s.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[s.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[s.softmax(w("x",n,e,t))];case"LogSoftmax":return[s.logSoftmax(w("x",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8272 * @license
8273 * Copyright 2022 Google LLC. All Rights Reserved.
8274 * Licensed under the Apache License, Version 2.0 (the "License");
8275 * you may not use this file except in compliance with the License.
8276 * You may obtain a copy of the License at
8277 *
8278 * http://www.apache.org/licenses/LICENSE-2.0
8279 *
8280 * Unless required by applicable law or agreed to in writing, software
8281 * distributed under the License is distributed on an "AS IS" BASIS,
8282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8283 * See the License for the specific language governing permissions and
8284 * limitations under the License.
8285 * =============================================================================
8286 */const uL=(n,e,t,s=$t)=>{switch(n.op){case"RaggedGather":{const{outputNestedSplits:r,outputDenseValues:a}=s.raggedGather(w("paramsNestedSplits",n,e,t),w("paramsDenseValues",n,e,t),w("indices",n,e,t),w("outputRaggedRank",n,e,t));return r.concat(a)}case"RaggedRange":{const{rtNestedSplits:r,rtDenseValues:a}=s.raggedRange(w("starts",n,e,t),w("limits",n,e,t),w("splits",n,e,t));return[r,a]}case"RaggedTensorToTensor":return[s.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`)}};/**
8287 * @license
8288 * Copyright 2018 Google LLC. All Rights Reserved.
8289 * Licensed under the Apache License, Version 2.0 (the "License");
8290 * you may not use this file except in compliance with the License.
8291 * You may obtain a copy of the License at
8292 *
8293 * http://www.apache.org/licenses/LICENSE-2.0
8294 *
8295 * Unless required by applicable law or agreed to in writing, software
8296 * distributed under the License is distributed on an "AS IS" BASIS,
8297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8298 * See the License for the specific language governing permissions and
8299 * limitations under the License.
8300 * =============================================================================
8301 */const cL=(n,e,t,s=$t)=>{switch(n.op){case"Max":{const i=w("axis",n,e,t),l=w("keepDims",n,e,t);return[s.max(w("x",n,e,t),i,l)]}case"Mean":{const i=w("axis",n,e,t),l=w("keepDims",n,e,t);return[s.mean(w("x",n,e,t),i,l)]}case"Min":{const i=w("axis",n,e,t),l=w("keepDims",n,e,t);return[s.min(w("x",n,e,t),i,l)]}case"Sum":{const i=w("axis",n,e,t),l=w("keepDims",n,e,t);return[s.sum(w("x",n,e,t),i,l)]}case"All":{const i=w("axis",n,e,t),l=w("keepDims",n,e,t);return[s.all(w("x",n,e,t),i,l)]}case"Any":{const i=w("axis",n,e,t),l=w("keepDims",n,e,t);return[s.any(w("x",n,e,t),i,l)]}case"ArgMax":{const i=w("axis",n,e,t);return[s.argMax(w("x",n,e,t),i)]}case"ArgMin":{const i=w("axis",n,e,t);return[s.argMin(w("x",n,e,t),i)]}case"Prod":{const i=w("axis",n,e,t),l=w("keepDims",n,e,t);return[s.prod(w("x",n,e,t),i,l)]}case"Cumprod":{const i=w("axis",n,e,t),l=w("exclusive",n,e,t),u=w("reverse",n,e,t);return[s.cumprod(w("x",n,e,t),i,l,u)]}case"Cumsum":{const i=w("axis",n,e,t),l=w("exclusive",n,e,t),u=w("reverse",n,e,t);return[s.cumsum(w("x",n,e,t),i,l,u)]}case"Bincount":const r=w("x",n,e,t),a=w("weights",n,e,t),o=w("size",n,e,t);return[s.bincount(r,a,o)];case"DenseBincount":{const i=w("x",n,e,t),l=w("weights",n,e,t),u=w("size",n,e,t),c=w("binaryOutput",n,e,t);return[s.denseBincount(i,l,u,c)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8302 * @license
8303 * Copyright 2018 Google LLC. All Rights Reserved.
8304 * Licensed under the Apache License, Version 2.0 (the "License");
8305 * you may not use this file except in compliance with the License.
8306 * You may obtain a copy of the License at
8307 *
8308 * http://www.apache.org/licenses/LICENSE-2.0
8309 *
8310 * Unless required by applicable law or agreed to in writing, software
8311 * distributed under the License is distributed on an "AS IS" BASIS,
8312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8313 * See the License for the specific language governing permissions and
8314 * limitations under the License.
8315 * =============================================================================
8316 */const hL=(n,e,t,s=$t)=>{switch(n.op){case"ConcatV2":case"Concat":{const r=w("n",n,e,t),a=w("axis",n,e,t);let o=w("tensors",n,e,t);return o=o.slice(0,r),[s.concat(o,a)]}case"Gather":{const r=w("x",n,e,t),a=w("indices",n,e,t);return[s.gather(r,s.cast(a,"int32"),0)]}case"GatherV2":{const r=w("axis",n,e,t),a=w("batchDims",n,e,t),o=w("x",n,e,t),i=w("indices",n,e,t);return[s.gather(o,s.cast(i,"int32"),r,a)]}case"Reverse":{const r=w("dims",n,e,t),a=[];for(let i=0;i<r.length;i++)r[i]&&a.push(i);const o=w("x",n,e,t);return[s.reverse(o,a)]}case"ReverseV2":{const r=w("axis",n,e,t),a=w("x",n,e,t);return[s.reverse(a,r)]}case"Slice":{const r=w("begin",n,e,t),a=w("size",n,e,t);return[s.slice(w("x",n,e,t),r,a)]}case"StridedSlice":{const r=w("begin",n,e,t),a=w("end",n,e,t),o=w("strides",n,e,t),i=w("beginMask",n,e,t),l=w("endMask",n,e,t),u=w("ellipsisMask",n,e,t),c=w("newAxisMask",n,e,t),h=w("shrinkAxisMask",n,e,t),d=w("x",n,e,t);return[s.stridedSlice(d,r,a,o,i,l,u,c,h)]}case"Pack":return L(()=>{const r=w("axis",n,e,t),a=w("tensors",n,e,t),o=a[0].shape,i=s.squeeze(a[0]).shape,l=a.map(u=>{const c=ke(u.shape,o);if(!c&&!ke(s.squeeze(u).shape,i))throw new Error("the input tensors shape does not match");return c?u:s.reshape(u,o)});return[s.stack(l,r)]});case"Unpack":{const r=w("axis",n,e,t),a=w("tensor",n,e,t);return s.unstack(a,r)}case"Tile":{const r=w("reps",n,e,t);return[s.tile(w("x",n,e,t),r)]}case"Split":case"SplitV":{const r=w("axis",n,e,t),a=w("numOrSizeSplits",n,e,t),o=w("x",n,e,t);return s.split(o,a,r)}case"ScatterNd":{const r=w("indices",n,e,t),a=w("values",n,e,t),o=w("shape",n,e,t);return[s.scatterND(r,a,o)]}case"GatherNd":{const r=w("x",n,e,t),a=w("indices",n,e,t);return[s.gatherND(r,a)]}case"SparseToDense":{const r=w("sparseIndices",n,e,t),a=w("outputShape",n,e,t),o=w("sparseValues",n,e,t),i=w("defaultValue",n,e,t);return[s.sparseToDense(r,o,a,o.dtype===i.dtype?i:s.cast(i,o.dtype))]}case"TensorScatterUpdate":{const r=w("indices",n,e,t),a=w("values",n,e,t),o=w("tensor",n,e,t);return[s.tensorScatterUpdate(o,r,a)]}default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8317 * @license
8318 * Copyright 2021 Google LLC. All Rights Reserved.
8319 * Licensed under the Apache License, Version 2.0 (the "License");
8320 * you may not use this file except in compliance with the License.
8321 * You may obtain a copy of the License at
8322 *
8323 * http://www.apache.org/licenses/LICENSE-2.0
8324 *
8325 * Unless required by applicable law or agreed to in writing, software
8326 * distributed under the License is distributed on an "AS IS" BASIS,
8327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8328 * See the License for the specific language governing permissions and
8329 * limitations under the License.
8330 * =============================================================================
8331 */const dL=(n,e,t,s=$t)=>{switch(n.op){case"SparseFillEmptyRows":{const{outputIndices:r,outputValues:a,emptyRowIndicator:o,reverseIndexMap:i}=s.sparse.sparseFillEmptyRows(w("indices",n,e,t),w("values",n,e,t),w("denseShape",n,e,t),w("defaultValue",n,e,t));return[r,a,o,i]}case"SparseReshape":{const{outputIndices:r,outputShape:a}=s.sparse.sparseReshape(w("inputIndices",n,e,t),w("inputShape",n,e,t),w("newShape",n,e,t));return[r,a]}case"SparseSegmentMean":return[s.sparse.sparseSegmentMean(w("data",n,e,t),w("indices",n,e,t),w("segmentIds",n,e,t))];case"SparseSegmentSum":return[s.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`)}};/**
8332 * @license
8333 * Copyright 2018 Google LLC. All Rights Reserved.
8334 * Licensed under the Apache License, Version 2.0 (the "License");
8335 * you may not use this file except in compliance with the License.
8336 * You may obtain a copy of the License at
8337 *
8338 * http://www.apache.org/licenses/LICENSE-2.0
8339 *
8340 * Unless required by applicable law or agreed to in writing, software
8341 * distributed under the License is distributed on an "AS IS" BASIS,
8342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8343 * See the License for the specific language governing permissions and
8344 * limitations under the License.
8345 * =============================================================================
8346 */const pL=(n,e,t,s=$t)=>{switch(n.op){case"FFT":return[s.fft(w("x",n,e,t))];case"IFFT":return[s.ifft(w("x",n,e,t))];case"RFFT":return[s.rfft(w("x",n,e,t))];case"IRFFT":return[s.irfft(w("x",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8347 * @license
8348 * Copyright 2021 Google LLC. All Rights Reserved.
8349 * Licensed under the Apache License, Version 2.0 (the "License");
8350 * you may not use this file except in compliance with the License.
8351 * You may obtain a copy of the License at
8352 *
8353 * http://www.apache.org/licenses/LICENSE-2.0
8354 *
8355 * Unless required by applicable law or agreed to in writing, software
8356 * distributed under the License is distributed on an "AS IS" BASIS,
8357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8358 * See the License for the specific language governing permissions and
8359 * limitations under the License.
8360 * =============================================================================
8361 */const fL=(n,e,t,s=$t)=>{switch(n.op){case"StaticRegexReplace":return[s.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:r,nGramsSplits:a}=s.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[r,a]}case"StringSplit":{const{indices:r,values:a,shape:o}=s.string.stringSplit(w("input",n,e,t),w("delimiter",n,e,t),w("skipEmpty",n,e,t));return[r,a,o]}case"StringToHashBucketFast":return[s.string.stringToHashBucketFast(w("input",n,e,t),w("numBuckets",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8362 * @license
8363 * Copyright 2018 Google LLC. All Rights Reserved.
8364 * Licensed under the Apache License, Version 2.0 (the "License");
8365 * you may not use this file except in compliance with the License.
8366 * You may obtain a copy of the License at
8367 *
8368 * http://www.apache.org/licenses/LICENSE-2.0
8369 *
8370 * Unless required by applicable law or agreed to in writing, software
8371 * distributed under the License is distributed on an "AS IS" BASIS,
8372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8373 * See the License for the specific language governing permissions and
8374 * limitations under the License.
8375 * =============================================================================
8376 */const mL=(n,e,t,s=$t)=>{switch(n.op){case"Cast":return[s.cast(w("x",n,e,t),w("dtype",n,e,t))];case"ExpandDims":{const r=w("axis",n,e,t);return[s.expandDims(w("x",n,e,t),r)]}case"Squeeze":{const r=w("axis",n,e,t);return[s.squeeze(w("x",n,e,t),r)]}case"Reshape":return[s.reshape(w("x",n,e,t),w("shape",n,e,t))];case"EnsureShape":return[s.ensureShape(w("x",n,e,t),w("shape",n,e,t))];case"MirrorPad":return[s.mirrorPad(w("x",n,e,t),w("padding",n,e,t),w("mode",n,e,t))];case"PadV2":case"Pad":return[s.pad(w("x",n,e,t),w("padding",n,e,t),w("constantValue",n,e,t))];
8376case"SpaceToBatchND":{const r=w("blockShape",n,e,t),a=w("paddings",n,e,t);return[s.spaceToBatchND(w("x",n,e,t),r,a)]}case"BatchToSpaceND":{const r=w("blockShape",n,e,t),a=w("crops",n,e,t);return[s.batchToSpaceND(w("x",n,e,t),r,a)]}case"DepthToSpace":{const r=w("blockSize",n,e,t),a=w("dataFormat",n,e,t).toUpperCase();return[s.depthToSpace(w("x",n,e,t),r,a)]}case"BroadcastTo":return[s.broadcastTo(w("x",n,e,t),w("shape",n,e,t))];case"BroadcastArgs":return[s.broadcastArgs(w("s0",n,e,t),w("s1",n,e,t))];default:throw TypeError(`Node type ${n.op} is not implemented`)}};/**
8377 * @license
8378 * Copyright 2018 Google LLC. All Rights Reserved.
8379 * Licensed under the Apache License, Version 2.0 (the "License");
8380 * you may not use this file except in compliance with the License.
8381 * You may obtain a copy of the License at
8382 *
8383 * http://www.apache.org/licenses/LICENSE-2.0
8384 *
8385 * Unless required by applicable law or agreed to in writing, software
8386 * distributed under the License is distributed on an "AS IS" BASIS,
8387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8388 * See the License for the specific language governing permissions and
8389 * limitations under the License.
8390 * =============================================================================
8391 */function hy(n,e,t,s,r=L){const a=((o,i,l)=>{switch(o.category){case"arithmetic":return r(()=>GF(o,i,l));case"basic_math":return r(()=>HF(o,i,l));case"control":return JF(o,i,l);case"convolution":return r(()=>ZF(o,i,l));case"creation":return r(()=>QF(o,i,l));case"dynamic":return eL(o,i,l);case"evaluation":return r(()=>tL(o,i,l));case"image":return r(()=>aL(o,i,l));case"graph":return r(()=>nL(o,i,l));case"logical":return r(()=>oL(o,i,l));case"matrices":return r(()=>iL(o,i,l));case"normalization":return r(()=>lL(o,i,l));case"ragged":return r(()=>uL(o,i,l));case"reduction":return r(()=>cL(o,i,l));case"slice_join":return r(()=>hL(o,i,l));case"sparse":return r(()=>dL(o,i,l));case"spectral":return r(()=>pL(o,i,l));case"string":return r(()=>fL(o,i,l));case"transformation":return r(()=>mL(o,i,l));case"hash_table":return rL(o,i,l,s);case"custom":const u=I0(o.op);if(u&&u.customExecutor)return u.customExecutor(new UF(o,i,l));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 bo(a)?a.then(o=>[].concat(o)):[].concat(a)}class dy{constructor(e={},t={},s={},r={},a){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=s,this.functionMap=r,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 s=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(s))}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)}}/**
8392 * @license
8393 * Copyright 2019 Google LLC. All Rights Reserved.
8394 * Licensed under the Apache License, Version 2.0 (the "License");
8395 * you may not use this file except in compliance with the License.
8396 * You may obtain a copy of the License at
8397 *
8398 * http://www.apache.org/licenses/LICENSE-2.0
8399 *
8400 * Unless required by applicable law or agreed to in writing, software
8401 * distributed under the License is distributed on an "AS IS" BASIS,
8402 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8403 * See the License for the specific language governing permissions and
8404 * limitations under the License.
8405 * =============================================================================
8406 */function py(n,e,t,s){const r=new Set,a=[];let o=null,i=null;const l=new Set,u=new Set(Object.keys(n).map(d=>Kt(d)[0]));s=s||[];const c=new Set(s.map(d=>Kt(d.name)[0])),h=[...e];for(;h.length>0;){const d=h.pop();if((Ks(d)||$L(d)||NL(d))&&o==null&&(o=d,i=o.children.map(p=>p.name).filter(p=>r.has(p))),r.add(d.name),t[d.name]==null&&!u.has(d.name)&&!c.has(d.name)){if(d.inputs.length===0){a.push(d.name);continue}d.inputs.forEach(p=>{l.has(p.name)||(l.add(p.name),h.push(p))})}}return{inputs:n,outputs:e,usedNodes:r,missingInputs:a,dynamicNode:o,syncInputs:i}}function gL(n,e){const{usedNodes:t,inputs:s}=e,r=Object.keys(s).map(m=>Kt(m)[0]).map(m=>n.nodes[m]),a=n.initNodes||[],o=m=>t.has(typeof m=="string"?m:m.name);function i(m){return[...new Map(m.map(y=>[y.name,y])).values()]}const l=i([...r,...n.weights,...a]).filter(o),u=i([...l,...Object.values(n.nodes)]).filter(o),c=new Map(u.map(m=>[m.name,m])),h={};for(const m of u){h[m.name]=h[m.name]||0;for(const y of m.children)o(y)||(h[y.name]=Number.POSITIVE_INFINITY),h[y.name]=(h[y.name]||0)+1}const d=Object.entries(h).filter(([,m])=>m===0).map(([m])=>m),p=[...d];for(;d.length>0;){const m=d.pop(),y=c.get(m);for(const x of y.children.filter(o))--h[x.name]===0&&(p.push(x.name),d.push(x.name))}const f=p.map(m=>c.get(m)),g=yL(f,l);return xL(g,l),g}function yL(n,e){const t=new Map(n.map(o=>[o.name,o])),s=e.map(o=>o.name),r=new Set(s);for(;s.length>0;){const o=s.pop(),i=t.get(o);for(const l of i.children)!t.has(l.name)||r.has(l.name)||(r.add(l.name),s.push(l.name))}return n.filter(o=>r.has(o.name))}class El extends Error{constructor(e){super(`NodesExecutionOrderError: ${e}`)}}function xL(n,e){const t=new Map(n.map((i,l)=>[i.name,l])),s=new Set(e.map(i=>i.name)),r=i=>s.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 l of i.children.filter(o)){if(!t.has(l.name))throw new El(`Child ${l.name} of node ${i.name} is unreachable.`);if(t.get(i.name)>t.get(l.name))throw new El(`Node ${i.name} is scheduled to run after its child ${l.name}.`)}if(!r(i))for(const l of i.inputs){if(!t.has(l.name))throw new El(`Input ${l.name} of node ${i.name} is unreachable.`);if(t.get(l.name)>t.get(i.name))throw new El(`Node ${i.name} is scheduled to run before its input ${l.name}.`)}}}function bL(n){const e=new Map(n.map((i,l)=>[i.name,l])),t=Number.MAX_SAFE_INTEGER,s=n.map((i,l)=>Ks(i)?t:l),r=i=>{const l=s[e.get(i.name)];return l??-1},a=n.map((i,l)=>i.children.map(r).reduce((u,c)=>Math.max(u,c),s[l])),o=new Map;for(let i=0;i<n.length;++i){const l=a[i];if(l===t)continue;const u=n[i],c=n[l];o.has(c.name)||o.set(c.name,[]),o.get(c.name).push(u)}return o}const wL=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),vL=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),CL=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function Ks(n){return wL.has(n.op)}function $L(n){return vL.has(n.op)}function NL(n){return CL.has(n.op)}/**
8407 * @license
8408 * Copyright 2018 Google LLC. All Rights Reserved.
8409 * Licensed under the Apache License, Version 2.0 (the "License");
8410 * you may not use this file except in compliance with the License.
8411 * You may obtain a copy of the License at
8412 *
8413 * http://www.apache.org/licenses/LICENSE-2.0
8414 *
8415 * Unless required by applicable law or agreed to in writing, software
8416 * distributed under the License is distributed on an "AS IS" BASIS,
8417 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8418 * See the License for the specific language governing permissions and
8419 * limitations under the License.
8420 * =============================================================================
8421 */class lu{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(s=>e[s].map(r=>r.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)=>
8421(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(s=>{this._functionExecutorMap[s]=new lu(e.functions[s],this)})}getCompilationKey(e,t){const s=e.map(a=>a.name).sort(),r=t.map(a=>a.name).sort();return s.join(this.SEPARATOR)+"--"+r.join(this.SEPARATOR)}compile(e,t){const s=py(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:o}=s;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(r.length>0){const u=t.map(h=>h.name),c=Object.keys(e);throw new Error(`Cannot compute the outputs [${u}] from the provided inputs [${c}]. Missing the following inputs: [${r}]`)}const i=gL(this.graph,s),l=bL(i);return{orderedNodes:i,nodeLiveUntilMap:l}}cloneAndKeepTensor(e){if(e==null)return null;const t=e.clone();return ct(t),t}cloneTensorList(e){return e?e.map(s=>this.cloneAndKeepTensor(s)):null}cloneTensorMap(e){return Object.fromEntries(Object.entries(e).map(([t,s])=>[t,this.cloneTensorList(s)]))}execute(e,t){this.disposeIntermediateTensors(),e=this.mapInputs(e);const s=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=s.map(d=>this.graph.nodes[Kt(d)[0]]),a=t.map(d=>Kt(d)[0]),o=new Set(a);let i=a.map(d=>this.graph.nodes[d]);i.length===0&&(i=this._outputs);const l=this.getCompilationKey(r,i);let u=this.compiledMap.get(l);u==null&&(u=this.compile(e,i),this.compiledMap.set(l,u));try{this.keepIntermediateTensors=W().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(d){this.keepIntermediateTensors=!1,console.warn(d.message)}const c={},h={};return L(()=>{const d=new dy(this.weightMap,c,h,this.functionExecutorMap,this.parseNodeNameCache),p=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(e).forEach(y=>{const[x,v]=Kt(y,d),b=[];b[v]=e[y],p[x]=b,this.keepIntermediateTensors&&(this.clonedTensorsMap[x]=this.cloneTensorList(b))});const f=this.getFrozenTensorIds(p),{orderedNodes:g,nodeLiveUntilMap:m}=u;for(const y of g){if(p[y.name])continue;const x=hy(y,p,d,this._resourceManager);if(bo(x))throw new Error(`The execution of the op '${y.op}' returned a promise. Please use model.executeAsync() instead.`);p[y.name]=x,this.keepIntermediateTensors&&(this.clonedTensorsMap[y.name]=this.cloneTensorList(x)),this.checkTensorForDisposalWithNodeLiveUntilInfo(y,p,d,f,o,m.get(y.name))}return this.parent==null&&d.dispose(f),t.map(y=>gt(y,p,d))})}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map(s=>e[s]).map(s=>s.map(r=>r.id)));return new Set(t)}checkTensorForDisposal(e,t,s,r,a,o,i){if(!(Ks(t)||o.has(e))){for(const l of s[e])l!=null&&(i[l.id]=(i[l.id]||0)+t.children.length);for(const l of t.inputs){if(Ks(l))continue;const u=oy(l.name,s,r);if(u!=null)for(const c of u){if(!c||c.kept||a.has(c.id))continue;const h=i[c.id];h===1?(c.dispose(),delete i[c.id]):h!=null&&i[c.id]--}}}}checkTensorForDisposalWithNodeLiveUntilInfo(e,t,s,r,a,o){function i(l){return Ks(l)||a.has(l.name)}if(!(Ks(e)||o==null))for(const l of o){if(i(l))continue;const u=oy(l.name,t,s);for(const c of u)!c||c.kept||r.has(c.id)||c.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,s=!1,r={},a={}){this.disposeIntermediateTensors(),s||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepIntermediateTensors=W().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(d){this.keepIntermediateTensors=!1,console.warn(d.message)}const o=new dy(this.weightMap,r,a,this.functionExecutorMap,this.parseNodeNameCache);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));const i=await this.executeWithControlFlow(e,o,t,s),l=t.map(d=>gt(d,i,o)),u=l.map(d=>d.id),c=Object.keys(e).map(d=>e[d].id),h=new Set([...u,...c,...this.weightIds]);
8421return Object.values(i).forEach(d=>{d.forEach(p=>{p&&!p.isDisposed&&!h.has(p.id)&&p.dispose()})}),this.parent==null&&o.dispose(h),l}async executeFunctionAsync(e,t,s){const r=e.reduce((a,o,i)=>(a[this.inputs[i].name]=o,a),{});return this._executeAsync(r,this.outputNodes,!0,t,s)}async executeWithControlFlow(e,t,s,r){const a=Object.keys(e),o=a.map(b=>this.graph.nodes[Kt(b)[0]]),i=s.map(b=>Kt(b)[0]),l=new Set(i);let u=i.map(b=>this.graph.nodes[b]);u.length===0&&(u=this._outputs);const{usedNodes:c,missingInputs:h,dynamicNode:d,syncInputs:p}=py(e,u,this.weightMap,this._initNodes),f=[...o,...this.graph.weights,...this._initNodes||[]].map(b=>({node:b,contexts:t.currentContext})),g=Object.assign({},this.weightMap);Object.keys(e).forEach(b=>{const[C,$]=Kt(b),S=[];S[$]=e[b],g[C]=S});const m={},y=this.getFrozenTensorIds(g),x={};for(;f.length>0;){const b=this.processStack(o,f,t,g,x,y,l,m,c);await Promise.all(b)}d==null&&!r&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const v=u.filter(b=>!Ks(b)&&!gt(b.name,g,t)).map(b=>b.name);if(v.length>0){let b="";throw d!=null&&(b=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${v}] from the provided inputs [${a}]. Consider providing the following inputs: [${h}]. ${b}`)}return g}processStack(e,t,s,r,a,o,i,l,u){const c=[];for(;t.length>0;){const h=t.pop();s.currentContext=h.contexts;let d="";if(h.node.op==="Enter"&&w("isConstant",h.node,r,s)&&([d]=Qn(h.node.name,s)),r[h.node.name]==null){const p=hy(h.node,r,s,this._resourceManager);d||([d]=Qn(h.node.name,s));const f=s.currentContext;bo(p)?c.push(p.then(g=>(r[d]=g,this.keepIntermediateTensors&&(this.clonedTensorsMap[d]=this.cloneTensorList(g)),s.currentContext=f,this.checkTensorForDisposal(d,h.node,r,s,o,i,l),this.processChildNodes(h.node,t,s,r,a,u),g))):(r[d]=p,this.keepIntermediateTensors&&(this.clonedTensorsMap[d]=this.cloneTensorList(p)),this.checkTensorForDisposal(d,h.node,r,s,o,i,l),this.processChildNodes(h.node,t,s,r,a,u))}else this.processChildNodes(h.node,t,s,r,a,u)}return c}processChildNodes(e,t,s,r,a,o){e.children.forEach(i=>{const[l]=Qn(i.name,s);a[l]||!o.has(i.name)||(i.op==="Merge"?i.inputNames.some(u=>!!gt(u,r,s))&&(a[l]=!0,t.push({contexts:s.currentContext,node:i})):i.inputNames.every(u=>!!gt(u,r,s))&&(a[l]=!0,t.push({contexts:s.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 s=e[t],[r]=Kt(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const o=a.attrParams.shape.value,i=o.length===s.shape.length&&s.shape.every((l,u)=>o[u]===-1||o[u]===l);I(i,()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${o}], but was [${s.shape}]`)}a.attrParams.dtype&&a.attrParams.dtype.value&&I(s.dtype===a.attrParams.dtype.value,()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${s.dtype}`)})}mapInputs(e){var t,s;const r={};for(const a in e){const o=(s=(t=this._signature)===null||t===void 0?void 0:t.inputs)===null||s===void 0?void 0:s[a];o!=null?r[o.name]=e[a]:r[a]=e[a]}return r}checkInputs(e){const t=Object.keys(e).filter(s=>{const[r]=Kt(s);return this.graph.nodes[r]==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 s,r;const a=(r=(s=this._signature)===null||s===void 0?void 0:s.outputs)===null||r===void 0?void 0:r[t];return a!=null?a.name:t},{})}checkOutputs(e){e.forEach(t=>{const[s]=Kt(t);if(!this.graph.nodes[s])throw new Error(`The output '${t}' is not found in the graph`)})}}class IL{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]}}/**
8422 * @license
8423 * Copyright 2018 Google LLC. All Rights Reserved.
8424 * Licensed under the Apache License, Version 2.0 (the "License");
8425 * you may not use this file except in compliance with the License.
8426 * You may obtain a copy of the License at
8427 *
8428 * http://www.apache.org/licenses/LICENSE-2.0
8429 *
8430 * Unless required by applicable law or agreed to in writing, software
8431 * distributed under the License is distributed on an "AS IS" BASIS,
8432 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8433 * See the License for the specific language governing permissions and
8434 * limitations under the License.
8435 * =============================================================================
8436 */const SL="?tfjs-format=file",kL="model.json";class Hm{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={},s=pf){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=s,t==null&&(this.loadOptions={}),this.resourceManager=new IL}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 bo(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 Jy(e.getWeightStream(),e.weightSpecs);return this.loadWithWeightMap(e,t)}loadWithWeightMap(e,t){this.artifacts=e;const s=this.artifacts.modelTopology;let r=this.artifacts.signature;if(this.artifacts.userDefinedMetadata!=null){const a=this.artifacts.userDefinedMetadata;a.signature!=null&&(r=a.signature),a.structuredOutputKeys!=null&&(this.structuredOutputKeys=a.structuredOutputKeys)}if(this.signature=r,this.version=`${s.versions.producer}.${s.versions.minConsumer}`,this.executor=new lu(iy.Instance.transformGraph(s,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(t),this.executor.resourceManager=this.resourceManager,e.modelInitializer!=null&&e.modelInitializer.node!=null){const a=iy.Instance.transformGraph(e.modelInitializer);this.initializer=new lu(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 s=this.io.getSaveHandlers(e);if(s.length===0)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(s.length>1)throw new Error(`Found more than one (${s.length}) save handlers for URL '${e}'`);e=s[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 lt?[e]:e,s={};return t.forEach((r,a)=>s[this.structuredOutputKeys[a]]=r),s}return e}predict(e,t){const s=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(s)}async predictAsync(e,t){const s=await this.executeAsync(e,this.outputNodes);return this.addStructuredOutputNames(s)}normalizeInputs(e){var t;if(!(e instanceof lt)&&!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 s=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+s!==this.inputNodes.length)throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-s} non-resource placeholders, while there are ${e.length} input tensors provided.`);let r=0;return this.inputNodes.reduce((a,o)=>{var i,l,u;const c=(u=(l=(i=this.signature)===null||i===void 0?void 0:i.inputs)===null||l===void 0?void 0:l[o])===null||u===void 0?void 0:u.resourceId;return c!=null?a[o]=this.resourceIdToCapturedInput[c]:a[o]=e[r++],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,s=Object.keys(t);for(let r=0;r<s.length;r++){const a=s[r],o=t[a];this.resourceIdToCapturedInput[o.resourceId]=e[r]}}}execute(e,t){this.resourceIdToCapturedInput==null&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const s=this.executor.execute(e,t);return s.length>1?s:s[0]}async executeAsync(e,t){this.resourceIdToCapturedInput==null&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const s=await this.executor.executeAsync(e,t);return s.length>1?s:s[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce((t,s)=>(t[s]=[e[s]],t),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&Re(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function TL(n,e={},t=pf){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=RL(n));const s=new Hm(n,e,t);return await s.load(),s}function EL(n){if(n==null)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model");let e;if(n instanceof Array){const[s,r]=n;if(!s)throw new Error("modelJSON must be the first element of the array");if(!r||!(r instanceof ArrayBuffer))throw new Error("An ArrayBuffer of weights must be the second element of the array");if(!("modelTopology"in s))throw new Error("Model JSON is missing 'modelTopology'");
8436if(!("weightsManifest"in s))throw new Error("Model JSON is missing 'weightsManifest'");const a=jl(s.weightsManifest),o=Qy(s,a,r);e=Jl(o)}else if("load"in n)e=n;else if("modelTopology"in n&&"weightSpecs"in n&&"weightData"in n)e=Jl(n);else throw new Error("Unknown model format");const t=new Hm(e);return t.load(),t}function RL(n){return n.endsWith("/")||(n=n+"/"),`${n}${kL}${SL}`}/** @license See the LICENSE file. */const T0="4.22.0";/**
8437 * @license
8438 * Copyright 2018 Google LLC. All Rights Reserved.
8439 * Licensed under the Apache License, Version 2.0 (the "License");
8440 * you may not use this file except in compliance with the License.
8441 * You may obtain a copy of the License at
8442 *
8443 * http://www.apache.org/licenses/LICENSE-2.0
8444 *
8445 * Unless required by applicable law or agreed to in writing, software
8446 * distributed under the License is distributed on an "AS IS" BASIS,
8447 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8448 * See the License for the specific language governing permissions and
8449 * limitations under the License.
8450 *
8451 * =============================================================================
8452 */function DL(n,e){return uu(n,e)}function uu(n,e,t=new Map,s=new Set){if(n==null)return null;if(typeof Blob=="function"&&n instanceof Blob)return n.slice();if(s.has(n))throw new Error("Circular references are not supported.");if(t.has(n))return t.get(n);const r=e(n);if(r.recurse&&r.value!==null)throw new Error("A deep map function may not return both a value and recurse=true.");if(r.recurse)if(Mr(n)){const a=Array.isArray(n)?[]:{};s.add(n);for(const o in n){const i=n[o],l=uu(i,e,t,s);a[o]=l}return s.delete(n),n.__proto__&&(a.__proto__=n.__proto__),a}else throw new Error(`Can't recurse into non-iterable type: ${n}`);else return t.set(n,r.value),r.value}function AL(n,e=R0){return E0(n,e)}function E0(n,e,t=new Set){const s=n[0];if(t.has(s))throw new Error("Circular references are not supported.");const r=e(n);if(r.recurse&&r.value!==null)throw new Error("A deep zip function may not return both a value and recurse=true.");if(r.recurse)if(Mr(s)){const a=Array.isArray(s)?[]:{};t.add(s);for(const o in s){const i=n.map(u=>u[o]),l=E0(i,e,t);a[o]=l}return t.delete(s),a}else throw new Error(`Can't recurse into non-iterable type: ${s}`);else return r.value}function R0(n){return n===null?null:Mr(n[0])?{value:null,recurse:!0}:{value:n,recurse:!1}}async function D0(n,e){const t=new Map;uu(n,e,t);for(const r of Array.from(t.keys())){const a=t.get(r);if(bo(a)){const o=await a;t.set(r,o)}}return uu(n,e,t)}function Mr(n){let e=!1;if(W().get("IS_BROWSER"))e=n instanceof TextDecoder;else{const{StringDecoder:t}=require("string_decoder");e=n instanceof t}return n!=null&&!ArrayBuffer.isView(n)&&(Array.isArray(n)||typeof n=="object"&&!(n instanceof lt)&&!(n instanceof Promise)&&!e)}function OL(n){return n==null||_L(n)||Array.isArray(n)||typeof n=="object"&&n instanceof lt||Gs(n)}function _L(n){return n===null||typeof n!="object"&&typeof n!="function"}/**
8453 * @license
8454 * Copyright 2018 Google LLC. All Rights Reserved.
8455 * Licensed under the Apache License, Version 2.0 (the "License");
8456 * you may not use this file except in compliance with the License.
8457 * You may obtain a copy of the License at
8458 *
8459 * http://www.apache.org/licenses/LICENSE-2.0
8460 *
8461 * Unless required by applicable law or agreed to in writing, software
8462 * distributed under the License is distributed on an "AS IS" BASIS,
8463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8464 * See the License for the specific language governing permissions and
8465 * limitations under the License.
8466 *
8467 * =============================================================================
8468 */function FL(n){return DL(n,LL)}function LL(n){return n instanceof lt?{value:n.clone(),recurse:!1}:Mr(n)?{value:null,recurse:!0}:{value:n,recurse:!1}}/**
8469 * @license
8470 * Copyright 2018 Google LLC. All Rights Reserved.
8471 * Licensed under the Apache License, Version 2.0 (the "License");
8472 * you may not use this file except in compliance with the License.
8473 * You may obtain a copy of the License at
8474 *
8475 * http://www.apache.org/licenses/LICENSE-2.0
8476 *
8477 * Unless required by applicable law or agreed to in writing, softw
8477are
8478 * distributed under the License is distributed on an "AS IS" BASIS,
8479 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8480 * See the License for the specific language governing permissions and
8481 * limitations under the License.
8482 *
8483 * =============================================================================
8484 */class A0{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,e==null)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}length(){let e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}isFull(){return this.length()===this.capacity}isEmpty(){return this.length()===0}push(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}pushAll(e){for(const t of e)this.push(t)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const e=this.get(this.end);return this.set(this.end,void 0),e}unshift(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e}shuffleExcise(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.wrap(this.begin+e),s=this.get(t);return this.set(t,this.pop()),s}}/**
8485 * @license
8486 * Copyright 2018 Google LLC. All Rights Reserved.
8487 * Licensed under the Apache License, Version 2.0 (the "License");
8488 * you may not use this file except in compliance with the License.
8489 * You may obtain a copy of the License at
8490 *
8491 * http://www.apache.org/licenses/LICENSE-2.0
8492 *
8493 * Unless required by applicable law or agreed to in writing, software
8494 * distributed under the License is distributed on an "AS IS" BASIS,
8495 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8496 * See the License for the specific language governing permissions and
8497 * limitations under the License.
8498 *
8499 * =============================================================================
8500 */class Oh extends A0{constructor(){super(Oh.INITIAL_CAPACITY)}isFull(){return!1}push(e){super.isFull()&&this.expand(),super.push(e)}unshift(e){super.isFull()&&this.expand(),super.unshift(e)}expand(){const e=this.capacity*2,t=new Array(e),s=this.length();for(let r=0;r<s;r++)t[r]=this.get(this.wrap(this.begin+r));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=s}}Oh.INITIAL_CAPACITY=32;/**
8501 * @license
8502 * Copyright 2018 Google LLC. All Rights Reserved.
8503 * Licensed under the Apache License, Version 2.0 (the "License");
8504 * you may not use this file except in compliance with the License.
8505 * You may obtain a copy of the License at
8506 *
8507 * http://www.apache.org/licenses/LICENSE-2.0
8508 *
8509 * Unless required by applicable law or agreed to in writing, software
8510 * distributed under the License is distributed on an "AS IS" BASIS,
8511 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8512 * See the License for the specific language governing permissions and
8513 * limitations under the License.
8514 *
8515 * =============================================================================
8516 */function O0(n){return new VL(n)}function jm(n){return new BL(n)}function PL(n,e){return new _0(n,e)}function zL(n,e=ys.FAIL){return new XL(n,e)}class pt{async toArray(){const e=[];let t=await this.next();for(;!t.done;)e.push(t.value),t=await this.next();return e}async toArrayForTest(){const e=this.prefetch(100),t=[];let s=await e.next();for(;!s.done;)t.push(s.value),s=await e.next();return t}async resolveFully(){let e=await this.next();for(;!e.done;)e=await this.next()}async resolveWhile(e){let t=await this.next(),s=e(t.value);for(;!t.done&&s;)t=await this.next(),s=e(t.value)}handleErrors(e){return new qL(this,e)}filter(e){return new HL(this,e)}map(e){return new jL(this,e)}mapAsync(e){return new fy(this,e)}serialMapAsync(e){return new fy(this,e).serial()}flatmap(e){return new KL(this,e)}async forEachAsync(e){return this.map(e).resolveFully()}async serialForEach(e){return this.serialMapAsync(e).resolveWhile(t=>t===!0)}rowMajorBatch(e,t=!0){return new GL(this,e,t)}columnMajorBatch(e,t=!0,s=R0){return this.rowMajorBatch(e,t).map(a=>AL(a,s))}concatenate(e,t){return new _0(O0([this,e]),t)}take(e){return e<0||e==null?this:new UL(this,e)}skip(e){return e<0||e==null?this:new WL(this,e)}prefetch(e){return new F0(this,e)}shuffle(e,t){return new YL(this,e,t)}serial(){return new ML(this)}}class VL extends pt{constructor(e){super(),this.items=e,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const e=this.items[this.trav];return this.trav++,{value:FL(e),done:!1}}}class BL extends pt{constructor(e){super(),this.nextFn=e}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(e){throw e.message=`Error thrown while iterating through a dataset: ${e.message}`,e}}}class ML extends pt{constructor(e){super(),this.upstream=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){return this.upstream.next()}}class WL extends pt{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){const e=await this.upstream.next();if(e.done)return e;Re(e.value)}return this.upstream.next()}}class UL extends pt{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class GL extends pt{constructor(e,t,s=!0){super(),this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=s,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){const e=[];for(;e.length<this.batchSize;){const t=await this.upstream.next();if(t.done)return this.enableSmallLastBatch&&e.length>0?{value:e,done:!1}:{value:null,done:!0};e.push(t.value)}return{value:e,done:!1}}}class HL extends pt{constructor(e,t){super(),this.upstream=e,this.predicate=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;){const e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;Re(e.value)}}}class jL extends pt{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Map`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=Rr(e.value),s=this.transform(e.value),r=Rr(s);for(const a of t)qd(a,r)||a.dispose();return{value:s,done:!1}}}class qL extends pt{constructor(e,t){super(),this.upstream=e,this.handler=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(e){if(!this.handler(e))return{value:null,done:!0}}}}class fy extends pt{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=Rr(e.value),s=await this.transform(e.value),r=Rr(s);for(const a of t)qd(a,r)||a.dispose();return{value:s,done:!1}}}class qm extends pt{constructor(){super(),this.outputQueue=new Oh,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;this.outputQueue.length()===0;)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class KL extends qm{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const e=await this.upstream.next();if(e.done)return!1;const t=Rr(e.value),s=this.transform(e.value),r=Rr(s);this.outputQueue.pushAll(s);for(const a of t)qd(a,r)||a.dispose();return!0}}class _0 extends pt{constructor(e,t){super(),this.baseErrorHandler=t,this.lastRead=null,this.iterator=null,this.moreIterators=e}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(e){if(await e,this.iterator==null){const s=await this.moreIterators.next();if(s.done)return{value:null,done:!0};this.iterator=s.value,this.baseErrorHandler!=null&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}}var ys;
8516(function(n){n[n.FAIL=0]="FAIL",n[n.SHORTEST=1]="SHORTEST",n[n.LONGEST=2]="LONGEST"})(ys||(ys={}));class XL extends pt{constructor(e,t=ys.FAIL){super(),this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,s=0;function r(o){return o instanceof pt?{value:o.next().then(l=>(t++,l.done&&s++,l.value)),recurse:!1}:{value:null,recurse:!0}}const a=await D0(this.iterators,r);if(t===s)return{value:null,done:!0};if(s>0)switch(this.mismatchMode){case ys.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case ys.SHORTEST:return{value:null,done:!0};case ys.LONGEST:}return this.count++,{value:a,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class F0 extends pt{constructor(e,t){super(),this.upstream=e,this.bufferSize=t,this.buffer=new A0(t)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const e=this.upstream.next();this.buffer.push(e)}}next(){return this.refill(),this.buffer.shift()}}class YL extends F0{constructor(e,t,s){super(e,t),this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=za.alea(s||nn().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}randomInt(e){return Math.floor(this.random()*e)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const e=this.chooseIndex(),t=await this.buffer.shuffleExcise(e);if(t.done)this.upstreamExhausted=!0;else return this.refill(),t}return{value:null,done:!0}}}/**
8517 * @license
8518 * Copyright 2018 Google LLC. All Rights Reserved.
8519 * Licensed under the Apache License, Version 2.0 (the "License");
8520 * you may not use this file except in compliance with the License.
8521 * You may obtain a copy of the License at
8522 *
8523 * http://www.apache.org/licenses/LICENSE-2.0
8524 *
8525 * Unless required by applicable law or agreed to in writing, software
8526 * distributed under the License is distributed on an "AS IS" BASIS,
8527 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8528 * See the License for the specific language governing permissions and
8529 * limitations under the License.
8530 *
8531 * =============================================================================
8532 */class Ha{constructor(){this.size=null}batch(e,t=!0){const s=this;I(e>0,()=>`batchSize needs to be positive, but it is
8533      ${e}`);let r;return this.size===1/0||this.size==null?r=this.size:t?r=Math.ceil(this.size/e):r=Math.floor(this.size/e),qt(async()=>(await s.iterator()).columnMajorBatch(e,t,QL),r)}concatenate(e){const t=this;let s;return this.size===1/0||e.size===1/0?s=1/0:this.size!=null&&e.size!=null?s=this.size+e.size:s=null,qt(async()=>(await t.iterator()).concatenate(await e.iterator()),s)}filter(e){const t=this;let s;return this.size===1/0?s=1/0:s=null,qt(async()=>(await t.iterator()).filter(r=>L(()=>e(r))),s)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){const t=this;return qt(async()=>(await t.iterator()).map(s=>L(()=>e(s))),this.size)}mapAsync(e){const t=this;return qt(async()=>(await t.iterator()).mapAsync(e),this.size)}prefetch(e){if(e==null)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const t=this;return qt(async()=>(await t.iterator()).prefetch(e),this.size)}repeat(e){const t=this;let s;return this.size!=null&&e>0?s=this.size*e:e===0?s=0:this.size!=null&&(e===void 0||e<0)?s=1/0:s=null,qt(async()=>{const r=jm(async()=>({value:await t.iterator(),done:!1}));return PL(r.take(e))},s)}skip(e){const t=this;let s;return this.size!=null&&e>=0&&this.size>=e?s=this.size-e:this.size!=null&&(this.size<e||e===void 0||e<0)?s=0:s=null,qt(async()=>(await t.iterator()).skip(e),s)}shuffle(e,t,s=!0){if(e==null||e<0)throw this.size==null?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified.  If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const r=this,a=za.alea(t||nn().toString());return qt(async()=>{let o=a.int32();return s&&(o+=a.int32()),(await r.iterator()).shuffle(e,o.toString())},this.size)}take(e){const t=this;let s;return this.size!=null&&this.size>e?s=e:this.size!=null&&this.size<=e?s=this.size:s=null,qt(async()=>(await t.iterator()).take(e),s)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}Ha.MAX_BUFFER_SIZE=1e4;function qt(n,e=null){return new class extends Ha{constructor(){super(...arguments),this.size=e}async iterator(){return n()}}}function JL(n){return qt(async()=>O0(n),n.length)}function ZL(n){if(!Mr(n))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(n))for(let t=0;t<n.length;t++)e=e==null?n[t].size:Math.min(e,n[t].size);else if(n instanceof Object)for(const t in n)e=e==null?n[t].size:Math.min(e,n[t].size);return qt(async()=>{const t=await D0(n,s=>
8533{if(s instanceof Ha)return{value:s.iterator(),recurse:!1};if(Mr(s))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")});return zL(t,ys.SHORTEST)},e)}function QL(n){if(n===null)return null;const e=n[0];return OL(e)?{value:eP(n),recurse:!1}:{value:null,recurse:!0}}function eP(n){if(n.length===0)throw new Error("Can't make a batch of zero elements.");return n[0]instanceof lt?Ot(n):En(n)}/**
8534 * @license
8535 * Copyright 2018 Google LLC. All Rights Reserved.
8536 * Licensed under the Apache License, Version 2.0 (the "License");
8537 * you may not use this file except in compliance with the License.
8538 * You may obtain a copy of the License at
8539 *
8540 * http://www.apache.org/licenses/LICENSE-2.0
8541 *
8542 * Unless required by applicable law or agreed to in writing, software
8543 * distributed under the License is distributed on an "AS IS" BASIS,
8544 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8545 * See the License for the specific language governing permissions and
8546 * limitations under the License.
8547 *
8548 * =============================================================================
8549 */class L0 extends Ha{constructor(e){super(),this.input=e}async iterator(){return(await this.input.iterator()).decodeUTF8().split(`
8550`).map(r=>(r.endsWith("\r")&&(r=r.slice(0,-1)),r))}}/**
8551 * @license
8552 * Copyright 2018 Google LLC. All Rights Reserved.
8553 * Licensed under the Apache License, Version 2.0 (the "License");
8554 * you may not use this file except in compliance with the License.
8555 * You may obtain a copy of the License at
8556 *
8557 * http://www.apache.org/licenses/LICENSE-2.0
8558 *
8559 * Unless required by applicable law or agreed to in writing, software
8560 * distributed under the License is distributed on an "AS IS" BASIS,
8561 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8562 * See the License for the specific language governing permissions and
8563 * limitations under the License.
8564 *
8565 * =============================================================================
8566 */const Rl='"',oo=Symbol("out"),my=Symbol("field"),Dl=Symbol("quote"),Xh=Symbol("quoteafterquote"),gy=Symbol("quoteinquote");class P0 extends Ha{async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const e=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&e&&I(e.length===this.fullColumnNames.length,()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+")."),this.fullColumnNames||(this.fullColumnNames=e);const t=this.fullColumnNames.reduce((r,a)=>(r[a]=r[a]+1||1,r),{}),s=Object.keys(t).filter(r=>t[r]>1);if(I(s.length===0,()=>"Duplicate column names found: "+s.toString()),this.columnConfigs){for(const r of Object.keys(this.columnConfigs))if(this.fullColumnNames.indexOf(r)===-1)throw new Error('The key "'+r+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await(await this.base.iterator()).next();if(t.done)throw new Error("No data was found for CSV parsing.");const s=t.value;return this.parseRow(s,!1)}else return null}constructor(e,t){super(),this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new L0(e),t||(t={}),this.hasHeader=t.hasHeader!==!1,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(I(t.delimiter==null,()=>"Delimiter should not be provided when delimWhitespace is true."),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map(t=>this.makeDataElement(t))}makeDataElement(e){const t=this.parseRow(e),s={},r={};for(let a=0;a<this.fullColumnNames.length;a++){const o=this.fullColumnNames[a],i=this.columnConfigs?this.columnConfigs[o]:null;if(!(this.configuredColumnsOnly&&!i)){const l=t[a];let u=null;if(l==="")if(i&&i.default!==void 0)u=i.default;else{if(i&&(i.required||i.isLabel))throw new Error(`Required column ${o} is empty in this line: ${e}`);u=void 0}else{const c=Number(l);if(isNaN(c))i&&i.dtype==="bool"?u=this.getBoolean(l):u=l;else if(!i||!i.dtype)u=c;else switch(i.dtype){case"float32":u=c;break;case"int32":u=Math.floor(c);break;case"bool":u=this.getBoolean(l);break;default:u=c}}i&&i.isLabel?r[o]=u:s[o]=u}}return Object.keys(r).length===0?s:{xs:s,ys:r}}getBoolean(e){return e==="1"||e.toLowerCase()==="true"?1:0}parseRow(e,t=!0){const s=[];let r=0;const a=e.length;let o=oo;for(let i=0;i<a;i++)switch(o){case oo:switch(e.charAt(i)){case Rl:r=i+1,o=Dl;break;case this.delimiter:if(r=i+1,this.delimiter===" "&&this.delimWhitespace)break;s.push(""),o=oo;break;default:o=my,r=i;break}break;case my:switch(e.charAt(i)){case this.delimiter:s.push(e.substring(r,i)),o=oo,r=i+1;break}break;case Dl:switch(e.charAt(i)){case Rl:o=Xh;break}break;case Xh:switch(e.charAt(i)){case this.delimiter:s.push(e.substring(r,i-1)),o=oo,r=i+1;break;case Rl:o=Dl;break;default:o=gy;break}break;case gy:switch(e.charAt(i)){case Rl:o=Dl;break}break}if(o===Xh?s.push(e.substring(r,a-1)):s.push(e.substring(r)),t&&s.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${s}`);return s}}/**
8567 * @license
8568 * Copyright 2019 Google LLC. All Rights Reserved.
8569 * Licensed under the Apache License, Version 2.0 (the "License");
8570 * you may not use this file except in compliance with the License.
8571 * You may obtain a copy of the License at
8572 *
8573 * http://www.apache.org/licenses/LICENSE-2.0
8574 *
8575 * Unless required by applicable law or agreed to in writing, software
8576 * distributed under the License is distributed on an "AS IS" BASIS,
8577 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8578 * See the License for the specific language governing permissions and
8579 * limitations under the License.
8580 *
8581 * =============================================================================
8582 */class Km extends pt{constructor(e){super(),this.microphoneConfig=e,this.isClosed=!1,this.fftSize=e.fftSize||1024;const t=Math.log2(this.fftSize);if(this.fftSize<0||t<4||t>14||!Number.isInteger(t))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=e.numFramesPerSpectrogram||43,this.sampleRateHz=e.sampleRateHz,this.columnTruncateLength=e.columnTruncateLength||this.fftSize,this.audioTrackConstraints=e.audioTrackConstraints,this.smoothingTimeConstant=e.smoothingTimeConstant||0,this.includeSpectrogram=e.includeSpectrogram!==!1,this.includeWaveform=e.includeWaveform===!0,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(!W().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const t=new Km(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints==null?!0:this.audioTrackConstraints,video:!1})}catch(s){throw new Error(`Error thrown while initializing video stream: ${s.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,!this.sampleRateHz)this.sampleRateHz=this.audioContext.sampleRate;else if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`);const t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=this.fftSize*2,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let e,t;const s=await this.getAudioData();if(this.includeSpectrogram){const r=this.flattenQueue(s.freqDataQueue);e=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const r=this.flattenQueue(s.timeDataQueue);t=this.getTensorFromAudioDataArray(r,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:e,waveform:t},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const e=[],t=[];let s=0;return new Promise(r=>{const a=setInterval(()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&r({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++s===this.numFrames&&(clearInterval(a),r({freqDataQueue:e,timeDataQueue:t}))},this.fftSize/this.sampleRateHz*1e3)})}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),this.stream!=null&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){const t=e[0].length,s=new Float32Array(e.length*t);return e.forEach((r,a)=>s.set(r,a*t)),s}getTensorFromAudioDataArray(e,t){const s=new Float32Array(H(t));return s.set(e,s.length-e.length),En(s,t)}}/**
8583 * @license
8584 * Copyright 2018 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 * =============================================================================
8598 */class Xm extends pt{constructor(e,t){if(super(),this.webcamVideoElement=e,this.webcamConfig=t,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=xt([0],"int32"),this.webcamConfig.centerCrop){const s=this.webcamConfig.resizeWidth*1/this.webcamVideoElement.width,r=this.webcamConfig.resizeHeight*1/this.webcamVideoElement.height,a=(1-s)/2,o=(1-r)/2,i=a+s,l=r+o;this.cropBox=bs([o,a,l,i],[1,4])}else this.cropBox=bs([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(!W().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=t.resizeWidth,e.height=t.resizeHeight}const s=new Xm(e,t);return await s.start(),s}async start(){this.webcamConfig.facingMode&&I(this.webcamConfig.facingMode==="user"||this.webcamConfig.facingMode==="environment",()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`);try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(e){throw e.message=`Error thrown while initializing video stream: ${e.message}`,e}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(e){this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise(e=>{this.webcamVideoElement.onloadedmetadata=()=>{e()}})}async next(){if(this.isClosed)return{value:null,done:!0};let e;try{e=iw(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(this.resize)try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{e.dispose()}else return{value:e,done:!1}}needToResize(){return!!(this.webcamConfig.resizeWidth&&this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight))}cropAndResizeFrame(e){return L(()=>{const t=mt(ee(e,"float32"),0);let s;s=yn.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const r=s.shape;return D(s,r.slice(1))})}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach(t=>t.stop());try{this.webcamVideoElement.srcObject=null}catch(t){this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}/**
8599 * @license
8600 * Copyright 2018 Google LLC. All Rights Reserved.
8601 * Licensed under the Apache License, Version 2.0 (the "License");
8602 * you may not use this file except in compliance with the License.
8603 * You may obtain a copy of the License at
8604 *
8605 * http://www.apache.org/licenses/LICENSE-2.0
8606 *
8607 * Unless required by applicable law or agreed to in writing, software
8608 * distributed under the License is distributed on an "AS IS" BASIS,
8609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8610 * See the License for the specific language governing permissions and
8611 * limitations under the License.
8612 *
8613 * =============================================================================
8614 */class z0{}/**
8615 * @license
8616 * Copyright 2018 Google LLC. All Rights Reserved.
8617 * Licensed under the Apache License, Version 2.0 (the "License");
8618 * you may not use this file except in compliance with the License.
8619 * You may obtain a copy of the License at
8620 *
8621 * http://www.apache.org/licenses/LICENSE-2.0
8622 *
8623 * Unless required by applicable law or agreed to in writing, software
8624 * distributed under the License is distributed on an "AS IS" BASIS,
8625 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8626 * See the License for the specific language governing permissions and
8627 * limitations under the License.
8628 *
8629 * =============================================================================
8630 */class V0 extends pt{split(e){return new tP(this,e)}}class tP extends V0{constructor(e,t){super(),this.upstream=e,this.impl=new nP(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class nP extends qm{constructor(e,t){super(),this.upstream=e,this.separator=t,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const e=await this.upstream.next();if(e.done)return this.carryover===""?!1:(this.outputQueue.push(this.carryover),this.carryover="",!0);const t=e.value.split(this.separator);t[0]=this.carryover+t[0];for(const s of t.slice(0,-1))this.outputQueue.push(s);return this.carryover=t[t.length-1],!0}}/**
8631 * @license
8632 * Copyright 2018 Google LLC. All Rights Reserved.
8633 * Licensed under the Apache License, Version 2.0 (the "License");
8634 * you may not use this file except in compliance with the License.
8635 * You may obtain a copy of the License at
8636 *
8637 * http://www.apache.org/licenses/LICENSE-2.0
8638 *
8639 * Unless required by applicable law or agreed to in writing, software
8640 * distributed under the License is distributed on an "AS IS" BASIS,
8641 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8642 * See the License for the specific language governing permissions and
8643 * limitations under the License.
8644 *
8645 * =============================================================================
8646 */class sP extends pt{decodeUTF8(){return new rP(this)}}class rP extends V0{constructor(e){super(),this.upstream=e,this.impl=new aP(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class aP extends qm{constructor(e){if(super(),this.upstream=e,W().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=require("string_decoder");this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const e=await this.upstream.next();let t;if(e.done)return!1;t=e.value;let s;return W().get("IS_BROWSER")?s=this.decoder.decode(t,{stream:!0}):s=this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(s),!0}}/**
8647 * @license
8648 * Copyright 2018 Google LLC. All Rights Reserved.
8649 * Licensed under the Apache License, Version 2.0 (the "License");
8650 * you may not use this file except in compliance with the License.
8651 * You may obtain a copy of the License at
8652 *
8653 * http://www.apache.org/licenses/LICENSE-2.0
8654 *
8655 * Unless required by applicable law or agreed to in writing, software
8656 * distributed under the License is distributed on an "AS IS" BASIS,
8657 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8658 * See the License for the specific language governing permissions and
8659 * limitations under the License.
8660 *
8661 * =============================================================================
8662 */class B0 extends sP{constructor(e,t={}){super(),this.file=e,this.options=t,I(e instanceof Uint8Array||(W().get("IS_BROWSER")?e instanceof File||e instanceof Blob:!1),()=>"FileChunkIterator only supports File, Blob and Uint8Array right now."),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1024*1024}summary(){return`FileChunks ${this.file}`}async next(){return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?{value:null,done:!0}:{value:await new Promise((t,s)=>{const r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,r)));else{const a=new FileReader;a.onload=i=>{let l=a.result;if(l instanceof ArrayBuffer&&(l=new Uint8Array(l)),!(l instanceof Uint8Array))return s(new TypeError("FileReader returned unknown type."));t(l)},a.onabort=i=>s(new Error("Aborted")),a.onerror=i=>s(new Error(i.type));const o=this.file.slice(this.offset,r);a.readAsArrayBuffer(o)}this.offset=r}),done:!1}}}/**
8663 * @license
8664 * Copyright 2018 Google LLC. All Rights Reserved.
8665 * Licensed under the Apache License, Version 2.0 (the "License");
8666 * you may not use this file except in compliance with the License.
8667 * You may obtain a copy of the License at
8668 *
8669 * http://www.apache.org/licenses/LICENSE-2.0
8670 *
8671 * Unless required by applicable law or agreed to in writing, software
8672 * distributed under the License is distributed on an "AS IS" BASIS,
8673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8674 * See the License for the specific language governing permissions and
8675 * limitations under the License.
8676 *
8677 * =============================================================================
8678 */async function oP(n,e={},t){let s,r;typeof n=="string"?s=n:(s=n.url,r=iP(n));const a=await zC(s,r);if(a.ok){const o=new Uint8Array(await a.arrayBuffer());return new B0(o,e)}else throw new Error(a.statusText)}const iP=n=>({method:n.method,headers:n.headers,body:n.body,mode:n.mode,credentials:n.credentials,cache:n.cache,redirect:n.redirect,referrer:n.referrer,integrity:n.integrity});/**
8679 * @license
8680 * Copyright 2018 Google LLC. All Rights Reserved.
8681 * Licensed under the Apache License, Version 2.0 (the "License");
8682 * you may not use this file except in compliance with the License.
8683 * You may obtain a copy of the License at
8684 *
8685 * http://www.apache.org/licenses/LICENSE-2.0
8686 *
8687 * Unless required by applicable law or agreed to in writing, software
8688 * distributed under the License is distributed on an "AS IS" BASIS,
8689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8690 * See the License for the specific language governing permissions and
8691 * limitations under the License.
8692 *
8693 * =============================================================================
8694 */function M0(n){return typeof n=="string"&&n.slice(0,7)==="file://"}/**
8695 * @license
8696 * Copyright 2018 Google LLC. All Rights Reserved.
8697 * Licensed under the Apache License, Version 2.0 (the "License");
8698 * you may not use this file except in compliance with the License.
8699 * You may obtain a copy of the License at
8700 *
8701 * http://www.apache.org/licenses/LICENSE-2.0
8702 *
8703 * Unless required by applicable law or agreed to in writing, software
8704 * distributed under the License is distributed on an "AS IS" BASIS,
8705 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8706 * See the License for the specific language governing permissions and
8707 * limitations under the License.
8708 *
8709 * =============================================================================
8710 */class W0 extends z0{constructor(e,t={}){super(),this.input=e,this.options=t}async iterator(){if(M0(this.input)&&W().get("IS_NODE")){const e=require("fs");this.input=e.readFileSync(this.input.slice(7))}return new B0(this.input,this.options)}}/**
8711 * @license
8712 * Copyright 2018 Google LLC. All Rights Reserved.
8713 * Licensed under the Apache License, Version 2.0 (the "License");
8714 * you may not use this file except in compliance with the License.
8715 * You may obtain a copy of the License at
8716 *
8717 * http://www.apache.org/licenses/LICENSE-2.0
8718 *
8719 * Unless required by applicable law or agreed to in writing, software
8720 * distributed under the License is distributed on an "AS IS" BASIS,
8721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8722 * See the License for the specific language governing permissions and
8723 * limitations under the License.
8724 *
8725 * =============================================================================
8726 */class U0 extends z0{constructor(e,t={}){super(),this.url=e,this.fileOptions=t}async iterator(){return M0(this.url)?new W0(this.url,this.fileOptions).iterator():oP(this.url,this.fileOptions)}}/**
8727 * @license
8728 * Copyright 2018 Google LLC. All Rights Reserved.
8729 * Licensed under the Apache License, Version 2.0 (the "License");
8730 * you may not use this file except in compliance with the License.
8731 * You may obtain a copy of the License at
8732 *
8733 * http://www.apache.org/licenses/LICENSE-2.0
8734 *
8735 * Unless required by applicable law or agreed to in writing, software
8736 * distributed under the License is distributed on an "AS IS" BASIS,
8737 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8738 * See the License for the specific language governing permissions and
8739 * limitations under the License.
8740 *
8741 * =============================================================================
8742 */function lP(n,e={}){return new P0(new U0(n),e)}function uP(n){const e=jm(n);return qt(async()=>e)}function cP(n){return qt(async()=>{const e=await n();return jm(()=>e.next())})}async function hP(n,e){return Xm.create(n,e)}async function dP(n){return Km.create(n)}/** @license See the LICENSE file. */const G0="4.22.0";/**
8743 * @license
8744 * Copyright 2018 Google LLC. All Rights Reserved.
8745 * Licensed under the Apache License, Version 2.0 (the "License");
8746 * you may not use this file except in compliance with the License.
8747 * You may obtain a copy of the License at
8748 *
8749 * http://www.apache.org/licenses/LICENSE-2.0
8750 *
8751 * Unless required by applicable law or agreed to in writing, software
8752 * distributed under the License is distributed on an "AS IS" BASIS,
8753 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8754 * See the License for the specific language governing permissions and
8755 * limitations under the License.
8756 * =============================================================================
8757 */const pP=Object.freeze(Object.defineProperty({__proto__:null,CSVDataset:P0,Dataset:Ha,FileDataSource:W0,TextLineDataset:L0,URLDataSource:U0,array:JL,csv:lP,func:uP,generator:cP,microphone:dP,version_data:G0,webcam:hP,zip:ZL},Symbol.toStringTag,{value:"Module"}));/**
8758 * @license
8759 * Copyright 2021 Google LLC. All Rights Reserved.
8760 * Licensed under the Apache License, Version 2.0 (the "License");
8761 * you may not use this file except in compliance with the License.
8762 * You may obtain a copy of the License at
8763 *
8764 * http://www.apache.org/licenses/LICENSE-2.0
8765 *
8766 * Unless required by applicable law or agreed to in writing, software
8767 * distributed under the License is distributed on an "AS IS" BASIS,
8768 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8769 * See the License for the specific language governing permissions and
8770 * limitations under the License.
8771 * =============================================================================
8772 */const fP=lh;class ml extends Kd{nextDataId(){return ml.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new Xd(this,Sn())}write(e,t,s){this.firstUse&&(this.firstUse=!1,W().get("IS_NODE")&&Ui(`
8773============================
8774Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. 
8775============================`));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:s,refCount:1}),r}makeTensorInfo(e,t,s){let r;if(t==="string"&&s!=null&&s.length>0&&kr(s[0])){const a=s.map(o=>Od(o));r=this.write(a,e,t)}else r=this.write(s,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){const t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){const t=this.data.get(e);t.refCount--}}move(e,t,s,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:s}=this.data.get(e);if(t==="complex64"){const r=this.readSync(s.real.dataId),a=this.readSync(s.imag.dataId);return Ns(r,a)}return VC(this.data.get(e).values,t)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const s=t.map(r=>Gi(r));return $e(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return $e(e.shape,e.dtype,t)}makeOutput(e,t,s){return Sn().makeTensorFromTensorInfo(this.makeTensorInfo(t,s,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:s}=this.data.get(e);s!=null&&(this.disposeData(s.real.dataId,!0),this.disposeData(s.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=nn();return e(),{kernelMs:nn()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){ue([e],"where");const t=this.readSync(e.dataId);return fP(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}ml.nextDataId=0;/**
8776 * @license
8777 * Copyright 2020 Google LLC. All Rights Reserved.
8778 * Licensed under the Apache License, Version 2.0 (the License);
8779 * you may not use this file except in compliance with the License.
8780 * You may obtain a copy of the License at
8781 *
8782 * http://www.apache.org/licenses/LICENSE-2.0
8783 *
8784 * Unless required by applicable law or agreed to in writing, softw
8784are
8785 * distributed under the License is distributed on an AS IS BASIS,
8786 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8787 * See the License for the specific language governing permissions and
8788 * limitations under the License.
8789 * =============================================================================
8790 */function H0(n){const e=new Float32Array(n.length);for(let t=0;t<n.length;++t)e[t]=Math.abs(n[t]);return e}const mP=n=>{const{x:e}=n.inputs,t=n.backend;ue(e,"abs");let s=new Float32Array(H(e.shape));const r=t.data.get(e.dataId).values;return s=H0(r),t.makeOutput(s,e.shape,e.dtype)},gP={kernelName:pc,backendName:"cpu",kernelFunc:mP};/**
8791 * @license
8792 * Copyright 2020 Google LLC. All Rights Reserved.
8793 * Licensed under the Apache License, Version 2.0 (the "License");
8794 * you may not use this file except in compliance with the License.
8795 * You may obtain a copy of the License at
8796 *
8797 * http://www.apache.org/licenses/LICENSE-2.0
8798 *
8799 * Unless required by applicable law or agreed to in writing, software
8800 * distributed under the License is distributed on an "AS IS" BASIS,
8801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8802 * See the License for the specific language governing permissions and
8803 * limitations under the License.
8804 * =============================================================================
8805 */function Qe(n){return(e,t,s,r,a)=>{const o=xe(e,t),i=o.length,l=fe(o),u=H(o),c=wt(a,u),h=e.length,d=t.length,p=fe(e),f=fe(t),g=wo(e,o),m=wo(t,o);if(g.length+m.length===0)for(let y=0;y<c.length;++y)c[y]=n(s[y%s.length],r[y%r.length]);else for(let y=0;y<c.length;++y){const x=Ra(y,i,l),v=x.slice(-h);g.forEach(S=>v[S]=0);const b=Wn(v,h,p),C=x.slice(-d);m.forEach(S=>C[S]=0);const $=Wn(C,d,f);c[y]=n(s[b],r[$])}return[c,o]}}/**
8806 * @license
8807 * Copyright 2020 Google LLC. All Rights Reserved.
8808 * Licensed under the Apache License, Version 2.0 (the "License");
8809 * you may not use this file except in compliance with the License.
8810 * You may obtain a copy of the License at
8811 *
8812 * http://www.apache.org/licenses/LICENSE-2.0
8813 *
8814 * Unless required by applicable law or agreed to in writing, software
8815 * distributed under the License is distributed on an "AS IS" BASIS,
8816 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8817 * See the License for the specific language governing permissions and
8818 * limitations under the License.
8819 * =============================================================================
8820 */function Xt(n){const{inputs:e,backend:t}=n,{real:s,imag:r}=e,a=t.data.get(s.dataId).values,o=t.data.get(r.dataId).values,i=t.makeTensorInfo(s.shape,"complex64"),l=t.data.get(i.dataId);return l.complexTensorInfos={real:t.makeTensorInfo(s.shape,"float32",a),imag:t.makeTensorInfo(r.shape,"float32",o)},i}const yP={kernelName:Yd,backendName:"cpu",kernelFunc:Xt};/**
8821 * @license
8822 * Copyright 2020 Google LLC. All Rights Reserved.
8823 * Licensed under the Apache License, Version 2.0 (the "License");
8824 * you may not use this file except in compliance with the License.
8825 * You may obtain a copy of the License at
8826 *
8827 * http://www.apache.org/licenses/LICENSE-2.0
8828 *
8829 * Unless required by applicable law or agreed to in writing, software
8830 * distributed under the License is distributed on an "AS IS" BASIS,
8831 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8832 * See the License for the specific language governing permissions and
8833 * limitations under the License.
8834 * =============================================================================
8835 */function cu(n,e,t="float32"){if(t==="complex64"){const r=cu(n,e,"float32"),a=cu(n,e,"float32");return Xt({inputs:{real:r,imag:a},backend:n})}const s=hn(H(e),t);return n.makeTensorInfo(e,t,s)}/**
8836 * @license
8837 * Copyright 2020 Google LLC. All Rights Reserved.
8838 * Licensed under the Apache License, Version 2.0 (the "License");
8839 * you may not use this file except in compliance with the License.
8840 * You may obtain a copy of the License at
8841 *
8842 * http://www.apache.org/licenses/LICENSE-2.0
8843 *
8844 * Unless required by applicable law or agreed to in writing, softw
8844are
8845 * distributed under the License is distributed on an "AS IS" BASIS,
8846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8847 * See the License for the specific language governing permissions and
8848 * limitations under the License.
8849 * =============================================================================
8850 */function jn(n){const{inputs:e,backend:t}=n,{x:s}=e;return t.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const xP={kernelName:wc,backendName:"cpu",kernelFunc:jn};/**
8851 * @license
8852 * Copyright 2020 Google LLC. All Rights Reserved.
8853 * Licensed under the Apache License, Version 2.0 (the "License");
8854 * you may not use this file except in compliance with the License.
8855 * You may obtain a copy of the License at
8856 *
8857 * http://www.apache.org/licenses/LICENSE-2.0
8858 *
8859 * Unless required by applicable law or agreed to in writing, software
8860 * distributed under the License is distributed on an "AS IS" BASIS,
8861 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8862 * See the License for the specific language governing permissions and
8863 * limitations under the License.
8864 * =============================================================================
8865 */function ur(n){const{inputs:e,backend:t}=n,{input:s}=e,r=t.data.get(s.dataId).complexTensorInfos.real,a=t.data.get(r.dataId).values;return t.makeTensorInfo(r.shape,r.dtype,a)}const bP={kernelName:zu,backendName:"cpu",kernelFunc:ur};/**
8866 * @license
8867 * Copyright 2020 Google LLC. All Rights Reserved.
8868 * Licensed under the Apache License, Version 2.0 (the "License");
8869 * you may not use this file except in compliance with the License.
8870 * You may obtain a copy of the License at
8871 *
8872 * http://www.apache.org/licenses/LICENSE-2.0
8873 *
8874 * Unless required by applicable law or agreed to in writing, software
8875 * distributed under the License is distributed on an "AS IS" BASIS,
8876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8877 * See the License for the specific language governing permissions and
8878 * limitations under the License.
8879 * =============================================================================
8880 */function j0(n,e,t,s){if(s==="int32"){const r=Int32Array.from(n);return[e,"int32",r]}if(s==="bool"){const r=_c([0],t),[a,o]=Qe((i,l)=>i!==l?1:0)(e,[],n,r,"bool");return[o,"bool",a]}throw new Error(`Error in Cast: failed to cast ${t} to ${s}`)}function Ds(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{dtype:a}=s;if(a==="complex64"){if(r.dtype==="complex64")return jn({inputs:{x:r},backend:t});const c=cu(t,r.shape,r.dtype),h=Ds({inputs:{x:r},backend:t,attrs:{dtype:"float32"}}),d=Xt({inputs:{real:h,imag:c},backend:t});return t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(h),d}if(r.dtype==="complex64"){const c=ur({inputs:{input:r},backend:t}),h=Ds({inputs:{x:c},backend:t,attrs:{dtype:a}});return t.disposeIntermediateTensorInfo(c),h}if(!gx(r.dtype,a)){const c=jn({inputs:{x:r},backend:t});return{dataId:c.dataId,shape:c.shape,dtype:a}}const o=t.data.get(r.dataId).values,[i,l,u]=j0(o,r.shape,r.dtype,a);return t.makeTensorInfo(i,l,u)}const wP={kernelName:gc,backendName:"cpu",kernelFunc:Ds};/**
8881 * @license
8882 * Copyright 2020 Google LLC. All Rights Reserved.
8883 * Licensed under the Apache License, Version 2.0 (the "License");
8884 * you may not use this file except in compliance with the License.
8885 * You may obtain a copy of the License at
8886 *
8887 * http://www.apache.org/licenses/LICENSE-2.0
8888 *
8889 * Unless required by applicable law or agreed to in writing, software
8890 * distributed under the License is distributed on an "AS IS" BASIS,
8891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8892 * See the License for the specific language governing permissions and
8893 * limitations under the License.
8894 * =============================================================================
8895 */function ut(n,e,t,s){return t==null?({inputs:r,backend:a})=>{const{a:o,b:i}=r,l=a;ue([o,i],n);const u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,h=o.dtype==="string"?Dr(u):u,d=o.dtype==="string"?Dr(c):c,p=s||o.dtype,[f,g]=e(o.shape,i.shape,h,d,p);return l.makeTensorInfo(g,p,f)}
vendor: 4,418 bytes, lines 8895-8943
8895:({inputs:r,backend:a})=>{const{a:o,b:i}=r,l=a;if(o.dtype==="complex64"||i.dtype==="complex64"){const u=Ds({inputs:{x:o},backend:l,attrs:{dtype:"complex64"}}),c=l.data.get(u.dataId),h=c.complexTensorInfos.real,d=c.complexTensorInfos.imag,p=l.data.get(h.dataId).values,f=l.data.get(d.dataId).values,g=Ds({inputs:{x:i},backend:l,attrs:{dtype:"complex64"}}),m=l.data.get(g.dataId),y=m.complexTensorInfos.real,x=m.complexTensorInfos.imag,v=l.data.get(y.dataId).values,b=l.data.get(x.dataId).values,[C,$,S]=t(o.shape,i.shape,p,f,v,b),k=l.makeTensorInfo(S,"float32",C),T=l.makeTensorInfo(S,"float32",$),E=Xt({inputs:{real:k,imag:T},backend:l});return l.disposeIntermediateTensorInfo(u),l.disposeIntermediateTensorInfo(g),l.disposeIntermediateTensorInfo(k),l.disposeIntermediateTensorInfo(T),E}else{const u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,h=s||o.dtype,[d,p]=e(o.shape,i.shape,u,c,h);return l.makeTensorInfo(p,h,d)}}}function Ym(n){return(e,t,s,r,a,o)=>{const i=xe(e,t),l=H(i),u=i.length,c=fe(i),h=wt("float32",l),d=wt("float32",l),p=wo(e,i),f=wo(t,i),g=Ns(s,r),m=Ns(a,o),y=e.length,x=fe(e),v=t.length,b=fe(t);if(p.length+f.length===0)for(let C=0;C<h.length;C++){const $=C%g.length,S=C%m.length,k=n(g[$*2],g[$*2+1],m[S*2],m[S*2+1]);h[C]=k.real,d[C]=k.imag}else for(let C=0;C<h.length;C++){const $=Ra(C,u,c),S=$.slice(-y);p.forEach(z=>S[z]=0);const k=Wn(S,y,x),T=$.slice(-v);f.forEach(z=>T[z]=0);const E=Wn(T,v,b),_=n(g[k*2],g[k*2+1],m[E*2],m[E*2+1]);h[C]=_.real,d[C]=_.imag}return[h,d,i]}}/**
8896 * @license
8897 * Copyright 2020 Google LLC. All Rights Reserved.
8898 * Licensed under the Apache License, Version 2.0 (the "License");
8899 * you may not use this file except in compliance with the License.
8900 * You may obtain a copy of the License at
8901 *
8902 * http://www.apache.org/licenses/LICENSE-2.0
8903 *
8904 * Unless required by applicable law or agreed to in writing, software
8905 * distributed under the License is distributed on an "AS IS" BASIS,
8906 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8907 * See the License for the specific language governing permissions and
8908 * limitations under the License.
8909 * =============================================================================
8910 */const q0=Qe((n,e)=>n+e),vP=Ym((n,e,t,s)=>({real:n+t,imag:e+s})),Wr=ut(ki,q0,vP),CP={kernelName:ki,backendName:"cpu",kernelFunc:Wr};/**
8911 * @license
8912 * Copyright 2020 Google LLC. All Rights Reserved.
8913 * Licensed under the Apache License, Version 2.0 (the "License");
8914 * you may not use this file except in compliance with the License.
8915 * You may obtain a copy of the License at
8916 *
8917 * http://www.apache.org/licenses/LICENSE-2.0
8918 *
8919 * Unless required by applicable law or agreed to in writing, software
8920 * distributed under the License is distributed on an "AS IS" BASIS,
8921 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8922 * See the License for the specific language governing permissions and
8923 * limitations under the License.
8924 * =============================================================================
8925 */function Jm(n,e,t,s,r){const a=H(s),o=hn(r,t);for(let i=0;i<n.length;i++){const l=n[i];if(l<0)throw new Error("Input x must be non-negative!");l>=r||(a>0?o[l]+=e[i]:o[l]+=1)}return o}function K0(n,e,t,s=!1){const r=n.shape[0],a=n.shape[1],o=$e([r,t],e.dtype);for(let i=0;i<r;i++)for(let l=0;l<a;l++){const u=n.get(i,l);if(u<0)throw new Error("Input x must be non-negative!");u>=t||(s?o.set(1,i,u):e.size>0?o.set(o.get(i,u)+e.get(i,l),i,u):o.set(o.get(i,u)+1,i,u))}return o}/**
8926 * @license
8927 * Copyright 2023 Google LLC.
8928 * Licensed under the Apache License, Version 2.0 (the "License");
8929 * you may not use this file except in compliance with the License.
8930 * You may obtain a copy of the License at
8931 *
8932 * http://www.apache.org/licenses/LICENSE-2.0
8933 *
8934 * Unless required by applicable law or agreed to in writing, software
8935 * distributed under the License is distributed on an "AS IS" BASIS,
8936 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8937 * See the License for the specific language governing permissions and
8938 * limitations under the License.
8939 * =============================================================================
8940 */const X0=Qe((n,e)=>n&e),$P=ut(Bo,X0),NP={kernelName:Bo,backendName:"cpu",kernelFunc:$P};/**
8941 * @license
8942 * Copyright 2020 Google LLC. All Rights Reserved.
8943 * Licensed under the Apache License, Version 2.0 (the "License");
8944 * you may not use this file except in compliance with the License.
8945 * You may obtain a copy of the License at
8946 *
8947 * http://www.apache.org/licenses/LICENSE-2.0
8948 *
8949 * Unless required by applicable law or agreed to in writing, software
8950 * distributed under the License is distributed on an "AS IS" BASIS,
8951 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8952 * See the License for the specific language governing permissions and
8953 * limitations under the License.
8954 * =============================================================================
8955 */function Xn(n){return(e,t,s)=>{const r=Dt(t,e.length);for(let a=0;a<e.length;++a)r[a]=n(e[a],s);return r}}/**
8956 * @license
8957 * Copyright 2020 Google LLC. All Rights Reserved.
8958 * Licensed under the Apache License, Version 2.0 (the "License");
8959 * you may not use this file except in compliance with the License.
8960 * You may obtain a copy of the License at
8961 *
8962 * http://www.apache.org/licenses/LICENSE-2.0
8963 *
8964 * Unless required by applicable law or agreed to in writing, software
8965 * distributed under the License is distributed on an "AS IS" BASIS,
8966 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8967 * See the License for the specific language governing permissions and
8968 * limitations under the License.
8969 * =============================================================================
8970 */function Oe(n,e,t){const s=Xn(e);return Vs(n,s,t)}function Vs(n,e,t){return({inputs:s,attrs:r,backend:a})=>{const{x:o}=s;ue(o,n);const i=a,l=i.data.get(o.dataId).values;let u;if(o.dtype==="string"){if(!Array.isArray(l))throw new Error("String tensor's value was not an instance of Array");u=Dr(l)}else u=l;const c=t||o.dtype,h=e(u,c,r);return i.makeTensorInfo(o.shape,c,h)}}/**
8971 * @license
8972 * Copyright 2020 Google LLC. All Rights Reserved.
8973 * Licensed under the Apache License, Version 2.0 (the License);
8974 * you may not use this file except in compliance with the License.
8975 * You may obtain a copy of the License at
8976 *
8977 * http://www.apache.org/licenses/LICENSE-2.0
8978 *
8979 * Unless required by applicable law or agreed to in writing, software
8980 * distributed under the License is distributed on an AS IS BASIS,
8981 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8982 * See the License for the specific language governing permissions and
8983 * limitations under the License.
8984 * =============================================================================
8985 */const Y0=Xn(n=>Math.ceil(n)),IP=Vs(ea,Y0),SP={kernelName:ea,backendName:"cpu",kernelFunc:IP};/**
8986 * @license
8987 * Copyright 2020 Google LLC. All Rights Reserved.
8988 * Licensed under the Apache License, Version 2.0 (the "License");
8989 * you may not use this file except in compliance with the License.
8990 * You may obtain a copy of the License at
8991 *
8992 * http://www.apache.org/licenses/LICENSE-2.0
8993 *
8994 * Unless required by applicable law or agreed to in writing, software
8995 * distributed under the License is distributed on an "AS IS" BASIS,
8996 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8997 * See the License for the specific language governing permissions and
8998 * limitations under the License.
8999 * =============================================================================
9000 */const J0=Qe((n,e)=>n===e?1:0),Z0=ut(qo,J0,null,"bool"),kP={kernelName:qo,backendName:"cpu",kernelFunc:Z0};/**
9001 * @license
9002 * Copyright 2020 Google LLC. All Rights Reserved.
9003 * Licensed under the Apache License, Version 2.0 (the License);
9004 * you may not use this file except in compliance with the License.
9005 * You may obtain a copy of the License at
9006 *
9007 * http://www.apache.org/licenses/LICENSE-2.0
9008 *
9009 * Unless required by applicable law or agreed to in writing, software
9010 * distributed under the License is distributed on an AS IS BASIS,
9011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9012 * See the License for the specific language governing permissions and
9013 * limitations under the License.
9014 * =============================================================================
9015 */const Q0=Xn(n=>Math.exp(n)),e1=Vs(oa,Q0,"float32"),TP={kernelName:oa,backendName:"cpu",kernelFunc:e1};/**
9016 * @license
9017 * Copyright 2020 Google LLC. All Rights Reserved.
9018 * Licensed under the Apache License, Version 2.0 (the License);
9019 * you may not use this file except in compliance with the License.
9020 * You may obtain a copy of the License at
9021 *
9022 * http://www.apache.org/licenses/LICENSE-2.0
9023 *
9024 * Unless required by applicable law or agreed to in writing, software
9025 * distributed under the License is distributed on an AS IS BASIS,
9026 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9027 * See the License for the specific language governing permissions and
9028 * limitations under the License.
9029 * =============================================================================
9030 */const t1=Xn(n=>Math.expm1(n)),EP=Vs(ia,t1),RP={kernelName:ia,backendName:"cpu",kernelFunc:EP};/**
9031 * @license
9032 * Copyright 2020 Google LLC. All Rights Reserved.
9033 * Licensed under the Apache License, Version 2.0 (the License);
9034 * you may not use this file except in compliance with the License.
9035 * You may obtain a copy of the License at
9036 *
9037 * http://www.apache.org/licenses/LICENSE-2.0
9038 *
9039 * Unless required by applicable law or agreed to in writing, software
9040 * distributed under the License is distributed on an AS IS BASIS,
9041 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9042 * See the License for the specific language governing permissions and
9043 * limitations under the License.
9044 * =============================================================================
9045 */const n1=Xn(n=>Math.floor(n)),DP=Vs(la,n1),AP={kernelName:la,backendName:"cpu",kernelFunc:DP};/**
9046 * @license
9047 * Copyright 2020 Google LLC. All Rights Reserved.
9048 * Licensed under the Apache License, Version 2.0 (the "License");
9049 * you may not use this file except in compliance with the License.
9050 * You may obtain a copy of the License at
9051 *
9052 * http://www.apache.org/licenses/LICENSE-2.0
9053 *
9054 * Unless required by applicable law or agreed to in writing, software
9055 * distributed under the License is distributed on an "AS IS" BASIS,
9056 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9057 * See the License for the specific language governing permissions and
9058 * limitations under the License.
9059 * =============================================================================
9060 */const s1=Qe((n,e)=>Math.floor(n/e)),OP=ut(Ei,s1,null,"int32"),_P={kernelName:Ei,backendName:"cpu",kernelFunc:OP};/**
9061 * @license
9062 * Copyright 2021 Google LLC. All Rights Reserved.
9063 * Licensed under the Apache License, Version 2.0 (the "License");
9064 * you may not use this file except in compliance with the License.
9065 * You may obtain a copy of the License at
9066 *
9067 * http://www.apache.org/licenses/LICENSE-2.0
9068 *
9069 * Unless required by applicable law or agreed to in writing, software
9070 * distributed under the License is distributed on an "AS IS" BASIS,
9071 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9072 * See the License for the specific language governing permissions and
9073 * limitations under the License.
9074 * =============================================================================
9075 */function r1(n,e,t,s,r,a,o,i,l){const u=$e([s,a],t);for(let c=0;c<s;c++){const h=[];let d=0;for(let p=0;p<r;p++){const f=n[c*r+p];d+=f*o[p],h.push(f)}if(d<0||d>=l/a)throw new Error(`Invalid indices: ${h} does not index into ${i}`);for(let p=0;p<a;p++)u.values[c*a+p]=e.get(...e.indexToLoc(d*a+p))}return u}/**
9076 * @license
9077 * Copyright 2020 Google LLC. All Rights Reserved.
9078 * Licensed under the Apache License, Version 2.0 (the "License");
9079 * you may not use this file except in compliance with the License.
9080 * You may obtain a copy of the License at
9081 *
9082 * http://www.apache.org/licenses/LICENSE-2.0
9083 *
9084 * Unless required by applicable law or agreed to in writing, software
9085 * distributed under the License is distributed on an "AS IS" BASIS,
9086 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9087 * See the License for the specific language governing permissions and
9088 * limitations under the License.
9089 * =============================================================================
9090 */function a1(n,e,t){const s=$e(t,n.dtype);for(let r=0;r<s.size;++r){const o=s.indexToLoc(r).slice(),i=o[0],l=o[2],u=e.locToIndex([i,l]);o[2]=e.values[u];const c=n.locToIndex(o);
vendor: 4,234 bytes, lines 9090-9168
90900<=c&&c<n.values.length&&(s.values[r]=n.values[c])}return s}/**
9091 * @license
9092 * Copyright 2020 Google LLC. All Rights Reserved.
9093 * Licensed under the Apache License, Version 2.0 (the "License");
9094 * you may not use this file except in compliance with the License.
9095 * You may obtain a copy of the License at
9096 *
9097 * http://www.apache.org/licenses/LICENSE-2.0
9098 *
9099 * Unless required by applicable law or agreed to in writing, software
9100 * distributed under the License is distributed on an "AS IS" BASIS,
9101 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9102 * See the License for the specific language governing permissions and
9103 * limitations under the License.
9104 * =============================================================================
9105 */const o1=Qe((n,e)=>n>e?1:0),FP=ut(Qo,o1,null,"bool"),LP={kernelName:Qo,backendName:"cpu",kernelFunc:FP};/**
9106 * @license
9107 * Copyright 2020 Google LLC. All Rights Reserved.
9108 * Licensed under the Apache License, Version 2.0 (the "License");
9109 * you may not use this file except in compliance with the License.
9110 * You may obtain a copy of the License at
9111 *
9112 * http://www.apache.org/licenses/LICENSE-2.0
9113 *
9114 * Unless required by applicable law or agreed to in writing, software
9115 * distributed under the License is distributed on an "AS IS" BASIS,
9116 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9117 * See the License for the specific language governing permissions and
9118 * limitations under the License.
9119 * =============================================================================
9120 */const i1=Qe((n,e)=>n>=e?1:0),PP=ut(ua,i1,null,"bool"),zP={kernelName:ua,backendName:"cpu",kernelFunc:PP};/**
9121 * @license
9122 * Copyright 2020 Google LLC. All Rights Reserved.
9123 * Licensed under the Apache License, Version 2.0 (the "License");
9124 * you may not use this file except in compliance with the License.
9125 * You may obtain a copy of the License at
9126 *
9127 * http://www.apache.org/licenses/LICENSE-2.0
9128 *
9129 * Unless required by applicable law or agreed to in writing, software
9130 * distributed under the License is distributed on an "AS IS" BASIS,
9131 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9132 * See the License for the specific language governing permissions and
9133 * limitations under the License.
9134 * =============================================================================
9135 */const l1=Qe((n,e)=>n<e?1:0),VP=ut(ei,l1,null,"bool"),BP={kernelName:ei,backendName:"cpu",kernelFunc:VP};/**
9136 * @license
9137 * Copyright 2020 Google LLC. All Rights Reserved.
9138 * Licensed under the Apache License, Version 2.0 (the "License");
9139 * you may not use this file except in compliance with the License.
9140 * You may obtain a copy of the License at
9141 *
9142 * http://www.apache.org/licenses/LICENSE-2.0
9143 *
9144 * Unless required by applicable law or agreed to in writing, software
9145 * distributed under the License is distributed on an "AS IS" BASIS,
9146 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9147 * See the License for the specific language governing permissions and
9148 * limitations under the License.
9149 * =============================================================================
9150 */const u1=Qe((n,e)=>n<=e?1:0),MP=ut(ti,u1,null,"bool"),WP={kernelName:ti,backendName:"cpu",kernelFunc:MP};/**
9151 * @license
9152 * Copyright 2020 Google LLC. All Rights Reserved.
9153 * Licensed under the Apache License, Version 2.0 (the "License");
9154 * you may not use this file except in compliance with the License.
9155 * You may obtain a copy of the License at
9156 *
9157 * http://www.apache.org/licenses/LICENSE-2.0
9158 *
9159 * Unless required by applicable law or agreed to in writing, software
9160 * distributed under the License is distributed on an "AS IS" BASIS,
9161 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9162 * See the License for the specific language governing permissions and
9163 * limitations under the License.
9164 * =============================================================================
9165 */function c1(n,e,t){const s=(e-n)/(t-1),r=hn(t,"float32");r[0]=n;for(let a=1;a<r.length;a++)r[a]=r[a-1]+s;return r}/**
9166 * @license
9167 * Copyright 2020 Google LLC. All Rights Reserved.
9168 * Licensed under the Apache License, Version 2.0 (the License);
9169 * you may not use this file except in compliance with the License.
9170 * You may obtain a copy of the License at
9171 *
9172 * http://www.apache.org/licenses/LICENSE-2.0
9173 *
9174 * Unless required by applicable law or agreed to in writing, software
9175 * distributed under the License is distributed on an AS IS BASIS,
9176 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9177 * See the License for the specific language governing permissions and
9178 * limitations under the License.
9179 * =============================================================================
9180 */const h1=Xn(n=>Math.log(n)),UP=Vs(pa,h1),GP={kernelName:pa,backendName:"cpu",kernelFunc:UP};/**
9181 * @license
9182 * Copyright 2020 Google LLC. All Rights Reserved.
9183 * Licensed under the Apache License, Version 2.0 (the "License");
9184 * you may not use this file except in compliance with the License.
9185 * You may obtain a copy of the License at
9186 *
9187 * http://www.apache.org/licenses/LICENSE-2.0
9188 *
9189 * Unless required by applicable law or agreed to in writing, software
9190 * distributed under the License is distributed on an "AS IS" BASIS,
9191 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9192 * See the License for the specific language governing permissions and
9193 * limitations under the License.
9194 * =============================================================================
9195 */function d1(n,e,t,s){const r=wt(s,H(t));for(let a=0;a<r.length;++a){const o=a*e;let i=n[o];for(let l=0;l<e;++l){const u=n[o+l];(Number.isNaN(u)||u>i)&&(i=u)}r[a]=i}return r}/**
9196 * @license
9197 * Copyright 2020 Google LLC. All Rights Reserved.
9198 * Licensed under the Apache License, Version 2.0 (the "License");
9199 * you may not use this file except in compliance with the License.
9200 * You may obtain a copy of the License at
9201 *
9202 * http://www.apache.org/licenses/LICENSE-2.0
9203 *
9204 * Unless required by applicable law or agreed to in writing, software
9205 * distributed under the License is distributed on an "AS IS" BASIS,
9206 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9207 * See the License for the specific language governing permissions and
9208 * limitations under the License.
9209 * =============================================================================
9210 */const p1=Qe((n,e)=>Math.max(n,e)),HP=ut(Ri,p1),jP={kernelName:Ri,backendName:"cpu",kernelFunc:HP};/**
9211 * @license
9212 * Copyright 2020 Google LLC. All Rights Reserved.
9213 * Licensed under the Apache License, Version 2.0 (the "License");
9214 * you may not use this file except in compliance with the License.
9215 * You may obtain a copy of the License at
9216 *
9217 * http://www.apache.org/licenses/LICENSE-2.0
9218 *
9219 * Unless required by applicable law or agreed to in writing, software
9220 * distributed under the License is distributed on an "AS IS" BASIS,
9221 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9222 * See the License for the specific language governing permissions and
9223 * limitations under the License.
9224 * =============================================================================
9225 */const f1=Qe((n,e)=>Math.min(n,e)),qP=ut(ga,f1),KP={kernelName:ga,backendName:"cpu",kernelFunc:qP};/**
9226 * @license
9227 * Copyright 2020 Google LLC. All Rights Reserved.
9228 * Licensed under the Apache License, Version 2.0 (the "License");
9229 * you may not use this file except in compliance with the License.
9230 * You may obtain a copy of the License at
9231 *
9232 * http://www.apache.org/licenses/LICENSE-2.0
9233 *
9234 * Unless required by applicable law or agreed to in writing, software
9235 * distributed under the License is distributed on an "AS IS" BASIS,
9236 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9237 * See the License for the specific language governing permissions and
9238 * limitations under the License.
9239 * =============================================================================
9240 */const Zm=Qe((n,e)=>n*e),XP=Ym((n,e,t,s)=>({real:n*t-e*s,imag:n*s+e*t})),_h=ut(Di,Zm,XP),YP={kernelName:Di,backendName:"cpu",kernelFunc:_h};/**
9241 * @license
9242 * Copyright 2020 Google LLC. All Rights Reserved.
9243 * Licensed under the Apache License, Version 2.0 (the "License");
9244 * you may not use this file except in compliance with the License.
9245 * You may obtain a copy of the License at
9246 *
9247 * http://www.apache.org/licenses/LICENSE-2.0
9248 *
9249 * Unless required by applicable law or agreed to in writing, software
9250 * distributed under the License is distributed on an "AS IS" BASIS,
9251 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9252 * See the License for the specific language governing permissions and
9253 * limitations under the License.
9254 * =============================================================================
9255 */function m1(n,e,t){const s=_s(-1,t);return Zm([],e,s,n,t)}function JP(n){const{inputs:e,backend:t}=n,{x:s}=e;ue(s,"neg");const r=t.data.get(s.dataId).values,[a,o]=m1(r,s.shape,s.dtype);return t.makeTensorInfo(o,s.dtype,a)}const ZP={kernelName:si,backendName:"cpu",kernelFunc:JP};/**
9256 * @license
9257 * Copyright 2020 Google LLC. All Rights Reserved.
9258 * Licensed under the Apache License, Version 2.0 (the "License");
9259 * you may not use this file except in compliance with the License.
9260 * You may obtain a copy of the License at
9261 *
9262 * http://www.apache.org/licenses/LICENSE-2.0
9263 *
9264 * Unless required by applicable law or agreed to in writing, software
9265 * distributed under the License is distributed on an "AS IS" BASIS,
9266 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9267 * See the License for the specific language governing permissions and
9268 * limitations under the License.
9269 * =============================================================================
9270 */const g1=Qe((n,e)=>n!==e?1:0),QP=ut(hi,g1,null,"bool"),ez={kernelName:hi,backendName:"cpu",kernelFunc:QP};/**
9271 * @license
9272 * Copyright 2020 Google LLC. All Rights Reserved.
9273 * Licensed under the Apache License, Version 2.0 (the "License");
9274 * you may not use this file except in compliance with the License.
9275 * You may obtain a copy of the License at
9276 *
9277 * http://www.apache.org/licenses/LICENSE-2.0
9278 *
9279 * Unless required by applicable law or agreed to in writing, software
9280 * distributed under the License is distributed on an "AS IS" BASIS,
9281 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9282 * See the License for the specific language governing permissions and
9283 * limitations under the License.
9284 * =============================================================================
9285 */function Qm(n,e,t,s,r){const a=e.length,o=H(e),i=fe(e),l=fe(r),u=wt(t,H(r));for(let c=0;c<o;++c){const h=Ra(c,a,i),d=new Array(h.length);for(let f=0;f<d.length;f++)d[f]=h[s[f]];const p=Wn(d,a,l);u[p]=n[c]}return u}/**
9286 * @license
9287 * Copyright 2020 Google LLC. All Rights Reserved.
9288 * Licensed under the Apache License, Version 2.0 (the "License");
9289 * you may not use this file except in compliance with the License.
9290 * You may obtain a copy of the License at
9291 *
9292 * http://www.apache.org/licenses/LICENSE-2.0
9293 *
9294 * Unless required by applicable law or agreed to in writing, software
9295 * distributed under the License is distributed on an "AS IS" BASIS,
9296 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9297 * See the License for the specific language governing permissions and
9298 * limitations under the License.
9299 * =============================================================================
9300 */function Gt(n){const{inputs:e,attrs:t,backend:s}=n,{x:r}=e,{perm:a}=t;ue(r,"transpose");const o=r.shape.length,i=new Array(o);for(let h=0;h<i.length;h++)i[h]=r.shape[a[h]];const l=s.data.get(r.dataId).values,u=Qm(l,r.shape,r.dtype,a,i);return{dataId:s.write(u,i,r.dtype),shape:i,dtype:r.dtype}}const tz={kernelName:Js,backendName:"cpu",kernelFunc:Gt};/**
9301 * @license
9302 * Copyright 2020 Google LLC. All Rights Reserved.
9303 * Licensed under the Apache License, Version 2.0 (the "License");
9304 * you may not use this file except in compliance with the License.
9305 * You may obtain a copy of the License at
9306 *
9307 * http://www.apache.org/licenses/LICENSE-2.0
9308 *
9309 * Unless required by applicable law or agreed to in writing, software
9310 * distributed under the License is distributed on an "AS IS" BASIS,
9311 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9312 * See the License for the specific language governing permissions and
9313 * limitations under the License.
9314 * =============================================================================
9315 */function y1(n,e,t,s){const[r,a]=Ct(n,s),o=bn(e,"int32"),i=hn(H(r),o),l=H(a);for(let u=0;u<i.length;++u){const c=u*l;let h=1;for(let d=0;d<l;++d)h*=t[c+d];i[u]=h}
vendor: 15,041 bytes, lines 9315-9423
9315return{outVals:i,outShape:r,outDtype:o}}function nz(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s;ue(r,"prod");const i=r.shape.length,l=Ie(a,r.shape),u=Xe(l,i);let c=l,h=r;const d=[];u!=null&&(h=Gt({inputs:{x:r},backend:t,attrs:{perm:u}}),d.push(h),c=st(c.length,i));const p=t.data.get(h.dataId).values,{outVals:f,outShape:g,outDtype:m}=y1(h.shape,h.dtype,p,c);let y=g;return o&&(y=nt(g,l)),d.forEach(x=>t.disposeIntermediateTensorInfo(x)),t.makeTensorInfo(y,m,f)}const sz={kernelName:gi,backendName:"cpu",kernelFunc:nz};/**
9316 * @license
9317 * Copyright 2022 Google LLC. All Rights Reserved.
9318 * Licensed under the Apache License, Version 2.0 (the "License");
9319 * you may not use this file except in compliance with the License.
9320 * You may obtain a copy of the License at
9321 *
9322 * http://www.apache.org/licenses/LICENSE-2.0
9323 *
9324 * Unless required by applicable law or agreed to in writing, software
9325 * distributed under the License is distributed on an "AS IS" BASIS,
9326 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9327 * See the License for the specific language governing permissions and
9328 * limitations under the License.
9329 * =============================================================================
9330 */function rz(n,e,t){n.forEach((s,r)=>{if(s<0||s>=t){const a=Ra(r,e.length,fe(e)).join(",");throw new Error(`indices[${a}] = ${s} is not in [0, ${t})`)}})}function az(n,e){for(let t=0;t<n.length;++t){const s=n[t],r=t===n.length-1?e:n[t+1].length;if(s.length===0)throw new Error("Ragged splits may not be empty");if(s[0]<0)throw new Error("Ragged splits must be non-negative");if(s[s.length-1]>r)throw new Error("Ragged splits must not point past values");for(let a=1;a<s.length;++a)if(s[a-1]>s[a])throw new Error("Ragged splits must be sorted in ascending order")}}function oz(n,e,t,s){const r=[];let a=0;const o=e.length-1+t.length,i=new Array(o).fill(null).map(()=>[0]);az(t,s);let l=1;for(let u=0;u<e.length-1;++u){l*=e[u];const c=e[u+1];for(let h=1;h<l+1;++h)i[u].push(h*c)}for(let u=0;u<n.length;++u){let c=n[u],h=n[u]+1;for(let d=0;d<t.length;++d){const p=t[d],f=d+e.length-1;if(f>=0){const g=i[f],m=g[g.length-1]-p[c];for(let y=c;y<h;++y)i[f].push(p[y+1]+m)}c=p[c],h=p[h]}h!==c&&(r.push([c,h]),a+=h-c)}return{outSplits:i,valueSlices:r,numValues:a}}function iz(n){const e=[];for(let t=0;t<n.length;++t){const s=n[t].length,r=Dt("int32",s);e.push(r),n[t].forEach((a,o)=>r[o]=a)}return e}function yy(n,e){const t=n.slice(0,e);for(;t.length<e;)t.push(1);for(let s=e;s<n.length;s++)t[e-1]*=n[s];return t}function lz(n,e,t,s,r,a){const o=yy(e,2)[1],i=yy(a,2)[1];let l=0;for(const u of t)for(let c=u[0];c<u[1];++c){for(let h=0;h<s;++h)r[l*i+h]=n[c*o+h];++l}}function uz(n,e,t,s,r){const a=e.slice();a[0]=r;const o=Dt(t,H(a)),i=n.length,l=i===0?0:i/e[0];return lz(n,e,s,l,o,a),[o,a]}function x1(n,e,t,s,r,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 l=e[0][0]-1;if(rz(a,o,l),s.length===0)throw new Error("params.rank must be nonzero");const u=s[0],{outSplits:c,valueSlices:h,numValues:d}=oz(a,o,n,u),p=iz(c),f=uz(t,s,r,h,d);return[p,f[0],f[1]]}/**
9331 * @license
9332 * Copyright 2022 Google LLC.
9333 * Licensed under the Apache License, Version 2.0 (the "License");
9334 * you may not use this file except in compliance with the License.
9335 * You may obtain a copy of the License at
9336 *
9337 * http://www.apache.org/licenses/LICENSE-2.0
9338 *
9339 * Unless required by applicable law or agreed to in writing, software
9340 * distributed under the License is distributed on an "AS IS" BASIS,
9341 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9342 * See the License for the specific language governing permissions and
9343 * limitations under the License.
9344 * =============================================================================
9345 */const xy=2147483647;function b1(n,e,t,s,r,a,o){if(e.length>1)throw new Error("starts must be a scalar or vector");if(r.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,l=r.length===0,u=o.length===0,c=[];i||c.push(e[0]),l||c.push(r[0]),u||c.push(o[0]);for(let m=1;m<c.length;++m)if(c[m]!==c[m-1])throw new Error("starts, limits, and deltas must have the same shape");const h=c.length===0?1:c[0],d=Dt("int32",h+1);d[0]=0;for(let m=0;m<h;++m){const y=i?n[0]:n[m],x=l?s[0]:s[m],v=u?a[0]:a[m];if(v===0)throw new Error("Requires delta != 0");let b;if(v>0&&x<y||v<0&&x>y)b=0;else if(b=Math.ceil(Math.abs((x-y)/v)),b>xy)throw new Error(`Requires ((limit - start) / delta) <= ${xy}`);d[m+1]=d[m]+b}const p=d[h],f=Dt(t,p);let g=0;for(let m=0;m<h;++m){const y=d[m+1]-d[m];let x=i?n[0]:n[m];const v=u?a[0]:a[m];for(let b=0;b<y;++b)f[g++]=x,x+=v}return[d,f]}/**
9346 * @license
9347 * Copyright 2022 Google LLC. All Rights Reserved.
9348 * Licensed under the Apache License, Version 2.0 (the "License");
9349 * you may not use this file except in compliance with the License.
9350 * You may obtain a copy of the License at
9351 *
9352 * http://www.apache.org/licenses/LICENSE-2.0
9353 *
9354 * Unless required by applicable law or agreed to in writing, software
9355 * distributed under the License is distributed on an "AS IS" BASIS,
9356 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9357 * See the License for the specific language governing permissions and
9358 * limitations under the License.
9359 * =============================================================================
9360 */var mn=WC;class hu{constructor(e,t,s,r,a,o,i,l,u,c){this.shape=e,this.shapeShape=t,this.values=s,this.valuesShape=r,this.valuesDType=a,this.defaultValue=o,this.defaultValueShape=i,this.rowPartitionValues=l,this.rowPartitionValuesShapes=u,this.rowPartitionTypes=BC(c),this.raggedRank=MC(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===mn.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===mn.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case mn.VALUE_ROWIDS:return hu.getMaxWidthValueRowID(t);case mn.ROW_SPLITS:return hu.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${mn[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(t===0||t===1)return 0;let s=0;for(let r=0;r<t-1;++r){const a=e[r+1]-e[r];a>s&&(s=a)}return s}static getMaxWidthValueRowID(e){const t=e.length;if(t===0)return 0;let s=0,r=e[0],a=0;for(let o=1;o<t;++o){const i=e[o];i!==r&&(r=i,a=Math.max(o-s,a),s=o)}return Math.max(t-s,a)}tensorShapeFromTensor(e,t,s=!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 wy(e,s)}calculateOutputSize(e){const t=this.valuesShape,s=this.defaultValueShape;UC(s,t);const r=this.tensorShapeFromTensor(this.shape,this.shapeShape),o=GC(this.raggedRank,r,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,s){const r=Math.min(e,s),a=[];let o=0;for(let i=0;i<r;++i,o+=t)a.push(o);for(let i=r;i<e;++i)a.push(-1);return I(a.length===e,()=>"Final length of result must be equal to firstDimension."),a}calculateOutputIndexRowSplit(e,t,s,r){const a=e.length,o=[];for(let i=0;i<a-1;++i){const l=e[i+1]-e[i];let u=Math.min(r,l),c=t[i];c===-1&&(u=0);for(let h=0;h<u;++h)o.push(c),c+=s;for(let h=0;h<l-u;++h)o.push(-1)}if(a>0&&o.length!==e[a-1])throw new Error("Invalid row split size.");return o}calculateOutputIndexValueRowID(e,t,s,r){const a=e.length,o=[];if(a===0)return[];let i=0,l=e[0];if(l>=t.length)throw new Error(`Got currentValueRowId=${l}, which is not less than ${t.length}`);let u=t[l];o.push(u);for(let c=1;c<a;++c){const h=e[c];if(h===l)u>=0&&(++i,i<r?u+=s:u=-1);else{if(i=0,l=h,h>=t.length)throw new Error(`Got nextValueRowId=${h} which is not less than ${t.length}`);u=t[h]}o.push(u)}if(o.length!==e.length)throw new Error("Invalid row ids.");return o}calculateOutputIndex(e,t,s,r){const a=this.getRowPartitionTensor(e),o=this.getRowPartitionTypeByDimension(e);switch(o){case mn.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(a,t,s,r);case mn.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,s,r);default:throw new Error(`Unsupported partition type: ${mn[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 mn.FIRST_DIM_SIZE:return e[0];case mn.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case mn.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${mn[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(),s=this.calculateOutputSize(t),r=new Array(this.raggedRank+1);r[r.length-1]=1;for(let l=r.length-2;l>=0;--l)r[l]=r[l+1]*s[l+1];const a=wy(s,!1),o=Dt(this.valuesDType,H(a));if(r[0]*s[0]>0){let l=this.calculateFirstParentOutputIndex(t,r[0],s[0]);for(let u=1;u<=this.raggedRank;++u)l=this.calculateOutputIndex(u-1,l,r[u],s[u]);this.setOutput(this.raggedRank,l,o,a)}return[a,o]}setOutput(e,t,s,r){if(s.length===0)return;const a=this.values,o=s;let i=r.slice();i=i.slice(e+1);const l=H(i),u=t.length;let c=this.defaultValue;if(c.length!==l&&c.length!==1){const f=this.defaultValueShape;L(()=>{const g=D(c,f);c=Qs(g,i).dataSync()})}let h=0,d=0,p=0;for(let f=0;f<=u;++f){let g=f<u?t[f]:-1;if(g===p){++p;continue}if(d<p){const m=a.subarray(h*l),y=o.subarray(d*l),x=(p-d)*l;by(y,m,x)}if(f>=u){const m=s.length;g=Math.floor(m/l)}if(g>p)if(this.defaultValue.length===1)o.subarray(p*l,g*l).fill(this.defaultValue[0]),p=g;else for(;g>p;){const m=o.slice(p*l);by(m,c,l),++p}g<0?(h=f+1,d=p):(h=f,d=p,p=d+1)}}}function by(n,e,t){for(let s=0;s<t;s++)n[s]=e[s]}function wy(n,e){const t=[];for(let s of n){if(s<0){if(!e)throw new Error(`Dimension ${s} must be >= 0`);if(s<-1)throw new Error(`Dimension ${s} must be >= -1`);s=-1}t.push(s)}return t}function w1(n,e,t,s,r,a,o,i,l,u){return new hu(n,e,t,s,r,a,o,i,l,u).compute()}/**
9361 * @license
9362 * Copyright 2020 Google LLC. All Rights Reserved.
9363 * Licensed under the Apache License, Version 2.0 (the License);
9364 * you may not use this file except in compliance with the License.
9365 * You may obtain a copy of the License at
9366 *
9367 * http://www.apache.org/licenses/LICENSE-2.0
9368 *
9369 * Unless required by applicable law or agreed to in writing, software
9370 * distributed under the License is distributed on an AS IS BASIS,
9371 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9372 * See the License for the specific language governing permissions and
9373 * limitations under the License.
9374 * =============================================================================
9375 */const v1=Xn(n=>1/Math.sqrt(n)),cz=Vs(wa,v1),hz={kernelName:wa,backendName:"cpu",kernelFunc:cz};/**
9376 * @license
9377 * Copyright 2020 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 */function Ys(n,e,t,s,r,a,o,i,l,u){const c=[s/r,r],h=n.values,d=e.values;if(s===0)return $e(t,e.dtype);const p=l instanceof bt?l:$e(c,e.dtype);typeof l=="string"||typeof l=="number"?p.values.fill(l):typeof l=="boolean"&&p.values.fill(+l);for(let f=0;f<a;f++){const g=[];let m=0;for(let y=0;y<o;y++){const x=h[f*o+y];g.push(x),m+=x*i[y]}if(m<0||m>=s/r)throw new Error(`Invalid indices: ${g} does not index into ${t}`);for(let y=0;y<r;y++)u?p.values[m*r+y]+=d[f*r+y]:p.values[m*r+y]=e.rank===0?d[0]:d[f*r+y]}return p}/**
9391 * @license
9392 * Copyright 2020 Google LLC. All Rights Reserved.
9393 * Licensed under the Apache License, Version 2.0 (the License);
9394 * you may not use this file except in compliance with the License.
9395 * You may obtain a copy of the License at
9396 *
9397 * http://www.apache.org/licenses/LICENSE-2.0
9398 *
9399 * Unless required by applicable law or agreed to in writing, software
9400 * distributed under the License is distributed on an AS IS BASIS,
9401 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9402 * See the License for the specific language governing permissions and
9403 * limitations under the License.
9404 * =============================================================================
9405 */const dz=Xn(n=>1/(1+Math.exp(-n))),C1=Oe(Li,n=>1/(1+Math.exp(-n))),pz={kernelName:Li,backendName:"cpu",kernelFunc:C1};/**
9406 * @license
9407 * Copyright 2021 Google LLC. All Rights Reserved.
9408 * Licensed under the Apache License, Version 2.0 (the "License");
9409 * you may not use this file except in compliance with the License.
9410 * You may obtain a copy of the License at
9411 *
9412 * http://www.apache.org/licenses/LICENSE-2.0
9413 *
9414 * Unless required by applicable law or agreed to in writing, software
9415 * distributed under the License is distributed on an "AS IS" BASIS,
9416 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9417 * See the License for the specific language governing permissions and
9418 * limitations under the License.
9419 * =============================================================================
9420 */function $1(n,e,t,s,r,a,o){const i=e[0],l=a[0],u=new Array(l),c=new Array(i),h=e[1];if(l===0){if(i!==0)throw new Error(HC(i));const m=Dt(t,0),y=Dt(r,0);return[m,[0,h],y,u,c]}let d=!0,p=0;const f=new Array(l).fill(0);for(let m=0;m<i;++m){const y=n[m*h];if(y<0)throw new Error(jC(m,y));if(y>=l)throw new Error(qC(m,y,l));++f[y],d=d&&y>=p,p=y}let g=!0;for(let m=0;m<l;++m){const y=f[m]===0;u[m]=y,g=g&&!y,f[m]=Math.max(f[m],1),m>0&&(f[m]+=f[m-1])}if(g&&d){const m=n,y=s;for(let x=0;x<i;++x)c[x]=x;return[m,[i,h],y,u,c]}else{const m=f[l-1],y=Dt(t,m*h),x=Dt(r,m),v=new Array(l).fill(0);for(let b=0;b<i;++b){const C=n[b*h],$=v[C],S=(C===0?0:f[C-1])+$;v[C]++;for(let k=0;k<h;++k)y[S*h+k]=n[b*h+k];x[S]=s[b],c[b]=S}for(let b=0;b<l;++b)if(v[b]===0){const $=b===0?0:f[b-1];y[$*h+0]=b;for(let S=1;S<h;++S)y[$*h+S]=0;x[$]=o}return[y,[m,h],x,u,c]}}/**
9421 * @license
9422 * Copyright 2021 Google LLC. All Rights Reserved.
9423 * Licensed under the Apache License, Version 2.0 (the "License");
9424 * you may not use this file except in compliance with the License.
9425 * You may obtain a copy of the License at
9426 *
9427 * http://www.apache.org/licenses/LICENSE-2.0
9428 *
9429 * Unless required by applicable law or agreed to in writing, software
9430 * distributed under the License is distributed on an "AS IS" BASIS,
9431 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9432 * See the License for the specific language governing permissions and
9433 * limitations under the License.
9434 * =============================================================================
9435 */function N1(n,e,t,s,r){const a=H(s),o=e[0],i=r.length,l=[];let u=1,c=-1;for(let m=0;m<i;++m){const y=r[m];if(y===-1){if(c!==-1)throw new Error(KC(c,m));c=m,l.push(1)}else{if(y<0)throw new Error(XC(m,y));u*=y,l.push(y)}}if(c!==-1){if(u<=0)throw new Error(YC());const m=Math.trunc(a/u);if(u*m!==a)throw new Error(JC(s,l));l[c]=m}if(H(l)!==a)throw new Error(ZC(s,l));const d=s.length,p=[];if(d>0){p[d-1]=1;for(let m=d-2;m>=0;--m)p[m]=p[m+1]*s[m+1]}const f=[];if(i>0){f[i-1]=1;for(let m=i-2;m>=0;--m)f[m]=f[m+1]*l[m+1]}const g=Dt(t,o*i);for(let m=0;m<o;++m){let y=0;for(let x=0;x<d;++x)y+=n[m*d+x]*p[x];for(let x=0;x<i;++x)g[m*i+x]=Math.trunc(y/f[x]),y%=f[x]}return[g,[o,i],l]}/**
9436 * @license
9437 * Copyright 2021 Google LLC. All Rights Reserved.
9438 * Licensed under the Apache License, Version 2.0 (the "License");
9439 * you may not use this file except in compliance with the License.
9440 * You may obtain a copy of the License at
9441 *
9442 * http://www.apache.org/licenses/LICENSE-2.0
9443 *
9444 * Unless required by applicable law or agreed to in writing, software
9445 * distributed under the License is distributed on an "AS IS" BASIS,
9446 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9447 * See the License for the specific language governing permissions and
9448 * limitations under the License.
9449 * =============================================================================
9450 */function eg(n,e,t,s,r,a=!1,o=0){const i=s.length,l=[e[0],n.length/e[0]],u=l[1],h=i>0?r[i-1]+1:0;if(h<0)throw new Error(Cg());const d=e.slice();d[0]=h;const p=d.reduce((v,b)=>v*b,1),f=Dt(t,p);if(i===0)return h>0&&f.fill(o),[f,d];if(h<=0)throw new Error(Cg());let g=0,m=1,y=0,x=r[g];for(;;){let v=0;if(m<i){if(v=r[m],x===v){++m;continue}if(x>=v)throw new Error(QC())}if(x<0||x>=h)throw new Error(e$(x,h));x>y&&f.fill(o,y*u,x*u);for(let b=g;b<m;++b){const C=s[b];if(C<0||C>=l[0])throw new Error(t$(b,s[b],l[0]));for(let $=0;$<u;$++)f[x*u+$]+=n[C*u+$]}if(a)for(let b=0;b<u;b++)f[x*u+b]/=m-g;if(g=m,++m,y=x+1,x=v,m>i)break}return y<h&&f.fill(o,y*u,h*u),[f,d]}/**
9451 * @license
9452 * Copyright 2020 Google LLC. All Rights Reserved.
9453 * Licensed under the Apache License, Version 2.0 (the License);
9454 * you may not use this file except in compliance with the License.
9455 * You may obtain a copy of the License at
9456 *
9457 * http://www.apache.org/licenses/LICENSE-2.0
9458 *
9459 * Unless required by applicable law or agreed to in writing, software
9460 * distributed under the License is distributed on an AS IS BASIS,
9461 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9462 * See the License for the specific language governing permissions and
9463 * limitations under the License.
9464 * =============================================================================
9465 */const fz=Xn(n=>Math.sqrt(n)),mz=Oe(Pi,n=>Math.sqrt(n)),gz={kernelName:Pi,backendName:"cpu",kernelFunc:mz};/**
9466 * @license
9467 * Copyright 2020 Google LLC. All Rights Reserved.
9468 * Licensed under the Apache License, Version 2.0 (the "License");
9469 * you may not use this file except in compliance with the License.
9470 * You may obtain a copy of the License at
9471 *
9472 * http://www.apache.org/licenses/LICENSE-2.0
9473 *
9474 * Unless required by applicable law or agreed to in writing, software
9475 * distributed under the License is distributed on an "AS IS" BASIS,
9476 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9477 * See the License for the specific language governing permissions and
9478 * limitations under the License.
9479 * =============================================================================
9480 */const I1=Qe((n,e)=>{const t=n-e;return t*t}),yz=ut(Ia,I1),xz={kernelName:Ia,backendName:"cpu",kernelFunc:yz};/**
9481 * @license
9482 * Copyright 2023 Google LLC.
9483 * Licensed under the Apache License, Version 2.0 (the "License");
9484 * you may not use this file except in compliance with the License.
9485 * You may obtain a copy of the License at
9486 *
9487 * http://www.apache.org/licenses/LICENSE-2.0
9488 *
9489 * Unless required by applicable law or agreed to in writing, software
9490 * distributed under the License is distributed on an "AS IS" BASIS,
9491 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9492 * See the License for the specific language governing permissions and
9493 * limitations under the License.
9494 * =============================================================================
9495 */const S1=Xn((n,e)=>{const{pattern:t,replaceGlobal:s,rewrite:r}=e;return n.replace(new RegExp(t,s?"g":""),r)}),bz=Vs(Si,S1),wz={kernelName:Si,backendName:"cpu",kernelFunc:bz};/**
9496 * @license
9497 * Copyright 2020 Google LLC. All Rights Reserved.
9498 * Licensed under the Apache License, Version 2.0 (the "License");
9499 * you may not use this file except in compliance with the License.
9500 * You may obtain a copy of the License at
9501 *
9502 * http://www.apache.org/licenses/LICENSE-2.0
9503 *
9504 * Unless required by applicable law or agreed to in writing, software
9505 * distributed under the License is distributed on an "AS IS" BASIS,
9506 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9507 * See the License for the specific language governing permissions and
9508 * limitations under the License.
9509 * =============================================================================
9510 */function k1(n,e,t,s){const r=$e(n,e.dtype);for(let a=0;a<r.size;a++){const o=r.indexToLoc(a),i=new Array(o.length);for(let l=0;l<i.length;l++)i[l]=o[l]*t[l]+s[l];r.set(e.get(...i),...o)}return r}/**
9511 * @license
9512 * Copyright 2020 Google LLC. All Rights Reserved.
9513 * Licensed under the Apache License, Version 2.0 (the "License");
9514 * you may not use this file except in compliance with the License.
9515 * You may obtain a copy of the License at
9516 *
9517 * http://www.apache.org/licenses/LICENSE-2.0
9518 *
9519 * Unless required by applicable law or agreed to in writing, software
9520 * distributed under the License is distributed on an "AS IS" BASIS,
9521 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9522 * See the License for the specific language governing permissions and
9523 * limitations under the License.
9524 * =============================================================================
9525 */const T1=Qe((n,e)=>n-e),vz=Ym((n,e,t,s)=>({real:n-t,imag:e-s})),tg=ut(Vi,T1,vz),Cz={kernelName:Vi,backendName:"cpu",kernelFunc:tg};/**
9526 * @license
9527 * Copyright 2019 Google LLC. All Rights Reserved.
9528 * Licensed under the Apache License, Version 2.0 (the "License");
9529 * you may not use this file except in compliance with the License.
9530 * You may obtain a copy of the License at
9531 *
9532 * http://www.apache.org/licenses/LICENSE-2.0
9533 *
9534 * Unless required by applicable law or agreed to in writing, software
9535 * distributed under the License is distributed on an "AS IS" BASIS,
9536 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9537 * See the License for the specific language governing permissions and
9538 * limitations under the License.
9539 * =============================================================================
9540 */function E1(n,e){const t=new Array(n.rank);for(let r=0;r<t.length;r++)t[r]=n.shape[r]*e[r];const s=$e(t,n.dtype);for(let r=0;r<s.values.length;++r){const a=s.indexToLoc(r),o=new Array(n.rank);for(let l=0;l<o.length;l++)o[l]=a[l]%n.shape[l];const i=n.locToIndex(o);s.values[r]=n.values[i]}return s}/**
9541 * @license
9542 * Copyright 2020 Google LLC. All Rights Reserved.
9543 * Licensed under the Apache License, Version 2.0 (the "License");
9544 * you may not use this file except in compliance with the License.
9545 * You may obtain a copy of the License at
9546 *
9547 * http://www.apache.org/licenses/LICENSE-2.0
9548 *
9549 * Unless required by applicable law or agreed to in writing, software
9550 * distributed under the License is distributed on an "AS IS" BASIS,
9551 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9552 * See the License for the specific language governing permissions and
9553 * limitations under the License.
9554 * =============================================================================
9555 */const lo=(n,e)=>{const t=e.value-n.value;return t===0?n.index-e.index:t};function R1(n,e,t=0,s=n.length-1){for(;s>t;){if(s-t>600){const i=s-t+1,l=e-t+1,u=Math.log(i),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(i-c)/i)*Math.sign(l-i/2),d=Math.max(t,Math.floor(e-l*c/i+h)),p=Math.min(s,Math.floor(e+(i-l)*c/i+h));R1(n,e,d,p)}const r=n[e];let a=t,o=s;for(no(n,t,e),lo(n[s],r)>0&&no(n,t,s);a<o;){for(no(n,a,o),a++,o--;lo(n[a],r)<0;)a=a+1;for(;lo(n[o],r)>0;)o=o-1}lo(n[t],r)===0?no(n,t,o):(o=o+1,no(n,o,s)),o<=e&&(t=o+1),e<=o&&(s=o-1)}}function D1(n,e,t,s,r){const a=e[e.length-1],[o,i]=[n.length/a,a],l=wt(t,o*s),u=wt("int32",o*s);for(let h=0;h<o;h++){const d=h*i,p=n.subarray(d,d+i);let f=new Array(p.length);p.forEach((x,v)=>f[v]={value:x,index:v}),s<f.length&&(R1(f,s),f=f.slice(0,s)),r&&f.sort(lo);const g=h*s,m=l.subarray(g,g+s),y=u.subarray(g,g+s);for(let x=0;x<s;x++)m[x]=f[x].value,y[x]=f[x].index}const c=e.slice();return c[c.length-1]=s,[$e(c,t,l),$e(c,"int32",u)]}/**
9556 * @license
9557 * Copyright 2020 Google LLC. All Rights Reserved.
9558 * Licensed under the Apache License, Version 2.0 (the "License");
9559 * you may not use this file except in compliance with the License.
9560 * You may obtain a copy of the License at
9561 *
9562 * http://www.apache.org/licenses/LICENSE-2.0
9563 *
9564 * Unless required by applicable law or agreed to in writing, software
9565 * distributed under the License is distributed on an "AS IS" BASIS,
9566 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9567 * See the License for the specific language governing permissions and
9568 * limitations under the License.
9569 * =============================================================================
9570 */const A1=Object.freeze(Object.defineProperty({__proto__:null,addImpl:q0,bincountImpl:Jm,bincountReduceImpl:K0,bitwiseAndImpl:X0,castImpl:j0,ceilImpl:Y0,concatImpl:yx,equalImpl:J0,expImpl:Q0,expm1Impl:t1,floorDivImpl:s1,floorImpl:n1,gatherNdImpl:r1,gatherV2Impl:a1,greaterEqualImpl:i1,greaterImpl:o1,lessEqualImpl:u1,lessImpl:l1,linSpaceImpl:c1,logImpl:h1,maxImpl:d1,maximumImpl:p1,minimumImpl:f1,multiplyImpl:Zm,negImpl:m1,notEqualImpl:g1,prodImpl:y1,raggedGatherImpl:x1,raggedRangeImpl:b1,raggedTensorToTensorImpl:w1,rangeImpl:xx,rsqrtImpl:v1,scatterImpl:Ys,sigmoidImpl:dz,simpleAbsImpl:H0,sliceImpl:n$,sparseFillEmptyRowsImpl:$1,sparseReshapeImpl:N1,sparseSegmentReductionImpl:eg,sqrtImpl:fz,squaredDifferenceImpl:I1,staticRegexReplaceImpl:S1,stridedSliceImpl:k1,stringNGramsImpl:bx,stringSplitImpl:wx,stringToHashBucketFastImpl:vx,subImpl:T1,tileImpl:E1,topKImpl:D1,transposeImpl:Qm,uniqueImpl:Cx},Symbol.toStringTag,{value:"Module"}));/** @license See the LICENSE file. */const O1="4.22.0";/**
9571 * @license
9572 * Copyright 2020 Google LLC. All Rights Reserved.
9573 * Licensed under the Apache License, Version 2.0 (the "License");
9574 * you may not use this file except in compliance with the License.
9575 * You may obtain a copy of the License at
9576 *
9577 * http://www.apache.org/licenses/LICENSE-2.0
9578 *
9579 * Unless required by applicable law or agreed to in writing, software
9580 * distributed under the License is distributed on an "AS IS" BASIS,
9581 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9582 * See the License for the specific language governing permissions and
9583 * limitations under the License.
9584 * =============================================================================
9585 */Jd("cpu",()=>new ml,1);/**
9586 * @license
9587 * Copyright 2020 Google LLC. All Rights Reserved.
9588 * Licensed under the Apache License, Version 2.0 (the License);
9589 * you may not use this file except in compliance with the License.
9590 * You may obtain a copy of the License at
9591 *
9592 * http://www.apache.org/licenses/LICENSE-2.0
9593 *
9594 * Unless required by applicable law or agreed to in writing, software
9595 * distributed under the License is distributed on an AS IS BASIS,
9596 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9597 * See the License for the specific language governing permissions and
9598 * limitations under the License.
9599 * =============================================================================
9600 */const _1=Oe(Ti,n=>n>=0?n:Math.exp(n)-1),$z={kernelName:Ti,backendName:"cpu",kernelFunc:_1};/**
9601 * @license
9602 * Copyright 2020 Google LLC. All Rights Reserved.
9603 * Licensed under the Apache License, Version 2.0 (the "License");
9604 * you may not use this file except in compliance with the License.
9605 * You may obtain a copy of the License at
9606 *
9607 * http://www.apache.org/licenses/LICENSE-2.0
9608 *
9609 * Unless required by applicable law or agreed to in writing, software
9610 * distributed under the License is distributed on an "AS IS" BASIS,
9611 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9612 * See the License for the specific language governing permissions and
9613 * limitations under the License.
9614 * =============================================================================
9615 */function F1(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{alpha:a}=s;ue([r],"leakyRelu");const o=H(r.shape),i=t.data.get(r.dataId).values,l=wt("float32",o);for(let u=0;u<i.length;u++)l[u]=i[u]<0?a*i[u]:i[u];return t.makeTensorInfo(r.shape,"float32",l)}const Nz={kernelName:vc,backendName:"cpu",kernelFunc:F1};/**
9616 * @license
9617 * Copyright 2020 Google LLC. All Rights Reserved.
9618 * Licensed under the Apache License, Version 2.0 (the License);
9619 * you may not use this file except in compliance with the License.
9620 * You may obtain a copy of the License at
9621 *
9622 * http://www.apache.org/licenses/LICENSE-2.0
9623 *
9624 * Unless required by applicable law or agreed to in writing, software
9625 * distributed under the License is distributed on an AS IS BASIS,
9626 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9627 * See the License for the specific language governing permissions and
9628 * limitations under the License.
9629 * =============================================================================
9630 */const Iz=Qe((n,e)=>n<0?e*n:n);function L1(n){const{inputs:e,backend:t}=n,{x:s,alpha:r}=e;ue([s,r],"prelu");const a=t.data.get(s.dataId).values,o=t.data.get(r.dataId).values,[i,l]=Iz(s.shape,r.shape,a,o,"float32");return t.makeTensorInfo(l,"float32",i)}const Sz={kernelName:Ic,backendName:"cpu",kernelFunc:L1};/**
9631 * @license
9632 * Copyright 2020 Google LLC. All Rights Reserved.
9633 * Licensed under the Apache License, Version 2.0 (the License);
9634 * you may not use this file except in compliance with the License.
9635 * You may obtain a copy of the License at
9636 *
9637 * http://www.apache.org/licenses/LICENSE-2.0
9638 *
9639 * Unless required by applicable law or agreed to in writing, software
9640 * distributed under the License is distributed on an AS IS BASIS,
9641 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9642 * See the License for the specific language governing permissions and
9643 * limitations under the License.
9644 * =============================================================================
9645 */const P1=Oe(Fi,n=>Math.max(0,n)),kz={kernelName:Fi,backendName:"cpu",kernelFunc:P1};/**
9646 * @license
9647 * Copyright 2020 Google LLC. All Rights Reserved.
9648 * Licensed under the Apache License, Version 2.0 (the License);
9649 * you may not use this file except in compliance with the License.
9650 * You may obtain a copy of the License at
9651 *
9652 * http://www.apache.org/licenses/LICENSE-2.0
9653 *
9654 * Unless required by applicable law or agreed to in writing, software
9655 * distributed under the License is distributed on an AS IS BASIS,
9656 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9657 * See the License for the specific language governing permissions and
9658 * limitations under the License.
9659 * =============================================================================
9660 */const z1=Oe(_i,n=>Math.min(Math.max(0,n),6)),Tz={kernelName:_i,backendName:"cpu",kernelFunc:z1};/**
9661 * @license
9662 * Copyright 2020 Google LLC. All Rights Reserved.
9663 * Licensed under the Apache License, Version 2.0 (the "License");
9664 * you may not use this file except in compliance with the License.
9665 * You may obtain a copy of the License at
9666 *
9667 * http://www.apache.org/licenses/LICENSE-2.0
9668 *
9669 * Unless required by applicable law or agreed to in writing, software
9670 * distributed under the License is distributed on an "AS IS" BASIS,
9671 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9672 * See the License for the specific language governing permissions and
9673 * limitations under the License.
9674 * =============================================================================
9675 */function du(n,e,t,s,r){if(t==="linear")return jn({inputs:{x:e},backend:n});if(t==="relu")return P1({inputs:{x:e},backend:n});if(t==="elu")return _1({inputs:{x:e},backend:n});if(t==="relu6")return z1({inputs:{x:e},backend:n});
vendor: 4,109 bytes, lines 9675-9714
9675if(t==="prelu")return L1({inputs:{x:e,alpha:s},backend:n});if(t==="leakyrelu")return F1({inputs:{x:e},backend:n,attrs:{alpha:r}});if(t==="sigmoid")return C1({inputs:{x:e},backend:n});throw new Error(`Activation ${t} has not been implemented for the CPU backend.`)}/**
9676 * @license
9677 * Copyright 2020 Google LLC. All Rights Reserved.
9678 * Licensed under the Apache License, Version 2.0 (the "License");
9679 * you may not use this file except in compliance with the License.
9680 * You may obtain a copy of the License at
9681 *
9682 * http://www.apache.org/licenses/LICENSE-2.0
9683 *
9684 * Unless required by applicable law or agreed to in writing, software
9685 * distributed under the License is distributed on an "AS IS" BASIS,
9686 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9687 * See the License for the specific language governing permissions and
9688 * limitations under the License.
9689 * =============================================================================
9690 */function Me(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{shape:a}=s,o=H(r.shape),i=$x(a,o),l=H(i);I(o===l,()=>`The new shape (${i}) has ${l} elements and the old shape (${r.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`),t.incRef(r.dataId);const u=t.data.get(r.dataId);if(u.complexTensorInfos!=null){const c=u.complexTensorInfos.real,h=u.complexTensorInfos.imag;c.shape=i,h.shape=i}return{dataId:r.dataId,shape:i,dtype:r.dtype}}const Ez={kernelName:Sc,backendName:"cpu",kernelFunc:Me};/**
9691 * @license
9692 * Copyright 2020 Google LLC. All Rights Reserved.
9693 * Licensed under the Apache License, Version 2.0 (the License);
9694 * you may not use this file except in compliance with the License.
9695 * You may obtain a copy of the License at
9696 *
9697 * http://www.apache.org/licenses/LICENSE-2.0
9698 *
9699 * Unless required by applicable law or agreed to in writing, software
9700 * distributed under the License is distributed on an AS IS BASIS,
9701 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9702 * See the License for the specific language governing permissions and
9703 * limitations under the License.
9704 * =============================================================================
9705 */function V1(n){const{inputs:e,backend:t,attrs:s}=n,{a:r,b:a}=e,{transposeA:o,transposeB:i}=s;ue([r,a],"matMul");const l=r.shape.length,u=a.shape.length,c=o?r.shape[l-2]:r.shape[l-1],h=i?a.shape[u-1]:a.shape[u-2],d=o?r.shape[l-1]:r.shape[l-2],p=i?a.shape[u-2]:a.shape[u-1],f=r.shape.slice(0,-2),g=a.shape.slice(0,-2),m=H(f),y=H(g),v=xe(r.shape.slice(0,-2),a.shape.slice(0,-2)).concat([d,p]);I(c===h,()=>`Error in matMul: inner shapes (${c}) and (${h}) of Tensors with shapes ${r.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);const b=o?[m,c,d]:[m,d,c],C=i?[y,p,h]:[y,h,p],$=Me({inputs:{x:r},backend:t,attrs:{shape:b}}),S=Me({inputs:{x:a},backend:t,attrs:{shape:C}}),k=o?$.shape[1]:$.shape[2],T=o?$.shape[2]:$.shape[1],E=i?S.shape[1]:S.shape[2],_=Math.max(m,y),z=t.data.get($.dataId).values,P=t.data.get(S.dataId).values,V=fe($.shape),B=fe(S.shape),[M,j,U]=o?[V[0],1,V[1]]:[V[0],V[1],1],[q,X,Y]=i?[1,B[1],B[0]]:[B[1],1,B[0]],Z=T*E,J=$e([_,T,E],$.dtype),re=J.values,Q=t.blockSize;for(let ae=0;ae<_;ae++){const ce=ae%m,me=ae%y;for(let de=0;de<T;de+=Q){const be=Math.min(de+Q,T);for(let we=0;we<E;we+=Q){const De=Math.min(we+Q,E);for(let Pe=0;Pe<k;Pe+=Q){const Ke=Math.min(Pe+Q,k);for(let ze=de;ze<be;ze++)for(let _e=we;_e<De;_e++){let He=0;for(let We=Pe;We<Ke;We++){const Yn=z[ce*M+ze*j+We*U],ft=P[We*q+_e*X+me*Y];He+=Yn*ft}re[ae*Z+(ze*E+_e)]+=He}}}}}return t.disposeIntermediateTensorInfo($),t.disposeIntermediateTensorInfo(S),t.makeTensorInfo(v,J.dtype,J.values)}const Rz={kernelName:Po,backendName:"cpu",kernelFunc:V1};/**
9706 * @license
9707 * Copyright 2020 Google LLC. All Rights Reserved.
9708 * Licensed under the Apache License, Version 2.0 (the License);
9709 * you may not use this file except in compliance with the License.
9710 * You may obtain a copy of the License at
9711 *
9712 * http://www.apache.org/licenses/LICENSE-2.0
9713 *
9714 * Unless required by applicable law or agreed to in writing, softw
9714are
9715 * distributed under the License is distributed on an AS IS BASIS,
9716 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9717 * See the License for the specific language governing permissions and
9718 * limitations under the License.
9719 * =============================================================================
9720 */function Dz(n){const{inputs:e,backend:t,attrs:s}=n,{a:r,b:a,bias:o,preluActivationWeights:i}=e,{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:h}=s;let d,p,f;const g=[];d=V1({inputs:{a:r,b:a},attrs:{transposeA:l,transposeB:u},backend:t}),o&&(p=Wr({inputs:{a:d,b:o},backend:t}),g.push(d),d=p),c&&(f=du(t,d,c,i,h),g.push(d),d=f);for(const y of g)t.disposeIntermediateTensorInfo(y);return d}const Az={kernelName:xo,backendName:"cpu",kernelFunc:Dz};/**
9721 * @license
9722 * Copyright 2020 Google LLC. All Rights Reserved.
9723 * Licensed under the Apache License, Version 2.0 (the License);
9724 * you may not use this file except in compliance with the License.
9725 * You may obtain a copy of the License at
9726 *
9727 * http://www.apache.org/licenses/LICENSE-2.0
9728 *
9729 * Unless required by applicable law or agreed to in writing, software
9730 * distributed under the License is distributed on an AS IS BASIS,
9731 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9732 * See the License for the specific language governing permissions and
9733 * limitations under the License.
9734 * =============================================================================
9735 */const Oz=Oe(Hr,n=>Math.acos(n)),_z={kernelName:Hr,backendName:"cpu",kernelFunc:Oz};/**
9736 * @license
9737 * Copyright 2020 Google LLC. All Rights Reserved.
9738 * Licensed under the Apache License, Version 2.0 (the License);
9739 * you may not use this file except in compliance with the License.
9740 * You may obtain a copy of the License at
9741 *
9742 * http://www.apache.org/licenses/LICENSE-2.0
9743 *
9744 * Unless required by applicable law or agreed to in writing, software
9745 * distributed under the License is distributed on an AS IS BASIS,
9746 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9747 * See the License for the specific language governing permissions and
9748 * limitations under the License.
9749 * =============================================================================
9750 */const Fz=Oe(jr,n=>Math.acosh(n)),Lz={kernelName:jr,backendName:"cpu",kernelFunc:Fz};/**
9751 * @license
9752 * Copyright 2020 Google LLC. All Rights Reserved.
9753 * Licensed under the Apache License, Version 2.0 (the "License");
9754 * you may not use this file except in compliance with the License.
9755 * You may obtain a copy of the License at
9756 *
9757 * http://www.apache.org/licenses/LICENSE-2.0
9758 *
9759 * Unless required by applicable law or agreed to in writing, software
9760 * distributed under the License is distributed on an "AS IS" BASIS,
9761 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9762 * See the License for the specific language governing permissions and
9763 * limitations under the License.
9764 * =============================================================================
9765 */function Pz(n){const{inputs:e,backend:t}=n,s=e;ue(e,"addN");const r=s.map(i=>t.data.get(i.dataId).values),a=$e(s[0].shape,s[0].dtype),o=a.values;for(let i=0;i<s.length;i++){const l=r[i];for(let u=0;u<o.length;u++)o[u]+=l[u]}return t.makeTensorInfo(a.shape,a.dtype,a.values)}const zz={kernelName:Do,backendName:"cpu",kernelFunc:Pz};/**
9766 * @license
9767 * Copyright 2020 Google LLC. All Rights Reserved.
9768 * Licensed under the Apache License, Version 2.0 (the "License");
9769 * you may not use this file except in compliance with the License.
9770 * You may obtain a copy of the License at
9771 *
9772 * http://www.apache.org/licenses/LICENSE-2.0
9773 *
9774 * Unless required by applicable law or agreed to in writing, software
9775 * distributed under the License is distributed on an "AS IS" BASIS,
9776 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9777 * See the License for the specific language governing permissions and
9778 * limitations under the License.
9779 * =============================================================================
9780 */function Vz(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s;ue(r,"all");const i=Ie(a,r.shape);let l=i;const u=Xe(l,r.shape.length);let c=r;u!=null&&(c=Gt({inputs:{x:r},backend:t,attrs:{perm:u}}),l=st(l.length,r.shape.length)),St("all",l,c.shape.length);const[h,d]=Ct(c.shape,l),p=H(d),f=hn(H(h),c.dtype),g=t.data.get(c.dataId).values;for(let y=0;y<f.length;++y){const x=y*p;let v=g[x];for(let b=0;b<p;++b){const C=g[x+b];v=v&&C}f[y]=v}
vendor: 4,476 bytes, lines 9780-9828
9780u!=null&&t.disposeIntermediateTensorInfo(c);const m=t.makeTensorInfo(h,c.dtype,f);if(o){const y=nt(h,i),x=Me({inputs:{x:m},backend:t,attrs:{shape:y}});return t.disposeIntermediateTensorInfo(m),x}return m}const Bz={kernelName:xu,backendName:"cpu",kernelFunc:Vz};/**
9781 * @license
9782 * Copyright 2020 Google LLC. All Rights Reserved.
9783 * Licensed under the Apache License, Version 2.0 (the "License");
9784 * you may not use this file except in compliance with the License.
9785 * You may obtain a copy of the License at
9786 *
9787 * http://www.apache.org/licenses/LICENSE-2.0
9788 *
9789 * Unless required by applicable law or agreed to in writing, software
9790 * distributed under the License is distributed on an "AS IS" BASIS,
9791 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9792 * See the License for the specific language governing permissions and
9793 * limitations under the License.
9794 * =============================================================================
9795 */function Mz(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s;ue(r,"any");const i=Ie(a,r.shape);let l=i;const u=Xe(l,r.shape.length);let c=r;u!=null&&(c=Gt({inputs:{x:r},backend:t,attrs:{perm:u}}),l=st(l.length,r.shape.length)),St("any",l,c.shape.length);const[h,d]=Ct(c.shape,l),p=H(d),f=hn(H(h),c.dtype),g=t.data.get(c.dataId).values;for(let y=0;y<f.length;++y){const x=y*p;let v=g[x];for(let b=0;b<p;++b){const C=g[x+b];v=v||C}f[y]=v}u!=null&&t.disposeIntermediateTensorInfo(c);const m=t.makeTensorInfo(h,c.dtype,f);if(o){const y=nt(h,i),x=Me({inputs:{x:m},backend:t,attrs:{shape:y}});return t.disposeIntermediateTensorInfo(m),x}return m}const Wz={kernelName:bu,backendName:"cpu",kernelFunc:Mz};/**
9796 * @license
9797 * Copyright 2020 Google LLC. All Rights Reserved.
9798 * Licensed under the Apache License, Version 2.0 (the "License");
9799 * you may not use this file except in compliance with the License.
9800 * You may obtain a copy of the License at
9801 *
9802 * http://www.apache.org/licenses/LICENSE-2.0
9803 *
9804 * Unless required by applicable law or agreed to in writing, software
9805 * distributed under the License is distributed on an "AS IS" BASIS,
9806 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9807 * See the License for the specific language governing permissions and
9808 * limitations under the License.
9809 * =============================================================================
9810 */function Uz(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a}=s;ue(r,"argMax");let o=Ie(a,r.shape);const i=Xe(o,r.shape.length);let l=r;const u=[];i!=null&&(l=Gt({inputs:{x:r},backend:t,attrs:{perm:i}}),u.push(l),o=st(o.length,l.shape.length)),o=[o[0]],St("argMax",o,l.shape.length);const[c,h]=Ct(l.shape,o),d=H(c),p=hn(d,"int32"),f=H(h),g=t.data.get(l.dataId).values;for(let m=0;m<p.length;++m){const y=m*f;let x=g[y],v=0;for(let b=0;b<f;++b){const C=g[y+b];C>x&&(x=C,v=b)}p[m]=v}return u.forEach(m=>t.disposeIntermediateTensorInfo(m)),t.makeTensorInfo(c,"int32",p)}const Gz={kernelName:Ao,backendName:"cpu",kernelFunc:Uz};/**
9811 * @license
9812 * Copyright 2020 Google LLC. All Rights Reserved.
9813 * Licensed under the Apache License, Version 2.0 (the "License");
9814 * you may not use this file except in compliance with the License.
9815 * You may obtain a copy of the License at
9816 *
9817 * http://www.apache.org/licenses/LICENSE-2.0
9818 *
9819 * Unless required by applicable law or agreed to in writing, software
9820 * distributed under the License is distributed on an "AS IS" BASIS,
9821 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9822 * See the License for the specific language governing permissions and
9823 * limitations under the License.
9824 * =============================================================================
9825 */function Hz(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a}=s;ue(r,"argMin");let o=Ie(a,r.shape);const i=Xe(o,r.shape.length);let l=r;const u=[];i!=null&&(l=Gt({inputs:{x:r},backend:t,attrs:{perm:i}}),u.push(l),o=st(o.length,l.shape.length)),o=[o[0]],St("argMin",o,l.shape.length);const[c,h]=Ct(l.shape,o),d=H(c),p=hn(d,"int32"),f=H(h),g=t.data.get(l.dataId).values;for(let m=0;m<p.length;++m){const y=m*f;let x=g[y],v=0;for(let b=0;b<f;++b){const C=g[y+b];C<x&&(x=C,v=b)}p[m]=v}return u.forEach(m=>t.disposeIntermediateTensorInfo(m)),t.makeTensorInfo(c,"int32",p)}const jz={kernelName:Oo,backendName:"cpu",kernelFunc:Hz};/**
9826 * @license
9827 * Copyright 2020 Google LLC. All Rights Reserved.
9828 * Licensed under the Apache License, Version 2.0 (the License);
9829 * you may not use this file except in compliance with the License.
9830 * You may obtain a copy of the License at
9831 *
9832 * http://www.apache.org/licenses/LICENSE-2.0
9833 *
9834 * Unless required by applicable law or agreed to in writing, software
9835 * distributed under the License is distributed on an AS IS BASIS,
9836 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9837 * See the License for the specific language governing permissions and
9838 * limitations under the License.
9839 * =============================================================================
9840 */const qz=Oe(qr,n=>Math.asin(n)),Kz={kernelName:qr,backendName:"cpu",kernelFunc:qz};/**
9841 * @license
9842 * Copyright 2020 Google LLC. All Rights Reserved.
9843 * Licensed under the Apache License, Version 2.0 (the License);
9844 * you may not use this file except in compliance with the License.
9845 * You may obtain a copy of the License at
9846 *
9847 * http://www.apache.org/licenses/LICENSE-2.0
9848 *
9849 * Unless required by applicable law or agreed to in writing, software
9850 * distributed under the License is distributed on an AS IS BASIS,
9851 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9852 * See the License for the specific language governing permissions and
9853 * limitations under the License.
9854 * =============================================================================
9855 */const Xz=Oe(Kr,n=>Math.asinh(n)),Yz={kernelName:Kr,backendName:"cpu",kernelFunc:Xz};/**
9856 * @license
9857 * Copyright 2020 Google LLC. All Rights Reserved.
9858 * Licensed under the Apache License, Version 2.0 (the License);
9859 * you may not use this file except in compliance with the License.
9860 * You may obtain a copy of the License at
9861 *
9862 * http://www.apache.org/licenses/LICENSE-2.0
9863 *
9864 * Unless required by applicable law or agreed to in writing, software
9865 * distributed under the License is distributed on an AS IS BASIS,
9866 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9867 * See the License for the specific language governing permissions and
9868 * limitations under the License.
9869 * =============================================================================
9870 */const Jz=Oe(Xr,n=>Math.atan(n)),Zz={kernelName:Xr,backendName:"cpu",kernelFunc:Jz};/**
9871 * @license
9872 * Copyright 2020 Google LLC. All Rights Reserved.
9873 * Licensed under the Apache License, Version 2.0 (the License);
9874 * you may not use this file except in compliance with the License.
9875 * You may obtain a copy of the License at
9876 *
9877 * http://www.apache.org/licenses/LICENSE-2.0
9878 *
9879 * Unless required by applicable law or agreed to in writing, software
9880 * distributed under the License is distributed on an AS IS BASIS,
9881 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9882 * See the License for the specific language governing permissions and
9883 * limitations under the License.
9884 * =============================================================================
9885 */const Qz=Qe((n,e)=>Math.atan2(n,e)),e3=ut(Yr,Qz),t3={kernelName:Yr,backendName:"cpu",kernelFunc:e3};/**
9886 * @license
9887 * Copyright 2020 Google LLC. All Rights Reserved.
9888 * Licensed under the Apache License, Version 2.0 (the License);
9889 * you may not use this file except in compliance with the License.
9890 * You may obtain a copy of the License at
9891 *
9892 * http://www.apache.org/licenses/LICENSE-2.0
9893 *
9894 * Unless required by applicable law or agreed to in writing, software
9895 * distributed under the License is distributed on an AS IS BASIS,
9896 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9897 * See the License for the specific language governing permissions and
9898 * limitations under the License.
9899 * =============================================================================
9900 */const n3=Oe(Jr,n=>Math.atanh(n)),s3={kernelName:Jr,backendName:"cpu",kernelFunc:n3};/**
9901 * @license
9902 * Copyright 2020 Google LLC. All Rights Reserved.
9903 * Licensed under the Apache License, Version 2.0 (the "License");
9904 * you may not use this file except in compliance with the License.
9905 * You may obtain a copy of the License at
9906 *
9907 * http://www.apache.org/licenses/LICENSE-2.0
9908 *
9909 * Unless required by applicable law or agreed to in writing, softw
9909are
9910 * distributed under the License is distributed on an "AS IS" BASIS,
9911 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9912 * See the License for the specific language governing permissions and
9913 * limitations under the License.
9914 * =============================================================================
9915 */function ng(n,e,t,s,r,a){const o=r.strideHeight,i=r.strideWidth,l=r.dilationHeight,u=r.dilationWidth,c=r.effectiveFilterHeight,h=r.effectiveFilterWidth,d=r.padInfo.top,p=r.padInfo.left,f=a==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=$e(r.outShape,t),m=g.values,y=r.outShape[1]*r.outShape[2]*r.outShape[3],x=r.outShape[2]*r.outShape[3],v=r.outShape[3];for(let b=0;b<r.batchSize;++b){const C=b*y,$=b*s[0];for(let S=0;S<r.inChannels;++S)for(let k=0;k<r.outHeight;++k){const T=k*o-d,E=Math.max(0,T),_=Math.min(r.inHeight,c+T),z=C+k*x;for(let P=0;P<r.outWidth;++P){const V=P*i-p,B=Math.max(0,V),M=Math.min(r.inWidth,h+V);let j=f,U=0,q=0;for(let Y=E;Y<_;Y+=l){const Z=$+Y*s[1];for(let J=B;J<M;J+=u){const re=Z+J*s[2],Q=n[re+S];a==="max"&&Q>j?j=Q:a==="avg"&&(U+=Q,q++)}if(isNaN(j))break}const X=z+P*v+S;m[X]=a==="avg"?U/q:j}}}return g}function B1(n,e,t,s,r=!1,a=!1){const o=$e(s.outShape,"int32"),i=s.strideHeight,l=s.strideWidth,u=s.dilationHeight,c=s.dilationWidth,h=s.effectiveFilterHeight,d=s.effectiveFilterWidth,p=s.padInfo.top,f=s.padInfo.left,g=$e(e,t,n);for(let m=0;m<s.batchSize;++m)for(let y=0;y<s.inChannels;++y)for(let x=0;x<s.outHeight;++x){const v=x*i-p;let b=v;for(;b<0;)b+=u;const C=Math.min(s.inHeight,h+v);for(let $=0;$<s.outWidth;++$){const S=$*l-f;let k=S;for(;k<0;)k+=c;const T=Math.min(s.inWidth,d+S);let E=Number.NEGATIVE_INFINITY,_=-1;for(let z=b;z<C;z+=u){const P=z-v;for(let V=k;V<T;V+=c){const B=V-S,M=g.get(m,z,V,y);M>E&&(E=M,r?_=a?((m*s.inHeight+z)*s.inWidth+V)*s.inChannels+y:(z*s.inWidth+V)*s.inChannels+y:_=P*d+B)}}o.set(_,m,x,$,y)}}return o}function M1(n,e,t,s,r,a){const o=r.strideDepth,i=r.strideHeight,l=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,h=r.dilationWidth,d=r.effectiveFilterDepth,p=r.effectiveFilterHeight,f=r.effectiveFilterWidth,g=r.padInfo.front,m=r.padInfo.top,y=r.padInfo.left,x=a==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,v=$e(r.outShape,t),b=v.values,C=r.outShape[1]*r.outShape[2]*r.outShape[3]*r.outShape[4],$=r.outShape[2]*r.outShape[3]*r.outShape[4],S=r.outShape[3]*r.outShape[4],k=r.outShape[4];for(let T=0;T<r.batchSize;++T){const E=T*C,_=T*s[0];for(let z=0;z<r.inChannels;++z)for(let P=0;P<r.outDepth;++P){const V=P*o-g;let B=V;for(;B<0;)B+=u;const M=Math.min(r.inDepth,d+V),j=E+P*$;for(let U=0;U<r.outHeight;++U){const q=U*i-m;let X=q;for(;X<0;)X+=c;const Y=Math.min(r.inHeight,p+q),Z=j+U*S;for(let J=0;J<r.outWidth;++J){const re=J*l-y;let Q=re;for(;Q<0;)Q+=h;const ae=Math.min(r.inWidth,f+re),ce=Z+J*k;let me=x,de=0,be=0;for(let De=B;De<M;De+=u){const Pe=_+De*s[1];for(let Ke=X;Ke<Y;Ke+=c){const ze=Pe+Ke*s[2];for(let _e=Q;_e<ae;_e+=h){const He=ze+_e*s[3],We=n[He+z];if(a==="max"&&We>me?me=We:a==="avg"&&(de+=We,be++),isNaN(me))break}if(isNaN(me))break}if(isNaN(me))break}const we=ce+z;b[we]=a==="avg"?de/Math.max(be,1):me}}}}return v}function r3(n,e){const t=$e(e.outShape,"int32"),s=e.strideDepth,r=e.strideHeight,a=e.strideWidth,o=e.dilationDepth,i=e.dilationHeight,l=e.dilationWidth,u=e.effectiveFilterDepth,c=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=e.padInfo.front,p=e.padInfo.top,f=e.padInfo.left;for(let g=0;g<e.batchSize;++g)for(let m=0;m<e.inChannels;++m)for(let y=0;y<e.outDepth;++y){const x=y*s-d;let v=x;for(;v<0;)v+=o;const b=Math.min(e.inDepth,u+x);for(let C=0;C<e.outHeight;++C){const $=C*r-p;let S=$;for(;S<0;)S+=i;const k=Math.min(e.inHeight,c+$);for(let T=0;T<e.outWidth;++T){const E=T*a-f;let _=E;for(;_<0;)_+=l;const z=Math.min(e.inWidth,h+E);let P=Number.NEGATIVE_INFINITY,V=-1;for(let B=v;B<b;B+=o){const M=B-x;for(let j=S;j<k;j+=i){const U=j-$;for(let q=_;q<z;q+=l){const X=q-E,Y=n.get(g,B,j,q,m);Y>=P&&(P=Y,V=M*c*h+U*c+X)}}}t.set(V,g,y,C,T,m)}}}return t}/**
9916 * @license
9917 * Copyright 2020 Google LLC. All Rights Reserved.
9918 * Licensed under the Apache License, Version 2.0 (the "License");
9919 * you may not use this file except in compliance with the License.
9920 * You may obtain a copy of the License at
9921 *
9922 * http://www.apache.org/licenses/LICENSE-2.0
9923 *
9924 * Unless required by applicable law or agreed to in writing, software
9925 * distributed under the License is distributed on an "AS IS" BASIS,
9926 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9927 * See the License for the specific language governing permissions and
9928 * limitations under the License.
9929 * =============================================================================
9930 */function a3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e;ue(r,"avgPool");const{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;I(It(o,u),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);const c=_n(r.shape,a,o,u,i,l);let h;if(c.filterWidth===1&&c.filterHeight===1&&ke(c.inShape,c.outShape))h=jn({inputs:{x:r},backend:t});else{const d=t.data.get(r.dataId).values,p=fe(r.shape),f=ng(d,r.shape,r.dtype,p,c,"avg");h=t.makeTensorInfo(c.outShape,r.dtype,f.values)}return h}const o3={kernelName:_o,backendName:"cpu",kernelFunc:a3};/**
9931 * @license
9932 * Copyright 2020 Google LLC. All Rights Reserved.
9933 * Licensed under the Apache License, Version 2.0 (the "License");
9934 * you may not use this file except in compliance with the License.
9935 * You may obtain a copy of the License at
9936 *
9937 * http://www.apache.org/licenses/LICENSE-2.0
9938 *
9939 * Unless required by applicable law or agreed to in writing, software
9940 * distributed under the License is distributed on an "AS IS" BASIS,
9941 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9942 * See the License for the specific language governing permissions and
9943 * limitations under the License.
9944 * =============================================================================
9945 */function i3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=s;ue(r,"avgPool3d");const c=Fs(r.shape,a,o,1,i,l,u),h=t.data.get(r.dataId).values,d=M1(h,r.shape,r.dtype,fe(r.shape),c,"avg");return t.makeTensorInfo(d.shape,"float32",d.values)}const l3={kernelName:Fo,backendName:"cpu",kernelFunc:i3};/**
9946 * @license
9947 * Copyright 2020 Google LLC. All Rights Reserved.
9948 * Licensed under the Apache License, Version 2.0 (the "License");
9949 * you may not use this file except in compliance with the License.
9950 * You may obtain a copy of the License at
9951 *
9952 * http://www.apache.org/licenses/LICENSE-2.0
9953 *
9954 * Unless required by applicable law or agreed to in writing, software
9955 * distributed under the License is distributed on an "AS IS" BASIS,
9956 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9957 * See the License for the specific language governing permissions and
9958 * limitations under the License.
9959 * =============================================================================
9960 */function u3(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a}=e,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=s;ue([r,a],"avgPool3DGrad");const c=Fs(a.shape,o,i,1,l,u),h=c.strideDepth,d=c.strideHeight,p=c.strideWidth,f=c.filterDepth,g=c.filterHeight,m=c.filterWidth,y=c.dilationDepth,x=c.dilationHeight,v=c.dilationWidth,b=c.effectiveFilterDepth,C=c.effectiveFilterHeight,$=c.effectiveFilterWidth,S=b-1-c.padInfo.front,k=$-1-c.padInfo.left,T=C-1-c.padInfo.top,E=$e(a.shape,"float32"),_=1/(f*g*m),z=t.bufferSync(r);for(let P=0;P<c.batchSize;++P)for(let V=0;V<c.inChannels;++V)for(let B=0;B<c.inDepth;++B)for(let M=0;M<c.inHeight;++M)for(let j=0;j<c.inWidth;++j){const U=B-S,q=M-T,X=j-k;let Y=0;for(let Z=0;Z<b;Z+=y){const J=(U+Z)/h;if(!(J<0||J>=c.outDepth||Math.floor(J)!==J))for(let re=0;re<C;re+=x){const Q=(q+re)/d;if(!(Q<0||Q>=c.outHeight||Math.floor(Q)!==Q))for(let ae=0;ae<$;ae+=v){const ce=(X+ae)/p;if(ce<0||ce>=c.outWidth||Math.floor(ce)!==ce)continue;const me=z.get(P,J,Q,ce,V);Y+=me}}}E.set(Y*_,P,B,M,j,V)}return t.makeTensorInfo(E.shape,E.dtype,E.values)}const c3={kernelName:fc,backendName:"cpu",kernelFunc:u3};/**
9961 * @license
9962 * Copyright 2020 Google LLC. All Rights Reserved.
9963 * Licensed under the Apache License, Version 2.0 (the "License");
9964 * you may not use this file except in compliance with the License.
9965 * You may obtain a copy of the License at
9966 *
9967 * http://www.apache.org/licenses/LICENSE-2.0
9968 *
9969 * Unless required by applicable law or agreed to in writing, software
9970 * distributed under the License is distributed on an "AS IS" BASIS,
9971 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9972 * See the License for the specific language governing permissions and
9973 * limitations under the License.
9974 * =============================================================================
9975 */function h3(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a}=e,o=a;ue([r,a],"avgPoolGrad");const{filterSize:i,strides:l,pad:u}=s,c=_n(o.shape,i,l,1,u),h=c.strideHeight,d=c.strideWidth,p=c.filterHeight,f=c.filterWidth,g=c.dilationHeight,m=c.dilationWidth,y=c.effectiveFilterHeight,x=c.effectiveFilterWidth,v=x-1-c.padInfo.left,b=y-1-c.padInfo.top,C=$e(o.shape,"float32"),$=1/(p*f),S=t.data.get(r.dataId).values,k=$e(r.shape,"float32",S);for(let T=0;T<c.batchSize;++T)for(let E=0;E<c.inChannels;++E)for(let _=0;_<c.inHeight;++_)for(let z=0;z<c.inWidth;++z){const P=_-b,V=z-v;let B=0;for(let M=0;M<y;M+=g){const j=(P+M)/h;if(!(j<0||j>=c.outHeight||Math.floor(j)!==j))for(let U=0;U<x;U+=m){const q=(V+U)/d;if(q<0||q>=c.outWidth||Math.floor(q)!==q)continue;const X=k.get(T,j,q,E);B+=X}}C.set(B*$,T,_,z,E)}return t.makeTensorInfo(C.shape,C.dtype,C.values)}const d3={kernelName:mc,backendName:"cpu",kernelFunc:h3};/**
9976 * @license
9977 * Copyright 2020 Google LLC. All Rights Reserved.
9978 * Licensed under the Apache License, Version 2.0 (the "License");
9979 * you may not use this file except in compliance with the License.
9980 * You may obtain a copy of the License at
9981 *
9982 * http://www.apache.org/licenses/LICENSE-2.0
9983 *
9984 * Unless required by applicable law or agreed to in writing, software
9985 * distributed under the License is distributed on an "AS IS" BASIS,
9986 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9987 * See the License for the specific language governing permissions and
9988 * limitations under the License.
9989 * =============================================================================
9990 */function p3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,scale:a,offset:o,mean:i,variance:l}=e;I(i.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(o==null||i.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(a==null||i.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),ue([r,i,l,a,o],"batchNorm");let{varianceEpsilon:u}=s;u==null&&(u=.001);const c=t.data.get(r.dataId).values,h=t.data.get(i.dataId).values,d=t.data.get(l.dataId).values,p=a?t.data.get(a.dataId).values:new Float32Array([1]),f=o?t.data.get(o.dataId).values:new Float32Array([0]),g=new Float32Array(c.length),m=f.length,y=p.length,x=d.length,v=h.length;let b=0,C=0,$=0,S=0;for(let k=0;k<c.length;++k)g[k]=f[b++]+(c[k]-h[C++])*p[$++]/Math.sqrt(d[S++]+u),b>=m&&(b=0),C>=v&&(C=0),$>=y&&($=0),S>=x&&(S=0);return t.makeTensorInfo(r.shape,r.dtype,g)}const f3={kernelName:Vo,backendName:"cpu",kernelFunc:p3};/**
9991 * @license
9992 * Copyright 2020 Google LLC. All Rights Reserved.
9993 * Licensed under the Apache License, Version 2.0 (the "License");
9994 * you may not use this file except in compliance with the License.
9995 * You may obtain a copy of the License at
9996 *
9997 * http://www.apache.org/licenses/LICENSE-2.0
9998 *
9999 * Unless required by applicable law or agreed to in writing, software
10000 * distributed under the License is distributed on an "AS IS" BASIS,
10001 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10002 * See the License for the specific language governing permissions and
10003 * limitations under the License.
10004 * =============================================================================
10005 */function m3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{blockShape:a,crops:o}=s;ue([r],"batchToSpaceND");const i=a.reduce((y,x)=>y*x),l=Fc(r.shape,a,i),u=Lc(l.length,a.length),c=Pc(r.shape,a,i),h=Nx(o,a.length),d=Ix(c,o,a.length),p=Me({inputs:{x:r},backend:t,attrs:{shape:l}}),f=Gt({inputs:{x:p},backend:t,attrs:{perm:u}}),g=Me({inputs:{x:f},backend:t,attrs:{shape:c}}),m=Ar({inputs:{x:g},backend:t,attrs:{begin:h,size:d}});
vendor: 4,176 bytes, lines 10005-10068
10005return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),m}const g3={kernelName:zo,backendName:"cpu",kernelFunc:m3};/**
10006 * @license
10007 * Copyright 2020 Google LLC. All Rights Reserved.
10008 * Licensed under the Apache License, Version 2.0 (the "License");
10009 * you may not use this file except in compliance with the License.
10010 * You may obtain a copy of the License at
10011 *
10012 * http://www.apache.org/licenses/LICENSE-2.0
10013 *
10014 * Unless required by applicable law or agreed to in writing, software
10015 * distributed under the License is distributed on an "AS IS" BASIS,
10016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10017 * See the License for the specific language governing permissions and
10018 * limitations under the License.
10019 * =============================================================================
10020 */function y3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,weights:a}=e,{size:o}=s,i=t.data.get(r.dataId).values,l=t.data.get(a.dataId).values,u=Jm(i,l,a.dtype,a.shape,o);return t.makeTensorInfo([o],a.dtype,u)}const x3={kernelName:vu,backendName:"cpu",kernelFunc:y3};/**
10021 * @license
10022 * Copyright 2021 Google LLC. All Rights Reserved.
10023 * Licensed under the Apache License, Version 2.0 (the "License");
10024 * you may not use this file except in compliance with the License.
10025 * You may obtain a copy of the License at
10026 *
10027 * http://www.apache.org/licenses/LICENSE-2.0
10028 *
10029 * Unless required by applicable law or agreed to in writing, software
10030 * distributed under the License is distributed on an "AS IS" BASIS,
10031 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10032 * See the License for the specific language governing permissions and
10033 * limitations under the License.
10034 * =============================================================================
10035 */function b3(n){const{inputs:e,backend:t}=n,{s0:s,s1:r}=e,a=t.data.get(s.dataId).values,o=t.data.get(r.dataId).values,i=xe(Array.from(a),Array.from(o));return t.makeTensorInfo([i.length],"int32",Int32Array.from(i))}const w3={kernelName:Cu,backendName:"cpu",kernelFunc:b3};/**
10036 * @license
10037 * Copyright 2020 Google LLC. All Rights Reserved.
10038 * Licensed under the Apache License, Version 2.0 (the License);
10039 * you may not use this file except in compliance with the License.
10040 * You may obtain a copy of the License at
10041 *
10042 * http://www.apache.org/licenses/LICENSE-2.0
10043 *
10044 * Unless required by applicable law or agreed to in writing, software
10045 * distributed under the License is distributed on an AS IS BASIS,
10046 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10047 * See the License for the specific language governing permissions and
10048 * limitations under the License.
10049 * =============================================================================
10050 */const v3=Oe(na,(n,e)=>{const t=e;return n>t.clipValueMax?t.clipValueMax:n<t.clipValueMin?t.clipValueMin:n}),C3={kernelName:na,backendName:"cpu",kernelFunc:v3};/**
10051 * @license
10052 * Copyright 2020 Google LLC. All Rights Reserved.
10053 * Licensed under the Apache License, Version 2.0 (the License);
10054 * you may not use this file except in compliance with the License.
10055 * You may obtain a copy of the License at
10056 *
10057 * http://www.apache.org/licenses/LICENSE-2.0
10058 *
10059 * Unless required by applicable law or agreed to in writing, software
10060 * distributed under the License is distributed on an AS IS BASIS,
10061 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10062 * See the License for the specific language governing permissions and
10063 * limitations under the License.
10064 * =============================================================================
10065 */const $3=n=>{const{x:e}=n.inputs,t=n.backend,s=new Float32Array(H(e.shape)),r=t.data.get(e.dataId),a=r.complexTensorInfos.real,o=r.complexTensorInfos.imag,i=t.data.get(a.dataId).values,l=t.data.get(o.dataId).values;for(let u=0;u<i.length;u++){const c=i[u],h=l[u];s[u]=Math.hypot(c,h)}return t.makeOutput(s,e.shape,"float32")},N3={kernelName:yc,backendName:"cpu",kernelFunc:$3};/**
10066 * @license
10067 * Copyright 2020 Google LLC. All Rights Reserved.
10068 * Licensed under the Apache License, Version 2.0 (the "License");
10069 * you may not use this file except in compliance with the License.
10070 * You may obtain a copy of the License at
10071 *
10072 * http://www.apache.org/licenses/LICENSE-2.0
10073 *
10074 * Unless required by applicable law or agreed to in writing, software
10075 * distributed under the License is distributed on an "AS IS" BASIS,
10076 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10077 * See the License for the specific language governing permissions and
10078 * limitations under the License.
10079 * =============================================================================
10080 */function Ur(n){const{inputs:e,backend:t}=n,{input:s}=e,r=t.data.get(s.dataId).complexTensorInfos.imag,a=t.data.get(r.dataId).values;return t.makeTensorInfo(r.shape,r.dtype,a)}const I3={kernelName:Eu,backendName:"cpu",kernelFunc:Ur};/**
10081 * @license
10082 * Copyright 2020 Google LLC. All Rights Reserved.
10083 * Licensed under the Apache License, Version 2.0 (the "License");
10084 * you may not use this file except in compliance with the License.
10085 * You may obtain a copy of the License at
10086 *
10087 * http://www.apache.org/licenses/LICENSE-2.0
10088 *
10089 * Unless required by applicable law or agreed to in writing, software
10090 * distributed under the License is distributed on an "AS IS" BASIS,
10091 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10092 * See the License for the specific language governing permissions and
10093 * limitations under the License.
10094 * =============================================================================
10095 */function Gr(n){const{inputs:e,backend:t,attrs:s}=n,{axis:r}=s,a=Ie(r,e[0].shape)[0],o=e.map(g=>g.shape);Sx(o,a);let i=ns(e.map(g=>g.shape),a);if(H(i)===0)return t.makeTensorInfo(i,e[0].dtype,[]);const l=e.filter(g=>H(g.shape)>0);if(l.length===1)return jn({inputs:{x:l[0]},backend:t});if(l[0].dtype==="complex64"){const g=l.map(b=>ur({inputs:{input:b},backend:t})),m=l.map(b=>Ur({inputs:{input:b},backend:t})),y=Gr({inputs:g,backend:t,attrs:{axis:a}}),x=Gr({inputs:m,backend:t,attrs:{axis:a}}),v=Xt({inputs:{real:y,imag:x},backend:t});return g.forEach(b=>t.disposeIntermediateTensorInfo(b)),m.forEach(b=>t.disposeIntermediateTensorInfo(b)),t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(x),v}const u=l.map(g=>{const y=[-1,H(g.shape.slice(a))];return Me({inputs:{x:g},backend:t,attrs:{shape:y}})}),c=u.map(g=>({vals:t.data.get(g.dataId).values,shape:g.shape}));i=ns(u.map(g=>g.shape),1);const h=u[0].shape[0]===1,d=yx(c,i,e[0].dtype,h),p=ns(l.map(g=>g.shape),a),f=t.makeTensorInfo(p,e[0].dtype,d);return u.forEach(g=>t.disposeIntermediateTensorInfo(g)),f}const S3={kernelName:Lo,backendName:"cpu",kernelFunc:Gr};/**
10096 * @license
10097 * Copyright 2020 Google LLC. All Rights Reserved.
10098 * Licensed under the Apache License, Version 2.0 (the "License");
10099 * you may not use this file except in compliance with the License.
10100 * You may obtain a copy of the License at
10101 *
10102 * http://www.apache.org/licenses/LICENSE-2.0
10103 *
10104 * Unless required by applicable law or agreed to in writing, software
10105 * distributed under the License is distributed on an "AS IS" BASIS,
10106 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10107 * See the License for the specific language governing permissions and
10108 * limitations under the License.
10109 * =============================================================================
10110 */function W1(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a}=e,{strides:o,pad:i,dataFormat:l,dilations:u,dimRoundingMode:c}=s;ue([r,a],"conv2d");const h=fr(l),d=Ft(r.shape,a.shape,o,u,i,c,!1,h),p=d.filterHeight,f=d.filterWidth,g=d.dilationHeight,m=d.dilationWidth,y=d.padInfo.left,x=d.padInfo.top,v=d.dataFormat==="channelsLast",b=new bt(d.outShape,r.dtype),C=fe(r.shape),$=fe(a.shape),S=C[0],k=v?C[1]:C[2],T=v?C[2]:1,E=v?1:C[1],_=b.strides[0],z=v?b.strides[1]:b.strides[2],P=v?b.strides[2]:1,V=v?1:b.strides[1],B=t.data.get(r.dataId).values,M=t.data.get(a.dataId).values,j=b.values;for(let U=0;U<d.batchSize;++U){const q=U*S,X=U*_;for(let Y=0;Y<d.outHeight;++Y){const Z=X+Y*z,J=Y*d.strideHeight-x;for(let re=0;re<p;++re){const Q=J+re*g;if(Q<0||Q>=d.inHeight)continue;const ae=re*$[0],ce=q+Q*k;for(let me=0;me<d.outWidth;++me){const de=Z+me*P,be=me*d.strideWidth-y;for(let we=0;we<f;++we){const De=be+we*m;if(De<0||De>=d.inWidth)continue;const Pe=ae+we*$[1],Ke=ce+De*T;let ze=Pe;for(let _e=0;_e<d.inChannels;++_e){const He=B[Ke+_e*E];for(let We=0;We<d.outChannels;++We)j[de+We*V]+=He*M[ze+We];ze+=d.outChannels}}}}}}return t.makeTensorInfo(b.shape,b.dtype,j)}const k3={kernelName:Mo,backendName:"cpu",kernelFunc:W1};/**
10111 * @license
10112 * Copyright 2020 Google LLC. All Rights Reserved.
10113 * Licensed under the Apache License, Version 2.0 (the "License");
10114 * you may not use this file except in compliance with the License.
10115 * You may obtain a copy of the License at
10116 *
10117 * http://www.apache.org/licenses/LICENSE-2.0
10118 *
10119 * Unless required by applicable law or agreed to in writing, software
10120 * distributed under the License is distributed on an "AS IS" BASIS,
10121 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10122 * See the License for the specific language governing permissions and
10123 * limitations under the License.
10124 * =============================================================================
10125 */function T3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,dy:a}=e,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,filterShape:c}=s;ue([r,a],"conv2dBackpropFilter");const h=fr(l),d=Ft(r.shape,c,o,1,i,u,!1,h),{strideHeight:p,strideWidth:f,filterHeight:g,filterWidth:m}=d,y=d.dataFormat==="channelsLast",x=new bt(d.filterShape,"float32"),v=d.padInfo.left,b=d.padInfo.top,C=t.data.get(r.dataId).values,$=t.data.get(a.dataId).values,S=new bt(r.shape,r.dtype,C),k=new bt(a.shape,a.dtype,$);for(let T=0;T<g;++T){const E=Math.max(0,Math.ceil((b-T)/p)),_=Math.min(d.outHeight,(d.inHeight+b-T)/p);for(let z=0;z<m;++z){const P=Math.max(0,Math.ceil((v-z)/f)),V=Math.min(d.outWidth,(d.inWidth+v-z)/f);for(let B=0;B<d.inChannels;++B)for(let M=0;M<d.outChannels;++M){let j=0;for(let U=0;U<d.batchSize;++U)for(let q=E;q<_;++q){const X=T+q*p-b;for(let Y=P;Y<V;++Y){const Z=z+Y*f-v;y?j+=S.get(U,X,Z,B)*k.get(U,q,Y,M):j+=S.get(U,B,X,Z)*k.get(U,M,q,Y)}}x.set(j,T,z,B,M)}}}return t.makeTensorInfo(x.shape,x.dtype,x.values)}const E3={kernelName:Ku,backendName:"cpu",kernelFunc:T3};/**
10126 * @license
10127 * Copyright 2020 Google LLC. All Rights Reserved.
10128 * Licensed under the Apache License, Version 2.0 (the "License");
10129 * you may not use this file except in compliance with the License.
10130 * You may obtain a copy of the License at
10131 *
10132 * http://www.apache.org/licenses/LICENSE-2.0
10133 *
10134 * Unless required by applicable law or agreed to in writing, software
10135 * distributed under the License is distributed on an "AS IS" BASIS,
10136 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10137 * See the License for the specific language governing permissions and
10138 * limitations under the License.
10139 * =============================================================================
10140 */function R3(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,filter:a}=e,{inputShape:o,strides:i,pad:l,dataFormat:u,dimRoundingMode:c}=s;ue([r,a],"conv2dBackpropInput");const h=fe(a.shape),d=fe(r.shape);let p=fr(u);const f=Ft(o,a.shape,i,1,l,c,!1,p),g=new bt(f.inShape,"float32"),m=g.values,y=t.data.get(r.dataId).values,x=t.data.get(a.dataId).values,[v,b,C]=h,{batchSize:$,filterHeight:S,filterWidth:k,inChannels:T,inHeight:E,inWidth:_,outChannels:z,outHeight:P,outWidth:V,strideHeight:B,strideWidth:M}=f;p=f.dataFormat;const j=S-1-f.padInfo.top,U=k-1-f.padInfo.left,q=p==="channelsLast",X=g.strides[0],Y=q?g.strides[1]:g.strides[2],Z=q?g.strides[2]:1,J=q?1:g.strides[1],re=d[0],Q=q?d[1]:d[2],ae=q?d[2]:1,ce=q?1:d[1];for(let me=0;me<$;++me)for(let de=0;de<T;++de)for(let be=0;be<E;++be){const we=be-j,De=Math.max(0,Math.ceil(we/B)),Pe=Math.min(P,(S+we)/B);for(let Ke=0;Ke<_;++Ke){const ze=Ke-U,_e=Math.max(0,Math.ceil(ze/M)),He=Math.min(V,(k+ze)/M);let We=0;for(let ft=De;ft<Pe;++ft){const cs=ft*B-we;for(let en=_e;en<He;++en){const Ms=en*M-ze,$n=re*me+Q*ft+ae*en,Jn=v*(S-1-cs)+b*(k-1-Ms)+C*de;for(let hs=0;hs<z;++hs){const ds=y[$n+ce*hs],ps=x[Jn+hs];We+=ds*ps}}}const Yn=X*me+Y*be+Z*Ke+J*de;m[Yn]=We}}return t.makeTensorInfo(g.shape,g.dtype,g.values)}const D3={kernelName:Wo,backendName:"cpu",kernelFunc:R3};/**
10141 * @license
10142 * Copyright 2020 Google LLC. All Rights Reserved.
10143 * Licensed under the Apache License, Version 2.0 (the "License");
10144 * you may not use this file except in compliance with the License.
10145 * You may obtain a copy of the License at
10146 *
10147 * http://www.apache.org/licenses/LICENSE-2.0
10148 *
10149 * Unless required by applicable law or agreed to in writing, software
10150 * distributed under the License is distributed on an "AS IS" BASIS,
10151 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10152 * See the License for the specific language governing permissions and
10153 * limitations under the License.
10154 * =============================================================================
10155 */function A3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a}=e,{strides:o,pad:i,dilations:l}=s;
vendor: 9,199 bytes, lines 10155-10233
10155ue([r,a],"conv3d");const u=Da(r.shape,a.shape,o,l,i),{filterDepth:c,filterHeight:h,filterWidth:d,dilationDepth:p,dilationHeight:f,dilationWidth:g,padInfo:m}=u,y=m.front,x=m.left,v=m.top,b=new bt(u.outShape,r.dtype),C=t.data.get(r.dataId).values,$=t.data.get(a.dataId).values,S=b.values,k=fe(r.shape),T=fe(a.shape);for(let E=0;E<u.batchSize;++E){const _=E*k[0],z=E*b.strides[0];for(let P=0;P<u.outDepth;++P){const V=z+P*b.strides[1],B=P*u.strideDepth-y;for(let M=0;M<c;++M){const j=B+M*p;if(j<0||j>=u.inDepth)continue;const U=M*T[0],q=_+j*k[1];for(let X=0;X<u.outHeight;++X){const Y=V+X*b.strides[2],Z=X*u.strideHeight-v;for(let J=0;J<h;++J){const re=Z+J*f;if(re<0||re>=u.inHeight)continue;const Q=U+J*T[1],ae=q+re*k[2];for(let ce=0;ce<u.outWidth;++ce){const me=Y+ce*u.outChannels,de=ce*u.strideWidth-x;for(let be=0;be<d;++be){const we=de+be*g;if(we<0||we>=u.inWidth)continue;const De=Q+be*T[2],Pe=ae+we*u.inChannels;let Ke=De;for(let ze=0;ze<u.inChannels;++ze){const _e=C[Pe+ze];for(let He=0;He<u.outChannels;++He)S[me+He]+=_e*$[Ke+He];Ke+=u.outChannels}}}}}}}}return t.makeTensorInfo(b.shape,b.dtype,b.values)}const O3={kernelName:Uo,backendName:"cpu",kernelFunc:A3};/**
10156 * @license
10157 * Copyright 2020 Google LLC. All Rights Reserved.
10158 * Licensed under the Apache License, Version 2.0 (the "License");
10159 * you may not use this file except in compliance with the License.
10160 * You may obtain a copy of the License at
10161 *
10162 * http://www.apache.org/licenses/LICENSE-2.0
10163 *
10164 * Unless required by applicable law or agreed to in writing, software
10165 * distributed under the License is distributed on an "AS IS" BASIS,
10166 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10167 * See the License for the specific language governing permissions and
10168 * limitations under the License.
10169 * =============================================================================
10170 */function _3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,dy:a}=e,{strides:o,pad:i,filterShape:l}=s;ue([r,a],"conv3dBackpropFilterV2");const u=fe(r.shape),c=fe(a.shape),h=Da(r.shape,l,o,1,i),d=h.strideDepth,p=h.strideHeight,f=h.strideWidth,g=h.filterDepth,m=h.filterHeight,y=h.filterWidth,x=new bt(h.filterShape,"float32"),v=x.values,[b,C,$,S]=x.strides,k=t.data.get(a.dataId).values,[T,E,_,z]=c,P=t.data.get(r.dataId).values,[V,B,M,j]=u,U=h.padInfo.front,q=h.padInfo.left,X=h.padInfo.top;for(let Y=0;Y<g;++Y){const Z=Math.max(0,Math.ceil((U-Y)/d)),J=Math.min(h.outDepth,(h.inDepth+U-Y)/d),re=Y*b;for(let Q=0;Q<m;++Q){const ae=Math.max(0,Math.ceil((X-Q)/p)),ce=Math.min(h.outHeight,(h.inHeight+X-Q)/p),me=Q*C+re;for(let de=0;de<y;++de){const be=Math.max(0,Math.ceil((q-de)/f)),we=Math.min(h.outWidth,(h.inWidth+q-de)/f),De=de*$+me;for(let Pe=0;Pe<h.inChannels;++Pe){const Ke=Pe*S+De;for(let ze=0;ze<h.outChannels;++ze){let _e=0;for(let He=0;He<h.batchSize;++He){const We=He*V,Yn=He*T;for(let ft=Z;ft<J;++ft){const en=(Y+ft*d-U)*B+We,Ms=ft*E+Yn;for(let $n=ae;$n<ce;++$n){const hs=(Q+$n*p-X)*M+en,ds=$n*_+Ms;for(let ps=be;ps<we;++ps){const Vh=(de+ps*f-q)*j+hs,Bh=ps*z+ds;_e+=P[Vh+Pe]*k[Bh+ze]}}}}v[Ke+ze]=_e}}}}}return t.makeTensorInfo(x.shape,x.dtype,x.values)}const F3={kernelName:xc,backendName:"cpu",kernelFunc:_3};/**
10171 * @license
10172 * Copyright 2020 Google LLC. All Rights Reserved.
10173 * Licensed under the Apache License, Version 2.0 (the "License");
10174 * you may not use this file except in compliance with the License.
10175 * You may obtain a copy of the License at
10176 *
10177 * http://www.apache.org/licenses/LICENSE-2.0
10178 *
10179 * Unless required by applicable law or agreed to in writing, software
10180 * distributed under the License is distributed on an "AS IS" BASIS,
10181 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10182 * See the License for the specific language governing permissions and
10183 * limitations under the License.
10184 * =============================================================================
10185 */function L3(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,filter:a}=e,{pad:o,strides:i,inputShape:l}=s;ue([r],"conv3dBackpropInputV2");const u=fe(r.shape),c=fe(a.shape),h=Da(l,a.shape,i,1,o),d=new bt(h.inShape,"float32"),p=d.values,[f,g,m,y]=d.strides,x=t.data.get(r.dataId).values,[v,b,C,$]=u,S=t.data.get(a.dataId).values,[k,T,E,_]=c,{batchSize:z,filterDepth:P,filterHeight:V,filterWidth:B,inChannels:M,inDepth:j,inHeight:U,inWidth:q,outChannels:X,outDepth:Y,outHeight:Z,outWidth:J,strideDepth:re,strideHeight:Q,strideWidth:ae}=h,ce=P-1-h.padInfo.front,me=V-1-h.padInfo.top,de=B-1-h.padInfo.left;for(let be=0;be<z;++be)for(let we=0;we<M;++we)for(let De=0;De<j;++De){const Pe=De-ce,Ke=Math.max(0,Math.ceil(Pe/re)),ze=Math.min(Y,(P+Pe)/re);for(let _e=0;_e<U;++_e){const He=_e-me,We=Math.max(0,Math.ceil(He/Q)),Yn=Math.min(Z,(V+He)/Q);for(let ft=0;ft<q;++ft){const cs=ft-de,en=Math.max(0,Math.ceil(cs/ae)),Ms=Math.min(J,(B+cs)/ae);let $n=0;for(let Jn=Ke;Jn<ze;++Jn){const hs=Jn*re-Pe;for(let ds=We;ds<Yn;++ds){const ps=ds*Q-He;for(let to=en;to<Ms;++to){const Vh=to*ae-cs,Bh=v*be+b*Jn+C*ds+$*to,NC=k*(P-1-hs)+T*(V-1-ps)+E*(B-1-Vh)+_*we;for(let Cl=0;Cl<X;++Cl){const IC=x[Bh+Cl],SC=S[NC+Cl];$n+=IC*SC}}}}p[f*be+g*De+m*_e+y*ft+we]=$n}}}return t.makeTensorInfo(d.shape,d.dtype,d.values)}const P3={kernelName:$u,backendName:"cpu",kernelFunc:L3};/**
10186 * @license
10187 * Copyright 2020 Google LLC. All Rights Reserved.
10188 * Licensed under the Apache License, Version 2.0 (the "License");
10189 * you may not use this file except in compliance with the License.
10190 * You may obtain a copy of the License at
10191 *
10192 * http://www.apache.org/licenses/LICENSE-2.0
10193 *
10194 * Unless required by applicable law or agreed to in writing, software
10195 * distributed under the License is distributed on an "AS IS" BASIS,
10196 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10197 * See the License for the specific language governing permissions and
10198 * limitations under the License.
10199 * =============================================================================
10200 */const z3=Oe(sa,n=>Math.cos(n)),V3={kernelName:sa,backendName:"cpu",kernelFunc:z3};/**
10201 * @license
10202 * Copyright 2020 Google LLC. All Rights Reserved.
10203 * Licensed under the Apache License, Version 2.0 (the License);
10204 * you may not use this file except in compliance with the License.
10205 * You may obtain a copy of the License at
10206 *
10207 * http://www.apache.org/licenses/LICENSE-2.0
10208 *
10209 * Unless required by applicable law or agreed to in writing, software
10210 * distributed under the License is distributed on an AS IS BASIS,
10211 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10212 * See the License for the specific language governing permissions and
10213 * limitations under the License.
10214 * =============================================================================
10215 */const B3=Oe(ra,n=>Math.cosh(n)),M3={kernelName:ra,backendName:"cpu",kernelFunc:B3};/**
10216 * @license
10217 * Copyright 2020 Google LLC. All Rights Reserved.
10218 * Licensed under the Apache License, Version 2.0 (the "License");
10219 * you may not use this file except in compliance with the License.
10220 * You may obtain a copy of the License at
10221 *
10222 * http://www.apache.org/licenses/LICENSE-2.0
10223 *
10224 * Unless required by applicable law or agreed to in writing, software
10225 * distributed under the License is distributed on an "AS IS" BASIS,
10226 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10227 * See the License for the specific language governing permissions and
10228 * limitations under the License.
10229 * =============================================================================
10230 */function W3(n){const{inputs:e,backend:t,attrs:s}=n,{image:r,boxes:a,boxInd:o}=e,{cropSize:i,method:l,extrapolationValue:u}=s,[c,h,d,p]=r.shape,f=a.shape[0],[g,m]=i,y=$e([f,g,m,p],"float32"),x=t.data.get(a.dataId).values,v=t.data.get(o.dataId).values,b=t.data.get(r.dataId).values,C=fe(r.shape),$=fe(y.shape);for(let S=0;S<f;S++){const k=S*4,T=x[k],E=x[k+1],_=x[k+2],z=x[k+3],P=v[S];if(P>=c)continue;const V=g>1?(_-T)*(h-1)/(g-1):0,B=m>1?(z-E)*(d-1)/(m-1):0;for(let M=0;M<g;M++){const j=g>1?T*(h-1)+M*V:.5*(T+_)*(h-1);if(j<0||j>h-1){for(let U=0;U<m;U++)for(let q=0;q<p;q++){const X=q+U*$[2]+M*$[1]+S*$[0];y.values[X]=u}continue}if(l==="bilinear"){const U=Math.floor(j),q=Math.ceil(j),X=j-U;for(let Y=0;Y<m;Y++){const Z=m>1?E*(d-1)+Y*B:.5*(E+z)*(d-1);if(Z<0||Z>d-1){for(let ae=0;ae<p;ae++){const ce=ae+Y*$[2]+M*$[1]+S*$[0];y.values[ce]=u}continue}const J=Math.floor(Z),re=Math.ceil(Z),Q=Z-J;for(let ae=0;ae<p;ae++){let ce=ae+J*C[2]+U*C[1]+P*C[0];const me=b[ce];ce=ae+re*C[2]+U*C[1]+P*C[0];const de=b[ce];ce=ae+J*C[2]+q*C[1]+P*C[0];const be=b[ce];ce=ae+re*C[2]+q*C[1]+P*C[0];const we=b[ce],De=me+(de-me)*Q,Pe=be+(we-be)*Q;ce=ae+Y*$[2]+M*$[1]+S*$[0],y.values[ce]=De+(Pe-De)*X}}}else for(let U=0;U<m;++U){const q=m>1?E*(d-1)+U*B:.5*(E+z)*(d-1);if(q<0||q>d-1){for(let Z=0;Z<p;Z++){const J=Z+U*$[2]+M*$[1]+S*$[0];y.values[J]=u}continue}const X=Math.round(q),Y=Math.round(j);for(let Z=0;Z<p;Z++){const J=Z+X*C[2]+Y*C[1]+P*C[0],re=Z+U*$[2]+M*$[1]+S*$[0];y.values[re]=b[J]}}}}return t.makeTensorInfo(y.shape,y.dtype,y.values)}const U3={kernelName:Ju,backendName:"cpu",kernelFunc:W3};/**
10231 * @license
10232 * Copyright 2022 Google LLC. All Rights Reserved.
10233 * Licensed under the Apache License, Version 2.0 (the "License");
10234 * you may not use this file except in compliance with the License.
10235 * You may obtain a copy of the License at
10236 *
10237 * http://www.apache.org/licenses/LICENSE-2.0
10238 *
10239 * Unless required by applicable law or agreed to in writing, software
10240 * distributed under the License is distributed on an "AS IS" BASIS,
10241 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10242 * See the License for the specific language governing permissions and
10243 * limitations under the License.
10244 * =============================================================================
10245 */function G3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,exclusive:o,reverse:i}=s;ue(r,"cumprod");const l=Xe([a],r.shape.length);let u=r;l!=null&&(u=Gt({inputs:{x:r},backend:t,attrs:{perm:l}}));const c=st(1,r.shape.length)[0];if(c!==u.shape.length-1)throw new Error(`backend.cumprod in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${c}`);const h=bn(u.dtype,"int32"),d=qy(H(u.shape),h),p=t.data.get(u.dataId).values,f=u.shape[u.shape.length-1],g=i?(y,x)=>y+f-x-1:(y,x)=>y+x;for(let y=0;y<p.length;y+=f)for(let x=0;x<f;x++){const v=g(y,x);if(x===0)d[v]=o?1:p[v];else{const b=g(y,x-1);d[v]=o?p[b]*d[b]:p[v]*d[b]}}const m=t.makeTensorInfo(u.shape,h,d);if(l!=null){const y=pr(l),x=Gt({inputs:{x:m},backend:t,attrs:{perm:y}});return t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(u),x}return m}const H3={kernelName:Nu,backendName:"cpu",kernelFunc:G3};/**
10246 * @license
10247 * Copyright 2020 Google LLC. All Rights Reserved.
10248 * Licensed under the Apache License, Version 2.0 (the "License");
10249 * you may not use this file except in compliance with the License.
10250 * You may obtain a copy of the License at
10251 *
10252 * http://www.apache.org/licenses/LICENSE-2.0
10253 *
10254 * Unless required by applicable law or agreed to in writing, software
10255 * distributed under the License is distributed on an "AS IS" BASIS,
10256 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10257 * See the License for the specific language governing permissions and
10258 * limitations under the License.
10259 * =============================================================================
10260 */function j3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,exclusive:o,reverse:i}=s;ue(r,"cumsum");const l=Xe([a],r.shape.length);let u=r;l!=null&&(u=Gt({inputs:{x:r},backend:t,attrs:{perm:l}}));const c=st(1,r.shape.length)[0];if(c!==u.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${c}`);const h=bn(u.dtype,"int32"),d=hn(H(u.shape),h),p=t.data.get(u.dataId).values,f=u.shape[u.shape.length-1],g=i?(y,x)=>y+f-x-1:(y,x)=>y+x;for(let y=0;y<p.length;y+=f)for(let x=0;x<f;x++){const v=g(y,x);if(x===0)d[v]=o?0:p[v];else{const b=g(y,x-1);d[v]=o?p[b]+d[b]:p[v]+d[b]}}const m=t.makeTensorInfo(u.shape,h,d);if(l!=null){const y=pr(l),x=Gt({inputs:{x:m},backend:t,attrs:{perm:y}});return t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(u),x}return m}const q3={kernelName:Go,backendName:"cpu",kernelFunc:j3};/**
10261 * @license
10262 * Copyright 2020 Google LLC. All Rights Reserved.
10263 * Licensed under the Apache License, Version 2.0 (the "License");
10264 * you may not use this file except in compliance with the License.
10265 * You may obtain a copy of the License at
10266 *
10267 * http://www.apache.org/licenses/LICENSE-2.0
10268 *
10269 * Unless required by applicable law or agreed to in writing, software
10270 * distributed under the License is distributed on an "AS IS" BASIS,
10271 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10272 * See the License for the specific language governing permissions and
10273 * limitations under the License.
10274 * =============================================================================
10275 */function K3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,weights:a}=e,{size:o,binaryOutput:i}=s;if(r.shape.length===1){const l=t.data.get(r.dataId).values,u=t.data.get(a.dataId).values,c=Jm(l,u,a.dtype,a.shape,o);return t.makeTensorInfo([o],a.dtype,c)}else if(r.shape.length===2){const l=t.bufferSync(r),u=t.bufferSync(a),c=K0(l,u,o,i);return t.makeTensorInfo(c.shape,a.dtype,c.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}const X3={kernelName:Iu,backendName:"cpu",kernelFunc:K3};/**
10276 * @license
10277 * Copyright 2020 Google LLC. All Rights Reserved.
10278 * Licensed under the Apache License, Version 2.0 (the "License");
10279 * you may not use this file except in compliance with the License.
10280 * You may obtain a copy of the License at
10281 *
10282 * http://www.apache.org/licenses/LICENSE-2.0
10283 *
10284 * Unless required by applicable law or agreed to in writing, software
10285 * distributed under the License is distributed on an "AS IS" BASIS,
10286 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10287 * See the License for the specific language governing permissions and
10288 * limitations under the License.
10289 * =============================================================================
10290 */function Y3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{blockSize:a,dataFormat:o}=s;I(o==="NHWC",()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${o}`);const i=r.shape[0],l=r.shape[1],u=r.shape[2],c=r.shape[3],h=l*a,d=u*a,p=c/(a*a),f=t.data.get(r.dataId).values,g=new Float32Array(i*h*d*p);let m=0;for(let y=0;y<i;++y)for(let x=0;x<h;++x){const v=Math.floor(x/a),b=x%a;for(let C=0;C<d;++C){const $=Math.floor(C/a),S=C%a,k=(b*a+S)*p;for(let T=0;T<p;++T){const _=T+k+c*($+u*(v+l*y));g[m++]=f[_]}}}return t.makeTensorInfo([i,h,d,p],r.dtype,g)}const J3={kernelName:Su,backendName:"cpu",kernelFunc:Y3};/**
10291 * @license
10292 * Copyright 2020 Google LLC. All Rights Reserved.
10293 * Licensed under the Apache License, Version 2.0 (the "License");
10294 * you may not use this file except in compliance with the License.
10295 * You may obtain a copy of the License at
10296 *
10297 * http://www.apache.org/licenses/LICENSE-2.0
10298 *
10299 * Unless required by applicable law or agreed to in writing, software
10300 * distributed under the License is distributed on an "AS IS" BASIS,
10301 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10302 * See the License for the specific language governing permissions and
10303 * limitations under the License.
10304 * =============================================================================
10305 */function U1(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a}=e,{strides:o,pad:i,dilations:l,dimRoundingMode:u}=s;ue([r,a],"depthwiseConv2DNative");const c=fe(r.shape),h=fe(a.shape);let d=l;d==null&&(d=[1,1]),I(It(o,d),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${d}'`);const p=Ft(r.shape,a.shape,o,d,i,u,!0),{filterHeight:f,filterWidth:g,dilationHeight:m,dilationWidth:y,padInfo:x}=p,v=x.left,b=x.top,C=p.outChannels/p.inChannels,$=new bt(p.outShape,r.dtype),S=t.data.get(r.dataId).values,k=t.data.get(a.dataId).values,T=$.values;for(let E=0;E<p.batchSize;++E){const _=E*c[0],z=E*$.strides[0];for(let P=0;P<p.outHeight;++P){const V=z+P*$.strides[1],B=P*p.strideHeight-b;for(let M=0;M<f;++M){const j=B+M*m;if(j<0||j>=p.inHeight)continue;const U=M*h[0],q=_+j*c[1];for(let X=0;X<p.outWidth;++X){const Y=V+X*$.strides[2],Z=X*p.strideWidth-v;for(let J=0;J<g;++J){const re=Z+J*y;if(re<0||re>=p.inWidth)continue;const Q=U+J*h[1],ae=q+re*p.inChannels;let ce=Y,me=Q;for(let de=0;de<p.inChannels;++de){const be=S[ae+de];for(let we=0;we<C;++we)T[ce+we]+=be*k[me+we];ce+=C,me+=C}}}}}}return t.makeTensorInfo($.shape,$.dtype,$.values)}const Z3={kernelName:Ho,backendName:"cpu",kernelFunc:U1};/**
10306 * @license
10307 * Copyright 2020 Google LLC. All Rights Reserved.
10308 * Licensed under the Apache License, Version 2.0 (the "License");
10309 * you may not use this file except in compliance with the License.
10310 * You may obtain a copy of the License at
10311 *
10312 * http://www.apache.org/licenses/LICENSE-2.0
10313 *
10314 * Unless required by applicable law or agreed to in writing, software
10315 * distributed under the License is distributed on an "AS IS" BASIS,
10316 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10317 * See the License for the specific language governing permissions and
10318 * limitations under the License.
10319 * =============================================================================
10320 */function Q3(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,dy:a}=e,{strides:o,dilations:i,pad:l,dimRoundingMode:u,filterShape:c}=s;ue([r,a],"depthwiseConv2dNativeBackpropFilter");const h=Ft(r.shape,c,o,i,l,u,!0),{strideHeight:d,strideWidth:p,filterHeight:f,filterWidth:g}
vendor: 4,309 bytes, lines 10320-10364
10320=h,m=new bt(h.filterShape,"float32"),y=h.padInfo.left,x=h.padInfo.top,v=h.outChannels/h.inChannels,b=t.data.get(r.dataId).values,C=new bt(r.shape,r.dtype,b),$=t.data.get(a.dataId).values,S=new bt(a.shape,a.dtype,$);for(let k=0;k<f;++k){const T=Math.max(0,Math.ceil((x-k)/d)),E=Math.min(h.outHeight,(h.inHeight+x-k)/d);for(let _=0;_<g;++_){const z=Math.max(0,Math.ceil((y-_)/p)),P=Math.min(h.outWidth,(h.inWidth+y-_)/p);for(let V=0;V<h.outChannels;++V){const B=Math.trunc(V/v),M=V%v;let j=0;for(let U=0;U<h.batchSize;++U)for(let q=T;q<E;++q){const X=k+q*d-x;for(let Y=z;Y<P;++Y){const Z=_+Y*p-y;j+=C.get(U,X,Z,B)*S.get(U,q,Y,V)}}m.set(j,k,_,B,M)}}}return t.makeTensorInfo(m.shape,m.dtype,m.values)}const eV={kernelName:Xu,backendName:"cpu",kernelFunc:Q3};/**
10321 * @license
10322 * Copyright 2020 Google LLC. All Rights Reserved.
10323 * Licensed under the Apache License, Version 2.0 (the "License");
10324 * you may not use this file except in compliance with the License.
10325 * You may obtain a copy of the License at
10326 *
10327 * http://www.apache.org/licenses/LICENSE-2.0
10328 *
10329 * Unless required by applicable law or agreed to in writing, software
10330 * distributed under the License is distributed on an "AS IS" BASIS,
10331 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10332 * See the License for the specific language governing permissions and
10333 * limitations under the License.
10334 * =============================================================================
10335 */function tV(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,filter:a}=e,{strides:o,dilations:i,pad:l,dimRoundingMode:u,inputShape:c}=s;ue([r,a],"depthwiseConv2DNativeBackpropInput");const h=fe(r.shape),d=fe(a.shape),p=Ft(c,a.shape,o,i,l,u,!0),f=new bt(p.inShape,"float32"),g=f.values,[m,y,x]=f.strides,v=t.data.get(r.dataId).values,[b,C,$]=h,S=t.data.get(a.dataId).values,[k,T,E]=d,{batchSize:_,filterHeight:z,filterWidth:P,inChannels:V,inHeight:B,inWidth:M,outChannels:j,outHeight:U,outWidth:q,strideHeight:X,strideWidth:Y}=p,Z=z-1-p.padInfo.top,J=P-1-p.padInfo.left,re=j/V;for(let Q=0;Q<_;++Q)for(let ae=0;ae<V;++ae)for(let ce=0;ce<B;++ce){const me=ce-Z,de=Math.max(0,Math.ceil(me/X)),be=Math.min(U,(z+me)/X);for(let we=0;we<M;++we){const De=we-J,Pe=Math.max(0,Math.ceil(De/Y)),Ke=Math.min(q,(P+De)/Y);let ze=0;for(let _e=de;_e<be;++_e){const He=_e*X-me;for(let We=Pe;We<Ke;++We){const Yn=We*Y-De,ft=b*Q+C*_e+$*We,cs=k*(z-1-He)+T*(P-1-Yn)+E*ae;for(let en=0;en<re;++en){const Ms=ae*re+en,$n=v[ft+Ms],Jn=S[cs+en];ze+=$n*Jn}}}g[m*Q+y*ce+x*we+ae]=ze}}return t.makeTensorInfo(f.shape,f.dtype,f.values)}const nV={kernelName:Yu,backendName:"cpu",kernelFunc:tV};/**
10336 * @license
10337 * Copyright 2020 Google LLC. All Rights Reserved.
10338 * Licensed under the Apache License, Version 2.0 (the "License");
10339 * you may not use this file except in compliance with the License.
10340 * You may obtain a copy of the License at
10341 *
10342 * http://www.apache.org/licenses/LICENSE-2.0
10343 *
10344 * Unless required by applicable law or agreed to in writing, software
10345 * distributed under the License is distributed on an "AS IS" BASIS,
10346 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10347 * See the License for the specific language governing permissions and
10348 * limitations under the License.
10349 * =============================================================================
10350 */function sV(n){const{inputs:e,backend:t}=n,{x:s}=e,r=H(s.shape),a=t.data.get(s.dataId).values,o=$e([r,r],s.dtype),i=o.values;for(let u=0;u<a.length;u++)i[u*r+u]=a[u];const l=[...s.shape,...s.shape];return t.makeTensorInfo(l,o.dtype,o.values)}const rV={kernelName:ku,backendName:"cpu",kernelFunc:sV};/**
10351 * @license
10352 * Copyright 2020 Google LLC. All Rights Reserved.
10353 * Licensed under the Apache License, Version 2.0 (the "License");
10354 * you may not use this file except in compliance with the License.
10355 * You may obtain a copy of the License at
10356 *
10357 * http://www.apache.org/licenses/LICENSE-2.0
10358 *
10359 * Unless required by applicable law or agreed to in writing, software
10360 * distributed under the License is distributed on an "AS IS" BASIS,
10361 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10362 * See the License for the specific language governing permissions and
10363 * limitations under the License.
10364 * =============================================================================
10365 */const aV={kernelName:jo,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:r}=n,{strides:a,pad:o,dilations:i}=t,l=e,u=l.data.get(s.dataId).values,c=s.shape.length,h=l.data.get(r.dataId).values,d=r.shape.length,{batchSize:p,inHeight:f,inWidth:g,inChannels:m,outHeight:y,outWidth:x,padInfo:v,strideHeight:b,strideWidth:C,filterHeight:$,filterWidth:S,dilationHeight:k,dilationWidth:T,outShape:E}=zc(s.shape,r.shape,a,o,"NHWC",i),_=H(E),z=E.length,P=Dt(s.dtype,_);for(let B=0;B<p;++B)for(let M=0;M<y;++M){const j=M*b-v.top;for(let U=0;U<x;++U){const q=U*C-v.left;for(let X=0;X<m;++X){let Y=Number.MIN_SAFE_INTEGER;for(let J=0;J<$;++J){const re=j+J*k;if(re>=0&&re<f)for(let Q=0;Q<S;++Q){const ae=q+Q*T;if(ae>=0&&ae<g){const ce=Wn([B,re,ae,X],c,fe(s.shape)),me=Wn([J,Q,X],d,fe(r.shape)),de=u[ce]+h[me];de>Y&&(Y=de)}}}const Z=Wn([B,M,U,X],z,fe(E));P[Z]=Y}}}return{dataId:l.write(_c(P,s.dtype),E,s.dtype),shape:E,dtype:s.dtype}}};/**
10366 * @license
10367 * Copyright 2020 Google LLC. All Rights Reserved.
10368 * Licensed under the Apache License, Version 2.0 (the "License");
10369 * you may not use this file except in compliance with the License.
10370 * You may obtain a copy of the License at
10371 *
10372 * http://www.apache.org/licenses/LICENSE-2.0
10373 *
10374 * Unless required by applicable law or agreed to in writing, software
10375 * distributed under the License is distributed on an "AS IS" BASIS,
10376 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10377 * See the License for the specific language governing permissions and
10378 * limitations under the License.
10379 * =============================================================================
10380 */const oV={kernelName:Kl,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:r,dy:a}=n,{strides:o,pad:i,dilations:l}=t,u=e,c=Zs(s.shape,u.data.get(s.dataId).values),h=Zs(r.shape,u.data.get(r.dataId).values),{batchSize:d,inHeight:p,inWidth:f,inChannels:g,outHeight:m,outWidth:y,padInfo:x,strideHeight:v,strideWidth:b,filterHeight:C,filterWidth:$,dilationHeight:S,dilationWidth:k,outShape:T}=zc(s.shape,r.shape,o,i,"NHWC",l);I(a.rank===T.length,()=>`Error in ${Kl}, dy must have the same rank as output ${T.length}, but got ${a.rank}`);const E=Zs(T,u.data.get(a.dataId).values),_=kx(r.shape,r.dtype);for(let P=0;P<d;++P)for(let V=0;V<m;++V){const B=V*v-x.top;for(let M=0;M<y;++M){const j=M*b-x.left;for(let U=0;U<g;++U){let q=Number.MIN_SAFE_INTEGER,X=0,Y=0;for(let Z=0;Z<C;++Z){const J=B+Z*S;if(J>=0&&J<p)for(let re=0;re<$;++re){const Q=j+re*k;if(Q>=0&&Q<f){const ae=c[P][J][Q][U]+h[Z][re][U];ae>q&&(q=ae,X=Z,Y=re)}}}_[X][Y][U]+=E[P][V][M][U]}}}return{dataId:u.write(_c(_,s.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};/**
10381 * @license
10382 * Copyright 2020 Google LLC. All Rights Reserved.
10383 * Licensed under the Apache License, Version 2.0 (the "License");
10384 * you may not use this file except in compliance with the License.
10385 * You may obtain a copy of the License at
10386 *
10387 * http://www.apache.org/licenses/LICENSE-2.0
10388 *
10389 * Unless required by applicable law or agreed to in writing, software
10390 * distributed under the License is distributed on an "AS IS" BASIS,
10391 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10392 * See the License for the specific language governing permissions and
10393 * limitations under the License.
10394 * =============================================================================
10395 */const iV={kernelName:Xl,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:s,filter:r,dy:a}=n,{strides:o,pad:i,dilations:l}=t,u=e,c=Zs(s.shape,u.data.get(s.dataId).values),h=Zs(r.shape,u.data.get(r.dataId).values),{batchSize:d,inHeight:p,inWidth:f,inChannels:g,outHeight:m,outWidth:y,padInfo:x,strideHeight:v,strideWidth:b,filterHeight:C,filterWidth:$,dilationHeight:S,dilationWidth:k,outShape:T}=zc(s.shape,r.shape,o,i,"NHWC",l);I(a.rank===T.length,()=>`Error in ${Xl}, dy must have the same rank as output ${T.length}, but got ${a.rank}`);const E=Zs(T,u.data.get(a.dataId).values),_=kx(s.shape,s.dtype);for(let P=0;P<d;++P)for(let V=0;V<m;++V){const B=V*v-x.top;for(let M=0;M<y;++M){const j=M*b-x.left;for(let U=0;U<g;++U){let q=Number.MIN_SAFE_INTEGER,X=B<0?0:B,Y=j<0?0:j;for(let Z=0;Z<C;++Z){const J=B+Z*S;if(J>=0&&J<p)for(let re=0;re<$;++re){const Q=j+re*k;if(Q>=0&&Q<f){const ae=c[P][J][Q][U]+h[Z][re][U];ae>q&&(q=ae,X=J,Y=Q)}}}_[P][X][Y][U]+=E[P][V][M][U]}}}return{dataId:u.write(_c(_,s.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};/**
10396 * @license
10397 * Copyright 2023 Google LLC.
10398 * Licensed under the Apache License, Version 2.0 (the "License");
10399 * you may not use this file except in compliance with the License.
10400 * You may obtain a copy of the License at
10401 *
10402 * http://www.apache.org/licenses/LICENSE-2.0
10403 *
10404 * Unless required by applicable law or agreed to in writing, software
10405 * distributed under the License is distributed on an "AS IS" BASIS,
10406 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10407 * See the License for the specific language governing permissions and
10408 * limitations under the License.
10409 * =============================================================================
10410 */function lV(n){const{inputs:e,backend:t,attrs:s}=n,{image:r}=e,{canvas:a,options:o}=s,{contextOptions:i,imageOptions:l}=o||{},u=(l==null?void 0:l.alpha)||1,c=(i==null?void 0:i.contextType)||"2d";if(c!=="2d")throw new Error(`Context type ${i.contextType} is not supported by the CPU backend.`);const h=a.getContext(c,(i==null?void 0:i.contextAttributes)||{});if(h==null)throw new Error(`Could not get the context with ${c} type.`);const[d,p]=r.shape.slice(0,2),f=r.shape.length===2?1:r.shape[2],g=t.data.get(r.dataId).values,m=r.dtype==="float32"?255:1,y=new Uint8ClampedArray(p*d*4);for(let v=0;v<d*p;++v){const b=[0,0,0,255*u];for(let $=0;$<f;$++){const S=g[v*f+$];if(r.dtype==="float32"){if(S<0||S>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${S}.`)}else if(r.dtype==="int32"&&(S<0||S>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${S}.`);f===1?(b[0]=S*m,b[1]=S*m,b[2]=S*m):b[$]=S*m}const C=v*4;y[C+0]=Math.round(b[0]),y[C+1]=Math.round(b[1]),y[C+2]=Math.round(b[2]),y[C+3]=Math.round(b[3])}a.width=p,a.height=d;const x=new ImageData(y,p,d);return h.putImageData(x,0,0),r}const uV={kernelName:dc,backendName:"cpu",kernelFunc:lV};/**
10411 * @license
10412 * Copyright 2020 Google LLC. All Rights Reserved.
10413 * Licensed under the Apache License, Version 2.0 (the "License");
10414 * you may not use this file except in compliance with the License.
10415 * You may obtain a copy of the License at
10416 *
10417 * http://www.apache.org/licenses/LICENSE-2.0
10418 *
10419 * Unless required by applicable law or agreed to in writing, software
10420 * distributed under the License is distributed on an "AS IS" BASIS,
10421 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10422 * See the License for the specific language governing permissions and
10423 * limitations under the License.
10424 * =============================================================================
10425 */function gl(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s;ue(r,"sum");let i;r.dtype==="bool"?i=Ds({inputs:{x:r},backend:t,attrs:{dtype:"int32"}}
vendor: 4,296 bytes, lines 10425-10473
10425):i=jn({inputs:{x:r},backend:t});const l=i.shape.length,u=Ie(a,i.shape),c=Xe(u,l);let h=u,d=i;c!=null&&(d=Gt({inputs:{x:i},backend:t,attrs:{perm:c}}),h=st(h.length,l)),St("sum",h,d.shape.length);const[p,f]=Ct(d.shape,h),g=bn(d.dtype,"int32");let m=cu(t,p,g);const y=H(f),x=t.data.get(m.dataId).values,v=t.data.get(d.dataId).values;for(let b=0;b<x.length;++b){const C=b*y;let $=0;for(let S=0;S<y;++S)$+=v[C+S];x[b]=$}if(o){const b=nt(m.shape,u),C=m;m=Me({inputs:{x:m},backend:t,attrs:{shape:b}}),t.disposeIntermediateTensorInfo(C)}return t.disposeIntermediateTensorInfo(i),c!=null&&t.disposeIntermediateTensorInfo(d),m}const cV={kernelName:Rc,backendName:"cpu",kernelFunc:gl};/**
10426 * @license
10427 * Copyright 2021 Google LLC. All Rights Reserved.
10428 * Licensed under the Apache License, Version 2.0 (the "License");
10429 * you may not use this file except in compliance with the License.
10430 * You may obtain a copy of the License at
10431 *
10432 * http://www.apache.org/licenses/LICENSE-2.0
10433 *
10434 * Unless required by applicable law or agreed to in writing, software
10435 * distributed under the License is distributed on an "AS IS" BASIS,
10436 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10437 * See the License for the specific language governing permissions and
10438 * limitations under the License.
10439 * =============================================================================
10440 */function hV(n){const{inputs:e,backend:t,attrs:s}=n,{equation:r}=s,a=e,{allDims:o,summedDims:i,idDims:l}=Tx(r,a.length);Ex(o.length,l,a);const{path:u,steps:c}=Rx(i,l),h=c.length;let d=null,p=o.length;const f=[];for(let g=0;g<h;++g){for(const m of c[g]){const{permutationIndices:y,expandDims:x}=Dx(p,l[m]);let v;Ax(y)?v=a[m]:(v=Gt({inputs:{x:a[m]},backend:t,attrs:{perm:y}}),f.push(v));const b=v.shape.slice();for(let C=0;C<x.length;++C)b.splice(x[C],0,1);ke(v.shape,b)||(v=Me({inputs:{x:v},backend:t,attrs:{shape:b}}),f.push(v)),d===null?d=v:(d=_h({inputs:{a:v,b:d},backend:t}),f.push(d))}g<h-1&&(u[g]>=0&&(d=gl({inputs:{x:d},backend:t,attrs:{axis:u[g]-(o.length-p),keepDims:!1}}),f.push(d)),p--)}for(const g of f)g!==d&&t.disposeIntermediateTensorInfo(g);return d}const dV={kernelName:Tu,backendName:"cpu",kernelFunc:hV};/**
10441 * @license
10442 * Copyright 2020 Google LLC. All Rights Reserved.
10443 * Licensed under the Apache License, Version 2.0 (the "License");
10444 * you may not use this file except in compliance with the License.
10445 * You may obtain a copy of the License at
10446 *
10447 * http://www.apache.org/licenses/LICENSE-2.0
10448 *
10449 * Unless required by applicable law or agreed to in writing, software
10450 * distributed under the License is distributed on an "AS IS" BASIS,
10451 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10452 * See the License for the specific language governing permissions and
10453 * limitations under the License.
10454 * =============================================================================
10455 */function pV(n){const{inputs:e,backend:t}=n,{dy:s,y:r}=e;ue([s,r],"eluGrad");const a=new Float32Array(H(r.shape)),o=t.data.get(r.dataId).values,i=t.data.get(s.dataId).values;for(let l=0;l<o.length;++l){const u=o[l];u>=0?a[l]=i[l]:a[l]=i[l]*(u+1)}return t.makeTensorInfo(r.shape,"float32",a)}const fV={kernelName:bc,backendName:"cpu",kernelFunc:pV};/**
10456 * @license
10457 * Copyright 2020 Google LLC. All Rights Reserved.
10458 * Licensed under the Apache License, Version 2.0 (the License);
10459 * you may not use this file except in compliance with the License.
10460 * You may obtain a copy of the License at
10461 *
10462 * http://www.apache.org/licenses/LICENSE-2.0
10463 *
10464 * Unless required by applicable law or agreed to in writing, software
10465 * distributed under the License is distributed on an AS IS BASIS,
10466 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10467 * See the License for the specific language governing permissions and
10468 * limitations under the License.
10469 * =============================================================================
10470 */const mV=zx,gV=Px,yV=Lx,xV=Fx,bV=_x,wV=Ox,vV=Oe(aa,n=>{const e=Math.sign(n),t=Math.abs(n),s=1/(1+mV*t);return e*(1-((((wV*s+bV)*s+xV)*s+yV)*s+gV)*s*Math.exp(-t*t))}),CV={kernelName:aa,backendName:"cpu",kernelFunc:vV};/**
10471 * @license
10472 * Copyright 2020 Google LLC. All Rights Reserved.
10473 * Licensed under the Apache License, Version 2.0 (the "License");
10474 * you may not use this file except in compliance with the License.
10475 * You may obtain a copy of the License at
10476 *
10477 * http://www.apache.org/licenses/LICENSE-2.0
10478 *
10479 * Unless required by applicable law or agreed to in writing, software
10480 * distributed under the License is distributed on an "AS IS" BASIS,
10481 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10482 * See the License for the specific language governing permissions and
10483 * limitations under the License.
10484 * =============================================================================
10485 */function pu(n){const{inputs:e,backend:t,attrs:s}=n,{input:r}=e,{dim:a}=s,o=r.shape.length,i=r.shape.slice();let l=a;return a<0&&(I(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+a+1),i.splice(l,0,1),Me({inputs:{x:r},backend:t,attrs:{shape:i}})}const $V={kernelName:Jo,backendName:"cpu",kernelFunc:pu};/**
10486 * @license
10487 * Copyright 2020 Google LLC. All Rights Reserved.
10488 * Licensed under the Apache License, Version 2.0 (the "License");
10489 * you may not use this file except in compliance with the License.
10490 * You may obtain a copy of the License at
10491 *
10492 * http://www.apache.org/licenses/LICENSE-2.0
10493 *
10494 * Unless required by applicable law or agreed to in writing, software
10495 * distributed under the License is distributed on an "AS IS" BASIS,
10496 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10497 * See the License for the specific language governing permissions and
10498 * limitations under the License.
10499 * =============================================================================
10500 */const NV=Qe((n,e)=>n/e),sg=ut(Oi,NV),$d={kernelName:Oi,backendName:"cpu",kernelFunc:sg};/**
10501 * @license
10502 * Copyright 2020 Google LLC. All Rights Reserved.
10503 * Licensed under the Apache License, Version 2.0 (the "License");
10504 * you may not use this file except in compliance with the License.
10505 * You may obtain a copy of the License at
10506 *
10507 * http://www.apache.org/licenses/LICENSE-2.0
10508 *
10509 * Unless required by applicable law or agreed to in writing, software
10510 * distributed under the License is distributed on an "AS IS" BASIS,
10511 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10512 * See the License for the specific language governing permissions and
10513 * limitations under the License.
10514 * =============================================================================
10515 */function G1(n,e,t){const s=n.shape,r=s[0],a=s[1],o=t.data.get(n.dataId),i=o.complexTensorInfos.real,l=o.complexTensorInfos.imag,u=[r,a],c=H(u),h=wt("float32",c),d=wt("float32",c);for(let m=0;m<r;m++){const y=Ar({inputs:{x:i},backend:t,attrs:{begin:[m,0],size:[1,a]}}),x=Ar({inputs:{x:l},backend:t,attrs:{begin:[m,0],size:[1,a]}}),v=Xt({inputs:{real:y,imag:x},backend:t}),{real:b,imag:C}=IV(v,e,t),$=Ns(b,C);for(let S=0;S<a;S++){const k=Vx($,S);h[m*a+S]=k.real,d[m*a+S]=k.imag}t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(x),t.disposeIntermediateTensorInfo(v)}const p=t.makeTensorInfo(u,"float32",h),f=t.makeTensorInfo(u,"float32",d),g=Xt({inputs:{real:p,imag:f},backend:t});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),g}function IV(n,e,t){const s=H(n.shape),r=t.data.get(n.dataId),a=t.data.get(r.complexTensorInfos.real.dataId).values,o=t.data.get(r.complexTensorInfos.imag.dataId).values;if(SV(s)){const i=Nd(a,o,s,e,t),l=[n.shape[0],n.shape[1]];if(e){const u=t.makeTensorInfo(l,"float32",i.real),c=t.makeTensorInfo(l,"float32",i.imag),h=t.makeTensorInfo([],"float32",_s(s,"float32")),d=jn({inputs:{x:h},backend:t}),p=$d.kernelFunc({inputs:{a:u,b:h},backend:t}),f=$d.kernelFunc({inputs:{a:c,b:d},backend:t}),g=t.data.get(p.dataId).values,m=t.data.get(f.dataId).values;return t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),{real:g,imag:m}}return i}else{const i=Ns(a,o),l=kV(i,s,e);return s$(l)}}function SV(n){return(n&n-1)===0}function Nd(n,e,t,s,r){if(t===1)return{real:n,imag:e};const a=Ns(n,e),o=t/2,i=r$(a),l=i.real,u=i.imag,c=[l.length],h=r.makeTensorInfo(c,"float32",l),d=r.makeTensorInfo(c,"float32",u),p=Xt({inputs:{real:h,imag:d},backend:r}),f=a$(a),g=f.real,m=f.imag,y=[g.length],x=r.makeTensorInfo(y,"float32",g),v=r.makeTensorInfo(y,"float32",m),b=Xt({inputs:{real:x,imag:v},backend:r}),C=Nd(l,u,o,s,r),$=C.real,S=C.imag,k=[$.length],T=r.makeTensorInfo(k,"float32",$),E=r.makeTensorInfo(k,"float32",S),_=Xt({inputs:{real:T,imag:E},backend:r}),z=Nd(g,m,o,s,r),P=z.real,V=z.imag,B=[P.length],M=r.makeTensorInfo(B,"float32",P),j=r.makeTensorInfo(B,"float32",V),U=Xt({inputs:{real:M,imag:j},backend:r}),q=o$(t,s),X=[q.real.length],Y=r.makeTensorInfo(X,"float32",q.real),Z=r.makeTensorInfo(X,"float32",q.imag),J=Xt({inputs:{real:Y,imag:Z},backend:r}
vendor: 4,202 bytes, lines 10515-10559
10515),re=_h({inputs:{a:J,b:U},backend:r}),Q=Wr({inputs:{a:_,b:re},backend:r}),ae=tg({inputs:{a:_,b:re},backend:r}),ce=ur({inputs:{input:Q},backend:r}),me=ur({inputs:{input:ae},backend:r}),de=Ur({inputs:{input:Q},backend:r}),be=Ur({inputs:{input:ae},backend:r}),we=Gr({inputs:[ce,me],backend:r,attrs:{axis:0}}),De=Gr({inputs:[de,be],backend:r,attrs:{axis:0}}),Pe=r.data.get(we.dataId).values,Ke=r.data.get(De.dataId).values;return r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(x),r.disposeIntermediateTensorInfo(v),r.disposeIntermediateTensorInfo(b),r.disposeIntermediateTensorInfo(T),r.disposeIntermediateTensorInfo(E),r.disposeIntermediateTensorInfo(_),r.disposeIntermediateTensorInfo(M),r.disposeIntermediateTensorInfo(j),r.disposeIntermediateTensorInfo(U),r.disposeIntermediateTensorInfo(Y),r.disposeIntermediateTensorInfo(Z),r.disposeIntermediateTensorInfo(J),r.disposeIntermediateTensorInfo(re),r.disposeIntermediateTensorInfo(Q),r.disposeIntermediateTensorInfo(ae),r.disposeIntermediateTensorInfo(ce),r.disposeIntermediateTensorInfo(de),r.disposeIntermediateTensorInfo(me),r.disposeIntermediateTensorInfo(be),r.disposeIntermediateTensorInfo(we),r.disposeIntermediateTensorInfo(De),{real:Pe,imag:Ke}}function kV(n,e,t){const s=new Float32Array(e*2);for(let r=0;r<e;r++){let a=0,o=0;for(let i=0;i<e;i++){const l=i$(r*i,e,t),u=Vx(n,i);a+=u.real*l.real-u.imag*l.imag,o+=u.real*l.imag+u.imag*l.real}t&&(a/=e,o/=e),l$(s,a,o,r)}return s}/**
10516 * @license
10517 * Copyright 2020 Google LLC. All Rights Reserved.
10518 * Licensed under the Apache License, Version 2.0 (the "License");
10519 * you may not use this file except in compliance with the License.
10520 * You may obtain a copy of the License at
10521 *
10522 * http://www.apache.org/licenses/LICENSE-2.0
10523 *
10524 * Unless required by applicable law or agreed to in writing, software
10525 * distributed under the License is distributed on an "AS IS" BASIS,
10526 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10527 * See the License for the specific language governing permissions and
10528 * limitations under the License.
10529 * =============================================================================
10530 */function TV(n){const{inputs:e,backend:t}=n,{input:s}=e,r=H(s.shape),a=s.shape[s.shape.length-1],o=r/a,i=Me({inputs:{x:s},backend:t,attrs:{shape:[o,a]}}),l=G1(i,!1,t),u=Me({inputs:{x:l},backend:t,attrs:{shape:s.shape}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(l),u}const EV={kernelName:Vu,backendName:"cpu",kernelFunc:TV};/**
10531 * @license
10532 * Copyright 2020 Google LLC. All Rights Reserved.
10533 * Licensed under the Apache License, Version 2.0 (the "License");
10534 * you may not use this file except in compliance with the License.
10535 * You may obtain a copy of the License at
10536 *
10537 * http://www.apache.org/licenses/LICENSE-2.0
10538 *
10539 * Unless required by applicable law or agreed to in writing, software
10540 * distributed under the License is distributed on an "AS IS" BASIS,
10541 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10542 * See the License for the specific language governing permissions and
10543 * limitations under the License.
10544 * =============================================================================
10545 */function rg(n){const{backend:e,attrs:t}=n,{shape:s,value:r,dtype:a}=t,o=a||Bx(r),i=Dt(o,H(s));return DV(i,r,o),e.makeTensorInfo(s,o,i)}const RV={kernelName:Zd,backendName:"cpu",kernelFunc:rg};function DV(n,e,t){n.fill(e)}/**
10546 * @license
10547 * Copyright 2020 Google LLC. All Rights Reserved.
10548 * Licensed under the Apache License, Version 2.0 (the "License");
10549 * you may not use this file except in compliance with the License.
10550 * You may obtain a copy of the License at
10551 *
10552 * http://www.apache.org/licenses/LICENSE-2.0
10553 *
10554 * Unless required by applicable law or agreed to in writing, software
10555 * distributed under the License is distributed on an "AS IS" BASIS,
10556 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10557 * See the License for the specific language governing permissions and
10558 * limitations under the License.
10559 * =============================================================================
10560 */const AV={kernelName:Zu,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:s}=n,r=t,a=wt(s.dtype,H(s.shape)),[o,i,l,u]=s.shape,c=r.data.get(s.dataId).values;for(let d=0;d<o;d++){const p=d*l*i*u;for(let f=0;f<i;f++){const g=f*(l*u);for(let m=0;m<l;m++){const y=m*u;for(let x=0;x<u;x++){const v=Math.round(l-m-1),b=p+g+y+x;let C=c[b];if(v>=0&&v<l){const $=v*u,S=p+g+$+x;C=c[S]}a[b]=C}}}}return{dataId:r.write(a,s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};/**
10561 * @license
10562 * Copyright 2020 Google LLC. All Rights Reserved.
10563 * Licensed under the Apache License, Version 2.0 (the "License");
10564 * you may not use this file except in compliance with the License.
10565 * You may obtain a copy of the License at
10566 *
10567 * http://www.apache.org/licenses/LICENSE-2.0
10568 *
10569 * Unless required by applicable law or agreed to in writing, software
10570 * distributed under the License is distributed on an "AS IS" BASIS,
10571 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10572 * See the License for the specific language governing permissions and
10573 * limitations under the License.
10574 * =============================================================================
10575 */function OV(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a,bias:o,preluActivationWeights:i}=e,{strides:l,pad:u,dataFormat:c,dilations:h,dimRoundingMode:d,activation:p,leakyreluAlpha:f}=s;let g=W1({inputs:{x:r,filter:a},backend:t,attrs:{strides:l,pad:u,dataFormat:c,dilations:h,dimRoundingMode:d}});if(o){const m=g;if(c==="NCHW"&&o.shape.length===1&&o.shape[0]!==1){const y=Me({inputs:{x:o},backend:t,attrs:{shape:[o.shape[0],1,1]}});g=Wr({inputs:{a:g,b:y},backend:t}),t.disposeIntermediateTensorInfo(y)}else g=Wr({inputs:{a:g,b:o},backend:t});t.disposeIntermediateTensorInfo(m)}if(p){const m=g;if(c==="NCHW"&&p==="prelu"&&i.shape.length===1&&i.shape[0]!==1){const y=Me({inputs:{x:i},backend:t,attrs:{shape:[i.shape[0],1,1]}});g=du(t,g,p,y,f),t.disposeIntermediateTensorInfo(y)}else g=du(t,g,p,i,f);t.disposeIntermediateTensorInfo(m)}return g}const _V={kernelName:go,backendName:"cpu",kernelFunc:OV};/**
10576 * @license
10577 * Copyright 2020 Google LLC. All Rights Reserved.
10578 * Licensed under the Apache License, Version 2.0 (the "License");
10579 * you may not use this file except in compliance with the License.
10580 * You may obtain a copy of the License at
10581 *
10582 * http://www.apache.org/licenses/LICENSE-2.0
10583 *
10584 * Unless required by applicable law or agreed to in writing, software
10585 * distributed under the License is distributed on an "AS IS" BASIS,
10586 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10587 * See the License for the specific language governing permissions and
10588 * limitations under the License.
10589 * =============================================================================
10590 */function FV(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a,bias:o,preluActivationWeights:i}=e,{strides:l,pad:u,dataFormat:c,dilations:h,dimRoundingMode:d,activation:p,leakyreluAlpha:f}=s;let g=U1({inputs:{x:r,filter:a},backend:t,attrs:{strides:l,pad:u,dataFormat:c,dilations:h,dimRoundingMode:d}});if(o){const m=g;g=Wr({inputs:{a:g,b:o},backend:t}),t.disposeIntermediateTensorInfo(m)}if(p){const m=g;g=du(t,g,p,i,f),t.disposeIntermediateTensorInfo(m)}return g}const LV={kernelName:yo,backendName:"cpu",kernelFunc:FV};/**
10591 * @license
10592 * Copyright 2020 Google LLC. All Rights Reserved.
10593 * Licensed under the Apache License, Version 2.0 (the "License");
10594 * you may not use this file except in compliance with the License.
10595 * You may obtain a copy of the License at
10596 *
10597 * http://www.apache.org/licenses/LICENSE-2.0
10598 *
10599 * Unless required by applicable law or agreed to in writing, software
10600 * distributed under the License is distributed on an "AS IS" BASIS,
10601 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10602 * See the License for the specific language governing permissions and
10603 * limitations under the License.
10604 * =============================================================================
10605 */function PV(n){const{inputs:e,backend:t}=n,{params:s,indices:r}=e,a=H(s.shape),o=r.shape,i=o[o.length-1],[l,u,c,h]=Mx(s,r);if(u===0)return t.makeTensorInfo(l,s.dtype,[]);const d=t.data.get(r.dataId).values,p=t.bufferSync(s),f=r1(d,p,s.dtype,u,i,c,h,s.shape,a);return t.makeTensorInfo(l,s.dtype,f.values)}const zV={kernelName:qu,backendName:"cpu",kernelFunc:PV};/**
10606 * @license
10607 * Copyright 2020 Google LLC. All Rights Reserved.
10608 * Licensed under the Apache License, Version 2.0 (the "License");
10609 * you may not use this file except in compliance with the License.
10610 * You may obtain a copy of the License at
10611 *
10612 * http://www.apache.org/licenses/LICENSE-2.0
10613 *
10614 * Unless required by applicable law or agreed to in writing, software
10615 * distributed under the License is distributed on an "AS IS" BASIS,
10616 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10617 * See the License for the specific language governing permissions and
10618 * limitations under the License.
10619 * =============================================================================
10620 */function VV(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,indices:a}=e,{axis:o,batchDims:i}=s;ue([r,a],"gatherV2");const l=Ie(o,r.shape)[0],u=t.data.get(a.dataId).values,c=r.shape[l];for(let b=0;b<u.length;++b){const C=u[b];I(C<=c-1&&C>=0,()=>`GatherV2: the index value ${C} is not in [0, ${c-1}]`)}let h=i;i==null&&(h=0);const d=H(a.shape),p=Wx(r,a,l,h),f=Me({inputs:{x:r},backend:t,attrs:{shape:[p.batchSize,p.outerSize,p.dimSize,p.sliceSize]}}),g=Me({inputs:{x:a},backend:t,attrs:{shape:[p.batchSize,d/p.batchSize]}}),m=[p.batchSize,p.outerSize,d/p.batchSize,p.sliceSize],y=t.bufferSync(g),x=t.bufferSync(f),v=a1(x,y,m);return t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),t.makeTensorInfo(p.outputShape,v.dtype,v.values)}const BV={kernelName:Zo,backendName:"cpu",kernelFunc:VV};/**
10621 * @license
10622 * Copyright 2020 Google LLC. All Rights Reserved.
10623 * Licensed under the Apache License, Version 2.0 (the "License");
10624 * you may not use this file except in compliance with the License.
10625 * You may obtain a copy of the License at
10626 *
10627 * http://www.apache.org/licenses/LICENSE-2.0
10628 *
10629 * Unless required by applicable law or agreed to in writing, software
10630 * distributed under the License is distributed on an "AS IS" BASIS,
10631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10632 * See the License for the specific language governing permissions and
10633 * limitations under the License.
10634 * =============================================================================
10635 */function MV(n){const{inputs:e,backend:t}=n,{input:s}=e,r=H(s.shape),a=s.shape[s.shape.length-1],o=r/a,i=Me({inputs:{x:s},backend:t,attrs:{shape:[o,a]}}),l=G1(i,!0,t),u=Me({inputs:{x:l},backend:t,attrs:{shape:s.shape}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(l),u}const WV={kernelName:Bu,backendName:"cpu",kernelFunc:MV};/**
10636 * @license
10637 * Copyright 2020 Google LLC. All Rights Reserved.
10638 * Licensed under the Apache License, Version 2.0 (the License);
10639 * you may not use this file except in compliance with the License.
10640 * You may obtain a copy of the License at
10641 *
10642 * http://www.apache.org/licenses/LICENSE-2.0
10643 *
10644 * Unless required by applicable law or agreed to in writing, software
10645 * distributed under the License is distributed on an AS IS BASIS,
10646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10647 * See the License for the specific language governing permissions and
10648 * limitations under the License.
10649 * =============================================================================
10650 */const UV=Oe(ca,n=>Number.isFinite(n)?1:0,"bool"),GV={kernelName:ca,backendName:"cpu",kernelFunc:UV};/**
10651 * @license
10652 * Copyright 2020 Google LLC. All Rights Reserved.
10653 * Licensed under the Apache License, Version 2.0 (the License);
10654 * you may not use this file except in compliance with the License.
10655 * You may obtain a copy of the License at
10656 *
10657 * http://www.apache.org/licenses/LICENSE-2.0
10658 *
10659 * Unless required by applicable law or agreed to in writing, software
10660 * distributed under the License is distributed on an AS IS BASIS,
10661 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10662 * See the License for the specific language governing permissions and
10663 * limitations under the License.
10664 * =============================================================================
10665 */const HV=Oe(ha,n=>Math.abs(n)===1/0?1:0,"bool"),jV={kernelName:ha,backendName:"cpu",kernelFunc:HV};/**
10666 * @license
10667 * Copyright 2020 Google LLC. All Rights Reserved.
10668 * Licensed under the Apache License, Version 2.0 (the License);
10669 * you may not use this file except in compliance with the License.
10670 * You may obtain a copy of the License at
10671 *
10672 * http://www.apache.org/licenses/LICENSE-2.0
10673 *
10674 * Unless required by applicable law or agreed to in writing, software
10675 * distributed under the License is distributed on an AS IS BASIS,
10676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10677 * See the License for the specific language governing permissions and
10678 * limitations under the License.
10679 * =============================================================================
10680 */const qV=Oe(da,n=>Number.isNaN(n)?1:0,"bool"),KV={kernelName:da,backendName:"cpu",kernelFunc:qV};/**
10681 * @license
10682 * Copyright 2020 Google LLC. All Rights Reserved.
10683 * Licensed under the Apache License, Version 2.0 (the "License");
10684 * you may not use this file except in compliance with the License.
10685 * You may obtain a copy of the License at
10686 *
10687 * http://www.apache.org/licenses/LICENSE-2.0
10688 *
10689 * Unless required by applicable law or agreed to in writing, software
10690 * distributed under the License is distributed on an "AS IS" BASIS,
10691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10692 * See the License for the specific language governing permissions and
10693 * limitations under the License.
10694 * =============================================================================
10695 */function XV(n){const{backend:e,attrs:t}=n,{start:s,stop:r,num:a}=t,o=c1(s,r,a);return e.makeTensorInfo([o.length],"float32",o)}const YV={kernelName:Ru,backendName:"cpu",kernelFunc:XV};/**
10696 * @license
10697 * Copyright 2020 Google LLC. All Rights Reserved.
10698 * Licensed under the Apache License, Version 2.0 (the License);
10699 * you may not use this file except in compliance with the License.
10700 * You may obtain a copy of the License at
10701 *
10702 * http://www.apache.org/licenses/LICENSE-2.0
10703 *
10704 * Unless required by applicable law or agreed to in writing, software
10705 * distributed under the License is distributed on an AS IS BASIS,
10706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10707 * See the License for the specific language governing permissions and
10708 * limitations under the License.
10709 * =============================================================================
10710 */const JV=Oe(fa,n=>Math.log1p(n)),ZV={kernelName:fa,backendName:"cpu",kernelFunc:JV};/**
10711 * @license
10712 * Copyright 2020 Google LLC. All Rights Reserved.
10713 * Licensed under the Apache License, Version 2.0 (the "License");
10714 * you may not use this file except in compliance with the License.
10715 * You may obtain a copy of the License at
10716 *
10717 * http://www.apache.org/licenses/LICENSE-2.0
10718 *
10719 * Unless required by applicable law or agreed to in writing, software
10720 * distributed under the License is distributed on an "AS IS" BASIS,
10721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10722 * See the License for the specific language governing permissions and
10723 * limitations under the License.
10724 * =============================================================================
10725 */const QV=Qe((n,e)=>n&&e),eB=ut(ri,QV,null,"bool"),tB={kernelName:ri,backendName:"cpu",kernelFunc:eB};/**
10726 * @license
10727 * Copyright 2020 Google LLC. All Rights Reserved.
10728 * Licensed under the Apache License, Version 2.0 (the License);
10729 * you may not use this file except in compliance with the License.
10730 * You may obtain a copy of the License at
10731 *
10732 * http://www.apache.org/licenses/LICENSE-2.0
10733 *
10734 * Unless required by applicable law or agreed to in writing, software
10735 * distributed under the License is distributed on an AS IS BASIS,
10736 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10737 * See the License for the specific language governing permissions and
10738 * limitations under the License.
10739 * =============================================================================
10740 */const nB=Oe(ai,n=>n?0:1,"bool"),sB={kernelName:ai,backendName:"cpu",kernelFunc:nB};/**
10741 * @license
10742 * Copyright 2020 Google LLC. All Rights Reserved.
10743 * Licensed under the Apache License, Version 2.0 (the "License");
10744 * you may not use this file except in compliance with the License.
10745 * You may obtain a copy of the License at
10746 *
10747 * http://www.apache.org/licenses/LICENSE-2.0
10748 *
10749 * Unless required by applicable law or agreed to in writing, softw
10749are
10750 * distributed under the License is distributed on an "AS IS" BASIS,
10751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10752 * See the License for the specific language governing permissions and
10753 * limitations under the License.
10754 * =============================================================================
10755 */const rB=Qe((n,e)=>n||e),aB=ut(oi,rB,null,"bool"),oB={kernelName:oi,backendName:"cpu",kernelFunc:aB};/**
10756 * @license
10757 * Copyright 2020 Google LLC. All Rights Reserved.
10758 * Licensed under the Apache License, Version 2.0 (the "License");
10759 * you may not use this file except in compliance with the License.
10760 * You may obtain a copy of the License at
10761 *
10762 * http://www.apache.org/licenses/LICENSE-2.0
10763 *
10764 * Unless required by applicable law or agreed to in writing, software
10765 * distributed under the License is distributed on an "AS IS" BASIS,
10766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10767 * See the License for the specific language governing permissions and
10768 * limitations under the License.
10769 * =============================================================================
10770 */function iB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{depthRadius:a,bias:o,alpha:i,beta:l}=s;ue(r,"LRN");const u=r.shape[3],c=u-1,h=t.data.get(r.dataId).values,d=H(r.shape),p=new Float32Array(d);function f(g){const m=g%u;let y=g-m+Math.max(0,m-a);const x=g-m+Math.min(m+a,c);let v=0;for(;y<=x;y++){const b=h[y];v+=b*b}return v}for(let g=0;g<d;g++){const m=f(g),y=h[g]*Math.pow(o+i*m,-l);p[g]=y}return t.makeTensorInfo(r.shape,r.dtype,p)}const lB={kernelName:ni,backendName:"cpu",kernelFunc:iB};/**
10771 * @license
10772 * Copyright 2020 Google LLC. All Rights Reserved.
10773 * Licensed under the Apache License, Version 2.0 (the "License");
10774 * you may not use this file except in compliance with the License.
10775 * You may obtain a copy of the License at
10776 *
10777 * http://www.apache.org/licenses/LICENSE-2.0
10778 *
10779 * Unless required by applicable law or agreed to in writing, software
10780 * distributed under the License is distributed on an "AS IS" BASIS,
10781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10782 * See the License for the specific language governing permissions and
10783 * limitations under the License.
10784 * =============================================================================
10785 */function uB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,y:a,dy:o}=e,{depthRadius:i,bias:l,alpha:u,beta:c}=s;ue(o,"LRNGrad");const h=H(o.shape),d=o.shape[3],p=t.data.get(o.dataId).values,f=t.data.get(r.dataId).values,g=t.data.get(a.dataId).values,m=new Float32Array(h),y=h;for(let x=0;x<y;x++){const v=x%d,b=x-v+Math.max(0,v-i),C=x-v+Math.min(d,v+i+1);let $=0;for(let S=b;S<C;S++)$+=Math.pow(f[S],2);$=u*$+l;for(let S=b;S<C;S++){let k=-2*u*c*f[S]*g[x]/$;x===S&&(k+=Math.pow($,-c)),k*=p[x],m[S]+=k}}return t.makeTensorInfo(o.shape,r.dtype,m)}const cB={kernelName:Cc,backendName:"cpu",kernelFunc:uB};/**
10786 * @license
10787 * Copyright 2020 Google LLC. All Rights Reserved.
10788 * Licensed under the Apache License, Version 2.0 (the "License");
10789 * you may not use this file except in compliance with the License.
10790 * You may obtain a copy of the License at
10791 *
10792 * http://www.apache.org/licenses/LICENSE-2.0
10793 *
10794 * Unless required by applicable law or agreed to in writing, software
10795 * distributed under the License is distributed on an "AS IS" BASIS,
10796 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10797 * See the License for the specific language governing permissions and
10798 * limitations under the License.
10799 * =============================================================================
10800 */function H1(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{reductionIndices:a,keepDims:o}=s,i=t;let l=r.shape;const u=l.length,c=Ie(a,l);let h=c;const d=Xe(h,u);let p=i.data.get(r.dataId).values;if(d!=null){const b=new Array(u);for(let C=0;C<b.length;C++)b[C]=l[d[C]];p=Qm(p,l,r.dtype,d,b),h=st(h.length,u),l=b}ue(r,"max"),St("max",h,u);const[f,g]=Ct(l,h),m=H(g),y=d1(p,m,f,r.dtype),x=i.write(y,f,r.dtype);let v=f;return o&&(v=nt(f,c)),{dataId:x,shape:v,dtype:r.dtype}}const hB={kernelName:Xo,backendName:"cpu",kernelFunc:H1};/**
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 dB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e;ue(r,"maxPool");const{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;I(It(o,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);const c=_n(r.shape,a,o,u,i,l);let h;if(c.filterWidth===1&&c.filterHeight===1&&ke(c.inShape,c.outShape))h=jn({inputs:{x:r},backend:t});else{const d=t.data.get(r.dataId).values,p=fe(r.shape),f=ng(d,r.shape,r.dtype,p,c,"max");h=t.makeTensorInfo(c.outShape,r.dtype,f.values)}return h}const pB={kernelName:ii,backendName:"cpu",kernelFunc:dB};/**
10816 * @license
10817 * Copyright 2020 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 fB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=s;ue(r,"maxPool3d");const c=Fs(r.shape,a,o,1,i,l,u),h=t.data.get(r.dataId).values,d=M1(h,r.shape,r.dtype,fe(r.shape),c,"max");return t.makeTensorInfo(d.shape,"float32",d.values)}const mB={kernelName:li,backendName:"cpu",kernelFunc:fB};/**
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 */function gB(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a}=e,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=s;ue([r,a],"maxPool3DGrad");const c=Fs(a.shape,o,i,1,l,u),h=t.bufferSync(a),d=r3(h,c),p=c.strideDepth,f=c.strideHeight,g=c.strideWidth,m=c.dilationDepth,y=c.dilationHeight,x=c.dilationWidth,v=c.effectiveFilterDepth,b=c.effectiveFilterHeight,C=c.effectiveFilterWidth,$=v-1-c.padInfo.front,S=C-1-c.padInfo.left,k=b-1-c.padInfo.top,T=$e(a.shape,"float32"),E=t.bufferSync(r);for(let _=0;_<c.batchSize;++_)for(let z=0;z<c.inChannels;++z)for(let P=0;P<c.inDepth;++P)for(let V=0;V<c.inHeight;++V)for(let B=0;B<c.inWidth;++B){const M=P-$,j=V-k,U=B-S;let q=0;for(let X=0;X<v;X+=m){const Y=(M+X)/p;if(!(Y<0||Y>=c.outDepth||Math.floor(Y)!==Y))for(let Z=0;Z<b;Z+=y){const J=(j+Z)/f;if(!(J<0||J>=c.outHeight||Math.floor(J)!==J))for(let re=0;re<C;re+=x){const Q=(U+re)/g;if(Q<0||Q>=c.outWidth||Math.floor(Q)!==Q)continue;const ae=v*b*C-1-d.get(_,Y,J,Q,z),ce=X*b*C+Z*C+re,me=ae===ce?1:0;if(me===0)continue;const de=E.get(_,Y,J,Q,z);q+=de*me}}}T.set(q,_,P,V,B,z)}return t.makeTensorInfo(T.shape,T.dtype,T.values)}const yB={kernelName:$c,backendName:"cpu",kernelFunc:gB};/**
10846 * @license
10847 * Copyright 2020 Google LLC. All Rights Reserved.
10848 * Licensed under the Apache License, Version 2.0 (the "License");
10849 * you may not use this file except in compliance with the License.
10850 * You may obtain a copy of the License at
10851 *
10852 * http://www.apache.org/licenses/LICENSE-2.0
10853 *
10854 * Unless required by applicable law or agreed to in writing, software
10855 * distributed under the License is distributed on an "AS IS" BASIS,
10856 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10857 * See the License for the specific language governing permissions and
10858 * limitations under the License.
10859 * =============================================================================
10860 */function xB(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a,output:o}=e,i=a;ue([a,o],"maxPoolGrad");const{filterSize:l,strides:u,pad:c,dimRoundingMode:h}=s,d=_n(i.shape,l,u,1,c,h),p=t.data.get(i.dataId).values,f=$e(d.outShape,i.dtype,B1(p,i.shape,i.dtype,d).values),g=d.strideHeight,m=d.strideWidth,y=d.dilationHeight,x=d.dilationWidth,v=d.effectiveFilterHeight,b=d.effectiveFilterWidth,C=b-1-d.padInfo.left,$=v-1-d.padInfo.top,S=$e(i.shape,"float32"),k=t.data.get(r.dataId).values,T=$e(r.shape,"float32",k);for(let E=0;E<d.batchSize;++E)for(let _=0;_<d.inChannels;++_)for(let z=0;z<d.inHeight;++z)for(let P=0;P<d.inWidth;++P){const V=z-$,B=P-C;let M=0;for(let j=0;j<v;j+=y){const U=(V+j)/g;if(!(U<0||U>=d.outHeight||Math.floor(U)!==U))for(let q=0;q<b;q+=x){const X=(B+q)/m;if(X<0||X>=d.outWidth||Math.floor(X)!==X)continue;const Y=v*b-1-f.get(E,U,X,_),Z=j*b+q,J=Y===Z?1:0;if(J===0)continue;const re=T.get(E,U,X,_);M+=re*J}}S.set(M,E,z,P,_)}return t.makeTensorInfo(S.shape,S.dtype,S.values)}const bB={kernelName:Nc,backendName:"cpu",kernelFunc:xB};/**
10861 * @license
10862 * Copyright 2020 Google LLC. All Rights Reserved.
10863 * Licensed under the Apache License, Version 2.0 (the "License");
10864 * you may not use this file except in compliance with the License.
10865 * You may obtain a copy of the License at
10866 *
10867 * http://www.apache.org/licenses/LICENSE-2.0
10868 *
10869 * Unless required by applicable law or agreed to in writing, software
10870 * distributed under the License is distributed on an "AS IS" BASIS,
10871 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10872 * See the License for the specific language governing permissions and
10873 * limitations under the License.
10874 * =============================================================================
10875 */function wB(n,e,t,s,r){const a=fe(e),o=ng(n,e,t,a,r,"max"),i=B1(n,e,t,r,!0,s);return[o.values,i.values]}/**
10876 * @license
10877 * Copyright 2020 Google LLC. All Rights Reserved.
10878 * Licensed under the Apache License, Version 2.0 (the "License");
10879 * you may not use this file except in compliance with the License.
10880 * You may obtain a copy of the License at
10881 *
10882 * http://www.apache.org/licenses/LICENSE-2.0
10883 *
10884 * Unless required by applicable law or agreed to in writing, software
10885 * distributed under the License is distributed on an "AS IS" BASIS,
10886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10887 * See the License for the specific language governing permissions and
10888 * limitations under the License.
10889 * =============================================================================
10890 */const vB={kernelName:Au,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{filterSize:r,strides:a,pad:o,includeBatchInIndex:i}=e,l=t;ue(s,"MaxPoolWithArgmax");const u=l.data.get(s.dataId).values,c=_n(s.shape,r,a,[1,1],o),[h,d]=wB(u,s.shape,s.dtype,i,c),p=l.write(h,c.outShape,s.dtype),f=l.write(d,c.outShape,s.dtype);return[{dataId:p,shape:c.outShape,dtype:s.dtype},{dataId:f,shape:c.outShape,dtype:"int32"}]}};/**
10891 * @license
10892 * Copyright 2020 Google LLC. All Rights Reserved.
10893 * Licensed under the Apache License, Version 2.0 (the "License");
10894 * you may not use this file except in compliance with the License.
10895 * You may obtain a copy of the License at
10896 *
10897 * http://www.apache.org/licenses/LICENSE-2.0
10898 *
10899 * Unless required by applicable law or agreed to in writing, software
10900 * distributed under the License is distributed on an "AS IS" BASIS,
10901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10902 * See the License for the specific language governing permissions and
10903 * limitations under the License.
10904 * =============================================================================
10905 */function CB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s,i=Ie(a,r.shape),u=Ct(r.shape,i)[1],c=H(u),h=[],d=t.makeTensorInfo([],"float32",new Float32Array([c]));h.push(d);
vendor: 4,249 bytes, lines 10905-10959
10905const p=Ds({inputs:{x:r},backend:t,attrs:{dtype:"float32"}});h.push(p);const f=sg({inputs:{a:p,b:d},backend:t});h.push(f);const g=gl({inputs:{x:f},backend:t,attrs:{axis:a,keepDims:o}});return h.forEach(m=>t.disposeIntermediateTensorInfo(m)),g}const $B={kernelName:ui,backendName:"cpu",kernelFunc:CB};/**
10906 * @license
10907 * Copyright 2020 Google LLC. All Rights Reserved.
10908 * Licensed under the Apache License, Version 2.0 (the "License");
10909 * you may not use this file except in compliance with the License.
10910 * You may obtain a copy of the License at
10911 *
10912 * http://www.apache.org/licenses/LICENSE-2.0
10913 *
10914 * Unless required by applicable law or agreed to in writing, software
10915 * distributed under the License is distributed on an "AS IS" BASIS,
10916 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10917 * See the License for the specific language governing permissions and
10918 * limitations under the License.
10919 * =============================================================================
10920 */function NB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s;ue(r,"min");const i=Ie(a,r.shape);let l=i;const u=Xe(l,r.shape.length);let c=r;u!=null&&(c=Gt({inputs:{x:r},backend:t,attrs:{perm:u}}),l=st(l.length,r.shape.length)),St("min",l,c.shape.length);const[h,d]=Ct(c.shape,l),p=H(d),f=hn(H(h),c.dtype),g=t.data.get(c.dataId).values;for(let y=0;y<f.length;++y){const x=y*p;let v=g[x];for(let b=0;b<p;++b){const C=g[x+b];(Number.isNaN(C)||C<v)&&(v=C)}f[y]=v}u!=null&&t.disposeIntermediateTensorInfo(c);const m=t.makeTensorInfo(h,c.dtype,f);if(o){const y=nt(h,i),x=Me({inputs:{x:m},backend:t,attrs:{shape:y}});return t.disposeIntermediateTensorInfo(m),x}return m}const IB={kernelName:Yo,backendName:"cpu",kernelFunc:NB};/**
10921 * @license
10922 * Copyright 2020 Google LLC. All Rights Reserved.
10923 * Licensed under the Apache License, Version 2.0 (the "License");
10924 * you may not use this file except in compliance with the License.
10925 * You may obtain a copy of the License at
10926 *
10927 * http://www.apache.org/licenses/LICENSE-2.0
10928 *
10929 * Unless required by applicable law or agreed to in writing, software
10930 * distributed under the License is distributed on an "AS IS" BASIS,
10931 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10932 * See the License for the specific language governing permissions and
10933 * limitations under the License.
10934 * =============================================================================
10935 */function SB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{paddings:a,mode:o}=s;ue(r,"mirrorPad");const i=a.map((v,b)=>v[0]+r.shape[b]+v[1]),l=a.map(v=>v[0]),u=a.map((v,b)=>v[0]+r.shape[b]),c=o==="reflect"?0:1,h=t.data.get(r.dataId).values,d=r.shape.length,p=fe(r.shape),f=H(i),g=i.length,m=fe(i),y=wt(r.dtype,f);for(let v=0;v<f;v++){let b=Ra(v,g,m);for(let $=0;$<g;$++)b[$]<l[$]?b[$]=l[$]*2-b[$]-c:b[$]>=u[$]&&(b[$]=(u[$]-1)*2-b[$]+c);b=b.map(($,S)=>$-l[S]);const C=Wn(b,d,p);y[v]=h[C]}return{dataId:t.write(y,i,r.dtype),shape:i,dtype:r.dtype}}const kB={kernelName:ci,backendName:"cpu",kernelFunc:SB};/**
10936 * @license
10937 * Copyright 2020 Google LLC. All Rights Reserved.
10938 * Licensed under the Apache License, Version 2.0 (the "License");
10939 * you may not use this file except in compliance with the License.
10940 * You may obtain a copy of the License at
10941 *
10942 * http://www.apache.org/licenses/LICENSE-2.0
10943 *
10944 * Unless required by applicable law or agreed to in writing, software
10945 * distributed under the License is distributed on an "AS IS" BASIS,
10946 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10947 * See the License for the specific language governing permissions and
10948 * limitations under the License.
10949 * =============================================================================
10950 */const TB=Qe((n,e)=>{const t=n%e;return n<0&&e<0||n>=0&&e>=0?t:(t+e)%e}),EB=ut(ya,TB),RB={kernelName:ya,backendName:"cpu",kernelFunc:EB};/**
10951 * @license
10952 * Copyright 2020 Google LLC. All Rights Reserved.
10953 * Licensed under the Apache License, Version 2.0 (the "License");
10954 * you may not use this file except in compliance with the License.
10955 * You may obtain a copy of the License at
10956 *
10957 * http://www.apache.org/licenses/LICENSE-2.0
10958 *
10959 * Unless required by applicable law or agreed to in writing, softw
10959are
10960 * distributed under the License is distributed on an "AS IS" BASIS,
10961 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10962 * See the License for the specific language governing permissions and
10963 * limitations under the License.
10964 * =============================================================================
10965 */function j1(n){const{inputs:e,backend:t,attrs:s}=n,{logits:r}=e,{dim:a}=s,o=r.shape.length;let i=a;if(i===-1&&(i=o-1),i!==o-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${o} and dim was ${i}`);const l=Ie([i],r.shape),u=H1({inputs:{x:r},backend:t,attrs:{reductionIndices:l,keepDims:!1}}),c=nt(u.shape,l),h=Me({inputs:{x:u},backend:t,attrs:{shape:c}}),d=tg({inputs:{a:r,b:h},backend:t}),p=e1({inputs:{x:d},backend:t}),f=gl({inputs:{x:p},backend:t,attrs:{axis:l,keepDims:!1}}),g=Me({inputs:{x:f},backend:t,attrs:{shape:c}}),m=sg({inputs:{a:p,b:g},backend:t});return t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),m}const DB={kernelName:xi,backendName:"cpu",kernelFunc:j1};/**
10966 * @license
10967 * Copyright 2020 Google LLC. All Rights Reserved.
10968 * Licensed under the Apache License, Version 2.0 (the "License");
10969 * you may not use this file except in compliance with the License.
10970 * You may obtain a copy of the License at
10971 *
10972 * http://www.apache.org/licenses/LICENSE-2.0
10973 *
10974 * Unless required by applicable law or agreed to in writing, software
10975 * distributed under the License is distributed on an "AS IS" BASIS,
10976 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10977 * See the License for the specific language governing permissions and
10978 * limitations under the License.
10979 * =============================================================================
10980 */function AB(n){const{inputs:e,backend:t,attrs:s}=n,{logits:r}=e,{numSamples:a,seed:o,normalized:i}=s;ue(r,"multinomial");const l=i?r:j1({inputs:{logits:r},backend:t,attrs:{dim:-1}}),u=l.shape[0],c=l.shape[1],h=t.data.get(l.dataId).values,d=[u,a],p=hn(H(d),"int32");for(let f=0;f<u;++f){const g=f*c,m=new Float32Array(c-1);m[0]=h[g];for(let v=1;v<m.length;++v)m[v]=m[v-1]+h[g+v];const y=za.alea(o.toString()),x=f*a;for(let v=0;v<a;++v){const b=y();p[x+v]=m.length;for(let C=0;C<m.length;C++)if(b<m[C]){p[x+v]=C;break}}}return i||t.disposeIntermediateTensorInfo(l),t.makeTensorInfo(d,"int32",p)}const OB={kernelName:Ou,backendName:"cpu",kernelFunc:AB};/**
10981 * @license
10982 * Copyright 2020 Google LLC. All Rights Reserved.
10983 * Licensed under the Apache License, Version 2.0 (the "License");
10984 * you may not use this file except in compliance with the License.
10985 * You may obtain a copy of the License at
10986 *
10987 * http://www.apache.org/licenses/LICENSE-2.0
10988 *
10989 * Unless required by applicable law or agreed to in writing, software
10990 * distributed under the License is distributed on an "AS IS" BASIS,
10991 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10992 * See the License for the specific language governing permissions and
10993 * limitations under the License.
10994 * =============================================================================
10995 */const _B=ch;function FB(n){const{inputs:e,backend:t,attrs:s}=n,{boxes:r,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l}=s;ue(r,"NonMaxSuppression");const u=t.data.get(r.dataId).values,c=t.data.get(a.dataId).values,{selectedIndices:h}=_B(u,c,o,i,l);return t.makeTensorInfo([h.length],"int32",new Int32Array(h))}const LB={kernelName:ec,backendName:"cpu",kernelFunc:FB};/**
10996 * @license
10997 * Copyright 2020 Google LLC. All Rights Reserved.
10998 * Licensed under the Apache License, Version 2.0 (the "License");
10999 * you may not use this file except in compliance with the License.
11000 * You may obtain a copy of the License at
11001 *
11002 * http://www.apache.org/licenses/LICENSE-2.0
11003 *
11004 * Unless required by applicable law or agreed to in writing, software
11005 * distributed under the License is distributed on an "AS IS" BASIS,
11006 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11007 * See the License for the specific language governing permissions and
11008 * limitations under the License.
11009 * =============================================================================
11010 */const PB=hh;function zB(n){const{inputs:e,backend:t,attrs:s}=n,{boxes:r,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,padToMaxOutputSize:u}=s;ue(r,"NonMaxSuppressionPadded");const c=t.data.get(r.dataId).values,h=t.data.get(a.dataId).values,{selectedIndices:d,validOutputs:p}=PB(c,h,o,i,l,u);return[t.makeTensorInfo([d.length],"int32",new Int32Array(d)),t.makeTensorInfo([],"int32",new Int32Array([p]))]}const VB={kernelName:nc,backendName:"cpu",kernelFunc:zB};/**
11011 * @license
11012 * Copyright 2019 Google LLC. All Rights Reserved.
11013 * Licensed under the Apache License, Version 2.0 (the "License");
11014 * you may not use this file except in compliance with the License.
11015 * You may obtain a copy of the License at
11016 *
11017 * http://www.apache.org/licenses/LICENSE-2.0
11018 *
11019 * Unless required by applicable law or agreed to in writing, software
11020 * distributed under the License is distributed on an "AS IS" BASIS,
11021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11022 * See the License for the specific language governing permissions and
11023 * limitations under the License.
11024 * =============================================================================
11025 */const BB=dh;function MB(n){const{inputs:e,backend:t,attrs:s}=n,{boxes:r,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,softNmsSigma:u}=s;ue(r,"NonMaxSuppressionWithScore");const c=t.data.get(r.dataId).values,h=t.data.get(a.dataId).values,d=o,p=i,f=l,g=u,{selectedIndices:m,selectedScores:y}=BB(c,h,d,p,f,g);return[t.makeTensorInfo([m.length],"int32",new Int32Array(m)),t.makeTensorInfo([y.length],"float32",new Float32Array(y))]}const WB={kernelName:tc,backendName:"cpu",kernelFunc:MB};/**
11026 * @license
11027 * Copyright 2020 Google LLC. All Rights Reserved.
11028 * Licensed under the Apache License, Version 2.0 (the "License");
11029 * you may not use this file except in compliance with the License.
11030 * You may obtain a copy of the License at
11031 *
11032 * http://www.apache.org/licenses/LICENSE-2.0
11033 *
11034 * Unless required by applicable law or agreed to in writing, software
11035 * distributed under the License is distributed on an "AS IS" BASIS,
11036 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11037 * See the License for the specific language governing permissions and
11038 * limitations under the License.
11039 * =============================================================================
11040 */function UB(n){const{inputs:e,backend:t,attrs:s}=n,{indices:r}=e,{dtype:a,depth:o,onValue:i,offValue:l}=s;ue(r,"oneHot");const u=H(r.shape),c=new Float32Array(u*o);c.fill(l);const h=t.data.get(r.dataId).values;for(let d=0;d<u;++d)h[d]>=0&&h[d]<o&&(c[d*o+h[d]]=i);return t.makeTensorInfo([...r.shape,o],a,c)}const GB={kernelName:di,backendName:"cpu",kernelFunc:UB};/**
11041 * @license
11042 * Copyright 2020 Google LLC. All Rights Reserved.
11043 * Licensed under the Apache License, Version 2.0 (the "License");
11044 * you may not use this file except in compliance with the License.
11045 * You may obtain a copy of the License at
11046 *
11047 * http://www.apache.org/licenses/LICENSE-2.0
11048 *
11049 * Unless required by applicable law or agreed to in writing, software
11050 * distributed under the License is distributed on an "AS IS" BASIS,
11051 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11052 * See the License for the specific language governing permissions and
11053 * limitations under the License.
11054 * =============================================================================
11055 */function fu(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="string")throw new Error("zerosLike is not supported for string tensors");if(s.dtype==="complex64"){const r=ur({inputs:{input:s},backend:t}),a=fu({inputs:{x:r},backend:t}),o=Ur({inputs:{input:s},backend:t}),i=fu({inputs:{x:o},backend:t}),l=Xt({inputs:{real:a,imag:i},backend:t});return t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),l}else return rg({backend:t,attrs:{shape:s.shape,value:0,dtype:s.dtype}})}const HB={kernelName:Dc,backendName:"cpu",kernelFunc:fu};/**
11056 * @license
11057 * Copyright 2020 Google LLC. All Rights Reserved.
11058 * Licensed under the Apache License, Version 2.0 (the "License");
11059 * you may not use this file except in compliance with the License.
11060 * You may obtain a copy of the License at
11061 *
11062 * http://www.apache.org/licenses/LICENSE-2.0
11063 *
11064 * Unless required by applicable law or agreed to in writing, software
11065 * distributed under the License is distributed on an "AS IS" BASIS,
11066 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11067 * See the License for the specific language governing permissions and
11068 * limitations under the License.
11069 * =============================================================================
11070 */function q1(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="string")throw new Error("onesLike is not supported for string tensors");if(s.dtype==="complex64"){const r=ur({inputs:{input:s},backend:t}),a=q1({inputs:{x:r},backend:t}),o=Ur({inputs:{input:s},backend:t}),i=fu({inputs:{x:o},backend:t}),l=Xt({inputs:{real:a,imag:i},backend:t});return t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(a),t.dis
vendor: 4,743 bytes, lines 11070-11133
11070poseIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),l}else return rg({backend:t,attrs:{shape:s.shape,value:1,dtype:s.dtype}})}const jB={kernelName:pi,backendName:"cpu",kernelFunc:q1};/**
11071 * @license
11072 * Copyright 2020 Google LLC. All Rights Reserved.
11073 * Licensed under the Apache License, Version 2.0 (the "License");
11074 * you may not use this file except in compliance with the License.
11075 * You may obtain a copy of the License at
11076 *
11077 * http://www.apache.org/licenses/LICENSE-2.0
11078 *
11079 * Unless required by applicable law or agreed to in writing, software
11080 * distributed under the License is distributed on an "AS IS" BASIS,
11081 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11082 * See the License for the specific language governing permissions and
11083 * limitations under the License.
11084 * =============================================================================
11085 */function K1(n){const{inputs:e,backend:t,attrs:s}=n,{axis:r}=s;if(e.length===1)return pu({inputs:{input:e[0]},backend:t,attrs:{dim:r}});const a=e[0].shape,o=e[0].dtype;e.forEach(c=>{dn(a,c.shape,"All tensors passed to stack must have matching shapes"),I(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});const i=[],l=e.map(c=>{const h=pu({inputs:{input:c},backend:t,attrs:{dim:r}});return i.push(h),h}),u=Gr({inputs:l,backend:t,attrs:{axis:r}});return i.forEach(c=>t.disposeIntermediateTensorInfo(c)),u}const qB={kernelName:wi,backendName:"cpu",kernelFunc:K1};/**
11086 * @license
11087 * Copyright 2020 Google LLC. All Rights Reserved.
11088 * Licensed under the Apache License, Version 2.0 (the "License");
11089 * you may not use this file except in compliance with the License.
11090 * You may obtain a copy of the License at
11091 *
11092 * http://www.apache.org/licenses/LICENSE-2.0
11093 *
11094 * Unless required by applicable law or agreed to in writing, software
11095 * distributed under the License is distributed on an "AS IS" BASIS,
11096 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11097 * See the License for the specific language governing permissions and
11098 * limitations under the License.
11099 * =============================================================================
11100 */function KB(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{paddings:a,constantValue:o}=s;ue(r,"pad");const i=a.map((x,v)=>x[0]+r.shape[v]+x[1]),l=a.map(x=>x[0]),u=t.data.get(r.dataId).values,c=H(r.shape),h=r.shape.length,d=fe(r.shape),p=H(i),f=i.length,g=fe(i),m=wt(r.dtype,p);o!==0&&m.fill(o);for(let x=0;x<c;x++){const b=Ra(x,h,d).map(($,S)=>$+l[S]),C=Wn(b,f,g);m[C]=u[x]}return{dataId:t.write(m,i,r.dtype),shape:i,dtype:r.dtype}}const X1={kernelName:fi,backendName:"cpu",kernelFunc:KB};/**
11101 * @license
11102 * Copyright 2020 Google LLC. All Rights Reserved.
11103 * Licensed under the Apache License, Version 2.0 (the "License");
11104 * you may not use this file except in compliance with the License.
11105 * You may obtain a copy of the License at
11106 *
11107 * http://www.apache.org/licenses/LICENSE-2.0
11108 *
11109 * Unless required by applicable law or agreed to in writing, software
11110 * distributed under the License is distributed on an "AS IS" BASIS,
11111 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11112 * See the License for the specific language governing permissions and
11113 * limitations under the License.
11114 * =============================================================================
11115 */const XB=Qe((n,e)=>Math.pow(n,e)),YB=ut(Ai,XB),JB={kernelName:Ai,backendName:"cpu",kernelFunc:YB};/**
11116 * @license
11117 * Copyright 2022 Google LLC. All Rights Reserved.
11118 * Licensed under the Apache License, Version 2.0 (the "License");
11119 * you may not use this file except in compliance with the License.
11120 * You may obtain a copy of the License at
11121 *
11122 * http://www.apache.org/licenses/LICENSE-2.0
11123 *
11124 * Unless required by applicable law or agreed to in writing, software
11125 * distributed under the License is distributed on an "AS IS" BASIS,
11126 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11127 * See the License for the specific language governing permissions and
11128 * limitations under the License.
11129 * =============================================================================
11130 */function ZB(n){const{inputs:e,backend:t,attrs:s}=n,{paramsNestedSplits:r,paramsDenseValues:a,indices:o}=e,{outputRaggedRank:i}=s,l=r.map(y=>t.data.get(y.dataId).values),u=r.map(y=>y.shape),c=t.data.get(a.dataId).values,h=t.data.get(o.dataId).values,[d,p,f]=x1(l,u,c,a.shape,a.dtype,h,o.shape),g=d.map(y=>t.makeTensorInfo([y.length],"int32",y)),m=t.makeTensorInfo(f,a.dtype,p);return g.concat([m])}const QB={kernelName:_u,backendName:"cpu",kernelFunc:ZB};/**
11131 * @license
11132 * Copyright 2022 Google LLC.
11133 * Licensed under the Apache License, Version 2.0 (the "License");
11134 * you may not use this file except in compliance with the License.
11135 * You may obtain a copy of the License at
11136 *
11137 * http://www.apache.org/licenses/LICENSE-2.0
11138 *
11139 * Unless required by applicable law or agreed to in writing, software
11140 * distributed under the License is distributed on an "AS IS" BASIS,
11141 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11142 * See the License for the specific language governing permissions and
11143 * limitations under the License.
11144 * =============================================================================
11145 */function eM(n){const{inputs:e,backend:t}=n,{starts:s,limits:r,deltas:a}=e,o=t.data.get(s.dataId).values,i=t.data.get(r.dataId).values,l=t.data.get(a.dataId).values,[u,c]=b1(o,s.shape,s.dtype,i,r.shape,l,a.shape),h=t.makeTensorInfo([u.length],"int32",u),d=t.makeTensorInfo([c.length],s.dtype,c);return[h,d]}const tM={kernelName:Fu,backendName:"cpu",kernelFunc:eM};/**
11146 * @license
11147 * Copyright 2022 Google LLC. All Rights Reserved.
11148 * Licensed under the Apache License, Version 2.0 (the "License");
11149 * you may not use this file except in compliance with the License.
11150 * You may obtain a copy of the License at
11151 *
11152 * http://www.apache.org/licenses/LICENSE-2.0
11153 *
11154 * Unless required by applicable law or agreed to in writing, software
11155 * distributed under the License is distributed on an "AS IS" BASIS,
11156 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11157 * See the License for the specific language governing permissions and
11158 * limitations under the License.
11159 * =============================================================================
11160 */function nM(n){const{inputs:e,backend:t,attrs:s}=n,{shape:r,values:a,defaultValue:o,rowPartitionTensors:i}=e,{rowPartitionTypes:l}=s,u=t.data.get(r.dataId).values,c=t.data.get(a.dataId).values,h=t.data.get(o.dataId).values,d=i.map(m=>t.data.get(m.dataId).values),p=i.map(m=>m.shape),[f,g]=w1(u,r.shape,c,a.shape,a.dtype,h,o.shape,d,p,l);return t.makeTensorInfo(f,a.dtype,g)}const sM={kernelName:Lu,backendName:"cpu",kernelFunc:nM};/**
11161 * @license
11162 * Copyright 2020 Google LLC. All Rights Reserved.
11163 * Licensed under the Apache License, Version 2.0 (the "License");
11164 * you may not use this file except in compliance with the License.
11165 * You may obtain a copy of the License at
11166 *
11167 * http://www.apache.org/licenses/LICENSE-2.0
11168 *
11169 * Unless required by applicable law or agreed to in writing, software
11170 * distributed under the License is distributed on an "AS IS" BASIS,
11171 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11172 * See the License for the specific language governing permissions and
11173 * limitations under the License.
11174 * =============================================================================
11175 */function rM(n){const{backend:e,attrs:t}=n,{start:s,stop:r,dtype:a,step:o}=t,i=xx(s,r,o,a);return e.makeTensorInfo([i.length],a,i)}const aM={kernelName:Pu,backendName:"cpu",kernelFunc:rM};/**
11176 * @license
11177 * Copyright 2020 Google LLC. All Rights Reserved.
11178 * Licensed under the Apache License, Version 2.0 (the License);
11179 * you may not use this file except in compliance with the License.
11180 * You may obtain a copy of the License at
11181 *
11182 * http://www.apache.org/licenses/LICENSE-2.0
11183 *
11184 * Unless required by applicable law or agreed to in writing, software
11185 * distributed under the License is distributed on an AS IS BASIS,
11186 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11187 * See the License for the specific language governing permissions and
11188 * limitations under the License.
11189 * =============================================================================
11190 */const oM=Oe(xa,n=>1/n),iM={kernelName:xa,backendName:"cpu",kernelFunc:oM};/**
11191 * @license
11192 * Copyright 2020 Google LLC. All Rights Reserved.
11193 * Licensed under the Apache License, Version 2.0 (the "License");
11194 * you may not use this file except in compliance with the License.
11195 * You may obtain a copy of the License at
11196 *
11197 * http://www.apache.org/licenses/LICENSE-2.0
11198 *
11199 * Unless required by applicable law or agreed to in writing, software
11200 * distributed under the License is distributed on an "AS IS" BASIS,
11201 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11202 * See the License for the specific language governing permissions and
11203 * limitations under the License.
11204 * =============================================================================
11205 */function lM(n){const{inputs:e,backend:t,attrs:s}=n,{images:r}=e,{alignCorners:a,halfPixelCenters:o,size:i}=s;ue(r,"resizeBilinear");const l=fe(r.shape),[u,c]=i,[h,d,p,f]=r.shape,g=t.data.get(r.dataId).values,m=new Float32Array(H([h,u,c,f])),y=[a&&u>1?d-1:d,a&&c>1?p-1:p],x=[a&&u>1?u-1:u,a&&c>1?c-1:c];let v=0;const b=y[0]/x[0],C=y[1]/x[1];for(let $=0;$<h;$++)for(let S=0;S<u;S++){let k;o?k=b*(S+.5)-.5:k=b*S;const T=Math.max(0,Math.floor(k)),E=k-T,_=Math.min(d-1,Math.ceil(k)),z=$*l[0]+T*l[1],P=$*l[0]+_*l[1];for(let V=0;V<c;V++){let B;o?B=C*(V+.5)-.5:B=C*V;const M=Math.max(0,Math.floor(B)),j=B-M,U=Math.min(p-1,Math.ceil(B)),q=z+M*l[2],X=P+M*l[2],Y=z+U*l[2],Z=P+U*l[2];for(let J=0;J<f;J++){const re=g[q+J],Q=g[X+J],ae=g[Y+J],ce=g[Z+J],me=re+(ae-re)*j,de=Q+(ce-Q)*j,be=me+(de-me)*E;
vendor: 4,990 bytes, lines 11205-11253
11205m[v++]=be}}}return t.makeTensorInfo([h,u,c,f],"float32",m)}const uM={kernelName:Ni,backendName:"cpu",kernelFunc:lM};/**
11206 * @license
11207 * Copyright 2020 Google LLC. All Rights Reserved.
11208 * Licensed under the Apache License, Version 2.0 (the "License");
11209 * you may not use this file except in compliance with the License.
11210 * You may obtain a copy of the License at
11211 *
11212 * http://www.apache.org/licenses/LICENSE-2.0
11213 *
11214 * Unless required by applicable law or agreed to in writing, software
11215 * distributed under the License is distributed on an "AS IS" BASIS,
11216 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11217 * See the License for the specific language governing permissions and
11218 * limitations under the License.
11219 * =============================================================================
11220 */function cM(n){const{inputs:e,backend:t,attrs:s}=n,{images:r,dy:a}=e,{alignCorners:o}=s;ue([a,r],"resizeBilinearGrad");const i=fe(r.shape),[l,u,c,h]=r.shape,[,d,p]=a.shape,f=new Float32Array(l*u*c*h),g=[o&&d>1?u-1:u,o&&p>1?c-1:c],m=[o&&d>1?d-1:d,o&&p>1?p-1:p],y=g[0]/m[0],x=g[1]/m[1],v=t.data.get(a.dataId).values;let b=0;for(let C=0;C<l;C++){const $=C*i[0];for(let S=0;S<d;S++){const k=S*y,T=Math.floor(k),E=Math.min(Math.ceil(k),u-1),_=$+T*i[1],z=$+E*i[1],P=k-T,V=1-P;for(let B=0;B<p;B++){const M=B*x,j=Math.floor(M),U=Math.min(Math.ceil(M),c-1),q=M-j,X=1-q,Y=_+j*i[2],Z=_+U*i[2],J=z+j*i[2],re=z+U*i[2],Q=V*X,ae=V*q,ce=P*X,me=P*q;for(let de=0;de<h;de++){const be=v[b++];f[Y+de]+=be*Q,f[Z+de]+=be*ae,f[J+de]+=be*ce,f[re+de]+=be*me}}}}return t.makeTensorInfo([l,c,u,h],"float32",f)}const hM={kernelName:kc,backendName:"cpu",kernelFunc:cM};/**
11221 * @license
11222 * Copyright 2020 Google LLC. All Rights Reserved.
11223 * Licensed under the Apache License, Version 2.0 (the "License");
11224 * you may not use this file except in compliance with the License.
11225 * You may obtain a copy of the License at
11226 *
11227 * http://www.apache.org/licenses/LICENSE-2.0
11228 *
11229 * Unless required by applicable law or agreed to in writing, software
11230 * distributed under the License is distributed on an "AS IS" BASIS,
11231 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11232 * See the License for the specific language governing permissions and
11233 * limitations under the License.
11234 * =============================================================================
11235 */function dM(n){const{inputs:e,backend:t,attrs:s}=n,{images:r}=e,{alignCorners:a,halfPixelCenters:o,size:i}=s;ue(r,"resizeNearestNeighbor");const l=fe(r.shape),[u,c]=i,[h,d,p,f]=r.shape,g=t.data.get(r.dataId).values,m=new Float32Array(h*u*c*f),y=[a&&u>1?d-1:d,a&&c>1?p-1:p],x=[a&&u>1?u-1:u,a&&c>1?c-1:c],v=y[0]/x[0],b=y[1]/x[1];let C=0;for(let $=0;$<h;$++){const S=$*l[0];for(let k=0;k<u;k++){const T=o?v*(k+.5):v*k;let E=Math.min(d-1,a?Math.round(T):Math.floor(T));o&&(E=Math.max(0,E));const _=S+E*l[1];for(let z=0;z<c;z++){const P=o?b*(z+.5):b*z;let V=Math.min(p-1,a?Math.round(P):Math.floor(P));o&&(V=Math.max(0,V));const B=_+V*l[2];for(let M=0;M<f;M++){const j=g[B+M];m[C++]=j}}}}return t.makeTensorInfo([h,u,c,f],r.dtype,m)}const pM={kernelName:Ii,backendName:"cpu",kernelFunc:dM};/**
11236 * @license
11237 * Copyright 2020 Google LLC. All Rights Reserved.
11238 * Licensed under the Apache License, Version 2.0 (the "License");
11239 * you may not use this file except in compliance with the License.
11240 * You may obtain a copy of the License at
11241 *
11242 * http://www.apache.org/licenses/LICENSE-2.0
11243 *
11244 * Unless required by applicable law or agreed to in writing, software
11245 * distributed under the License is distributed on an "AS IS" BASIS,
11246 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11247 * See the License for the specific language governing permissions and
11248 * limitations under the License.
11249 * =============================================================================
11250 */function fM(n){const{inputs:e,backend:t,attrs:s}=n,{images:r,dy:a}=e,{alignCorners:o}=s;ue([a,r],"resizeNearestNeighborGrad");const i=fe(r.shape),l=fe(a.shape),[u,c,h,d]=r.shape,[,p,f]=a.shape,g=new Float32Array(u*c*h*d),m=t.data.get(a.dataId).values,y=[o&&p>1?c-1:c,o&&f>1?h-1:h],x=[o&&p>1?p-1:p,o&&f>1?f-1:f],v=y[0]/x[0],b=y[1]/x[1],C=1/v,$=1/b,S=Math.ceil(C)*2+2,k=Math.ceil($)*2+2;for(let T=0;T<u;T++){const E=T*i[0];for(let _=0;_<c;_++){const z=E+_*i[1],P=Math.floor(_*C),V=Math.floor(P-S/2);for(let B=0;B<h;B++){const M=z+B*i[2],j=Math.floor(B*$),U=Math.floor(j-k/2);for(let q=0;q<d;q++){let X=0;for(let Y=0;Y<S;Y++){const Z=Y+V;if(Z<0||Z>=p)continue;const J=E+Z*l[1],re=Z*v,Q=Math.min(c-1,o?Math.round(re):Math.floor(re));if(_===Q)for(let ae=0;ae<k;ae++){const ce=ae+U;if(ce<0||ce>=f)continue;const me=J+ce*l[2],de=ce*b,be=Math.min(h-1,o?Math.round(de):Math.floor(de));B===be&&(X+=m[me+q])}}g[M+q]=X}}}}return t.makeTensorInfo(r.shape,r.dtype,g)}const mM={kernelName:Tc,backendName:"cpu",kernelFunc:fM};/**
11251 * @license
11252 * Copyright 2020 Google LLC. All Rights Reserved.
11253 * Licensed under the Apache License, Version 2.0 (the "License");
11254 * you may not use this file except in compliance with the License.
11255 * You may obtain a copy of the License at
11256 *
11257 * http://www.apache.org/licenses/LICENSE-2.0
11258 *
11259 * Unless required by applicable law or agreed to in writing, software
11260 * distributed under the License is distributed on an "AS IS" BASIS,
11261 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11262 * See the License for the specific language governing permissions and
11263 * limitations under the License.
11264 * =============================================================================
11265 */function gM(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{dims:a}=s;ue(r,"reverse");const o=r.shape.length,i=Ie(a,r.shape);if(o===0)return jn({inputs:{x:r},backend:t});const l=new bt(r.shape,r.dtype),u=t.bufferSync(r);for(let c=0;c<l.size;c++){const h=l.indexToLoc(c),d=h.slice();i.forEach(p=>d[p]=r.shape[p]-1-d[p]),l.set(u.get(...d),...h)}return t.makeTensorInfo(l.shape,l.dtype,l.values)}const yM={kernelName:yi,backendName:"cpu",kernelFunc:gM};/**
11266 * @license
11267 * Copyright 2020 Google LLC. All Rights Reserved.
11268 * Licensed under the Apache License, Version 2.0 (the "License");
11269 * you may not use this file except in compliance with the License.
11270 * You may obtain a copy of the License at
11271 *
11272 * http://www.apache.org/licenses/LICENSE-2.0
11273 *
11274 * Unless required by applicable law or agreed to in writing, software
11275 * distributed under the License is distributed on an "AS IS" BASIS,
11276 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11277 * See the License for the specific language governing permissions and
11278 * limitations under the License.
11279 * =============================================================================
11280 */const xM={kernelName:Qu,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:s}=n,{radians:r,fillValue:a,center:o}=e,i=t,l=wt(s.dtype,H(s.shape)),[u,c,h,d]=s.shape,[p,f]=Ux(o,c,h),g=255,m=Math.sin(r),y=Math.cos(r),x=i.data.get(s.dataId).values;for(let b=0;b<u;b++){const C=b*h*c*d;for(let $=0;$<c;$++){const S=$*(h*d);for(let k=0;k<h;k++){const T=k*d;for(let E=0;E<d;E++){const _=[u,$,k,E],z=_[2],P=_[1];let V=(z-p)*y-(P-f)*m,B=(z-p)*m+(P-f)*y;V=Math.round(V+p),B=Math.round(B+f);let M=a;if(typeof a!="number"&&(E===3?M=g:M=a[E]),V>=0&&V<h&&B>=0&&B<c){const U=B*(h*d),q=V*d,X=C+U+q+E;M=x[X]}const j=C+S+T+E;l[j]=M}}}}return{dataId:i.write(l,s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};/**
11281 * @license
11282 * Copyright 2020 Google LLC. All Rights Reserved.
11283 * Licensed under the Apache License, Version 2.0 (the License);
11284 * you may not use this file except in compliance with the License.
11285 * You may obtain a copy of the License at
11286 *
11287 * http://www.apache.org/licenses/LICENSE-2.0
11288 *
11289 * Unless required by applicable law or agreed to in writing, software
11290 * distributed under the License is distributed on an AS IS BASIS,
11291 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11292 * See the License for the specific language governing permissions and
11293 * limitations under the License.
11294 * =============================================================================
11295 */const bM=Oe(ba,n=>{const e=Math.floor(n);return n-e<.5?Math.floor(n):n-e>.5?Math.ceil(n):e%2===0?e:e+1}),wM={kernelName:ba,backendName:"cpu",kernelFunc:bM};/**
11296 * @license
11297 * Copyright 2020 Google LLC. All Rights Reserved.
11298 * Licensed under the Apache License, Version 2.0 (the "License");
11299 * you may not use this file except in compliance with the License.
11300 * You may obtain a copy of the License at
11301 *
11302 * http://www.apache.org/licenses/LICENSE-2.0
11303 *
11304 * Unless required by applicable law or agreed to in writing, software
11305 * distributed under the License is distributed on an "AS IS" BASIS,
11306 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11307 * See the License for the specific language governing permissions and
11308 * limitations under the License.
11309 * =============================================================================
11310 */function vM(n){const{inputs:e,backend:t,attrs:s}=n,{indices:r,updates:a}=e,{shape:o}=s,{sliceRank:i,numUpdates:l,sliceSize:u,strides:c,outputSize:h}=Aa(a,r,o),d=!0,p=t.bufferSync(r),f=t.bufferSync(a),g=Ys(p,f,o,h,u,l,i,c,0,d);return t.makeTensorInfo(o,g.dtype,g.values)}const CM={kernelName:Hu,backendName:"cpu",kernelFunc:vM};/**
11311 * @license
11312 * Copyright 2022 Google LLC. All Rights Reserved.
11313 * Licensed under the Apache License, Version 2.0 (the "License");
11314 * you may not use this file except in compliance with the License.
11315 * You may obtain a copy of the License at
11316 *
11317 * http://www.apache.org/licenses/LICENSE-2.0
11318 *
11319 * Unless required by applicable law or agreed to in writing, software
11320 * distributed under the License is distributed on an "AS IS" BASIS,
11321 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11322 * See the License for the specific language governing permissions and
11323 * limitations under the License.
11324 * =============================================================================
11325 */function $M(n,e){let t=0,s=n.length,r=0;for(;t<s;)r=Math.floor((t+s)/2),n[r]<e?t=r+1:s=r;return s}function NM(n,e){let t=0,s=n.length,r=0;for(;t<s;)r=Math.floor((t+s)/2),n[r]<=e?t=r+1:s=r;return s}function IM(n,e,t,s,r,a){const o=Dt("int32",t*r);for(let i=0;i<t;++i){const l=n.slice(i*s,(i+1)*s),u=i*r;for(let c=0;c<r;++c)o[u+c]=a==="left"?$M(l,e[c+u]):NM(l,e[c+u])}return o}/**
11326 * @license
11327 * Copyright 2022 Google LLC. All Rights Reserved.
11328 * Licensed under the Apache License, Version 2.0 (the "License");
11329 * you may not use this file except in compliance with the License.
11330 * You may obtain a copy of the License at
11331 *
11332 * http://www.apache.org/licenses/LICENSE-2.0
11333 *
11334 * Unless required by applicable law or agreed to in writing, software
11335 * distributed under the License is distributed on an "AS IS" BASIS,
11336 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11337 * See the License for the specific language governing permissions and
11338 * limitations under the License.
11339 * =============================================================================
11340 */function SM(n){const{inputs:e,backend:t,attrs:s}=n,{sortedSequence:r,values:a}=e,{side:o}=s,i=t.data.get(r.dataId).values,l=t.data.get(a.dataId).values,u=IM(i,l,r.shape[0],r.shape[1],a.shape[1],o);return t.makeTensorInfo(a.shape,"int32",u)}const kM={kernelName:Du,backendName:"cpu",kernelFunc:SM};/**
11341 * @license
11342 * Copyright 2020 Google LLC. All Rights Reserved.
11343 * Licensed under the Apache License, Version 2.0 (the "License");
11344 * you may not use this file except in compliance with the License.
11345 * You may obtain a copy of the License at
11346 *
11347 * http://www.apache.org/licenses/LICENSE-2.0
11348 *
11349 * Unless required by applicable law or agreed to in writing, software
11350 * distributed under the License is distributed on an "AS IS" BASIS,
11351 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11352 * See the License for the specific language governing permissions and
11353 * limitations under the License.
11354 * =============================================================================
11355 */function TM(n){const{inputs:e,backend:t}=n,{condition:s,t:r,e:a}=e;ue([s,r,a],"select");const o=s.shape.length,i=t.data.get(s.dataId).values,l=t.data.get(r.dataId).values,u=t.data.get(a.dataId).values,c=bn(r.dtype,a.dtype),h=hn(H(r.shape),c);let d=0;const p=o===0||o>1||r.shape.length===1?1:H(r.shape.slice(1));for(let f=0;f<i.length;f++)for(let g=0;g<p;g++)i[f]===1?h[d++]=l[f]:h[d++]=u[f];return t.makeTensorInfo(r.shape,c,h)}const EM={kernelName:Ko,backendName:"cpu",kernelFunc:TM};/**
11356 * @license
11357 * Copyright 2020 Google LLC. All Rights Reserved.
11358 * Licensed under the Apache License, Version 2.0 (the License);
11359 * you may not use this file except in compliance with the License.
11360 * You may obtain a copy of the License at
11361 *
11362 * http://www.apache.org/licenses/LICENSE-2.0
11363 *
11364 * Unless required by applicable law or agreed to in writing, software
11365 * distributed under the License is distributed on an AS IS BASIS,
11366 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11367 * See the License for the specific language governing permissions and
11368 * limitations under the License.
11369 * =============================================================================
11370 */const RM=Ud,DM=Gd,AM=Oe(va,n=>n>=0?DM*n:RM*(Math.exp(n)-1)),OM={kernelName:va,backendName:"cpu",kernelFunc:AM};/**
11371 * @license
11372 * Copyright 2020 Google LLC. All Rights Reserved.
11373 * Licensed under the Apache License, Version 2.0 (the License);
11374 * you may not use this file except in compliance with the License.
11375 * You may obtain a copy of the License at
11376 *
11377 * http://www.apache.org/licenses/LICENSE-2.0
11378 *
11379 * Unless required by applicable law or agreed to in writing, softw
11379are
11380 * distributed under the License is distributed on an AS IS BASIS,
11381 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11382 * See the License for the specific language governing permissions and
11383 * limitations under the License.
11384 * =============================================================================
11385 */const _M=Oe(Ca,n=>n<0?-1:n>0?1:0),FM={kernelName:Ca,backendName:"cpu",kernelFunc:_M};/**
11386 * @license
11387 * Copyright 2020 Google LLC. All Rights Reserved.
11388 * Licensed under the Apache License, Version 2.0 (the License);
11389 * you may not use this file except in compliance with the License.
11390 * You may obtain a copy of the License at
11391 *
11392 * http://www.apache.org/licenses/LICENSE-2.0
11393 *
11394 * Unless required by applicable law or agreed to in writing, software
11395 * distributed under the License is distributed on an AS IS BASIS,
11396 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11397 * See the License for the specific language governing permissions and
11398 * limitations under the License.
11399 * =============================================================================
11400 */const LM=Oe($a,n=>Math.sin(n)),PM={kernelName:$a,backendName:"cpu",kernelFunc:LM};/**
11401 * @license
11402 * Copyright 2020 Google LLC. All Rights Reserved.
11403 * Licensed under the Apache License, Version 2.0 (the License);
11404 * you may not use this file except in compliance with the License.
11405 * You may obtain a copy of the License at
11406 *
11407 * http://www.apache.org/licenses/LICENSE-2.0
11408 *
11409 * Unless required by applicable law or agreed to in writing, software
11410 * distributed under the License is distributed on an AS IS BASIS,
11411 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11412 * See the License for the specific language governing permissions and
11413 * limitations under the License.
11414 * =============================================================================
11415 */const zM=Oe(Na,n=>Math.sinh(n)),VM={kernelName:Na,backendName:"cpu",kernelFunc:zM};/**
11416 * @license
11417 * Copyright 2020 Google LLC. All Rights Reserved.
11418 * Licensed under the Apache License, Version 2.0 (the License);
11419 * you may not use this file except in compliance with the License.
11420 * You may obtain a copy of the License at
11421 *
11422 * http://www.apache.org/licenses/LICENSE-2.0
11423 *
11424 * Unless required by applicable law or agreed to in writing, software
11425 * distributed under the License is distributed on an AS IS BASIS,
11426 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11427 * See the License for the specific language governing permissions and
11428 * limitations under the License.
11429 * =============================================================================
11430 */const BM=11920928955078125e-23,vy=Math.log(BM)+2,MM=Oe(ma,n=>{const e=n>-vy,t=n<vy,s=Math.exp(n);let r;return t?r=s:e?r=n:r=Math.log(1+s),r}),WM={kernelName:ma,backendName:"cpu",kernelFunc:MM};/**
11431 * @license
11432 * Copyright 2020 Google LLC. All Rights Reserved.
11433 * Licensed under the Apache License, Version 2.0 (the "License");
11434 * you may not use this file except in compliance with the License.
11435 * You may obtain a copy of the License at
11436 *
11437 * http://www.apache.org/licenses/LICENSE-2.0
11438 *
11439 * Unless required by applicable law or agreed to in writing, software
11440 * distributed under the License is distributed on an "AS IS" BASIS,
11441 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11442 * See the License for the specific language governing permissions and
11443 * limitations under the License.
11444 * =============================================================================
11445 */function UM(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{blockShape:a,paddings:o}=s;ue([r],"spaceToBatchND");const i=H(a),l=[[0,0]];l.push(...o);for(let $=1+a.length;$<r.shape.length;++$)l.push([0,0]);const u=X1.kernelFunc({inputs:{x:r},backend:t,attrs:{paddings:l,constantValue:0}}),c=Fc(u.shape,a,i,!1),h=Lc(c.length,a.length,!1),d=Pc(u.shape,a,i,!1),g=Me({inputs:{x:u},backend:t,attrs:{shape:c}}),x=Gt({inputs:{x:g},backend:t,attrs:{perm:h}}),C=Me({inputs:{x},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(x),C}const GM={kernelName:mi,backendName:"cpu",kernelFunc:UM};/**
11446 * @license
11447 * Copyright 2021 Google LLC. All Rights Reserved.
11448 * Licensed under the Apache License, Version 2.0 (the "License");
11449 * you may not use this file except in compliance with the License.
11450 * You may obtain a copy of the License at
11451 *
11452 * http://www.apache.org/licenses/LICENSE-2.0
11453 *
11454 * Unless required by applicable law or agreed to in writing, software
11455 * distributed under the License is distributed on an "AS IS" BASIS,
11456 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11457 * See the License for the specific language governing permissions and
11458 * limitations under the License.
11459 * =============================================================================
11460 */function HM(n){const{inputs:e,backend:t}=n,{indices:s,values:r,denseShape:a,defaultValue:o}=e;if(a.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
11461        ${a.shape}`);if(s.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
11462        ${s.shape}`);if(r.shape.length!==1)throw new Error(`Values must be a vector, saw:
11463        ${r.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
11464        ${o.shape}`);const i=t.data.get(s.dataId).values,l=t.data.get(r.dataId).values,u=t.data.get(a.dataId).values,c=t.data.get(o.dataId).values[0],[h,d,p,f,g]=$1(i,s.shape,s.dtype,l,r.dtype,u,c);return[t.makeTensorInfo(d,s.dtype,h),t.makeTensorInfo([d[0]],r.dtype,p),t.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(m=>Number(m)))),t.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const jM={kernelName:rc,backendName:"cpu",kernelFunc:HM};/**
11465 * @license
11466 * Copyright 2021 Google LLC. All Rights Reserved.
11467 * Licensed under the Apache License, Version 2.0 (the "License");
11468 * you may not use this file except in compliance with the License.
11469 * You may obtain a copy of the License at
11470 *
11471 * http://www.apache.org/licenses/LICENSE-2.0
11472 *
11473 * Unless required by applicable law or agreed to in writing, software
11474 * distributed under the License is distributed on an "AS IS" BASIS,
11475 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11476 * See the License for the specific language governing permissions and
11477 * limitations under the License.
11478 * =============================================================================
11479 */function qM(n){const{inputs:e,backend:t}=n,{inputIndices:s,inputShape:r,newShape:a}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape
11480        ${s.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape
11481        ${r.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.data.get(r.dataId).values),i=t.data.get(s.dataId).values,l=Array.from(t.data.get(a.dataId).values),[u,c,h]=N1(i,s.shape,s.dtype,o,l);return[t.makeTensorInfo(c,s.dtype,u),t.makeTensorInfo([h.length],a.dtype,new Int32Array(h))]}const KM={kernelName:ac,backendName:"cpu",kernelFunc:qM};/**
11482 * @license
11483 * Copyright 2021 Google LLC. All Rights Reserved.
11484 * Licensed under the Apache License, Version 2.0 (the "License");
11485 * you may not use this file except in compliance with the License.
11486 * You may obtain a copy of the License at
11487 *
11488 * http://www.apache.org/licenses/LICENSE-2.0
11489 *
11490 * Unless required by applicable law or agreed to in writing, software
11491 * distributed under the License is distributed on an "AS IS" BASIS,
11492 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11493 * See the License for the specific language governing permissions and
11494 * limitations under the License.
11495 * =============================================================================
11496 */function XM(n){const{inputs:e,backend:t}=n,{data:s,indices:r,segmentIds:a}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
11497          ${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
11498          ${a.shape}`);if(r.shape[0]!==a.shape[0])throw new Error("segmentIds and indices should have same size.");const o=t.data.get(s.dataId).values,i=t.data.get(r.dataId).values,l=t.data.get(a.dataId).values,[u,c]=eg(o,s.shape,s.dtype,i,l,!0);return t.makeTensorInfo(c,s.dtype,u)}const YM={kernelName:oc,backendName:"cpu",kernelFunc:XM};/**
11499 * @license
11500 * Copyright 2021 Google LLC. All Rights Reserved.
11501 * Licensed under the Apache License, Version 2.0 (the "License");
11502 * you may not use this file except in compliance with the License.
11503 * You may obtain a copy of the License at
11504 *
11505 * http://www.apache.org/licenses/LICENSE-2.0
11506 *
11507 * Unless required by applicable law or agreed to in writing, software
11508 * distributed under the License is distributed on an "AS IS" BASIS,
11509 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11510 * See the License for the specific language governing permissions and
11511 * limitations under the License.
11512 * =============================================================================
11513 */function JM(n){const{inputs:e,backend:t}=n,{data:s,indices:r,segmentIds:a}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
11514         ${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
11515         ${a.shape}`);if(r.shape[0]!==a.shape[0])throw new Error("segmentIds and indices should have same size.");const o=t.data.get(s.dataId).values,i=t.data.get(r.dataId).values,l=t.data.get(a.dataId).values,[u,c]=eg(o,s.shape,s.dtype,i,l);return t.makeTensorInfo(c,s.dtype,u)}const ZM={kernelName:ic,backendName:"cpu",kernelFunc:JM};/**
11516 * @license
11517 * Copyright 2020 Google LLC. All Rights Reserved.
11518 * Licensed under the Apache License, Version 2.0 (the "License");
11519 * you may not use this file except in compliance with the License.
11520 * You may obtain a copy of the License at
11521 *
11522 * http://www.apache.org/licenses/LICENSE-2.0
11523 *
11524 * Unless required by applicable law or agreed to in writing, software
11525 * distributed under the License is distributed on an "AS IS" BASIS,
11526 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11527 * See the License for the specific language governing permissions and
11528 * limitations under the License.
11529 * =============================================================================
11530 */function QM(n){const{inputs:e,backend:t,attrs:s}=n,{sparseIndices:r,sparseValues:a,defaultValue:o}=e,{outputShape:i}=s,{sliceRank:l,numUpdates:u,sliceSize:c,strides:h,outputSize:d}=Aa(a,r,i),p=!1,f=t.bufferSync(r);let g;switch(a.dtype){case"bool":{const m=t.bufferSync(a),y=!!t.data.get(o.dataId).values[0];g=Ys(f,m,i,d,c,u,l,h,y,p);break}case"float32":{const m=t.bufferSync(a),y=t.data.get(o.dataId).values[0];g=Ys(f,m,i,d,c,u,l,h,y,p);break}case"int32":{const m=t.bufferSync(a),y=t.data.get(o.dataId).values[0];g=Ys(f,m,i,d,c,u,l,h,y,p);break}case"string":{const m=t.bufferSync(a),y=Gi(t.data.get(o.dataId).values[0]);g=Ys(f,m,i,d,c,u,l,h,y,p);break}default:throw new Error(`Unsupported type ${a.dtype}`)}return t.makeTensorInfo(i,g.dtype,g.values)}const eW={kernelName:ju,backendName:"cpu",kernelFunc:QM};/**
11531 * @license
11532 * Copyright 2020 Google LLC. All Rights Reserved.
11533 * Licensed under the Apache License, Version 2.0 (the "License");
11534 * you may not use this file except in compliance with the License.
11535 * You may obtain a copy of the License at
11536 *
11537 * http://www.apache.org/licenses/LICENSE-2.0
11538 *
11539 * Unless required by applicable law or agreed to in writing, software
11540 * distributed under the License is distributed on an "AS IS" BASIS,
11541 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11542 * See the License for the specific language governing permissions and
11543 * limitations under the License.
11544 * =============================================================================
11545 */function tW(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{numOrSizeSplits:a,axis:o}=s,i=Ie(o,r.shape)[0],l=Gx(r,a,i),u=new Array(r.shape.length).fill(0),c=r.shape.slice();return l.map(h=>{const d=[...c];d[i]=h;const p=Ar({inputs:{x:r},backend:t,attrs:{begin:u,size:d}});return u[i]+=h,p})}const nW={kernelName:bi,backendName:"cpu",kernelFunc:tW};/**
11546 * @license
11547 * Copyright 2019 Google LLC. All Rights Reserved.
11548 * Licensed under the Apache License, Version 2.0 (the "License");
11549 * you may not use this file except in compliance with the License.
11550 * You may obtain a copy of the License at
11551 *
11552 * http://www.apache.org/licenses/LICENSE-2.0
11553 *
11554 * Unless required by applicable law or agreed to in writing, softw
11554are
11555 * distributed under the License is distributed on an "AS IS" BASIS,
11556 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11557 * See the License for the specific language governing permissions and
11558 * limitations under the License.
11559 * =============================================================================
11560 */const sW={kernelName:Ec,backendName:"cpu",kernelFunc:({inputs:n,backend:e})=>{const{x:t}=n,s=e;ue(t,"square");const r=s.data.get(t.dataId).values,a=new Float32Array(r.length);for(let i=0;i<r.length;++i){const l=r[i];a[i]=l*l}return{dataId:s.write(a,t.shape,t.dtype),shape:t.shape,dtype:t.dtype}}};/**
11561 * @license
11562 * Copyright 2020 Google LLC. All Rights Reserved.
11563 * Licensed under the Apache License, Version 2.0 (the License);
11564 * you may not use this file except in compliance with the License.
11565 * You may obtain a copy of the License at
11566 *
11567 * http://www.apache.org/licenses/LICENSE-2.0
11568 *
11569 * Unless required by applicable law or agreed to in writing, software
11570 * distributed under the License is distributed on an AS IS BASIS,
11571 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11572 * See the License for the specific language governing permissions and
11573 * limitations under the License.
11574 * =============================================================================
11575 */const rW=Oe(zi,(n,e)=>{const t=e;return isNaN(n)?NaN:n>0?1:t.alpha}),aW={kernelName:zi,backendName:"cpu",kernelFunc:rW};/**
11576 * @license
11577 * Copyright 2020 Google LLC. All Rights Reserved.
11578 * Licensed under the Apache License, Version 2.0 (the "License");
11579 * you may not use this file except in compliance with the License.
11580 * You may obtain a copy of the License at
11581 *
11582 * http://www.apache.org/licenses/LICENSE-2.0
11583 *
11584 * Unless required by applicable law or agreed to in writing, software
11585 * distributed under the License is distributed on an "AS IS" BASIS,
11586 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11587 * See the License for the specific language governing permissions and
11588 * limitations under the License.
11589 * =============================================================================
11590 */function oW(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{begin:a,end:o,strides:i,beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:h,shrinkAxisMask:d}=s;ue(r,"stridedSlice");const{finalShapeSparse:p,finalShape:f,isIdentity:g,sliceDim0:m,isSimpleSlice:y,begin:x,end:v,strides:b}=Hx(r.shape,a,o,i,l,u,c,h,d);let C;if(g)C=Me({inputs:{x:r},backend:t,attrs:{shape:f}});else if(m||y){I(r.shape.length>=1,()=>`Input must have rank at least 1, got: ${r.shape.length}`);const $=jx(x,v,b),S=Ar({inputs:{x:r},backend:t,attrs:{begin:x,size:$}});C=Me({inputs:{x:S},backend:t,attrs:{shape:f}}),t.disposeIntermediateTensorInfo(S)}else{const $=t.bufferSync(r),S=k1(p,$,b,x);C=t.makeTensorInfo(f,S.dtype,S.values)}return C}const iW={kernelName:Mu,backendName:"cpu",kernelFunc:oW};/**
11591 * @license
11592 * Copyright 2021 Google LLC. All Rights Reserved.
11593 * Licensed under the Apache License, Version 2.0 (the "License");
11594 * you may not use this file except in compliance with the License.
11595 * You may obtain a copy of the License at
11596 *
11597 * http://www.apache.org/licenses/LICENSE-2.0
11598 *
11599 * Unless required by applicable law or agreed to in writing, software
11600 * distributed under the License is distributed on an "AS IS" BASIS,
11601 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11602 * See the License for the specific language governing permissions and
11603 * limitations under the License.
11604 * =============================================================================
11605 */function lW(n){const{inputs:e,backend:t,attrs:s}=n,{separator:r,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:u}=s,{data:c,dataSplits:h}=e,d=t.data.get(c.dataId).values,p=t.data.get(h.dataId).values,[f,g]=bx(d,p,r,a,o,i,l,u);return[t.makeTensorInfo([f.length],"string",f),t.makeTensorInfo(h.shape,"int32",g)]}const uW={kernelName:lc,backendName:"cpu",kernelFunc:lW};/**
11606 * @license
11607 * Copyright 2021 Google LLC. All Rights Reserved.
11608 * Licensed under the Apache License, Version 2.0 (the "License");
11609 * you may not use this file except in compliance with the License.
11610 * You may obtain a copy of the License at
11611 *
11612 * http://www.apache.org/licenses/LICENSE-2.0
11613 *
11614 * Unless required by applicable law or agreed to in writing, software
11615 * distributed under the License is distributed on an "AS IS" BASIS,
11616 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11617 * See the License for the specific language governing permissions and
11618 * limitations under the License.
11619 * =============================================================================
11620 */function cW(n){const{inputs:e,backend:t,attrs:s}=n,{skipEmpty:r}=s,{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.data.get(a.dataId).values,l=t.data.get(o.dataId).values[0],[u,c,h]=wx(i,l,r),d=c.length;return[t.makeTensorInfo([d,2],"int32",u),t.makeTensorInfo([d],"string",c),t.makeTensorInfo([2],"int32",new Int32Array(h))]}const hW={kernelName:uc,backendName:"cpu",kernelFunc:cW};/**
11621 * @license
11622 * Copyright 2021 Google LLC. All Rights Reserved.
11623 * Licensed under the Apache License, Version 2.0 (the "License");
11624 * you may not use this file except in compliance with the License.
11625 * You may obtain a copy of the License at
11626 *
11627 * http://www.apache.org/licenses/LICENSE-2.0
11628 *
11629 * Unless required by applicable law or agreed to in writing, software
11630 * distributed under the License is distributed on an "AS IS" BASIS,
11631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11632 * See the License for the specific language governing permissions and
11633 * limitations under the License.
11634 * =============================================================================
11635 */function dW(n){const{inputs:e,backend:t,attrs:s}=n,{numBuckets:r}=s,{input:a}=e;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");const o=t.data.get(a.dataId).values,i=vx(o,r);return t.makeTensorInfo(a.shape,"int32",i)}const pW={kernelName:cc,backendName:"cpu",kernelFunc:dW};/**
11636 * @license
11637 * Copyright 2020 Google LLC. All Rights Reserved.
11638 * Licensed under the Apache License, Version 2.0 (the License);
11639 * you may not use this file except in compliance with the License.
11640 * You may obtain a copy of the License at
11641 *
11642 * http://www.apache.org/licenses/LICENSE-2.0
11643 *
11644 * Unless required by applicable law or agreed to in writing, software
11645 * distributed under the License is distributed on an AS IS BASIS,
11646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11647 * See the License for the specific language governing permissions and
11648 * limitations under the License.
11649 * =============================================================================
11650 */const fW=Oe(Sa,n=>Math.tan(n)),mW={kernelName:Sa,backendName:"cpu",kernelFunc:fW};/**
11651 * @license
11652 * Copyright 2020 Google LLC. All Rights Reserved.
11653 * Licensed under the Apache License, Version 2.0 (the License);
11654 * you may not use this file except in compliance with the License.
11655 * You may obtain a copy of the License at
11656 *
11657 * http://www.apache.org/licenses/LICENSE-2.0
11658 *
11659 * Unless required by applicable law or agreed to in writing, software
11660 * distributed under the License is distributed on an AS IS BASIS,
11661 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11662 * See the License for the specific language governing permissions and
11663 * limitations under the License.
11664 * =============================================================================
11665 */const gW=Oe(Zr,n=>Math.tanh(n)),yW={kernelName:Zr,backendName:"cpu",kernelFunc:gW};/**
11666 * @license
11667 * Copyright 2022 Google LLC. All Rights Reserved.
11668 * Licensed under the Apache License, Version 2.0 (the "License");
11669 * you may not use this file except in compliance with the License.
11670 * You may obtain a copy of the License at
11671 *
11672 * http://www.apache.org/licenses/LICENSE-2.0
11673 *
11674 * Unless required by applicable law or agreed to in writing, softw
11674are
11675 * distributed under the License is distributed on an "AS IS" BASIS,
11676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11677 * See the License for the specific language governing permissions and
11678 * limitations under the License.
11679 * =============================================================================
11680 */function xW(n){const{inputs:e,backend:t}=n,{tensor:s,indices:r,updates:a}=e,{sliceRank:o,numUpdates:i,sliceSize:l,strides:u,outputSize:c}=Aa(a,r,s.shape),h=!1,d=t.bufferSync(r),p=t.bufferSync(a),f=t.bufferSync(s),g=Ys(d,p,s.shape,c,l,i,o,u,f,h);return t.makeTensorInfo(s.shape,g.dtype,g.values)}const bW={kernelName:Wu,backendName:"cpu",kernelFunc:xW};/**
11681 * @license
11682 * Copyright 2020 Google LLC. All Rights Reserved.
11683 * Licensed under the Apache License, Version 2.0 (the "License");
11684 * you may not use this file except in compliance with the License.
11685 * You may obtain a copy of the License at
11686 *
11687 * http://www.apache.org/licenses/LICENSE-2.0
11688 *
11689 * Unless required by applicable law or agreed to in writing, software
11690 * distributed under the License is distributed on an "AS IS" BASIS,
11691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11692 * See the License for the specific language governing permissions and
11693 * limitations under the License.
11694 * =============================================================================
11695 */function wW(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{reps:a}=s;ue(r,"tile");const o=E1(t.bufferSync(r),a);return t.makeTensorInfo(o.shape,o.dtype,o.values)}const vW={kernelName:Qr,backendName:"cpu",kernelFunc:wW};/**
11696 * @license
11697 * Copyright 2020 Google LLC. All Rights Reserved.
11698 * Licensed under the Apache License, Version 2.0 (the "License");
11699 * you may not use this file except in compliance with the License.
11700 * You may obtain a copy of the License at
11701 *
11702 * http://www.apache.org/licenses/LICENSE-2.0
11703 *
11704 * Unless required by applicable law or agreed to in writing, software
11705 * distributed under the License is distributed on an "AS IS" BASIS,
11706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11707 * See the License for the specific language governing permissions and
11708 * limitations under the License.
11709 * =============================================================================
11710 */function CW(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{k:a,sorted:o}=s;ue(r,"topk");const i=t.data.get(r.dataId).values,[l,u]=D1(i,r.shape,r.dtype,a,o);return[t.makeTensorInfo(l.shape,l.dtype,l.values),t.makeTensorInfo(u.shape,u.dtype,u.values)]}const $W={kernelName:Uu,backendName:"cpu",kernelFunc:CW};/**
11711 * @license
11712 * Copyright 2021 Google LLC. All Rights Reserved.
11713 * Licensed under the Apache License, Version 2.0 (the "License");
11714 * you may not use this file except in compliance with the License.
11715 * You may obtain a copy of the License at
11716 *
11717 * http://www.apache.org/licenses/LICENSE-2.0
11718 *
11719 * Unless required by applicable law or agreed to in writing, software
11720 * distributed under the License is distributed on an "AS IS" BASIS,
11721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11722 * See the License for the specific language governing permissions and
11723 * limitations under the License.
11724 * =============================================================================
11725 */function NW(n){const{inputs:e,attrs:t,backend:s}=n,{image:r,transforms:a}=e,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=t,[c,h,d,p]=r.shape,[f,g]=u??[h,d],m=[c,f,g,p],y=fe(r.shape),x=y[0],v=y[1],b=y[2],C=fe(m),$=C[0],S=C[1],k=C[2],T=wt(r.dtype,H(m));T.fill(l);const E=s.data.get(r.dataId).values,_=s.data.get(a.dataId).values;for(let P=0;P<c;++P){const V=a.shape[0]===1?_:_.subarray(P*8,P*8+8);for(let B=0;B<f;++B)for(let M=0;M<g;++M)for(let j=0;j<p;++j){let U;const q=V[6]*M+V[7]*B+1;if(q===0)continue;const X=(V[0]*M+V[1]*B+V[2])/q,Y=(V[3]*M+V[4]*B+V[5])/q,Z=Cy(X,d,i),J=Cy(Y,h,i);switch(o){case"nearest":U=RW(E,h,d,x,v,b,P,J,Z,j,l);break;case"bilinear":U=DW(E,h,d,x,v,b,P,J,Z,j,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${o}`)}const re=P*$+B*S+M*k+j;T[re]=U}return s.makeTensorInfo(m,r.dtype,T)}return{dataId:s.write(T,m,r.dtype),shape:r.shape,dtype:r.dtype}}const IW={kernelName:sc,backendName:"cpu",kernelFunc:NW};
vendor: 8,650 bytes, lines 11725-11815
11725function Cy(n,e,t){switch(t){case"reflect":return SW(n,e);case"wrap":return kW(n,e);case"nearest":return EW(n,e);case"constant":default:return TW(n)}}function SW(n,e){let t=n;if(t<0)if(e<=1)t=0;else{const s=2*e;t<s&&(t=s*Math.trunc(-t/s)+t),t=t<-e?t+s:-t-1}else if(t>e-1)if(e<=1)t=0;else{const s=2*e;t-=s*Math.trunc(t/s),t>=e&&(t=s-t-1)}return Qd(0,t,e-1)}function kW(n,e){let t=n;if(t<0)if(e<=1)t=0;else{const s=e-1;t+=e*(Math.trunc(-t/s)+1)}else if(t>e-1)if(e<=1)t=0;else{const s=e-1;t-=e*Math.trunc(t/s)}return Qd(0,t,e-1)}function TW(n,e){return n}function EW(n,e){return Qd(0,n,e-1)}function uo(n,e,t,s,r,a,o,i,l,u,c){const h=o*s+i*r+l*a+u;return 0<=i&&i<e&&0<=l&&l<t?n[h]:c}function RW(n,e,t,s,r,a,o,i,l,u,c){const h=Math.round(i),d=Math.round(l);return uo(n,e,t,s,r,a,o,h,d,u,c)}function DW(n,e,t,s,r,a,o,i,l,u,c){const h=Math.floor(i),d=Math.floor(l),p=h+1,f=d+1,g=(f-l)*uo(n,e,t,s,r,a,o,h,d,u,c)+(l-d)*uo(n,e,t,s,r,a,o,h,f,u,c),m=(f-l)*uo(n,e,t,s,r,a,o,p,d,u,c)+(l-d)*uo(n,e,t,s,r,a,o,p,f,u,c);return(p-i)*g+(i-h)*m}/**
11726 * @license
11727 * Copyright 2020 Google LLC. All Rights Reserved.
11728 * Licensed under the Apache License, Version 2.0 (the License);
11729 * you may not use this file except in compliance with the License.
11730 * You may obtain a copy of the License at
11731 *
11732 * http://www.apache.org/licenses/LICENSE-2.0
11733 *
11734 * Unless required by applicable law or agreed to in writing, software
11735 * distributed under the License is distributed on an AS IS BASIS,
11736 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11737 * See the License for the specific language governing permissions and
11738 * limitations under the License.
11739 * =============================================================================
11740 */function AW(n){const{inputs:e,attrs:t,backend:s}=n,{axis:r}=t,{x:a}=e;ue(a,"unique");const o=s.data.get(a.dataId).values,{outputValues:i,outputShape:l,indices:u}=Cx(o,r,a.shape,a.dtype);return[s.makeTensorInfo(l,a.dtype,i),s.makeTensorInfo([u.length],"int32",u)]}const OW={kernelName:Gu,backendName:"cpu",kernelFunc:AW};/**
11741 * @license
11742 * Copyright 2020 Google LLC. All Rights Reserved.
11743 * Licensed under the Apache License, Version 2.0 (the "License");
11744 * you may not use this file except in compliance with the License.
11745 * You may obtain a copy of the License at
11746 *
11747 * http://www.apache.org/licenses/LICENSE-2.0
11748 *
11749 * Unless required by applicable law or agreed to in writing, software
11750 * distributed under the License is distributed on an "AS IS" BASIS,
11751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11752 * See the License for the specific language governing permissions and
11753 * limitations under the License.
11754 * =============================================================================
11755 */function _W(n){const{inputs:e,backend:t,attrs:s}=n,{value:r}=e;let{axis:a}=s;a<0&&(a+=r.shape.length);const o=r.shape.length,i=r.shape[a],l=new Array(o-1);let u=0;for(let p=0;p<o;p++)p!==a&&(l[u++]=r.shape[p]);const c=new Array(o).fill(0),h=r.shape.slice();h[a]=1;const d=new Array(i);for(let p=0;p<d.length;p++){c[a]=p;const f=Ar({inputs:{x:r},backend:t,attrs:{begin:c,size:h}});d[p]=Me({inputs:{x:f},backend:t,attrs:{shape:l}}),t.disposeIntermediateTensorInfo(f)}return d}const FW={kernelName:Ci,backendName:"cpu",kernelFunc:_W};/**
11756 * @license
11757 * Copyright 2020 Google LLC. All Rights Reserved.
11758 * Licensed under the Apache License, Version 2.0 (the "License");
11759 * you may not use this file except in compliance with the License.
11760 * You may obtain a copy of the License at
11761 *
11762 * http://www.apache.org/licenses/LICENSE-2.0
11763 *
11764 * Unless required by applicable law or agreed to in writing, software
11765 * distributed under the License is distributed on an "AS IS" BASIS,
11766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11767 * See the License for the specific language governing permissions and
11768 * limitations under the License.
11769 * =============================================================================
11770 */function LW(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,segmentIds:a}=e,{numSegments:o}=s;ue(r,"unsortedSegmentSum");const i=r.shape.length,l=a.shape.length,u=[],c=[],h=i-l;let d=a;for(let f=0;f<h;++f){const g=pu({inputs:{input:d},backend:t,attrs:{dim:f+1}});d=g,c.push(g)}for(let f=0;f<o;++f){const g=_s(f,"int32"),m=t.makeTensorInfo([],"int32",g),y=Z0({inputs:{a:m,b:d},backend:t}),x=Ds({inputs:{x:y},backend:t,attrs:{dtype:"float32"}}),v=_h({inputs:{a:x,b:r},backend:t}),b=gl({inputs:{x:v},backend:t,attrs:{axis:0,keepDims:!1}});u.push(b),c.push(m),c.push(y),c.push(x),c.push(v),c.push(b)}const p=K1({inputs:u,backend:t,attrs:{axis:0}});return c.forEach(f=>t.disposeIntermediateTensorInfo(f)),p}const PW={kernelName:vi,backendName:"cpu",kernelFunc:LW};/**
11771 * @license
11772 * Copyright 2020 Google LLC. All Rights Reserved.
11773 * Licensed under the Apache License, Version 2.0 (the "License");
11774 * you may not use this file except in compliance with the License.
11775 * You may obtain a copy of the License at
11776 *
11777 * http://www.apache.org/licenses/LICENSE-2.0
11778 *
11779 * Unless required by applicable law or agreed to in writing, software
11780 * distributed under the License is distributed on an "AS IS" BASIS,
11781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11782 * See the License for the specific language governing permissions and
11783 * limitations under the License.
11784 * =============================================================================
11785 */const zW=[Az,gP,_z,Lz,CP,zz,Bz,Wz,Gz,jz,Kz,Yz,Zz,t3,s3,o3,l3,c3,d3,Rz,f3,g3,x3,NP,w3,wP,SP,C3,yP,N3,S3,k3,E3,D3,O3,F3,P3,V3,M3,U3,H3,q3,X3,J3,Z3,eV,nV,rV,aV,oV,iV,uV,dV,$z,fV,kP,CV,TP,$V,RP,EV,RV,AV,AP,_P,_V,LV,zV,BV,LP,zP,xP,WV,I3,GV,jV,KV,Nz,BP,WP,YV,GP,ZV,tB,sB,oB,lB,cB,hB,jP,pB,mB,yB,bB,vB,$B,IB,KP,kB,RB,OB,YP,ZP,LB,VB,WB,ez,GB,jB,qB,X1,JB,Sz,sz,QB,tM,sM,aM,bP,$d,iM,kz,Tz,Ez,uM,hM,pM,mM,yM,xM,wM,hz,CM,kM,EM,OM,pz,FM,PM,VM,u$,DB,WM,GM,jM,KM,YM,ZM,eW,nW,gz,sW,xz,wz,aW,iW,uW,hW,pW,Cz,cV,mW,yW,bW,vW,$W,IW,tz,OW,FW,PW,HB];for(const n of zW)ep(n);/**
11786 * @license
11787 * Copyright 2018 Google LLC. All Rights Reserved.
11788 * Licensed under the Apache License, Version 2.0 (the "License");
11789 * you may not use this file except in compliance with the License.
11790 * You may obtain a copy of the License at
11791 *
11792 * http://www.apache.org/licenses/LICENSE-2.0
11793 *
11794 * Unless required by applicable law or agreed to in writing, software
11795 * distributed under the License is distributed on an "AS IS" BASIS,
11796 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11797 * See the License for the specific language governing permissions and
11798 * limitations under the License.
11799 * =============================================================================
11800 */const Xs={},Al={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Y1(n,e){Xs[n]=e}function On(n,e){if(!(n in Xs)||e!=null){const s=BW(n,e);if(s!==null)Xs[n]=s;else return null}const t=Xs[n];return t==null||t.isContextLost()?(delete Xs[n],On(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),Xs[n])}function VW(n){if(!W().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 BW(n,e){if(n!==1&&n!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=e??VW(n);return t.addEventListener("webglcontextlost",s=>{s.preventDefault(),delete Xs[n]},!1),W().getBool("SOFTWARE_WEBGL_ENABLED")&&(Al.failIfMajorPerformanceCaveat=!1),n===1?t.getContext("webgl",Al)||t.getContext("experimental-webgl",Al):t.getContext("webgl2",Al)}/**
11801 * @license
11802 * Copyright 2017 Google LLC. All Rights Reserved.
11803 * Licensed under the Apache License, Version 2.0 (the "License");
11804 * you may not use this file except in compliance with the License.
11805 * You may obtain a copy of the License at
11806 *
11807 * http://www.apache.org/licenses/LICENSE-2.0
11808 *
11809 * Unless required by applicable law or agreed to in writing, software
11810 * distributed under the License is distributed on an "AS IS" BASIS,
11811 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11812 * See the License for the specific language governing permissions and
11813 * limitations under the License.
11814 * =============================================================================
11815 */var So;(function(n){n[n.DENSE=0]="DENSE",n[n.SHARED_BATCH=1]="SHARED_BATCH"})(So||(So={}));
11815var rn;(function(n){n[n.RENDER=0]="RENDER",n[n.UPLOAD=1]="UPLOAD",n[n.PIXELS=2]="PIXELS",n[n.DOWNLOAD=3]="DOWNLOAD"})(rn||(rn={}));var yt;(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"})(yt||(yt={}));function yl(n,e){return[e,n]}function MW(n,e){return n*e}function Ol(n){const e=H(n),t=Math.ceil(e/4);return Qh(t)}function ja(n,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(n/2))]}function WW(n,e){const[t,s]=ja(n,e);return t*s*4}function ag(n,e){const t=n;let s,r,a,o,i,l,u,c,h,d;return W().getNumber("WEBGL_VERSION")===2?(s=t.R32F,r=t.R16F,a=t.RGBA16F,o=t.RGBA32F,i=t.RED,u=4,c=1,h=t.HALF_FLOAT,d=t.FLOAT,l=t.RGBA8):(s=n.RGBA,r=n.RGBA,a=n.RGBA,o=t.RGBA,i=n.RGBA,u=4,c=4,h=e!=null?e.HALF_FLOAT_OES:null,d=n.FLOAT,l=n.RGBA),{internalFormatFloat:s,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:o,textureFormatFloat:i,downloadTextureFormat:l,downloadUnpackNumChannels:u,defaultNumChannels:c,textureTypeHalfFloat:h,textureTypeFloat:d}}/**
11816 * @license
11817 * Copyright 2017 Google LLC. All Rights Reserved.
11818 * Licensed under the Apache License, Version 2.0 (the "License");
11819 * you may not use this file except in compliance with the License.
11820 * You may obtain a copy of the License at
11821 *
11822 * http://www.apache.org/licenses/LICENSE-2.0
11823 *
11824 * Unless required by applicable law or agreed to in writing, software
11825 * distributed under the License is distributed on an "AS IS" BASIS,
11826 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11827 * See the License for the specific language governing permissions and
11828 * limitations under the License.
11829 * =============================================================================
11830 */function se(n,e){const t=e();return W().getBool("DEBUG")&&UW(n),t}function UW(n){const e=n.getError();if(e!==n.NO_ERROR)throw new Error("WebGL Error: "+Z1(n,e))}const GW=596e-10,HW=65504;function J1(n){return!!(W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||n===0||GW<Math.abs(n)&&Math.abs(n)<HW)}function Z1(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 co(n,e){return us(n,()=>n.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function Q1(n,e){const t=us(n,()=>n.createShader(n.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(se(n,()=>n.shaderSource(t,e)),se(n,()=>n.compileShader(t)),n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw n.getShaderInfoLog(t),new Error("Failed to compile vertex shader.");return t}function ev(n,e){const t=us(n,()=>n.createShader(n.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(se(n,()=>n.shaderSource(t,e)),se(n,()=>n.compileShader(t)),W().get("ENGINE_COMPILE_ONLY"))return t;if(n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw og(e,n.getShaderInfoLog(t)),new Error("Failed to compile fragment shader.");return t}const jW=/ERROR: [0-9]+:([0-9]+):/g;function og(n,e){const t=jW.exec(e);if(t==null){`${e}`;return}const s=+t[1],r=n.split(`
11831`),a=r.length.toString().length+2,o=r.map((h,d)=>$g((d+1).toString(),a)+h);let i=0;for(let h=0;h<o.length;h++)i=Math.max(o[h].length,i);const l=o.slice(0,s-1),u=o.slice(s-1,s),c=o.slice(s);l.join(`
11832`),e.split(`
11833`)[0],`${$g(u[0],i)}`,c.join(`
11834`)}function tv(n){return us(n,()=>n.createProgram(),"Unable to create WebGLProgram.")}function nv(n,e){if(se(n,()=>n.linkProgram(e)),!W().get("ENGINE_COMPILE_ONLY")&&n.getProgramParameter(e,n.LINK_STATUS)===!1)throw n.getProgramInfoLog(e),new Error("Failed to link vertex and fragment shaders.")}function zl(n,e){if(se(n,()=>n.validateProgram(e)),n.getProgramParameter(e,n.VALIDATE_STATUS)===!1)throw n.getProgramInfoLog(e),new Error("Shader program validation failed.")}function sv(n,e){const t=us(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return se(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),se(n,()=>n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function rv(n,e){const t=us(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return se(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t)),se(n,()=>n.bufferData(n.ELEMENT_ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function qW(){return W().getNumber("WEBGL_VERSION")===2?1:4}function av(n){return us(n,()=>n.createTexture(),"Unable to create WebGLTexture.")}function ov(n,e){const t=W().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(n<=0||e<=0){const s=`[${n}x${e}]`;
vendor: 5,187 bytes, line 11834
11834throw new Error("Requested texture size "+s+" is invalid.")}if(n>t||e>t){const s=`[${n}x${e}]`,r=`[${t}x${t}]`;throw new Error("Requested texture size "+s+" greater than WebGL maximum on this browser / GPU "+r+".")}}function iv(n){return us(n,()=>n.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function Id(n,e,t,s,r,a,o){const i=n.getAttribLocation(e,t);return i===-1?!1:(se(n,()=>n.bindBuffer(n.ARRAY_BUFFER,s)),se(n,()=>n.vertexAttribPointer(i,r,n.FLOAT,!1,a,o)),se(n,()=>n.enableVertexAttribArray(i)),!0)}function lv(n,e,t){pv(n,t),se(n,()=>n.activeTexture(n.TEXTURE0+t)),se(n,()=>n.bindTexture(n.TEXTURE_2D,e))}function KW(n,e){pv(n,e),se(n,()=>n.activeTexture(n.TEXTURE0+e)),se(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function uv(n,e,t){return us(n,()=>n.getUniformLocation(e,t),'uniform "'+t+'" not present in program.')}function cv(n,e,t){return n.getUniformLocation(e,t)}function hv(n,e,t,s){se(n,()=>lv(n,e,s)),se(n,()=>n.uniform1i(t,s))}function XW(n){se(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,null)),se(n,()=>n.viewport(0,0,n.canvas.width,n.canvas.height)),se(n,()=>n.scissor(0,0,n.canvas.width,n.canvas.height))}function Vl(n,e,t){se(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,t)),se(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0))}function Sd(n,e){se(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,e)),se(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,null,0))}function ho(n){const e=n.checkFramebufferStatus(n.FRAMEBUFFER);if(e!==n.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+dv(n,e))}function dv(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 us(n,e,t){const s=se(n,()=>e());if(s==null)throw new Error(t);return s}function pv(n,e){const t=n.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,s=e+n.TEXTURE0;if(s<n.TEXTURE0||s>t){const r=`[gl.TEXTURE0, gl.TEXTURE${t}]`;throw new Error(`textureUnit must be in ${r}.`)}}function cr(n,e=2){return H(n.slice(0,n.length-e))}function hr(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 po(n){let e=[1,1,1];return n.length===0||n.length===1&&n[0]===1||(e=[cr(n),...hr(n)]),e}function fv(n,e=!1){let t=W().getNumber("WEBGL_MAX_TEXTURE_SIZE"),s=W().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");s===1/0&&W().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(s=t/2),e&&(t=t*2,s=s*2,n=n.map((i,l)=>l>=n.length-2?tp(n[l]):n[l]),n.length===1&&(n=[2,n[0]])),n.length!==2&&(n=Os(n).newShape);let r=H(n),a=null;n.length<=1&&r<=t?a=[1,r]: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)>s&&Math.min(...a)<=(e?2:1)&&Math.min(...a)>0;if(a==null||o)if(e){const i=cr(n);let l=2,u=2;n.length&&([l,u]=hr(n)),r=i*(l/2)*(u/2),a=Qh(r).map(c=>c*2)}else a=Qh(r);return a}function _l(n){return n%2===0}function ko(n,e){if(n=n.slice(-2),e=e.slice(-2),ke(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],s=e[e.length-1];if(t===s||_l(t)&&_l(s)&&(n[0]===1||e[0]===1))return!0}return n[1]===e[1]&&_l(n[0])&&_l(e[0])}let Bl,Ml;function mv(n){if(Bl==null){const e=On(n);Bl=e.getParameter(e.MAX_TEXTURE_SIZE)}return Bl}function YW(){Bl=null}function JW(){Ml=null}function gv(n){if(Ml==null){const e=On(n);Ml=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Ml)}function yv(n){if(n===0)return 0;let e;const t=On(n);return an(t,"EXT_disjoint_timer_query_webgl2")&&n===2?e=2:an(t,"EXT_disjoint_timer_query")?e=1:e=0,e}function an(n,e){return n.getExtension(e)!=null}function kd(n){try{if(On(n)!=null)return!0}catch(e){return!1}return!1}function xv(n){if(n===0)return!1;const e=On(n);if(n===1){if(!an(e,"OES_texture_float"))return!1}else if(!an(e,"EXT_color_buffer_float"))return!1;return Td(e)}function bv(n){if(n===0)return!1;const e=On(n);if(n===1){if(!an(e,"OES_texture_float")||!an(e,"WEBGL_color_buffer_float"))return!1}else{if(an(e,"EXT_color_buffer_float"))return Td(e);const s="EXT_color_buffer_half_float";if(an(e,s)){const r=e.getExtension(s);return ZW(e,r)}return!1}return Td(e)}function Td(n){const e=ag(n),t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texImage2D(n.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const 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}
11834function ZW(n,e){const t=ag(n,e),s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),n.texImage2D(n.TEXTURE_2D,0,t.internalFormatHalfFloat,1,1,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,s,0);const i=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(s),n.deleteFramebuffer(o),i}function wv(n){return n!==2?!1:On(n).fenceSync!=null}function qa(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>{t!=null&&I(t.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the WebGL backend.`)})}const QW=Object.freeze(Object.defineProperty({__proto__:null,assertNotComplex:qa,bindCanvasToFramebuffer:XW,bindColorTextureToFramebuffer:Vl,bindTextureToProgramUniformSampler:hv,bindTextureUnit:lv,bindVertexBufferToProgramAttribute:Id,callAndCheck:se,canBeRepresented:J1,createFragmentShader:ev,createFramebuffer:iv,createProgram:tv,createStaticIndexBuffer:rv,createStaticVertexBuffer:sv,createTexture:av,createVertexShader:Q1,getBatchDim:cr,getExtensionOrThrow:co,getFramebufferErrorMessage:dv,getMaxTexturesInShader:gv,getNumChannels:qW,getProgramUniformLocation:cv,getProgramUniformLocationOrThrow:uv,getRowsCols:hr,getShapeAs3D:po,getTextureShapeFromLogicalShape:fv,getWebGLDisjointQueryTimerVersion:yv,getWebGLErrorMessage:Z1,getWebGLMaxTextureSize:mv,hasExtension:an,isCapableOfRenderingToFloatTexture:xv,isDownloadFloatTextureEnabled:bv,isReshapeFree:ko,isWebGLFenceEnabled:wv,isWebGLVersionEnabled:kd,linkProgram:nv,logShaderSourceAndInfoLog:og,resetMaxTextureSize:YW,resetMaxTexturesInShader:JW,unbindColorTextureFromFramebuffer:Sd,unbindTextureUnit:KW,validateFramebuffer:ho,validateProgram:zl,validateTextureSize:ov},Symbol.toStringTag,{value:"Module"}));/**
11835 * @license
11836 * Copyright 2019 Google LLC. All Rights Reserved.
11837 * Licensed under the Apache License, Version 2.0 (the "License");
11838 * you may not use this file except in compliance with the License.
11839 * You may obtain a copy of the License at
11840 *
11841 * http://www.apache.org/licenses/LICENSE-2.0
11842 *
11843 * Unless required by applicable law or agreed to in writing, software
11844 * distributed under the License is distributed on an "AS IS" BASIS,
11845 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11846 * See the License for the specific language governing permissions and
11847 * limitations under the License.
11848 * =============================================================================
11849 */const le=W();le.registerFlag("HAS_WEBGL",()=>le.getNumber("WEBGL_VERSION")>0);le.registerFlag("WEBGL_VERSION",()=>kd(2)?2:kd(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",()=>mv(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>gv(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const n=le.getNumber("WEBGL_VERSION");return n===0?0:yv(n)});le.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>le.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!qx());le.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>xv(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",()=>bv(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_FENCE_API_ENABLED",()=>wv(le.getNumber("WEBGL_VERSION")));le.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>le.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);
11849le.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",()=>qx()?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);/**
11850 * @license
11851 * Copyright 2018 Google LLC. All Rights Reserved.
11852 * Licensed under the Apache License, Version 2.0 (the "License");
11853 * you may not use this file except in compliance with the License.
11854 * You may obtain a copy of the License at
11855 *
11856 * http://www.apache.org/licenses/LICENSE-2.0
11857 *
11858 * Unless required by applicable law or agreed to in writing, software
11859 * distributed under the License is distributed on an "AS IS" BASIS,
11860 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11861 * See the License for the specific language governing permissions and
11862 * limitations under the License.
11863 * =============================================================================
11864 */function Pt(){let n,e,t,s,r,a,o,i,l,u;return W().getNumber("WEBGL_VERSION")===2?(n="#version 300 es",e="in",t="out",s="in",r="texture",a="outputColor",o="out vec4 outputColor;",i=W().getBool("WEBGL2_ISNAN_CUSTOM")?`
11865      bool isnan_custom(float val) {
11866        uint floatToUint = floatBitsToUint(val);
11867        return (floatToUint & 0x7fffffffu) > 0x7f800000u;
11868      }
11869
11870      bvec4 isnan_custom(vec4 val) {
11871        return bvec4(isnan_custom(val.x),
11872          isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));
11873      }
11874
11875      #define isnan(value) isnan_custom(value)
11876    `:"",l="",u=`
11877      #define round(value) newRound(value)
11878      int newRound(float value) {
11879        return int(floor(value + 0.5));
11880      }
11881
11882      ivec4 newRound(vec4 value) {
11883        return ivec4(floor(value + vec4(0.5)));
11884      }
11885    `):(n="",e="attribute",t="varying",s="varying",r="texture2D",a="gl_FragColor",o="",i=`
11886      #define isnan(value) isnan_custom(value)
11887      bool isnan_custom(float val) {
11888        return (val > 0. || val < 1. || val == 0.) ? false : true;
11889      }
11890      bvec4 isnan_custom(vec4 val) {
11891        return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
11892      }
11893    `,l=`
11894      uniform float INFINITY;
11895
11896      bool isinf(float val) {
11897        return abs(val) == INFINITY;
11898      }
11899      bvec4 isinf(vec4 val) {
11900        return equal(abs(val), vec4(INFINITY));
11901      }
11902    `,u=`
11903      int round(float value) {
11904        return int(floor(value + 0.5));
11905      }
11906
11907      ivec4 round(vec4 value) {
11908        return ivec4(floor(value + vec4(0.5)));
11909      }
11910    `),{version:n,attribute:e,varyingVs:t,varyingFs:s,texture2D:r,output:a,defineOutput:o,defineSpecialNaN:i,defineSpecialInf:l,defineRound:u}}/**
11911 * @license
11912 * Copyright 2018 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 vr(n,e,t="index"){const s=fe(e);return s.map((r,a)=>{const o=`int ${n[a]} = ${t} / ${r}`,i=a===s.length-1?`int ${n[a+1]} = ${t} - ${n[a]} * ${r}`:`index -= ${n[a]} * ${r}`;return`${o}; ${i};`}).join("")}function Fh(n,e,t="index"){const s=fe(e);return s.map((r,a)=>{const o=`int ${n[a]} = ${t} / outShapeStrides[${a}]`,i=a===s.length-1?`int ${n[a+1]} = ${t} - ${n[a]} * outShapeStrides[${a}]`:`index -= ${n[a]} * outShapeStrides[${a}]`;return`${o}; ${i};`}).join("")}function e4(n,e){const t=n.length,s=n.map(a=>`${e}[${a}]`),r=new Array(t-1);r[t-2]=s[t-1];for(let a=t-3;a>=0;
vendor: 8,376 bytes, lines 11925-12122
11925--a)r[a]=`(${r[a+1]} * ${s[a+1]})`;return r}function t4(n,e,t="index"){const s=n.map((a,o)=>o),r=e4(s,e);return r.map((a,o)=>{const i=`int ${n[o]} = ${t} / ${r[o]}`,l=o===r.length-1?`int ${n[o+1]} = ${t} - ${n[o]} * ${r[o]}`:`index -= ${n[o]} * ${r[o]}`;return`${i}; ${l};`}).join("")}function ig(n){const e=fe(n).map(t=>t.toString());return`
11926  int getFlatIndex(ivec3 coords) {
11927    return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;
11928  }
11929`}function lg(){return`
11930  int getFlatIndex(ivec3 coords) {
11931    return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
11932  }
11933`}const vv=`
11934  const float FLOAT_MAX = 1.70141184e38;
11935  const float FLOAT_MIN = 1.17549435e-38;
11936
11937  lowp vec4 encode_float(highp float v) {
11938    if (isnan(v)) {
11939      return vec4(255, 255, 255, 255);
11940    }
11941
11942    highp float av = abs(v);
11943
11944    if(av < FLOAT_MIN) {
11945      return vec4(0.0, 0.0, 0.0, 0.0);
11946    } else if(v > FLOAT_MAX) {
11947      return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
11948    } else if(v < -FLOAT_MAX) {
11949      return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;
11950    }
11951
11952    highp vec4 c = vec4(0,0,0,0);
11953
11954    highp float e = floor(log2(av));
11955    highp float m = exp2(fract(log2(av))) - 1.0;
11956
11957    c[2] = floor(128.0 * m);
11958    m -= c[2] / 128.0;
11959    c[1] = floor(32768.0 * m);
11960    m -= c[1] / 32768.0;
11961    c[0] = floor(8388608.0 * m);
11962
11963    highp float ebias = e + 127.0;
11964    c[3] = floor(ebias / 2.0);
11965    ebias -= c[3] * 2.0;
11966    c[2] += floor(ebias) * 128.0;
11967
11968    c[3] += 128.0 * step(0.0, -v);
11969
11970    return c / 255.0;
11971  }
11972`;/**
11973 * @license
11974 * Copyright 2017 Google LLC. All Rights Reserved.
11975 * Licensed under the Apache License, Version 2.0 (the "License");
11976 * you may not use this file except in compliance with the License.
11977 * You may obtain a copy of the License at
11978 *
11979 * http://www.apache.org/licenses/LICENSE-2.0
11980 *
11981 * Unless required by applicable law or agreed to in writing, software
11982 * distributed under the License is distributed on an "AS IS" BASIS,
11983 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11984 * See the License for the specific language governing permissions and
11985 * limitations under the License.
11986 * =============================================================================
11987 */const{getBroadcastDims:Cv}=Kx;function n4(n,e,t){const s=[];if(n.forEach(p=>{const f=H(p.shapeInfo.logicalShape);if(p.shapeInfo.isUniform?s.push(`uniform float ${p.name}${f>1?`[${f}]`:""};`):(s.push(`uniform sampler2D ${p.name};`),s.push(`uniform int offset${p.name};`)),t.enableShapeUniforms){const{uniformShape:g}=ug(t.packedInputs,p.shapeInfo.logicalShape,p.shapeInfo.texShape);switch(g.length){case 1:s.push(`uniform int ${p.name}Shape;`);break;case 2:s.push(`uniform ivec2 ${p.name}Shape;`);break;case 3:s.push(`uniform ivec3 ${p.name}Shape;`);break;case 4:s.push(`uniform ivec4 ${p.name}Shape;`);break}s.push(`uniform ivec2 ${p.name}TexShape;`)}}),t.enableShapeUniforms){switch(e.logicalShape.length){case 1:s.push("uniform int outShape;");break;case 2:s.push("uniform ivec2 outShape;"),s.push("uniform int outShapeStrides;");break;case 3:s.push("uniform ivec3 outShape;"),s.push("uniform ivec2 outShapeStrides;");break;case 4:s.push("uniform ivec4 outShape;"),s.push("uniform ivec3 outShapeStrides;");break}s.push("uniform ivec2 outTexShape;")}t.customUniforms&&t.customUniforms.forEach(p=>{s.push(`uniform ${p.type} ${p.name}${p.arrayIndex?`[${p.arrayIndex}]`:""};`)});const r=s.join(`
11988`),a=n.map(p=>s4(p,e,t.packedInputs,t.enableShapeUniforms)).join(`
11989`),o=e.texShape,i=Pt(),l=o4(i);let u,c,h=u4(i);return e.isPacked?(u=r4(e.logicalShape,o,t.enableShapeUniforms),c=l4(i)):(u=a4(e.logicalShape,o,t.enableShapeUniforms),c=i4(i)),t.packedInputs&&(h+=p4),[h,l,c,r,u,a,t.userCode].join(`
11990`)}function Ka(n,e=!1){const t=n.shapeInfo.logicalShape;switch(t.length){case 0:return I4(n,e);case 1:return k4(n,e);case 2:return E4(n,e);case 3:return D4(n,e);case 4:return O4(n,e);case 5:return _4(n);case 6:return F4(n);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function $v(n,e){switch(n.shapeInfo.logicalShape.length){case 0:return N4(n);case 1:return S4(n,e);case 2:return T4(n,e);case 3:return R4(n,e);default:return A4(n,e)}}function s4(n,e,t=!1,s){let r="";t?r+=$v(n,s):r+=Ka(n,s);const a=n.shapeInfo.logicalShape,o=e.logicalShape;return a.length<=o.length&&(t?r+=L4(n,e):r+=P4(n,e)),r}function r4(n,e,t){switch(n.length){case 0:return Nv();case 1:return f4(n,e,t);case 2:return C4(n,e,t);case 3:return g4(n,e,t);default:return x4(n,e,t)}}function a4(n,e,t){switch(n.length){case 0:return Nv();case 1:return m4(n,e,t);case 2:return $4(n,e,t);case 3:return y4(n,e,t);case 4:return b4(n,e,t);case 5:return w4(n,e);case 6:return v4(n,e);default:throw new Error(`${n.length}-D output sampling is not yet supported`)}}function o4(n){return`
11991    float sampleTexture(sampler2D textureSampler, vec2 uv) {
11992      return ${n.texture2D}(textureSampler, uv).r;
11993    }
11994  `}function i4(n){return`
11995    void setOutput(float val) {
11996      ${n.output} = vec4(val, 0, 0, 0);
11997    }
11998  `}function l4(n){return`
11999    void setOutput(vec4 val) {
12000      ${n.output} = val;
12001    }
12002  `}function u4(n){return`${n.version}
12003    precision highp float;
12004    precision highp int;
12005    precision highp sampler2D;
12006    ${n.varyingFs} vec2 resultUV;
12007    ${n.defineOutput}
12008    const vec2 halfCR = vec2(0.5, 0.5);
12009
12010    struct ivec5
12011    {
12012      int x;
12013      int y;
12014      int z;
12015      int w;
12016      int u;
12017    };
12018
12019    struct ivec6
12020    {
12021      int x;
12022      int y;
12023      int z;
12024      int w;
12025      int u;
12026      int v;
12027    };
12028
12029    uniform float NAN;
12030    ${n.defineSpecialNaN}
12031    ${n.defineSpecialInf}
12032    ${n.defineRound}
12033
12034    int imod(int x, int y) {
12035      return x - y * (x / y);
12036    }
12037
12038    int idiv(int a, int b, float sign) {
12039      int res = a / b;
12040      int mod = imod(a, b);
12041      if (sign < 0. && mod != 0) {
12042        res -= 1;
12043      }
12044      return res;
12045    }
12046
12047    //Based on the work of Dave Hoskins
12048    //https://www.shadertoy.com/view/4djSRW
12049    #define HASHSCALE1 443.8975
12050    float random(float seed){
12051      vec2 p = resultUV * seed;
12052      vec3 p3  = fract(vec3(p.xyx) * HASHSCALE1);
12053      p3 += dot(p3, p3.yzx + 19.19);
12054      return fract((p3.x + p3.y) * p3.z);
12055    }
12056
12057    ${c4}
12058    ${h4}
12059    ${d4}
12060  `}const c4=`
12061vec2 uvFromFlat(int texNumR, int texNumC, int index) {
12062  int texR = index / texNumC;
12063  int texC = index - texR * texNumC;
12064  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
12065}
12066vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
12067  int texelIndex = index / 2;
12068  int texR = texelIndex / texNumC;
12069  int texC = texelIndex - texR * texNumC;
12070  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
12071}
12072`,h4=`
12073vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
12074  int texNumC, int row, int col) {
12075  int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
12076  int texR = texelIndex / texNumC;
12077  int texC = texelIndex - texR * texNumC;
12078  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
12079}
12080`,d4=`
12081vec2 packedUVfrom3D(int texNumR, int texNumC,
12082    int texelsInBatch, int texelsInLogicalRow, int b,
12083    int row, int col) {
12084  int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
12085  int texR = index / texNumC;
12086  int texC = index - texR * texNumC;
12087  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
12088}
12089`,p4=`
12090  float getChannel(vec4 frag, vec2 innerDims) {
12091    vec2 modCoord = mod(innerDims, 2.);
12092    return modCoord.x == 0. ?
12093      (modCoord.y == 0. ? frag.r : frag.g) :
12094      (modCoord.y == 0. ? frag.b : frag.a);
12095  }
12096  float getChannel(vec4 frag, int dim) {
12097    float modCoord = mod(float(dim), 2.);
12098    return modCoord == 0. ? frag.r : frag.g;
12099  }
12100`;function Nv(){return`
12101    int getOutputCoords() {
12102      return 0;
12103    }
12104  `}function f4(n,e,t){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return s[0]===1?t?`
12105      int getOutputCoords() {
12106        return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));
12107      }
12108    `:`
12109      int getOutputCoords() {
12110        return 2 * int(resultUV.x * ${s[1]}.0);
12111      }
12112    `:s[1]===1?t?`
12113      int getOutputCoords() {
12114        return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));
12115      }
12116    `:`
12117      int getOutputCoords() {
12118        return 2 * int(resultUV.y * ${s[0]}.0);
12119      }
12120    `:t?`
12121    int getOutputCoords() {
12122      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
12123      ivec2 resTexRC = ivec2(resultUV.yx *
12124                             vec2(packedTexShape[0], packedTexShape[1]));
12125      return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);
12126    }
12127  `:`
12128    int getOutputCoords() {
12129      ivec2 resTexRC = ivec2(resultUV.yx *
12130                             vec2(${s[0]}, ${s[1]}));
12131      return 2 * (resTexRC.x * ${s[1]} + resTexRC.y);
12132    }
12133  `}function m4(n,e,t){return e[0]===1?t?`
12134      int getOutputCoords() {
12135        return int(resultUV.x * float(outTexShape[1]));
12136      }
12137    `:`
12138      int getOutputCoords() {
12139        return int(resultUV.x * ${e[1]}.0);
12140      }
12141    `:e[1]===1?t?`
12142      int getOutputCoords() {
12143        return int(resultUV.y * float(outTexShape[0]));
12144      }
12145    `:`
12146      int getOutputCoords() {
12147        return int(resultUV.y * ${e[0]}.0);
12148      }
12149    `:t?`
12150    int getOutputCoords() {
12151      ivec2 resTexRC = ivec2(resultUV.yx *
12152                             vec2(outTexShape[0], outTexShape[1]));
12153      return resTexRC.x * outTexShape[1] + resTexRC.y;
12154    }
12155  `:`
12156    int getOutputCoords() {
12157      ivec2 resTexRC = ivec2(resultUV.yx *
12158                             vec2(${e[0]}, ${e[1]}));
12159      return resTexRC.x * ${e[1]} + resTexRC.y;
12160    }
12161  `}function g4(n,e,t){if(t)return`
12162    ivec3 getOutputCoords() {
12163      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
12164      int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));
12165      int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));
12166      ivec2 resTexRC = ivec2(resultUV.yx *
12167                             vec2(packedTexShape[0], packedTexShape[1]));
12168      int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
12169
12170      int b = index / texelsInBatch;
12171      index -= b * texelsInBatch;
12172
12173      int r = 2 * (index / texelsInLogicalRow);
12174      int c = imod(index, texelsInLogicalRow) * 2;
12175
12176      return ivec3(b, r, c);
12177    }
12178  `;const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(n[2]/2),a=r*Math.ceil(n[1]/2);return`
12179    ivec3 getOutputCoords() {
12180      ivec2 resTexRC = ivec2(resultUV.yx *
12181                             vec2(${s[0]}, ${s[1]}));
12182      int index = resTexRC.x * ${s[1]} + resTexRC.y;
12183
12184      int b = index / ${a};
12185      index -= b * ${a};
12186
12187      int r = 2 * (index / ${r});
12188      int c = imod(index, ${r}) * 2;
12189
12190      return ivec3(b, r, c);
12191    }
12192  `}function y4(n,e,t){if(t)return`
12193  ivec3 getOutputCoords() {
12194    ivec2 resTexRC = ivec2(resultUV.yx *
12195                           vec2(outTexShape[0], outTexShape[1]));
12196    int index = resTexRC.x * outTexShape[1] + resTexRC.y;
12197    ${Fh(["r","c","d"],n)}
12198    return ivec3(r, c, d);
12199  }
12200`;const s=vr(["r","c","d"],n);return`
12201    ivec3 getOutputCoords() {
12202      ivec2 resTexRC = ivec2(resultUV.yx *
12203                             vec2(${e[0]}, ${e[1]}));
12204      int index = resTexRC.x * ${e[1]} + resTexRC.y;
12205      ${s}
12206      return ivec3(r, c, d);
12207    }
12208  `}function x4(n,e,t){if(t)return`
12209    ivec4 getOutputCoords() {
12210      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
12211      ivec2 resTexRC = ivec2(resultUV.yx *
12212                             vec2(packedTexShape[0], packedTexShape[1]));
12213      int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
12214
12215      int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));
12216      int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));
12217      int texelsInBatchN = texelsInBatch * outShape[1];
12218
12219      int b2 = index / texelsInBatchN;
12220      index -= b2 * texelsInBatchN;
12221
12222      int b = index / texelsInBatch;
12223      index -= b * texelsInBatch;
12224
12225      int r = 2 * (index / texelsInLogicalRow);
12226      int c = imod(index, texelsInLogicalRow) * 2;
12227
12228      return ivec4(b2, b, r, c);
12229    }
12230  `;const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(n[n.length-1]/2),a=r*Math.ceil(n[n.length-2]/2);let o=a,i="",l="b, r, c";for(let u=2;u<n.length-1;u++)o*=n[n.length-u-1],i=`
12231      int b${u} = index / ${o};
12232      index -= b${u} * ${o};
12233    `+i,l=`b${u}, `+l;return`
12234    ivec${n.length} getOutputCoords() {
12235      ivec2 resTexRC = ivec2(resultUV.yx *
12236                             vec2(${s[0]}, ${s[1]}));
12237      int index = resTexRC.x * ${s[1]} + resTexRC.y;
12238
12239      ${i}
12240
12241      int b = index / ${a};
12242      index -= b * ${a};
12243
12244      int r = 2 * (index / ${r});
12245      int c = imod(index, ${r}) * 2;
12246
12247      return ivec${n.length}(${l});
12248    }
12249  `}function b4(n,e,t){if(t)return`
12250    ivec4 getOutputCoords() {
12251      ivec2 resTexRC = ivec2(resultUV.yx *
12252        vec2(outTexShape[0], outTexShape[1]));
12253      int index = resTexRC.x * outTexShape[1] + resTexRC.y;
12254      ${Fh(["r","c","d","d2"],n)}
12255      return ivec4(r, c, d, d2);
12256    }
12257  `;const s=vr(["r","c","d","d2"],n);return`
12258    ivec4 getOutputCoords() {
12259      ivec2 resTexRC = ivec2(resultUV.yx *
12260        vec2(${e[0]}, ${e[1]}));
12261      int index = resTexRC.x * ${e[1]} + resTexRC.y;
12262      ${s}
12263      return ivec4(r, c, d, d2);
12264    }
12265  `}function w4(n,e){const t=vr(["r","c","d","d2","d3"],n);return`
12266    ivec5 getOutputCoords() {
12267      ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]},
12268                             ${e[1]}));
12269
12270      int index = resTexRC.x * ${e[1]} + resTexRC.y;
12271
12272      ${t}
12273
12274      ivec5 outShape = ivec5(r, c, d, d2, d3);
12275      return outShape;
12276    }
12277  `}function v4(n,e){const t=vr(["r","c","d","d2","d3","d4"],n);return`
12278    ivec6 getOutputCoords() {
12279      ivec2 resTexRC = ivec2(resultUV.yx *
12280        vec2(${e[0]}, ${e[1]}));
12281      int index = resTexRC.x * ${e[1]} + resTexRC.y;
12282
12283      ${t}
12284
12285      ivec6 result = ivec6(r, c, d, d2, d3, d4);
12286      return result;
12287    }
12288  `}function C4(n,e,t){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(ke(n,e))return t?`
12289      ivec2 getOutputCoords() {
12290        ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
12291        return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));
12292      }
12293    `:`
12294      ivec2 getOutputCoords() {
12295        return 2 * ivec2(resultUV.yx * vec2(${s[0]}, ${s[1]}));
12296      }
12297    `;const r=Math.ceil(n[1]/2);return t?`
12298    ivec2 getOutputCoords() {
12299      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
12300      int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));
12301      ivec2 resTexRC = ivec2(resultUV.yx *
12302                             vec2(packedTexShape[0], packedTexShape[1]));
12303
12304      int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
12305      int r = 2 * (index / texelsInLogicalRow);
12306      int c = imod(index, texelsInLogicalRow) * 2;
12307
12308      return ivec2(r, c);
12309    }
12310  `:`
12311    ivec2 getOutputCoords() {
12312      ivec2 resTexRC = ivec2(resultUV.yx *
12313                             vec2(${s[0]}, ${s[1]}));
12314
12315      int index = resTexRC.x * ${s[1]} + resTexRC.y;
12316      int r = 2 * (index / ${r});
12317      int c = imod(index, ${r}) * 2;
12318
12319      return ivec2(r, c);
12320    }
12321  `}function $4(n,e,t){return ke(n,e)?t?`
12322      ivec2 getOutputCoords() {
12323        return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));
12324      }
12325    `:`
12326      ivec2 getOutputCoords() {
12327        return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]}));
12328      }
12329    `:n[1]===1?t?`
12330      ivec2 getOutputCoords() {
12331        ivec2 resTexRC = ivec2(resultUV.yx *
12332                               vec2(outTexShape[0], outTexShape[1]));
12333        int index = resTexRC.x * outTexShape[1] + resTexRC.y;
12334        return ivec2(index, 0);
12335      }
12336    `:`
12337      ivec2 getOutputCoords() {
12338        ivec2 resTexRC = ivec2(resultUV.yx *
12339                               vec2(${e[0]}, ${e[1]}));
12340        int index = resTexRC.x * ${e[1]} + resTexRC.y;
12341        return ivec2(index, 0);
12342      }
12343    `:n[0]===1?t?`
12344      ivec2 getOutputCoords() {
12345        ivec2 resTexRC = ivec2(resultUV.yx *
12346                               vec2(outTexShape[0], outTexShape[1]));
12347        int index = resTexRC.x * outTexShape[1] + resTexRC.y;
12348        return ivec2(0, index);
12349      }
12350    `:`
12351      ivec2 getOutputCoords() {
12352        ivec2 resTexRC = ivec2(resultUV.yx *
12353                               vec2(${e[0]}, ${e[1]}));
12354        int index = resTexRC.x * ${e[1]} + resTexRC.y;
12355        return ivec2(0, index);
12356      }
12357    `:t?`
12358    ivec2 getOutputCoords() {
12359      ivec2 resTexRC = ivec2(resultUV.yx *
12360                             vec2(outTexShape[0], outTexShape[1]));
12361      int index = resTexRC.x * outTexShape[1] + resTexRC.y;
12362      int r = index / outShape[1];
12363      int c = index - r * outShape[1];
12364      return ivec2(r, c);
12365    }
12366  `:`
12367    ivec2 getOutputCoords() {
12368      ivec2 resTexRC = ivec2(resultUV.yx *
12369                             vec2(${e[0]}, ${e[1]}));
12370      int index = resTexRC.x * ${e[1]} + resTexRC.y;
12371      int r = index / ${n[1]};
12372      int c = index - r * ${n[1]};
12373      return ivec2(r, c);
12374    }
12375  `}function Cr(n){return`offset${n}`}function N4(n){const e=n.name,t="get"+e.charAt(0).toUpperCase()+e.slice(1),s=Pt();return`
12376    vec4 ${t}() {
12377      return ${s.texture2D}(${e}, halfCR);
12378    }
12379  `}function I4(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return`float ${s}() {return ${t};}`;const[r,a]=n.shapeInfo.texShape;if(r===1&&a===1)return`
12380      float ${s}() {
12381        return sampleTexture(${t}, halfCR);
12382      }
12383    `;const o=Cr(t);if(e)return`
12384    float ${s}() {
12385      vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], ${o});
12386      return sampleTexture(${t}, uv);
12387    }
12388  `;const[i,l]=n.shapeInfo.texShape;return`
12389    float ${s}() {
12390      vec2 uv = uvFromFlat(${i}, ${l}, ${o});
12391      return sampleTexture(${t}, uv);
12392    }
12393  `}function S4(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1),r=n.shapeInfo.texShape,a=Pt();if(e)return`
12394    vec4 ${s}(int index) {
12395      ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0));
12396      vec2 uv = packedUVfrom1D(
12397        packedTexShape[0], packedTexShape[1], index);
12398      return ${a.texture2D}(${t}, uv);
12399    }
12400  `;const o=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];return`
12401    vec4 ${s}(int index) {
12402      vec2 uv = packedUVfrom1D(
12403        ${o[0]}, ${o[1]}, index);
12404      return ${a.texture2D}(${t}, uv);
12405    }
12406  `}function k4(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return`
12407      float ${s}(int index) {
12408        ${Xa(n)}
12409      }
12410    `;const r=n.shapeInfo.texShape,a=r[0],o=r[1];if(o===1&&a===1)return`
12411      float ${s}(int index) {
12412        return sampleTexture(${t}, halfCR);
12413      }
12414    `;const i=Cr(t);return o===1?e?`
12415      float ${s}(int index) {
12416        vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${t}TexShape[0]));
12417        return sampleTexture(${t}, uv);
12418      }
12419    `:`
12420      float ${s}(int index) {
12421        vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${a}.0);
12422        return sampleTexture(${t}, uv);
12423      }
12424    `:a===1?e?`
12425      float ${s}(int index) {
12426        vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${t}TexShape[1]), 0.5);
12427        return sampleTexture(${t}, uv);
12428      }
12429    `:`
12430      float ${s}(int index) {
12431        vec2 uv = vec2((float(index + ${i}) + 0.5) / ${o}.0, 0.5);
12432        return sampleTexture(${t}, uv);
12433      }
12434    `:e?`
12435    float ${s}(int index) {
12436      vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], index + ${i});
12437      return sampleTexture(${t}, uv);
12438    }
12439  `:`
12440    float ${s}(int index) {
12441      vec2 uv = uvFromFlat(${a}, ${o}, index + ${i});
12442      return sampleTexture(${t}, uv);
12443    }
12444  `}function T4(n,e){const t=n.shapeInfo.logicalShape,s=n.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=n.shapeInfo.texShape,o=a[0],i=a[1],l=Pt();if(a!=null&&ke(t,a))return e?`
12445      vec4 ${r}(int row, int col) {
12446        vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]);
12447
12448        return ${l.texture2D}(${s}, uv);
12449      }
12450    `:`
12451      vec4 ${r}(int row, int col) {
12452        vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}.0, ${o}.0);
12453
12454        return ${l.texture2D}(${s}, uv);
12455      }
12456    `;if(e)return`
12457    vec4 ${r}(int row, int col) {
12458      ivec2 packedTexShape = ivec2(ceil(float(${s}TexShape[0]) / 2.0), ceil(float(${s}TexShape[1]) / 2.0));
12459      int valuesPerRow = int(ceil(float(${s}Shape[1]) / 2.0));
12460      vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
12461      return ${l.texture2D}(${s}, uv);
12462    }
12463  `;const u=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],c=Math.ceil(t[1]/2);return`
12464    vec4 ${r}(int row, int col) {
12465      vec2 uv = packedUVfrom2D(${c}, ${u[0]}, ${u[1]}
12465, row, col);
12466      return ${l.texture2D}(${s}, uv);
12467    }
12468  `}function E4(n,e){const t=n.shapeInfo.logicalShape,s=n.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=n.shapeInfo.texShape;if(a!=null&&ke(t,a)){if(e)return`
12469      float ${r}(int row, int col) {
12470        vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]);
12471        return sampleTexture(${s}, uv);
12472      }
12473    `;const d=a[0],p=a[1];return`
12474    float ${r}(int row, int col) {
12475      vec2 uv = (vec2(col, row) + halfCR) / vec2(${p}.0, ${d}.0);
12476      return sampleTexture(${s}, uv);
12477    }
12478  `}const{newShape:o,keptDims:i}=Os(t),l=o;if(l.length<t.length){const d=Ya(n,l),p=["row","col"];return`
12479      ${Ka(d,e)}
12480      float ${r}(int row, int col) {
12481        return ${r}(${Ja(p,i)});
12482      }
12483    `}if(n.shapeInfo.isUniform)return`
12484      float ${r}(int row, int col) {
12485        int index = round(dot(vec2(row, col), vec2(${t[1]}, 1)));
12486        ${Xa(n)}
12487      }
12488    `;const u=a[0],c=a[1],h=Cr(s);return c===1?e?`
12489      float ${r}(int row, int col) {
12490        float index = dot(vec3(row, col, ${h}), vec3(${s}Shape[1], 1, 1));
12491        vec2 uv = vec2(0.5, (index + 0.5) / float(${s}TexShape[0]));
12492        return sampleTexture(${s}, uv);
12493      }
12494    `:`
12495    float ${r}(int row, int col) {
12496      float index = dot(vec3(row, col, ${h}), vec3(${t[1]}, 1, 1));
12497      vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);
12498      return sampleTexture(${s}, uv);
12499    }
12500  `:u===1?e?`
12501      float ${r}(int row, int col) {
12502        float index = dot(vec3(row, col, ${h}), vec3(${s}Shape[1], 1, 1));
12503        vec2 uv = vec2((index + 0.5) / float(${s}TexShape[1]), 0.5);
12504        return sampleTexture(${s}, uv);
12505      }
12506    `:`
12507    float ${r}(int row, int col) {
12508      float index = dot(vec3(row, col, ${h}), vec3(${t[1]}, 1, 1));
12509      vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);
12510      return sampleTexture(${s}, uv);
12511    }
12512  `:e?`
12513      float ${r}(int row, int col) {
12514        // Explicitly use integer operations as dot() only works on floats.
12515        int index = row * ${s}Shape[1] + col + ${h};
12516        vec2 uv = uvFromFlat(${s}TexShape[0], ${s}TexShape[1], index);
12517        return sampleTexture(${s}, uv);
12518      }
12519    `:`
12520  float ${r}(int row, int col) {
12521    // Explicitly use integer operations as dot() only works on floats.
12522    int index = row * ${t[1]} + col + ${h};
12523    vec2 uv = uvFromFlat(${u}, ${c}, index);
12524    return sampleTexture(${s}, uv);
12525  }
12526`}function R4(n,e){const t=n.shapeInfo.logicalShape,s=n.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=n.shapeInfo.texShape,o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];if(t[0]===1){const d=t.slice(1),p=[1,2],f=Ya(n,d),g=["b","row","col"];return`
12527        ${$v(f,e)}
12528        vec4 ${r}(int b, int row, int col) {
12529          return ${r}(${Ja(g,p)});
12530        }
12531      `}const i=Pt();if(e)return`
12532    vec4 ${r}(int b, int row, int col) {
12533      ivec2 packedTexShape = ivec2(ceil(float(${s}TexShape[0]) / 2.0), ceil(float(${s}TexShape[1]) / 2.0));
12534      int valuesPerRow = int(ceil(float(${s}Shape[2]) / 2.0));
12535      int texelsInBatch = valuesPerRow * int(ceil(float(${s}Shape[1]) / 2.0));
12536      vec2 uv = packedUVfrom3D(
12537        packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);
12538      return ${i.texture2D}(${s}, uv);
12539    }
12540  `;const l=o[0],u=o[1],c=Math.ceil(t[2]/2),h=c*Math.ceil(t[1]/2);return`
12541    vec4 ${r}(int b, int row, int col) {
12542      vec2 uv = packedUVfrom3D(
12543        ${l}, ${u}, ${h}, ${c}, b, row, col);
12544      return ${i.texture2D}(${s}, uv);
12545    }
12546  `}function D4(n,e){const t=n.shapeInfo.logicalShape,s=n.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=t[1]*t[2],o=t[2],{newShape:i,keptDims:l}=Os(t),u=i;if(u.length<t.length){const g=Ya(n,u),m=["row","col","depth"];return`
12547        ${Ka(g,e)}
12548        float ${r}(int row, int col, int depth) {
12549          return ${r}(${Ja(m,l)});
12550        }
12551      `}if(n.shapeInfo.isUniform)return`
12552      float ${r}(int row, int col, int depth) {
12553        int index = round(dot(vec3(row, col, depth),
12554                          vec3(${a}, ${o}, 1)));
12555        ${Xa(n)}
12556      }
12557    `;const c=n.shapeInfo.texShape,h=c[0],d=c[1],p=n.shapeInfo.flatOffset;if(d===a&&p==null)return e?`
12558      float ${r}(int row, int col, int depth) {
12559        int stride1 = ${s}Shape[2];
12560        float texR = float(row);
12561        float texC = dot(vec2(col, depth), vec2(stride1, 1));
12562        vec2 uv = (vec2(texC, texR) + halfCR) /
12563                   vec2(${s}TexShape[1], ${s}TexShape[0]);
12564        return sampleTexture(${s}, uv);
12565      }
12566    `:`
12567        float ${r}(int row, int col, int depth) {
12568          float texR = float(row);
12569          float texC = dot(vec2(col, depth), vec2(${o}, 1));
12570          vec2 uv = (vec2(texC, texR) + halfCR) /
12571                     vec2(${d}.0, ${h}.0);
12572          return sampleTexture(${s}, uv);
12573        }
12574      `;if(d===o&&p==null)return e?`
12575      float ${r}(int row, int col, int depth) {
12576        float texR = dot(vec2(row, col), vec2(${s}Shape[1], 1));
12577        float texC = float(depth);
12578        vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]);
12579        return sampleTexture(${s}, uv);
12580      }
12581    `:`
12582    float ${r}(int row, int col, int depth) {
12583      float texR = dot(vec2(row, col), vec2(${t[1]}, 1));
12584      float texC = float(depth);
12585      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${d}.0, ${h}.0);
12586      return sampleTexture(${s}, uv);
12587    }
12588  `;const f=Cr(s);return e?`
12589    float ${r}(int row, int col, int depth) {
12590      // Explicitly use integer operations as dot() only works on floats.
12591      int stride0 = ${s}Shape[1] * ${s}Shape[2];
12592      int stride1 = ${s}Shape[2];
12593      int index = row * stride0 + col * stride1 + depth + ${f};
12594      vec2 uv = uvFromFlat(${s}TexShape[0], ${s}TexShape[1], index);
12595      return sampleTexture(${s}, uv);
12596    }
12597    `:`
12598      float ${r}(int row, int col, int depth) {
12599        // Explicitly use integer operations as dot() only works on floats.
12600        int index = row * ${a} + col * ${o} + depth + ${f};
12601        vec2 uv = uvFromFlat(${h}, ${d}, index);
12602        return sampleTexture(${s}, uv);
12603      }
12604  `}function A4(n,e){const t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1),r=Pt();if(e)return`
12605    vec4 ${s}(int b2, int b, int row, int col) {
12606      int valuesPerRow = int(ceil(float(${t}Shape[3]) / 2.0));
12607      int texelsInBatch = valuesPerRow * int(ceil(float(${t}Shape[2]) / 2.0));
12608      int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);
12609      texelsInBatch *= ${t}Shape[1];
12610      index = b2 * texelsInBatch + index;
12611      ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0));
12612      int texR = index / packedTexShape[1];
12613      int texC = index - texR * packedTexShape[1];
12614      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${r.texture2D}(${t}, uv);
12615    }
12616  `;const a=n.shapeInfo.logicalShape,o=a.length,i=n.shapeInfo.texShape,l=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],u=l[0],c=l[1],h=Math.ceil(a[o-1]/2);let d=h*Math.ceil(a[o-2]/2),p="int b, int row, int col",f=`b * ${d} + (row / 2) * ${h} + (col / 2)`;for(let g=2;g<o-1;g++)p=`int b${g}, `+p,d*=a[o-g-1],f=`b${g} * ${d} + `+f;return`
12617    vec4 ${s}(${p}) {
12618      int index = ${f};
12619      int texR = index / ${c};
12620      int texC = index - texR * ${c};
12621      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${u});
12622      return ${r.texture2D}(${t}, uv);
12623    }
12624  `}function O4(n,e){const t=n.shapeInfo.logicalShape,s=n.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=t[3],o=t[2]*a,i=t[1]*o,{newShape:l,keptDims:u}=Os(t);if(l.length<t.length){const x=Ya(n,l),v=["row","col","depth","depth2"];return`
12625      ${Ka(x,e)}
12626      float ${r}(int row, int col, int depth, int depth2) {
12627        return ${r}(${Ja(v,u)});
12628      }
12629    `}if(n.shapeInfo.isUniform)return`
12630      float ${r}(int row, int col, int depth, int depth2) {
12631        int index = round(dot(vec4(row, col, depth, depth2),
12632                          vec4(${i}, ${o}, ${a}, 1)));
12633        ${Xa(n)}
12634      }
12635    `;const c=n.shapeInfo.flatOffset,h=n.shapeInfo.texShape,d=h[0],p=h[1],f=`int stride2 = ${s}Shape[3];`,g=`int stride1 = ${s}Shape[2] * stride2;`,m=`int stride0 = ${s}Shape[1] * stride1;`;if(p===i&&c==null)return e?`
12636      float ${r}(int row, int col, int depth, int depth2) {
12637        ${f}
12638        ${g}
12639        float texR = float(row);
12640        float texC =
12641            dot(vec3(col, depth, depth2),
12642                vec3(stride1, stride2, 1));
12643        vec2 uv = (vec2(texC, texR) + halfCR) /
12644                   vec2(${s}TexShape[1], ${s}TexShape[0]);
12645        return sampleTexture(${s}, uv);
12646      }
12647    `:`
12648      float ${r}(int row, int col, int depth, int depth2) {
12649        float texR = float(row);
12650        float texC =
12651            dot(vec3(col, depth, depth2),
12652                vec3(${o}, ${a}, 1));
12653        vec2 uv = (vec2(texC, texR) + halfCR) /
12654                   vec2(${p}.0, ${d}.0);
12655        return sampleTexture(${s}, uv);
12656      }
12657    `;if(p===a&&c==null)return e?`
12658      float ${r}(int row, int col, int depth, int depth2) {
12659        float texR = dot(vec3(row, col, depth),
12660                         vec3(${s}Shape[1] * ${s}Shape[2], ${s}Shape[2], 1));
12661        float texC = float(depth2);
12662        vec2 uv = (vec2(texC, texR) + halfCR) /
12663                  vec2(${s}TexShape[1], ${s}TexShape[0]);
12664        return sampleTexture(${s}, uv);
12665      }
12666    `:`
12667      float ${r}(int row, int col, int depth, int depth2) {
12668        float texR = dot(vec3(row, col, depth),
12669                         vec3(${t[1]*t[2]}, ${t[2]}, 1));
12670        float texC = float(depth2);
12671        vec2 uv = (vec2(texC, texR) + halfCR) /
12672                  vec2(${p}.0, ${d}.0);
12673        return sampleTexture(${s}, uv);
12674      }
12675    `;const y=Cr(s);return e?`
12676    float ${r}(int row, int col, int depth, int depth2) {
12677      // Explicitly use integer operations as dot() only works on floats.
12678      ${f}
12679      ${g}
12680      ${m}
12681      int index = row * stride0 + col * stride1 +
12682          depth * stride2 + depth2;
12683      vec2 uv = uvFromFlat(${s}TexShape[0], ${s}TexShape[1], index + ${y});
12684      return sampleTexture(${s}, uv);
12685    }
12686  `:`
12687    float ${r}(int row, int col, int depth, int depth2) {
12688      // Explicitly use integer operations as dot() only works on floats.
12689      int index = row * ${i} + col * ${o} +
12690          depth * ${a} + depth2;
12691      vec2 uv = uvFromFlat(${d}, ${p}, index + ${y});
12692      return sampleTexture(${s}, uv);
12693    }
12694  `}function _4(n){const e=n.shapeInfo.logicalShape,t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1),r=e[4],a=e[3]*r,o=e[2]*a,i=e[1]*o,{newShape:l,keptDims:u}=Os(e);if(l.length<e.length){const g=Ya(n,l),m=["row","col","depth","depth2","depth3"];return`
12695      ${Ka(g)}
12696      float ${s}(int row, int col, int depth, int depth2, int depth3) {
12697        return ${s}(${Ja(m,u)});
12698      }
12699    `}if(n.shapeInfo.isUniform)return`
12700      float ${s}(int row, int col, int depth, int depth2, int depth3) {
12701        float index = dot(
12702          vec4(row, col, depth, depth2),
12703          vec4(${i}, ${o}, ${a}, ${r})) +
12704          depth3;
12705        ${Xa(n)}
12706      }
12707    `;const c=n.shapeInfo.flatOffset,h=n.shapeInfo.texShape,d=h[0],p=h[1];if(p===i&&c==null)return`
12708      float ${s}(int row, int col, int depth, int depth2, int depth3) {
12709        int texR = row;
12710        float texC = dot(vec4(col, depth, depth2, depth3),
12711                         vec4(${o}, ${a}, ${r}, 1));
12712        vec2 uv = (vec2(texC, texR) + halfCR) /
12713                   vec2(${p}.0, ${d}.0);
12714        return sampleTexture(${t}, uv);
12715      }
12716    `;if(p===r&&c==null)return`
12717      float ${s}(int row, int col, int depth, int depth2, int depth3) {
12718        float texR = dot(
12719          vec4(row, col, depth, depth2),
12720          vec4(${e[1]*e[2]*e[3]},
12721               ${e[2]*e[3]}, ${e[3]}, 1));
12722        int texC = depth3;
12723        vec2 uv = (vec2(texC, texR) + halfCR) /
12724                  vec2(${p}.0, ${d}.0);
12725        return sampleTexture(${t}, uv);
12726      }
12727    `;const f=Cr(t);return`
12728    float ${s}(int row, int col, int depth, int depth2, int depth3) {
12729      // Explicitly use integer operations as dot() only works on floats.
12730      int index = row * ${i} + col * ${o} + depth * ${a} +
12731          depth2 * ${r} + depth3 + ${f};
12732      vec2 uv = uvFromFlat(${d}, ${p}, index);
12733      return sampleTexture(${t}, uv);
12734    }
12735  `}function F4(n){const e=n.shapeInfo.logicalShape,t=n.name,s="get"+t.charAt(0).toUpperCase()+t.slice(1),{newShape:r,keptDims:a}=Os(e);if(r.length<e.length){const m=Ya(n,r),y=["row","col","depth","depth2","depth3","depth4"];return`
12736      ${Ka(m)}
12737      float ${s}(int row, int col, int depth,
12738                    int depth2, int depth3, int depth4) {
12739        return ${s}(${Ja(y,a)});
12740      }
12741    `}const o=e[5],i=e[4]*o,l=e[3]*i,u=e[2]*l,c=e[1]*u;if(n.shapeInfo.isUniform)return`
12742      float ${s}(int row, int col, int depth,
12743                  int depth2, int depth3, int depth4) {
12744        int index = round(dot(
12745          vec4(row, col, depth, depth2),
12746          vec4(${c}, ${u}, ${l}, ${i})) +
12747          dot(
12748            vec2(depth3, depth4),
12749            vec2(${o}, 1)));
12750        ${Xa(n)}
12751      }
12752    `;const h=n.shapeInfo.flatOffset,d=n.shapeInfo.texShape,p=d[0],f=d[1];if(f===c&&h==null)return`
12753      float ${s}(int row, int col, int depth,
12754                    int depth2, int depth3, int depth4) {
12755        int texR = row;
12756        float texC = dot(vec4(col, depth, depth2, depth3),
12757          vec4(${u}, ${l}, ${i}, ${o})) +
12758               float(depth4);
12759        vec2 uv = (vec2(texC, texR) + halfCR) /
12760                   vec2(${f}.0, ${p}.0);
12761        return sampleTexture(${t}, uv);
12762      }
12763    `;if(f===o&&h==null)return`
12764      float ${s}(int row, int col, int depth,
12765                    int depth2, int depth3, int depth4) {
12766        float texR = dot(vec4(row, col, depth, depth2),
12767          vec4(${e[1]*e[2]*e[3]*e[4]},
12768               ${e[2]*e[3]*e[4]},
12769               ${e[3]*e[4]},
12770               ${e[4]})) + float(depth3);
12771        int texC = depth4;
12772        vec2 uv = (vec2(texC, texR) + halfCR) /
12773                  vec2(${f}.0, ${p}.0);
12774        return sampleTexture(${t}, uv);
12775      }
12776    `;const g=Cr(t);return`
12777    float ${s}(int row, int col, int depth,
12778                  int depth2, int depth3, int depth4) {
12779      // Explicitly use integer operations as dot() only works on floats.
12780      int index = row * ${c} + col * ${u} + depth * ${l} +
12781          depth2 * ${i} + depth3 * ${o} + depth4 + ${g};
12782      vec2 uv = uvFromFlat(${p}, ${f}, index);
12783      return sampleTexture(${t}, uv);
12784    }
12785  `}function Xa(n){const e=n.name,t=H(n.shapeInfo.logicalShape);return t<2?`return ${e};`:`
12786    for (int i = 0; i < ${t}; i++) {
12787      if (i == index) {
12788        return ${e}[i];
12789      }
12790    }
12791  `}function L4(n,e){const t=n.name,s=t.charAt(0).toUpperCase()+t.slice(1),r="get"+s+"AtOutCoords",a=n.shapeInfo.logicalShape.length,o=e.logicalShape.length,i=Cv(n.shapeInfo.logicalShape,e.logicalShape),l=Fe(o),u=o-a;let c;const h=["x","y","z","w","u","v"];a===0?c="":o<2&&i.length>=1?c="coords = 0;":c=i.map(x=>`coords.${h[x+u]} = 0;`).join(`
12792`);let d="";o<2&&a>0?d="coords":d=n.shapeInfo.logicalShape.map((x,v)=>`coords.${h[v+u]}`).join(", ");let p="return outputValue;";const g=H(n.shapeInfo.logicalShape)===1,y=H(e.logicalShape)===1;if(a===1&&!g&&!y)p=`
12793      return vec4(outputValue.xy, outputValue.xy);
12794    `;else if(g&&!y)o===1?p=`
12795        return vec4(outputValue.x, outputValue.x, 0., 0.);
12796      `:p=`
12797        return vec4(outputValue.x);
12798      `;else if(i.length){const x=a-2,v=a-1;i.indexOf(x)>-1&&i.indexOf(v)>-1?p="return vec4(outputValue.x);":i.indexOf(x)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":i.indexOf(v)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}return`
12799    vec4 ${r}() {
12800      ${l} coords = getOutputCoords();
12801      ${c}
12802      vec4 outputValue = get${s}(${d});
12803      ${p}
12804    }
12805  `}function P4(n,e){const t=n.name,s=t.charAt(0).toUpperCase()+t.slice(1),r="get"+s+"AtOutCoords",a=e.texShape,o=n.shapeInfo.texShape,i=n.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!n.shapeInfo.isUniform&&i===l&&n.shapeInfo.flatOffset==null&&ke(o,a))return`
12806      float ${r}() {
12807        return sampleTexture(${t}, resultUV);
12808      }
12809    `;const u=Fe(l),c=Cv(n.shapeInfo.logicalShape,e.logicalShape),h=l-i;let d;const p=["x","y","z","w","u","v"];i===0?d="":l<2&&c.length>=1?d="coords = 0;":d=c.map(g=>`coords.${p[g+h]} = 0;`).join(`
12810`);let f="";return l<2&&i>0?f="coords":f=n.shapeInfo.logicalShape.map((g,m)=>`coords.${p[m+h]}`).join(", "),`
12811    float ${r}() {
12812      ${u} coords = getOutputCoords();
12813      ${d}
12814      return get${s}(${f});
12815    }
12816  `}function Fe(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 ug(n,e,t){const{newShape:s,keptDims:r}=Os(e),a=e.length,o=n&&a===3&&e[0]===1,i=o?e.slice(1):s,l=!n&&a>1&&!ke(e,t)&&s.length<a||o;return{useSqueezeShape:l,uniformShape:l?i:e,keptDims:r}}function Ya(n,e){const t=JSON.parse(JSON.stringify(n));return t.shapeInfo.logicalShape=e,t}function Ja(n,e){return e.map(t=>n[t]).join(", ")}/**
12817 * @license
12818 * Copyright 2017 Google LLC. All Rights Reserved.
12819 * Licensed under the Apache License, Version 2.0 (the "License");
12820 * you may not use this file except in compliance with the License.
12821 * You may obtain a copy of the License at
12822 *
12823 * http://www.apache.org/licenses/LICENSE-2.0
12824 *
12825 * Unless required by applicable law or agreed to in writing, software
12826 * distributed under the License is distributed on an "AS IS" BASIS,
12827 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12828 * See the License for the specific language governing permissions and
12829 * limitations under the License.
12830 * =============================================================================
12831 */function z4(n,e,t,s){const r=t.map((c,h)=>{const d={logicalShape:c.shape,texShape:c.isUniform?null:c.texData.texShape,isUniform:c.isUniform,isPacked:c.isUniform?!1:c.texData.isPacked,flatOffset:null};return c.texData!=null&&c.texData.slice!=null&&c.texData.slice.flatOffset>0&&(d.flatOffset=c.texData.slice.flatOffset),{name:e.variableNames[h],shapeInfo:d}}),a=r.map(c=>c.shapeInfo),o={logicalShape:s.shape,texShape:s.texData.texShape,isUniform:!1,isPacked:s.texData.isPacked,flatOffset:null},i=n4(r,o,e),l=ev(n.gl,i),u=n.createProgram(l);return W().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,s
vendor: 9,583 bytes, lines 12831-12926
12831ource:i,webGLProgram:u,inShapeInfos:a,outShapeInfo:o,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(n.buildVao(u),Object.assign({program:e,fragmentShader:l,source:i,webGLProgram:u,inShapeInfos:a,outShapeInfo:o},Iv(n,e,u)))}function Iv(n,e,t){const s=[],r=[];let a,o,i,l=null,u=null;u=n.getUniformLocation(t,"NAN",!1),W().getNumber("WEBGL_VERSION")===1&&(l=n.getUniformLocation(t,"INFINITY",!1));const c=!1;for(const h of e.variableNames){const d={name:h,uniform:n.getUniformLocation(t,h,c),offset:n.getUniformLocation(t,`offset${h}`,c)};e.enableShapeUniforms&&(d.shape=n.getUniformLocation(t,`${h}Shape`,c),d.texShape=n.getUniformLocation(t,`${h}TexShape`,c)),s.push(d)}if(e.enableShapeUniforms&&(a=n.getUniformLocation(t,"outShape",c),i=n.getUniformLocation(t,"outShapeStrides",c),o=n.getUniformLocation(t,"outTexShape",c)),e.customUniforms)for(const h of e.customUniforms)r.push(n.getUniformLocation(t,h.name,c));return{variablesLocations:s,customUniformLocations:r,infLoc:l,nanLoc:u,outShapeLocation:a,outShapeStridesLocation:i,outTexShapeLocation:o}}function $y(n,e){if(n.length!==e.length)throw Error(`Binary was compiled with ${n.length} inputs, but was executed with ${e.length} inputs`);n.forEach((t,s)=>{const r=t.logicalShape,a=e[s],o=a.shape;if(!ke(r,o))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${o} must match`);if(t.isUniform&&a.isUniform)return;const i=t.texShape,l=a.isUniform?null:a.texData.texShape;if(!ke(i,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${i} and ${l} must match`)})}function V4(n,e,t,s,r){e.program.enableShapeUniforms||($y(e.inShapeInfos,t),$y([e.outShapeInfo],[s]));const a=s.texData.texture,o=s.texData.texShape;s.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),W().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 l=0;l<t.length;++l){const u=t[l],{uniform:c,offset:h,shape:d,texShape:p}=e.variablesLocations[l];if(d){const{uniformShape:f}=ug(e.program.packedInputs,u.shape,u.texData.texShape);switch(f.length){case 1:n.gl.uniform1iv(d,new Int32Array(f));break;case 2:n.gl.uniform2iv(d,new Int32Array(f));break;case 3:n.gl.uniform3iv(d,new Int32Array(f));break;case 4:n.gl.uniform4iv(d,new Int32Array(f));break}}if(p&&n.gl.uniform2i(p,u.texData.texShape[0],u.texData.texShape[1]),c!=null){if(u.isUniform){if(H(u.shape)<2)n.gl.uniform1f(c,u.uniformValues[0]);else{let f=u.uniformValues;f instanceof Float32Array||(f=new Float32Array(f)),n.gl.uniform1fv(c,f)}continue}u.texData.slice!=null&&h!=null&&n.gl.uniform1i(h,u.texData.slice.flatOffset),n.setInputMatrixTexture(u.texData.texture.texture,c,l)}}const i=e.outShapeLocation;if(i)switch(s.shape.length){case 1:n.gl.uniform1iv(i,new Int32Array(s.shape));break;case 2:n.gl.uniform2iv(i,new Int32Array(s.shape));break;case 3:n.gl.uniform3iv(i,new Int32Array(s.shape));break;case 4:n.gl.uniform4iv(i,new Int32Array(s.shape));break}if(e.outShapeStridesLocation){const l=fe(s.shape);switch(s.shape.length){case 2:n.gl.uniform1iv(e.outShapeStridesLocation,new Int32Array(l));break;case 3:n.gl.uniform2iv(e.outShapeStridesLocation,new Int32Array(l));break;case 4:n.gl.uniform3iv(e.outShapeStridesLocation,new Int32Array(l));break}}if(e.outTexShapeLocation&&n.gl.uniform2i(e.outTexShapeLocation,s.texData.texShape[0],s.texData.texShape[1]),e.program.customUniforms&&r)for(let l=0;l<e.program.customUniforms.length;++l){const u=e.program.customUniforms[l],c=e.customUniformLocations[l],h=r[l];if(u.type==="float")n.gl.uniform1fv(c,h);else if(u.type==="vec2")n.gl.uniform2fv(c,h);else if(u.type==="vec3")n.gl.uniform3fv(c,h);else if(u.type==="vec4")n.gl.uniform4fv(c,h);else if(u.type==="int")n.gl.uniform1iv(c,h);else if(u.type==="ivec2")n.gl.uniform2iv(c,h);else if(u.type==="ivec3")n.gl.uniform3iv(c,h);else if(u.type==="ivec4")n.gl.uniform4iv(c,h);else throw Error(`uniform type ${u.type} is not supported yet.`)}n.executeProgram()}function B4(n,e,t){let s="";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 l=o.texData.texShape,{useSqueezeShape:u,uniformShape:c,keptDims:h}=ug(n.packedInputs,o.shape,l);let d="",p="",f="";if(c.length===1&&n.packedInputs){const C=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];d=`${C[0]>1}_${C[1]>1}`}else if(c.length===2&&!n.packedInputs)p=`${c[0]>1}_${c[1]>1}`;else if(c.length>2&&!n.packedInputs){const C=fe(c);f=`${C[0]===l[1]}_${C[C.length-1]===l[1]}`}const g=o.shape.length,m=c.length===2&&ke(o.shape,l),y=H(o.shape)===1,x=wo(o.shape,t.shape),v=!n.packedInputs&&g===t.shape.length&&ke(l,t.texData.texShape),b=n.packedInputs||c.length>2?"":`${l[0]>1}_${l[1]>1}`;s+=`${g}_${v}_${u?h:""}_${c.length}_${y}_${x}_${m}_${d}_${p}_${f}_${b}_${i}`}else{const l=o.isUniform?"uniform":o.texData.texShape;s+=`${o.shape}_${l}_${i}`}});const r=n.userCode;let a=n.constructor.name;return a+="_"+s+"_"+r+`${W().getNumber("WEBGL_VERSION")}`,a}function Tt(n){return W().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&n<=4}/**
12832 * @license
12833 * Copyright 2019 Google LLC. All Rights Reserved.
12834 * Licensed under the Apache License, Version 2.0 (the "License");
12835 * you may not use this file except in compliance with the License.
12836 * You may obtain a copy of the License at
12837 *
12838 * http://www.apache.org/licenses/LICENSE-2.0
12839 *
12840 * Unless required by applicable law or agreed to in writing, software
12841 * distributed under the License is distributed on an "AS IS" BASIS,
12842 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12843 * See the License for the specific language governing permissions and
12844 * limitations under the License.
12845 * =============================================================================
12846 */class M4{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=So.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Pt();this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length),this.userCode=`
12847      ivec3 outCoordsFromFlatIndex(int index) {
12848        ${this.enableShapeUniforms?Fh(["r","c","d"],e):vr(["r","c","d"],e)}
12849        return ivec3(r, c, d);
12850      }
12851
12852      void main() {
12853        ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
12854        int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
12855
12856        vec4 result = vec4(0.);
12857
12858        for (int i=0; i<4; i++) {
12859          int flatIndex = index + i;
12860          ivec3 rc = outCoordsFromFlatIndex(flatIndex);
12861          result[i] = getA(rc.x, rc.y, rc.z);
12862        }
12863
12864        ${t.output} = result;
12865      }
12866    `}}/**
12867 * @license
12868 * Copyright 2019 Google LLC. All Rights Reserved.
12869 * Licensed under the Apache License, Version 2.0 (the "License");
12870 * you may not use this file except in compliance with the License.
12871 * You may obtain a copy of the License at
12872 *
12873 * http://www.apache.org/licenses/LICENSE-2.0
12874 *
12875 * Unless required by applicable law or agreed to in writing, software
12876 * distributed under the License is distributed on an "AS IS" BASIS,
12877 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12878 * See the License for the specific language governing permissions and
12879 * limitations under the License.
12880 * =============================================================================
12881 */class W4{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=So.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=Pt();this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length),this.userCode=`
12882      ivec3 outCoordsFromFlatIndex(int index) {
12883        ${this.enableShapeUniforms?Fh(["r","c","d"],e):vr(["r","c","d"],e)}
12884        return ivec3(r, c, d);
12885      }
12886
12887      void main() {
12888        ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
12889        int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
12890
12891        vec4 result = vec4(0.);
12892
12893        for (int i=0; i<4; i++) {
12894          int flatIndex = index + i;
12895          ivec3 rc = outCoordsFromFlatIndex(flatIndex);
12896          result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));
12897        }
12898
12899        ${t.output} = result;
12900      }
12901    `}}/**
12902 * @license
12903 * Copyright 2018 Google LLC. All Rights Reserved.
12904 * Licensed under the Apache License, Version 2.0 (the "License");
12905 * you may not use this file except in compliance with the License.
12906 * You may obtain a copy of the License at
12907 *
12908 * http://www.apache.org/licenses/LICENSE-2.0
12909 *
12910 * Unless required by applicable law or agreed to in writing, software
12911 * distributed under the License is distributed on an "AS IS" BASIS,
12912 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12913 * See the License for the specific language governing permissions and
12914 * limitations under the License.
12915 * =============================================================================
12916 */class U4{constructor(e){this.variableNames=["A"],this.outTexUsage=rn.DOWNLOAD;const t=Pt();this.outputShape=e,this.userCode=`
12917      ${vv}
12918
12919      void main() {
12920        float x = getAAtOutCoords();
12921        ${t.output} = encode_float(x);
12922      }
12923    `}}/**
12924 * @license
12925 * Copyright 2018 Google LLC. All Rights Reserved.
12926 * Licensed under the Apache License, Version 2.0 (the "License");
12927 * you may not use this file except in compliance with the License.
12928 * You may obtain a copy of the License at
12929 *
12930 * http://www.apache.org/licenses/LICENSE-2.0
12931 *
12932 * Unless required by applicable law or agreed to in writing, software
12933 * distributed under the License is distributed on an "AS IS" BASIS,
12934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12935 * See the License for the specific language governing permissions and
12936 * limitations under the License.
12937 * =============================================================================
12938 */class G4{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=rn.DOWNLOAD;const t=Pt();this.outputShape=e,this.userCode=`
12939      ${vv}
12940
12941      void main() {
12942        ivec3 coords = getOutputCoords();
12943        float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
12944        ${t.output} = encode_float(x);
12945      }
12946    `}}/**
12947 * @license
12948 * Copyright 2018 Google LLC. All Rights Reserved.
12949 * Licensed under the Apache License, Version 2.0 (the "License");
12950 * you may not use this file except in compliance with the License.
12951 * You may obtain a copy of the License at
12952 *
12953 * http://www.apache.org/licenses/LICENSE-2.0
12954 *
12955 * Unless required by applicable law or agreed to in writing, software
12956 * distributed under the License is distributed on an "AS IS" BASIS,
12957 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12958 * See the License for the specific language governing permissions and
12959 * limitations under the License.
12960 * =============================================================================
12961 */const H4={R:0,G:1,B:2,A:3};class Ny{constructor(e,t=!1,s="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=Pt();this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length);let a="result";t&&(a="floor(result * 255. + 0.5)");let o="";for(let i=0;i<s.length;i++){const l=s[i];o+=`
12962          if(offset == ${i}) {
12963            result = values[${H4[l]}];
12964          }`}this.userCode=`
12965      ${this.enableShapeUniforms?lg():ig(e)}
12966
12967      void main() {
12968        ivec3 coords = getOutputCoords();
12969        int flatIndex = getFlatIndex(coords);
12970        float result = 0.;
12971        int offset = imod(flatIndex, ${s.length});
12972
12973        flatIndex = idiv(flatIndex, ${s.length}, 1.);
12974
12975        int r = flatIndex / texShape[1];
12976        if (r < texShape[0]) {
12977          int c = imod(flatIndex, texShape[1]);
12978          vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
12979          vec4 values = ${r.texture2D}(A, uv);
12980          ${o}
12981        }
12982        ${r.output} = vec4(${a}, 0., 0., 0.);
12983      }
12984    `}}/**
12985 * @license
12986 * Copyright 2018 Google LLC. All Rights Reserved.
12987 * Licensed under the Apache License, Version 2.0 (the "License");
12988 * you may not use this file except in compliance with the License.
12989 * You may obtain a copy of the License at
12990 *
12991 * http://www.apache.org/licenses/LICENSE-2.0
12992 *
12993 * Unless required by applicable law or agreed to in writing, software
12994 * distributed under the License is distributed on an "AS IS" BASIS,
12995 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12996 * See the License for the specific language governing permissions and
12997 * limitations under the License.
12998 * =============================================================================
12999 */class j4{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const s=Pt();this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let o=0;o<=1;o++)for(let i=0;i<=1;i++){const l=o*2+i;r+=`
13000          localCoords = coords;
13001          if(localCoords[2] + ${i} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {
13002          localCoords[2] += ${i};
13003          if (localCoords[1] + ${o} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {
13004            localCoords[1] += ${o};
13005
13006            flatIndex = getFlatIndex(localCoords);
13007            offset = imod(flatIndex, 4);
13008
13009            flatIndex = idiv(flatIndex, 4, 1.);
13010
13011            int r = flatIndex / texShape[1];
13012            int c = imod(flatIndex, texShape[1]);
13013            vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
13014            values = ${s.texture2D}(A, uv);
13015
13016            if (offset == 0) {
13017              result[${l}
13017] = values[0];
13018            } else if (offset == 1) {
13019              result[${l}] = values[1];
13020            } else if (offset == 2) {
13021              result[${l}] = values[2];
13022            } else {
13023              result[${l}] = values[3];
13024            }
13025          }
13026        }
13027        `}this.userCode=`
13028        ${this.enableShapeUniforms?lg():ig(e)}
13029
13030        void main() {
13031          ivec3 coords = getOutputCoords();
13032
13033          vec4 result = vec4(0.);
13034          int flatIndex, r, c, offset;
13035          ivec3 localCoords;
13036          vec2 uv;
13037          vec4 values;
13038
13039          ${r}
13040
13041          ${s.output} = ${a};
13042        }
13043    `}}/**
13044 * @license
13045 * Copyright 2017 Google LLC. All Rights Reserved.
13046 * Licensed under the Apache License, Version 2.0 (the "License");
13047 * you may not use this file except in compliance with the License.
13048 * You may obtain a copy of the License at
13049 *
13050 * http://www.apache.org/licenses/LICENSE-2.0
13051 *
13052 * Unless required by applicable law or agreed to in writing, software
13053 * distributed under the License is distributed on an "AS IS" BASIS,
13054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13055 * See the License for the specific language governing permissions and
13056 * limitations under the License.
13057 * =============================================================================
13058 */function Sv(n){const e=Pt(),t=`${e.version}
13059    precision highp float;
13060    ${e.attribute} vec3 clipSpacePos;
13061    ${e.attribute} vec2 uv;
13062    ${e.varyingVs} vec2 resultUV;
13063
13064    void main() {
13065      gl_Position = vec4(clipSpacePos, 1);
13066      resultUV = uv;
13067    }`;return Q1(n,t)}function kv(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 sv(n,e)}function Tv(n){const e=new Uint16Array([0,1,2,2,1,3]);return rv(n,e)}function xl(n,e,t,s,r,a){ov(e,t);const o=av(n),i=n.TEXTURE_2D;return se(n,()=>n.bindTexture(i,o)),se(n,()=>n.texParameteri(i,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE)),se(n,()=>n.texParameteri(i,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),se(n,()=>n.texParameteri(i,n.TEXTURE_MIN_FILTER,n.NEAREST)),se(n,()=>n.texParameteri(i,n.TEXTURE_MAG_FILTER,n.NEAREST)),W().getNumber("WEBGL_VERSION")===1?se(n,()=>n.texImage2D(i,0,s,e,t,0,r,a,null)):se(n,()=>n.texStorage2D(i,1,s,e,t)),se(n,()=>n.bindTexture(n.TEXTURE_2D,null)),{texture:o,texShape:[t,e]}}function cg(n){return n.internalFormatFloat}function Ev(n,e,t,s){const[r,a]=yl(e,t);return xl(n,r,a,cg(s),s.textureFormatFloat,n.FLOAT)}function hg(n){return n.internalFormatHalfFloat}function Rv(n,e,t,s){const[r,a]=yl(e,t);return xl(n,r,a,hg(s),s.textureFormatFloat,s.textureTypeHalfFloat)}function dg(n){return n.downloadTextureFormat}function Dv(n,e,t,s){const[r,a]=yl(e,t);return xl(n,r,a,dg(s),n.RGBA,n.UNSIGNED_BYTE)}function pg(n){return n.internalFormatPackedFloat}function Av(n,e,t,s){const[r,a]=ja(e,t);return xl(n,r,a,pg(s),n.RGBA,n.FLOAT)}function fg(n){return n.internalFormatPackedHalfFloat}function Ov(n,e,t,s){const[r,a]=ja(e,t);return xl(n,r,a,fg(s),n.RGBA,s.textureTypeHalfFloat)}function _v(n,e,t){return se(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),Id(n,e,"clipSpacePos",t,3,20,0)&&Id(n,e,"uv",t,2,20,12)}function Fv(n,e,t,s,r,a){se(n,()=>n.bindTexture(n.TEXTURE_2D,e));let o,i,l;r instanceof Uint8Array?(o=new Uint8Array(t*s*4),i=n.UNSIGNED_BYTE,l=n.RGBA):(o=new Float32Array(t*s*4),i=n.FLOAT,l=a.internalFormatPackedFloat),o.set(r),W().getNumber("WEBGL_VERSION")===2?se(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t,s,n.RGBA,i,o)):se(n,()=>n.texImage2D(n.TEXTURE_2D,0,l,t,s,0,n.RGBA,i,o)),se(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function Lv(n,e,t){se(n,()=>n.bindTexture(n.TEXTURE_2D,e)),t.data instanceof Uint8Array?W().getNumber("WEBGL_VERSION")===2?se(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,t.data)):se(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t.width,t.height,0,n.RGBA,n.UNSIGNED_BYTE,t.data)):W().getNumber("WEBGL_VERSION")===2?se(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,t)):se(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)),se(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function Pv(n,e,t,s){const r=n.createBuffer();se(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,r));const i=4*4*e*t;return se(n,()=>n.bufferData(n.PIXEL_PACK_BUFFER,i,n.STREAM_READ)),se(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,0)),se(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,null)),r}function zv(n,e,t){const s=n,r=new Float32Array(t);return s.bindBuffer(s.PIXEL_PACK_BUFFER,e),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,r),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),r}function Vv(n,e,t,s){const[r,a]=yl(e,t),o=4,i=new Uint8Array(MW(e*t,o));return se(n,()=>n.readPixels(0,0,r,a,s.downloadTextureFormat,n.UNSIGNED_BYTE,i)),new Float32Array(i.buffer)}function Bv(n,e,t,s,r,a,o,i){const l=n,u=new Float32Array(WW(a,o));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,u),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),u}function Mv(n,e,t){const s=new Float32Array(e*t*4);return se(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,s)),s}const q4=Object.freeze(Object.defineProperty({__proto__:null,bindVertexProgramAttributeStreams:_v,createBufferFromOutputTexture:Pv,createFloat16MatrixTexture:Rv,createFloat16PackedMatrixTexture:Ov,createFloat32MatrixTexture:Ev,createIndexBuffer:Tv,createPackedMatrixTexture:Av,createUnsignedBytesMatrixTexture:Dv,createVertexBuffer:kv,createVertexShader:Sv,downloadByteEncodedFloatMatrixFromOutputTexture:Vv,downloadFloat32MatrixFromBuffer:zv,downloadMatrixFromPackedOutputTexture:Mv,downloadPackedMatrixFromBuffer:Bv,getInternalFormatForFloat16MatrixTexture:hg,getInternalFormatForFloat16PackedMatrixTexture:fg,getInternalFormatForFloat32MatrixTexture:cg,getInternalFormatForPackedMatrixTexture:pg,getInternalFormatForUnsignedBytesMatrixTexture:dg,uploadDenseMatrixToTexture:Fv,uploadPixelDataToTexture:Lv},Symbol.toStringTag,{value:"Module"}));/**
13068 * @license
13069 * Copyright 2017 Google LLC. All Rights Reserved.
13070 * Licensed under the Apache License, Version 2.0 (the "License");
13071 * you may not use this file except in compliance with the License.
13072 * You may obtain a copy of the License at
13073 *
13074 * http://www.apache.org/licenses/LICENSE-2.0
13075 *
13076 * Unless required by applicable law or agreed to in writing, software
13077 * distributed under the License is distributed on an "AS IS" BASIS,
13078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13079 * See the License for the specific language governing permissions and
13080 * limitations under the License.
13081 * =============================================================================
13082 */class Wl{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const t=W().getNumber("WEBGL_VERSION");if(e!=null?(this.gl=e,Y1(t,e)):this.gl=On(t),e=this.gl,W().getNumber("WEBGL_VERSION")===2){const a=e;this.createVertexArray=()=>se(a,()=>a.createVertexArray()),this.bindVertexArray=o=>se(a,()=>a.bindVertexArray(o)),this.deleteVertexArray=o=>se(a,()=>a.deleteVertexArray(o)),this.getVertexArray=()=>se(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=()=>se(e,()=>a.createVertexArrayOES()),this.bindVertexArray=o=>se(e,()=>a.bindVertexArrayOES(o)),this.deleteVertexArray=o=>se(e,()=>a.deleteVertexArrayOES(o)),this.getVertexArray=()=>se(e,()=>e.getParameter(a.VERTEX_ARRAY_BINDING_OES))}let s="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),W().getNumber("WEBGL_VERSION")===1){const a="OES_texture_float",o="OES_texture_half_float";if(this.textureFloatExtension=co(this.gl,a),an(this.gl,o))this.textureHalfFloatExtension=co(this.gl,o);else if(W().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(s),an(this.gl,r))this.colorBufferHalfFloatExtension=co(this.gl,r);else if(W().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(s="EXT_color_buffer_float",an(this.gl,s))this.colorBufferFloatExtension=this.gl.getExtension(s);else if(an(this.gl,r))this.colorBufferHalfFloatExtension=this.gl.getExtension(r);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=kv(this.gl),this.indexBuffer=Tv(this.gl),this.framebuffer=iv(this.gl),this.textureConfig=ag(this.gl,this.textureHalfFloatExtension)}get debug(){return W().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;se(e,()=>e.finish()),se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),se(e,()=>e.deleteFramebuffer(this.framebuffer)),se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),se(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),se(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),Ev(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),Rv(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),Dv(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),Lv(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,s,r){this.throwIfDisposed(),Fv(this.gl,e,t,s,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),Ov(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),Av(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(Sd(this.gl,this.framebuffer),this.outputTexture=null),se(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,s){return this.downloadMatrixDriver(e,()=>Vv(this.gl,t,s,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,s,r,a,o){return Bv(this.gl,e,t,s,r,a,o,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return zv(this.gl,e,t)}createBufferFromTexture(e,t,s){this.bindTextureToFrameBuffer(e);const r=Pv(this.gl,t,s,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);
vendor: 6,065 bytes, lines 13082-13085
13082return this.pollFence(e)}createFence(e){let t,s;if(W().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),s=()=>{const o=r.clientWaitSync(a,0,0);return o===r.ALREADY_SIGNALED||o===r.CONDITION_SATISFIED},t=a}else W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),s=()=>this.isQueryAvailable(t,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):s=()=>!0;return{query:t,isFencePassed:s}}downloadMatrixFromPackedTexture(e,t,s){return this.downloadMatrixDriver(e,()=>Mv(this.gl,t,s))}createProgram(e){this.throwIfDisposed();const t=this.gl;this.vertexShader==null&&(this.vertexShader=Sv(t));const s=tv(t);se(t,()=>t.attachShader(s,this.vertexShader)),se(t,()=>t.attachShader(s,e)),nv(t,s);const r=Object.assign(s,{vao:this.createVertexArray()});return this.debug&&zl(t,r),r}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);const t=this.gl;se(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),_v(t,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&(se(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&zl(this.gl,this.program),se(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,s=!0){return this.throwIfDisposed(),s?uv(this.gl,e,t):cv(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),se(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,s){this.throwIfDisposed(),this.throwIfNoProgram(),hv(this.gl,e,t,s)}setOutputMatrixTexture(e,t,s){this.setOutputMatrixTextureDriver(e,s,t)}setOutputPackedMatrixTexture(e,t,s){this.throwIfDisposed();const[r,a]=ja(t,s);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,s,r){this.setOutputMatrixWriteRegionDriver(s,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,s,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&zl(this.gl,this.program),ho(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()}se(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),se(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=co(this.gl,W().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(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const s=this.gl,r=this.getQueryTimerExtensionWebGL2(),a=s.createQuery();return s.beginQuery(r.TIME_ELAPSED_EXT,a),a}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const t=this.gl,s=this.getQueryTimerExtensionWebGL2();t.endQuery(s.TIME_ELAPSED_EXT);return}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await Ng(()=>this.disposed||this.isQueryAvailable(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(t===0)return null;if(t===2){const s=this.gl;return s.getQueryParameter(e,s.QUERY_RESULT)/1e6}else{const s=this.getQueryTimerExtensionWebGL1();return s.getQueryObjectEXT(e,s.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(t===0)return!0;if(t===2){const s=this.gl,r=this.getQueryTimerExtensionWebGL2(),a=s.getQueryParameter(e,s.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),a&&!this.disjoint}else{const s=this.getQueryTimerExtensionWebGL1(),r=s.getQueryObjectEXT(e,s.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),r&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){const e=K4(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=e;++t){const{resolveFn:s}=this.itemsToPoll[t];s()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let s;"setTimeoutCustom"in W().platform&&(s=W().platform.setTimeoutCustom.bind(W().platform)),Ng(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,s)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),Vl(this.gl,e,this.framebuffer),this.debug&&ho(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(Vl(this.gl,this.outputTexture,this.framebuffer),this.debug&&ho(this.gl)):Sd(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const s=t();return this.unbindTextureToFrameBuffer(),s}setOutputMatrixTextureDriver(e,t,s){this.throwIfDisposed();const r=this.gl;Vl(r,e,this.framebuffer),this.debug&&ho(r),this.outputTexture=e,se(r,()=>r.viewport(0,0,t,s)),se(r,()=>r.scissor(0,0,t,s))}setOutputMatrixWriteRegionDriver(e,t,s,r){this.throwIfDisposed(),se(this.gl,()=>this.gl.scissor(e,t,s,r))}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 K4(n){let e=0;for(;e<n.length&&n[e]();++e);return e-1}/**
13083 * @license
13084 * Copyright 2020 Google LLC. All Rights Reserved.
13085 * Licensed under the Apache License, Version 2.0 (the "License");
13086 * you may not use this file except in compliance with the License.
13087 * You may obtain a copy of the License at
13088 *
13089 * http://www.apache.org/licenses/LICENSE-2.0
13090 *
13091 * Unless required by applicable law or agreed to in writing, software
13092 * distributed under the License is distributed on an "AS IS" BASIS,
13093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13094 * See the License for the specific language governing permissions and
13095 * limitations under the License.
13096 * =============================================================================
13097 */const{addImpl:X4,bincountImpl:Wv,bincountReduceImpl:Y4,bitwiseAndImpl:J4,castImpl:Z4,ceilImpl:Q4,concatImpl:eU,equalImpl:tU,expImpl:nU,expm1Impl:sU,floorImpl:rU,gatherNdImpl:aU,gatherV2Impl:oU,greaterImpl:iU,greaterEqualImpl:lU,lessImpl:uU,lessEqualImpl:cU,linSpaceImpl:hU,logImpl:dU,maxImpl:pU,maximumImpl:fU,minimumImpl:mU,multiplyImpl:gU,negImpl:yU,notEqualImpl:xU,prodImpl:bU,raggedGatherImpl:wU,raggedRangeImpl:vU,raggedTensorToTensorImpl:CU,rangeImpl:$U,rsqrtImpl:NU,scatterImpl:IU,sigmoidImpl:SU,simpleAbsImpl:Uv,sliceImpl:kU,sparseFillEmptyRowsImpl:TU,sparseReshapeImpl:EU,sparseSegmentReductionImpl:Gv,sqrtImpl:RU,staticRegexReplaceImpl:DU,stridedSliceImpl:AU,stringNGramsImpl:OU,stringSplitImpl:_U,stringToHashBucketFastImpl:FU,subImpl:LU,tileImpl:PU,topKImpl:zU,transposeImpl:mg,uniqueImpl:VU}=A1;/**
13098 * @license
13099 * Copyright 2018 Google LLC. All Rights Reserved.
13100 * Licensed under the Apache License, Version 2.0 (the "License");
13101 * you may not use this file except in compliance with the License.
13102 * You may obtain a copy of the License at
13103 *
13104 * http://www.apache.org/licenses/LICENSE-2.0
13105 *
13106 * Unless required by applicable law or agreed to in writing, software
13107 * distributed under the License is distributed on an "AS IS" BASIS,
13108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13109 * See the License for the specific language governing permissions and
13110 * limitations under the License.
13111 * =============================================================================
13112 */function Hv(n,e){return["x","y","z","w","u","v"].slice(0,e).map(t=>`${n}.${t}`)}function Rt(n,e){return e===1?[n]:Hv(n,e)}function BU(n,e){if(n===1)return"rc";let t="";for(let s=0;s<n;s++)t+=e[s],s<n-1&&(t+=",");return t}/**
13113 * @license
13114 * Copyright 2018 Google LLC. All Rights Reserved.
13115 * Licensed under the Apache License, Version 2.0 (the "License");
13116 * you may not use this file except in compliance with the License.
13117 * You may obtain a copy of the License at
13118 *
13119 * http://www.apache.org/licenses/LICENSE-2.0
13120 *
13121 * Unless required by applicable law or agreed to in writing, software
13122 * distributed under the License is distributed on an "AS IS" BASIS,
13123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13124 * See the License for the specific language governing permissions and
13125 * limitations under the License.
13126 * =============================================================================
13127 */class MU{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=Tt(this.outputShape.length),this.rank===0)this.userCode=`
13128        void main() {
13129          setOutput(vec4(getA(), 0., 0., 0.));
13130        }
13131      `;else{const t=Rt("rc",this.rank),s=Fe(this.rank),r=this.getOutOfBoundsCondition(t),a=this.getSetup(t),o=this.getOutput(t);this.userCode=`
13132        void main() {
13133          ${s} rc = getOutputCoords();
13134
13135          if(${r}) {
13136            setOutput(vec4(0));
13137          } else {
13138            ${a}
13139
13140            setOutput(vec4(${o}));
13141          }
13142        }
13143      `}}getSourceCoordsArr(e){const t=[];for(let s=0;s<=1;s++)for(let r=0;r<=1;r++){let a=`${s===0?"r":"rp1"}, ${r===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 s=this.rank-2;s<this.rank;s++)t+=`${e[s]} >= ${this.enableShapeUniforms?`outShape[${s}]`:this.outputShape[s]}`,s<this.rank-1&&(t+="||");return t}getSetup(e){if(this.rank===1)return"";const t=e.slice(-2),s=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],r=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return`
13144      int r = ${t[0]};
13145      int c = ${t[1]};
13146      int rp1 = r + 1;
13147      int cp1 = c + 1;
13148
13149      bool cEdge = cp1 >= ${s};
13150      bool rEdge = rp1 >= ${r};
13151    `}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]}),
13152            cEdge ? 0. : getA(${t[1]}),
13153            rEdge ? 0. : getA(${t[2]}),
13154            rEdge || cEdge ? 0. : getA(${t[3]})`}}/**
13155 * @license
13156 * Copyright 2018 Google LLC. All Rights Reserved.
13157 * Licensed under the Apache License, Version 2.0 (the "License");
13158 * you may not use this file except in compliance with the License.
13159 * You may obtain a copy of the License at
13160 *
13161 * http://www.apache.org/licenses/LICENSE-2.0
13162 *
13163 * Unless required by applicable law or agreed to in writing, software
13164 * distributed under the License is distributed on an "AS IS" BASIS,
13165 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13166 * See the License for the specific language governing permissions and
13167 * limitations under the License.
13168 * =============================================================================
13169 */class jv{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length);let s="";for(let r=0;r<4;r++){let a="thisRC = rc;";r%2===1&&(a+="thisRC.z += 1;"),r>1&&(a+="thisRC.y += 1;"),s+=`
13170        ${a}
13171        ${r>0?"if(thisRC.y < rows && thisRC.z < cols){":""}
13172          int flatIndex = getFlatIndex(thisRC);
13173
13174          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);
13175          vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));
13176
13177          result[${r}] =
13178            getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
13179        ${r>0?"}":""}
13180      `}this.userCode=`
13181      ${WU(t,this.enableShapeUniforms)}
13182      ${this.enableShapeUniforms?lg():ig(e)}
13183
13184      void main() {
13185        ivec3 rc = getOutputCoords();
13186
13187        vec4 result = vec4(0.);
13188
13189        ivec3 thisRC;
13190        int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};
13191        int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};
13192
13193        ${s}
13194
13195        setOutput(result);
13196      }
13197    `}}function WU(n,e){return`
13198    ivec3 inputCoordsFromReshapedOutCoords(int index) {
13199      ${e?t4(["r","c","d"],"inputShape"):vr(["r","c","d"],n)}
13200      return ivec3(r, c, d);
13201    }
13202  `}/**
13203 * @license
13204 * Copyright 2017 Google LLC. All Rights Reserved.
13205 * Licensed under the Apache License, Version 2.0 (the "License");
13206 * you may not use this file except in compliance with the License.
13207 * You may obtain a copy of the License at
13208 *
13209 * http://www.apache.org/licenses/LICENSE-2.0
13210 *
13211 * Unless required by applicable law or agreed to in writing, software
13212 * distributed under the License is distributed on an "AS IS" BASIS,
13213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13214 * See the License for the specific language governing permissions and
13215 * limitations under the License.
13216 * =============================================================================
13217 */class UU{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,s){const r=Sy(t,s),a=ky(e,r,s);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const o=Iy(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,s);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();const l=this.freeTextures[a].pop();return this.usedTextures[a].push(l),l}let i;return r===yt.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===yt.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===yt.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===yt.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===yt.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,s,r){if(this.freeTextures==null)return;const a=Sy(s,r),o=ky(t,a,r);o in this.freeTextures||(this.freeTextures[o]=[]);const i=Iy(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),l=W().getNumber("WEBGL_DELET
13217E_TEXTURE_THRESHOLD");l!==-1&&this._numBytesAllocated>l?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=i):(this.freeTextures[o].push(e),this.numFreeTextures++,this._numBytesFree+=i),this.numUsedTextures--;const u=this.usedTextures[o],c=u&&u.indexOf(e);if(c==null||c<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u[c]=u[u.length-1],u.pop(),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;`${this.numFreeTextures}${this.numUsedTextures}`,`${e}`;const t=this._numBytesFree/this._numBytesAllocated;`${this._numBytesAllocated}`,`${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 GU(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 Iy(n,e,t,s,r){const a=HU(e,s);let o;if(r){const[l,u]=ja(n[0],n[1]);o=l*u}else{const[l,u]=yl(n[0],n[1]);o=l*u}const i=GU(t,a);return o*i}function HU(n,e){switch(n){case yt.PACKED_2X2_FLOAT32:return pg(e);case yt.PACKED_2X2_FLOAT16:return fg(e);case yt.UNPACKED_FLOAT32:return cg(e);case yt.UNPACKED_FLOAT16:return hg(e);case yt.PACKED_4X1_UNSIGNED_BYTE:return dg(e);default:throw new Error(`Unknown physical texture type ${n}`)}}function jU(n){return W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?yt.PACKED_2X2_FLOAT32:yt.UNPACKED_FLOAT32:n?yt.PACKED_2X2_FLOAT16:yt.UNPACKED_FLOAT16}function Sy(n,e){if(n===rn.UPLOAD)return yt.PACKED_2X2_FLOAT32;if(n===rn.RENDER||n==null)return jU(e);if(n===rn.DOWNLOAD||n===rn.PIXELS)return yt.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${n}`)}function ky(n,e,t){return`${n[0]}_${n[1]}_${e}_${t}`}/**
13218 * @license
13219 * Copyright 2017 Google LLC. All Rights Reserved.
13220 * Licensed under the Apache License, Version 2.0 (the "License");
13221 * you may not use this file except in compliance with the License.
13222 * You may obtain a copy of the License at
13223 *
13224 * http://www.apache.org/licenses/LICENSE-2.0
13225 *
13226 * Unless required by applicable law or agreed to in writing, software
13227 * distributed under the License is distributed on an "AS IS" BASIS,
13228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13229 * See the License for the specific language governing permissions and
13230 * limitations under the License.
13231 * =============================================================================
13232 */class Bn{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length),this.userCode=`
13233      float unaryOperation(float x) {
13234        ${t}
13235      }
13236
13237      void main() {
13238        float x = getAAtOutCoords();
13239        float y = unaryOperation(x);
13240
13241        setOutput(y);
13242      }
13243    `}}const Cn="if (isnan(x)) return x;",qU="return x;",Ty="return abs(x);",KU="return (x >= 0.0) ? x : (exp(x) - 1.0);",XU=Cn+`
13244  return (x < 0.0) ? 0.0 : x;
13245`,YU=Cn+`
13246  return (x < 0.0) ? 0.0 : min(6.0, x);
13247`,ms="return x;",JU="return 1.0 / (1.0 + exp(-1.0 * x));";/**
13248 * @license
13249 * Copyright 2018 Google LLC. All Rights Reserved.
13250 * Licensed under the Apache License, Version 2.0 (the "License");
13251 * you may not use this file except in compliance with the License.
13252 * You may obtain a copy of the License at
13253 *
13254 * http://www.apache.org/licenses/LICENSE-2.0
13255 *
13256 * Unless required by applicable law or agreed to in writing, software
13257 * distributed under the License is distributed on an "AS IS" BASIS,
13258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13259 * See the License for the specific language governing permissions and
13260 * limitations under the License.
13261 * =============================================================================
13262 */const ZU="return x;",QU=`
13263  vec4 result;
13264
13265  result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
13266  result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
13267  result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
13268  result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
13269
13270  return result;
13271`,eG=`
13272  vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
13273  bvec4 isNaN = isnan(x);
13274
13275  result.r = isNaN.r ? x.r : result.r;
13276  result.g = isNaN.g ? x.g : result.g;
13277  result.b = isNaN.b ? x.b : result.b;
13278  result.a = isNaN.a ? x.a : result.a;
13279
13280  return result;
13281`,tG=`
13282  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
13283  bvec4 isNaN = isnan(x);
13284
13285  result.r = isNaN.r ? x.r : result.r;
13286  result.g = isNaN.g ? x.g : result.g;
13287  result.b = isNaN.b ? x.b : result.b;
13288  result.a = isNaN.a ? x.a : result.a;
13289
13290  return result;
13291`,nG="return 1.0 / (1.0 + exp(-1.0 * x));";class xs{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length),this.userCode=`
13292      vec4 unaryOperation(vec4 x) {
13293        ${t}
13294      }
13295
13296      void main() {
13297        vec4 x = getAAtOutCoords();
13298        vec4 y = unaryOperation(x);
13299
13300        setOutput(y);
13301      }
13302    `}}/**
13303 * @license
13304 * Copyright 2018 Google LLC. All Rights Reserved.
13305 * Licensed under the Apache License, Version 2.0 (the "License");
13306 * you may not use this file except in compliance with the License.
13307 * You may obtain a copy of the License at
13308 *
13309 * http://www.apache.org/licenses/LICENSE-2.0
13310 *
13311 * Unless required by applicable law or agreed to in writing, software
13312 * distributed under the License is distributed on an "AS IS" BASIS,
13313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13314 * See the License for the specific language governing permissions and
13315 * limitations under the License.
13316 * =============================================================================
13317 */class sG{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=Tt(this.outputShape.length);const t=e.length,s=Rt("rc",t),r=Fe(t),a=BU(t,s),o=s.slice(-2),i=t<=1?"rc":`vec2(${o.join(",")})`;this.userCode=`
13318      void main() {
13319        ${r} rc = getOutputCoords();
13320        vec4 packedInput = getA(${a});
13321
13322        setOutput(getChannel(packedInput, ${i}));
13323      }
13324    `}}/**
13325 * @license
13326 * Copyright 2017 Google LLC. All Rights Reserved.
13327 * Licensed under the Apache License, Version 2.0 (the "License");
13328 * you may not use this file except in compliance with the License.
13329 * You may obtain a copy of the License at
13330 *
13331 * http://www.apache.org/licenses/LICENSE-2.0
13332 *
13333 * Unless required by applicable law or agreed to in writing, software
13334 * distributed under the License is distributed on an "AS IS" BASIS,
13335 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13336 * See the License for the specific language governing permissions and
13337 * limitations under the License.
13338 * =============================================================================
13339 */const rG=lh,aG=1e-7,oG=1e-4,Fl={};function iG(n){return n in Fl||(Fl[n]={}),Fl[n]}const lG=W().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),uG=600;function cG(){return W().global.screen==null?1024:W().global.screen.height*W().global.screen.width*window.devicePixelRatio*uG/1024/1024}class bl extends Kd{nextDataId(){return bl.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,!W().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(e!=null){if(e instanceof Wl)t=e;else{const s=On(W().getNumber("WEBGL_VERSION"),e);t=new Wl(s)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const s=On(W().getNumber("WEBGL_VERSION"));t=new Wl(s),this.binaryCache=iG(W().getNumber("WEBGL_VERSION")),this.gpgpuCreatedLocally=!0}this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new UU(this.gpgpu),this.numMBBeforeWarning=cG(),this.texData=new Xd(this,Sn())}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(e,t,s,r,a,o){const i=this.makeTensorInfo(t,s),l=this.texData.get(i.dataId);l.isPacked=!1,l.texture={texture:e,texShape:[r,a]},l.texShape=[r,a];const u=po(t),c=new Ny(u,!1,o),h=this.runWebGLProgram(c,[i],s,[[r,a]]);return h.shape=t,l.texture=null,this.disposeIntermediateTensorInfo(i),h.dataId}write(e,t,s){if((W().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||W().getBool("DEBUG"))&&this.checkNumericalProblems(e),s==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:s,values:e,usage:rn.UPLOAD,refCount:1}),r}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,s,r,a){if(W().getBool("DEBUG")&&this.checkNumericalProblems(t),r==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:s,dtype:r,values:t,usage:rn.UPLOAD,refCount:a})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:s,dtype:r,complexTensorInfos:a,slice:o,shape:i,isPacked:l}=t;if(o!=null){let d;l?d=new xs(i,ms):d=new Bn(i,ms);const p=this.runWebGLProgram(d,[{dataId:e,shape:i,dtype:r}],r),f=this.readSync(p.dataId);return this.disposeIntermediateTensorInfo(p),f}if(s!=null)return this.convertAndCacheOnCPU(e);if(r==="string")return s;const u=this.activeTimers!=null;
vendor: 14,825 bytes, lines 13339-13342
13339let c;u&&(c=nn());let h;if(r==="complex64"){const d=this.readSync(a.real.dataId),p=this.readSync(a.imag.dataId);h=Ns(d,p)}else h=this.getValuesFromTexture(e);return u&&(this.downloadWaitMs+=nn()-c),this.convertAndCacheOnCPU(e,h)}async read(e){if(this.pendingRead.has(e)){const f=this.pendingRead.get(e);return new Promise(g=>f.push(g))}const t=this.texData.get(e),{values:s,shape:r,slice:a,dtype:o,complexTensorInfos:i,isPacked:l}=t;if(a!=null){let f;l?f=new xs(r,ms):f=new Bn(r,ms);const g=this.runWebGLProgram(f,[{dataId:e,shape:r,dtype:o}],o),m=this.read(g.dataId);return this.disposeIntermediateTensorInfo(g),m}if(s!=null)return this.convertAndCacheOnCPU(e);if(W().getBool("DEBUG")&&!W().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&W().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let u=null,c;if(o!=="complex64"&&W().get("WEBGL_BUFFER_SUPPORTED")){c=this.decode(e);const f=this.texData.get(c.dataId);u=this.gpgpu.createBufferFromTexture(f.texture.texture,...Ol(r))}this.pendingRead.set(e,[]),o!=="complex64"&&await this.gpgpu.createAndWaitForFence();let h;if(o==="complex64"){const f=await Promise.all([this.read(i.real.dataId),this.read(i.imag.dataId)]),g=f[0],m=f[1];h=Ns(g,m)}else if(u==null)h=this.getValuesFromTexture(e);else{const f=H(r);h=this.gpgpu.downloadFloat32MatrixFromBuffer(u,f)}if(c!=null&&this.disposeIntermediateTensorInfo(c),u!=null){const f=this.gpgpu.gl;se(f,()=>f.deleteBuffer(u))}const d=this.convertAndCacheOnCPU(e,h),p=this.pendingRead.get(e);return this.pendingRead.delete(e),p.forEach(f=>f(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&Sn().removeDataId(e,this),this.pendingDeletes--),d}readToGPU(e,t={}){const s=this.texData.get(e),{values:r,shape:a,slice:o,dtype:i,isPacked:l,texture:u}=s;if(i==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(o!=null){let p;l?p=new xs(a,ms):p=new Bn(a,ms);const f=this.runWebGLProgram(p,[{dataId:e,shape:a,dtype:i}],i),g=this.readToGPU(f,t);return this.disposeIntermediateTensorInfo(f),g}if(u==null)throw r!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const c=this.decode(e,t.customTexShape),h=Sn().makeTensorFromTensorInfo(c),d=this.texData.get(c.dataId);return Object.assign({tensorRef:h},d.texture)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const s=t.map(r=>Gi(r));return $e(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return $e(e.shape,e.dtype,t)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){const s=e[t];if(!J1(s))throw W().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")?Error(`The value ${s} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`):Error(`The value ${s} cannot be represented on this device.`)}}getValuesFromTexture(e){const{shape:t,dtype:s,isPacked:r}=this.texData.get(e),a=H(t);if(W().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const d=this.decode(e),p=this.texData.get(d.dataId),f=this.gpgpu.downloadMatrixFromPackedTexture(p.texture.texture,...Ol(t)).subarray(0,a);return this.disposeIntermediateTensorInfo(d),f}const o=W().getBool("WEBGL_PACK")&&r===!0,i=o?po(t):t,l=o?new G4(i):new U4(i),u=this.runWebGLProgram(l,[{shape:i,dtype:s,dataId:e}],"float32"),c=this.texData.get(u.dataId),h=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(c.texture.texture,c.texShape[0],c.texShape[1]).subarray(0,a);return this.disposeIntermediateTensorInfo(u),h}timerAvailable(){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(e){const t=this.activeTimers,s=[];let r=!1;this.programTimersStack==null?(this.programTimersStack=s,r=!0):this.activeTimers.push(s),this.activeTimers=s,e();const a=Hl(this.activeTimers.map(l=>l.query)).filter(l=>l!=null),o=Hl(this.activeTimers.map(l=>l.name)).filter(l=>l!=null);this.activeTimers=t,r&&(this.programTimersStack=null);const i={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const l=await Promise.all(a);i.kernelMs=c$(l),i.getExtraProfileInfo=()=>l.map((u,c)=>({name:o[c],ms:u})).map(u=>`${u.name}: ${u.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 W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:nn(),endMs:null}}endTimer(e){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=nn(),e)}async getQueryTime(e){if(W().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:s}=this.texData.get(e);return s!=null&&(this.disposeData(s.real.dataId,t),this.disposeData(s.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:s,texShape:r,usage:a,isPacked:o,slice:i}=this.texData.get(e),l=i&&i.origDataId||e,u=this.dataRefCount.get(l);u>1?this.dataRefCount.set(l,u-1):(this.dataRefCount.delete(l),t!=null&&(this.numBytesInGPU-=this.computeBytes(r,s),this.textureManager.releaseTexture(t,r,a,o)));const c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=lG){return W().getBool("WEBGL_CPU_FORWARD")&&e.every(s=>this.texData.get(s.dataId).texture==null&&H(s.shape)<t)}getGPGPUContext(){return this.gpgpu}where(e){Ui("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return rG(e.shape,t)}packedUnaryOp(e,t,s){const r=new xs(e.shape,t),a=this.compileAndRun(r,[e],s);return Sn().makeTensorFromTensorInfo(a)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){const r=Uv(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,r)}if(W().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,Ty,e.dtype);const t=new Bn(e.shape,Ty),s=this.compileAndRun(t,[e]);return Sn().makeTensorFromTensorInfo(s)}makeTensorInfo(e,t,s){let r;if(t==="string"&&s!=null&&s.length>0&&kr(s[0])){const a=s.map(o=>Od(o));r=this.write(a,e,t)}else r=this.write(s,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,s){return Sn().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,s),this)}unpackTensor(e){const t=new sG(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new MU(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const s=[cr(e.shape),...hr(e.shape)],r={dtype:e.dtype,shape:s,dataId:e.dataId},a=[cr(t),...hr(t)],o=new jv(a,s),i=!0,l=[s],u=this.runWebGLProgram(o,[r],e.dtype,l,i);return{dataId:u.dataId,shape:t,dtype:u.dtype}}decode(e,t){const s=this.texData.get(e),{isPacked:r,shape:a,dtype:o}=s;if(t!=null){const d=H(a),p=t[0]*t[1]*4;I(d<=p,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const i=po(a);let l;r?l=new W4(i):l=new M4(i);const u=!0,c=[t??Ol(i)],h=this.runWebGLProgram(l,[{shape:i,dtype:o,dataId:e}],o,c,u,t);return{dtype:o,shape:a,dataId:h.dataId}}runWebGLProgram(e,t,s,r,a=!1,o){const i=this.makeTensorInfo(e.outputShape,s),l=this.texData.get(i.dataId);if(e.packedOutput&&(l.isPacked=!0),e.outPackingScheme===So.DENSE){const y=o??Ol(e.outputShape);l.texShape=y.map(x=>x*2)}if(e.outTexUsage!=null&&(l.usage=e.outTexUsage),H(i.shape)===0)return l.values=wt(i.dtype,0),i;const u=[],c=t.map(y=>{if(y.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let x=this.texData.get(y.dataId);if(x.texture==null){if(!e.packedInputs&&H(y.shape)<=W().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:y.shape,texData:null,isUniform:!0,uniformValues:x.values};e.packedInputs&&(x.isPacked=!0,x.shape=y.shape)}if(this.uploadToGPU(y.dataId),!!x.isPacked!=!!e.packedInputs)y=x.isPacked?this.unpackTensor(y):this.packTensor(y),u.push(y),x=this.texData.get(y.dataId);else if(x.isPacked&&!ko(x.shape,y.shape)){const v=y,b=y.shape;y.shape=x.shape,y=this.packedReshape(y,b),u.push(y),x=this.texData.get(y.dataId),v.shape=b}return{shape:y.shape,texData:x,isUniform:!1}});this.uploadToGPU(i.dataId);const h={shape:i.shape,texData:l,isUniform:!1},d=B4(e,c,h),p=this.getAndSaveBinary(d,()=>z4(this.gpgpu,e,c,h)),f=this.activeTimers!=null;let g;f&&(g=this.startTimer()),W().get("ENGINE_COMPILE_ONLY")||V4(this.gpgpu,p,c,h,r),u.forEach(y=>this.disposeIntermediateTensorInfo(y)),f&&(g=this.endTimer(g),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(g)}));const m=W().getNumber("WEBGL_FLUSH_THRESHOLD");if(m>0){const y=nn();y-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=y)}if(!W().getBool("WEBGL_LAZILY_UNPACK")&&l.isPacked&&a===!1){const y=this.unpackTensor(i);return this.disposeIntermediateTensorInfo(i),y}return i}compileAndRun(e,t,s,r,a=!1){return s=s||t[0].dtype,this.runWebGLProgram(e,t,s,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(W().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=L(()=>{if(!W().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=W().getBool("DEBUG");W().set("DEBUG",!1);const t=this.abs(pe(1e-8)).dataSync()[0];if(W().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?aG:oG}uploadToGPU(e){const t=this.texData.get(e),{shape:s,dtype:r,values:a,texture:o,usage:i,isPacked:l}=t;if(o!=null)return;const u=this.activeTimers!=null;let c;u&&(c=nn());let h=t.texShape;if(h==null&&(h=fv(s,l),t.texShape=h),a!=null){const d=po(s);let p,f=h[1],g=h[0];const m=a instanceof Uint8Array||a instanceof Uint8ClampedArray;(l||!m)&&([f,g]=ja(h[0],h[1])),l?p=new j4(d,m):p=new Ny(d,m);const y=m?[g,f]:h,x=this.makeTensorInfo(y,r),v=this.texData.get(x.dataId);m?v.usage=rn.PIXELS:v.usage=rn.UPLOAD,v.texShape=y,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(x.dataId),f,g,a);const b=[[g,f]],$=this.runWebGLProgram(p,[x],r,b,!0),S=this.texData.get($.dataId);t.texShape=S.texShape,t.isPacked=S.isPacked,t.usage=S.usage,W().get("ENGINE_COMPILE_ONLY")?this.disposeData($.dataId):(t.texture=S.texture,t.values=null,this.texData.delete($.dataId)),this.disposeIntermediateTensorInfo(x),u&&(this.uploadWaitMs+=nn()-c)}else{const d=this.acquireTexture(h,i,r,l);t.texture=d}}convertAndCacheOnCPU(e,t){const s=this.texData.get(e),{dtype:r}=s;return t!=null&&(s.values=hG(t,r)),s.values}acquireTexture(e,t,s,r){if(this.numBytesInGPU+=this.computeBytes(e,s),!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,r)}computeBytes(e,t){return e[0]*e[1]*h$(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 s=new Promise(r=>{try{this.checkCompletion_(t),r(!0)}catch(a){throw a}});e.push(s)}return Promise.all(e)}}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await ff(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)===!1)throw this.gpgpu.gl.getProgramInfoLog(e.webGLProgram),this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS)===!1?(og(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:s,infLoc:r,nanLoc:a,outShapeLocation:o,outShapeStridesLocation:i,outTexShapeLocation:l}=Iv(this.gpgpu,e.program,e.webGLProgram);e.variablesLocations=t,e.customUniformLocations=s,e.infLoc=r,e.nanLoc=a,e.outShapeLocation=o,e.outShapeStridesLocation=i,e.outTexShapeLocation=l}}createTensorFromGPUData(e,t,s){e.channels=e.channels||"RGBA";const{texture:r,height:a,width:o,channels:i}=e,l=Sn().backend;if(!l.gpgpu.gl.isTexture(r))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 u=l.writeTexture(r,t,s,a,o,i);return Sn().makeTensorFromDataId(u,t,s,l)}}bl.nextDataId=0;function hG(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 s=0;s<t.length;++s)t[s]=Math.round(n[s]);return t}else throw new Error(`Unknown dtype ${e}`)}/** @license See the LICENSE file. */const qv="4.22.0";/**
13340 * @license
13341 * Copyright 2019 Google LLC. All Rights Reserved.
13342 * Licensed under the Apache License, Version 2.0 (the "License");
13343 * you may not use this file except in compliance with the License.
13344 * You may obtain a copy of the License at
13345 *
13346 * http://www.apache.org/licenses/LICENSE-2.0
13347 *
13348 * Unless required by applicable law or agreed to in writing, software
13349 * distributed under the License is distributed on an "AS IS" BASIS,
13350 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13351 * See the License for the specific language governing permissions and
13352 * limitations under the License.
13353 * =============================================================================
13354 */function Kv(){W().set("WEBGL_FORCE_F16_TEXTURES",!0)}/**
13355 * @license
13356 * Copyright 2020 Google Inc. All Rights Reserved.
13357 * Licensed under the Apache License, Version 2.0 (the "License");
13358 * you may not use this file except in compliance with the License.
13359 * You may obtain a copy of the License at
13360 *
13361 * http://www.apache.org/licenses/LICENSE-2.0
13362 *
13363 * Unless required by applicable law or agreed to in writing, software
13364 * distributed under the License is distributed on an "AS IS" BASIS,
13365 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13366 * See the License for the specific language governing permissions and
13367 * limitations under the License.
13368 * =============================================================================
13369 */d$()&&Jd("webgl",()=>new bl,2);const dG={forceHalfFloat:Kv};/**
13370 * @license
13371 * Copyright 2017 Google LLC. All Rights Reserved.
13372 * Licensed under the Apache License, Version 2.0 (the "License");
13373 * you may not use this file except in compliance with the License.
13374 * You may obtain a copy of the License at
13375 *
13376 * http://www.apache.org/licenses/LICENSE-2.0
13377 *
13378 * Unless required by applicable law or agreed to in writing, software
13379 * distributed under the License is distributed on an "AS IS" BASIS,
13380 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13381 * See the License for the specific language governing permissions and
13382 * limitations under the License.
13383 * =============================================================================
13384 */const gg=`
13385  if (isnan(a)) return a;
13386  if (isnan(b)) return b;
13387`;class dr{constructor(e,t,s){this.variableNames=["A","B"],this.outputShape=xe(t,s),this.enableShapeUniforms=Tt(this.outputShape.length),this.userCode=`
13388      float binaryOperation(float a, float b) {
13389        ${e}
13390      }
13391
13392      void main() {
13393        float a = getAAtOutCoords();
13394        float b = getBAtOutCoords();
13395        setOutput(binaryOperation(a, b));
13396      }
13397    `}}/**
13398 * @license
13399 * Copyright 2018 Google LLC. All Rights Reserved.
13400 * Licensed under the Apache License, Version 2.0 (the "License");
13401 * you may not use this file except in compliance with the License.
13402 * You may obtain a copy of the License at
13403 *
13404 * http://www.apache.org/licenses/LICENSE-2.0
13405 *
13406 * Unless required by applicable law or agreed to in writing, software
13407 * distributed under the License is distributed on an "AS IS" BASIS,
13408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13409 * See the License for the specific language governing permissions and
13410 * limitations under the License.
13411 * =============================================================================
13412 */const $r=`
13413  result.r = isNaN.r ? NAN : result.r;
13414  result.g = isNaN.g ? NAN : result.g;
13415  result.b = isNaN.b ? NAN : result.b;
13416  result.a = isNaN.a ? NAN : result.a;
13417`;class Za{constructor(e,t,s,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=xe(t,s);const a=this.outputShape.length;this.enableShapeUniforms=Tt(a);let o="";if(r)if(a===0||H(this.outputShape)===1)o=`
13418          result.y = 0.;
13419          result.z = 0.;
13420          result.w = 0.;
13421        `;else if(o=`
13422          ${Fe(a)} coords = getOutputCoords();
13423        `,a===1)this.enableShapeUniforms?o+=`
13424            result.y = (coords + 1) >= outShape ? 0. : result.y;
13425            result.z = 0.;
13426            result.w = 0.;
13427          `:o+=`
13428            result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
13429            result.z = 0.;
13430            result.w = 0.;
13431          `;else{const l=Rt("coords",a);this.enableShapeUniforms?o+=`
13432            bool nextRowOutOfBounds =
13433              (${l[a-2]} + 1) >= outShape[${a} - 2];
13434            bool nextColOutOfBounds =
13435              (${l[a-1]} + 1) >= outShape[${a} - 1];
13436            result.y = nextColOutOfBounds ? 0. : result.y;
13437            result.z = nextRowOutOfBounds ? 0. : result.z;
13438            result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
13439          `:o+=`
13440            bool nextRowOutOfBounds =
13441              (${l[a-2]} + 1) >= ${this.outputShape[a-2]};
13442            bool nextColOutOfBounds =
13443              (${l[a-1]} + 1) >= ${this.outputShape[a-1]};
13444            result.y = nextColOutOfBounds ? 0. : result.y;
13445            result.z = nextRowOutOfBounds ? 0. : result.z;
13446            result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
13447          `}this.userCode=`
13448      vec4 binaryOperation(vec4 a, vec4 b) {
13449        ${e}
13450      }
13451
13452      void main() {
13453        vec4 a = getAAtOutCoords();
13454        vec4 b = getBAtOutCoords();
13455
13456        vec4 result = binaryOperation(a, b);
13457        ${o}
13458
13459        setOutput(result);
13460      }
13461    `}}/**
13462 * @license
13463 * Copyright 2020 Google LLC. All Rights Reserved.
13464 * Licensed under the Apache License, Version 2.0 (the "License");
13465 * you may not use this file except in compliance with the License.
13466 * You may obtain a copy of the License at
13467 *
13468 * http://www.apache.org/licenses/LICENSE-2.0
13469 *
13470 * Unless required by applicable law or agreed to in writing, software
13471 * distributed under the License is distributed on an "AS IS" BASIS,
13472 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13473 * See the License for the specific language governing permissions and
13474 * limitations under the License.
13475 * =============================================================================
13476 */function Qt(n){const{inputs:e,backend:t}=n,{x:s}=e;return t.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const pG={kernelName:wc,backendName:"webgl",kernelFunc:Qt};/**
13477 * @license
13478 * Copyright 2020 Google LLC. All Rights Reserved.
13479 * Licensed under the Apache License, Version 2.0 (the "License");
13480 * you may not use this file except in compliance with the License.
13481 * You may obtain a copy of the License at
13482 *
13483 * http://www.apache.org/licenses/LICENSE-2.0
13484 *
13485 * Unless required by applicable law or agreed to in writing, software
13486 * distributed under the License is distributed on an "AS IS" BASIS,
13487 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13488 * See the License for the specific language governing permissions and
13489 * limitations under the License.
13490 * =============================================================================
13491 */function Bs(n){const{inputs:e,backend:t}=n,{real:s,imag:r}=e,a=t.makeTensorInfo(s.shape,"complex64"),o=t.texData.get(a.dataId),i=Qt({inputs:{x:s},backend:t}),l=Qt({inputs:{x:r},backend:t});return o.complexTensorInfos={real:i,imag:l},a}const fG={kernelName:Yd,backendName:"webgl",kernelFunc:Bs};/**
13492 * @license
13493 * Copyright 2020 Google LLC. All Rights Reserved.
13494 * Licensed under the Apache License, Version 2.0 (the "License");
13495 * you may not use this file except in compliance with the License.
13496 * You may obtain a copy of the License at
13497 *
13498 * http://www.apache.org/licenses/LICENSE-2.0
13499 *
13500 * Unless required by applicable law or agreed to in writing, software
13501 * distributed under the License is distributed on an "AS IS" BASIS,
13502 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13503 * See the License for the specific language governing permissions and
13504 * limitations under the License.
13505 * =============================================================================
13506 */const Xv="return (a < 0.) ? b * a : a;",Yv=`
13507  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
13508  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
13509`;function mG(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{alpha:a}=s,o=t.makeTensorInfo([],"float32",_s(a,"float32")),i=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Za(Yv,r.shape,o.shape):new dr(Xv,r.shape,o.shape),l=t.runWebGLProgram(i,[r,o],"float32");return t.disposeIntermediateTensorInfo(o),l}const gG={kernelName:vc,backendName:"webgl",kernelFunc:mG};/**
13510 * @license
13511 * Copyright 2020 Google LLC. All Rights Reserved.
13512 * Licensed under the Apache License, Version 2.0 (the "License");
13513 * you may not use this file except in compliance with the License.
13514 * You may obtain a copy of the License at
13515 *
13516 * http://www.apache.org/licenses/LICENSE-2.0
13517 *
13518 * Unless required by applicable law or agreed to in writing, software
13519 * distributed under the License is distributed on an "AS IS" BASIS,
13520 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13521 * See the License for the specific language governing permissions and
13522 * limitations under the License.
13523 * =============================================================================
13524 */const Jv="return (a < 0.) ? b * a : a;",Zv=`
13525  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
13526  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
13527`;function yG(n){const{inputs:e,backend:t}=n,{x:s,alpha:r}=e,a=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Za(Zv,s.shape,r.shape):new dr(Jv,s.shape,r.shape);return t.runWebGLProgram(a,[s,r],"float32")}const xG={kernelName:Ic,backendName:"webgl",kernelFunc:yG};/**
13528 * @license
13529 * Copyright 2020 Google LLC. All Rights Reserved.
13530 * Licensed under the Apache License, Version 2.0 (the "License");
13531 * you may not use this file except in compliance with the License.
13532 * You may obtain a copy of the License at
13533 *
13534 * http://www.apache.org/licenses/LICENSE-2.0
13535 *
13536 * Unless required by applicable law or agreed to in writing, software
13537 * distributed under the License is distributed on an "AS IS" BASIS,
13538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13539 * See the License for the specific language governing permissions and
13540 * limitations under the License.
13541 * =============================================================================
13542 */const Qa="if (isnan(x)) return x;";function Te({opSnippet:n,packedOpSnippet:e,cpuKernelImpl:t,dtype:s}){return({inputs:r,backend:a})=>{const{x:o}=r,i=a,l=s||o.dtype;if(i.shouldExecuteOnCPU([o])&&t!=null){const h=i.texData.get(o.dataId),d=t(h.values,l);return i.makeTensorInfo(o.shape,l,d)}const u=W().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let c;return u?c=new xs(o.shape,e):c=new Bn(o.shape,n),i.runWebGLProgram(c,[o],l)}}function Nt({opSnippet:n,packedOpSnippet:e,checkOutOfBounds:t=!1,supportsComplex:s=!1,cpuKernelImpl:r,dtype:a}){return({inputs:o,backend:i})=>{const{a:l,b:u}=o,c=i;
vendor: 3,523 bytes, lines 13542-13578
13542if(s&&l.dtype==="complex64"){const f=c.texData.get(l.dataId),g=c.texData.get(u.dataId),[m,y]=[[f.complexTensorInfos.real,g.complexTensorInfos.real],[f.complexTensorInfos.imag,g.complexTensorInfos.imag]].map(v=>{const[b,C]=v,$={dataId:b.dataId,dtype:b.dtype,shape:l.shape},S={dataId:C.dataId,dtype:C.dtype,shape:u.shape},k=new dr(n,l.shape,u.shape);return c.runWebGLProgram(k,[$,S],bn(b.dtype,C.dtype))}),x=Bs({inputs:{real:m,imag:y},backend:c});return c.disposeIntermediateTensorInfo(m),c.disposeIntermediateTensorInfo(y),x}const h=a||bn(l.dtype,u.dtype);if((l.dtype==="string"||u.dtype==="string"||c.shouldExecuteOnCPU([l,u]))&&r!=null){const f=c.texData.get(l.dataId).values,g=c.texData.get(u.dataId).values,m=l.dtype==="string"?Dr(f):f,y=l.dtype==="string"?Dr(g):g,[x,v]=r(l.shape,u.shape,m,y,h),b=c.makeTensorInfo(v,h),C=c.texData.get(b.dataId);return C.values=x,b}const d=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let p;return d?p=new Za(e,l.shape,u.shape,t):p=new dr(n,l.shape,u.shape),c.runWebGLProgram(p,[l,u],h)}}function To(n,e=!1){if(n==="linear")return e?ZU:qU;if(n==="relu")return e?eG:XU;if(n==="elu")return e?QU:KU;if(n==="relu6")return e?tG:YU;if(n==="prelu")return e?Zv:Jv;if(n==="leakyrelu")return e?Yv:Xv;if(n==="sigmoid")return e?nG:JU;throw new Error(`Activation ${n} has not been implemented for the WebGL backend.`)}/**
13543 * @license
13544 * Copyright 2018 Google LLC. All Rights Reserved.
13545 * Licensed under the Apache License, Version 2.0 (the "License");
13546 * you may not use this file except in compliance with the License.
13547 * You may obtain a copy of the License at
13548 *
13549 * http://www.apache.org/licenses/LICENSE-2.0
13550 *
13551 * Unless required by applicable law or agreed to in writing, software
13552 * distributed under the License is distributed on an "AS IS" BASIS,
13553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13554 * See the License for the specific language governing permissions and
13555 * limitations under the License.
13556 * =============================================================================
13557 */class Qv{constructor(e,t,s,r=!1,a=!1,o=!1,i=null,l=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=s,this.enableShapeUniforms=Tt(this.outputShape.length);const c=r?e[1]:e[2],h=Math.ceil(c/2),d=r?"i * 2, rc.y":"rc.y, i * 2",p=a?"rc.z, i * 2":"i * 2, rc.z",f=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],g=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",y="";i&&(l?m=`vec4 activation(vec4 a) {
13558          vec4 b = getPreluActivationWeightsAtOutCoords();
13559          ${i}
13560        }`:u?m=`vec4 activation(vec4 a) {
13561          vec4 b = getLeakyreluAlphaAtOutCoords();
13562          ${i}
13563        }`:m=`vec4 activation(vec4 x) {
13564          ${i}
13565        }`,y="result = activation(result);");const x=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),l&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let v="rc.x",b="rc.x";e[0]<t[0]?v=`imod(rc.x, ${e[0]})`:t[0]<e[0]&&(b=`imod(rc.x, ${t[0]})`),this.userCode=`
13566      ${m}
13567      // Don't use uniform for sharedDimensionPacked for performance.
13568      const float sharedDimension = ${h}.0;
13569
13570      vec4 dot2x2ARowBCol(ivec3 rc) {
13571        vec4 result = vec4(0);
13572        int batchA = ${v};
13573        int batchB = ${b};
13574        for (int i = 0; i < ${h}; i++) {
13575          vec4 a = getMatrixA(batchA, ${d});
13576          vec4 b = getMatrixB(batchB, ${p});
13577
13578          // These swizzled products need to be separately added.
13579          // See: https://github.com/tensorflow/tfjs/issues/1735
13580          result += (${f[0]} * ${g[0]});
13581          result += (${f[1]} * ${g[1]});
13582        }
13583        return result;
13584      }
13585
13586      void main() {
13587        ivec3 rc = getOutputCoords();
13588        vec4 result = dot2x2ARowBCol(rc);
13589
13590        ${x}
13591
13592        ${y}
13593
13594        setOutput(result);
13595      }
13596    `}}/**
13597 * @license
13598 * Copyright 2018 Google LLC. All Rights Reserved.
13599 * Licensed under the Apache License, Version 2.0 (the "License");
13600 * you may not use this file except in compliance with the License.
13601 * You may obtain a copy of the License at
13602 *
13603 * http://www.apache.org/licenses/LICENSE-2.0
13604 *
13605 * Unless required by applicable law or agreed to in writing, software
13606 * distributed under the License is distributed on an "AS IS" BASIS,
13607 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13608 * See the License for the specific language governing permissions and
13609 * limitations under the License.
13610 * =============================================================================
13611 */const Ey={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class Ry{constructor(e,t,s){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=xe(t,s),this.userCode=`
13612      float binaryOpComplex(
13613          float areal, float aimag, float breal, float bimag) {
13614        ${e}
13615      }
13616
13617      void main() {
13618        float areal = getARealAtOutCoords();
13619        float aimag = getAImagAtOutCoords();
13620        float breal = getBRealAtOutCoords();
13621        float bimag = getBImagAtOutCoords();
13622        setOutput(binaryOpComplex(areal, aimag, breal, bimag));
13623      }
13624    `}}/**
13625 * @license
13626 * Copyright 2020 Google LLC. All Rights Reserved.
13627 * Licensed under the Apache License, Version 2.0 (the "License");
13628 * you may not use this file except in compliance with the License.
13629 * You may obtain a copy of the License at
13630 *
13631 * http://www.apache.org/licenses/LICENSE-2.0
13632 *
13633 * Unless required by applicable law or agreed to in writing, software
13634 * distributed under the License is distributed on an "AS IS" BASIS,
13635 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13636 * See the License for the specific language governing permissions and
13637 * limitations under the License.
13638 * =============================================================================
13639 */const Dy="return a * b;";function yg(n){const{inputs:e,backend:t}=n,{a:s,b:r}=e,a=bn(s.dtype,r.dtype);if(s.dtype==="complex64"){const i=t.texData.get(s.dataId),l=t.texData.get(r.dataId),u=new Ry(Ey.REAL,s.shape,r.shape),c=new Ry(Ey.IMAG,s.shape,r.shape),h=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:s.shape},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:s.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:r.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:r.shape}],d=t.runWebGLProgram(u,h,"float32"),p=t.runWebGLProgram(c,h,"float32"),f=Bs({inputs:{real:d,imag:p},backend:t});return t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),f}if(t.shouldExecuteOnCPU([s,r])){const i=t.texData.get(s.dataId),l=t.texData.get(r.dataId),[u,c]=gU(s.shape,r.shape,i.values,l.values,a),h=t.makeTensorInfo(c,a),d=t.texData.get(h.dataId);return d.values=u,h}let o;return W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?o=new Za(Dy,s.shape,r.shape):o=new dr(Dy,s.shape,r.shape),t.runWebGLProgram(o,[s,r],a)}const bG={kernelName:Di,backendName:"webgl",kernelFunc:yg};/**
13640 * @license
13641 * Copyright 2020 Google LLC. All Rights Reserved.
13642 * Licensed under the Apache License, Version 2.0 (the "License");
13643 * you may not use this file except in compliance with the License.
13644 * You may obtain a copy of the License at
13645 *
13646 * http://www.apache.org/licenses/LICENSE-2.0
13647 *
13648 * Unless required by applicable law or agreed to in writing, software
13649 * distributed under the License is distributed on an "AS IS" BASIS,
13650 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13651 * See the License for the specific language governing permissions and
13652 * limitations under the License.
13653 * =============================================================================
13654 */function wG(n,e,t){const s=[cr(n.shape),...hr(n.shape)],r={dtype:n.dtype,shape:s,dataId:n.dataId},a=[cr(e),...hr(e)],o=new jv(a,s),i=!0,l=[s],u=t.runWebGLProgram(o,[r],n.dtype,l,i);return{dataId:u.dataId,shape:e,dtype:u.dtype}}/**
13655 * @license
13656 * Copyright 2020 Google LLC. All Rights Reserved.
13657 * Licensed under the Apache License, Version 2.0 (the "License");
13658 * you may not use this file except in compliance with the License.
13659 * You may obtain a copy of the License at
13660 *
13661 * http://www.apache.org/licenses/LICENSE-2.0
13662 *
13663 * Unless required by applicable law or agreed to in writing, software
13664 * distributed under the License is distributed on an "AS IS" BASIS,
13665 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13666 * See the License for the specific language governing permissions and
13667 * limitations under the License.
13668 * =============================================================================
13669 */function ne(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{shape:a}=s,o=t,i=H(r.shape),l=$x(a,i),u=H(l);I(i===u,()=>`The new shape (${l}) has ${u} elements and the old shape (${r.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);const c=o.texData.get(r.dataId);return c.isPacked&&!ko(r.shape,l)&&!(c.texture!==null&&ko(c.shape,l))?wG(r,l,o):(o.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}const vG={kernelName:Sc,backendName:"webgl",kernelFunc:ne};/**
13670 * @license
13671 * Copyright 2020 Google LLC. All Rights Reserved.
13672 * Licensed under the Apache License, Version 2.0 (the "License");
13673 * you may not use this file except in compliance with the License.
13674 * You may obtain a copy of the License at
13675 *
13676 * http://www.apache.org/licenses/LICENSE-2.0
13677 *
13678 * Unless required by applicable law or agreed to in writing, software
13679 * distributed under the License is distributed on an "AS IS" BASIS,
13680 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13681 * See the License for the specific language governing permissions and
13682 * limitations under the License.
13683 * =============================================================================
13684 */class Ay{constructor(e,t){this.variableNames=["x"];const{windowSize:s,batchSize:r,inSize:a,outSize:o}=e;this.outputShape=[r,o];const i=Math.floor(s/4)*4,l=s%4;let u="sumValue += dot(values, ones);";if(t!=null){const h=1/t;u=`sumValue += dot(values * ${Ad(h)?h.toPrecision(2):h}, ones);`}let c="";a%s>0&&(c=`
13685        if (inIdx < 0 || inIdx >= ${a}) {
13686          return 0.0;
13687        }
13688      `),this.userCode=`
13689      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
13690
13691      float getValue(int batch, int inIdx) {
13692        ${c}
13693        return getX(batch, inIdx);
13694      }
13695
13696      void main() {
13697        ivec2 coords = getOutputCoords();
13698        int batch = coords[0];
13699        int outIdx = coords[1];
13700        int inOffset = outIdx * ${s};
13701
13702        float sumValue = 0.0;
13703
13704        for (int i = 0; i < ${i}; i += 4) {
13705          int inIdx = inOffset + i;
13706          vec4 values = vec4(
13707            getValue(batch, inIdx),
13708            getValue(batch, inIdx + 1),
13709            getValue(batch, inIdx + 2),
13710            getValue(batch, inIdx + 3)
13711          );
13712
13713          ${u}
13714        }
13715
13716        int inIdx = inOffset + ${i};
13717        if (${l===1}) {
13718          vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);
13719
13720          ${u}
13721        } else if (${l===2}) {
13722          vec4 values = vec4(
13723            getValue(batch, inIdx),
13724            getValue(batch, inIdx + 1), 0.0, 0.0);
13725
13726          ${u}
13727        } else if (${l===3}) {
13728          vec4 values = vec4(
13729            getValue(batch, inIdx),
13730            getValue(batch, inIdx + 1),
13731            getValue(batch, inIdx + 2), 0.0);
13732
13733          ${u}
13734        }
13735        setOutput(sumValue);
13736      }
13737    `}}/**
13738 * @license
13739 * Copyright 2017 Google LLC. All Rights Reserved.
13740 * Licensed under the Apache License, Version 2.0 (the "License");
13741 * you may not use this file except in compliance with the License.
13742 * You may obtain a copy of the License at
13743 *
13744 * http://www.apache.org/licenses/LICENSE-2.0
13745 *
13746 * Unless required by applicable law or agreed to in writing, software
13747 * distributed under the License is distributed on an "AS IS" BASIS,
13748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13749 * See the License for the specific language governing permissions and
13750 * limitations under the License.
13751 * =============================================================================
13752 */class CG{constructor(e,t){this.variableNames=["x"];const{windowSize:s,batchSize:r,inSize:a,outSize:o}=e;this.outputShape=[r,o];let i="0.0",l="";t==="prod"?i="1.0":t==="min"?(i="1.0 / 1e-20",l="min"):t==="max"&&(i="-1.0 / 1e-20",l="max");let u=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="sum"?u="sumValue":t==="prod"?u="prodValue":t==="all"?u="allValue":t==="any"&&(u="anyValue");const c=Math.floor(s/4)*4,h=s%4;let d=`
13753      if (${t==="sum"}) {
13754        sumValue += dot(values, ones);
13755      } else if (${t==="prod"}) {
13756        vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);
13757        prodValue *= tmp[0] * tmp[1];
13758      } else {
13759        minMaxValue = ${l}(values, minMaxValue);
13760        if (${t==="min"} || ${t==="max"}) {
13761          minMaxValue = ${l}(values, minMaxValue);
13762          bvec4 isNaN = isnan(values);
13763          if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {
13764            minMaxValue = vec4(NAN);
13765          }
13766        }
13767      }
13768    `,p="vec4";t==="all"?(i="1.0",d=`
13769        bool reducedAllValue = all(values);
13770        float floatedReducedAllValue = float(reducedAllValue);
13771        allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
13772      `,p="bvec4"):t==="any"&&(i="0.0",d=`
13773        bool reducedAnyValue = any(values);
13774        float floatedReducedAnyValue = float(reducedAnyValue);
13775        anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
13776      `,p="bvec4");let f="";a%s>0&&(f=`
13777        if (inIdx < 0 || inIdx >= ${a}) {
13778          return initializationValue;
13779        }
13780      `),this.userCode=`
13781      const float initializationValue = ${i};
13782      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
13783
13784      float getValue(int batch, int inIdx) {
13785        ${f}
13786        return getX(batch, inIdx);
13787      }
13788
13789      void main() {
13790        ivec2 coords = getOutputCoords();
13791        int batch = coords[0];
13792        int outIdx = coords[1];
13793        int inOffset = outIdx * ${s};
13794
13795        vec4 minMaxValue = vec4(${i});
13796        float prodValue = 1.0;
13797        float sumValue = 0.0;
13798        float allValue = 1.0;
13799        float anyValue = 0.0;
13800
13801        for (int i = 0; i < ${c}; i += 4) {
13802          int inIdx = inOffset + i;
13803          ${p} values = ${p}(
13804            getValue(batch, inIdx),
13805            getValue(batch, inIdx + 1),
13806            getValue(batch, inIdx + 2),
13807            getValue(batch, inIdx + 3)
13808          );
13809
13810          ${d}
13811        }
13812
13813        int inIdx = inOffset + ${c};
13814        if (${h===1}) {
13815          ${p} values = ${p}(
13816            getValue(batch, inIdx),
13817            initializationValue,
13818            initializationValue,
13819            initializationValue
13820          );
13821
13822          ${d}
13823        } else if (${h===2}) {
13824          ${p} values = ${p}(
13825            getValue(batch, inIdx),
13826            getValue(batch, inIdx + 1),
13827            initializationValue,
13828            initializationValue
13829          );
13830
13831          ${d}
13832        } else if (${h===3}) {
13833          ${p} values = ${p}(
13834            getValue(batch, inIdx),
13835            getValue(batch, inIdx + 1),
13836            getValue(batch, inIdx + 2),
13837            initializationValue
13838          );
13839
13840          ${d}
13841        }
13842        setOutput(${u});
13843      }
13844    `}}/**
13845 * @license
13846 * Copyright 2020 Google LLC. All Rights Reserved.
13847 * Licensed under the Apache License, Version 2.0 (the "License");
13848 * you may not use this file except in compliance with the License.
13849 * You may obtain a copy of the License at
13850 *
13851 * http://www.apache.org/licenses/LICENSE-2.0
13852 *
13853 * Unless required by applicable law or agreed to in writing, software
13854 * distributed under the License is distributed on an "AS IS" BASIS,
13855 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13856 * See the License for the specific language governing permissions and
13857 * limitations under the License.
13858 * =============================================================================
13859 */function $G(n){const e=[];for(;e.length===0||e[e.length-1].outSize!==1;){const t=e.length?e[e.length-1].outSize:n[1],s=np(t);e.push({inSize:t,windowSize:s,outSize:Math.ceil(t/s)})}return e}function Nr(n,e,t,s){const r=$G(n.shape);let a=n;for(let o=0;o<r.length;o++){const{inSize:i,windowSize:l,outSize:u}=r[o];let c,h;t==="mean"?c=o===0?new Ay({windowSize:l,inSize:i,batchSize:n.shape[0],outSize:u},i):new Ay({windowSize:l,inSize:i,batchSize:n.shape[0],outSize:u}):c=new CG({windowSize:l,inSize:i,batchSize:n.shape[0],outSize:u},t),h=a,a=s.runWebGLProgram(c,[a],e),h.dataId!==n.dataId&&s.disposeIntermediateTensorInfo(h)}return a}/**
13860 * @license
13861 * Copyright 2017 Google LLC. All Rights Reserved.
13862 * Licensed under the Apache License, Version 2.0 (the "License");
13863 * you may not use this file except in compliance with the License.
13864 * You may obtain a copy of the License at
13865 *
13866 * http://www.apache.org/licenses/LICENSE-2.0
13867 *
13868 * Unless required by applicable law or agreed to in writing, software
13869 * distributed under the License is distributed on an "AS IS" BASIS,
13870 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13871 * See the License for the specific language governing permissions and
13872 * limitations under the License.
13873 * =============================================================================
13874 */class NG{constructor(e,t){this.variableNames=["A"];const s=new Array(e.length);for(let o=0;o<s.length;o++)s[o]=e[t[o]];this.outputShape=s,this.rank=s.length;const r=Fe(this.rank),a=IG(t);this.userCode=`
13875    void main() {
13876      ${r} resRC = getOutputCoords();
13877      setOutput(getA(${a}));
13878    }
13879    `}}function IG(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"],s=new Array(e);for(let r=0;r<n.length;r++)s[n[r]]=t[r];return s.join()}/**
13880 * @license
13881 * Copyright 2019 Google LLC. All Rights Reserved.
13882 * Licensed under the Apache License, Version 2.0 (the "License");
13883 * you may not use this file except in compliance with the License.
13884 * You may obtain a copy of the License at
13885 *
13886 * http://www.apache.org/licenses/LICENSE-2.0
13887 *
13888 * Unless required by applicable law or agreed to in writing, software
13889 * distributed under the License is distributed on an "AS IS" BASIS,
13890 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13891 * See the License for the specific language governing permissions and
13892 * limitations under the License.
13893 * =============================================================================
13894 */class SG{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const s=new Array(e.length);for(let c=0;c<s.length;c++)s[c]=e[t[c]];if(this.outputShape=s,this.rank=s.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=Fe(this.rank),a=Hv("rc",this.rank),o=new Array(this.rank);for(let c=0;c<t.length;c++)o[t[c]]=a[c];const i=`vec2(${o.slice(-2).join()})`,l=`++${a[this.rank-1]} < ${s[this.rank-1]}`,u=`getChannel(getA(${o.join()}), ${i})`;this.userCode=`
13895    void main() {
13896      ${r} rc = getOutputCoords();
13897      vec4 result = vec4(0.);
13898      result[0] = ${u};
13899      if(${l}) {
13900        result[1] = ${u};
13901      }
13902      --${a[this.rank-1]};
13903      if(++${a[this.rank-2]} < ${s[this.rank-2]}) {
13904        result[2] = ${u};
13905        if(${l}) {
13906          result[3] = ${u};
13907        }
13908      }
13909      setOutput(result);
13910    }
13911    `}}/**
13912 * @license
13913 * Copyright 2020 Google LLC. All Rights Reserved.
13914 * Licensed under the Apache License, Version 2.0 (the "License");
13915 * you may not use this file except in compliance with the License.
13916 * You may obtain a copy of the License at
13917 *
13918 * http://www.apache.org/licenses/LICENSE-2.0
13919 *
13920 * Unless required by applicable law or agreed to in writing, software
13921 * distributed under the License is distributed on an "AS IS" BASIS,
13922 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13923 * See the License for the specific language governing permissions and
13924 * limitations under the License.
13925 * =============================================================================
13926 */function Lh(n,e,t){const s=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new SG(n.shape,e):new NG(n.shape,e);return t.runWebGLProgram(s,[n],n.dtype)}/**
13927 * @license
13928 * Copyright 2020 Google LLC. All Rights Reserved.
13929 * Licensed under the Apache License, Version 2.0 (the "License");
13930 * you may not use this file except in compliance with the License.
13931 * You may obtain a copy of the License at
13932 *
13933 * http://www.apache.org/licenses/LICENSE-2.0
13934 *
13935 * Unless required by applicable law or agreed to in writing, software
13936 * distributed under the License is distributed on an "AS IS" BASIS,
13937 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13938 * See the License for the specific language governing permissions and
13939 * limitations under the License.
13940 * =============================================================================
13941 */function kG(n,e,t,s){const r=e,a=n.shape.length,o=Ie(r,n.shape);let i=o;const l=Xe(i,a),u=l!=null;let c=n;u&&(c=Lh(n,l,s),i=st(i.length,a)),St("sum",i,a);const[h,d]=Ct(c.shape,i);let p=h;t&&(p=nt(h,o));const f=H(d),m=H(n.shape)/f,y=ne({inputs:{x:c},attrs:{shape:[m,f]},backend:s}),x=Vc(n.dtype),v=Nr(y,x,"sum",s),b=ne({inputs:{x:v},attrs:{shape:p},backend:s});return s.disposeIntermediateTensorInfo(y),s.disposeIntermediateTensorInfo(v),u&&s.disposeIntermediateTensorInfo(c),b}/**
13942 * @license
13943 * Copyright 2020 Google LLC. All Rights Reserved.
13944 * Licensed under the Apache License, Version 2.0 (the "License");
13945 * you may not use this file except in compliance with the License.
13946 * You may obtain a copy of the License at
13947 *
13948 * http://www.apache.org/licenses/LICENSE-2.0
13949 *
13950 * Unless required by applicable law or agreed to in writing, software
13951 * distributed under the License is distributed on an "AS IS" BASIS,
13952 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13953 * See the License for the specific language governing permissions and
13954 * limitations under the License.
13955 * =============================================================================
13956 */function Ph(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s;return kG(r,a,o,t)}const TG={kernelName:Rc,backendName:"webgl",kernelFunc:Ph};/**
13957 * @license
13958 * Copyright 2020 Google LLC. All Rights Reserved.
13959 * Licensed under the Apache License, Version 2.0 (the "License");
13960 * you may not use this file except in compliance with the License.
13961 * You may obtain a copy of the License at
13962 *
13963 * http://www.apache.org/licenses/LICENSE-2.0
13964 *
13965 * Unless required by applicable law or agreed to in writing, software
13966 * distributed under the License is distributed on an "AS IS" BASIS,
13967 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13968 * See the License for the specific language governing permissions and
13969 * limitations under the License.
13970 * =============================================================================
13971 */function _t(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{perm:a}=s,o=t,i=r.shape.length,l=new Array(i);for(let c=0;c<l.length;c++)l[c]=r.shape[a[c]];let u;if(o.shouldExecuteOnCPU([r])){const h=o.texData.get(r.dataId).values,d=mg(h,r.shape,r.dtype,a,l);u=o.makeTensorInfo(l,r.dtype);const p=o.texData.get(u.dataId);p.values=d}else u=Lh(r,a,o);return u}const EG={kernelName:Js,backendName:"webgl",kernelFunc:_t};/**
13972 * @license
13973 * Copyright 2020 Google LLC. All Rights Reserved.
13974 * Licensed under the Apache License, Version 2.0 (the "License");
13975 * you may not use this file except in compliance with the License.
13976 * You may obtain a copy of the License at
13977 *
13978 * http://www.apache.org/licenses/LICENSE-2.0
13979 *
13980 * Unless required by applicable law or agreed to in writing, softw
13980are
13981 * distributed under the License is distributed on an "AS IS" BASIS,
13982 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13983 * See the License for the specific language governing permissions and
13984 * limitations under the License.
13985 * =============================================================================
13986 */const eC=1e3;function mu({a:n,b:e,transposeA:t,transposeB:s,backend:r,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:l=null}){const u=n.shape.length,c=e.shape.length,h=t?n.shape[u-2]:n.shape[u-1],d=s?e.shape[c-1]:e.shape[c-2],p=t?n.shape[u-1]:n.shape[u-2],f=s?e.shape[c-2]:e.shape[c-1],g=n.shape.slice(0,-2),m=e.shape.slice(0,-2),y=H(g),x=H(m),b=xe(n.shape.slice(0,-2),e.shape.slice(0,-2)).concat([p,f]);I(h===d,()=>`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${n.shape} and ${e.shape} and transposeA=${t} and transposeB=${s} must match.`);const C=t?[y,h,p]:[y,p,h],$=s?[x,f,d]:[x,d,f],S=ne({inputs:{x:n},backend:r,attrs:{shape:C}}),k=ne({inputs:{x:e},backend:r,attrs:{shape:$}}),T=[S,k],E=Math.max(y,x),_=t?S.shape[1]:S.shape[2],z=a!=null,P=o!=null,V=l==="leakyrelu",B=l!=null?To(l,!0):null,M=z||P||V||B!=null;let j;if((p===1||f===1)&&_>eC&&M===!1){let q=S,X=k;t&&(q=_t({inputs:{x:S},backend:r,attrs:{perm:[0,2,1]}}),T.push(q)),s&&(X=_t({inputs:{x:k},backend:r,attrs:{perm:[0,2,1]}}),T.push(X));const Y=f!==1,Z=f===1;let J=q;Y&&(J=ne({inputs:{x:q},backend:r,attrs:{shape:[E,_,1]}}),T.push(J));const re=f===1?2:1;let Q=X;Z&&(Q=ne({inputs:{x:X},backend:r,attrs:{shape:[E,1,_]}}),T.push(Q));const ae=yg({inputs:{a:J,b:Q},backend:r});
vendor: 4,393 bytes, lines 13986-14056
13986j=Ph({inputs:{x:ae},backend:r,attrs:{axis:re,keepDims:!0}}),T.push(ae)}else{const q=bn(n.dtype,e.dtype),X=new Qv(C,$,[E,p,f],t,s,z,B,P,V),Y=[S,k];if(a!=null&&Y.push(a),P&&Y.push(o),V){const Z=r.makeTensorInfo([],"float32",_s(i,"float32"));Y.push(Z),T.push(Z)}j=r.runWebGLProgram(X,Y,q)}const U=ne({inputs:{x:j},backend:r,attrs:{shape:b}});T.push(j);for(const q of T)r.disposeIntermediateTensorInfo(q);return U}/**
13987 * @license
13988 * Copyright 2020 Google LLC. All Rights Reserved.
13989 * Licensed under the Apache License, Version 2.0 (the License);
13990 * you may not use this file except in compliance with the License.
13991 * You may obtain a copy of the License at
13992 *
13993 * http://www.apache.org/licenses/LICENSE-2.0
13994 *
13995 * Unless required by applicable law or agreed to in writing, software
13996 * distributed under the License is distributed on an AS IS BASIS,
13997 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13998 * See the License for the specific language governing permissions and
13999 * limitations under the License.
14000 * =============================================================================
14001 */function RG(n){const{inputs:e,backend:t,attrs:s}=n,{a:r,b:a,bias:o,preluActivationWeights:i}=e,{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:h}=s;return mu({a:r,b:a,transposeA:l,transposeB:u,backend:t,bias:o,preluActivationWeights:i,leakyreluAlpha:h,activation:c})}const DG={kernelName:xo,backendName:"webgl",kernelFunc:RG};/**
14002 * @license
14003 * Copyright 2020 Google LLC. All Rights Reserved.
14004 * Licensed under the Apache License, Version 2.0 (the "License");
14005 * you may not use this file except in compliance with the License.
14006 * You may obtain a copy of the License at
14007 *
14008 * http://www.apache.org/licenses/LICENSE-2.0
14009 *
14010 * Unless required by applicable law or agreed to in writing, software
14011 * distributed under the License is distributed on an "AS IS" BASIS,
14012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14013 * See the License for the specific language governing permissions and
14014 * limitations under the License.
14015 * =============================================================================
14016 */const Oy="return abs(x);";function AG(n){const{inputs:e,backend:t}=n,{x:s}=e;if(t.shouldExecuteOnCPU([s])&&s.dtype!=="complex64"){const a=t.texData.get(s.dataId),o=Uv(a.values);return t.makeTensorInfo(s.shape,s.dtype,o)}let r;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new xs(s.shape,Oy):r=new Bn(s.shape,Oy),t.runWebGLProgram(r,[s],s.dtype)}const OG={kernelName:pc,backendName:"webgl",kernelFunc:AG};/**
14017 * @license
14018 * Copyright 2020 Google LLC. All Rights Reserved.
14019 * Licensed under the Apache License, Version 2.0 (the "License");
14020 * you may not use this file except in compliance with the License.
14021 * You may obtain a copy of the License at
14022 *
14023 * http://www.apache.org/licenses/LICENSE-2.0
14024 *
14025 * Unless required by applicable law or agreed to in writing, software
14026 * distributed under the License is distributed on an "AS IS" BASIS,
14027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14028 * See the License for the specific language governing permissions and
14029 * limitations under the License.
14030 * =============================================================================
14031 */const _G=Cn+`
14032  if (abs(x) > 1.) {
14033    return NAN;
14034  }
14035  return acos(x);
14036`,FG=Te({opSnippet:_G}),LG={kernelName:Hr,backendName:"webgl",kernelFunc:FG};/**
14037 * @license
14038 * Copyright 2020 Google LLC. All Rights Reserved.
14039 * Licensed under the Apache License, Version 2.0 (the "License");
14040 * you may not use this file except in compliance with the License.
14041 * You may obtain a copy of the License at
14042 *
14043 * http://www.apache.org/licenses/LICENSE-2.0
14044 *
14045 * Unless required by applicable law or agreed to in writing, software
14046 * distributed under the License is distributed on an "AS IS" BASIS,
14047 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14048 * See the License for the specific language governing permissions and
14049 * limitations under the License.
14050 * =============================================================================
14051 */const PG=Cn+`
14052  if (x < 1.0) return NAN;
14053return log(x + sqrt(x * x - 1.0));`,zG=Te({opSnippet:PG}),VG={kernelName:jr,backendName:"webgl",kernelFunc:zG};/**
14054 * @license
14055 * Copyright 2020 Google LLC. All Rights Reserved.
14056 * Licensed under the Apache License, Version 2.0 (the "License");
14057 * you may not use this file except in compliance with the License.
14058 * You may obtain a copy of the License at
14059 *
14060 * http://www.apache.org/licenses/LICENSE-2.0
14061 *
14062 * Unless required by applicable law or agreed to in writing, software
14063 * distributed under the License is distributed on an "AS IS" BASIS,
14064 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14065 * See the License for the specific language governing permissions and
14066 * limitations under the License.
14067 * =============================================================================
14068 */const _y="return a + b;",BG=Nt({opSnippet:_y,packedOpSnippet:_y,supportsComplex:!0,cpuKernelImpl:X4}),MG={kernelName:ki,backendName:"webgl",kernelFunc:BG};/**
14069 * @license
14070 * Copyright 2019 Google LLC. All Rights Reserved.
14071 * Licensed under the Apache License, Version 2.0 (the "License");
14072 * you may not use this file except in compliance with the License.
14073 * You may obtain a copy of the License at
14074 *
14075 * http://www.apache.org/licenses/LICENSE-2.0
14076 *
14077 * Unless required by applicable law or agreed to in writing, software
14078 * distributed under the License is distributed on an "AS IS" BASIS,
14079 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14080 * See the License for the specific language governing permissions and
14081 * limitations under the License.
14082 * =============================================================================
14083 */class WG{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((a,o)=>`T${o}`);const s=[];this.variableNames.forEach(a=>{s.push(`float v${a} = get${a}AtOutCoords();`)});const r=this.variableNames.map(a=>`v${a}`).join(" + ");this.userCode=`
14084      void main() {
14085        ${s.join(`
14086        `)}
14087
14088        float result = ${r};
14089        setOutput(result);
14090      }
14091    `}}/**
14092 * @license
14093 * Copyright 2019 Google LLC. All Rights Reserved.
14094 * Licensed under the Apache License, Version 2.0 (the "License");
14095 * you may not use this file except in compliance with the License.
14096 * You may obtain a copy of the License at
14097 *
14098 * http://www.apache.org/licenses/LICENSE-2.0
14099 *
14100 * Unless required by applicable law or agreed to in writing, software
14101 * distributed under the License is distributed on an "AS IS" BASIS,
14102 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14103 * See the License for the specific language governing permissions and
14104 * limitations under the License.
14105 * =============================================================================
14106 */class UG{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((a,o)=>`T${o}`);const s=[];this.variableNames.forEach(a=>{s.push(`vec4 v${a} = get${a}AtOutCoords();`)});const r=this.variableNames.map(a=>`v${a}`).join(" + ");this.userCode=`
14107      void main() {
14108        ${s.join(`
14109        `)}
14110
14111        vec4 result = ${r};
14112        setOutput(result);
14113      }
14114    `}}/**
14115 * @license
14116 * Copyright 2020 Google LLC. All Rights Reserved.
14117 * Licensed under the Apache License, Version 2.0 (the "License");
14118 * you may not use this file except in compliance with the License.
14119 * You may obtain a copy of the License at
14120 *
14121 * http://www.apache.org/licenses/LICENSE-2.0
14122 *
14123 * Unless required by applicable law or agreed to in writing, software
14124 * distributed under the License is distributed on an "AS IS" BASIS,
14125 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14126 * See the License for the specific language governing permissions and
14127 * limitations under the License.
14128 * =============================================================================
14129 */function Ul(n){const{inputs:e,backend:t}=n,s=e;if(s.length===1)return Qt({inputs:{x:s[0]},backend:t});if(s.length>W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const l=Math.floor(s.length/2),u=Ul({inputs:s.slice(0,l),backend:t}),c=Ul({inputs:s.slice(l),backend:t});return Ul({inputs:[u,c],backend:t})}const r=s.map(l=>l.dtype).reduce((l,u)=>bn(l,u)),a=s.map(l=>l.shape),i=W().getBool("WEBGL_PACK")?new UG(s[0].shape,a):new WG(s[0].shape,a);return t.runWebGLProgram(i,s,r)}const GG={kernelName:Do,backendName:"webgl",kernelFunc:Ul};/**
14130 * @license
14131 * Copyright 2020 Google LLC. All Rights Reserved.
14132 * Licensed under the Apache License, Version 2.0 (the "License");
14133 * you may not use this file except in compliance with the License.
14134 * You may obtain a copy of the License at
14135 *
14136 * http://www.apache.org/licenses/LICENSE-2.0
14137 *
14138 * Unless required by applicable law or agreed to in writing, software
14139 * distributed under the License is distributed on an "AS IS" BASIS,
14140 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14141 * See the License for the specific language governing permissions and
14142 * limitations under the License.
14143 * =============================================================================
14144 */function HG(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s,i=r.shape.length,l=Ie(a,r.shape);let u=l;const c=Xe(u,i);let h=r;c!=null&&(h=_t({inputs:{x:r},backend:t,attrs:{perm:c}}),u=st(u.length,i)),St("all",u,i);const[d,p]=Ct(h.shape,u),f=H(p),g=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,f]}}),m=Nr(g,g.dtype,"all",t);let y;if(o){const x=nt(d,l);y=ne({inputs:{x:m},backend:t,attrs:{shape:x}})}else y=ne({inputs:{x:m},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),c!=null&&t.disposeIntermediateTensorInfo(h),y}const jG={kernelName:xu,backendName:"webgl",kernelFunc:HG};/**
14145 * @license
14146 * Copyright 2020 Google LLC. All Rights Reserved.
14147 * Licensed under the Apache License, Version 2.0 (the "License");
14148 * you may not use this file except in compliance with the License.
14149 * You may obtain a copy of the License at
14150 *
14151 * http://www.apache.org/licenses/LICENSE-2.0
14152 *
14153 * Unless required by applicable law or agreed to in writing, software
14154 * distributed under the License is distributed on an "AS IS" BASIS,
14155 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14156 * See the License for the specific language governing permissions and
14157 * limitations under the License.
14158 * =============================================================================
14159 */function qG(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s,i=r.shape.length,l=Ie(a,r.shape);let u=l;const c=Xe(u,i);let h=r;c!=null&&(h=_t({inputs:{x:r},backend:t,attrs:{perm:c}}),u=st(u.length,i)),St("any",u,i);const[d,p]=Ct(h.shape,u),f=H(p),g=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,f]}}),m=Nr(g,g.dtype,"any",t);let y;if(o){const x=nt(d,l);y=ne({inputs:{x:m},backend:t,attrs:{shape:x}})}else y=ne({inputs:{x:m},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),c!=null&&t.disposeIntermediateTensorInfo(h),y}const KG={kernelName:bu,backendName:"webgl",kernelFunc:qG};/**
14160 * @license
14161 * Copyright 2017 Google LLC. All Rights Reserved.
14162 * Licensed under the Apache License, Version 2.0 (the "License");
14163 * you may not use this file except in compliance with the License.
14164 * You may obtain a copy of the License at
14165 *
14166 * http://www.apache.org/licenses/LICENSE-2.0
14167 *
14168 * Unless required by applicable law or agreed to in writing, software
14169 * distributed under the License is distributed on an "AS IS" BASIS,
14170 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14171 * See the License for the specific language governing permissions and
14172 * limitations under the License.
14173 * =============================================================================
14174 */class XG{constructor(e,t,s){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:o}=e;s||this.variableNames.push("bestIndicesA"),this.outputShape=[a,o];const i=t==="max"?">":"<",l=s?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`
14175      void main() {
14176        ivec2 coords = getOutputCoords();
14177        int batch = coords[0];
14178        int outIdx = coords[1];
14179        int inOffset = outIdx * ${r};
14180
14181        int bestIndex = inOffset;
14182        float bestValue = getA(batch, bestIndex);
14183
14184        for (int i = 0; i < ${r}; i++) {
14185          int inIdx = ${l};
14186          float candidate = getA(batch, inIdx);
14187          if (candidate ${i} bestValue) {
14188            bestValue = candidate;
14189            bestIndex = inIdx;
14190          }
14191        }
14192        setOutput(float(bestIndex));
14193      }
14194    `}}/**
14195 * @license
14196 * Copyright 2019 Google LLC. All Rights Reserved.
14197 * Licensed under the Apache License, Version 2.0 (the "License");
14198 * you may not use this file except in compliance with the License.
14199 * You may obtain a copy of the License at
14200 *
14201 * http://www.apache.org/licenses/LICENSE-2.0
14202 *
14203 * Unless required by applicable law or agreed to in writing, software
14204 * distributed under the License is distributed on an "AS IS" BASIS,
14205 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14206 * See the License for the specific language governing permissions and
14207 * limitations under the License.
14208 * =============================================================================
14209 */class YG{constructor(e,t,s,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,I(e.length>2,()=>`Packed arg${s.charAt(0).toUpperCase()+s.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),r||this.variableNames.push("bestIndicesA");const i=this.outputShape,l=i.length,u=Fe(l),c=Rt("coords",l);let h,d;if(o===1){d=l+1;const k=Fe(d);h=`
14210        ${k} sourceLocR = ${k}(${c.join()}, 0);
14211        ++${c[l-1]};
14212        ${k} sourceLocG = ${k}(${c.join()}, 0);
14213        ++${c[l-2]};
14214        ${k} sourceLocA = ${k}(${c.join()}, 0);
14215        --${c[l-1]};
14216        ${k} sourceLocB = ${k}(${c.join()}, 0);
14217        --${c[l-2]};`}else d=l,h=`
14218        ${u} sourceLocR = coords;
14219        ++${c[l-1]};
14220        ${u} sourceLocG = coords;
14221        ++${c[l-2]};
14222        ${u} sourceLocA = coords;
14223        --${c[l-1]};
14224        ${u} sourceLocB = coords;
14225        --${c[l-2]};`;const p=["x","y","z","w","u","v"].slice(0,d),f="."+p[d-1],g=p.map(k=>"int "+k),m=Rt("sourceLocR",d-1).concat("inIdx.r"),y=Rt("sourceLocG",d-1).concat("inIdx.g"),x=Rt("sourceLocB",d-1).concat("inIdx.b"),v=Rt("sourceLocA",d-1).concat("inIdx.a"),b=s==="max"?"greaterThan":"lessThan",C=r?"":`
14226          inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),
14227                             getBestIndicesAChannel(${y.join()}),
14228                             getBestIndicesAChannel(${x.join()}),
14229                             getBestIndicesAChannel(${v.join()})));`,$=`vec4(
14230            getAChannel(${m.join()}),
14231            hasNextCol ? getAChannel(${y.join()}) : 0.,
14232            hasNextRow ? getAChannel(${x.join()}) : 0.,
14233            hasNextRow && hasNextCol ? getAChannel(${v.join()}) : 0.)`,S=r?"":`
14234      float getBestIndicesAChannel(${g.join()}) {
14235        return getChannel(getBestIndicesA(${p.join()}),
14236                                          vec2(${p.slice(-2).join()}));
14237      }`;this.userCode=`
14238      float getAChannel(${g.join()}) {
14239        return getChannel(getA(${p.join()}),
14240                               vec2(${p.slice(-2).join()}));
14241      }
14242      ${S}
14243      void main() {
14244        ${u} coords = getOutputCoords();
14245        bool hasNextCol = ${c[l-1]} < ${i[l-1]-1};
14246        bool hasNextRow = ${c[l-2]} < ${i[l-2]-1};
14247        ${h}
14248        ivec4 srcIdx = ivec4(sourceLocR${f}, sourceLocG${f},
14249          sourceLocB${f}, sourceLocA${f}) * ${t};
14250        ivec4 inIdx = srcIdx;
14251        vec4 bestIndex = vec4(inIdx);
14252        vec4 bestValue = ${$};
14253
14254        for (int i = 0; i < ${t}; i++) {
14255          inIdx = srcIdx;
14256          ${C}
14257          vec4 candidate = ${$};
14258          bvec4 nan = isnan(candidate);
14259          bvec4 replace = bvec4(
14260            vec4(${b}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));
14261
14262          bestValue = vec4(replace.x  ? candidate.x : bestValue.x,
14263                           replace.y  ? candidate.y : bestValue.y,
14264                           replace.z  ? candidate.z : bestValue.z,
14265                           replace.w  ? candidate.w : bestValue.w);
14266          bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));
14267          srcIdx++;
14268        }
14269        setOutput(bestIndex);
14270      }
14271    `}}/**
14272 * @license
14273 * Copyright 2020 Google LLC. All Rights Reserved.
14274 * Licensed under the Apache License, Version 2.0 (the "License");
14275 * you may not use this file except in compliance with the License.
14276 * You may obtain a copy of the License at
14277 *
14278 * http://www.apache.org/licenses/LICENSE-2.0
14279 *
14280 * Unless required by applicable law or agreed to in writing, softw
14280are
14281 * distributed under the License is distributed on an "AS IS" BASIS,
14282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14283 * See the License for the specific language governing permissions and
14284 * limitations under the License.
14285 * =============================================================================
14286 */function tC(n,e,t,s=null){let r=e.shape[0],a=e.shape[1];s!=null&&(r=s.shape[0],a=s.shape[1]);const o=np(a),i={windowSize:o,inSize:a,batchSize:r,outSize:Math.ceil(a/o)},l=new XG(i,t,s==null),u=[e];s!=null&&u.push(s);const c=n.runWebGLProgram(l,u,"int32");if(c.shape[1]===1)return c;const h=tC(n,e,t,c);return n.disposeIntermediateTensorInfo(c),h}function nC(n,e,t,s=null){const r=s!=null?s.shape:e.shape,a=r[r.length-1],o=np(a),i=new YG(r,o,t,s==null),l=s==null?[e]:[e,s],u=n.runWebGLProgram(i,l,"int32");if(u.shape.length===e.shape.length){const c=nC(n,e,t,u);return n.disposeIntermediateTensorInfo(u),c}return u}function sC(n,e,t,s){const r=[t];if(St("arg"+s.charAt(0).toUpperCase()+s.slice(1),r,e.shape.length),!W().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const a=[],o=n.texData.get(e.dataId),i=o!==null&&o.isPacked;let l=e;i&&(l=n.unpackTensor(e),a.push(l));const[u,c]=Ct(l.shape,r),h=H(c),d=ne({inputs:{x:l},backend:n,attrs:{shape:[-1,h]}});a.push(d);const p=tC(n,d,s);a.push(p);const f=ne({inputs:{x:p},backend:n,attrs:{shape:u}});return a.forEach(g=>n.disposeIntermediateTensorInfo(g)),f}return nC(n,e,s)}/**
14287 * @license
14288 * Copyright 2020 Google LLC. All Rights Reserved.
14289 * Licensed under the Apache License, Version 2.0 (the "License");
14290 * you may not use this file except in compliance with the License.
14291 * You may obtain a copy of the License at
14292 *
14293 * http://www.apache.org/licenses/LICENSE-2.0
14294 *
14295 * Unless required by applicable law or agreed to in writing, software
14296 * distributed under the License is distributed on an "AS IS" BASIS,
14297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14298 * See the License for the specific language governing permissions and
14299 * limitations under the License.
14300 * =============================================================================
14301 */function JG(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a}=s;let o=Ie(a,r.shape);const i=Xe(o,r.shape.length);let l=r;const u=[];i!=null&&(l=_t({inputs:{x:r},backend:t,attrs:{perm:i}}),u.push(l),o=st(o.length,l.shape.length)),St("argMax",[o[0]],l.shape.length);const c=sC(t,l,o[0],"max");return u.forEach(h=>t.disposeIntermediateTensorInfo(h)),c}const ZG={kernelName:Ao,backendName:"webgl",kernelFunc:JG};/**
14302 * @license
14303 * Copyright 2020 Google LLC. All Rights Reserved.
14304 * Licensed under the Apache License, Version 2.0 (the "License");
14305 * you may not use this file except in compliance with the License.
14306 * You may obtain a copy of the License at
14307 *
14308 * http://www.apache.org/licenses/LICENSE-2.0
14309 *
14310 * Unless required by applicable law or agreed to in writing, software
14311 * distributed under the License is distributed on an "AS IS" BASIS,
14312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14313 * See the License for the specific language governing permissions and
14314 * limitations under the License.
14315 * =============================================================================
14316 */function QG(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a}=s;let o=Ie(a,r.shape);const i=Xe(o,r.shape.length);let l=r;const u=[];i!=null&&(l=_t({inputs:{x:r},backend:t,attrs:{perm:i}}),u.push(l),o=st(o.length,l.shape.length)),St("argMin",[o[0]],l.shape.length);const c=sC(t,l,o[0],"min");return u.forEach(h=>t.disposeIntermediateTensorInfo(h)),c}const eH={kernelName:Oo,backendName:"webgl",kernelFunc:QG};/**
14317 * @license
14318 * Copyright 2020 Google LLC. All Rights Reserved.
14319 * Licensed under the Apache License, Version 2.0 (the "License");
14320 * you may not use this file except in compliance with the License.
14321 * You may obtain a copy of the License at
14322 *
14323 * http://www.apache.org/licenses/LICENSE-2.0
14324 *
14325 * Unless required by applicable law or agreed to in writing, software
14326 * distributed under the License is distributed on an "AS IS" BASIS,
14327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14328 * See the License for the specific language governing permissions and
14329 * limitations under the License.
14330 * =============================================================================
14331 */const tH=Cn+`
14332  if (abs(x) > 1.) {
14333    return NAN;
14334  }
14335  return asin(x);
14336`,nH=Te({opSnippet:tH}),sH={kernelName:qr,backendName:"webgl",kernelFunc:nH};/**
14337 * @license
14338 * Copyright 2020 Google LLC. All Rights Reserved.
14339 * Licensed under the Apache License, Version 2.0 (the "License");
14340 * you may not use this file except in compliance with the License.
14341 * You may obtain a copy of the License at
14342 *
14343 * http://www.apache.org/licenses/LICENSE-2.0
14344 *
14345 * Unless required by applicable law or agreed to in writing, software
14346 * distributed under the License is distributed on an "AS IS" BASIS,
14347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14348 * See the License for the specific language governing permissions and
14349 * limitations under the License.
14350 * =============================================================================
14351 */const rH=Cn+"return log(x + sqrt(x * x + 1.0));",aH=Te({opSnippet:rH}),oH={kernelName:Kr,backendName:"webgl",kernelFunc:aH};/**
14352 * @license
14353 * Copyright 2020 Google LLC. All Rights Reserved.
14354 * Licensed under the Apache License, Version 2.0 (the "License");
14355 * you may not use this file except in compliance with the License.
14356 * You may obtain a copy of the License at
14357 *
14358 * http://www.apache.org/licenses/LICENSE-2.0
14359 *
14360 * Unless required by applicable law or agreed to in writing, software
14361 * distributed under the License is distributed on an "AS IS" BASIS,
14362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14363 * See the License for the specific language governing permissions and
14364 * limitations under the License.
14365 * =============================================================================
14366 */const iH=Cn+`
14367  return atan(x);
14368`,lH=Te({opSnippet:iH}),uH={kernelName:Xr,backendName:"webgl",kernelFunc:lH};/**
14369 * @license
14370 * Copyright 2020 Google LLC. All Rights Reserved.
14371 * Licensed under the Apache License, Version 2.0 (the "License");
14372 * you may not use this file except in compliance with the License.
14373 * You may obtain a copy of the License at
14374 *
14375 * http://www.apache.org/licenses/LICENSE-2.0
14376 *
14377 * Unless required by applicable law or agreed to in writing, software
14378 * distributed under the License is distributed on an "AS IS" BASIS,
14379 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14380 * See the License for the specific language governing permissions and
14381 * limitations under the License.
14382 * =============================================================================
14383 */const cH=gg+`
14384  return atan(a, b);
14385`,hH=`
14386  vec4 result = atan(a, b);
14387  bvec4 isNaNA = isnan(a);
14388  bvec4 isNaNB = isnan(b);
14389  bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
14390  `+$r+`
14391  return result;
14392`,dH=Nt({opSnippet:cH,packedOpSnippet:hH}),pH={kernelName:Yr,backendName:"webgl",kernelFunc:dH};/**
14393 * @license
14394 * Copyright 2020 Google LLC. All Rights Reserved.
14395 * Licensed under the Apache License, Version 2.0 (the "License");
14396 * you may not use this file except in compliance with the License.
14397 * You may obtain a copy of the License at
14398 *
14399 * http://www.apache.org/licenses/LICENSE-2.0
14400 *
14401 * Unless required by applicable law or agreed to in writing, software
14402 * distributed under the License is distributed on an "AS IS" BASIS,
14403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14404 * See the License for the specific language governing permissions and
14405 * limitations under the License.
14406 * =============================================================================
14407 */const fH=Cn+`
14408  if ((x < -1.0) || (x > 1.0)) return NAN;
14409return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,mH=Te({opSnippet:fH}),gH={kernelName:Jr,backendName:"webgl",kernelFunc:mH};/**
14410 * @license
14411 * Copyright 2017 Google LLC. All Rights Reserved.
14412 * Licensed under the Apache License, Version 2.0 (the "License");
14413 * you may not use this file except in compliance with the License.
14414 * You may obtain a copy of the License at
14415 *
14416 * http://www.apache.org/licenses/LICENSE-2.0
14417 *
14418 * Unless required by applicable law or agreed to in writing, software
14419 * distributed under the License is distributed on an "AS IS" BASIS,
14420 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14421 * See the License for the specific language governing permissions and
14422 * limitations under the License.
14423 * =============================================================================
14424 */class Eo{constructor(e,t,s,r=!1,a=!1){if(this.variableNames=["x"],t==="avg"&&s)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,i=e.strideHeight,l=e.strideWidth,u=e.dilationHeight,c=e.dilationWidth,h=e.effectiveFilterHeight,d=e.effectiveFilterWidth,p=e.padInfo.top,f=e.padInfo.left;this.outputShape=e.outShape;const g=t==="avg",m=`((batch  * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,y=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let x="0.0";if(g||(x="-1.0 / 1e-20"),s){const k=">=";this.userCode=`
14425        const ivec2 strides = ivec2(${i}, ${l});
14426        const ivec2 pads = ivec2(${p}, ${f});
14427
14428        void main() {
14429          ivec4 coords = getOutputCoords();
14430          int batch = coords[0];
14431          int d = coords[3];
14432
14433          ivec2 xRCCorner = coords.yz * strides - pads;
14434          int xRCorner = xRCCorner.x;
14435          int xCCorner = xRCCorner.y;
14436
14437          // max/min x(?, ?, d) to get y(yR, yC, d).
14438          // ? = to be determined
14439          float minMaxValue = 0.0;
14440          float minMaxValueFound = 0.0;
14441          int minMaxPosition = 0;
14442          float avgValue = 0.0;
14443
14444          for (int wR = 0; wR < ${h};
14445              wR += ${u}) {
14446            int xR = xRCorner + wR;
14447
14448            if (xR < 0 || xR >= ${e.inHeight}) {
14449              continue;
14450            }
14451
14452            for (int wC = 0; wC < ${d};
14453                wC += ${c}) {
14454              int xC = xCCorner + wC;
14455
14456              if (xC < 0 || xC >= ${e.inWidth}) {
14457                continue;
14458              }
14459
14460              float value = getX(batch, xR, xC, d);
14461
14462              // If a min / max value has already been found, use it. If not,
14463              // use the current value.
14464              float currMinMaxValue = mix(
14465                  value, minMaxValue, minMaxValueFound);
14466              if (value ${k} currMinMaxValue) {
14467                minMaxValue = value;
14468                minMaxValueFound = 1.0;
14469                minMaxPosition = ${r?a?m:y:`wR * ${d} + wC`};
14470              }
14471            }
14472          }
14473          setOutput(float(minMaxPosition));
14474        }
14475      `;return}const v="max";let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(b="avgValue / max(count, 1.0)");const C=Math.floor(o/4)*4,$=o%4,S=`
14476      if (${g}) {
14477        avgValue += dot(values, ones);
14478      } else {
14479        minMaxValue = ${v}(values, minMaxValue);
14480      }
14481    `;this.userCode=`
14482      const ivec2 strides = ivec2(${i}, ${l});
14483      const ivec2 pads = ivec2(${p}, ${f});
14484      const float initializationValue = ${x};
14485      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
14486
14487      float count = 0.0;
14488
14489      float getValue(int batch, int xR, int xC, int d) {
14490        if (xC < 0 || xC >= ${e.inWidth}) {
14491          return initializationValue;
14492        }
14493        count += 1.0;
14494        return getX(batch, xR, xC, d);
14495      }
14496
14497      void main() {
14498        ivec4 coords = getOutputCoords();
14499        int batch = coords[0];
14500        int d = coords[3];
14501
14502        ivec2 xRCCorner = coords.yz * strides - pads;
14503        int xRCorner = xRCCorner.x;
14504        int xCCorner = xRCCorner.y;
14505
14506        // max/min x(?, ?, d) to get y(yR, yC, d).
14507        // ? = to be determined
14508        vec4 minMaxValue = vec4(${x});
14509        float avgValue = 0.0;
14510        count = 0.0;
14511
14512        for (int wR = 0; wR < ${h};
14513            wR += ${u}) {
14514          int xR = xRCorner + wR;
14515
14516          if (xR < 0 || xR >= ${e.inHeight}) {
14517            continue;
14518          }
14519
14520          for (int wC = 0; wC < ${C}; wC += 4) {
14521            int xC = xCCorner + wC * ${c};
14522
14523            vec4 values = vec4(
14524              getValue(batch, xR, xC, d),
14525              getValue(batch, xR, xC + ${c}, d),
14526              getValue(batch, xR, xC + 2 * ${c}, d),
14527              getValue(batch, xR, xC + 3 * ${c}, d)
14528            );
14529
14530            ${S}
14531          }
14532
14533          int xC = xCCorner + ${C};
14534          if (${$===1}) {
14535            vec4 values = vec4(
14536              getValue(batch, xR, xC, d),
14537              initializationValue,
14538              initializationValue,
14539              initializationValue
14540            );
14541
14542            ${S}
14543          } else if (${$===2}) {
14544            vec4 values = vec4(
14545              getValue(batch, xR, xC, d),
14546              getValue(batch, xR, xC + ${c}, d),
14547              initializationValue,
14548              initializationValue
14549            );
14550
14551            ${S}
14552          } else if (${$===3}) {
14553            vec4 values = vec4(
14554              getValue(batch, xR, xC, d),
14555              getValue(batch, xR, xC + ${c}, d),
14556              getValue(batch, xR, xC + 2 * ${c}, d),
14557              initializationValue
14558            );
14559
14560            ${S}
14561          }
14562        }
14563        setOutput(${b});
14564      }
14565    `}}class xg{constructor(e,t,s,r=!1,a=!1){if(this.variableNames=["x"],t==="avg"&&s)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,i=e.strideDepth,l=e.strideHeight,u=e.strideWidth,c=e.dilationDepth,h=e.dilationHeight,d=e.dilationWidth,p=e.effectiveFilterDepth,f=e.effectiveFilterHeight,g=e.effectiveFilterWidth,m=e.padInfo.front,y=e.padInfo.top,x=e.padInfo.left;this.outputShape=e.outShape;const v=t==="avg";let b="0.0";if(v||(b="-1.0 / 1e-20"),s){const E=">=";this.userCode=`
14566        const ivec3 strides =
14567            ivec3(${i}, ${l}, ${u});
14568        const ivec3 pads = ivec3(${m}, ${y}, ${x});
14569
14570        void main() {
14571          ivec5 coords = getOutputCoords();
14572          int batch = coords.x;
14573          int ch = coords.u;
14574
14575          ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
14576          int xDCorner = xCorner.x;
14577          int xRCorner = xCorner.y;
14578          int xCCorner = xCorner.z;
14579
14580          // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).
14581          // ? = to be determined
14582          float minMaxValue = 0.0;
14583          float minMaxValueFound = 0.0;
14584          int minMaxPosition = 0;
14585
14586          for (int wD = 0; wD < ${p};
14587              wD += ${c}) {
14588            int xD = xDCorner + wD;
14589
14590            if (xD < 0 || xD >= ${e.inDepth}) {
14591              continue;
14592            }
14593
14594            for (int wR = 0; wR < ${f};
14595                wR += ${h}) {
14596              int xR = xRCorner + wR;
14597
14598              if (xR < 0 || xR >= ${e.inHeight}) {
14599                continue;
14600              }
14601
14602              for (int wC = 0; wC < ${g};
14603                  wC += ${d}) {
14604                int xC = xCCorner + wC;
14605
14606                if (xC < 0 || xC >= ${e.inWidth}) {
14607                  continue;
14608                }
14609
14610                float value = getX(batch, xD, xR, xC, ch);
14611
14612                // If a min / max value has already been found, use it. If not,
14613                // use the current value.
14614                float currMinMaxValue = mix(
14615                    value, minMaxValue, minMaxValueFound);
14616                if (value ${E} currMinMaxValue) {
14617                  minMaxValue = value;
14618                  minMaxValueFound = 1.0;
14619                  minMaxPosition = ${r?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${f} * ${g} +
14620                      wR * ${g} + wC`};
14621                }
14622              }
14623            }
14624          }
14625          setOutput(float(minMaxPosition));
14626        }
14627      `;return}const C="max";let $=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&($="avgValue / max(count, 1.0)");const S=Math.floor(o/4)*4,k=o%4,T=`
14628      if (${v}) {
14629        avgValue += dot(values, ones);
14630      } else {
14631        minMaxValue = ${C}(values, minMaxValue);
14632      }
14633    `;this.userCode=`
14634      const ivec3 strides =
14635        ivec3(${i}, ${l}, ${u});
14636      const ivec3 pads = ivec3(${m}, ${y}, ${x});
14637      const float initializationValue = ${b};
14638      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
14639
14640      float count = 0.0;
14641
14642      float getValue(int batch, int xD, int xR, int xC, int ch) {
14643        if (xC < 0 || xC >= ${e.inWidth}) {
14644          return initializationValue;
14645        }
14646        count += 1.0;
14647        return getX(batch, xD, xR, xC, ch);
14648      }
14649
14650      void main() {
14651        ivec5 coords = getOutputCoords();
14652        int batch = coords.x;
14653        int ch = coords.u;
14654
14655        ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
14656        int xDCorner = xCorner.x;
14657        int xRCorner = xCorner.y;
14658        int xCCorner = xCorner.z;
14659
14660        // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).
14661        // ? = to be determined
14662        vec4 minMaxValue = vec4(${b});
14663        float avgValue = 0.0;
14664        count = 0.0;
14665
14666        for (int wD = 0; wD < ${p};
14667            wD += ${c}) {
14668          int xD = xDCorner + wD;
14669
14670          if (xD < 0 || xD >= ${e.inDepth}) {
14671            continue;
14672          }
14673
14674          for (int wR = 0; wR < ${f};
14675            wR += ${h}) {
14676            int xR = xRCorner + wR;
14677
14678            if (xR < 0 || xR >= ${e.inHeight}) {
14679              continue;
14680            }
14681
14682            for (int wC = 0; wC < ${S}; wC += 4) {
14683              int xC = xCCorner + wC * ${d};
14684
14685              vec4 values = vec4(
14686                getValue(batch, xD, xR, xC, ch),
14687                getValue(batch, xD, xR, xC + ${d}, ch),
14688                getValue(batch, xD, xR, xC + 2 * ${d}, ch),
14689                getValue(batch, xD, xR, xC + 3 * ${d}, ch)
14690              );
14691
14692              ${T}
14693            }
14694
14695            int xC = xCCorner + ${S};
14696            if (${k===1}) {
14697              vec4 values = vec4(
14698                getValue(batch, xD, xR, xC, ch),
14699                initializationValue,
14700                initializationValue,
14701                initializationValue
14702              );
14703
14704              ${T}
14705            } else if (${k===2}) {
14706              vec4 values = vec4(
14707                getValue(batch, xD, xR, xC, ch),
14708                getValue(batch, xD, xR, xC + ${d}, ch),
14709                initializationValue,
14710                initializationValue
14711              );
14712
14713              ${T}
14714            } else if (${k===3}) {
14715              vec4 values = vec4(
14716                getValue(batch, xD, xR, xC, ch),
14717                getValue(batch, xD, xR, xC + ${d}, ch),
14718                getValue(batch, xD, xR, xC + 2 * ${d}, ch),
14719                initializationValue
14720              );
14721
14722              ${T}
14723            }
14724          }
14725        }
14726        setOutput(${$});
14727      }
14728    `}}/**
14729 * @license
14730 * Copyright 2020 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 yH(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e;qa(r,"avgPool");const{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;I(It(o,u),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);const c=_n(r.shape,a,o,u,i,l);
vendor: 4,301 bytes, lines 14743-14829
14743if(c.filterWidth===1&&c.filterHeight===1&&ke(c.inShape,c.outShape))return Qt({inputs:{x:r},backend:t});const h=new Eo(c,"avg",!1);return t.runWebGLProgram(h,[r],"float32")}const xH={kernelName:_o,backendName:"webgl",kernelFunc:yH};/**
14744 * @license
14745 * Copyright 2020 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 */function bH(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=s,c=[1,1,1],h=Fs(r.shape,a,o,c,i,l,u),d=new xg(h,"avg",!1);return t.runWebGLProgram(d,[r],"float32")}const wH={kernelName:Fo,backendName:"webgl",kernelFunc:bH};/**
14759 * @license
14760 * Copyright 2017 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 */class vH{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,r=e.strideHeight,a=e.strideWidth,o=e.dilationHeight,i=e.dilationWidth,l=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=l-1-e.padInfo.top,h=u-1-e.padInfo.left,d=1/(t*s);this.userCode=`
14774      const ivec2 pads = ivec2(${c}, ${h});
14775      const float avgMultiplier = float(${d});
14776
14777      void main() {
14778        ivec4 coords = getOutputCoords();
14779        int b = coords[0];
14780        int d = coords[3];
14781
14782        ivec2 dyRCCorner = coords.yz - pads;
14783        int dyRCorner = dyRCCorner.x;
14784        int dyCCorner = dyRCCorner.y;
14785
14786        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
14787        // ? = to be determined. : = across all values in that axis.
14788        float dotProd = 0.0;
14789        for (int wR = 0; wR < ${l};
14790            wR += ${o}) {
14791          float dyR = float(dyRCorner + wR) / ${r}.0;
14792
14793          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
14794            continue;
14795          }
14796          int idyR = int(dyR);
14797
14798          for (int wC = 0; wC < ${u};
14799            wC+= ${i}) {
14800            float dyC = float(dyCCorner + wC) / ${a}.0;
14801
14802            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
14803                fract(dyC) > 0.0) {
14804              continue;
14805            }
14806            int idyC = int(dyC);
14807
14808            float dyValue = getDy(b, idyR, idyC, d);
14809
14810            dotProd += dyValue * avgMultiplier;
14811          }
14812        }
14813        setOutput(dotProd);
14814      }
14815    `}}class CH{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,s=e.filterHeight,r=e.filterWidth,a=e.strideDepth,o=e.strideHeight,i=e.strideWidth,l=e.dilationDepth,u=e.dilationHeight,c=e.dilationWidth,h=e.effectiveFilterDepth,d=e.effectiveFilterHeight,p=e.effectiveFilterWidth,f=h-1-e.padInfo.front,g=d-1-e.padInfo.top,m=p-1-e.padInfo.left,y=1/(t*s*r);this.userCode=`
14816      const ivec3 pads = ivec3(${f}, ${g}, ${m});
14817      const float avgMultiplier = float(${y});
14818
14819      void main() {
14820        ivec5 coords = getOutputCoords();
14821        int batch = coords.x;
14822        int ch = coords.u;
14823
14824        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
14825        int dyDCorner = dyCorner.x;
14826        int dyRCorner = dyCorner.y;
14827        int dyCCorner = dyCorner.z;
14828
14829        // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
14830        // dx(xD, xR, xC, ch).
14831        // ? = to be determined. : = across all values in that axis.
14832        float dotProd = 0.0;
14833
14834        for (int wD = 0; wD < ${h};
14835            wD += ${l}) {
14836          float dyD = float(dyDCorner + wD) / ${a}.0;
14837
14838          if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
14839            continue;
14840          }
14841          int idyD = int(dyD);
14842
14843          for (int wR = 0; wR < ${d};
14844              wR += ${u}) {
14845            float dyR = float(dyRCorner + wR) / ${o}.0;
14846
14847            if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
14848                fract(dyR) > 0.0) {
14849              continue;
14850            }
14851            int idyR = int(dyR);
14852
14853            for (int wC = 0; wC < ${p};
14854                wC += ${c}) {
14855              float dyC = float(dyCCorner + wC) / ${i}.0;
14856
14857              if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
14858                  fract(dyC) > 0.0) {
14859                continue;
14860              }
14861              int idyC = int(dyC);
14862
14863              float dyValue = getDy(batch, idyD, idyR, idyC, ch);
14864
14865              dotProd += dyValue * avgMultiplier;
14866            }
14867          }
14868        }
14869        setOutput(dotProd);
14870      }
14871    `}}/**
14872 * @license
14873 * Copyright 2020 Google LLC. All Rights Reserved.
14874 * Licensed under the Apache License, Version 2.0 (the "License");
14875 * you may not use this file except in compliance with the License.
14876 * You may obtain a copy of the License at
14877 *
14878 * http://www.apache.org/licenses/LICENSE-2.0
14879 *
14880 * Unless required by applicable law or agreed to in writing, software
14881 * distributed under the License is distributed on an "AS IS" BASIS,
14882 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14883 * See the License for the specific language governing permissions and
14884 * limitations under the License.
14885 * =============================================================================
14886 */function $H(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a}=e,o=a,{filterSize:i,strides:l,pad:u,dimRoundingMode:c}=s,h=[1,1,1],d=Fs(o.shape,i,l,h,u,c),p=new CH(d);return t.runWebGLProgram(p,[r],o.dtype)}const NH={kernelName:fc,backendName:"webgl",kernelFunc:$H};/**
14887 * @license
14888 * Copyright 2020 Google LLC. All Rights Reserved.
14889 * Licensed under the Apache License, Version 2.0 (the "License");
14890 * you may not use this file except in compliance with the License.
14891 * You may obtain a copy of the License at
14892 *
14893 * http://www.apache.org/licenses/LICENSE-2.0
14894 *
14895 * Unless required by applicable law or agreed to in writing, software
14896 * distributed under the License is distributed on an "AS IS" BASIS,
14897 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14898 * See the License for the specific language governing permissions and
14899 * limitations under the License.
14900 * =============================================================================
14901 */function IH(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a}=e,o=a;qa([r,a],"avgPoolGrad");const{filterSize:i,strides:l,pad:u}=s,c=_n(o.shape,i,l,1,u),h=new vH(c);return t.runWebGLProgram(h,[r],o.dtype)}const SH={kernelName:mc,backendName:"webgl",kernelFunc:IH};/**
14902 * @license
14903 * Copyright 2020 Google LLC. All Rights Reserved.
14904 * Licensed under the Apache License, Version 2.0 (the "License");
14905 * you may not use this file except in compliance with the License.
14906 * You may obtain a copy of the License at
14907 *
14908 * http://www.apache.org/licenses/LICENSE-2.0
14909 *
14910 * Unless required by applicable law or agreed to in writing, software
14911 * distributed under the License is distributed on an "AS IS" BASIS,
14912 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14913 * See the License for the specific language governing permissions and
14914 * limitations under the License.
14915 * =============================================================================
14916 */function kH(n){const{inputs:e,backend:t,attrs:s}=n,{a:r,b:a}=e,{transposeA:o,transposeB:i}=s;return mu({a:r,b:a,transposeA:o,transposeB:i,backend:t})}const TH={kernelName:Po,backendName:"webgl",kernelFunc:kH};/**
14917 * @license
14918 * Copyright 2017 Google LLC. All Rights Reserved.
14919 * Licensed under the Apache License, Version 2.0 (the "License");
14920 * you may not use this file except in compliance with the License.
14921 * You may obtain a copy of the License at
14922 *
14923 * http://www.apache.org/licenses/LICENSE-2.0
14924 *
14925 * Unless required by applicable law or agreed to in writing, software
14926 * distributed under the License is distributed on an "AS IS" BASIS,
14927 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14928 * See the License for the specific language governing permissions and
14929 * limitations under the License.
14930 * =============================================================================
14931 */class EH{constructor(e,t,s,r,a,o){this.outputShape=[],this.variableNames=["x","mean","variance"],xe(e,t),xe(e,s);let i="0.0";r!=null&&(xe(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let l="1.0";a!=null&&(xe(e,a),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
14932      void main() {
14933        float x = getXAtOutCoords();
14934        float mean = getMeanAtOutCoords();
14935        float variance = getVarianceAtOutCoords();
14936        float offset = ${i};
14937        float scale = ${l};
14938        float inv = scale * inversesqrt(variance + float(${o}));
14939        setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));
14940      }
14941    `}}/**
14942 * @license
14943 * Copyright 2018 Google LLC. All Rights Reserved.
14944 * Licensed under the Apache License, Version 2.0 (the "License");
14945 * you may not use this file except in compliance with the License.
14946 * You may obtain a copy of the License at
14947 *
14948 * http://www.apache.org/licenses/LICENSE-2.0
14949 *
14950 * Unless required by applicable law or agreed to in writing, software
14951 * distributed under the License is distributed on an "AS IS" BASIS,
14952 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14953 * See the License for the specific language governing permissions and
14954 * limitations under the License.
14955 * =============================================================================
14956 */class RH{constructor(e,t,s,r,a,o){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],xe(e,t),xe(e,s);let i="vec4(0.0)";r!=null&&(xe(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let l="vec4(1.0)";a!=null&&(xe(e,a),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
14957      void main() {
14958        vec4 offset = ${i};
14959        vec4 scale = ${l};
14960
14961        vec4 x = getXAtOutCoords();
14962        vec4 mean = getMeanAtOutCoords();
14963        vec4 variance = getVarianceAtOutCoords();
14964
14965        vec4 inv = scale * inversesqrt(variance + vec4(${o}));
14966
14967        setOutput((x - mean) * inv + offset);
14968      }
14969    `}}/**
14970 * @license
14971 * Copyright 2020 Google LLC. All Rights Reserved.
14972 * Licensed under the Apache License, Version 2.0 (the "License");
14973 * you may not use this file except in compliance with the License.
14974 * You may obtain a copy of the License at
14975 *
14976 * http://www.apache.org/licenses/LICENSE-2.0
14977 *
14978 * Unless required by applicable law or agreed to in writing, software
14979 * distributed under the License is distributed on an "AS IS" BASIS,
14980 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14981 * See the License for the specific language governing permissions and
14982 * limitations under the License.
14983 * =============================================================================
14984 */const DH=({inputs:n,backend:e,attrs:t})=>{const{x:s,mean:r,variance:a,offset:o,scale:i}=n;I(r.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(o==null||r.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(i==null||r.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=t;l==null&&(l=.001);const u=[s,r,a];let c=null;o!=null&&(c=o.shape,u.push(o));let h=null;i!=null&&(h=i.shape,u.push(i));const d=W().getBool("WEBGL_PACK_NORMALIZATION")?new RH(s.shape,r.shape,a.shape,c,h,l):new EH(s.shape,r.shape,a.shape,c,h,l);return e.runWebGLProgram(d,u,u[0].dtype)},AH={kernelName:Vo,backendName:"webgl",kernelFunc:DH};/**
14985 * @license
14986 * Copyright 2017 Google LLC. All Rights Reserved.
14987 * Licensed under the Apache License, Version 2.0 (the "License");
14988 * you may not use this file except in compliance with the License.
14989 * You may obtain a copy of the License at
14990 *
14991 * http://www.apache.org/licenses/LICENSE-2.0
14992 *
14993 * Unless required by applicable law or agreed to in writing, software
14994 * distributed under the License is distributed on an "AS IS" BASIS,
14995 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14996 * See the License for the specific language governing permissions and
14997 * limitations under the License.
14998 * =============================================================================
14999 */class OH{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=Fe(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const s=_H(this.rank);let r;const a=e.map((o,i)=>`sourceLoc.${Ed[i]} = start[${i}] + coords.${Ed[i]};`);r=`
15000        ${t} sourceLoc;
15001        ${t} coords = getOutputCoords();
15002        ${a.join(`
15003`)}
15004      `,this.userCode=`
15005      void main() {
15006        ${r}
15007        setOutput(getSource(${s}));
15008      }
15009    `}}const Ed=["x","y","z","w","u","v"];function _H(n){if(n===1)return"sourceLoc";if(n<=6)return Ed.slice(0,n).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${n} is not yet supported`)}/**
15010 * @license
15011 * Copyright 2019 Google LLC. All Rights Reserved.
15012 * Licensed under the Apache License, Version 2.0 (the "License");
15013 * you may not use this file except in compliance with the License.
15014 * You may obtain a copy of the License at
15015 *
15016 * http://www.apache.org/licenses/LICENSE-2.0
15017 *
15018 * Unless required by applicable law or agreed to in writing, software
15019 * distributed under the License is distributed on an "AS IS" BASIS,
15020 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15021 * See the License for the specific language governing permissions and
15022 * limitations under the License.
15023 * =============================================================================
15024 */class FH{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=Fe(this.rank),s=Rt("coords",this.rank),r=Rt("sourceLoc",this.rank),a=this.rank===1?"sourceLoc":`vec2(${r.slice(-2).join()})`,o=`getChannel(getSource(${r.join()}), ${a})`,i=`
15025      result.x = ${o};
15026      if (++${s[this.rank-1]} < ${e[this.rank-1]}) {
15027        ++${r[this.rank-1]};
15028        result.y = ${o};
15029        --${r[this.rank-1]};
15030      }
15031    `,l=this.rank===1?"":`
15032      --${s[this.rank-1]};
15033      if (++${s[this.rank-2]} < ${e[this.rank-2]}) {
15034        ++${r[this.rank-2]};
15035        result.z = ${o};
15036        if (++${s[this.rank-1]} < ${e[this.rank-1]}) {
15037          ++${r[this.rank-1]};
15038          result.w = ${o};
15039        }
15040      }
15041    `,u=this.rank<=4?`sourceLoc = coords +
15042            ${t}(${e.map((c,h)=>`start[${h}]`).join()});`:e.map((c,h)=>`${r[h]} = ${s[h]} + start[${h}];`).join(`
15043`);this.userCode=`
15044      void main() {
15045        ${t} coords = getOutputCoords();
15046        ${t} sourceLoc;
15047        ${u}
15048        vec4 result = vec4(0.);
15049        ${i}
15050        ${l}
15051        setOutput(result);
15052      }
15053    `}}/**
15054 * @license
15055 * Copyright 2020 Google LLC. All Rights Reserved.
15056 * Licensed under the Apache License, Version 2.0 (the "License");
15057 * you may not use this file except in compliance with the License.
15058 * You may obtain a copy of the License at
15059 *
15060 * http://www.apache.org/licenses/LICENSE-2.0
15061 *
15062 * Unless required by applicable law or agreed to in writing, software
15063 * distributed under the License is distributed on an "AS IS" BASIS,
15064 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15065 * See the License for the specific language governing permissions and
15066 * limitations under the License.
15067 * =============================================================================
15068 */function LH(n,e,t,s){const r=s.texData.get(n.dataId),a=s.makeTensorInfo(t,n.dtype),o=s.texData.get(a.dataId);Object.assign(o,r),o.refCount=1,o.shape=t,o.dtype=n.dtype;let i=m$(e,fe(n.shape));
vendor: 6,463 bytes, lines 15068-15154
15068r.slice&&(i+=r.slice.flatOffset),o.slice={flatOffset:i,origDataId:r.slice&&r.slice.origDataId||n.dataId};const l=s.dataRefCount.get(o.slice.origDataId)||1;return s.dataRefCount.set(o.slice.origDataId,l+1),a}function eo(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{begin:a,size:o}=s,[i,l]=cx(r,a,o);if(p$(r,i,l),H(l)===0)return t.makeTensorInfo(l,r.dtype,[]);if(t.shouldExecuteOnCPU([r])||r.dtype==="string"){const h=t.texData.get(r.dataId),d=kU(h.values,i,l,r.shape,r.dtype);return t.makeTensorInfo(l,r.dtype,d)}const{isPacked:u}=t.texData.get(r.dataId),c=f$(r.shape,i,l);if(u||!c){const h=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new FH(l):new OH(l),d=[i];return t.runWebGLProgram(h,[r],r.dtype,d)}return t.uploadToGPU(r.dataId),LH(r,i,l,t)}const PH={kernelName:wu,backendName:"webgl",kernelFunc:eo};/**
15069 * @license
15070 * Copyright 2020 Google LLC. All Rights Reserved.
15071 * Licensed under the Apache License, Version 2.0 (the "License");
15072 * you may not use this file except in compliance with the License.
15073 * You may obtain a copy of the License at
15074 *
15075 * http://www.apache.org/licenses/LICENSE-2.0
15076 *
15077 * Unless required by applicable law or agreed to in writing, software
15078 * distributed under the License is distributed on an "AS IS" BASIS,
15079 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15080 * See the License for the specific language governing permissions and
15081 * limitations under the License.
15082 * =============================================================================
15083 */const zH=n=>{const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{blockShape:a,crops:o}=s;I(r.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const i=a.reduce((x,v)=>x*v),l=Fc(r.shape,a,i),u=Lc(l.length,a.length),c=Pc(r.shape,a,i),h=Nx(o,a.length),d=Ix(c,o,a.length),p=[],f=ne({inputs:{x:r},backend:t,attrs:{shape:l}}),g=_t({inputs:{x:f},backend:t,attrs:{perm:u}}),m=ne({inputs:{x:g},backend:t,attrs:{shape:c}}),y=eo({inputs:{x:m},backend:t,attrs:{begin:h,size:d}});return p.push(f),p.push(g),p.push(m),p.forEach(x=>t.disposeIntermediateTensorInfo(x)),y},VH={kernelName:zo,backendName:"webgl",kernelFunc:zH};/**
15084 * @license
15085 * Copyright 2020 Google LLC. All Rights Reserved.
15086 * Licensed under the Apache License, Version 2.0 (the "License");
15087 * you may not use this file except in compliance with the License.
15088 * You may obtain a copy of the License at
15089 *
15090 * http://www.apache.org/licenses/LICENSE-2.0
15091 *
15092 * Unless required by applicable law or agreed to in writing, software
15093 * distributed under the License is distributed on an "AS IS" BASIS,
15094 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15095 * See the License for the specific language governing permissions and
15096 * limitations under the License.
15097 * =============================================================================
15098 */function BH(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,weights:a}=e,{size:o}=s,i=t.readSync(r.dataId),l=t.readSync(a.dataId),u=Wv(i,l,a.dtype,a.shape,o);return t.makeTensorInfo([o],a.dtype,u)}const MH={kernelName:vu,backendName:"webgl",kernelFunc:BH};/**
15099 * @license
15100 * Copyright 2023 Google LLC.
15101 * Licensed under the Apache License, Version 2.0 (the "License");
15102 * you may not use this file except in compliance with the License.
15103 * You may obtain a copy of the License at
15104 *
15105 * http://www.apache.org/licenses/LICENSE-2.0
15106 *
15107 * Unless required by applicable law or agreed to in writing, software
15108 * distributed under the License is distributed on an "AS IS" BASIS,
15109 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15110 * See the License for the specific language governing permissions and
15111 * limitations under the License.
15112 * =============================================================================
15113 */const WH=`
15114  int r = int(a.r) & int(b.r);
15115  int g = int(a.g) & int(b.g);
15116  int rb = int(a.b) & int(b.b);
15117  int ra = int(a.a) & int(b.a);
15118  return vec4(r, g, rb, ra);
15119`,UH=`
15120  return float(int(a.r) & int(b.r));
15121`;function GH(n){const{inputs:e,backend:t}=n,{a:s,b:r}=e,a=W().getBool("WEBGL_PACK_BINARY_OPERATIONS"),o=W().getNumber("WEBGL_VERSION");if(t.shouldExecuteOnCPU([s,r])||o===1){const l=t.texData.get(s.dataId).values,u=t.texData.get(r.dataId).values,[c,h]=J4(s.shape,r.shape,l,u,s.dtype),d=t.makeTensorInfo(h,s.dtype),p=t.texData.get(d.dataId);return p.values=c,d}let i;return a?i=new Za(WH,s.shape,r.shape,!1):i=new dr(UH,s.shape,r.shape),t.runWebGLProgram(i,[s,r],s.dtype)}const HH={kernelName:Bo,backendName:"webgl",kernelFunc:GH};/**
15122 * @license
15123 * Copyright 2021 Google LLC. All Rights Reserved.
15124 * Licensed under the Apache License, Version 2.0 (the "License");
15125 * you may not use this file except in compliance with the License.
15126 * You may obtain a copy of the License at
15127 *
15128 * http://www.apache.org/licenses/LICENSE-2.0
15129 *
15130 * Unless required by applicable law or agreed to in writing, software
15131 * distributed under the License is distributed on an "AS IS" BASIS,
15132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15133 * See the License for the specific language governing permissions and
15134 * limitations under the License.
15135 * =============================================================================
15136 */function jH(n){const{inputs:e,backend:t}=n,{s0:s,s1:r}=e,a=t.readSync(s.dataId),o=t.readSync(r.dataId),i=xe(Array.from(a),Array.from(o));return t.makeTensorInfo([i.length],"int32",Int32Array.from(i))}const qH={kernelName:Cu,backendName:"webgl",kernelFunc:jH};/**
15137 * @license
15138 * Copyright 2020 Google LLC. All Rights Reserved.
15139 * Licensed under the Apache License, Version 2.0 (the "License");
15140 * you may not use this file except in compliance with the License.
15141 * You may obtain a copy of the License at
15142 *
15143 * http://www.apache.org/licenses/LICENSE-2.0
15144 *
15145 * Unless required by applicable law or agreed to in writing, software
15146 * distributed under the License is distributed on an "AS IS" BASIS,
15147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15148 * See the License for the specific language governing permissions and
15149 * limitations under the License.
15150 * =============================================================================
15151 */const KH="return float(a != b);",rC=Nt({opSnippet:KH,cpuKernelImpl:xU,dtype:"bool"}),XH={kernelName:hi,backendName:"webgl",kernelFunc:rC};/**
15152 * @license
15153 * Copyright 2020 Google LLC. All Rights Reserved.
15154 * Licensed under the Apache License, Version 2.0 (the "License");
15155 * you may not use this file except in compliance with the License.
15156 * You may obtain a copy of the License at
15157 *
15158 * http://www.apache.org/licenses/LICENSE-2.0
15159 *
15160 * Unless required by applicable law or agreed to in writing, software
15161 * distributed under the License is distributed on an "AS IS" BASIS,
15162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15163 * See the License for the specific language governing permissions and
15164 * limitations under the License.
15165 * =============================================================================
15166 */function wl(n){const{inputs:e,backend:t}=n,{input:s}=e,r=t.texData.get(s.dataId);return Qt({inputs:{x:r.complexTensorInfos.real},backend:t})}const YH={kernelName:zu,backendName:"webgl",kernelFunc:wl};/**
15167 * @license
15168 * Copyright 2020 Google LLC. All Rights Reserved.
15169 * Licensed under the Apache License, Version 2.0 (the "License");
15170 * you may not use this file except in compliance with the License.
15171 * You may obtain a copy of the License at
15172 *
15173 * http://www.apache.org/licenses/LICENSE-2.0
15174 *
15175 * Unless required by applicable law or agreed to in writing, software
15176 * distributed under the License is distributed on an "AS IS" BASIS,
15177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15178 * See the License for the specific language governing permissions and
15179 * limitations under the License.
15180 * =============================================================================
15181 */const JH="return float(int(x));";function ZH(n,e){const t=new Bn(n.shape,JH),s=e.runWebGLProgram(t,[n],"int32");return{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}/**
15182 * @license
15183 * Copyright 2020 Google LLC. All Rights Reserved.
15184 * Licensed under the Apache License, Version 2.0 (the "License");
15185 * you may not use this file except in compliance with the License.
15186 * You may obtain a copy of the License at
15187 *
15188 * http://www.apache.org/licenses/LICENSE-2.0
15189 *
15190 * Unless required by applicable law or agreed to in writing, software
15191 * distributed under the License is distributed on an "AS IS" BASIS,
15192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15193 * See the License for the specific language governing permissions and
15194 * limitations under the License.
15195 * =============================================================================
15196 */function Rd(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{dtype:a}=s;if(a==="complex64"){if(r.dtype==="complex64")return Qt({inputs:{x:r},backend:t});const o=et(r.shape),i=Rd({inputs:{x:r},backend:t,attrs:{dtype:"float32"}}),l=Bs({inputs:{real:i,imag:o},backend:t});return o.dispose(),t.disposeIntermediateTensorInfo(i),l}if(r.dtype==="complex64"){const o=wl({inputs:{input:r},backend:t}),i=Rd({inputs:{x:o},backend:t,attrs:{dtype:a}});return t.disposeIntermediateTensorInfo(o),i}if(!gx(r.dtype,a)){const o=Qt({inputs:{x:r},backend:t});return{dataId:o.dataId,shape:o.shape,dtype:a}}if(t.shouldExecuteOnCPU([r])){const o=t.texData.get(r.dataId).values,[i,l,u]=Z4(o,r.shape,r.dtype,a);return t.makeTensorInfo(i,l,u)}if(a==="int32")return ZH(r,t);if(a==="bool"){const o=t.makeTensorInfo([],"bool",wt("bool",1)),l=rC({inputs:{a:r,b:o},backend:t});return t.disposeIntermediateTensorInfo(o),l}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${a}`)}const QH={kernelName:gc,backendName:"webgl",kernelFunc:Rd};/**
15197 * @license
15198 * Copyright 2020 Google LLC. All Rights Reserved.
15199 * Licensed under the Apache License, Version 2.0 (the "License");
15200 * you may not use this file except in compliance with the License.
15201 * You may obtain a copy of the License at
15202 *
15203 * http://www.apache.org/licenses/LICENSE-2.0
15204 *
15205 * Unless required by applicable law or agreed to in writing, software
15206 * distributed under the License is distributed on an "AS IS" BASIS,
15207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15208 * See the License for the specific language governing permissions and
15209 * limitations under the License.
15210 * =============================================================================
15211 */const Fy="return ceil(x);",ej=Te({opSnippet:Fy,packedOpSnippet:Fy,cpuKernelImpl:Q4}),tj={kernelName:ea,backendName:"webgl",kernelFunc:ej};/**
15212 * @license
15213 * Copyright 2017 Google LLC. All Rights Reserved.
15214 * Licensed under the Apache License, Version 2.0 (the "License");
15215 * you may not use this file except in compliance with the License.
15216 * You may obtain a copy of the License at
15217 *
15218 * http://www.apache.org/licenses/LICENSE-2.0
15219 *
15220 * Unless required by applicable law or agreed to in writing, software
15221 * distributed under the License is distributed on an "AS IS" BASIS,
15222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15223 * See the License for the specific language governing permissions and
15224 * limitations under the License.
15225 * =============================================================================
15226 */class nj{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=`
15227
15228      void main() {
15229        float value = getAAtOutCoords();
15230        if (isnan(value)) {
15231          setOutput(value);
15232          return;
15233        }
15234
15235        setOutput(clamp(value, minVal, maxVal));
15236      }
15237    `}}/**
15238 * @license
15239 * Copyright 2018 Google LLC. All Rights Reserved.
15240 * Licensed under the Apache License, Version 2.0 (the "License");
15241 * you may not use this file except in compliance with the License.
15242 * You may obtain a copy of the License at
15243 *
15244 * http://www.apache.org/licenses/LICENSE-2.0
15245 *
15246 * Unless required by applicable law or agreed to in writing, software
15247 * distributed under the License is distributed on an "AS IS" BASIS,
15248 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15249 * See the License for the specific language governing permissions and
15250 * limitations under the License.
15251 * =============================================================================
15252 */class sj{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=`
15253      void main() {
15254        vec4 value = getAAtOutCoords();
15255
15256        if (any(isnan(value))) {
15257          setOutput(value);
15258          return;
15259        }
15260
15261        setOutput(clamp(value, vec4(minVal), vec4(maxVal)));
15262      }
15263    `}}/**
15264 * @license
15265 * Copyright 2020 Google LLC. All Rights Reserved.
15266 * Licensed under the Apache License, Version 2.0 (the "License");
15267 * you may not use this file except in compliance with the License.
15268 * You may obtain a copy of the License at
15269 *
15270 * http://www.apache.org/licenses/LICENSE-2.0
15271 *
15272 * Unless required by applicable law or agreed to in writing, software
15273 * distributed under the License is distributed on an "AS IS" BASIS,
15274 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15275 * See the License for the specific language governing permissions and
15276 * limitations under the License.
15277 * =============================================================================
15278 */function rj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{clipValueMin:a,clipValueMax:o}=s;let i;W().getBool("WEBGL_PACK_CLIP")?i=new sj(r.shape):i=new nj(r.shape);const l=[[a],[o]];return t.runWebGLProgram(i,[r],r.dtype,l)}const aj={kernelName:na,backendName:"webgl",kernelFunc:rj};/**
15279 * @license
15280 * Copyright 2018 Google LLC. All Rights Reserved.
15281 * Licensed under the Apache License, Version 2.0 (the "License");
15282 * you may not use this file except in compliance with the License.
15283 * You may obtain a copy of the License at
15284 *
15285 * http://www.apache.org/licenses/LICENSE-2.0
15286 *
15287 * Unless required by applicable law or agreed to in writing, software
15288 * distributed under the License is distributed on an "AS IS" BASIS,
15289 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15290 * See the License for the specific language governing permissions and
15291 * limitations under the License.
15292 * =============================================================================
15293 */class oj{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=`
15294      void main() {
15295        float re = abs(getRealAtOutCoords());
15296        float im = abs(getImagAtOutCoords());
15297        float mx = max(re, im);
15298
15299        // sadly the length function in glsl is not underflow-safe
15300        // (at least not on Intel GPUs). So the safe solution is
15301        // to ensure underflow-safety in all cases.
15302        setOutput(
15303          mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))
15304        );
15305      }
15306    `}}/**
15307 * @license
15308 * Copyright 2020 Google LLC. All Rights Reserved.
15309 * Licensed under the Apache License, Version 2.0 (the "License");
15310 * you may not use this file except in compliance with the License.
15311 * You may obtain a copy of the License at
15312 *
15313 * http://www.apache.org/licenses/LICENSE-2.0
15314 *
15315 * Unless required by applicable law or agreed to in writing, software
15316 * distributed under the License is distributed on an "AS IS" BASIS,
15317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15318 * See the License for the specific language governing permissions and
15319 * limitations under the License.
15320 * =============================================================================
15321 */function Ly(n,e){return{dataId:e.dataId,dtype:e.dtype,shape:n.shape}}function ij(n){const{inputs:e,backend:t}=n,{x:s}=e,r=t.texData.get(s.dataId),a=new oj(s.shape),o=[Ly(s,r.complexTensorInfos.real),Ly(s,r.complexTensorInfos.imag)];return t.runWebGLProgram(a,o,o[0].dtype)}const lj={kernelName:yc,backendName:"webgl",kernelFunc:ij};/**
15322 * @license
15323 * Copyright 2017 Google LLC. All Rights Reserved.
15324 * Licensed under the Apache License, Version 2.0 (the "License");
15325 * you may not use this file except in compliance with the License.
15326 * You may obtain a copy of the License at
15327 *
15328 * http://www.apache.org/licenses/LICENSE-2.0
15329 *
15330 * Unless required by applicable law or agreed to in writing, software
15331 * distributed under the License is distributed on an "AS IS" BASIS,
15332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15333 * See the License for the specific language governing permissions and
15334 * limitations under the License.
15335 * =============================================================================
15336 */class uj{constructor(e){this.outputShape=[],this.outputShape=ns(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 s=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let o=1;o<t.length;o++){const i=t[o-1];s.push(`else if (yC < ${t[o]}) setOutput(getT${o}(yR, yC-${i}));`)}const r=t.length,a=t[t.length-1];s.push(`else setOutput(getT${r}(yR, yC-${a}));`),this.userCode=`
15337      void main() {
15338        ivec2 coords = getOutputCoords();
15339        int yR = coords.x;
15340        int yC = coords.y;
15341
15342        ${s.join(`
15343        `)}
15344      }
15345    `}}/**
15346 * @license
15347 * Copyright 2019 Google LLC. All Rights Reserved.
15348 * Licensed under the Apache License, Version 2.0 (the "License");
15349 * you may not use this file except in compliance with the License.
15350 * You may obtain a copy of the License at
15351 *
15352 * http://www.apache.org/licenses/LICENSE-2.0
15353 *
15354 * Unless required by applicable law or agreed to in writing, software
15355 * distributed under the License is distributed on an "AS IS" BASIS,
15356 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15357 * See the License for the specific language governing permissions and
15358 * limitations under the License.
15359 * =============================================================================
15360 */class cj{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=ns(e,t);const s=this.outputShape,r=s.length,a=Fe(r),o=Rt("coords",r),i=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map((g,m)=>`T${m}`);const l=new Array(e.length-1);l[0]=e[0][t];for(let g=1;g<l.length;g++)l[g]=l[g-1]+e[g][t];const u=i[t],c=i.slice(-2),h=i.join();let d=`if (${u} < ${l[0]}) {
15361        return getChannel(
15362            getT0(${h}), vec2(${c.join()}));
15363        }`;for(let g=1;g<l.length;g++){const m=l[g-1];d+=`
15364        if (${u} < ${l[g]}  && ${u} >= ${l[g-1]}) {
15365          return getChannel(
15366            getT${g}(${Ll(i,u,m)}),
15367            vec2(${Ll(c,u,m)}));
15368        }`}const p=l.length,f=l[l.length-1];d+=`
15369        return getChannel(
15370          getT${p}(${Ll(i,u,f)}),
15371          vec2(${Ll(c,u,f)}));`,this.userCode=`
15372      float getValue(${i.map(g=>"int "+g)}) {
15373        ${d}
15374      }
15375
15376      void main() {
15377        ${a} coords = getOutputCoords();
15378        vec4 result = vec4(getValue(${o}), 0., 0., 0.);
15379
15380        ${o[r-1]} = ${o[r-1]} + 1;
15381        if (${o[r-1]} < ${s[r-1]}) {
15382          result.g = getValue(${o});
15383        }
15384
15385        ${o[r-2]} = ${o[r-2]} + 1;
15386        if (${o[r-2]} < ${s[r-2]}) {
15387          result.a = getValue(${o});
15388        }
15389
15390        ${o[r-1]} = ${o[r-1]} - 1;
15391        if (${o[r-2]} < ${s[r-2]} &&
15392            ${o[r-1]} < ${s[r-1]}) {
15393          result.b = getValue(${o});
15394        }
15395        setOutput(result);
15396      }
15397    `}}function Ll(n,e,t){const s=n.indexOf(e);return n.map((a,o)=>o===s?`${a} - ${t}`:a).join()}/**
15398 * @license
15399 * Copyright 2020 Google LLC. All Rights Reserved.
15400 * Licensed under the Apache License, Version 2.0 (the "License");
15401 * you may not use this file except in compliance with the License.
15402 * You may obtain a copy of the License at
15403 *
15404 * http://www.apache.org/licenses/LICENSE-2.0
15405 *
15406 * Unless required by applicable law or agreed to in writing, software
15407 * distributed under the License is distributed on an "AS IS" BASIS,
15408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15409 * See the License for the specific language governing permissions and
15410 * limitations under the License.
15411 * =============================================================================
15412 */function zh(n){const{inputs:e,backend:t}=n,{input:s}=e,r=t.texData.get(s.dataId);return Qt({inputs:{x:r.complexTensorInfos.imag},backend:t})}const hj={kernelName:Eu,backendName:"webgl",kernelFunc:zh};/**
15413 * @license
15414 * Copyright 2020 Google LLC. All Rights Reserved.
15415 * Licensed under the Apache License, Version 2.0 (the "License");
15416 * you may not use this file except in compliance with the License.
15417 * You may obtain a copy of the License at
15418 *
15419 * http://www.apache.org/licenses/LICENSE-2.0
15420 *
15421 * Unless required by applicable law or agreed to in writing, software
15422 * distributed under the License is distributed on an "AS IS" BASIS,
15423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15424 * See the License for the specific language governing permissions and
15425 * limitations under the License.
15426 * =============================================================================
15427 */function fo(n,e,t){const s=n[0].dtype;if(s==="complex64"){const p=n.map(x=>wl({inputs:{input:x},backend:t})),f=n.map(x=>zh({inputs:{input:x},backend:t})),g=fo(p,e,t),m=fo(f,e,t),y=Bs({inputs:{real:g,imag:m},backend:t});return p.forEach(x=>t.disposeIntermediateTensorInfo(x)),f.forEach(x=>t.disposeIntermediateTensorInfo(x)),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),y}let r=t.shouldExecuteOnCPU(n);if(s==="string"&&(r=!0),r){const p=n.map(b=>{const $=[-1,H(b.shape.slice(e))];return ne({inputs:{x:b},backend:t,attrs:{shape:$}})}),f=p.map(b=>({vals:t.readSync(b.dataId),shape:b.shape})),g=ns(p.map(b=>b.shape),1),m=p[0].shape[0]===1,y=eU(f,g,s,m),x=ns(n.map(b=>b.shape),e),v=t.makeTensorInfo(x,s,y);return p.forEach(b=>t.disposeIntermediateTensorInfo(b)),v}const a=n.filter(p=>H(p.shape)>0),o=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&a[0].shape.length>1;if(a.length===1){const p=o?new Bn(n[0].shape,ms):new xs(n[0].shape,ms);return t.runWebGLProgram(p,n,s)}const i=W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(a.length>i){const p=[];for(let g=0;g<a.length;g+=i){const m=a.slice(g,g+i);p.push(fo(m,e,t))}const f=fo(p,e,t);for(const g of p)t.disposeIntermediateTensorInfo(g);return f}if(o){const p=new cj(a.map(f=>f.shape),e);return t.runWebGLProgram(p,a,s)}const{tensors2D:l,outShape:u}=dj(a,e,t),c=new uj(l.map(p=>p.shape)),h=t.runWebGLProgram(c,l,s);l.forEach(p=>t.disposeIntermediateTensorInfo(p));const d=ne({inputs:{x:h},attrs:{shape:u},backend:t});return t.disposeIntermediateTensorInfo(h),d}function dj(n,e,t){const s=ns(n.map(a=>a.shape),e);return{tensors2D:n.map(a=>ne({inputs:{x:a},attrs:{shape:[-1,H(a.shape.slice(e))]},backend:t})),outShape:s}}/**
15428 * @license
15429 * Copyright 2020 Google LLC. All Rights Reserved.
15430 * Licensed under the Apache License, Version 2.0 (the "License");
15431 * you may not use this file except in compliance with the License.
15432 * You may obtain a copy of the License at
15433 *
15434 * http://www.apache.org/licenses/LICENSE-2.0
15435 *
15436 * Unless required by applicable law or agreed to in writing, software
15437 * distributed under the License is distributed on an "AS IS" BASIS,
15438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15439 * See the License for the specific language governing permissions and
15440 * limitations under the License.
15441 * =============================================================================
15442 */function aC(n){const{inputs:e,backend:t,attrs:s}=n,{axis:r}=s,a=Ie(r,e[0].shape)[0],o=e.map(u=>u.shape);Sx(o,a);const i=ns(e.map(u=>u.shape),a);if(H(i)===0)return t.makeTensorInfo(i,e[0].dtype,[]);const l=e.filter(u=>H(u.shape)>0);return l.length===1?Qt({inputs:{x:l[0]},backend:t}):fo(l,a,t)}const pj={kernelName:Lo,backendName:"webgl",kernelFunc:aC};/**
15443 * @license
15444 * Copyright 2017 Google LLC. All Rights Reserved.
15445 * Licensed under the Apache License, Version 2.0 (the "License");
15446 * you may not use this file except in compliance with the License.
15447 * You may obtain a copy of the License at
15448 *
15449 * http://www.apache.org/licenses/LICENSE-2.0
15450 *
15451 * Unless required by applicable law or agreed to in writing, software
15452 * distributed under the License is distributed on an "AS IS" BASIS,
15453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15454 * See the License for the specific language governing permissions and
15455 * limitations under the License.
15456 * =============================================================================
15457 */class oC{constructor(e,t=!1,s=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const o=e.padInfo.top,i=e.padInfo.left,l=e.strideHeight,u=e.strideWidth,c=e.dilationHeight,h=e.dilationWidth,d=e.filterHeight,p=e.filterWidth,f=Math.floor(e.inChannels/4)*4,g=e.inChannels%4,m=e.dataFormat==="channelsLast",y=m?1:2,x=m?2:3,v=m?3:1;let b="",C="";s&&(r?b=`float activation(float a) {
15458          float b = getPreluActivationWeightsAtOutCoords();
15459          ${s}
15460        }`:a?b=`float activation(float a) {
15461          float b = getLeakyreluAlphaAtOutCoords();
15462          ${s}
15463        }`:b=`
15464          float activation(float x) {
15465            ${s}
15466          }
15467        `,C="result = activation(result);");const $=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
15468      ${b}
15469
15470      const ivec2 strides = ivec2(${l}, ${u});
15471      const ivec2 pads = ivec2(${o}, ${i});
15472
15473      void main() {
15474        ivec4 coords = getOutputCoords();
15475        int batch = coords[0];
15476        int d2 = coords[${v}];
15477
15478        ivec2 xRCCorner =
15479            ivec2(coords[${y}], coords[${x}]) * strides - pads;
15480        int xRCorner = xRCCorner.x;
15481        int xCCorner = xRCCorner.y;
15482
15483        // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).
15484        // ? = to be determined. : = across all values in that axis.
15485        float dotProd = 0.0;
15486        for (int wR = 0; wR < ${d}; wR++) {
15487          int xR = xRCorner + wR * ${c};
15488
15489          if (xR < 0 || xR >= ${e.inHeight}) {
15490            continue;
15491          }
15492
15493          for (int wC = 0; wC < ${p}; wC++) {
15494            int xC = xCCorner + wC * ${h};
15495
15496            if (xC < 0 || xC >= ${e.inWidth}) {
15497              continue;
15498            }
15499
15500            for (int d1 = 0; d1 < ${f}; d1 += 4) {
15501              vec4 wValues = vec4(
15502                getW(wR, wC, d1, d2),
15503                getW(wR, wC, d1 + 1, d2),
15504                getW(wR, wC, d1 + 2, d2),
15505                getW(wR, wC, d1 + 3, d2)
15506              );
15507
15508              if (${m}) {
15509                vec4 xValues = vec4(
15510                  getX(batch, xR, xC, d1),
15511                  getX(batch, xR, xC, d1 + 1),
15512                  getX(batch, xR, xC, d1 + 2),
15513                  getX(batch, xR, xC, d1 + 3)
15514                );
15515                dotProd += dot(xValues, wValues);
15516              } else {
15517                vec4 xValues = vec4(
15518                  getX(batch, d1, xR, xC),
15519                  getX(batch, d1 + 1, xR, xC),
15520                  getX(batch, d1 + 2, xR, xC),
15521                  getX(batch, d1 + 3, xR, xC)
15522                );
15523                dotProd += dot(xValues, wValues);
15524              }
15525            }
15526
15527            if (${g===1}) {
15528
15529              if (${m}) {
15530                dotProd +=
15531                    getX(batch, xR, xC, ${f}) *
15532                    getW(wR, wC, ${f}, d2);
15533              } else {
15534                dotProd +=
15535                    getX(batch, ${f}, xR, xC) *
15536                    getW(wR, wC, ${f}, d2);
15537              }
15538
15539            } else if (${g===2}) {
15540              vec2 wValues = vec2(
15541                getW(wR, wC, ${f}, d2),
15542                getW(wR, wC, ${f} + 1, d2)
15543              );
15544
15545              if (${m}) {
15546                vec2 xValues = vec2(
15547                  getX(batch, xR, xC, ${f}),
15548                  getX(batch, xR, xC, ${f} + 1)
15549                );
15550                dotProd += dot(xValues, wValues);
15551              } else {
15552                vec2 xValues = vec2(
15553                  getX(batch, ${f}, xR, xC),
15554                  getX(batch, ${f} + 1, xR, xC)
15555                );
15556                dotProd += dot(xValues, wValues);
15557              }
15558
15559            } else if (${g===3}) {
15560              vec3 wValues = vec3(
15561                getW(wR, wC, ${f}, d2),
15562                getW(wR, wC, ${f} + 1, d2),
15563                getW(wR, wC, ${f} + 2, d2)
15564              );
15565
15566              if (${m}) {
15567                vec3 xValues = vec3(
15568                  getX(batch, xR, xC, ${f}),
15569                  getX(batch, xR, xC, ${f} + 1),
15570                  getX(batch, xR, xC, ${f} + 2)
15571                );
15572                dotProd += dot(xValues, wValues);
15573              } else {
15574                vec3 xValues = vec3(
15575                  getX(batch, ${f}, xR, xC),
15576                  getX(batch, ${f} + 1, xR, xC),
15577                  getX(batch, ${f} + 2, xR, xC)
15578                );
15579                dotProd += dot(xValues, wValues);
15580              }
15581
15582            }
15583          }
15584        }
15585
15586        float result = dotProd;
15587        ${$}
15588        ${C}
15589        setOutput(result);
15590      }
15591    `}}class fj{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,s=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,o=e.strideHeight,i=e.strideWidth,l=e.dilationDepth,u=e.dilationHeight,c=e.dilationWidth,h=e.filterDepth,d=e.filterHeight,p=e.filterWidth,f=Math.floor(e.inChannels/4)*4,g=e.inChannels%4;this.userCode=`
15592      const ivec3 strides = ivec3(${a}, ${o}, ${i});
15593      const ivec3 pads = ivec3(${t}, ${s}, ${r});
15594
15595      void main() {
15596        ivec5 coords = getOutputCoords();
15597        int batch = coords.x;
15598        int d2 = coords.u;
15599
15600        ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
15601        int xFCorner = xFRCCorner.x;
15602        int xRCorner = xFRCCorner.y;
15603        int xCCorner = xFRCCorner.z;
15604
15605        // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get
15606        // y(yF, yR, yC, d2). ? = to be determined. : = across all
15607        // values in that axis.
15608        float dotProd = 0.0;
15609        for (int wF = 0; wF < ${h}; wF++) {
15610          int xF = xFCorner + wF * ${l};
15611
15612          if (xF < 0 || xF >= ${e.inDepth}) {
15613            continue;
15614          }
15615
15616          for (int wR = 0; wR < ${d}; wR++) {
15617            int xR = xRCorner + wR * ${u};
15618
15619            if (xR < 0 || xR >= ${e.inHeight}) {
15620              continue;
15621            }
15622
15623            for (int wC = 0; wC < ${p}; wC++) {
15624              int xC = xCCorner + wC * ${c};
15625
15626              if (xC < 0 || xC >= ${e.inWidth}) {
15627                continue;
15628              }
15629
15630              for (int d1 = 0; d1 < ${f}; d1 += 4) {
15631                vec4 xValues = vec4(
15632                  getX(batch, xF, xR, xC, d1),
15633                  getX(batch, xF, xR, xC, d1 + 1),
15634                  getX(batch, xF, xR, xC, d1 + 2),
15635                  getX(batch, xF, xR, xC, d1 + 3)
15636                );
15637                vec4 wValues = vec4(
15638                  getW(wF, wR, wC, d1, d2),
15639                  getW(wF, wR, wC, d1 + 1, d2),
15640                  getW(wF, wR, wC, d1 + 2, d2),
15641                  getW(wF, wR, wC, d1 + 3, d2)
15642                );
15643
15644                dotProd += dot(xValues, wValues);
15645              }
15646
15647              if (${g===1}) {
15648                dotProd +=
15649                  getX(batch, xF, xR, xC, ${f}) *
15650                  getW(wF, wR, wC, ${f}, d2);
15651              } else if (${g===2}) {
15652                vec2 xValues = vec2(
15653                  getX(batch, xF, xR, xC, ${f}),
15654                  getX(batch, xF, xR, xC, ${f} + 1)
15655                );
15656                vec2 wValues = vec2(
15657                  getW(wF, wR, wC, ${f}, d2),
15658                  getW(wF, wR, wC, ${f} + 1, d2)
15659                );
15660                dotProd += dot(xValues, wValues);
15661              } else if (${g===3}) {
15662                vec3 xValues = vec3(
15663                  getX(batch, xF, xR, xC, ${f}),
15664                  getX(batch, xF, xR, xC, ${f} + 1),
15665                  getX(batch, xF, xR, xC, ${f} + 2)
15666                );
15667                vec3 wValues = vec3(
15668                  getW(wF, wR, wC, ${f}, d2),
15669                  getW(wF, wR, wC, ${f} + 1, d2),
15670                  getW(wF, wR, wC, ${f} + 2, d2)
15671                );
15672                dotProd += dot(xValues, wValues);
15673              }
15674            }
15675          }
15676        }
15677        setOutput(dotProd);
15678      }
15679    `}}/**
15680 * @license
15681 * Copyright 2022 Google LLC. All Rights Reserved.
15682 * Licensed under the Apache License, Version 2.0 (the "License");
15683 * you may not use this file except in compliance with the License.
15684 * You may obtain a copy of the License at
15685 *
15686 * http://www.apache.org/licenses/LICENSE-2.0
15687 *
15688 * Unless required by applicable law or agreed to in writing, software
15689 * distributed under the License is distributed on an "AS IS" BASIS,
15690 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15691 * See the License for the specific language governing permissions and
15692 * limitations under the License.
15693 * =============================================================================
15694 */class iC{constructor(e,t=!1,s=null,r=!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=Tt(this.outputShape.length);const o=e.padInfo.left,i=e.strideWidth,l=e.dilationWidth,u=e.filterHeight,c=e.filterWidth,h=c;let d=`
15695       int xR; int xC; int xCOffset;
15696       vec4 wTexel; vec4 previous; vec4 final;`;for(let m=0;m<c;m++)d+=`
15697           vec4 xTexelC${m*2};
15698           int xTexelC${m*2}Ready;
15699           vec4 xTexelC${m*2+1};
15700           int xTexelC${m*2+1}Ready;
15701           vec4 xC${m};`;d+=`
15702     for (int r = 0; r < ${u}; r++) {
15703      for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) {
15704       `;for(let m=0;m<c;m++)d+=`
15705           xTexelC${m*2} = vec4(0.0);
15706           xTexelC${m*2}Ready = 0;
15707           xTexelC${m*2+1} = vec4(0.0);
15708           xTexelC${m*2+1}Ready = 0;
15709           xC${m} = vec4(0.0);`;d+=`
15710         xR = xRCorner + r * dilations[0];
15711         if (xR >=0 && xR < inDims[0]) {
15712       `;for(let m=0;m<(h+1)/2;m++){const y=m*2;if(d+=`
15713           xC = xCCorner + ${y*l};
15714           `,i===1){if(y<c&&(o%2===1?(d+=`
15715                 xCOffset = xC + 1;
15716                 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
15717                   xTexelC${y} = getX(batch, xR, xCOffset, d1);
15718
15719                   // Need to manually clear unused channels in case
15720                   // we're reading from recycled texture.
15721                   if (xCOffset + 1 >= inDims[1]) {
15722                     xTexelC${y}.zw = vec2(0.0);
15723                   }
15724                   xTexelC${y}Ready = 1;
15725                 }
15726               `,l===1&&y>0?d+=`
15727                 xC${y} = vec4(xTexelC${y-2}.zw, xTexelC${y}.xy);
15728                 `:d+=`
15729                   xCOffset = xC + 1 - 2;
15730
15731                   if (xCOffset >= 0 && xCOffset < inDims[1]) {
15732                     previous = getX(batch, xR, xCOffset, d1);
15733
15734                     // Need to manually clear unused channels in case
15735                     // we're reading from recycled texture.
15736                     if (xCOffset + 1 >= inDims[1]) {
15737                       previous.zw = vec2(0.0);
15738                     }
15739
15740                     xC${y} = vec4(previous.zw, xTexelC${y}.xy);
15741                   } else {
15742                     xC${y} = vec4(0.0, 0.0, xTexelC${y}.xy);
15743                   }
15744                   `):d+=`
15745                 if (xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
15746                   xTexelC${y} = getX(batch, xR, xC, d1);
15747                   if (xC + 1 >= inDims[1]) {
15748                     xTexelC${y}.zw = vec2(0.0);
15749                   }
15750                   xTexelC${y}Ready = 1;
15751                 }
15752
15753                 xC${y} = xTexelC${y};
15754                 `,y+1<c)){const x=o%2===0?tp(l):l;l%2===0&&o%2===1||l%2!==0&&o%2!==1?(d+=`
15755                   xCOffset = xC + imod(pads[1], 2) + ${x};
15756
15757                   if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
15758                     xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
15759
15760                     // Need to manually clear unused channels in case
15761                     // we're reading from recycled texture.
15762                     if (xCOffset + 1 >= inDims[1]) {
15763                       xTexelC${y+1}.zw = vec2(0.0);
15764                     }
15765                     xTexelC${y+1}Ready = 1;
15766                   }
15767                   `,l>1?d+=`
15768                     xCOffset -= 2;
15769                     if (xCOffset >= 0 && xCOffset < inDims[1]) {
15770                      previous = getX(batch, xR, xCOffset, d1);
15771                      xC${y+1} = vec4(previous.zw, xTexelC${y+1}.xy);
15772                     } else {
15773                      xC${y+1} = vec4(0.0, 0.0, xTexelC${y+1}.xy);
15774                     }
15775                     `:d+=`
15776                     xC${y+1} = vec4(xTexelC${y}.zw, xTexelC${y+1}.xy);
15777                     `):x===1?d+=`
15778                     xC${y+1} = xTexelC${y};
15779                     `:d+=`
15780                     xCOffset = xC + ${x};
15781
15782                     if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}
15782Ready == 0) {
15783                       xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
15784                       if (xCOffset + 1 >= inDims[1]) {
15785                         xTexelC${y+1}.zw = vec2(0.0);
15786                       }
15787                       xTexelC${y+1}Ready = 1;
15788                     }
15789
15790                     xC${y+1} = xTexelC${y+1};
15791                     `}}else y<c&&(o%2===1?(d+=`
15792                 xCOffset = xC + 1 - strides[1];
15793                 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
15794                   xTexelC${y} = getX(batch, xR, xCOffset, d1);
15795                   // Need to manually clear unused channels in case
15796                   // we're reading from recycled texture.
15797                   if (xCOffset + 1 >= inDims[1]) {
15798                     xTexelC${y}.zw = vec2(0.0);
15799                   }
15800                   xTexelC${y}Ready = 1;
15801                 }
15802
15803                 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${y+1}Ready == 0) {
15804                   xTexelC${y+1} = getX(batch, xR, xC + 1, d1);
15805                   // Need to manually clear unused channels in case
15806                   // we're reading from recycled texture.
15807                   if (xC + 2 >= inDims[1]) {
15808                     xTexelC${y+1}.zw = vec2(0.0);
15809                   }
15810                   xTexelC${y+1}Ready = 1;
15811                 }
15812
15813                 xC${y} = vec4(xTexelC${y}.zw, xTexelC${y+1}.zw);
15814               `,y+1<c&&(d+=`
15815                   final = vec4(0.0);
15816                   xCOffset = xC + 1 + strides[1];
15817                   if(xCOffset >= 0 && xCOffset < inDims[1]) {
15818                     final = getX(batch, xR, xCOffset, d1);
15819                   }
15820                   xC${y+1} = vec4(xTexelC${y+1}.xy, final.xy);
15821                 `)):(d+=`
15822                 if(xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
15823                   xTexelC${y} = getX(batch, xR, xC, d1);
15824                   if (xC + 1 >= inDims[1]) {
15825                     xTexelC${y}.zw = vec2(0.0);
15826                   }
15827                   xTexelC${y}Ready = 1;
15828                 }
15829
15830                 xCOffset = xC + strides[1];
15831                 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
15832                   xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
15833                   if (xCOffset + 1 >= inDims[1]) {
15834                     xTexelC${y+1}.zw = vec2(0.);
15835                   }
15836                   xTexelC${y+1}Ready = 1;
15837                 }
15838
15839                 xC${y} = vec4(
15840                   xTexelC${y}.xy, xTexelC${y+1}.xy);
15841               `,y+1<c&&(d+=`
15842                   xC${y+1} = vec4(xTexelC${y}.zw, xTexelC${y+1}.zw);
15843                 `)));
vendor: 4,659 bytes, lines 15843-15955
15843y<c&&(d+=`
15844             wTexel = getW(r, ${y}, d1, d2);
15845             dotProd += xC${y}.xxzz * vec4(wTexel.xy, wTexel.xy);
15846             if(d1 + 1 < ${e.inChannels}) {
15847               dotProd += xC${y}.yyww * vec4(wTexel.zw, wTexel.zw);
15848             }
15849           `,y+1<c&&(d+=`
15850               wTexel = getW(r, ${y+1}, d1, d2);
15851               dotProd += xC${y+1}.xxzz * vec4(wTexel.xy, wTexel.xy);
15852               if(d1 + 1 < ${e.inChannels}) {
15853                 dotProd += xC${y+1}.yyww * vec4(wTexel.zw, wTexel.zw);
15854               }
15855             `))}d+=`
15856     }
15857   `,d+=`
15858     }
15859   `,d+=`
15860     }
15861   `;let p="",f="";s&&(r?p=`vec4 activation(vec4 a) {
15862           vec4 b = getPreluActivationWeightsAtOutCoords();
15863           ${s}
15864         }`:a?p=`vec4 activation(vec4 a) {
15865           vec4 b = getLeakyreluAlphaAtOutCoords();
15866           ${s}
15867         }`:p=`vec4 activation(vec4 x) {
15868           ${s}
15869         }`,f="result = activation(result);");const g=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
15870       ${p}
15871
15872       void main() {
15873         ivec4 coords = getOutputCoords();
15874         int batch = coords.x;
15875         ivec2 xRCCorner = coords.yz * strides - pads;
15876         int d2 = coords.w;
15877         int xRCorner = xRCCorner.x;
15878         int xCCorner = xRCCorner.y;
15879
15880         //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
15881         vec4 dotProd = vec4(0.000000000000001);
15882
15883         ${d}
15884
15885         vec4 result = dotProd - vec4(0.000000000000001);
15886         ${g}
15887         ${f}
15888         setOutput(result);
15889       }
15890     `}}/**
15891 * @license
15892 * Copyright 2019 Google LLC. All Rights Reserved.
15893 * Licensed under the Apache License, Version 2.0 (the "License");
15894 * you may not use this file except in compliance with the License.
15895 * You may obtain a copy of the License at
15896 *
15897 * http://www.apache.org/licenses/LICENSE-2.0
15898 *
15899 * Unless required by applicable law or agreed to in writing, software
15900 * distributed under the License is distributed on an "AS IS" BASIS,
15901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15902 * See the License for the specific language governing permissions and
15903 * limitations under the License.
15904 * =============================================================================
15905 */class mj{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=Tt(this.outputShape.length);const{dataFormat:s}=t,r=Pt(),a=s==="channelsLast",o=a?1:2,i=a?2:3,l=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let u="";for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)u+=`
15906          blockIndex = rc.z + ${h};
15907          pos = rc.y + ${c};
15908
15909          ${l}
15910            offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];
15911            d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);
15912
15913            if(d0 < inputShape[${o}] && d0 >= 0) {
15914              // Use custom imod instead mod. On Intel GPU, mod may generate
15915              // unexpected value.
15916              // https://github.com/tensorflow/tfjs/issues/5447
15917              offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];
15918              d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /
15919                  inChannels);
15920
15921              if(d1 < inputShape[${i}] && d1 >= 0) {
15922
15923                ch = imod(pos, inChannels);
15924
15925                if (${a}) {
15926                  innerDims = vec2(d1, ch);
15927                  result[${c*2+h}] = getChannel(
15928                    getA(rc.x, d0, int(innerDims.x),
15929                    int(innerDims.y)), innerDims);
15930                } else {
15931                  innerDims = vec2(d0, d1);
15932                  result[${c*2+h}] = getChannel(
15933                    getA(rc.x, ch, int(innerDims.x),
15934                    int(innerDims.y)), innerDims);
15935                }
15936              }
15937            }
15938          }
15939        `;this.userCode=`
15940      void main() {
15941        ivec3 rc = getOutputCoords();
15942
15943        vec4 result = vec4(0);
15944
15945        int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
15946        vec2 innerDims;
15947
15948        ${u}
15949
15950        ${r.output} = result;
15951      }
15952    `}}/**
15953 * @license
15954 * Copyright 2020 Google LLC. All Rights Reserved.
15955 * Licensed under the Apache License, Version 2.0 (the "License");
15956 * you may not use this file except in compliance with the License.
15957 * You may obtain a copy of the License at
15958 *
15959 * http://www.apache.org/licenses/LICENSE-2.0
15960 *
15961 * Unless required by applicable law or agreed to in writing, software
15962 * distributed under the License is distributed on an "AS IS" BASIS,
15963 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15964 * See the License for the specific language governing permissions and
15965 * limitations under the License.
15966 * =============================================================================
15967 */function gu(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 lC({x:n,filter:e,convInfo:t,backend:s,bias:r=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){const l=n.shape,u=s.texData.get(n.dataId),c=t.inChannels,h=l[0]*l[1]*l[2],d=t.outChannels,p=t.dataFormat==="channelsLast",f=!1,g=!1;let m;const y=[];if(a!=null){const b=gu(a.shape,p);b!=null&&(a=ne({inputs:{x:a},backend:s,attrs:{shape:b}}),y.push(a))}if(r!=null){const b=gu(r.shape,p);b!=null&&(r=ne({inputs:{x:r},backend:s,attrs:{shape:b}}),y.push(r))}if(!((h===1||d===1)&&c>eC)&&u.isPacked&&p&&u.texture!=null&&l[2]%2!==0&&ke(u.shape.slice(-3),l.slice(-3))){const b=l[0]*l[1]*(l[2]+1),C={dataId:n.dataId,shape:[1,b,t.inChannels],dtype:n.dtype},$=u.shape;u.shape=u.shape.slice(),u.shape[u.shape.length-2]++,I(ko(u.shape,C.shape),()=>`packed reshape ${u.shape} to ${C.shape} isn't free`);const S=ne({inputs:{x:e},backend:s,attrs:{shape:[1,t.inChannels,t.outChannels]}});y.push(S);const k=mu({a:C,b:S,backend:s,transposeA:f,transposeB:g,bias:r,activation:i,preluActivationWeights:a,leakyreluAlpha:o}),T=s.texData.get(k.dataId);I(T.isPacked,()=>"batchMatMul result is expected to be packed"),u.shape=$,T.shape=t.outShape,m=Qt({inputs:{x:k},backend:s}),m.shape=t.outShape,y.push(k)}else{const b=t.outHeight*t.outWidth,C=ne({inputs:{x:n},backend:s,attrs:{shape:p?[t.batchSize,b,t.inChannels]:[t.batchSize,t.inChannels,b]}}),$=ne({inputs:{x:e},backend:s,attrs:{shape:[1,t.inChannels,t.outChannels]}}),S=mu({a:p?C:$,b:p?$:C,transposeA:!p,transposeB:g,backend:s,bias:r,activation:i,preluActivationWeights:a,leakyreluAlpha:o});m=ne({inputs:{x:S},backend:s,attrs:{shape:t.outShape}}),y.push(C),y.push($),y.push(S)}for(const b of y)s.disposeIntermediateTensorInfo(b);return m}function uC({x:n,filter:e,convInfo:t,backend:s,bias:r=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){const{filterWidth:l,filterHeight:u,inChannels:c,outWidth:h,outHeight:d,dataFormat:p}=t,f=p==="channelsLast",g=l*u*c,m=d*h,y=[t.batchSize,g,m],x=!0,v=!1,b=[];if(a!=null){const U=gu(a.shape,f);U!=null&&(a=ne({inputs:{x:a},backend:s,attrs:{shape:U}}),b.push(a))}if(r!=null){const U=gu(r.shape,f);U!=null&&(r=ne({inputs:{x:r},backend:s,attrs:{shape:U}}),b.push(r))}const C=ne({inputs:{x:e},backend:s,attrs:{shape:[1,g,H(e.shape)/g]}});b.push(C);const $=new mj(y,t),S=[n.shape,[t.padInfo.top,t.padInfo.left],[t.strideHeight,t.strideWidth],[t.dilationHeight,t.dilationWidth],[t.inChannels],[t.filterWidth*t.inChannels],[t.outWidth]],k=s.runWebGLProgram($,[n],"float32",S),T=ne({inputs:{x:k},backend:s,attrs:{shape:y}});b.push(k),b.push(T);const E=r!=null,_=a!=null,z=i==="leakyrelu",P=i?To(i,!0):null,V=new Qv(f?T.shape:C.shape,f?C.shape:T.shape,f?[t.batchSize,m,t.outChannels]:[t.batchSize,t.outChannels,m],x,v,E,P,_,z),B=f?[T,C]:[C,T];if(r&&B.push(r),_&&B.push(a),z){const U=s.makeTensorInfo([],"float32",_s(o,"float32"));B.push(U),b.push(U)}const M=s.runWebGLProgram(V,B,"float32"),j=ne({inputs:{x:M},backend:s,attrs:{shape:t.outShape}});b.push(M);for(const U of b)s.disposeIntermediateTensorInfo(U);return j}/**
15968 * @license
15969 * Copyright 2020 Google LLC. All Rights Reserved.
15970 * Licensed under the Apache License, Version 2.0 (the "License");
15971 * you may not use this file except in compliance with the License.
15972 * You may obtain a copy of the License at
15973 *
15974 * http://www.apache.org/licenses/LICENSE-2.0
15975 *
15976 * Unless required by applicable law or agreed to in writing, softw
15976are
15977 * distributed under the License is distributed on an "AS IS" BASIS,
15978 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15979 * See the License for the specific language governing permissions and
15980 * limitations under the License.
15981 * =============================================================================
15982 */function gj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a}=e,{strides:o,pad:i,dataFormat:l,dilations:u,dimRoundingMode:c}=s,h=fr(l),d=Ft(r.shape,a.shape,o,u,i,c,!1,h);let p;if(d.filterHeight===1&&d.filterWidth===1&&d.dilationHeight===1&&d.dilationWidth===1&&d.strideHeight===1&&d.strideWidth===1&&(d.padInfo.type==="SAME"||d.padInfo.type==="VALID"))p=lC({x:r,filter:a,convInfo:d,backend:t});else if(d.strideWidth<=2&&h==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const g=new iC(d),m=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];p=t.runWebGLProgram(g,[r,a],"float32",m)}else if(W().getBool("WEBGL_CONV_IM2COL"))p=uC({x:r,filter:a,convInfo:d,backend:t});else{const g=new oC(d);p=t.runWebGLProgram(g,[r,a],"float32")}const f=ne({inputs:{x:p},backend:t,attrs:{shape:d.outShape}});return t.disposeIntermediateTensorInfo(p),f}const yj={kernelName:Mo,backendName:"webgl",kernelFunc:gj};/**
15983 * @license
15984 * Copyright 2017 Google LLC. All Rights Reserved.
15985 * Licensed under the Apache License, Version 2.0 (the "License");
15986 * you may not use this file except in compliance with the License.
15987 * You may obtain a copy of the License at
15988 *
15989 * http://www.apache.org/licenses/LICENSE-2.0
15990 *
15991 * Unless required by applicable law or agreed to in writing, software
15992 * distributed under the License is distributed on an "AS IS" BASIS,
15993 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15994 * See the License for the specific language governing permissions and
15995 * limitations under the License.
15996 * =============================================================================
15997 */class xj{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,s=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,o=e.dataFormat==="channelsLast";this.userCode=`
15998      void main() {
15999        ivec4 coords = getOutputCoords();
16000        int wR = coords.x;
16001        int wC = coords.y;
16002        int d1 = coords.z;
16003        int d2 = coords.w;
16004
16005        // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).
16006        // ? = to be determined. : = across all values in that axis.
16007        float dotProd = 0.0;
16008
16009        for (int b = 0; b < ${e.batchSize}; b++) {
16010          for (int yR = 0; yR < ${e.outHeight}; yR++) {
16011            int xR = wR + yR * ${t} - ${r};
16012
16013            if (xR < 0 || xR >= ${e.inHeight}) {
16014              continue;
16015            }
16016
16017            for (int yC = 0; yC < ${e.outWidth}; yC++) {
16018              int xC = wC + yC * ${s} - ${a};
16019
16020              if (xC < 0 || xC >= ${e.inWidth}) {
16021                continue;
16022              }
16023
16024              ${o?`float dyValue = getDy(b, yR, yC, d2);
16025              float xValue = getX(b, xR, xC, d1);
16026              dotProd += (xValue * dyValue);`:`float dyValue = getDy(b, d2, yR, yC);
16027              float xValue = getX(b, d1, xR, xC);
16028              dotProd += (xValue * dyValue);`}
16029            }
16030          }
16031        }
16032        setOutput(dotProd);
16033      }
16034    `}}class bj{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,r=e.strideHeight,a=e.strideWidth,o=e.dataFormat==="channelsLast",i=t-1-e.padInfo.top,l=s-1-e.padInfo.left,u=o?1:2,c=o?2:3,h=o?3:1;this.userCode=`
16035      const ivec2 pads = ivec2(${i}, ${l});
16036
16037      void main() {
16038        ivec4 coords = getOutputCoords();
16039        int batch = coords[0];
16040        int d1 = coords[${h}];
16041
16042        ivec2 dyCorner = ivec2(coords[${u}], coords[${c}]) - pads;
16043        int dyRCorner = dyCorner.x;
16044        int dyCCorner = dyCorner.y;
16045
16046        // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
16047        // ? = to be determined. : = across all values in that axis.
16048        float dotProd = 0.0;
16049        for (int wR = 0; wR < ${t}; wR++) {
16050          float dyR = float(dyRCorner + wR) / ${r}.0;
16051
16052          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
16053            continue;
16054          }
16055          int idyR = int(dyR);
16056
16057          int wRPerm = ${t} - 1 - wR;
16058
16059          for (int wC = 0; wC < ${s}; wC++) {
16060            float dyC = float(dyCCorner + wC) / ${a}.0;
16061
16062            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
16063                fract(dyC) > 0.0) {
16064              continue;
16065            }
16066            int idyC = int(dyC);
16067
16068            int wCPerm = ${s} - 1 - wC;
16069
16070            for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
16071
16072              if (${o}) {
16073                float xValue = getDy(batch, idyR, idyC, d2);
16074                float wValue = getW(wRPerm, wCPerm, d1, d2);
16075                dotProd += xValue * wValue;
16076              } else {
16077                float xValue = getDy(batch, d2, idyR, idyC);
16078                float wValue = getW(wRPerm, wCPerm, d1, d2);
16079                dotProd += xValue * wValue;
16080              }
16081
16082            }
16083          }
16084        }
16085        setOutput(dotProd);
16086      }
16087    `}}class wj{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,s=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,o=e.padInfo.top,i=e.padInfo.left;this.userCode=`
16088      void main() {
16089        ivec5 coords = getOutputCoords();
16090        int wF = coords.x;
16091        int wR = coords.y;
16092        int wC = coords.z;
16093        int d1 = coords.w;
16094        int d2 = coords.u;
16095
16096        float dotProd = 0.0;
16097
16098        for (int b = 0; b < ${e.batchSize}; b++) {
16099          for (int yF = 0; yF < ${e.outDepth}; yF++) {
16100            int xF = wF + yF * ${t} - ${a};
16101
16102            if (xF < 0 || xF >= ${e.inDepth}) {
16103              continue;
16104            }
16105
16106            for (int yR = 0; yR < ${e.outHeight}; yR++) {
16107              int xR = wR + yR * ${s} - ${o};
16108
16109              if (xR < 0 || xR >= ${e.inHeight}) {
16110                continue;
16111              }
16112
16113              for (int yC = 0; yC < ${e.outWidth}; yC++) {
16114                int xC = wC + yC * ${r} - ${i};
16115
16116                if (xC < 0 || xC >= ${e.inWidth}) {
16117                  continue;
16118                }
16119
16120                float dyValue = getDy(b, yF, yR, yC, d2);
16121                float xValue = getX(b, xF, xR, xC, d1);
16122                dotProd += (xValue * dyValue);
16123              }
16124            }
16125          }
16126        }
16127        setOutput(dotProd);
16128      }
16129    `}}class vj{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,s=e.filterHeight,r=e.filterWidth,a=e.strideDepth,o=e.strideHeight,i=e.strideWidth,l=t-1-e.padInfo.front,u=s-1-e.padInfo.top,c=r-1-e.padInfo.left;this.userCode=`
16130      const ivec3 pads = ivec3(${l}, ${u}, ${c});
16131
16132      void main() {
16133        ivec5 coords = getOutputCoords();
16134        int batch = coords.x;
16135        int d1 = coords.u;
16136
16137
16138        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
16139        int dyFCorner = dyCorner.x;
16140        int dyRCorner = dyCorner.y;
16141        int dyCCorner = dyCorner.z;
16142
16143        float dotProd = 0.0;
16144        for (int wF = 0; wF < ${t}; wF++) {
16145          float dyF = float(dyFCorner + wF) / ${a}.0;
16146
16147          if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {
16148            continue;
16149          }
16150          int idyF = int(dyF);
16151
16152          int wFPerm = ${t} - 1 - wF;
16153
16154          for (int wR = 0; wR < ${s}; wR++) {
16155            float dyR = float(dyRCorner + wR) / ${o}.0;
16156
16157            if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
16158              fract(dyR) > 0.0) {
16159              continue;
16160            }
16161            int idyR = int(dyR);
16162
16163            int wRPerm = ${s} - 1 - wR;
16164
16165            for (int wC = 0; wC < ${r}; wC++) {
16166              float dyC = float(dyCCorner + wC) / ${i}.0;
16167
16168              if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
16169                  fract(dyC) > 0.0) {
16170                continue;
16171              }
16172              int idyC = int(dyC);
16173
16174              int wCPerm = ${r} - 1 - wC;
16175
16176              for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
16177                float xValue = getDy(batch, idyF, idyR, idyC, d2);
16178                float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);
16179                dotProd += xValue * wValue;
16180              }
16181            }
16182          }
16183        }
16184        setOutput(dotProd);
16185      }
16186    `}}/**
16187 * @license
16188 * Copyright 2020 Google LLC. All Rights Reserved.
16189 * Licensed under the Apache License, Version 2.0 (the "License");
16190 * you may not use this file except in compliance with the License.
16191 * You may obtain a copy of the License at
16192 *
16193 * http://www.apache.org/licenses/LICENSE-2.0
16194 *
16195 * Unless required by applicable law or agreed to in writing, software
16196 * distributed under the License is distributed on an "AS IS" BASIS,
16197 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16198 * See the License for the specific language governing permissions and
16199 * limitations under the License.
16200 * =============================================================================
16201 */function Cj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,dy:a}=e,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,filterShape:c}=s,h=fr(l),d=Ft(r.shape,c,o,1,i,u,!1,h),p=new xj(d);return t.runWebGLProgram(p,[r,a],"float32")}const $j={kernelName:Ku,backendName:"webgl",kernelFunc:Cj};/**
16202 * @license
16203 * Copyright 2023 Google LLC.
16204 * Licensed under the Apache License, Version 2.0 (the "License");
16205 * you may not use this file except in compliance with the License.
16206 * You may obtain a copy of the License at
16207 *
16208 * http://www.apache.org/licenses/LICENSE-2.0
16209 *
16210 * Unless required by applicable law or agreed to in writing, software
16211 * distributed under the License is distributed on an "AS IS" BASIS,
16212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16213 * See the License for the specific language governing permissions and
16214 * limitations under the License.
16215 * =============================================================================
16216 */class Nj{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=Tt(this.outputShape.length);const t=e.filterHeight,s=e.filterWidth,r=t-1-e.padInfo.top,a=s-1-e.padInfo.left;this.userCode=`
16217      const ivec2 pads = ivec2(${r}, ${a});
16218
16219      void main() {
16220        ivec4 coords = getOutputCoords();
16221        int batch = coords[0];
16222        int d1 = coords[3];
16223
16224        ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads;
16225        int dyRCorner = dyCorner.x;
16226        int dyCCorner = dyCorner.y;
16227
16228        vec4 result = vec4(0.);
16229        for (int wR = 0; wR < ${t}; wR++) {
16230          float dyR = float(dyRCorner + wR) / strides[0];
16231          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
16232            continue;
16233          }
16234          int idyR = int(dyR);
16235          int wRPerm = ${t} - 1 - wR;
16236
16237          for (int wC = 0; wC < ${s}; wC++) {
16238            int wCPerm = ${s} - 1 - wC;
16239
16240            float dyC = float(dyCCorner + wC) / strides[1];
16241            bool idyCVal = (dyC >= 0.0) && (dyC < ${e.outWidth}.0)
16242              && (fract(dyC) == 0.0);
16243            int idyC = int(dyC);
16244
16245            float dyC2 = float(dyCCorner + wC + 1) / strides[1];
16246            bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${e.outWidth}.0)
16247              && (fract(dyC2) == 0.0);
16248            int idyC2 = int(dyC2);
16249
16250            if (idyCVal && idyCVal2) {
16251              for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {
16252                vec4 wValue = getW(wRPerm, wCPerm, d1, d2);
16253                vec4 dySample = getDy(batch, idyR, idyC, d2);
16254                vec4 dySample2 = (idyC / 2 == idyC2 / 2) ?
16255                  dySample : getDy(batch, idyR, idyC2, d2);
16256
16257                vec2 dyValue = mod(float(idyC), 2.) == 0. ?
16258                  dySample.xy : dySample.zw;
16259                result.xy += vec2(dot(dyValue, wValue.xy),
16260                  dot(dyValue, wValue.zw));
16261
16262                dyValue = mod(float(idyC2), 2.) == 0. ?
16263                  dySample2.xy : dySample2.zw;
16264                result.zw += vec2(dot(dyValue, wValue.xy),
16265                  dot(dyValue, wValue.zw));
16266              }
16267            } else if (idyCVal) {
16268              for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {
16269                vec4 wValue = getW(wRPerm, wCPerm, d1, d2);
16270                vec4 dySample = getDy(batch, idyR, idyC, d2);
16271                vec2 dyValue = mod(float(idyC), 2.) == 0. ?
16272                  dySample.xy : dySample.zw;
16273                result.xy += vec2(dot(dyValue, wValue.xy),
16274                  dot(dyValue, wValue.zw));
16275              }
16276            } else if (idyCVal2) {
16277              for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {
16278                vec4 wValue = getW(wRPerm, wCPerm, d1, d2);
16279                vec4 dySample = getDy(batch, idyR, idyC2, d2);
16280                vec2 dyValue = mod(float(idyC2), 2.) == 0. ?
16281                  dySample.xy : dySample.zw;
16282                result.zw += vec2(dot(dyValue, wValue.xy),
16283                  dot(dyValue, wValue.zw));
16284              }
16285            }
16286          }
16287        }
16288        setOutput(result);
16289      }
16290    `}}/**
16291 * @license
16292 * Copyright 2020 Google LLC. All Rights Reserved.
16293 * Licensed under the Apache License, Version 2.0 (the "License");
16294 * you may not use this file except in compliance with the License.
16295 * You may obtain a copy of the License at
16296 *
16297 * http://www.apache.org/licenses/LICENSE-2.0
16298 *
16299 * Unless required by applicable law or agreed to in writing, software
16300 * distributed under the License is distributed on an "AS IS" BASIS,
16301 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16302 * See the License for the specific language governing permissions and
16303 * limitations under the License.
16304 * =============================================================================
16305 */function Ij(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,filter:a}=e,{inputShape:o,strides:i,pad:l,dataFormat:u,dimRoundingMode:c}=s,h=fr(u),d=Ft(o,a.shape,i,1,l,c,!1,h);if(W().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&h==="channelsLast"){const p=[[d.strideHeight,d.strideWidth]],f=new Nj(d);return t.runWebGLProgram(f,[r,a],"float32",p)}else{const p=new bj(d);return t.runWebGLProgram(p,[r,a],"float32")}}const Sj={kernelName:Wo,backendName:"webgl",kernelFunc:Ij};/**
16306 * @license
16307 * Copyright 2020 Google LLC. All Rights Reserved.
16308 * Licensed under the Apache License, Version 2.0 (the "License");
16309 * you may not use this file except in compliance with the License.
16310 * You may obtain a copy of the License at
16311 *
16312 * http://www.apache.org/licenses/LICENSE-2.0
16313 *
16314 * Unless required by applicable law or agreed to in writing, software
16315 * distributed under the License is distributed on an "AS IS" BASIS,
16316 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16317 * See the License for the specific language governing permissions and
16318 * limitations under the License.
16319 * =============================================================================
16320 */function kj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a}=e,{strides:o,pad:i,dilations:l}=s,u=Da(r.shape,a.shape,o,l,i),c=new fj(u);return t.runWebGLProgram(c,[r,a],"float32")}const Tj={kernelName:Uo,backendName:"webgl",kernelFunc:kj};/**
16321 * @license
16322 * Copyright 2020 Google LLC. All Rights Reserved.
16323 * Licensed under the Apache License, Version 2.0 (the "License");
16324 * you may not use this file except in compliance with the License.
16325 * You may obtain a copy of the License at
16326 *
16327 * http://www.apache.org/licenses/LICENSE-2.0
16328 *
16329 * Unless required by applicable law or agreed to in writing, software
16330 * distributed under the License is distributed on an "AS IS" BASIS,
16331 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16332 * See the License for the specific language governing permissions and
16333 * limitations under the License.
16334 * =============================================================================
16335 */function Ej(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,dy:a}=e,{strides:o,pad:i,filterShape:l}=s,u=Da(r.shape,l,o,1,i),c=new wj(u);return t.runWebGLProgram(c,[r,a],"float32")}const Rj={kernelName:xc,backendName:"webgl",kernelFunc:Ej};/**
16336 * @license
16337 * Copyright 2020 Google LLC. All Rights Reserved.
16338 * Licensed under the Apache License, Version 2.0 (the "License");
16339 * you may not use this file except in compliance with the License.
16340 * You may obtain a copy of the License at
16341 *
16342 * http://www.apache.org/licenses/LICENSE-2.0
16343 *
16344 * Unless required by applicable law or agreed to in writing, software
16345 * distributed under the License is distributed on an "AS IS" BASIS,
16346 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16347 * See the License for the specific language governing permissions and
16348 * limitations under the License.
16349 * =============================================================================
16350 */function Dj(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,filter:a}=e,{pad:o,strides:i,inputShape:l}=s,u=Da(l,a.shape,i,1,o),c=new vj(u);return t.runWebGLProgram(c,[r,a],"float32")}const Aj={kernelName:$u,backendName:"webgl",kernelFunc:Dj};/**
16351 * @license
16352 * Copyright 2020 Google LLC. All Rights Reserved.
16353 * Licensed under the Apache License, Version 2.0 (the "License");
16354 * you may not use this file except in compliance with the License.
16355 * You may obtain a copy of the License at
16356 *
16357 * http://www.apache.org/licenses/LICENSE-2.0
16358 *
16359 * Unless required by applicable law or agreed to in writing, softw
16359are
16360 * distributed under the License is distributed on an "AS IS" BASIS,
16361 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16362 * See the License for the specific language governing permissions and
16363 * limitations under the License.
16364 * =============================================================================
16365 */const Oj=Qa+`
16366  return cos(x);
16367`,_j=`
16368  vec4 result = cos(x);
16369  bvec4 isNaN = isnan(x);
16370  ${$r}
16371  return result;
16372`,Fj=Te({opSnippet:Oj,packedOpSnippet:_j}),Lj={kernelName:sa,backendName:"webgl",kernelFunc:Fj};/**
16373 * @license
16374 * Copyright 2020 Google LLC. All Rights Reserved.
16375 * Licensed under the Apache License, Version 2.0 (the "License");
16376 * you may not use this file except in compliance with the License.
16377 * You may obtain a copy of the License at
16378 *
16379 * http://www.apache.org/licenses/LICENSE-2.0
16380 *
16381 * Unless required by applicable law or agreed to in writing, software
16382 * distributed under the License is distributed on an "AS IS" BASIS,
16383 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16384 * See the License for the specific language governing permissions and
16385 * limitations under the License.
16386 * =============================================================================
16387 */const Pj=`
16388  float e2x = exp(-x);
16389  return (e2x + 1.0 / e2x) / 2.0;
16390`,zj=Te({opSnippet:Pj}),Vj={kernelName:ra,backendName:"webgl",kernelFunc:zj};/**
16391 * @license
16392 * Copyright 2017 Google LLC. All Rights Reserved.
16393 * Licensed under the Apache License, Version 2.0 (the "License");
16394 * you may not use this file except in compliance with the License.
16395 * You may obtain a copy of the License at
16396 *
16397 * http://www.apache.org/licenses/LICENSE-2.0
16398 *
16399 * Unless required by applicable law or agreed to in writing, software
16400 * distributed under the License is distributed on an "AS IS" BASIS,
16401 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16402 * See the License for the specific language governing permissions and
16403 * limitations under the License.
16404 * =============================================================================
16405 */class Bj{constructor(e,t,s,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[o,i,l,u]=e,[c]=t,[h,d]=s;this.outputShape=[c,h,d,u];const p=r==="bilinear"?1:0,[f,g]=[`${i-1}.0`,`${l-1}.0`],[m,y,x]=h>1?[`${(i-1)/(h-1)}`,"(y2-y1) * height_ratio",`y1*${f} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${f}`],[v,b,C]=d>1?[`${(l-1)/(d-1)}`,"(x2-x1) * width_ratio",`x1*${g} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${g}`];this.userCode=`
16406      const float height_ratio = float(${m});
16407      const float width_ratio = float(${v});
16408      void main() {
16409        ivec4 coords = getOutputCoords();
16410        int b = coords[0];
16411        int y = coords[1];
16412        int x = coords[2];
16413        int d = coords[3];
16414
16415        // get box vals
16416        float y1 = getBoxes(b,0);
16417        float x1 = getBoxes(b,1);
16418        float y2 = getBoxes(b,2);
16419        float x2 = getBoxes(b,3);
16420
16421        // get image in batch index
16422        int bInd = round(getBoxInd(b));
16423        if(bInd < 0 || bInd >= ${o}) {
16424          return;
16425        }
16426
16427        float height_scale = ${y};
16428        float width_scale = ${b};
16429
16430        float in_y = ${x};
16431        if( in_y < 0.0 || in_y > ${f} ) {
16432          setOutput(float(${a}));
16433          return;
16434        }
16435        float in_x = ${C};
16436        if( in_x < 0.0 || in_x > ${g} ) {
16437          setOutput(float(${a}));
16438          return;
16439        }
16440
16441        vec2 sourceFracIndexCR = vec2(in_x,in_y);
16442        if(${p} == 1) {
16443          // Compute the four integer indices.
16444          ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);
16445          ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));
16446
16447          float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);
16448          float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);
16449          float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);
16450          float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);
16451
16452          vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);
16453
16454          float top = topLeft + (topRight - topLeft) * fracCR.x;
16455          float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;
16456          float newValue = top + (bottom - top) * fracCR.y;
16457          setOutput(newValue);
16458        } else {
16459          // Compute the coordinators of nearest neighbor point.
16460          ivec2 sourceNearestCR = ivec2(floor(
16461            sourceFracIndexCR + vec2(0.5,0.5)));
16462          float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);
16463          setOutput(newValue);
16464        }
16465      }
16466    `}}/**
16467 * @license
16468 * Copyright 2020 Google LLC. All Rights Reserved.
16469 * Licensed under the Apache License, Version 2.0 (the "License");
16470 * you may not use this file except in compliance with the License.
16471 * You may obtain a copy of the License at
16472 *
16473 * http://www.apache.org/licenses/LICENSE-2.0
16474 *
16475 * Unless required by applicable law or agreed to in writing, software
16476 * distributed under the License is distributed on an "AS IS" BASIS,
16477 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16478 * See the License for the specific language governing permissions and
16479 * limitations under the License.
16480 * =============================================================================
16481 */const Mj=n=>{const{inputs:e,backend:t,attrs:s}=n,{image:r,boxes:a,boxInd:o}=e,{cropSize:i,method:l,extrapolationValue:u}=s,c=new Bj(r.shape,a.shape,i,l,u);return t.runWebGLProgram(c,[r,a,o],"float32")},Wj={kernelName:Ju,backendName:"webgl",kernelFunc:Mj};var Ro;(function(n){n.Prod="*",n.Sum="+"})(Ro||(Ro={}));class Py{constructor(e,t,s,r){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const a=this.outputShape.length,o=this.op===Ro.Prod?"1.0":"0.0",i=s?o:`getX(${zy(a,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1];let u="",c="";s?(u=r?`end != ${l-1}`:"end != 0",c=r?"end + 1":"end - 1"):(u=r?`end + pow2 < ${l}`:"end >= pow2",c=r?"end + pow2":"end - pow2"),this.userCode=`
16482      void main() {
16483        ${Fe(a)} coords = getOutputCoords();
16484        int end = ${Vy(a,"coords",this.op)};
16485        float val = ${i};
16486        int pow2 = int(pow(2.0, index));
16487        if (${u}) {
16488          int idx = ${c};
16489          ${Vy(a,"coords",this.op)} = idx;
16490          val ${this.op}= getX(${zy(a,"coords",this.op)});
16491        }
16492        setOutput(val);
16493      }
16494    `}}function zy(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 Vy(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`)}/**
16495 * @license
16496 * Copyright 2022 Google LLC. All Rights Reserved.
16497 * Licensed under the Apache License, Version 2.0 (the "License");
16498 * you may not use this file except in compliance with the License.
16499 * You may obtain a copy of the License at
16500 *
16501 * http://www.apache.org/licenses/LICENSE-2.0
16502 *
16503 * Unless required by applicable law or agreed to in writing, software
16504 * distributed under the License is distributed on an "AS IS" BASIS,
16505 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16506 * See the License for the specific language governing permissions and
16507 * limitations under the License.
16508 * =============================================================================
16509 */function cC(n,e,t,s,r,a){const o=e.shape.length,i=Xe([s],o);let l=e;i!=null&&(l=_t({inputs:{x:e},backend:t,attrs:{perm:i}}));const u=st(1,o)[0];if(u!==o-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length-1} but got axis=${s}`);const c=l.shape[u];let h=Qt({inputs:{x:l},backend:t});for(let d=0;d<=Math.ceil(Math.log2(c))-1;d++){const p=new Py(n,l.shape,!1,a),f=[[d]],g=h;h=t.runWebGLProgram(p,[h],h.dtype,f),t.disposeIntermediateTensorInfo(g)}if(r){const d=new Py(n,l.shape,r,a),p=h;h=t.runWebGLProgram(d,[h],h.dtype),t.disposeIntermediateTensorInfo(p)}if(i!=null){const d=pr(i),p=_t({inputs:{x:h},backend:t,attrs:{perm:d}});return t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(l),p}return h}/**
16510 * @license
16511 * Copyright 2022 Google LLC. All Rights Reserved.
16512 * Licensed under the Apache License, Version 2.0 (the "License");
16513 * you may not use this file except in compliance with the License.
16514 * You may obtain a copy of the License at
16515 *
16516 * http://www.apache.org/licenses/LICENSE-2.0
16517 *
16518 * Unless required by applicable law or agreed to in writing, software
16519 * distributed under the License is distributed on an "AS IS" BASIS,
16520 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16521 * See the License for the specific language governing permissions and
16522 * limitations under the License.
16523 * =============================================================================
16524 */function Uj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,exclusive:o,reverse:i}
vendor: 8,069 bytes, lines 16524-16674
16524=s;return cC(Ro.Prod,r,t,a,o,i)}const Gj={kernelName:Nu,backendName:"webgl",kernelFunc:Uj};/**
16525 * @license
16526 * Copyright 2022 Google LLC. All Rights Reserved.
16527 * Licensed under the Apache License, Version 2.0 (the "License");
16528 * you may not use this file except in compliance with the License.
16529 * You may obtain a copy of the License at
16530 *
16531 * http://www.apache.org/licenses/LICENSE-2.0
16532 *
16533 * Unless required by applicable law or agreed to in writing, software
16534 * distributed under the License is distributed on an "AS IS" BASIS,
16535 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16536 * See the License for the specific language governing permissions and
16537 * limitations under the License.
16538 * =============================================================================
16539 */function Hj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,exclusive:o,reverse:i}=s;return cC(Ro.Sum,r,t,a,o,i)}const jj={kernelName:Go,backendName:"webgl",kernelFunc:Hj};/**
16540 * @license
16541 * Copyright 2020 Google LLC. All Rights Reserved.
16542 * Licensed under the Apache License, Version 2.0 (the "License");
16543 * you may not use this file except in compliance with the License.
16544 * You may obtain a copy of the License at
16545 *
16546 * http://www.apache.org/licenses/LICENSE-2.0
16547 *
16548 * Unless required by applicable law or agreed to in writing, software
16549 * distributed under the License is distributed on an "AS IS" BASIS,
16550 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16551 * See the License for the specific language governing permissions and
16552 * limitations under the License.
16553 * =============================================================================
16554 */function qj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,weights:a}=e,{size:o,binaryOutput:i}=s;if(r.shape.length===1){const l=t.readSync(r.dataId),u=t.readSync(a.dataId),c=Wv(l,u,a.dtype,a.shape,o);return t.makeTensorInfo([o],a.dtype,c)}else if(r.shape.length===2){const l=t.bufferSync(r),u=t.bufferSync(a),c=Y4(l,u,o,i);return t.makeTensorInfo(c.shape,a.dtype,c.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}const Kj={kernelName:Iu,backendName:"webgl",kernelFunc:qj};/**
16555 * @license
16556 * Copyright 2018 Google LLC. All Rights Reserved.
16557 * Licensed under the Apache License, Version 2.0 (the "License");
16558 * you may not use this file except in compliance with the License.
16559 * You may obtain a copy of the License at
16560 *
16561 * http://www.apache.org/licenses/LICENSE-2.0
16562 *
16563 * Unless required by applicable law or agreed to in writing, software
16564 * distributed under the License is distributed on an "AS IS" BASIS,
16565 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16566 * See the License for the specific language governing permissions and
16567 * limitations under the License.
16568 * =============================================================================
16569 */class Xj{constructor(e,t,s){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=s,this.userCode=`
16570    void main() {
16571      ivec4 coords = getOutputCoords();
16572      int b = coords[0];
16573      int h = ${this.getHeightCoordString()};
16574      int w = ${this.getWidthCoordString()};
16575      int d = ${this.getDepthCoordString()};
16576
16577      int in_h = h / ${t};
16578      int offset_h = imod(h, ${t});
16579      int in_w = w / ${t};
16580      int offset_w = imod(w, ${t});
16581      int offset_d = (offset_h * ${t} + offset_w) *
16582        ${this.getOutputDepthSize()};
16583      int in_d = d + offset_d;
16584
16585      float result = ${this.getInputSamplingString()};
16586      setOutput(result);
16587    }
16588  `}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)"}}/**
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 */function Yj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{blockSize:a,dataFormat:o}=s,i=r.shape[0],l=o==="NHWC"?r.shape[1]:r.shape[2],u=o==="NHWC"?r.shape[2]:r.shape[3],c=o==="NHWC"?r.shape[3]:r.shape[1],h=l*a,d=u*a,p=c/(a*a),f=o==="NHWC"?[i,h,d,p]:[i,p,h,d],g=new Xj(f,a,o);return t.runWebGLProgram(g,[r],r.dtype)}const Jj={kernelName:Su,backendName:"webgl",kernelFunc:Yj};/**
16604 * @license
16605 * Copyright 2017 Google LLC. All Rights Reserved.
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 */class hC{constructor(e,t=!1,s=null,r=!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=Tt(this.outputShape.length);const o=e.filterHeight,i=e.filterWidth,l=e.outChannels/e.inChannels;let u="",c="";s&&(r?u=`float activation(float a) {
16619          float b = getPreluActivationWeightsAtOutCoords();
16620          ${s}
16621        }`:a?u=`float activation(float a) {
16622          float b = getLeakyreluAlphaAtOutCoords();
16623          ${s}
16624        }`:u=`
16625          float activation(float x) {
16626            ${s}
16627          }
16628        `,c="result = activation(result);");const h=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
16629      ${u}
16630
16631      void main() {
16632        ivec4 coords = getOutputCoords();
16633        int batch = coords.x;
16634        ivec2 xRCCorner = coords.yz * strides - pads;
16635        int d2 = coords.w;
16636        int d1 = d2 / ${l};
16637        int q = d2 - d1 * ${l};
16638
16639        int xRCorner = xRCCorner.x;
16640        int xCCorner = xRCCorner.y;
16641
16642        // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).
16643        // ? = to be determined. : = across all values in that axis.
16644        float dotProd = 0.0;
16645        // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.
16646        for (int wR = 0; wR < ${o}; wR++) {
16647          int xR = xRCorner + wR * dilations[0];
16648
16649          if (xR < 0 || xR >= inDims[0]) {
16650            continue;
16651          }
16652
16653          for (int wC = 0; wC < ${i}; wC++) {
16654            int xC = xCCorner + wC * dilations[1];
16655
16656            if (xC < 0 || xC >= inDims[1]) {
16657              continue;
16658            }
16659
16660            float xVal = getX(batch, xR, xC, d1);
16661            float wVal = getW(wR, wC, d1, q);
16662            dotProd += xVal * wVal;
16663          }
16664        }
16665
16666        float result = dotProd;
16667        ${h}
16668        ${c}
16669        setOutput(result);
16670      }
16671    `}}/**
16672 * @license
16673 * Copyright 2018 Google LLC. All Rights Reserved.
16674 * Licensed under the Apache License, Version 2.0 (the "License");
16675 * you may not use this file except in compliance with the License.
16676 * You may obtain a copy of the License at
16677 *
16678 * http://www.apache.org/licenses/LICENSE-2.0
16679 *
16680 * Unless required by applicable law or agreed to in writing, software
16681 * distributed under the License is distributed on an "AS IS" BASIS,
16682 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16683 * See the License for the specific language governing permissions and
16684 * limitations under the License.
16685 * =============================================================================
16686 */class dC{constructor(e,t=!1,s=null,r=!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=Tt(this.outputShape.length);const o=e.outChannels/e.inChannels,i=e.padInfo.left,l=e.strideWidth,u=e.dilationWidth,c=e.filterHeight,h=e.filterWidth,d=h;let p=`
16687      int xR; int xC; int xCOffset;
16688      vec4 wTexel; vec4 previous; vec4 final;`;for(let y=0;y<h;y++)p+=`
16689          vec4 xTexelC${y*2};
16690          int xTexelC${y*2}Ready;
16691          vec4 xTexelC${y*2+1};
16692          int xTexelC${y*2+1}Ready;
16693          vec4 xC${y};`;p+=`
16694    for (int r = 0; r < ${c}; r++) {
16695      `;for(let y=0;y<h;y++)p+=`
16696          xTexelC${y*2} = vec4(0.0);
16697          xTexelC${y*2}Ready = 0;
16698          xTexelC${y*2+1} = vec4(0.0);
16699          xTexelC${y*2+1}Ready = 0;
16700          xC${y} = vec4(0.0);`;p+=`
16701        xR = xRCorner + r * dilations[0];
16702        if (xR >=0 && xR < inDims[0]) {
16703      `;for(let y=0;y<(d+1)/2;y++){const x=y*2;if(p+=`
16704          xC = xCCorner + ${x*u};
16705          `,l===1){if(x<h&&(i%2===1?(p+=`
16706                xCOffset = xC + 1;
16707                if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x}Ready == 0) {
16708                  xTexelC${x} = getX(batch, xR, xCOffset, d1);
16709
16710                  // Need to manually clear unused channels in case
16711                  // we're reading from recycled texture.
16712                  if (xCOffset + 1 >= inDims[1]) {
16713                    xTexelC${x}.zw = vec2(0.0);
16714                  }
16715                  xTexelC${x}Ready = 1;
16716                }
16717              `,u===1&&x>0?p+=`
16718                xC${x} = vec4(xTexelC${x-2}.zw, xTexelC${x}.xy);
16719                `:p+=`
16720                  xCOffset = xC + 1 - 2;
16721
16722                  if (xCOffset >= 0 && xCOffset < inDims[1]) {
16723                    previous = getX(batch, xR, xCOffset, d1);
16724
16725                    // Need to manually clear unused channels in case
16726                    // we're reading from recycled texture.
16727                    if (xCOffset + 1 >= inDims[1]) {
16728                      previous.zw = vec2(0.0);
16729                    }
16730
16731                    xC${x} = vec4(previous.zw, xTexelC${x}.xy);
16732                  } else {
16733                    xC${x} = vec4(0.0, 0.0, xTexelC${x}.xy);
16734                  }
16735                  `):p+=`
16736                if (xC >= 0 && xC < inDims[1] && xTexelC${x}Ready == 0) {
16737                  xTexelC${x} = getX(batch, xR, xC, d1);
16738                  if (xC + 1 >= inDims[1]) {
16739                    xTexelC${x}.zw = vec2(0.0);
16740                  }
16741                  xTexelC${x}Ready = 1;
16742                }
16743
16744                xC${x} = xTexelC${x};
16745                `,x+1<h)){const v=i%2===0?tp(u):u;u%2===0&&i%2===1||u%2!==0&&i%2!==1?(p+=`
16746                  xCOffset = xC + imod(pads[1], 2) + ${v};
16747
16748                  if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x+1}Ready == 0) {
16749                    xTexelC${x+1} = getX(batch, xR, xCOffset, d1);
16750
16751                    // Need to manually clear unused channels in case
16752                    // we're reading from recycled texture.
16753                    if (xCOffset + 1 >= inDims[1]) {
16754                      xTexelC${x+1}.zw = vec2(0.0);
16755                    }
16756                    xTexelC${x+1}Ready = 1;
16757                  }
16758                  `,u>1?p+=`
16759                    xCOffset -= 2;
16760                    if (xCOffset >= 0 && xCOffset < inDims[1]) {
16761                     previous = getX(batch, xR, xCOffset, d1);
16762                     xC${x+1} = vec4(previous.zw, xTexelC${x+1}.xy);
16763                    } else {
16764                     xC${x+1} = vec4(0.0, 0.0, xTexelC${x+1}.xy);
16765                    }
16766                    `:p+=`
16767                    xC${x+1} = vec4(xTexelC${x}.zw, xTexelC${x+1}.xy);
16768                    `):v===1?p+=`
16769                    xC${x+1} = xTexelC${x};
16770                    `:p+=`
16771                    xCOffset = xC + ${v};
16772
16773                    if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x+1}Ready == 0) {
16774                      xTexelC${x+1} = getX(batch, xR, xCOffset, d1);
16775                      if (xCOffset + 1 >= inDims[1]) {
16776                        xTexelC${x+1}.zw = vec2(0.0);
16777                      }
16778                      xTexelC${x+1}Ready = 1;
16779                    }
16780
16781                    xC${x+1} = xTexelC${x+1};
16782                    `}}else x<h&&(i%2===1?(p+=`
16783                xCOffset = xC + 1 - strides[1];
16784                if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x}Ready == 0) {
16785                  xTexelC${x} = getX(batch, xR, xCOffset, d1);
16786                  // Need to manually clear unused channels in case
16787                  // we're reading from recycled texture.
16788                  if (xCOffset + 1 >= inDims[1]) {
16789                    xTexelC${x}.zw = vec2(0.0);
16790                  }
16791                  xTexelC${x}Ready = 1;
16792                }
16793
16794                if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${x+1}Ready == 0) {
16795                  xTexelC${x+1} = getX(batch, xR, xC + 1, d1);
16796                  // Need to manually clear unused channels in case
16797                  // we're reading from recycled texture.
16798                  if (xC + 2 >= inDims[1]) {
16799                    xTexelC${x+1}.zw = vec2(0.0);
16800                  }
16801                  xTexelC${x+1}Ready = 1;
16802                }
16803
16804                xC${x} = vec4(xTexelC${x}.zw, xTexelC${x+1}.zw);
16805              `,x+1<h&&(p+=`
16806                  final = vec4(0.0);
16807                  xCOffset = xC + 1 + strides[1];
16808                  if(xCOffset >= 0 && xCOffset < inDims[1]) {
16809                    final = getX(batch, xR, xCOffset, d1);
16810                  }
16811                  xC${x+1} = vec4(xTexelC${x+1}.xy, final.xy);
16812                `)):(p+=`
16813                if(xC >= 0 && xC < inDims[1] && xTexelC${x}Ready == 0) {
16814                  xTexelC${x} = getX(batch, xR, xC, d1);
16815                  if (xC + 1 >= inDims[1]) {
16816                    xTexelC${x}.zw = vec2(0.0);
16817                  }
16818                  xTexelC${x}Ready = 1;
16819                }
16820
16821                xCOffset = xC + strides[1];
16822                if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${x+1}Ready == 0) {
16823                  xTexelC${x+1} = getX(batch, xR, xCOffset, d1);
16824                  if (xCOffset + 1 >= inDims[1]) {
16825                    xTexelC${x+1}.zw = vec2(0.);
16826                  }
16827                  xTexelC${x+1}Ready = 1;
16828                }
16829
16830                xC${x} = vec4(
16831                  xTexelC${x}.xy, xTexelC${x+1}.xy);
16832              `,x+1<h&&(p+=`
16833                  xC${x+1} = vec4(xTexelC${x}.zw, xTexelC${x+1}.zw);
16834                `)));x<h&&(p+=`
16835            wTexel = getW(r, ${x}, d1, q);
16836            dotProd += xC${x} * vec4(wTexel.xz, wTexel.xz);
16837          `,x+1<h&&(p+=`
16838              wTexel = getW(r, ${x+1}, d1, q);
16839              dotProd += xC${x+1} * vec4(wTexel.xz, wTexel.xz);
16840            `))}p+=`
16841    }
16842  `,p+=`
16843      }
16844    `;let f="",g="";s&&(r?f=`vec4 activation(vec4 a) {
16845          vec4 b = getPreluActivationWeightsAtOutCoords();
16846          ${s}
16847        }`:a?f=`vec4 activation(vec4 a) {
16848          vec4 b = getLeakyreluAlphaAtOutCoords();
16849          ${s}
16850        }`:f=`vec4 activation(vec4 x) {
16851          ${s}
16852        }`,g="result = activation(result);");const m=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
16853      ${f}
16854
16855      void main() {
16856        ivec4 coords = getOutputCoords();
16857        int batch = coords.x;
16858        ivec2 xRCCorner = coords.yz * strides - pads;
16859        int d2 = coords.w;
16860        int d1 = d2 / ${o};
16861        int q = d2 - d1 * ${o};
16862        int xRCorner = xRCCorner.x;
16863        int xCCorner = xRCCorner.y;
16864
16865        //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
16866        vec4 dotProd = vec4(0.000000000000001);
16867
16868        ${p}
16869
16870        vec4 result = dotProd - vec4(0.000000000000001);
16871        ${m}
16872        ${g}
16873        setOutput(result);
16874      }
16875    `}}/**
16876 * @license
16877 * Copyright 2020 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 */function Zj(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a}=e,{strides:o,pad:i,dilations:l,dimRoundingMode:u}=s;let c=l;c==null&&(c=[1,1]),I(It(o,c),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);const h=Ft(r.shape,a.shape,o,c,i,u,!0);let d;W().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels===1?d=new dC(h):d=new hC(h);const p=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth]];return t.runWebGLProgram(d,[r,a],"float32",p)}const Qj={kernelName:Ho,backendName:"webgl",kernelFunc:Zj};/**
16891 * @license
16892 * Copyright 2018 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 */class eq{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,s=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=`
16906      void main() {
16907        ivec4 coords = getOutputCoords();
16908        int wR = coords.x;
16909        int wC = coords.y;
16910        int d1 = coords.z;
16911        int dm = coords.w;
16912        int d2 = d1 * ${o} + dm;
16913
16914        float dotProd = 0.0;
16915
16916        // TO DO: Vec4 over the batch size
16917        for (int b = 0; b < ${e.batchSize}; b++) {
16918          for (int yR = 0; yR < ${e.outHeight}; yR++) {
16919            int xR = wR + yR * ${t} - ${r};
16920
16921            if (xR < 0 || xR >= ${e.inHeight}) {
16922              continue;
16923            }
16924
16925            for (int yC = 0; yC < ${e.outWidth}; yC++) {
16926              int xC = wC + yC * ${s} - ${a};
16927
16928              if (xC < 0 || xC >= ${e.inWidth}) {
16929                continue;
16930              }
16931
16932              float dyValue = getDy(b, yR, yC, d2);
16933              float xValue = getX(b, xR, xC, d1);
16934              dotProd += (xValue * dyValue);
16935            }
16936          }
16937        }
16938        setOutput(dotProd);
16939      }
16940    `}}class tq{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,s=e.filterWidth,r=e.strideHeight,a=e.strideWidth,o=t-1-e.padInfo.top,i=s-1-e.padInfo.left,l=e.outChannels/e.inChannels;this.userCode=`
16941      const ivec2 pads = ivec2(${o}, ${i});
16942
16943      void main() {
16944        ivec4 coords = getOutputCoords();
16945        int batch = coords[0];
16946        int d1 = coords[3];
16947        ivec2 dyCorner = coords.yz - pads;
16948        int dyRCorner = dyCorner.x;
16949        int dyCCorner = dyCorner.y;
16950
16951        float dotProd = 0.0;
16952
16953        for (int wR = 0; wR < ${t}; wR++) {
16954          float dyR = float(dyRCorner + wR) / ${r}.0;
16955
16956          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
16957            continue;
16958          }
16959          int idyR = int(dyR);
16960
16961          int wRPerm = ${t} - 1 - wR;
16962
16963          for (int wC = 0; wC < ${s}; wC++) {
16964            float dyC = float(dyCCorner + wC) / ${a}.0;
16965
16966            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
16967                fract(dyC) > 0.0) {
16968              continue;
16969            }
16970            int idyC = int(dyC);
16971
16972            int wCPerm = ${s} - 1 - wC;
16973
16974            // TO DO: Vec4 over the channelMul
16975            for (int dm = 0; dm < ${l}; dm++) {
16976              int d2 = d1 * ${l} + dm;
16977              float xValue = getDy(batch, idyR, idyC, d2);
16978              float wValue = getW(wRPerm, wCPerm, d1, dm);
16979              dotProd += xValue * wValue;
16980            }
16981          }
16982        }
16983        setOutput(dotProd);
16984      }
16985    `}}/**
16986 * @license
16987 * Copyright 2020 Google LLC. All Rights Reserved.
16988 * Licensed under the Apache License, Version 2.0 (the "License");
16989 * you may not use this file except in compliance with the License.
16990 * You may obtain a copy of the License at
16991 *
16992 * http://www.apache.org/licenses/LICENSE-2.0
16993 *
16994 * Unless required by applicable law or agreed to in writing, software
16995 * distributed under the License is distributed on an "AS IS" BASIS,
16996 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16997 * See the License for the specific language governing permissions and
16998 * limitations under the License.
16999 * =============================================================================
17000 */function nq(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,dy:a}=e,{strides:o,dilations:i,pad:l,dimRoundingMode:u,filterShape:c}=s,h=Ft(r.shape,c,o,i,l,u,!0),d=new eq(h);return t.runWebGLProgram(d,[r,a],"float32")}const sq={kernelName:Xu,backendName:"webgl",kernelFunc:nq};/**
17001 * @license
17002 * Copyright 2020 Google LLC. All Rights Reserved.
17003 * Licensed under the Apache License, Version 2.0 (the "License");
17004 * you may not use this file except in compliance with the License.
17005 * You may obtain a copy of the License at
17006 *
17007 * http://www.apache.org/licenses/LICENSE-2.0
17008 *
17009 * Unless required by applicable law or agreed to in writing, software
17010 * distributed under the License is distributed on an "AS IS" BASIS,
17011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17012 * See the License for the specific language governing permissions and
17013 * limitations under the License.
17014 * =============================================================================
17015 */function rq(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,filter:a}=e,{strides:o,dilations:i,pad:l,dimRoundingMode:u,inputShape:c}=s,h=Ft(c,a.shape,o,i,l,u,!0),d=new tq(h);return t.runWebGLProgram(d,[r,a],"float32")}const aq={kernelName:Yu,backendName:"webgl",kernelFunc:rq};/**
17016 * @license
17017 * Copyright 2019 Google LLC. All Rights Reserved.
17018 * Licensed under the Apache License, Version 2.0 (the "License");
17019 * you may not use this file except in compliance with the License.
17020 * You may obtain a copy of the License at
17021 *
17022 * http://www.apache.org/licenses/LICENSE-2.0
17023 *
17024 * Unless required by applicable law or agreed to in writing, software
17025 * distributed under the License is distributed on an "AS IS" BASIS,
17026 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17027 * See the License for the specific language governing permissions and
17028 * limitations under the License.
17029 * =============================================================================
17030 */class oq{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=`
17031      void main() {
17032          ivec2 coords = getOutputCoords();
17033          float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;
17034          setOutput(val);
17035      }
17036    `}}/**
17037 * @license
17038 * Copyright 2020 Google LLC. All Rights Reserved.
17039 * Licensed under the Apache License, Version 2.0 (the "License");
17040 * you may not use this file except in compliance with the License.
17041 * You may obtain a copy of the License at
17042 *
17043 * http://www.apache.org/licenses/LICENSE-2.0
17044 *
17045 * Unless required by applicable law or agreed to in writing, software
17046 * distributed under the License is distributed on an "AS IS" BASIS,
17047 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17048 * See the License for the specific language governing permissions and
17049 * limitations under the License.
17050 * =============================================================================
17051 */function iq(n){const{inputs:e,backend:t}=n,{x:s}=e,r=[...s.shape,...s.shape],a=H(s.shape),o=ne({inputs:{x:s},backend:t,attrs:{shape:[a]}}),i=new oq(a),l=t.runWebGLProgram(i,[o],o.dtype),u=ne({inputs:{x:l},backend:t,attrs:{shape:r}});return t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(l),u}const lq={kernelName:ku,backendName:"webgl",kernelFunc:iq};/**
17052 * @license
17053 * Copyright 2017 Google LLC. All Rights Reserved.
17054 * Licensed under the Apache License, Version 2.0 (the "License");
17055 * you may not use this file except in compliance with the License.
17056 * You may obtain a copy of the License at
17057 *
17058 * http://www.apache.org/licenses/LICENSE-2.0
17059 *
17060 * Unless required by applicable law or agreed to in writing, softw
17060are
17061 * distributed under the License is distributed on an "AS IS" BASIS,
17062 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17063 * See the License for the specific language governing permissions and
17064 * limitations under the License.
17065 * =============================================================================
17066 */class uq{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:s,padInfo:r,strideHeight:a,strideWidth:o,filterHeight:i,filterWidth:l,dilationHeight:u,dilationWidth:c}=e,{top:h,left:d}=r;this.userCode=`
17067      const ivec2 strides = ivec2(${a}, ${o});
17068      const ivec2 pads = ivec2(${h}, ${d});
17069      const float neg_infinity = -3.4e38;
17070
17071      void main() {
17072        ivec4 coords = getOutputCoords();
17073        int batch = coords.x;
17074        int d1 = coords.w;
17075        ivec2 outTopLeftCorner =
17076            coords.yz * strides - pads;
17077        int hBeg = outTopLeftCorner.x;
17078        int wBeg = outTopLeftCorner.y;
17079
17080        float curVal = neg_infinity;
17081        for (int h = 0; h < ${i}; h++) {
17082          int hIn = hBeg + h * ${u};
17083
17084          if (hIn >= 0 && hIn < ${t}) {
17085            for (int w = 0; w < ${l}; w++) {
17086              int wIn = wBeg + w * ${c};
17087
17088              if (wIn >= 0 && wIn < ${s}) {
17089                float xVal = getX(batch, hIn, wIn, d1);
17090                float wVal = getW(h, w, d1);
17091
17092                float val = xVal + wVal;
17093                if (val > curVal) {
17094                  curVal = val;
17095                }
17096              }
17097            }
17098          }
17099        }
17100
17101        float result = curVal;
17102        setOutput(result);
17103      }
17104    `}}/**
17105 * @license
17106 * Copyright 2020 Google LLC. All Rights Reserved.
17107 * Licensed under the Apache License, Version 2.0 (the "License");
17108 * you may not use this file except in compliance with the License.
17109 * You may obtain a copy of the License at
17110 *
17111 * http://www.apache.org/licenses/LICENSE-2.0
17112 *
17113 * Unless required by applicable law or agreed to in writing, software
17114 * distributed under the License is distributed on an "AS IS" BASIS,
17115 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17116 * See the License for the specific language governing permissions and
17117 * limitations under the License.
17118 * =============================================================================
17119 */function cq(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a}=e,{strides:o,pad:i,dilations:l}=s,u=zc(r.shape,a.shape,o,i,"NHWC",l);let c;const h=new uq(u);c=t.runWebGLProgram(h,[r,a],"float32");const d=ne({inputs:{x:c},backend:t,attrs:{shape:u.outShape}});return t.disposeIntermediateTensorInfo(c),d}const hq={kernelName:jo,backendName:"webgl",kernelFunc:cq};/**
17120 * @license
17121 * Copyright 2021 Google LLC. All Rights Reserved.
17122 * Licensed under the Apache License, Version 2.0 (the "License");
17123 * you may not use this file except in compliance with the License.
17124 * You may obtain a copy of the License at
17125 *
17126 * http://www.apache.org/licenses/LICENSE-2.0
17127 *
17128 * Unless required by applicable law or agreed to in writing, software
17129 * distributed under the License is distributed on an "AS IS" BASIS,
17130 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17131 * See the License for the specific language governing permissions and
17132 * limitations under the License.
17133 * =============================================================================
17134 */function dq(n){const{inputs:e,backend:t,attrs:s}=n,{equation:r}=s,a=e,{allDims:o,summedDims:i,idDims:l}=Tx(r,a.length);Ex(o.length,l,a);const{path:u,steps:c}=Rx(i,l),h=c.length;let d=null,p=o.length;const f=[];for(let g=0;g<h;++g){for(const m of c[g]){const{permutationIndices:y,expandDims:x}=Dx(p,l[m]);let v;Ax(y)?v=a[m]:(v=_t({inputs:{x:a[m]},backend:t,attrs:{perm:y}}),f.push(v));const b=v.shape.slice();for(let C=0;C<x.length;++C)b.splice(x[C],0,1);ke(v.shape,b)||(v=ne({inputs:{x:v},backend:t,attrs:{shape:b}}),f.push(v)),d===null?d=v:(d=yg({inputs:{a:v,b:d},backend:t}),f.push(d))}g<h-1&&(u[g]>
17134=0&&(d=Ph({inputs:{x:d},backend:t,attrs:{axis:u[g]-(o.length-p),keepDims:!1}}),f.push(d)),p--)}for(const g of f)g!==d&&t.disposeIntermediateTensorInfo(g);return d}const pq={kernelName:Tu,backendName:"webgl",kernelFunc:dq};/**
17135 * @license
17136 * Copyright 2020 Google LLC. All Rights Reserved.
17137 * Licensed under the Apache License, Version 2.0 (the "License");
17138 * you may not use this file except in compliance with the License.
17139 * You may obtain a copy of the License at
17140 *
17141 * http://www.apache.org/licenses/LICENSE-2.0
17142 *
17143 * Unless required by applicable law or agreed to in writing, software
17144 * distributed under the License is distributed on an "AS IS" BASIS,
17145 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17146 * See the License for the specific language governing permissions and
17147 * limitations under the License.
17148 * =============================================================================
17149 */const fq="return (x >= 0.0) ? x : (exp(x) - 1.0);",mq=`
17150  vec4 result;
17151
17152  result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
17153  result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
17154  result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
17155  result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
17156
17157  return result;
17158`,gq=Te({opSnippet:fq,packedOpSnippet:mq}),yq={kernelName:Ti,backendName:"webgl",kernelFunc:gq};/**
17159 * @license
17160 * Copyright 2020 Google LLC. All Rights Reserved.
17161 * Licensed under the Apache License, Version 2.0 (the "License");
17162 * you may not use this file except in compliance with the License.
17163 * You may obtain a copy of the License at
17164 *
17165 * http://www.apache.org/licenses/LICENSE-2.0
17166 *
17167 * Unless required by applicable law or agreed to in writing, software
17168 * distributed under the License is distributed on an "AS IS" BASIS,
17169 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17170 * See the License for the specific language governing permissions and
17171 * limitations under the License.
17172 * =============================================================================
17173 */const xq="return (b >= 0.0) ? a : a * (b + 1.0);",bq=`
17174  vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
17175  return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
17176`,wq=n=>{const{inputs:e,backend:t}=n,{dy:s,y:r}=e,a=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Za(bq,s.shape,r.shape):new dr(xq,s.shape,r.shape);return t.runWebGLProgram(a,[s,r],s.dtype)},vq={kernelName:bc,backendName:"webgl",kernelFunc:wq};/**
17177 * @license
17178 * Copyright 2020 Google LLC. All Rights Reserved.
17179 * Licensed under the Apache License, Version 2.0 (the "License");
17180 * you may not use this file except in compliance with the License.
17181 * You may obtain a copy of the License at
17182 *
17183 * http://www.apache.org/licenses/LICENSE-2.0
17184 *
17185 * Unless required by applicable law or agreed to in writing, software
17186 * distributed under the License is distributed on an "AS IS" BASIS,
17187 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17188 * See the License for the specific language governing permissions and
17189 * limitations under the License.
17190 * =============================================================================
17191 */const Cq=`
17192  return vec4(equal(a, b));
17193`,$q="return float(a == b);",Nq=Nt({opSnippet:$q,packedOpSnippet:Cq,dtype:"bool",cpuKernelImpl:tU}),Iq={kernelName:qo,backendName:"webgl",kernelFunc:Nq};/**
17194 * @license
17195 * Copyright 2020 Google LLC. All Rights Reserved.
17196 * Licensed under the Apache License, Version 2.0 (the "License");
17197 * you may not use this file except in compliance with the License.
17198 * You may obtain a copy of the License at
17199 *
17200 * http://www.apache.org/licenses/LICENSE-2.0
17201 *
17202 * Unless required by applicable law or agreed to in writing, software
17203 * distributed under the License is distributed on an "AS IS" BASIS,
17204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17205 * See the License for the specific language governing permissions and
17206 * limitations under the License.
17207 * =============================================================================
17208 */const Sq=`
17209  // Error function is calculated approximately with elementary function.
17210  // See "Handbook of Mathematical Functions with Formulas,
17211  // Graphs, and Mathematical Tables", Abramowitz and Stegun.
17212  float p = ${zx};
17213  float a1 = ${Px};
17214  float a2 = ${Lx};
17215  float a3 = ${Fx};
17216  float a4 = ${_x};
17217  float a5 = ${Ox};
17218
17219  float sign = sign(x);
17220  x = abs(x);
17221  float t = 1.0 / (1.0 + p * x);
17222  return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));
17223`,kq=Te({opSnippet:Sq}),Tq={kernelName:aa,backendName:"webgl",kernelFunc:kq};/**
17224 * @license
17225 * Copyright 2020 Google LLC. All Rights Reserved.
17226 * Licensed under the Apache License, Version 2.0 (the "License");
17227 * you may not use this file except in compliance with the License.
17228 * You may obtain a copy of the License at
17229 *
17230 * http://www.apache.org/licenses/LICENSE-2.0
17231 *
17232 * Unless required by applicable law or agreed to in writing, software
17233 * distributed under the License is distributed on an "AS IS" BASIS,
17234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17235 * See the License for the specific language governing permissions and
17236 * limitations under the License.
17237 * =============================================================================
17238 */const Eq=Qa+`
17239  return exp(x);
17240`,Rq=`
17241  vec4 result = exp(x);
17242  bvec4 isNaN = isnan(x);
17243  result.r = isNaN.r ? x.r : result.r;
17244  result.g = isNaN.g ? x.g : result.g;
17245  result.b = isNaN.b ? x.b : result.b;
17246  result.a = isNaN.a ? x.a : result.a;
17247
17248  return result;
17249`,pC=Te({opSnippet:Eq,packedOpSnippet:Rq,cpuKernelImpl:nU,dtype:"float32"}),Dq={kernelName:oa,backendName:"webgl",kernelFunc:pC};/**
17250 * @license
17251 * Copyright 2020 Google LLC. All Rights Reserved.
17252 * Licensed under the Apache License, Version 2.0 (the License);
17253 * you may not use this file except in compliance with the License.
17254 * You may obtain a copy of the License at
17255 *
17256 * http://www.apache.org/licenses/LICENSE-2.0
17257 *
17258 * Unless required by applicable law or agreed to in writing, software
17259 * distributed under the License is distributed on an AS IS BASIS,
17260 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17261 * See the License for the specific language governing permissions and
17262 * limitations under the License.
17263 * =============================================================================
17264 */function Dd(n){const{inputs:e,attrs:t,backend:s}=n,{dim:r}=t,{input:a}=e,o=a.shape.length,i=a.shape.slice();let l=r;return r<0&&(I(-(o+1)<=r,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+r+1),i.splice(l,0,1),ne({inputs:{x:a},backend:s,attrs:{shape:i}})}const Aq={kernelName:Jo,backendName:"webgl",kernelFunc:Dd};/**
17265 * @license
17266 * Copyright 2020 Google LLC. All Rights Reserved.
17267 * Licensed under the Apache License, Version 2.0 (the "License");
17268 * you may not use this file except in compliance with the License.
17269 * You may obtain a copy of the License at
17270 *
17271 * http://www.apache.org/licenses/LICENSE-2.0
17272 *
17273 * Unless required by applicable law or agreed to in writing, software
17274 * distributed under the License is distributed on an "AS IS" BASIS,
17275 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17276 * See the License for the specific language governing permissions and
17277 * limitations under the License.
17278 * =============================================================================
17279 */const By="return exp(x) - 1.0;",Oq=Te({opSnippet:By,packedOpSnippet:By,cpuKernelImpl:sU}),_q={kernelName:ia,backendName:"webgl",kernelFunc:Oq};/**
17280 * @license
17281 * Copyright 2018 Google LLC. All Rights Reserved.
17282 * Licensed under the Apache License, Version 2.0 (the "License");
17283 * you may not use this file except in compliance with the License.
17284 * You may obtain a copy of the License at
17285 *
17286 * http://www.apache.org/licenses/LICENSE-2.0
17287 *
17288 * Unless required by applicable law or agreed to in writing, software
17289 * distributed under the License is distributed on an "AS IS" BASIS,
17290 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17291 * See the License for the specific language governing permissions and
17292 * limitations under the License.
17293 * =============================================================================
17294 */class My{constructor(e,t,s){this.variableNames=["real","imag"];const r=t[1];this.outputShape=t;const a=s?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,o=s?`${r}.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=`
17295      const float exponentMultiplier = ${a};
17296
17297      float unaryOpComplex(float real, float expR, float imag, float expI) {
17298        ${i}
17299      }
17300
17301      float mulMatDFT(int batch, int index) {
17302        float indexRatio = float(index) / float(${r});
17303        float exponentMultiplierTimesIndexRatio =
17304            exponentMultiplier * indexRatio;
17305
17306        float result = 0.0;
17307
17308        for (int i = 0; i < ${r}; i++) {
17309          // x = (-2|2 * PI / N) * index * i;
17310          float x = exponentMultiplierTimesIndexRatio * float(i);
17311          float expR = cos(x);
17312          float expI = sin(x);
17313          float real = getReal(batch, i);
17314          float imag = getImag(batch, i);
17315
17316          result +=
17317              unaryOpComplex(real, expR, imag, expI) / ${o};
17318        }
17319
17320        return result;
17321      }
17322
17323      void main() {
17324        ivec2 coords = getOutputCoords();
17325        setOutput(mulMatDFT(coords[0], coords[1]));
17326      }
17327    `}}/**
17328 * @license
17329 * Copyright 2020 Google LLC. All Rights Reserved.
17330 * Licensed under the Apache License, Version 2.0 (the "License");
17331 * you may not use this file except in compliance with the License.
17332 * You may obtain a copy of the License at
17333 *
17334 * http://www.apache.org/licenses/LICENSE-2.0
17335 *
17336 * Unless required by applicable law or agreed to in writing, software
17337 * distributed under the License is distributed on an "AS IS" BASIS,
17338 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17339 * See the License for the specific language governing permissions and
17340 * limitations under the License.
17341 * =============================================================================
17342 */function fC(n,e,t){const s=t.texData.get(n.dataId),r=H(n.shape),a=n.shape[n.shape.length-1],o=r/a,i=ne({inputs:{x:n},backend:t,attrs:{shape:[o,a]}}),l=i.shape,u=new My("real",l,e),c=new My("imag",l,e),h=[{dataId:s.complexTensorInfos.real.dataId,dtype:s.complexTensorInfos.real.dtype,shape:l},{dataId:s.complexTensorInfos.imag.dataId,dtype:s.complexTensorInfos.imag.dtype,shape:l}],d=t.runWebGLProgram(u,h,"float32"),p=t.runWebGLProgram(c,h,"float32"),f=Bs({inputs:{real:d,imag:p},backend:t});t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p);const g=ne({inputs:{x:f},backend:t,attrs:{shape:n.shape}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(f),g}/**
17343 * @license
17344 * Copyright 2020 Google LLC. All Rights Reserved.
17345 * Licensed under the Apache License, Version 2.0 (the "License");
17346 * you may not use this file except in compliance with the License.
17347 * You may obtain a copy of the License at
17348 *
17349 * http://www.apache.org/licenses/LICENSE-2.0
17350 *
17351 * Unless required by applicable law or agreed to in writing, software
17352 * distributed under the License is distributed on an "AS IS" BASIS,
17353 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17354 * See the License for the specific language governing permissions and
17355 * limitations under the License.
17356 * =============================================================================
17357 */function Fq(n){const{inputs:e,backend:t}=n,{input:s}=e;return fC(s,!1,t)}const Lq={kernelName:Vu,backendName:"webgl",kernelFunc:Fq};/**
17358 * @license
17359 * Copyright 2019 Google LLC. All Rights Reserved.
17360 * Licensed under the Apache License, Version 2.0 (the "License");
17361 * you may not use this file except in compliance with the License.
17362 * You may obtain a copy of the License at
17363 *
17364 * http://www.apache.org/licenses/LICENSE-2.0
17365 *
17366 * Unless required by applicable law or agreed to in writing, software
17367 * distributed under the License is distributed on an "AS IS" BASIS,
17368 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17369 * See the License for the specific language governing permissions and
17370 * limitations under the License.
17371 * =============================================================================
17372 */class Pq{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=`
17373      void main() {
17374        // Input can be obtained from uniform value.
17375        setOutput(value);
17376      }
17377    `}}/**
17378 * @license
17379 * Copyright 2020 Google LLC. All Rights Reserved.
17380 * Licensed under the Apache License, Version 2.0 (the "License");
17381 * you may not use this file except in compliance with the License.
17382 * You may obtain a copy of the License at
17383 *
17384 * http://www.apache.org/licenses/LICENSE-2.0
17385 *
17386 * Unless required by applicable law or agreed to in writing, software
17387 * distributed under the License is distributed on an "AS IS" BASIS,
17388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17389 * See the License for the specific language governing permissions and
17390 * limitations under the License.
17391 * =============================================================================
17392 */function vl(n){const{backend:e,attrs:t}=n,{shape:s,value:r}=t;let{dtype:a}=t;if(a=a||Bx(r),a==="string"){const o=Dt(a,H(s));return o.fill(r),e.makeTensorInfo(s,a,o)}else{const o=new Pq(s,r),i=[[r]];return e.runWebGLProgram(o,[],a,i)}}const zq={kernelName:Zd,backendName:"webgl",kernelFunc:vl};/**
17393 * @license
17394 * Copyright 2020 Google LLC. All Rights Reserved.
17395 * Licensed under the Apache License, Version 2.0 (the "License");
17396 * you may not use this file except in compliance with the License.
17397 * You may obtain a copy of the License at
17398 *
17399 * http://www.apache.org/licenses/LICENSE-2.0
17400 *
17401 * Unless required by applicable law or agreed to in writing, software
17402 * distributed under the License is distributed on an "AS IS" BASIS,
17403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17404 * See the License for the specific language governing permissions and
17405 * limitations under the License.
17406 * =============================================================================
17407 */class Vq{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`
17408        void main() {
17409          ivec4 coords = getOutputCoords();
17410          int x = coords[2];
17411
17412          int coordX = ${t} - x - 1;
17413          float outputValue;
17414          if(coordX >= 0 && coordX < ${t}) {
17415            outputValue = getImage(coords[0], coords[1], coordX, coords[3]);
17416          } else {
17417            outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);
17418          }
17419          setOutput(outputValue);
17420        }
17421    `}}/**
17422 * @license
17423 * Copyright 2020 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, softw
17430are
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 Bq={kernelName:Zu,backendName:"webgl",kernelFunc:({inputs:n,backend:e})=>{const{image:t}=n,s=e,r=new Vq(t.shape);return s.runWebGLProgram(r,[t],t.dtype)}};/**
17437 * @license
17438 * Copyright 2020 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 Wy="return floor(x);",Mq=Te({opSnippet:Wy,packedOpSnippet:Wy,cpuKernelImpl:rU}),Wq={kernelName:la,backendName:"webgl",kernelFunc:Mq};/**
17452 * @license
17453 * Copyright 2020 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 Uq=`
17467  float s = sign(a) * sign(b);
17468  int ia = round(a);
17469  int ib = round(b);
17470  if (ib != 0) {
17471    // Windows (D3D) wants guaranteed non-zero int division at compile-time.
17472    return float(idiv(ia, ib, s));
17473  } else {
17474    return NAN;
17475  }
17476`,Gq=`
17477  ivec4 ia = round(a);
17478  ivec4 ib = round(b);
17479  bvec4 cond = notEqual(ib, ivec4(0));
17480  ivec4 result = ivec4(0);
17481  vec4 s = sign(a) * sign(b);
17482
17483  // Windows (D3D) wants guaranteed non-zero int division at compile-time.
17484  if (cond[0]) {
17485    result[0] = idiv(ia[0], ib[0], s[0]);
17486  }
17487  if (cond[1]) {
17488    result[1] = idiv(ia[1], ib[1], s[1]);
17489  }
17490  if (cond[2]) {
17491    result[2] = idiv(ia[2], ib[2], s[2]);
17492  }
17493  if (cond[3]) {
17494    result[3] = idiv(ia[3], ib[3], s[3]);
17495  }
17496  return vec4(result);
17497`,Hq=Nt({opSnippet:Uq,packedOpSnippet:Gq,dtype:"int32"}),jq={kernelName:Ei,backendName:"webgl",kernelFunc:Hq};/**
17498 * @license
17499 * Copyright 2018 Google LLC. All Rights Reserved.
17500 * Licensed under the Apache License, Version 2.0 (the "License");
17501 * you may not use this file except in compliance with the License.
17502 * You may obtain a copy of the License at
17503 *
17504 * http://www.apache.org/licenses/LICENSE-2.0
17505 *
17506 * Unless required by applicable law or agreed to in writing, software
17507 * distributed under the License is distributed on an "AS IS" BASIS,
17508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17509 * See the License for the specific language governing permissions and
17510 * limitations under the License.
17511 * =============================================================================
17512 */class qq{constructor(e){this.variableNames=["A"];const t=Pt(),[s,r]=e;this.outputShape=e,this.userCode=`
17513      void main() {
17514        ivec3 coords = getOutputCoords();
17515        int texR = coords[0];
17516        int texC = coords[1];
17517        int depth = coords[2];
17518        vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${s}.0);
17519
17520        vec4 values = ${t.texture2D}(A, uv);
17521        float value;
17522        if (depth == 0) {
17523          value = values.r;
17524        } else if (depth == 1) {
17525          value = values.g;
17526        } else if (depth == 2) {
17527          value = values.b;
17528        } else if (depth == 3) {
17529          value = values.a;
17530        }
17531
17532        setOutput(floor(value * 255.0 + 0.5));
17533      }
17534    `}}/**
17535 * @license
17536 * Copyright 2018 Google LLC. All Rights Reserved.
17537 * Licensed under the Apache License, Version 2.0 (the "License");
17538 * you may not use this file except in compliance with the License.
17539 * You may obtain a copy of the License at
17540 *
17541 * http://www.apache.org/licenses/LICENSE-2.0
17542 *
17543 * Unless required by applicable law or agreed to in writing, software
17544 * distributed under the License is distributed on an "AS IS" BASIS,
17545 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17546 * See the License for the specific language governing permissions and
17547 * limitations under the License.
17548 * =============================================================================
17549 */class Kq{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=Pt(),[s,r]=e;this.outputShape=e,this.userCode=`
17550      void main() {
17551        ivec3 coords = getOutputCoords();
17552        int texR = coords[0];
17553        int texC = coords[1];
17554        int depth = coords[2];
17555
17556        vec4 result = vec4(0.);
17557
17558        for(int row=0; row<=1; row++) {
17559          for(int col=0; col<=1; col++) {
17560            texC = coords[1] + row;
17561            depth = coords[2] + col;
17562
17563            vec2 uv = (vec2(texC, texR) + halfCR) /
17564                       vec2(${r}.0, ${s}.0);
17565            vec4 values = ${t.texture2D}(A, uv);
17566            float value;
17567            if (depth == 0) {
17568              value = values.r;
17569            } else if (depth == 1) {
17570              value = values.g;
17571            } else if (depth == 2) {
17572              value = values.b;
17573            } else if (depth == 3) {
17574              value = values.a;
17575            }
17576
17577            result[row * 2 + col] = floor(value * 255.0 + 0.5);
17578          }
17579        }
17580
17581        ${t.output} = result;
17582      }
17583    `}}/**
17584 * @license
17585 * Copyright 2019 Google LLC. All Rights Reserved.
17586 * Licensed under the Apache License, Version 2.0 (the "License");
17587 * you may not use this file except in compliance with the License.
17588 * You may obtain a copy of the License at
17589 *
17590 * http://www.apache.org/licenses/LICENSE-2.0
17591 *
17592 * Unless required by applicable law or agreed to in writing, software
17593 * distributed under the License is distributed on an "AS IS" BASIS,
17594 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17595 * See the License for the specific language governing permissions and
17596 * limitations under the License.
17597 * =============================================================================
17598 */const Xq={kernelName:ql,backendName:"webgl",kernelFunc:Yq};let Sr,Yh=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function Yq(n){const{inputs:e,backend:t,attrs:s}=n;let{pixels:r}=e;const{numChannels:a}=s,o=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement,i=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,[l,u]=o?[r.videoWidth,r.videoHeight]:[r.width,r.height],c=[u,l],h=[u,l,a];if(i||o){const g=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(Sr==null||g!==Yh)&&(Yh=g,Sr=document.createElement("canvas").getContext("2d",{willReadFrequently:Yh})),Sr.canvas.width=l,Sr.canvas.height=u,Sr.drawImage(r,0,0,l,u),r=Sr.canvas}const d=t.makeTensorInfo(c,"int32");t.texData.get(d.dataId).usage=rn.PIXELS,t.gpgpu.uploadPixelDataToTexture(t.getTexture(d.dataId),r);const p=W().getBool("WEBGL_PACK")?new Kq(h):new qq(h),f=t.runWebGLProgram(p,[d],"int32");return t.disposeData(d.dataId),f}/**
17599 * @license
17600 * Copyright 2020 Google LLC. All Rights Reserved.
17601 * Licensed under the Apache License, Version 2.0 (the "License");
17602 * you may not use this file except in compliance with the License.
17603 * You may obtain a copy of the License at
17604 *
17605 * http://www.apache.org/licenses/LICENSE-2.0
17606 *
17607 * Unless required by applicable law or agreed to in writing, software
17608 * distributed under the License is distributed on an "AS IS" BASIS,
17609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17610 * See the License for the specific language governing permissions and
17611 * limitations under the License.
17612 * =============================================================================
17613 */function Jq(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a,bias:o,preluActivationWeights:i}=e,{strides:l,pad:u,dataFormat:c,dilations:h,dimRoundingMode:d,activation:p,leakyreluAlpha:f}=s,g=fr(c),m=Ft(r.shape,a.shape,l,h,u,d,!1,g);let y;const x=[],v=o!=null,b=i!=null,C=p==="leakyrelu",$=()=>{const k=[r,a],T=(E,_)=>{if(_==="NCHW"&&E.shape.length===1&&E.shape[0]!==1){const z=ne({inputs:{x:E},backend:t,attrs:{shape:[E.shape[0],1,1]}});return x.push(z),z}return E};if(v&&k.push(T(o,c)),b&&k.push(T(i,c)),C){const E=t.makeTensorInfo([],"float32",_s(f,"float32"));k.push(E),x.push(E)}return k};if(m.filterHeight===1&&m.filterWidth===1&&m.dilationHeight===1&&m.dilationWidth===1&&m.strideHeight===1&&m.strideWidth===1&&(m.padInfo.type==="SAME"||m.padInfo.type==="VALID"))y=lC({x:r,filter:a,convInfo:m,backend:t,bias:o,activation:p,preluActivationWeights:i,leakyreluAlpha:f});else if(m.strideWidth<=2&&g==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const k=p?To(p,!0):null,T=new iC(m,v,k,b,C),E=[[m.padInfo.top,m.padInfo.left],[m.strideHeight,m.strideWidth],[m.dilationHeight,m.dilationWidth],[m.inHeight,m.inWidth]],_=$();y=t.runWebGLProgram(T,_,"float32",E)}
vendor: 8,238 bytes, lines 17613-17715
17613else if(W().getBool("WEBGL_CONV_IM2COL"))y=uC({x:r,filter:a,convInfo:m,backend:t,bias:o,activation:p,preluActivationWeights:i,leakyreluAlpha:f});else{const k=p?To(p,!1):null,T=new oC(m,v,k,b,C),E=$();y=t.runWebGLProgram(T,E,"float32")}const S=ne({inputs:{x:y},backend:t,attrs:{shape:m.outShape}});return x.push(y),x.forEach(k=>t.disposeIntermediateTensorInfo(k)),S}const Zq={kernelName:go,backendName:"webgl",kernelFunc:Jq};/**
17614 * @license
17615 * Copyright 2020 Google LLC. All Rights Reserved.
17616 * Licensed under the Apache License, Version 2.0 (the "License");
17617 * you may not use this file except in compliance with the License.
17618 * You may obtain a copy of the License at
17619 *
17620 * http://www.apache.org/licenses/LICENSE-2.0
17621 *
17622 * Unless required by applicable law or agreed to in writing, software
17623 * distributed under the License is distributed on an "AS IS" BASIS,
17624 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17625 * See the License for the specific language governing permissions and
17626 * limitations under the License.
17627 * =============================================================================
17628 */function Qq(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,filter:a,bias:o,preluActivationWeights:i}=e,{strides:l,pad:u,dilations:c,dimRoundingMode:h,activation:d,leakyreluAlpha:p}=s,f=[];let g=c;g==null&&(g=[1,1]),I(It(l,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${g}'`);const m=Ft(r.shape,a.shape,l,g,u,h,!0),y=W().getBool("WEBGL_PACK_DEPTHWISECONV")&&m.strideWidth<=2&&m.outChannels/m.inChannels===1,x=d?To(d,y):null,v=[r,a],b=o!=null,C=i!=null,$=d==="leakyrelu";if(b&&v.push(o),C&&v.push(i),$){const E=t.makeTensorInfo([],"float32",_s(p,"float32"));v.push(E),f.push(E)}let S;y?S=new dC(m,b,x,C,$):S=new hC(m,b,x,C,$);const k=[[m.padInfo.top,m.padInfo.left],[m.strideHeight,m.strideWidth],[m.dilationHeight,m.dilationWidth],[m.inHeight,m.inWidth]],T=t.runWebGLProgram(S,v,"float32",k);return f.forEach(E=>t.disposeIntermediateTensorInfo(E)),T}const eK={kernelName:yo,backendName:"webgl",kernelFunc:Qq};class tK{constructor(e,t,s,r){this.sliceDim=e,this.strides=t,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=s;const a=Fe(s.length);let o=`
17629    int index;`;for(let i=0;i<this.sliceDim;i++)o+=`
17630          index = round(getIndices(coords[0], ${i}));
17631          out_of_bounds = out_of_bounds || index < 0;
17632          out_of_bounds = out_of_bounds || index >= ${this.paramsShape[i]};
17633          flattenIndex += index * ${this.strides[i]};`;this.userCode=`
17634         void main() {
17635          ${a} coords = getOutputCoords();
17636          int flattenIndex = 0;
17637          bool out_of_bounds = false;
17638
17639          ${o}
17640
17641          setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));
17642        }
17643      `}}/**
17644 * @license
17645 * Copyright 2020 Google LLC. All Rights Reserved.
17646 * Licensed under the Apache License, Version 2.0 (the "License");
17647 * you may not use this file except in compliance with the License.
17648 * You may obtain a copy of the License at
17649 *
17650 * http://www.apache.org/licenses/LICENSE-2.0
17651 *
17652 * Unless required by applicable law or agreed to in writing, software
17653 * distributed under the License is distributed on an "AS IS" BASIS,
17654 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17655 * See the License for the specific language governing permissions and
17656 * limitations under the License.
17657 * =============================================================================
17658 */function nK(n){const{inputs:e,backend:t}=n,{params:s,indices:r}=e,a=r.shape,o=a[a.length-1],i=H(s.shape),[l,u,c,h]=Mx(s,r),d=ne({inputs:{x:r},backend:t,attrs:{shape:[u,o]}}),p=ne({inputs:{x:s},backend:t,attrs:{shape:[H(s.shape)/c,c]}});if(t.shouldExecuteOnCPU([s,r])||s.dtype==="string"){const y=t.readSync(r.dataId),x=t.bufferSync(s),v=aU(y,x,s.dtype,u,o,c,h,s.shape,i);return t.makeTensorInfo(l,s.dtype,v.values)}const f=new tK(o,h,[u,c],s.shape),g=t.runWebGLProgram(f,[p,d],p.dtype),m=ne({inputs:{x:g},backend:t,attrs:{shape:l}});return t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(g),m}const sK={kernelName:qu,backendName:"webgl",kernelFunc:nK};/**
17659 * @license
17660 * Copyright 2017 Google LLC. All Rights Reserved.
17661 * Licensed under the Apache License, Version 2.0 (the "License");
17662 * you may not use this file except in compliance with the License.
17663 * You may obtain a copy of the License at
17664 *
17665 * http://www.apache.org/licenses/LICENSE-2.0
17666 *
17667 * Unless required by applicable law or agreed to in writing, software
17668 * distributed under the License is distributed on an "AS IS" BASIS,
17669 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17670 * See the License for the specific language governing permissions and
17671 * limitations under the License.
17672 * =============================================================================
17673 */class rK{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const s=Fe(this.rank),r=aK(e);this.userCode=`
17674      void main() {
17675        ${s} resRC = getOutputCoords();
17676        int index = int(getIndices(resRC.x, resRC.z));
17677        float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0;
17678        setOutput(inBounds * getA(${r}));
17679      }
17680    `}}function aK(n,e){const t=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[];for(let r=0;r<n.length;r++)r===2?s.push("index"):s.push(`${t[r]}`);return s.join()}/**
17681 * @license
17682 * Copyright 2020 Google LLC. All Rights Reserved.
17683 * Licensed under the Apache License, Version 2.0 (the "License");
17684 * you may not use this file except in compliance with the License.
17685 * You may obtain a copy of the License at
17686 *
17687 * http://www.apache.org/licenses/LICENSE-2.0
17688 *
17689 * Unless required by applicable law or agreed to in writing, software
17690 * distributed under the License is distributed on an "AS IS" BASIS,
17691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17692 * See the License for the specific language governing permissions and
17693 * limitations under the License.
17694 * =============================================================================
17695 */function mC(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,indices:a}=e,{axis:o,batchDims:i}=s,l=Ie(o,r.shape)[0];if(W().get("DEBUG")){const x=t.readSync(a.dataId),v=r.shape[l];for(let b=0;b<x.length;++b){const C=x[b];I(C<=v-1&&C>=0,()=>`GatherV2: the index value ${C} is not in [0, ${v-1}]`)}}const u=Wx(r,a,l,i),c=H(a.shape),h=[],d=ne({inputs:{x:r},backend:t,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),p=ne({inputs:{x:a},backend:t,attrs:{shape:[u.batchSize,c/u.batchSize]}});h.push(d),h.push(p);const f=[u.batchSize,u.outerSize,c/u.batchSize,u.sliceSize];if(t.shouldExecuteOnCPU([r,a])||r.dtype==="string"){const x=t.bufferSync(p),v=t.bufferSync(d),b=oU(v,x,f);return h.forEach(C=>t.disposeIntermediateTensorInfo(C)),t.makeTensorInfo(u.outputShape,b.dtype,b.values)}const g=new rK(d.shape,f),m=t.runWebGLProgram(g,[d,p],d.dtype);h.push(m);const y=ne({inputs:{x:m},backend:t,attrs:{shape:u.outputShape}});return h.forEach(x=>t.disposeIntermediateTensorInfo(x)),y}const oK={kernelName:Zo,backendName:"webgl",kernelFunc:mC};/**
17696 * @license
17697 * Copyright 2020 Google LLC. All Rights Reserved.
17698 * Licensed under the Apache License, Version 2.0 (the "License");
17699 * you may not use this file except in compliance with the License.
17700 * You may obtain a copy of the License at
17701 *
17702 * http://www.apache.org/licenses/LICENSE-2.0
17703 *
17704 * Unless required by applicable law or agreed to in writing, software
17705 * distributed under the License is distributed on an "AS IS" BASIS,
17706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17707 * See the License for the specific language governing permissions and
17708 * limitations under the License.
17709 * =============================================================================
17710 */const iK="return float(a > b);",lK=`
17711  return vec4(greaterThan(a, b));
17712`,uK=Nt({opSnippet:iK,packedOpSnippet:lK,cpuKernelImpl:iU,dtype:"bool"}),cK={kernelName:Qo,backendName:"webgl",kernelFunc:uK};/**
17713 * @license
17714 * Copyright 2020 Google LLC. All Rights Reserved.
17715 * Licensed under the Apache License, Version 2.0 (the "License");
17716 * you may not use this file except in compliance with the License.
17717 * You may obtain a copy of the License at
17718 *
17719 * http://www.apache.org/licenses/LICENSE-2.0
17720 *
17721 * Unless required by applicable law or agreed to in writing, software
17722 * distributed under the License is distributed on an "AS IS" BASIS,
17723 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17724 * See the License for the specific language governing permissions and
17725 * limitations under the License.
17726 * =============================================================================
17727 */const hK="return float(a >= b);",dK=`
17728  return vec4(greaterThanEqual(a, b));
17729`,pK=Nt({opSnippet:hK,packedOpSnippet:dK,dtype:"bool",cpuKernelImpl:lU}),fK={kernelName:ua,backendName:"webgl",kernelFunc:pK};/**
17730 * @license
17731 * Copyright 2020 Google LLC. All Rights Reserved.
17732 * Licensed under the Apache License, Version 2.0 (the "License");
17733 * you may not use this file except in compliance with the License.
17734 * You may obtain a copy of the License at
17735 *
17736 * http://www.apache.org/licenses/LICENSE-2.0
17737 *
17738 * Unless required by applicable law or agreed to in writing, software
17739 * distributed under the License is distributed on an "AS IS" BASIS,
17740 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17741 * See the License for the specific language governing permissions and
17742 * limitations under the License.
17743 * =============================================================================
17744 */function mK(n){const{inputs:e,backend:t}=n,{input:s}=e;return fC(s,!0,t)}const gK={kernelName:Bu,backendName:"webgl",kernelFunc:mK};/**
17745 * @license
17746 * Copyright 2020 Google LLC. All Rights Reserved.
17747 * Licensed under the Apache License, Version 2.0 (the "License");
17748 * you may not use this file except in compliance with the License.
17749 * You may obtain a copy of the License at
17750 *
17751 * http://www.apache.org/licenses/LICENSE-2.0
17752 *
17753 * Unless required by applicable law or agreed to in writing, software
17754 * distributed under the License is distributed on an "AS IS" BASIS,
17755 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17756 * See the License for the specific language governing permissions and
17757 * limitations under the License.
17758 * =============================================================================
17759 */const yK="return float(!isnan(x) && !isinf(x));",xK=Te({opSnippet:yK,dtype:"bool"}),bK={kernelName:ca,backendName:"webgl",kernelFunc:xK};/**
17760 * @license
17761 * Copyright 2020 Google LLC. All Rights Reserved.
17762 * Licensed under the Apache License, Version 2.0 (the "License");
17763 * you may not use this file except in compliance with the License.
17764 * You may obtain a copy of the License at
17765 *
17766 * http://www.apache.org/licenses/LICENSE-2.0
17767 *
17768 * Unless required by applicable law or agreed to in writing, software
17769 * distributed under the License is distributed on an "AS IS" BASIS,
17770 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17771 * See the License for the specific language governing permissions and
17772 * limitations under the License.
17773 * =============================================================================
17774 */const wK="return float(isinf(x));",vK=Te({opSnippet:wK,dtype:"bool"}),CK={kernelName:ha,backendName:"webgl",kernelFunc:vK};/**
17775 * @license
17776 * Copyright 2020 Google LLC. All Rights Reserved.
17777 * Licensed under the Apache License, Version 2.0 (the "License");
17778 * you may not use this file except in compliance with the License.
17779 * You may obtain a copy of the License at
17780 *
17781 * http://www.apache.org/licenses/LICENSE-2.0
17782 *
17783 * Unless required by applicable law or agreed to in writing, software
17784 * distributed under the License is distributed on an "AS IS" BASIS,
17785 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17786 * See the License for the specific language governing permissions and
17787 * limitations under the License.
17788 * =============================================================================
17789 */const $K="return float(isnan(x));",NK=Te({opSnippet:$K,dtype:"bool"}),IK={kernelName:da,backendName:"webgl",kernelFunc:NK};/**
17790 * @license
17791 * Copyright 2020 Google LLC. All Rights Reserved.
17792 * Licensed under the Apache License, Version 2.0 (the "License");
17793 * you may not use this file except in compliance with the License.
17794 * You may obtain a copy of the License at
17795 *
17796 * http://www.apache.org/licenses/LICENSE-2.0
17797 *
17798 * Unless required by applicable law or agreed to in writing, software
17799 * distributed under the License is distributed on an "AS IS" BASIS,
17800 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17801 * See the License for the specific language governing permissions and
17802 * limitations under the License.
17803 * =============================================================================
17804 */const SK="return float(a < b);",kK=`
17805  return vec4(lessThan(a, b));
17806`,TK=Nt({opSnippet:SK,packedOpSnippet:kK,cpuKernelImpl:uU,dtype:"bool"}),EK={kernelName:ei,backendName:"webgl",kernelFunc:TK};/**
17807 * @license
17808 * Copyright 2020 Google LLC. All Rights Reserved.
17809 * Licensed under the Apache License, Version 2.0 (the "License");
17810 * you may not use this file except in compliance with the License.
17811 * You may obtain a copy of the License at
17812 *
17813 * http://www.apache.org/licenses/LICENSE-2.0
17814 *
17815 * Unless required by applicable law or agreed to in writing, software
17816 * distributed under the License is distributed on an "AS IS" BASIS,
17817 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17818 * See the License for the specific language governing permissions and
17819 * limitations under the License.
17820 * =============================================================================
17821 */const RK="return float(a <= b);",DK=`
17822  return vec4(lessThanEqual(a, b));
17823`,AK=Nt({opSnippet:RK,packedOpSnippet:DK,cpuKernelImpl:cU,dtype:"bool"}),OK={kernelName:ti,backendName:"webgl",kernelFunc:AK};/**
17824 * @license
17825 * Copyright 2020 Google LLC. All Rights Reserved.
17826 * Licensed under the Apache License, Version 2.0 (the "License");
17827 * you may not use this file except in compliance with the License.
17828 * You may obtain a copy of the License at
17829 *
17830 * http://www.apache.org/licenses/LICENSE-2.0
17831 *
17832 * Unless required by applicable law or agreed to in writing, software
17833 * distributed under the License is distributed on an "AS IS" BASIS,
17834 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17835 * See the License for the specific language governing permissions and
17836 * limitations under the License.
17837 * =============================================================================
17838 */function _K(n){const{backend:e,attrs:t}=n,{start:s,stop:r,num:a}=t,o=hU(s,r,a);return e.makeTensorInfo([o.length],"float32",o)}const FK={kernelName:Ru,backendName:"webgl",kernelFunc:_K};/**
17839 * @license
17840 * Copyright 2020 Google LLC. All Rights Reserved.
17841 * Licensed under the Apache License, Version 2.0 (the "License");
17842 * you may not use this file except in compliance with the License.
17843 * You may obtain a copy of the License at
17844 *
17845 * http://www.apache.org/licenses/LICENSE-2.0
17846 *
17847 * Unless required by applicable law or agreed to in writing, software
17848 * distributed under the License is distributed on an "AS IS" BASIS,
17849 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17850 * See the License for the specific language governing permissions and
17851 * limitations under the License.
17852 * =============================================================================
17853 */const LK=Qa+`
17854  return x < 0.0 ? 0./0. : log(x);
17855`,PK=`
17856  vec4 result = log(x);
17857  bvec4 isNaN = isnan(x);
17858  result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);
17859  result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);
17860  result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);
17861  result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);
17862  return result;
17863`,zK=Te({opSnippet:LK,packedOpSnippet:PK,cpuKernelImpl:dU}),VK={kernelName:pa,backendName:"webgl",kernelFunc:zK};/**
17864 * @license
17865 * Copyright 2020 Google LLC. All Rights Reserved.
17866 * Licensed under the Apache License, Version 2.0 (the "License");
17867 * you may not use this file except in compliance with the License.
17868 * You may obtain a copy of the License at
17869 *
17870 * http://www.apache.org/licenses/LICENSE-2.0
17871 *
17872 * Unless required by applicable law or agreed to in writing, softw
17872are
17873 * distributed under the License is distributed on an "AS IS" BASIS,
17874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17875 * See the License for the specific language governing permissions and
17876 * limitations under the License.
17877 * =============================================================================
17878 */const BK=Qa+`
17879  return log(1.0 + x);
17880`,MK=Te({opSnippet:BK}),WK={kernelName:fa,backendName:"webgl",kernelFunc:MK};/**
17881 * @license
17882 * Copyright 2020 Google LLC. All Rights Reserved.
17883 * Licensed under the Apache License, Version 2.0 (the "License");
17884 * you may not use this file except in compliance with the License.
17885 * You may obtain a copy of the License at
17886 *
17887 * http://www.apache.org/licenses/LICENSE-2.0
17888 *
17889 * Unless required by applicable law or agreed to in writing, software
17890 * distributed under the License is distributed on an "AS IS" BASIS,
17891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17892 * See the License for the specific language governing permissions and
17893 * limitations under the License.
17894 * =============================================================================
17895 */const UK="return float(a >= 1.0 && b >= 1.0);",GK=`
17896  return vec4(
17897    vec4(greaterThanEqual(a, vec4(1.0))) *
17898    vec4(greaterThanEqual(b, vec4(1.0))));
17899`,HK=Nt({opSnippet:UK,packedOpSnippet:GK,dtype:"bool"}),jK={kernelName:ri,backendName:"webgl",kernelFunc:HK};/**
17900 * @license
17901 * Copyright 2020 Google LLC. All Rights Reserved.
17902 * Licensed under the Apache License, Version 2.0 (the "License");
17903 * you may not use this file except in compliance with the License.
17904 * You may obtain a copy of the License at
17905 *
17906 * http://www.apache.org/licenses/LICENSE-2.0
17907 *
17908 * Unless required by applicable law or agreed to in writing, software
17909 * distributed under the License is distributed on an "AS IS" BASIS,
17910 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17911 * See the License for the specific language governing permissions and
17912 * limitations under the License.
17913 * =============================================================================
17914 */const qK="return float(!(x >= 1.0));",KK=Te({opSnippet:qK}),XK={kernelName:ai,backendName:"webgl",kernelFunc:KK};/**
17915 * @license
17916 * Copyright 2020 Google LLC. All Rights Reserved.
17917 * Licensed under the Apache License, Version 2.0 (the "License");
17918 * you may not use this file except in compliance with the License.
17919 * You may obtain a copy of the License at
17920 *
17921 * http://www.apache.org/licenses/LICENSE-2.0
17922 *
17923 * Unless required by applicable law or agreed to in writing, software
17924 * distributed under the License is distributed on an "AS IS" BASIS,
17925 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17926 * See the License for the specific language governing permissions and
17927 * limitations under the License.
17928 * =============================================================================
17929 */const YK="return float(a >= 1.0 || b >= 1.0);",JK=`
17930  return min(
17931    vec4(greaterThanEqual(a, vec4(1.0))) +
17932    vec4(greaterThanEqual(b, vec4(1.0))),
17933    vec4(1.0));
17934`,ZK=Nt({opSnippet:YK,packedOpSnippet:JK,dtype:"bool"}),QK={kernelName:oi,backendName:"webgl",kernelFunc:ZK};/**
17935 * @license
17936 * Copyright 2017 Google LLC. All Rights Reserved.
17937 * Licensed under the Apache License, Version 2.0 (the "License");
17938 * you may not use this file except in compliance with the License.
17939 * You may obtain a copy of the License at
17940 *
17941 * http://www.apache.org/licenses/LICENSE-2.0
17942 *
17943 * Unless required by applicable law or agreed to in writing, software
17944 * distributed under the License is distributed on an "AS IS" BASIS,
17945 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17946 * See the License for the specific language governing permissions and
17947 * limitations under the License.
17948 * =============================================================================
17949 */class eX{constructor(e,t,s,r,a){this.variableNames=["x"],this.outputShape=[];const o=t,i=e[3]-1;this.outputShape=e;let l;const u=`float(${s}) + float(${r}) * sum`;a===.5?l=`inversesqrt(${u})`:a===1?l=`1.0/(${u})`:l=`exp(log(${u}) * float(-${a}));`,this.userCode=`
17950      void main() {
17951        ivec4 coords = getOutputCoords();
17952        int b = coords[0];
17953        int r = coords[1];
17954        int c = coords[2];
17955        int d = coords[3];
17956        float x = getX(b, r, c, d);
17957        float sum = 0.0;
17958        for (int j = -${o}; j <= ${o}; j++) {
17959          int idx = d + j;
17960          if (idx >= 0 && idx <=  ${i}) {
17961            float z = getX(b, r, c, idx);
17962            sum += z * z;
17963          }
17964        }
17965        float val = x * ${l};
17966        setOutput(val);
17967      }
17968    `}}/**
17969 * @license
17970 * Copyright 2019 Google LLC. All Rights Reserved.
17971 * Licensed under the Apache License, Version 2.0 (the "License");
17972 * you may not use this file except in compliance with the License.
17973 * You may obtain a copy of the License at
17974 *
17975 * http://www.apache.org/licenses/LICENSE-2.0
17976 *
17977 * Unless required by applicable law or agreed to in writing, software
17978 * distributed under the License is distributed on an "AS IS" BASIS,
17979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17980 * See the License for the specific language governing permissions and
17981 * limitations under the License.
17982 * =============================================================================
17983 */class tX{constructor(e,t,s,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const o=t,i=e[3]-1;this.outputShape=e;let l;const u=`float(${s}) + float(${r}) * sum`;a===.5?l=`inversesqrt(${u})`:a===1?l=`1.0/(${u})`:l=`exp(log(${u}) * float(-${a}));`,this.userCode=`
17984      void main() {
17985        ivec4 coords = getOutputCoords();
17986        int b = coords.x;
17987        int r = coords.y;
17988        int c = coords.z;
17989        int d = coords.w;
17990
17991        bool hasNextCol = d < ${this.outputShape[3]};
17992        bool hasNextRow = c < ${this.outputShape[2]};
17993
17994        vec4 sum = vec4(0.);
17995        vec4 xFragAtOutputCoords = getX(b, r, c, d);
17996
17997        vec4 xAtOutputCoords = vec4(
17998          getChannel(xFragAtOutputCoords, vec2(c, d)),
17999          hasNextCol ?
18000            getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,
18001          hasNextRow ?
18002            getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,
18003          (hasNextRow && hasNextCol) ?
18004            getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0
18005        );
18006
18007        int firstChannel = d - ${o};
18008        vec2 cache = vec2(0.);
18009        if(firstChannel >= 0){
18010          vec4 firstChannelFrag = getX(b, r, c, firstChannel);
18011          cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));
18012            if(hasNextRow){
18013              cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));
18014            }
18015        }
18016
18017        ivec2 depth = ivec2(d, d + 1);
18018        for (int j = - ${o}; j <= ${o}; j++) {
18019          ivec2 idx = depth + j;
18020          bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));
18021          bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${i}));
18022
18023          bool depthInRange = aboveLowerBound.x && belowUpperBound.x;
18024          bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;
18025
18026          if(depthInRange || depthPlusOneInRange){
18027            vec4 z = vec4(0.);
18028            vec4 xFragAtCurrentDepth;
18029            z.xz = cache.xy;
18030            if(depthPlusOneInRange && hasNextCol){
18031              xFragAtCurrentDepth = idx.y != d ?
18032                getX(b, r, c, idx.y) : xFragAtOutputCoords;
18033              z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));
18034              if(hasNextRow){
18035                z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));
18036              }
18037            }
18038            cache.xy = z.yw;
18039            sum += z * z;
18040          }
18041        }
18042        vec4 result = xAtOutputCoords * ${l};
18043        setOutput(result);
18044      }
18045    `}}/**
18046 * @license
18047 * Copyright 2020 Google LLC. All Rights Reserved.
18048 * Licensed under the Apache License, Version 2.0 (the "License");
18049 * you may not use this file except in compliance with the License.
18050 * You may obtain a copy of the License at
18051 *
18052 * http://www.apache.org/licenses/LICENSE-2.0
18053 *
18054 * Unless required by applicable law or agreed to in writing, software
18055 * distributed under the License is distributed on an "AS IS" BASIS,
18056 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18057 * See the License for the specific language governing permissions and
18058 * limitations under the License.
18059 * =============================================================================
18060 */const nX=n=>{const{inputs:e,backend:t,attrs:s}=n,{x:r}
18060=e,{depthRadius:a,bias:o,alpha:i,beta:l}=s,u=W().getBool("WEBGL_PACK_NORMALIZATION")?new tX(r.shape,a,o,i,l):new eX(r.shape,a,o,i,l);return t.runWebGLProgram(u,[r],r.dtype)},sX={kernelName:ni,backendName:"webgl",kernelFunc:nX};/**
18061 * @license
18062 * Copyright 2018 Google LLC. All Rights Reserved.
18063 * Licensed under the Apache License, Version 2.0 (the "License");
18064 * you may not use this file except in compliance with the License.
18065 * You may obtain a copy of the License at
18066 *
18067 * http://www.apache.org/licenses/LICENSE-2.0
18068 *
18069 * Unless required by applicable law or agreed to in writing, software
18070 * distributed under the License is distributed on an "AS IS" BASIS,
18071 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18072 * See the License for the specific language governing permissions and
18073 * limitations under the License.
18074 * =============================================================================
18075 */class rX{constructor(e,t,s,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=s,this.alpha=r,this.beta=a,this.userCode=`
18076      void main() {
18077        ivec4 coords = getOutputCoords();
18078        int b = coords[0];
18079        int r = coords[1];
18080        int c = coords[2];
18081
18082        float result = 0.0;
18083        for (int d = 0; d < ${this.depth}; ++d) {
18084          int depthBegin = int(max(0.0, float(d - ${t})));
18085          int depthEnd = int(min(float(${this.depth}),
18086              float(d + ${t} + 1)));
18087
18088          const int MIN_DEPTH_BEGIN = 0;
18089          const int MAX_DEPTH_END = ${this.depth};
18090
18091          float norm = 0.0;
18092          for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {
18093            if (k < depthBegin){
18094              continue;
18095            }
18096            else if (k >= depthBegin && k < depthEnd) {
18097              norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);
18098            }
18099            else {
18100              break;
18101            }
18102          }
18103
18104          norm = float(${r}) * norm + float(${s});
18105
18106          for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){
18107            if (k < depthBegin){
18108              continue;
18109            }
18110            else if (k >= depthBegin && k < depthEnd){
18111              float dyi = -2.0 * float(${r})
18112                * float(${a})
18113                * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d)
18114                / norm;
18115              if (k == d) {
18116                dyi += pow(norm, -1.0 * ${a});
18117              }
18118              if (k == coords[3]) {
18119                dyi *= getDy(b, r, c, d);
18120                result += dyi;
18121              }
18122            }
18123            else {
18124              break;
18125            }
18126          }
18127      }
18128      setOutput(result);
18129      }
18130    `}}/**
18131 * @license
18132 * Copyright 2020 Google LLC. All Rights Reserved.
18133 * Licensed under the Apache License, Version 2.0 (the "License");
18134 * you may not use this file except in compliance with the License.
18135 * You may obtain a copy of the License at
18136 *
18137 * http://www.apache.org/licenses/LICENSE-2.0
18138 *
18139 * Unless required by applicable law or agreed to in writing, software
18140 * distributed under the License is distributed on an "AS IS" BASIS,
18141 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18142 * See the License for the specific language governing permissions and
18143 * limitations under the License.
18144 * =============================================================================
18145 */const aX=n=>{const{inputs:e,backend:t,attrs:s}=n,{x:r,y:a,dy:o}=e,{depthRadius:i,bias:l,alpha:u,beta:c}=s,h=new rX(r.shape,i,l,u,c);return t.runWebGLProgram(h,[r,a,o],r.dtype)},oX={kernelName:Cc,backendName:"webgl",kernelFunc:aX};/**
18146 * @license
18147 * Copyright 2020 Google LLC. All Rights Reserved.
18148 * Licensed under the Apache License, Version 2.0 (the "License");
18149 * you may not use this file except in compliance with the License.
18150 * You may obtain a copy of the License at
18151 *
18152 * http://www.apache.org/licenses/LICENSE-2.0
18153 *
18154 * Unless required by applicable law or agreed to in writing, software
18155 * distributed under the License is distributed on an "AS IS" BASIS,
18156 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18157 * See the License for the specific language governing permissions and
18158 * limitations under the License.
18159 * =============================================================================
vendor: 4,160 bytes, lines 18160-18217
18160 */function iX(n,e,t,s){const r=H(e),o=H(n.shape)/r,i=ne({inputs:{x:n},attrs:{shape:[o,r]},backend:s}),l=Nr(i,n.dtype,"max",s),u=ne({inputs:{x:l},attrs:{shape:t},backend:s});return s.disposeIntermediateTensorInfo(i),s.disposeIntermediateTensorInfo(l),u}/**
18161 * @license
18162 * Copyright 2020 Google LLC. All Rights Reserved.
18163 * Licensed under the Apache License, Version 2.0 (the "License");
18164 * you may not use this file except in compliance with the License.
18165 * You may obtain a copy of the License at
18166 *
18167 * http://www.apache.org/licenses/LICENSE-2.0
18168 *
18169 * Unless required by applicable law or agreed to in writing, software
18170 * distributed under the License is distributed on an "AS IS" BASIS,
18171 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18172 * See the License for the specific language governing permissions and
18173 * limitations under the License.
18174 * =============================================================================
18175 */function gC(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{reductionIndices:a,keepDims:o}=s,i=r.shape.length,l=Ie(a,r.shape);let u=l;const c=Xe(u,i),h=c!=null,d=t.shouldExecuteOnCPU([r]);let p=r;if(h){if(d){const v=t.texData.get(p.dataId).values,b=new Array(i);for(let S=0;S<b.length;S++)b[S]=r.shape[c[S]];const C=mg(v,r.shape,r.dtype,c,b);p=t.makeTensorInfo(b,r.dtype);const $=t.texData.get(p.dataId);$.values=C}else p=Lh(r,c,t);u=st(u.length,i)}St("max",u,i);const[f,g]=Ct(p.shape,u);let m=f;o&&(m=nt(f,l));let y;if(d){const v=t.texData.get(p.dataId).values,b=pU(v,H(g),m,r.dtype);y=t.makeTensorInfo(m,r.dtype);const C=t.texData.get(y.dataId);C.values=b}else y=iX(p,g,m,t);return h&&t.disposeIntermediateTensorInfo(p),y}const lX={kernelName:Xo,backendName:"webgl",kernelFunc:gC};/**
18176 * @license
18177 * Copyright 2020 Google LLC. All Rights Reserved.
18178 * Licensed under the Apache License, Version 2.0 (the "License");
18179 * you may not use this file except in compliance with the License.
18180 * You may obtain a copy of the License at
18181 *
18182 * http://www.apache.org/licenses/LICENSE-2.0
18183 *
18184 * Unless required by applicable law or agreed to in writing, software
18185 * distributed under the License is distributed on an "AS IS" BASIS,
18186 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18187 * See the License for the specific language governing permissions and
18188 * limitations under the License.
18189 * =============================================================================
18190 */const uX=gg+`
18191  return max(a, b);
18192`,cX=`
18193  vec4 result = vec4(max(a, b));
18194  bvec4 isNaNA = isnan(a);
18195  bvec4 isNaNB = isnan(b);
18196  bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
18197  `+$r+`
18198  return result;
18199`,hX=Nt({opSnippet:uX,packedOpSnippet:cX,cpuKernelImpl:fU}),dX={kernelName:Ri,backendName:"webgl",kernelFunc:hX};/**
18200 * @license
18201 * Copyright 2020 Google LLC. All Rights Reserved.
18202 * Licensed under the Apache License, Version 2.0 (the "License");
18203 * you may not use this file except in compliance with the License.
18204 * You may obtain a copy of the License at
18205 *
18206 * http://www.apache.org/licenses/LICENSE-2.0
18207 *
18208 * Unless required by applicable law or agreed to in writing, software
18209 * distributed under the License is distributed on an "AS IS" BASIS,
18210 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18211 * See the License for the specific language governing permissions and
18212 * limitations under the License.
18213 * =============================================================================
18214 */function pX(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e;qa(r,"maxPool");const{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;I(It(o,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);const c=_n(r.shape,a,o,u,i,l);if(c.filterWidth===1&&c.filterHeight===1&&ke(c.inShape,c.outShape))return Qt({inputs:{x:r},backend:t});const h=new Eo(c,"max",!1);return t.runWebGLProgram(h,[r],r.dtype)}const fX={kernelName:ii,backendName:"webgl",kernelFunc:pX};/**
18215 * @license
18216 * Copyright 2020 Google LLC. All Rights Reserved.
18217 * Licensed under the Apache License, Version 2.0 (the "License");
18218 * you may not use this file except in compliance with the License.
18219 * You may obtain a copy of the License at
18220 *
18221 * http://www.apache.org/licenses/LICENSE-2.0
18222 *
18223 * Unless required by applicable law or agreed to in writing, software
18224 * distributed under the License is distributed on an "AS IS" BASIS,
18225 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18226 * See the License for the specific language governing permissions and
18227 * limitations under the License.
18228 * =============================================================================
18229 */function mX(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{filterSize:a,strides:o,pad:i,dataFormat:l,dimRoundingMode:u}=s,c=[1,1,1],h=Fs(r.shape,a,o,c,i,u,l),d=new xg(h,"max",!1);return t.runWebGLProgram(d,[r],r.dtype)}const gX={kernelName:li,backendName:"webgl",kernelFunc:mX};/**
18230 * @license
18231 * Copyright 2017 Google LLC. All Rights Reserved.
18232 * Licensed under the Apache License, Version 2.0 (the "License");
18233 * you may not use this file except in compliance with the License.
18234 * You may obtain a copy of the License at
18235 *
18236 * http://www.apache.org/licenses/LICENSE-2.0
18237 *
18238 * Unless required by applicable law or agreed to in writing, software
18239 * distributed under the License is distributed on an "AS IS" BASIS,
18240 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18241 * See the License for the specific language governing permissions and
18242 * limitations under the License.
18243 * =============================================================================
18244 */class yX{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,s=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,o=e.effectiveFilterWidth,i=a-1-e.padInfo.top,l=o-1-e.padInfo.left,u=a*o-1;this.userCode=`
18245      const ivec2 pads = ivec2(${i}, ${l});
18246
18247      void main() {
18248        ivec4 coords = getOutputCoords();
18249        int b = coords[0];
18250        int d = coords[3];
18251
18252        ivec2 dyRCCorner = coords.yz - pads;
18253        int dyRCorner = dyRCCorner.x;
18254        int dyCCorner = dyRCCorner.y;
18255
18256        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
18257        // ? = to be determined. : = across all values in that axis.
18258        float dotProd = 0.0;
18259        for (int wR = 0; wR < ${a};
18260          wR += ${r}) {
18261          float dyR = float(dyRCorner + wR) / ${t}.0;
18262
18263          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
18264            continue;
18265          }
18266          int idyR = int(dyR);
18267
18268          for (int wC = 0; wC < ${o}; wC++) {
18269            float dyC = float(dyCCorner + wC) / ${s}.0;
18270
18271            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
18272                fract(dyC) > 0.0) {
18273              continue;
18274            }
18275            int idyC = int(dyC);
18276
18277            float dyValue = getDy(b, idyR, idyC, d);
18278            int maxPosValue = ${u} - int(getMaxPos(b, idyR, idyC, d));
18279
18280            // Get the current value, check it against the value from the
18281            // position matrix.
18282            int curPosValue = wR * ${o} + wC;
18283            float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
18284
18285            dotProd += dyValue * mask;
18286          }
18287        }
18288        setOutput(dotProd);
18289      }
18290    `}}class xX{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,s=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,o=e.dilationHeight,i=e.dilationWidth,l=e.effectiveFilterDepth,u=e.effectiveFilterHeight,c=e.effectiveFilterWidth,h=l-1-e.padInfo.front,d=u-1-e.padInfo.top,p=c-1-e.padInfo.left,f=l*u*c-1;this.userCode=`
18291      const ivec3 pads = ivec3(${h}, ${d}, ${p});
18292
18293      void main() {
18294        ivec5 coords = getOutputCoords();
18295        int batch = coords.x;
18296        int ch = coords.u;
18297
18298        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
18299        int dyDCorner = dyCorner.x;
18300        int dyRCorner = dyCorner.y;
18301        int dyCCorner = dyCorner.z;
18302
18303        // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get
18304        // dx(xD, xR, xC, ch).
18305        // ? = to be determined. : = across all values in that axis.
18306        float dotProd = 0.0;
18307
18308        for (int wD = 0; wD < ${l};
18309           wD += ${a}) {
18310          float dyD = float(dyDCorner + wD) / ${t}.0;
18311
18312          if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
18313            continue;
18314          }
18315          int idyD = int(dyD);
18316
18317          for (int wR = 0; wR < ${u};
18318              wR += ${o}) {
18319            float dyR = float(dyRCorner + wR) / ${s}.0;
18320
18321            if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
18322                fract(dyR) > 0.0) {
18323              continue;
18324            }
18325            int idyR = int(dyR);
18326
18327            for (int wC = 0; wC < ${c};
18328                wC += ${i}) {
18329              float dyC = float(dyCCorner + wC) / ${r}.0;
18330
18331              if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
18332                  fract(dyC) > 0.0) {
18333                continue;
18334              }
18335              int idyC = int(dyC);
18336
18337              float dyValue = getDy(batch, idyD, idyR, idyC, ch);
18338              int maxPosValue = ${f} -
18339                  int(getMaxPos(batch, idyD, idyR, idyC, ch));
18340
18341              // Get the current value, check it against the value from the
18342              // position matrix.
18343              int curPosValue =
18344                  wD * ${u} * ${c} +
18345                  wR * ${c} + wC;
18346              float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
18347
18348              dotProd += dyValue * mask;
18349            }
18350          }
18351        }
18352        setOutput(dotProd);
18353      }
18354    `}}/**
18355 * @license
18356 * Copyright 2020 Google LLC. All Rights Reserved.
18357 * Licensed under the Apache License, Version 2.0 (the "License");
18358 * you may not use this file except in compliance with the License.
18359 * You may obtain a copy of the License at
18360 *
18361 * http://www.apache.org/licenses/LICENSE-2.0
18362 *
18363 * Unless required by applicable law or agreed to in writing, software
18364 * distributed under the License is distributed on an "AS IS" BASIS,
18365 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18366 * See the License for the specific language governing permissions and
18367 * limitations under the License.
18368 * =============================================================================
18369 */function bX(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a}=e,o=a,{filterSize:i,strides:l,pad:u,dimRoundingMode:c}=s,h=[1,1,1],d=Fs(o.shape,i,l,h,u,c),p=new xg(d,"max",!0),f=t.runWebGLProgram(p,[o],o.dtype),g=new xX(d),m=t.runWebGLProgram(g,[r,f],o.dtype);return t.disposeIntermediateTensorInfo(f),m}const wX={kernelName:$c,backendName:"webgl",kernelFunc:bX};/**
18370 * @license
18371 * Copyright 2020 Google LLC. All Rights Reserved.
18372 * Licensed under the Apache License, Version 2.0 (the "License");
18373 * you may not use this file except in compliance with the License.
18374 * You may obtain a copy of the License at
18375 *
18376 * http://www.apache.org/licenses/LICENSE-2.0
18377 *
18378 * Unless required by applicable law or agreed to in writing, software
18379 * distributed under the License is distributed on an "AS IS" BASIS,
18380 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18381 * See the License for the specific language governing permissions and
18382 * limitations under the License.
18383 * =============================================================================
18384 */function vX(n){const{inputs:e,backend:t,attrs:s}=n,{dy:r,input:a,output:o}=e,i=a;qa([a,o],"maxPoolGrad");const{filterSize:l,strides:u,pad:c,dimRoundingMode:h}=s,d=_n(i.shape,l,u,1,c,h),p=!0,f=new Eo(d,"max",p),g=t.runWebGLProgram(f,[i],i.dtype),m=new yX(d),y=t.runWebGLProgram(m,[r,g],i.dtype);return t.disposeIntermediateTensorInfo(g),y}const CX={kernelName:Nc,backendName:"webgl",kernelFunc:vX};/**
18385 * @license
18386 * Copyright 2020 Google LLC. All Rights Reserved.
18387 * Licensed under the Apache License, Version 2.0 (the "License");
18388 * you may not use this file except in compliance with the License.
18389 * You may obtain a copy of the License at
18390 *
18391 * http://www.apache.org/licenses/LICENSE-2.0
18392 *
18393 * Unless required by applicable law or agreed to in writing, software
18394 * distributed under the License is distributed on an "AS IS" BASIS,
18395 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18396 * See the License for the specific language governing permissions and
18397 * limitations under the License.
18398 * =============================================================================
18399 */function $X(n,e,t,s){let r=new Eo(t,"max",!1);const a=s.runWebGLProgram(r,[n],"float32");r=new Eo(t,"max",!0,!0,e);const o=s.runWebGLProgram(r,[n],"float32");return[a,o]}/**
18400 * @license
18401 * Copyright 2020 Google LLC. All Rights Reserved.
18402 * Licensed under the Apache License, Version 2.0 (the "License");
18403 * you may not use this file except in compliance with the License.
18404 * You may obtain a copy of the License at
18405 *
18406 * http://www.apache.org/licenses/LICENSE-2.0
18407 *
18408 * Unless required by applicable law or agreed to in writing, software
18409 * distributed under the License is distributed on an "AS IS" BASIS,
18410 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18411 * See the License for the specific language governing permissions and
18412 * limitations under the License.
18413 * =============================================================================
18414 */const NX={kernelName:Au,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{filterSize:r,strides:a,pad:o,includeBatchInIndex:i}=e,l=t;I(s.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`);const u=[1,1];I(It(a,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);const c=_n(s.shape,r,a,u,o),[h,d]=$X(s,i,c,l);return[h,d]}};/**
18415 * @license
18416 * Copyright 2020 Google LLC. All Rights Reserved.
18417 * Licensed under the Apache License, Version 2.0 (the "License");
18418 * you may not use this file except in compliance with the License.
18419 * You may obtain a copy of the License at
18420 *
18421 * http://www.apache.org/licenses/LICENSE-2.0
18422 *
18423 * Unless required by applicable law or agreed to in writing, software
18424 * distributed under the License is distributed on an "AS IS" BASIS,
18425 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18426 * See the License for the specific language governing permissions and
18427 * limitations under the License.
18428 * =============================================================================
18429 */function IX(n,e,t,s){const r=H(e),o=H(n.shape)/r,i=ne({inputs:{x:n},attrs:{shape:[o,r]},backend:s}),l=Nr(i,"float32","mean",s),u=ne({inputs:{x:l},attrs:{shape:t},backend:s});return s.disposeIntermediateTensorInfo(i),s.disposeIntermediateTensorInfo(l),u}/**
18430 * @license
18431 * Copyright 2020 Google LLC. All Rights Reserved.
18432 * Licensed under the Apache License, Version 2.0 (the "License");
18433 * you may not use this file except in compliance with the License.
18434 * You may obtain a copy of the License at
18435 *
18436 * http://www.apache.org/licenses/LICENSE-2.0
18437 *
18438 * Unless required by applicable law or agreed to in writing, software
18439 * distributed under the License is distributed on an "AS IS" BASIS,
18440 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18441 * See the License for the specific language governing permissions and
18442 * limitations under the License.
18443 * =============================================================================
18444 */const SX={kernelName:ui,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:s}=n,{keepDims:r,axis:a}=e,o=t,i=s.shape.length,l=Ie(a,s.shape);let u=l;const c=Xe(u,i),h=c!=null,d=o.shouldExecuteOnCPU([s]),p=[];let f=s;if(h){if(d){const b=o.texData.get(f.dataId).values,C=new Array(i);for(let k=0;k<C.length;k++)C[k]=s.shape[c[k]];const $=mg(b,s.shape,s.dtype,c,C);f=o.makeTensorInfo(C,s.dtype);const S=o.texData.get(f.dataId);S.values=$}else f=Lh(s,c,o);p.push(f),u=st(u.length,i)}St("sum",u,i);const[g,m]=Ct(f.shape,u);let y=g;r&&(y=nt(g,l));const x=IX(f,m,y,o);for(const v of p)o.disposeIntermediateTensorInfo(v);return x}};/**
18445 * @license
18446 * Copyright 2020 Google LLC. All Rights Reserved.
18447 * Licensed under the Apache License, Version 2.0 (the "License");
18448 * you may not use this file except in compliance with the License.
18449 * You may obtain a copy of the License at
18450 *
18451 * http://www.apache.org/licenses/LICENSE-2.0
18452 *
18453 * Unless required by applicable law or agreed to in writing, software
18454 * distributed under the License is distributed on an "AS IS" BASIS,
18455 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18456 * See the License for the specific language governing permissions and
18457 * limitations under the License.
18458 * =============================================================================
18459 */function kX(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s,i=r.shape.length,l=Ie(a,r.shape);let u=l;const c=Xe(u,i);let h=r;c!=null&&(h=_t({inputs:{x:r},backend:t,attrs:{perm:c}}),u=st(u.length,r.shape.length)),St("min",u,i);const[d,p]=Ct(h.shape,u),f=H(p),g=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,f]}}),m=Nr(g,g.dtype,"min",t);let y;if(o){const x=nt(d,l);y=ne({inputs:{x:m},backend:t,attrs:{shape:x}})}else y=ne({inputs:{x:m},backend:t,attrs:{shape:d}});return t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(m),c!=null&&t.disposeIntermediateTensorInfo(h),y}const TX={kernelName:Yo,backendName:"webgl",kernelFunc:kX};/**
18460 * @license
18461 * Copyright 2020 Google LLC. All Rights Reserved.
18462 * Licensed under the Apache License, Version 2.0 (the "License");
18463 * you may not use this file except in compliance with the License.
18464 * You may obtain a copy of the License at
18465 *
18466 * http://www.apache.org/licenses/LICENSE-2.0
18467 *
18468 * Unless required by applicable law or agreed to in writing, software
18469 * distributed under the License is distributed on an "AS IS" BASIS,
18470 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18471 * See the License for the specific language governing permissions and
18472 * limitations under the License.
18473 * =============================================================================
18474 */const EX=gg+`
18475  return min(a, b);
18476`,RX=`
18477  vec4 result = vec4(min(a, b));
18478  bvec4 isNaNA = isnan(a);
18479  bvec4 isNaNB = isnan(b);
18480  bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
18481  `+$r+`
18482  return result;
18483`,DX=Nt({opSnippet:EX,packedOpSnippet:RX,cpuKernelImpl:mU}),AX={kernelName:ga,backendName:"webgl",kernelFunc:DX};/**
18484 * @license
18485 * Copyright 2020 Google LLC. All Rights Reserved.
18486 * Licensed under the Apache License, Version 2.0 (the "License");
18487 * you may not use this file except in compliance with the License.
18488 * You may obtain a copy of the License at
18489 *
18490 * http://www.apache.org/licenses/LICENSE-2.0
18491 *
18492 * Unless required by applicable law or agreed to in writing, software
18493 * distributed under the License is distributed on an "AS IS" BASIS,
18494 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18495 * See the License for the specific language governing permissions and
18496 * limitations under the License.
18497 * =============================================================================
18498 */class OX{constructor(e,t,s){this.variableNames=["x"],this.outputShape=t.map((c,h)=>c[0]+e[h]+c[1]);const r=e.length,a=Fe(r),o=t.map(c=>c[0]).join(","),i=t.map((c,h)=>c[0]+e[h]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u=s==="reflect"?0:1;if(r===1){this.userCode=`
18499        int start = ${o};
18500        int end = ${i};
18501
18502        void main() {
18503          int outC = getOutputCoords();
18504          if (outC < start) {
18505            outC = start * 2 - outC - ${u};
18506          } else if(outC >= end) {
18507            outC = (end - 1) * 2 - outC + ${u};
18508          }
18509          setOutput(getX(outC - start));
18510        }
18511      `;return}this.userCode=`
18512      ${a} start = ${a}(${o});
18513      ${a} end = ${a}(${i});
18514
18515      void main() {
18516        ${a} outC = getOutputCoords();
18517        for (int i = 0; i < ${r}; i++) {
18518          if (outC[i] < start[i]) {
18519            outC[i] = start[i] * 2 - outC[i] - ${u};
18520          } else if(outC[i] >= end[i]) {
18521            outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};
18522          }
18523        }
18524        ${a} coords = outC - start;
18525        setOutput(getX(${l}));
18526      }
18527    `}}/**
18528 * @license
18529 * Copyright 2020 Google LLC. All Rights Reserved.
18530 * Licensed under the Apache License, Version 2.0 (the "License");
18531 * you may not use this file except in compliance with the License.
18532 * You may obtain a copy of the License at
18533 *
18534 * http://www.apache.org/licenses/LICENSE-2.0
18535 *
18536 * Unless required by applicable law or agreed to in writing, software
18537 * distributed under the License is distributed on an "AS IS" BASIS,
18538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18539 * See the License for the specific language governing permissions and
18540 * limitations under the License.
18541 * =============================================================================
18542 */class _X{constructor(e,t,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((f,g)=>f[0]+e[g]+f[1]);const r=e.length,a=Fe(r),o=t.map(f=>f[0]).join(","),i=t.map((f,g)=>f[0]+e[g]).join(","),l=Rt("rc",r),u=Rt("source",r),c=`${l[r-1]} < ${this.outputShape[r-1]}`,h=r===1?"source":`vec2(${u.slice(-2).join()})`,d=s==="reflect"?0:1;let p="";if(r===1){const f=`
18543        ${a} source = rc;
18544        if (source < start) {
18545          source = start * 2 - source - ${d};
18546        } else if (source >= end) {
18547          source = (end - 1) * 2 - source + ${d};
18548        }
18549        source -= start;
18550      `;p=`
18551        ${a} rc = outputLoc;
18552        ${f}
18553        result[0] = getChannel(getX(${u.join()}), ${h});
18554        ${l[r-1]} += 1;
18555        if(${c}) {
18556          ${f}
18557          result[1] = getChannel(getX(${u.join()}), ${h});
18558        }
18559      `}else{const f=`
18560        ${a} source = rc;
18561        ${a} lt = ${a}(lessThan(source, start));
18562        ${a} gte = ${a}(greaterThanEqual(source, end));
18563        ${a} orig = 1 - (lt + gte);
18564        source = orig * source +
18565                lt * (start * 2 - source - ${d}) +
18566                gte * ((end - 1) * 2 - source + ${d});
18567        source -= start;
18568      `;p=`
18569        ${a} rc = outputLoc;
18570        ${f}
18571        result[0] = getChannel(getX(${u.join()}), ${h});
18572        ${l[r-1]} += 1;
18573        if(${c}) {
18574          ${f}
18575          result[1] = getChannel(getX(${u.join()}), ${h});
18576        }
18577        rc = outputLoc;
18578        ${l[r-2]} += 1;
18579        if(${l[r-2]} < ${this.outputShape[r-2]}) {
18580          ${f}
18581          result[2] = getChannel(getX(${u.join()}), ${h});
18582          ${l[r-1]} += 1;
18583          if(${c}) {
18584            ${f}
18585            result[3] = getChannel(getX(${u.join()}), ${h});
18586          }
18587        }
18588      `}this.userCode=`
18589      const ${a} start = ${a}(${o});
18590      const ${a} end = ${a}(${i});
18591
18592      void main() {
18593        ${a} outputLoc = getOutputCoords();
18594        vec4 result = vec4(0.);
18595        ${p}
18596        setOutput(result);
18597      }
18598    `}}/**
18599 * @license
18600 * Copyright 2020 Google LLC. All Rights Reserved.
18601 * Licensed under the Apache License, Version 2.0 (the "License");
18602 * you may not use this file except in compliance with the License.
18603 * You may obtain a copy of the License at
18604 *
18605 * http://www.apache.org/licenses/LICENSE-2.0
18606 *
18607 * Unless required by applicable law or agreed to in writing, software
18608 * distributed under the License is distributed on an "AS IS" BASIS,
18609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18610 * See the License for the specific language governing permissions and
18611 * limitations under the License.
18612 * =============================================================================
18613 */const FX=({inputs:n,backend:e,attrs:t})=>{const{x:s}=n,{paddings:r,mode:a}=t,o=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new _X(s.shape,r,a):new OX(s.shape,r,a);return e.runWebGLProgram(o,[s],s.dtype)},LX={kernelName:ci,backendName:"webgl",kernelFunc:FX};/**
18614 * @license
18615 * Copyright 2020 Google LLC. All Rights Reserved.
18616 * Licensed under the Apache License, Version 2.0 (the "License");
18617 * you may not use this file except in compliance with the License.
18618 * You may obtain a copy of the License at
18619 *
18620 * http://www.apache.org/licenses/LICENSE-2.0
18621 *
18622 * Unless required by applicable law or agreed to in writing, software
18623 * distributed under the License is distributed on an "AS IS" BASIS,
18624 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18625 * See the License for the specific language governing permissions and
18626 * limitations under the License.
18627 * =============================================================================
18628 */const PX=`if (b == 0.0) return NAN;
18629  return mod(a, b);`,zX=`
18630  vec4 result = mod(a, b);
18631  bvec4 isNaN = equal(b, vec4(0.0));
18632  `+$r+`
18633  return result;
18634`,VX=Nt({opSnippet:PX,packedOpSnippet:zX}),BX={kernelName:ya,backendName:"webgl",kernelFunc:VX};/**
18635 * @license
18636 * Copyright 2017 Google LLC. All Rights Reserved.
18637 * Licensed under the Apache License, Version 2.0 (the "License");
18638 * you may not use this file except in compliance with the License.
18639 * You may obtain a copy of the License at
18640 *
18641 * http://www.apache.org/licenses/LICENSE-2.0
18642 *
18643 * Unless required by applicable law or agreed to in writing, software
18644 * distributed under the License is distributed on an "AS IS" BASIS,
18645 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18646 * See the License for the specific language governing permissions and
18647 * limitations under the License.
18648 * =============================================================================
18649 */class MX{constructor(e,t,s){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,s],this.userCode=`
18650      void main() {
18651        ivec2 coords = getOutputCoords();
18652        int batch = coords[0];
18653
18654        float r = random(seed);
18655        float cdf = 0.0;
18656
18657        for (int i = 0; i < ${t-1}; i++) {
18658          cdf += getProbs(batch, i);
18659
18660          if (r < cdf) {
18661            setOutput(float(i));
18662            return;
18663          }
18664        }
18665
18666        // If no other event happened, last event happened.
18667        setOutput(float(${t-1}));
18668      }
18669    `}}/**
18670 * @license
18671 * Copyright 2020 Google LLC. All Rights Reserved.
18672 * Licensed under the Apache License, Version 2.0 (the "License");
18673 * you may not use this file except in compliance with the License.
18674 * You may obtain a copy of the License at
18675 *
18676 * http://www.apache.org/licenses/LICENSE-2.0
18677 *
18678 * Unless required by applicable law or agreed to in writing, software
18679 * distributed under the License is distributed on an "AS IS" BASIS,
18680 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18681 * See the License for the specific language governing permissions and
18682 * limitations under the License.
18683 * =============================================================================
18684 */const WX=`
18685if (a == b) {
18686  return 1.0;
18687};
18688return a / b;`,UX=`
18689  // vec4 one = vec4(equal(a, b));
18690  // return one + (vec4(1.0) - one) * a / b;
18691  vec4 result = a / b;
18692  if(a.x == b.x) {
18693    result.x = 1.;
18694  }
18695  if(a.y == b.y) {
18696    result.y = 1.;
18697  }
18698  if(a.z == b.z) {
18699    result.z = 1.;
18700  }
18701  if(a.w == b.w) {
18702    result.w = 1.;
18703  }
18704
18705  return result;
18706`,yC=Nt({opSnippet:WX,packedOpSnippet:UX,checkOutOfBounds:!0}),GX={kernelName:Oi,backendName:"webgl",kernelFunc:yC};/**
18707 * @license
18708 * Copyright 2020 Google LLC. All Rights Reserved.
18709 * Licensed under the Apache License, Version 2.0 (the "License");
18710 * you may not use this file except in compliance with the License.
18711 * You may obtain a copy of the License at
18712 *
18713 * http://www.apache.org/licenses/LICENSE-2.0
18714 *
18715 * Unless required by applicable law or agreed to in writing, software
18716 * distributed under the License is distributed on an "AS IS" BASIS,
18717 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18718 * See the License for the specific language governing permissions and
18719 * limitations under the License.
18720 * =============================================================================
18721 */const Uy="return a - b;",xC=Nt({opSnippet:Uy,packedOpSnippet:Uy,supportsComplex:!0,cpuKernelImpl:LU}),HX={kernelName:Vi,backendName:"webgl",kernelFunc:xC};/**
18722 * @license
18723 * Copyright 2020 Google LLC. All Rights Reserved.
18724 * Licensed under the Apache License, Version 2.0 (the "License");
18725 * you may not use this file except in compliance with the License.
18726 * You may obtain a copy of the License at
18727 *
18728 * http://www.apache.org/licenses/LICENSE-2.0
18729 *
18730 * Unless required by applicable law or agreed to in writing, software
18731 * distributed under the License is distributed on an "AS IS" BASIS,
18732 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18733 * See the License for the specific language governing permissions and
18734 * limitations under the License.
18735 * =============================================================================
18736 */function bC(n){const{inputs:e,backend:t,attrs:s}=n,{logits:r}=e,{dim:a}=s,o=Ie([a],r.shape),i=gC({inputs:{x:r},backend:t,attrs:{reductionIndices:o,keepDims:!1}}),l=nt(i.shape,o),u=ne({inputs:{x:i},backend:t,attrs:{shape:l}}),c=xC({inputs:{a:r,b:u},backend:t}),h=pC({inputs:{x:c},backend:t}),d=Ph({inputs:{x:h},backend:t,attrs:{axis:o,keepDims:!1}}),p=ne({inputs:{x:d},backend:t,attrs:{shape:l}}),f=yC({inputs:{a:h,b:p},backend:t});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(u),t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(h),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),f}const jX={kernelName:xi,backendName:"webgl",kernelFunc:bC};/**
18737 * @license
18738 * Copyright 2020 Google LLC. All Rights Reserved.
18739 * Licensed under the Apache License, Version 2.0 (the "License");
18740 * you may not use this file except in compliance with the License.
18741 * You may obtain a copy of the License at
18742 *
18743 * http://www.apache.org/licenses/LICENSE-2.0
18744 *
18745 * Unless required by applicable law or agreed to in writing, software
18746 * distributed under the License is distributed on an "AS IS" BASIS,
18747 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18748 * See the License for the specific language governing permissions and
18749 * limitations under the License.
18750 * =============================================================================
18751 */function qX(n){const{inputs:e,backend:t,attrs:s}=n,{logits:r}=e,{numSamples:a,seed:o,normalized:i}=s,l=i?r:bC({inputs:{logits:r},backend:t,attrs:{dim:r.shape.length-1}}),u=l.shape[0],c=l.shape[1],h=new MX(u,c,a),d=[[o]],p=t.runWebGLProgram(h,[l],"int32",d);return i||t.disposeIntermediateTensorInfo(l),p}const KX={kernelName:Ou,backendName:"webgl",kernelFunc:qX};/**
18752 * @license
18753 * Copyright 2020 Google LLC. All Rights Reserved.
18754 * Licensed under the Apache License, Version 2.0 (the "License");
18755 * you may not use this file except in compliance with the License.
18756 * You may obtain a copy of the License at
18757 *
18758 * http://www.apache.org/licenses/LICENSE-2.0
18759 *
18760 * Unless required by applicable law or agreed to in writing, software
18761 * distributed under the License is distributed on an "AS IS" BASIS,
18762 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18763 * See the License for the specific language governing permissions and
18764 * limitations under the License.
18765 * =============================================================================
18766 */const XX=Cn+`
18767  return -x;
18768`,YX=`
18769  vec4 result = -x;
18770  bvec4 isNaN = isnan(x);
18771
18772  result.r = isNaN.r ? x.r : result.r;
18773  result.g = isNaN.g ? x.g : result.g;
18774  result.b = isNaN.b ? x.b : result.b;
18775  result.a = isNaN.a ? x.a : result.a;
18776
18777  return result;
18778`;function JX(n){const{inputs:e,backend:t}=n,{x:s}=e;if(t.shouldExecuteOnCPU([s])){const a=t.texData.get(s.dataId),[o,i]=yU(a.values,s.shape,s.dtype);return t.makeTensorInfo(i,s.dtype,o)}let r;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new xs(s.shape,YX):r=new Bn(s.shape,XX),t.runWebGLProgram(r,[s],s.dtype)}const ZX={kernelName:si,backendName:"webgl",kernelFunc:JX};/**
18779 * @license
18780 * Copyright 2020 Google LLC. All Rights Reserved.
18781 * Licensed under the Apache License, Version 2.0 (the "License");
18782 * you may not use this file except in compliance with the License.
18783 * You may obtain a copy of the License at
18784 *
18785 * http://www.apache.org/licenses/LICENSE-2.0
18786 *
18787 * Unless required by applicable law or agreed to in writing, software
18788 * distributed under the License is distributed on an "AS IS" BASIS,
18789 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18790 * See the License for the specific language governing permissions and
18791 * limitations under the License.
18792 * =============================================================================
18793 */const QX=ch;function e5(n){Ui("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:r,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l}=s,u=t.readSync(r.dataId),c=t.readSync(a.dataId),{selectedIndices:h}=QX(u,c,o,i,l);return t.makeTensorInfo([h.length],"int32",new Int32Array(h))}const t5={kernelName:ec,backendName:"webgl",kernelFunc:e5};/**
18794 * @license
18795 * Copyright 2020 Google LLC. All Rights Reserved.
18796 * Licensed under the Apache License, Version 2.0 (the "License");
18797 * you may not use this file except in compliance with the License.
18798 * You may obtain a copy of the License at
18799 *
18800 * http://www.apache.org/licenses/LICENSE-2.0
18801 *
18802 * Unless required by applicable law or agreed to in writing, software
18803 * distributed under the License is distributed on an "AS IS" BASIS,
18804 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18805 * See the License for the specific language governing permissions and
18806 * limitations under the License.
18807 * =============================================================================
18808 */const n5=hh;function s5(n){Ui("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:r,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,padToMaxOutputSize:u}=s,c=t.readSync(r.dataId),h=t.readSync(a.dataId),{selectedIndices:d,validOutputs:p}=n5(c,h,o,i,l,u);return[t.makeTensorInfo([d.length],"int32",new Int32Array(d)),t.makeTensorInfo([],"int32",new Int32Array([p]))]}const r5={kernelName:nc,backendName:"webgl",kernelFunc:s5};/**
18809 * @license
18810 * Copyright 2020 Google LLC. All Rights Reserved.
18811 * Licensed under the Apache License, Version 2.0 (the "License");
18812 * you may not use this file except in compliance with the License.
18813 * You may obtain a copy of the License at
18814 *
18815 * http://www.apache.org/licenses/LICENSE-2.0
18816 *
18817 * Unless required by applicable law or agreed to in writing, software
18818 * distributed under the License is distributed on an "AS IS" BASIS,
18819 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18820 * See the License for the specific language governing permissions and
18821 * limitations under the License.
18822 * =============================================================================
18823 */const a5=dh;function o5(n){Ui("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:s}=n,{boxes:r,scores:a}=e,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,softNmsSigma:u}=s,c=t.readSync(r.dataId),h=t.readSync(a.dataId),d=o,p=i,f=l,g=u,{selectedIndices:m,selectedScores:y}=a5(c,h,d,p,f,g);return[t.makeTensorInfo([m.length],"int32",new Int32Array(m)),t.makeTensorInfo([y.length],"float32",new Float32Array(y))]}const i5={kernelName:tc,backendName:"webgl",kernelFunc:o5};/**
18824 * @license
18825 * Copyright 2017 Google LLC. All Rights Reserved.
18826 * Licensed under the Apache License, Version 2.0 (the "License");
18827 * you may not use this file except in compliance with the License.
18828 * You may obtain a copy of the License at
18829 *
18830 * http://www.apache.org/licenses/LICENSE-2.0
18831 *
18832 * Unless required by applicable law or agreed to in writing, software
18833 * distributed under the License is distributed on an "AS IS" BASIS,
18834 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18835 * See the License for the specific language governing permissions and
18836 * limitations under the License.
18837 * =============================================================================
18838 */class l5{constructor(e,t,s,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`
18839      void main() {
18840        ivec2 coords = getOutputCoords();
18841        int index = round(getIndices(coords.x));
18842        setOutput(mix(float(${r}), float(${s}),
18843                      float(index == coords.y)));
18844      }
18845    `}}/**
18846 * @license
18847 * Copyright 2020 Google LLC. All Rights Reserved.
18848 * Licensed under the Apache License, Version 2.0 (the "License");
18849 * you may not use this file except in compliance with the License.
18850 * You may obtain a copy of the License at
18851 *
18852 * http://www.apache.org/licenses/LICENSE-2.0
18853 *
18854 * Unless required by applicable law or agreed to in writing, software
18855 * distributed under the License is distributed on an "AS IS" BASIS,
18856 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18857 * See the License for the specific language governing permissions and
18858 * limitations under the License.
18859 * =============================================================================
18860 */const u5=n=>{const{inputs:e,backend:t,attrs:s}=n,{indices:r}=e,{dtype:a,depth:o,onValue:i,offValue:l}=s,u=H(r.shape),c=new l5(u,o,i,l),h=ne({inputs:{x:r},backend:t,attrs:{shape:[u]}}),d=t.runWebGLProgram(c,[h],a);t.disposeIntermediateTensorInfo(h);const p=[...r.shape,o],f=ne({inputs:{x:d},backend:t,attrs:{shape:p}});return t.disposeIntermediateTensorInfo(d),f},c5={kernelName:di,backendName:"webgl",kernelFunc:u5};/**
18861 * @license
18862 * Copyright 2020 Google LLC. All Rights Reserved.
18863 * Licensed under the Apache License, Version 2.0 (the "License");
18864 * you may not use this file except in compliance with the License.
18865 * You may obtain a copy of the License at
18866 *
18867 * http://www.apache.org/licenses/LICENSE-2.0
18868 *
18869 * Unless required by applicable law or agreed to in writing, software
18870 * distributed under the License is distributed on an "AS IS" BASIS,
18871 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18872 * See the License for the specific language governing permissions and
18873 * limitations under the License.
18874 * =============================================================================
18875 */function yu(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="complex64"){const r=wl({inputs:{input:s},backend:t}),a=yu({inputs:{x:r},backend:t}),o=zh({inputs:{input:s},backend:t}),i=yu({inputs:{x:o},backend:t}),l=Bs({inputs:{real:a,imag:i},backend:t});return t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),l}else return vl({attrs:{shape:s.shape,dtype:s.dtype,value:s.dtype==="string"?"":0},backend:t})}const h5={kernelName:Dc,backendName:"webgl",kernelFunc:yu};/**
18876 * @license
18877 * Copyright 2020 Google LLC. All Rights Reserved.
18878 * Licensed under the Apache License, Version 2.0 (the "License");
18879 * you may not use this file except in compliance with the License.
18880 * You may obtain a copy of the License at
18881 *
18882 * http://www.apache.org/licenses/LICENSE-2.0
18883 *
18884 * Unless required by applicable law or agreed to in writing, software
18885 * distributed under the License is distributed on an "AS IS" BASIS,
18886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18887 * See the License for the specific language governing permissions and
18888 * limitations under the License.
18889 * =============================================================================
18890 */function wC(n){const{inputs:e,backend:t}=n,{x:s}=e;if(s.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(s.dtype==="complex64"){const r=wl({inputs:{input:s},backend:t}),a=wC({inputs:{x:r},backend:t}),o=zh({inputs:{input:s},backend:t}),i=yu({inputs:{x:o},backend:t}),l=Bs({inputs:{real:a,imag:i},backend:t});return t.disposeIntermediateTensorInfo(r),t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),l}else return vl({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:t})}const d5={kernelName:pi,backendName:"webgl",kernelFunc:wC};/**
18891 * @license
18892 * Copyright 2020 Google LLC. All Rights Reserved.
18893 * Licensed under the Apache License, Version 2.0 (the "License");
18894 * you may not use this file except in compliance with the License.
18895 * You may obtain a copy of the License at
18896 *
18897 * http://www.apache.org/licenses/LICENSE-2.0
18898 *
18899 * Unless required by applicable law or agreed to in writing, software
18900 * distributed under the License is distributed on an "AS IS" BASIS,
18901 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18902 * See the License for the specific language governing permissions and
18903 * limitations under the License.
18904 * =============================================================================
18905 */function p5(n){const{inputs:e,backend:t,attrs:s}=n,{axis:r}=s;if(e.length===1)return Dd({inputs:{input:e[0]},backend:t,attrs:{dim:r}});const a=e[0].shape,o=e[0].dtype;e.forEach(c=>{dn(a,c.shape,"All tensors passed to stack must have matching shapes"),I(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});const i=[],l=e.map(c=>{const h=Dd({inputs:{input:c},backend:t,attrs:{dim:r}});return i.push(h),h}
vendor: 4,130 bytes, lines 18905-18993
18905),u=aC({inputs:l,backend:t,attrs:{axis:r}});return i.forEach(c=>t.disposeIntermediateTensorInfo(c)),u}const f5={kernelName:wi,backendName:"webgl",kernelFunc:p5};/**
18906 * @license
18907 * Copyright 2017 Google LLC. All Rights Reserved.
18908 * Licensed under the Apache License, Version 2.0 (the "License");
18909 * you may not use this file except in compliance with the License.
18910 * You may obtain a copy of the License at
18911 *
18912 * http://www.apache.org/licenses/LICENSE-2.0
18913 *
18914 * Unless required by applicable law or agreed to in writing, software
18915 * distributed under the License is distributed on an "AS IS" BASIS,
18916 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18917 * See the License for the specific language governing permissions and
18918 * limitations under the License.
18919 * =============================================================================
18920 */class m5{constructor(e,t,s){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((u,c)=>u[0]+e[c]+u[1]);const r=e.length,a=Fe(r),o=t.map(u=>u[0]).join(","),i=t.map((u,c)=>u[0]+e[c]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);if(r===1){this.userCode=`
18921        int start = ${o};
18922        int end = ${i};
18923
18924        void main() {
18925          int outC = getOutputCoords();
18926          if (outC < start || outC >= end) {
18927            setOutput(value);
18928          } else {
18929            setOutput(getX(outC - start));
18930          }
18931        }
18932      `;return}this.userCode=`
18933      ${a} start = ${a}(${o});
18934      ${a} end = ${a}(${i});
18935
18936      void main() {
18937        ${a} outC = getOutputCoords();
18938        if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {
18939          setOutput(value);
18940        } else {
18941          ${a} coords = outC - start;
18942          setOutput(getX(${l}));
18943        }
18944      }
18945    `}}/**
18946 * @license
18947 * Copyright 2019 Google LLC. All Rights Reserved.
18948 * Licensed under the Apache License, Version 2.0 (the "License");
18949 * you may not use this file except in compliance with the License.
18950 * You may obtain a copy of the License at
18951 *
18952 * http://www.apache.org/licenses/LICENSE-2.0
18953 *
18954 * Unless required by applicable law or agreed to in writing, software
18955 * distributed under the License is distributed on an "AS IS" BASIS,
18956 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18957 * See the License for the specific language governing permissions and
18958 * limitations under the License.
18959 * =============================================================================
18960 */class g5{constructor(e,t,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((g,m)=>g[0]+e[m]+g[1]);const r=e.length,a=Fe(r),o=t.map(g=>g[0]).join(","),i=t.map((g,m)=>g[0]+e[m]).join(","),l=Rt("rc",r),u=Rt("source",r),c=`${l[r-1]} < ${this.outputShape[r-1]}`,h=r===1?"source":`vec2(${u.slice(-2).join()})`,d=[`${a} rc = outputLoc;`,`${l[r-1]} += 1;
18961       if(${c}) {
18962      `,r===1?"":`}
18963       rc = outputLoc;
18964       ${l[r-2]} += 1;
18965       if(${l[r-2]} < ${this.outputShape[r-2]}) {`,r===1?"":`  ${l[r-1]} += 1;
18966         if(${c}) {`],p=r===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let f="";for(let g=0,m=r===1?2:4;g<m;g++)f+=`
18967        ${d[g]}
18968        if (${p}) {
18969          result[${g}] = float(value);
18970        } else {
18971          ${a} source = rc - start;
18972          result[${g}] = getChannel(getX(${u.join()}), ${h});
18973        }
18974      `;f+=r===1?"} ":"}}",this.userCode=`
18975      const ${a} start = ${a}(${o});
18976      const ${a} end = ${a}(${i});
18977
18978      void main() {
18979        ${a} outputLoc = getOutputCoords();
18980        vec4 result = vec4(0.);
18981        ${f}
18982        setOutput(result);
18983      }
18984    `}}/**
18985 * @license
18986 * Copyright 2020 Google LLC. All Rights Reserved.
18987 * Licensed under the Apache License, Version 2.0 (the "License");
18988 * you may not use this file except in compliance with the License.
18989 * You may obtain a copy of the License at
18990 *
18991 * http://www.apache.org/licenses/LICENSE-2.0
18992 *
18993 * Unless required by applicable law or agreed to in writing, softw
18993are
18994 * distributed under the License is distributed on an "AS IS" BASIS,
18995 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18996 * See the License for the specific language governing permissions and
18997 * limitations under the License.
18998 * =============================================================================
18999 */const vC=n=>{const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{paddings:a,constantValue:o}=s;if(H(r.shape)===0){const u=a.map((c,h)=>c[0]+r.shape[h]+c[1]);return vl({backend:t,attrs:{shape:u,value:o,dtype:r.dtype}})}const i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new g5(r.shape,a,o):new m5(r.shape,a,o),l=[[o]];return t.runWebGLProgram(i,[r],r.dtype,l)},y5={kernelName:fi,backendName:"webgl",kernelFunc:vC};/**
19000 * @license
19001 * Copyright 2020 Google LLC. All Rights Reserved.
19002 * Licensed under the Apache License, Version 2.0 (the "License");
19003 * you may not use this file except in compliance with the License.
19004 * You may obtain a copy of the License at
19005 *
19006 * http://www.apache.org/licenses/LICENSE-2.0
19007 *
19008 * Unless required by applicable law or agreed to in writing, software
19009 * distributed under the License is distributed on an "AS IS" BASIS,
19010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19011 * See the License for the specific language governing permissions and
19012 * limitations under the License.
19013 * =============================================================================
19014 */const x5=`
19015  if(a < 0.0 && floor(b) < b){
19016    return NAN;
19017  }
19018  if (b == 0.0) {
19019    return 1.0;
19020  }
19021  return (round(mod(b, 2.0)) != 1) ?
19022      pow(abs(a), b) : sign(a) * pow(abs(a), b);
19023`,b5=`
19024  // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.
19025  vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));
19026  vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);
19027  vec4 result = multiplier * pow(abs(a), b);
19028
19029  // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS
19030  bvec4 isExpZero = equal(b, vec4(0.0));
19031  result.r = isExpZero.r ? 1.0 : result.r;
19032  result.g = isExpZero.g ? 1.0 : result.g;
19033  result.b = isExpZero.b ? 1.0 : result.b;
19034  result.a = isExpZero.a ? 1.0 : result.a;
19035
19036  bvec4 isNaN1 = lessThan(a, vec4(0.0));
19037  bvec4 isNaN2 = lessThan(floor(b), b);
19038  bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);
19039  `+$r+`
19040  return result;
19041`,w5=Nt({opSnippet:x5,packedOpSnippet:b5}),v5={kernelName:Ai,backendName:"webgl",kernelFunc:w5};/**
19042 * @license
19043 * Copyright 2020 Google LLC. All Rights Reserved.
19044 * Licensed under the Apache License, Version 2.0 (the "License");
19045 * you may not use this file except in compliance with the License.
19046 * You may obtain a copy of the License at
19047 *
19048 * http://www.apache.org/licenses/LICENSE-2.0
19049 *
19050 * Unless required by applicable law or agreed to in writing, software
19051 * distributed under the License is distributed on an "AS IS" BASIS,
19052 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19053 * See the License for the specific language governing permissions and
19054 * limitations under the License.
19055 * =============================================================================
19056 */function C5(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{axis:a,keepDims:o}=s,i=r.shape.length,l=[],u=Ie(a,r.shape);let c=u;const h=Xe(c,i);let d=r;h!=null&&(d=_t({inputs:{x:r},backend:t,attrs:{perm:h}}),c=st(c.length,i),l.push(d)),St("prod",c,i);let p;if(t.shouldExecuteOnCPU([d])){const f=t.texData.get(d.dataId).values,{outVals:g,outShape:m,outDtype:y}=bU(d.shape,d.dtype,f,c);p=t.makeTensorInfo(m,y,g)}else{const[f,g]=Ct(d.shape,c),m=H(g),y=ne({inputs:{x:d},backend:t,attrs:{shape:[-1,m]}}),x=Vc(r.dtype),v=Nr(y,x,"prod",t);p=ne({inputs:{x:v},backend:t,attrs:{shape:f}}),l.push(y),l.push(v)}if(o){l.push(p);const f=nt(p.shape,u);p=ne({inputs:{x:p},backend:t,attrs:{shape:f}})}return l.forEach(f=>t.disposeIntermediateTensorInfo(f)),p}const $5={kernelName:gi,backendName:"webgl",kernelFunc:C5};/**
19057 * @license
19058 * Copyright 2022 Google LLC. All Rights Reserved.
19059 * Licensed under the Apache License, Version 2.0 (the "License");
19060 * you may not use this file except in compliance with the License.
19061 * You may obtain a copy of the License at
19062 *
19063 * http://www.apache.org/licenses/LICENSE-2.0
19064 *
19065 * Unless required by applicable law or agreed to in writing, software
19066 * distributed under the License is distributed on an "AS IS" BASIS,
19067 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19068 * See the License for the specific language governing permissions and
19069 * limitations under the License.
19070 * =============================================================================
19071 */function N5(n){const{inputs:e,backend:t,attrs:s}=n,{paramsNestedSplits:r,paramsDenseValues:a,indices:o}=e,{outputRaggedRank:i}=s,l=r.map(y=>t.readSync(y.dataId)),u=r.map(y=>y.shape),c=t.readSync(a.dataId),h=t.readSync(o.dataId),[d,p,f]=wU(l,u,c,a.shape,a.dtype,h,o.shape,i),g=d.map(y=>t.makeTensorInfo([y.length],"int32",y)),m=t.makeTensorInfo(f,a.dtype,p);return g.concat([m])}const I5={kernelName:_u,backendName:"webgl",kernelFunc:N5};/**
19072 * @license
19073 * Copyright 2022 Google LLC.
19074 * Licensed under the Apache License, Version 2.0 (the "License");
19075 * you may not use this file except in compliance with the License.
19076 * You may obtain a copy of the License at
19077 *
19078 * http://www.apache.org/licenses/LICENSE-2.0
19079 *
19080 * Unless required by applicable law or agreed to in writing, software
19081 * distributed under the License is distributed on an "AS IS" BASIS,
19082 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19083 * See the License for the specific language governing permissions and
19084 * limitations under the License.
19085 * =============================================================================
19086 */function S5(n){const{inputs:e,backend:t}=n,{starts:s,limits:r,deltas:a}=e,o=t.readSync(s.dataId),i=t.readSync(r.dataId),l=t.readSync(a.dataId),[u,c]=vU(o,s.shape,s.dtype,i,r.shape,l,a.shape),h=t.makeTensorInfo([u.length],"int32",u),d=t.makeTensorInfo([c.length],s.dtype,c);return[h,d]}const k5={kernelName:Fu,backendName:"webgl",kernelFunc:S5};/**
19087 * @license
19088 * Copyright 2022 Google LLC. All Rights Reserved.
19089 * Licensed under the Apache License, Version 2.0 (the "License");
19090 * you may not use this file except in compliance with the License.
19091 * You may obtain a copy of the License at
19092 *
19093 * http://www.apache.org/licenses/LICENSE-2.0
19094 *
19095 * Unless required by applicable law or agreed to in writing, software
19096 * distributed under the License is distributed on an "AS IS" BASIS,
19097 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19098 * See the License for the specific language governing permissions and
19099 * limitations under the License.
19100 * =============================================================================
19101 */function T5(n){const{inputs:e,backend:t,attrs:s}=n,{shape:r,values:a,defaultValue:o,rowPartitionTensors:i}=e,{rowPartitionTypes:l}=s,u=t.readSync(r.dataId),c=t.readSync(a.dataId),h=t.readSync(o.dataId),d=i.map(m=>t.readSync(m.dataId)),p=i.map(m=>m.shape),[f,g]=CU(u,r.shape,c,a.shape,a.dtype,h,o.shape,d,p,l);return t.makeTensorInfo(f,a.dtype,g)}const E5={kernelName:Lu,backendName:"webgl",kernelFunc:T5};/**
19102 * @license
19103 * Copyright 2020 Google LLC. All Rights Reserved.
19104 * Licensed under the Apache License, Version 2.0 (the "License");
19105 * you may not use this file except in compliance with the License.
19106 * You may obtain a copy of the License at
19107 *
19108 * http://www.apache.org/licenses/LICENSE-2.0
19109 *
19110 * Unless required by applicable law or agreed to in writing, software
19111 * distributed under the License is distributed on an "AS IS" BASIS,
19112 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19113 * See the License for the specific language governing permissions and
19114 * limitations under the License.
19115 * =============================================================================
19116 */const CC=n=>{const{backend:e,attrs:t}=n,{start:s,stop:r,step:a,dtype:o}=t,i=$U(s,r,a,o);return e.makeTensorInfo([i.length],o,i)},R5={kernelName:Pu,backendName:"webgl",kernelFunc:CC};/**
19117 * @license
19118 * Copyright 2020 Google LLC. All Rights Reserved.
19119 * Licensed under the Apache License, Version 2.0 (the "License");
19120 * you may not use this file except in compliance with the License.
19121 * You may obtain a copy of the License at
19122 *
19123 * http://www.apache.org/licenses/LICENSE-2.0
19124 *
19125 * Unless required by applicable law or agreed to in writing, software
19126 * distributed under the License is distributed on an "AS IS" BASIS,
19127 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19128 * See the License for the specific language governing permissions and
19129 * limitations under the License.
19130 * =============================================================================
19131 */const D5="return 1.0 / x;",A5=Te({opSnippet:D5}),O5={kernelName:xa,backendName:"webgl",kernelFunc:A5};/**
19132 * @license
19133 * Copyright 2020 Google LLC. All Rights Reserved.
19134 * Licensed under the Apache License, Version 2.0 (the "License");
19135 * you may not use this file except in compliance with the License.
19136 * You may obtain a copy of the License at
19137 *
19138 * http://www.apache.org/licenses/LICENSE-2.0
19139 *
19140 * Unless required by applicable law or agreed to in writing, software
19141 * distributed under the License is distributed on an "AS IS" BASIS,
19142 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19143 * See the License for the specific language governing permissions and
19144 * limitations under the License.
19145 * =============================================================================
19146 */const _5=Cn+`
19147  return (x < 0.0) ? 0.0 : x;
19148`,F5=`
19149  vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
19150  bvec4 isNaN = isnan(x);
19151
19152  result.r = isNaN.r ? x.r : result.r;
19153  result.g = isNaN.g ? x.g : result.g;
19154  result.b = isNaN.b ? x.b : result.b;
19155  result.a = isNaN.a ? x.a : result.a;
19156
19157  return result;
19158`,L5=Te({opSnippet:_5,packedOpSnippet:F5}),P5={kernelName:Fi,backendName:"webgl",kernelFunc:L5};/**
19159 * @license
19160 * Copyright 2020 Google LLC. All Rights Reserved.
19161 * Licensed under the Apache License, Version 2.0 (the "License");
19162 * you may not use this file except in compliance with the License.
19163 * You may obtain a copy of the License at
19164 *
19165 * http://www.apache.org/licenses/LICENSE-2.0
19166 *
19167 * Unless required by applicable law or agreed to in writing, softw
19167are
19168 * distributed under the License is distributed on an "AS IS" BASIS,
19169 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19170 * See the License for the specific language governing permissions and
19171 * limitations under the License.
19172 * =============================================================================
19173 */const z5=Cn+`
19174  return (x < 0.0) ? 0.0 : min(6.0, x);
19175`,V5=`
19176  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
19177  bvec4 isNaN = isnan(x);
19178
19179  result.r = isNaN.r ? x.r : result.r;
19180  result.g = isNaN.g ? x.g : result.g;
19181  result.b = isNaN.b ? x.b : result.b;
19182  result.a = isNaN.a ? x.a : result.a;
19183
19184  return result;
19185`,B5=Te({opSnippet:z5,packedOpSnippet:V5}),M5={kernelName:_i,backendName:"webgl",kernelFunc:B5};/**
19186 * @license
19187 * Copyright 2017 Google LLC. All Rights Reserved.
19188 * Licensed under the Apache License, Version 2.0 (the "License");
19189 * you may not use this file except in compliance with the License.
19190 * You may obtain a copy of the License at
19191 *
19192 * http://www.apache.org/licenses/LICENSE-2.0
19193 *
19194 * Unless required by applicable law or agreed to in writing, software
19195 * distributed under the License is distributed on an "AS IS" BASIS,
19196 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19197 * See the License for the specific language governing permissions and
19198 * limitations under the License.
19199 * =============================================================================
19200 */class W5{constructor(e,t,s,r,a){this.variableNames=["A"],this.outputShape=[];const[o,i,l,u]=e;this.outputShape=[o,t,s,u];const c=[r&&t>1?i-1:i,r&&s>1?l-1:l],h=[r&&t>1?t-1:t,r&&s>1?s-1:s];let d;a?d="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
19201      const vec2 effectiveInputOverOutputRatioRC = vec2(
19202          ${c[0]/h[0]},
19203          ${c[1]/h[1]});
19204      const vec2 inputShapeRC = vec2(${i}.0, ${l}.0);
19205
19206      void main() {
19207        ivec4 coords = getOutputCoords();
19208        int b = coords[0];
19209        int d = coords[3];
19210        ivec2 yRC = coords.yz;
19211
19212        // Fractional source index.
19213        vec2 sourceFracIndexRC = ${d};
19214
19215        // Compute the four integer indices.
19216        ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));
19217        ivec2 sourceCeilRC = ivec2(
19218          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
19219
19220        float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);
19221        float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);
19222        float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);
19223        float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);
19224
19225        vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);
19226
19227        float top = topLeft + (topRight - topLeft) * fracRC.y;
19228        float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;
19229        float newValue = top + (bottom - top) * fracRC.x;
19230
19231        setOutput(newValue);
19232      }
19233    `}}/**
19234 * @license
19235 * Copyright 2019 Google LLC. All Rights Reserved.
19236 * Licensed under the Apache License, Version 2.0 (the "License");
19237 * you may not use this file except in compliance with the License.
19238 * You may obtain a copy of the License at
19239 *
19240 * http://www.apache.org/licenses/LICENSE-2.0
19241 *
19242 * Unless required by applicable law or agreed to in writing, software
19243 * distributed under the License is distributed on an "AS IS" BASIS,
19244 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19245 * See the License for the specific language governing permissions and
19246 * limitations under the License.
19247 * =============================================================================
19248 */class U5{constructor(e,t,s,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,i,l,u]=e;this.outputShape=[o,t,s,u];const c=[r&&t>1?i-1:i,r&&s>1?l-1:l],h=[r&&t>1?t-1:t,r&&s>1?s-1:s];let d;a?d="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
19249      const vec3 effectiveInputOverOutputRatioRC = vec3(
19250          ${c[0]/h[0]},
19251          ${c[1]/h[1]},
19252          ${c[1]/h[1]});
19253      const vec3 inputShapeRC = vec3(${i}.0, ${l}.0,
19254                                     ${l}.0);
19255
19256      float getAValue(int b, int r, int c, int d) {
19257        return getChannel(getA(b, r, c, d), vec2(c, d));
19258      }
19259
19260      void main() {
19261        ivec4 coords = getOutputCoords();
19262        int b = coords[0];
19263        int d = coords[3];
19264        // Calculate values for next column in yRC.z.
19265        ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
19266
19267        // Fractional source index.
19268        vec3 sourceFracIndexRC = ${d};
19269
19270        // Compute the four integer indices.
19271        ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));
19272        ivec3 sourceCeilRC = ivec3(
19273          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
19274
19275        // Should we calculate next column and row elements in 2x2 packed cell.
19276        bool hasNextCol = d < ${u-1};
19277        bool hasNextRow = coords.z < ${s-1}
vendor: 2,018 bytes, lines 19277-19325
19277;
19278
19279        // In parallel, construct four corners for all four components in
19280        // packed 2x2 cell.
19281        vec4 topLeft = vec4(
19282          getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),
19283          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)
19284                     : 0.0,
19285          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)
19286                     : 0.0,
19287          (hasNextRow && hasNextCol) ?
19288            getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);
19289
19290        vec4 bottomLeft = vec4(
19291          getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),
19292          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)
19293                     : 0.0,
19294          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)
19295                     : 0.0,
19296          (hasNextRow && hasNextCol) ?
19297            getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);
19298
19299        vec4 topRight = vec4(
19300          getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),
19301          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)
19302                     : 0.0,
19303          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)
19304                     : 0.0,
19305          (hasNextRow && hasNextCol) ?
19306            getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);
19307
19308        vec4 bottomRight = vec4(
19309          getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),
19310          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)
19311                     : 0.0,
19312          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)
19313                     : 0.0,
19314          (hasNextRow && hasNextCol) ?
19315            getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);
19316
19317        vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);
19318
19319        vec4 top = mix(topLeft, topRight, fracRC.yyzz);
19320        vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);
19321        vec4 newValue = mix(top, bottom, fracRC.x);
19322
19323        setOutput(newValue);
19324      }
19325    `}
vendor: 4,806 bytes, lines 19325-19439
19325}/**
19326 * @license
19327 * Copyright 2020 Google LLC. All Rights Reserved.
19328 * Licensed under the Apache License, Version 2.0 (the "License");
19329 * you may not use this file except in compliance with the License.
19330 * You may obtain a copy of the License at
19331 *
19332 * http://www.apache.org/licenses/LICENSE-2.0
19333 *
19334 * Unless required by applicable law or agreed to in writing, software
19335 * distributed under the License is distributed on an "AS IS" BASIS,
19336 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19337 * See the License for the specific language governing permissions and
19338 * limitations under the License.
19339 * =============================================================================
19340 */function G5(n){const{inputs:e,backend:t,attrs:s}=n,{images:r}=e,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,u]=i,c=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new U5(r.shape,l,u,a,o):new W5(r.shape,l,u,a,o);return t.runWebGLProgram(c,[r],"float32")}const H5={kernelName:Ni,backendName:"webgl",kernelFunc:G5};/**
19341 * @license
19342 * Copyright 2018 Google LLC. All Rights Reserved.
19343 * Licensed under the Apache License, Version 2.0 (the "License");
19344 * you may not use this file except in compliance with the License.
19345 * You may obtain a copy of the License at
19346 *
19347 * http://www.apache.org/licenses/LICENSE-2.0
19348 *
19349 * Unless required by applicable law or agreed to in writing, software
19350 * distributed under the License is distributed on an "AS IS" BASIS,
19351 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19352 * See the License for the specific language governing permissions and
19353 * limitations under the License.
19354 * =============================================================================
19355 */class j5{constructor(e,t,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,o,i]=e,l=[s&&o>1?r-1:r,s&&i>1?a-1:a],u=[s&&o>1?o-1:o,s&&i>1?i-1:i],c=l[0]/u[0],h=l[1]/u[1],d=1/c,p=1/h,f=Math.ceil(d)*2+2,g=Math.ceil(p)*2+2;this.userCode=`
19356      void main() {
19357        ivec4 coords = getOutputCoords();
19358        int b = coords[0];
19359        int d = coords[3];
19360        int r = coords[1];
19361        int c = coords[2];
19362
19363        float accumulator = 0.0;
19364
19365        const float heightScale = float(${c});
19366        const float widthScale = float(${h});
19367
19368        const float invHeightScale = float(${d});
19369        const float invWidthScale = float(${p});
19370
19371        const int winHeight = int(${f});
19372        const int winWidth = int(${g});
19373
19374        // Compute bounds for where in dy we will look
19375        float startRLerp = floor(float(r) * invHeightScale);
19376        int startDyR = int(startRLerp - float(winHeight / 2));
19377
19378        float startCLerp = floor(float(c) * invWidthScale);
19379        int startDyC = int(startCLerp - float(winWidth / 2));
19380
19381        // Loop over dy
19382        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
19383          int dyR = dyROffset + startDyR;
19384
19385          // Guard against the window exceeding the bounds of dy
19386          if (dyR < 0 || dyR >= ${o}) {
19387            continue;
19388          }
19389
19390          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
19391            int dyC = dyCOffset + startDyC;
19392
19393            // Guard against the window exceeding the bounds of dy
19394            if (dyC < 0 || dyC >= ${i}) {
19395              continue;
19396            }
19397
19398            float dxR = float(dyR) * heightScale;
19399            int topDxRIndex = int(floor(dxR));
19400            int bottomDxRIndex = int(min(ceil(dxR), ${r-1}.0));
19401            float dxRLerp = dxR - float(topDxRIndex);
19402            float inverseDxRLerp = 1.0 - dxRLerp;
19403
19404            float dxC = float(dyC) * widthScale;
19405            int leftDxCIndex = int(floor(dxC));
19406            int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0));
19407            float dxCLerp = dxC - float(leftDxCIndex);
19408            float inverseDxCLerp = 1.0 - dxCLerp;
19409
19410            if (r == topDxRIndex && c == leftDxCIndex) {
19411              // topLeft
19412              accumulator +=
19413                getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;
19414            }
19415
19416            if (r == topDxRIndex && c == rightDxCIndex) {
19417              // topRight
19418              accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;
19419            }
19420
19421            if (r == bottomDxRIndex && c == leftDxCIndex) {
19422              // bottomLeft
19423              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;
19424            }
19425
19426            if (r == bottomDxRIndex && c == rightDxCIndex) {
19427              // bottomRight
19428              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;
19429            }
19430          }
19431        }
19432        // End loop over dy
19433
19434        setOutput(accumulator);
19435      }
19436    `}}/**
19437 * @license
19438 * Copyright 2020 Google LLC. All Rights Reserved.
19439 * Licensed under the Apache License, Version 2.0 (the "License");
19440 * you may not use this file except in compliance with the License.
19441 * You may obtain a copy of the License at
19442 *
19443 * http://www.apache.org/licenses/LICENSE-2.0
19444 *
19445 * Unless required by applicable law or agreed to in writing, software
19446 * distributed under the License is distributed on an "AS IS" BASIS,
19447 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19448 * See the License for the specific language governing permissions and
19449 * limitations under the License.
19450 * =============================================================================
19451 */function q5(n){const{inputs:e,backend:t,attrs:s}=n,{images:r,dy:a}=e,{alignCorners:o}=s,i=new j5(a.shape,r.shape,o);return t.runWebGLProgram(i,[a],a.dtype)}const K5={kernelName:kc,backendName:"webgl",kernelFunc:q5};/**
19452 * @license
19453 * Copyright 2018 Google LLC. All Rights Reserved.
19454 * Licensed under the Apache License, Version 2.0 (the "License");
19455 * you may not use this file except in compliance with the License.
19456 * You may obtain a copy of the License at
19457 *
19458 * http://www.apache.org/licenses/LICENSE-2.0
19459 *
19460 * Unless required by applicable law or agreed to in writing, software
19461 * distributed under the License is distributed on an "AS IS" BASIS,
19462 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19463 * See the License for the specific language governing permissions and
19464 * limitations under the License.
19465 * =============================================================================
19466 */class X5{constructor(e,t,s,r,a){this.variableNames=["A"],this.outputShape=[];const[o,i,l,u]=e;this.outputShape=[o,t,s,u];const c=[r&&t>1?i-1:i,r&&s>1?l-1:l],h=[r&&t>1?t-1:t,r&&s>1?s-1:s],d=r?"0.5":"0.0";let p;a?p="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":p="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
19467      const vec2 effectiveInputOverOutputRatioRC = vec2(
19468          ${c[0]/h[0]},
19469          ${c[1]/h[1]});
19470      const vec2 inputShapeRC = vec2(${i}.0, ${l}.0);
19471
19472      void main() {
19473        ivec4 coords = getOutputCoords();
19474        int b = coords[0];
19475        int d = coords[3];
19476        ivec2 yRC = coords.yz;
19477
19478        // Fractional source index.
19479        vec2 sourceFracIndexRC = ${p};
19480
19481        // Compute the coordinators of nearest neighbor point.
19482        ivec2 sourceNearestRC = ivec2(
19483          min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${d})));
19484        float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
19485
19486        setOutput(newValue);
19487      }
19488    `}}/**
19489 * @license
19490 * Copyright 2019 Google LLC. All Rights Reserved.
19491 * Licensed under the Apache License, Version 2.0 (the "License");
19492 * you may not use this file except in compliance with the License.
19493 * You may obtain a copy of the License at
19494 *
19495 * http://www.apache.org/licenses/LICENSE-2.0
19496 *
19497 * Unless required by applicable law or agreed to in writing, software
19498 * distributed under the License is distributed on an "AS IS" BASIS,
19499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19500 * See the License for the specific language governing permissions and
19501 * limitations under the License.
19502 * =============================================================================
19503 */class Y5{constructor(e,t,s,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,i,l,u]=e;this.outputShape=[o,t,s,u];const c=[r&&t>1?i-1:i,r&&s>1?l-1:l],h=[r&&t>1?t-1:t,r&&s>1?s-1:s],d=r?"0.5":"0.0";let p;a?p="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":p="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
19504      const vec3 effectiveInputOverOutputRatioRC = vec3(
19505          ${c[0]/h[0]},
19506          ${c[1]/h[1]},
19507          ${c[1]/h[1]});
19508      const vec3 inputShapeRC = vec3(${i}.0, ${l}.0,
19509                                     ${l}.0);
19510
19511      float getAValue(int b, int r, int c, int d) {
19512        return getChannel(getA(b, r, c, d), vec2(c, d));
19513      }
19514
19515      void main() {
19516        ivec4 coords = getOutputCoords();
19517        int b = coords[0];
19518        int d = coords[3];
19519        // Calculate values for next column in yRC.z.
19520        ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
19521
19522        // Fractional source index.
19523        vec3 sourceFracIndexRC = ${p};
19524
19525        // Compute the coordinators of nearest neighbor point.
19526        ivec3 sourceNearestRC = ivec3(
19527          min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${d})));
19528
19529        // Should we calculate next column and row elements in 2x2 packed cell.
19530        bool hasNextCol = d < ${u-1};
19531        bool hasNextRow = coords.z < ${s-1};
19532
19533        vec4 newValue = vec4(
19534          getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),
19535          hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)
19536                     : 0.0,
19537          hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)
19538                     : 0.0,
19539          (hasNextRow && hasNextCol) ?
19540            getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);
19541
19542        setOutput(newValue);
19543      }
19544    `}}/**
19545 * @license
19546 * Copyright 2020 Google LLC. All Rights Reserved.
19547 * Licensed under the Apache License, Version 2.0 (the "License");
19548 * you may not use this file except in compliance with the License.
19549 * You may obtain a copy of the License at
19550 *
19551 * http://www.apache.org/licenses/LICENSE-2.0
19552 *
19553 * Unless required by applicable law or agreed to in writing, software
19554 * distributed under the License is distributed on an "AS IS" BASIS,
19555 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19556 * See the License for the specific language governing permissions and
19557 * limitations under the License.
19558 * =============================================================================
19559 */function J5(n){const{inputs:e,backend:t,attrs:s}=n,{images:r}=e,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,u]=i,c=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Y5(r.shape,l,u,a,o):new X5(r.shape,l,u,a,o);return t.runWebGLProgram(c,[r],r.dtype)}const Z5={kernelName:Ii,backendName:"webgl",kernelFunc:J5};/**
19560 * @license
19561 * Copyright 2018 Google LLC. All Rights Reserved.
19562 * Licensed under the Apache License, Version 2.0 (the "License");
19563 * you may not use this file except in compliance with the License.
19564 * You may obtain a copy of the License at
19565 *
19566 * http://www.apache.org/licenses/LICENSE-2.0
19567 *
19568 * Unless required by applicable law or agreed to in writing, software
19569 * distributed under the License is distributed on an "AS IS" BASIS,
19570 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19571 * See the License for the specific language governing permissions and
19572 * limitations under the License.
19573 * =============================================================================
19574 */class Q5{constructor(e,t,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,o,i]=e,l=[s&&o>1?r-1:r,s&&i>1?a-1:a],u=[s&&o>1?o-1:o,s&&i>1?i-1:i],c=l[0]/u[0],h=l[1]/u[1],d=1/c,p=1/h,f=Math.ceil(d)*2+2,g=Math.ceil(p)*2+2;this.userCode=`
19575      void main() {
19576        ivec4 coords = getOutputCoords();
19577        int b = coords[0];
19578        int d = coords[3];
19579        int r = coords[1];
19580        int c = coords[2];
19581
19582        float accumulator = 0.0;
19583
19584        const float heightScale = float(${c});
19585        const float widthScale = float(${h});
19586
19587        const float invHeightScale = float(${d});
19588        const float invWidthScale = float(${p});
19589
19590        const int winHeight = int(${f});
19591        const int winWidth = int(${g});
19592
19593        // Compute bounds for where in dy we will look
19594        float startRLerp = floor(float(r) * invHeightScale);
19595        int startDyR = int(floor(startRLerp - float(winHeight / 2)));
19596
19597        float startCLerp = floor(float(c) * invWidthScale);
19598        int startDyC = int(floor(startCLerp - float(winWidth / 2)));
19599
19600        // Loop over dy
19601        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
19602          int dyR = dyROffset + startDyR;
19603
19604          // Guard against the window exceeding the bounds of dy
19605          if (dyR < 0 || dyR >= ${o}) {
19606            continue;
19607          }
19608
19609          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
19610            int dyC = dyCOffset + startDyC;
19611
19612            // Guard against the window exceeding the bounds of dy
19613            if (dyC < 0 || dyC >= ${i}) {
19614              continue;
19615            }
19616
19617            float sourceFracRow =
19618              float(${l[0]}) *
19619                (float(dyR) / float(${u[0]}));
19620
19621            float sourceFracCol =
19622                float(${l[1]}) *
19623                  (float(dyC) / float(${u[1]}));
19624
19625            int sourceNearestRow = int(min(
19626                float(int(${r}) - 1),
19627                ${s} ? float(round(sourceFracRow)) :
19628                                  float(floor(sourceFracRow))));
19629
19630            int sourceNearestCol = int(min(
19631                float(int(${a}) - 1),
19632                ${s} ? float(round(sourceFracCol)) :
19633                                  float(floor(sourceFracCol))));
19634
19635            if (r == sourceNearestRow && c == sourceNearestCol) {
19636              accumulator += getDy(b, dyR, dyC, d);
19637            }
19638          }
19639        }
19640        // End loop over dy
19641
19642        setOutput(accumulator);
19643      }
19644    `}}/**
19645 * @license
19646 * Copyright 2020 Google LLC. All Rights Reserved.
19647 * Licensed under the Apache License, Version 2.0 (the "License");
19648 * you may not use this file except in compliance with the License.
19649 * You may obtain a copy of the License at
19650 *
19651 * http://www.apache.org/licenses/LICENSE-2.0
19652 *
19653 * Unless required by applicable law or agreed to in writing, software
19654 * distributed under the License is distributed on an "AS IS" BASIS,
19655 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19656 * See the License for the specific language governing permissions and
19657 * limitations under the License.
19658 * =============================================================================
19659 */function e6(n){const{inputs:e,backend:t,attrs:s}=n,{images:r,dy:a}=e,{alignCorners:o}=s,i=new Q5(a.shape,r.shape,o);return t.runWebGLProgram(i,[a],a.dtype)}const t6={kernelName:Tc,backendName:"webgl",kernelFunc:e6};/**
19660 * @license
19661 * Copyright 2017 Google LLC. All Rights Reserved.
19662 * Licensed under the Apache License, Version 2.0 (the "License");
19663 * you may not use this file except in compliance with the License.
19664 * You may obtain a copy of the License at
19665 *
19666 * http://www.apache.org/licenses/LICENSE-2.0
19667 *
19668 * Unless required by applicable law or agreed to in writing, software
19669 * distributed under the License is distributed on an "AS IS" BASIS,
19670 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19671 * See the License for the specific language governing permissions and
19672 * limitations under the License.
19673 * =============================================================================
19674 */class n6{constructor(e,t){this.variableNames=["x"];const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);if(this.outputShape=e,s===1){this.userCode=`
19675        void main() {
19676          int coord = getOutputCoords();
19677          setOutput(getX(${e[0]} - coord - 1));
19678        }
19679      `;return}const r=i=>t.indexOf(i)!==-1&&e[i]!==1?`${e[i]} - coords[${i}] - 1`:`coords[${i}]`,a=e.map((i,l)=>r(l)).join(","),o=Fe(s);this.userCode=`
19680      void main() {
19681        ${o} coords = getOutputCoords();
19682        setOutput(getX(${a}));
19683      }
19684    `}}/**
19685 * @license
19686 * Copyright 2019 Google LLC. All Rights Reserved.
19687 * Licensed under the Apache License, Version 2.0 (the "License");
19688 * you may not use this file except in compliance with the License.
19689 * You may obtain a copy of the License at
19690 *
19691 * http://www.apache.org/licenses/LICENSE-2.0
19692 *
19693 * Unless required by applicable law or agreed to in writing, software
19694 * distributed under the License is distributed on an "AS IS" BASIS,
19695 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19696 * See the License for the specific language governing permissions and
19697 * limitations under the License.
19698 * =============================================================================
19699 */class s6{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);this.outputShape=e;const r=Rt("rc",s),a=`${r[s-1]} + 1 < ${this.outputShape[s-1]}`,o=`${r[s-2]} + 1 < ${this.outputShape[s-2]}`,i=Fe(s);s===1?this.userCode=`
19700        void main(){
19701          int rc = getOutputCoords();
19702          vec4 result = vec4(0.);
19703          result.r = getChannel(getX(${e[0]} - rc - 1),
19704            ${e[0]} - rc - 1);
19705          if(${a}){
19706              result.g = getChannel(getX(${e[0]} - (rc  + 1) - 1),
19707                ${e[0]} - (rc  + 1) - 1);
19708          }
19709          setOutput(result);
19710        }
19711      `:this.userCode=`
19712        void main() {
19713          ${i} rc = getOutputCoords();
19714          vec4 result = vec4(0.);
19715          result.r = ${l(r.slice())};
19716          if(${a}){
19717            result.g = ${u(r.slice())};
19718          }
19719          if(${o}) {
19720            result.b = ${c(r.slice())};
19721            if(${a}) {
19722              result.a = ${h(r.slice())};
19723            }
19724          }
19725          setOutput(result);
19726        }
19727    `;function l(f){return d(f)}function u(f){return f[s-1]="("+f[s-1]+" + 1)",d(f)}function c(f){return f[s-2]="("+f[s-2]+" + 1)",d(f)}function h(f){return f[s-1]="("+f[s-1]+" + 1)",f[s-2]="("+f[s-2]+" + 1)",d(f)}function d(f){const g=e.map((x,v)=>p(v,f)),m=g.join(","),y=g.slice(-2).join(",");return`getChannel(getX(${m}), vec2(${y}))`}function p(f,g){return t.indexOf(f)!==-1&&e[f]!==1?`${e[f]}
19727 - ${g[f]} - 1`:`${g[f]}`}}}/**
19728 * @license
19729 * Copyright 2020 Google LLC. All Rights Reserved.
19730 * Licensed under the Apache License, Version 2.0 (the "License");
19731 * you may not use this file except in compliance with the License.
19732 * You may obtain a copy of the License at
19733 *
19734 * http://www.apache.org/licenses/LICENSE-2.0
19735 *
19736 * Unless required by applicable law or agreed to in writing, software
19737 * distributed under the License is distributed on an "AS IS" BASIS,
19738 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19739 * See the License for the specific language governing permissions and
19740 * limitations under the License.
19741 * =============================================================================
19742 */function r6(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{dims:a}=s,o=r.shape.length,i=Ie(a,r.shape);if(o===0)return Qt({inputs:{x:r},backend:t});const l=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new s6(r.shape,i):new n6(r.shape,i);return t.runWebGLProgram(l,[r],r.dtype)}const a6={kernelName:yi,backendName:"webgl",kernelFunc:r6};/**
19743 * @license
19744 * Copyright 2020 Google LLC. All Rights Reserved.
19745 * Licensed under the Apache License, Version 2.0 (the "License");
19746 * you may not use this file except in compliance with the License.
19747 * You may obtain a copy of the License at
19748 *
19749 * http://www.apache.org/licenses/LICENSE-2.0
19750 *
19751 * Unless required by applicable law or agreed to in writing, software
19752 * distributed under the License is distributed on an "AS IS" BASIS,
19753 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19754 * See the License for the specific language governing permissions and
19755 * limitations under the License.
19756 * =============================================================================
19757 */class o6{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const s=e[1],r=e[2];this.outputShape=e;let a="";typeof t=="number"?a=`float outputValue = ${t.toFixed(2)};`:a=`
19758        vec3 fill = vec3(${t.join(",")});
19759        float outputValue = fill[coords[3]];`,this.userCode=`
19760        void main() {
19761          ivec4 coords = getOutputCoords();
19762          int x = coords[2];
19763          int y = coords[1];
19764          float coordXFloat = (float(x) - params[0]) * params[3] -
19765            (float(y) - params[1]) * params[2];
19766          float coordYFloat = (float(x) - params[0]) * params[2] +
19767            (float(y) - params[1]) * params[3];
19768          int coordX = int(round(coordXFloat + params[0]));
19769          int coordY = int(round(coordYFloat + params[1]));
19770          ${a}
19771          if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${s}) {
19772            outputValue = getImage(coords[0], coordY, coordX, coords[3]);
19773          }
19774          setOutput(outputValue);
19775        }
19776    `}}/**
19777 * @license
19778 * Copyright 2020 Google LLC. All Rights Reserved.
19779 * Licensed under the Apache License, Version 2.0 (the "License");
19780 * you may not use this file except in compliance with the License.
19781 * You may obtain a copy of the License at
19782 *
19783 * http://www.apache.org/licenses/LICENSE-2.0
19784 *
19785 * Unless required by applicable law or agreed to in writing, software
19786 * distributed under the License is distributed on an "AS IS" BASIS,
19787 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19788 * See the License for the specific language governing permissions and
19789 * limitations under the License.
19790 * =============================================================================
19791 */const i6={kernelName:Qu,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:s}=n,{radians:r,fillValue:a,center:o}=e,i=t,l=new o6(s.shape,a),[u,c]=Ux(o,s.shape[1],s.shape[2]),h=[[u,c,Math.sin(r),Math.cos(r)]];return i.runWebGLProgram(l,[s],s.dtype,h)}};/**
19792 * @license
19793 * Copyright 2020 Google LLC. All Rights Reserved.
19794 * Licensed under the Apache License, Version 2.0 (the "License");
19795 * you may not use this file except in compliance with the License.
19796 * You may obtain a copy of the License at
19797 *
19798 * http://www.apache.org/licenses/LICENSE-2.0
19799 *
19800 * Unless required by applicable law or agreed to in writing, software
19801 * distributed under the License is distributed on an "AS IS" BASIS,
19802 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19803 * See the License for the specific language governing permissions and
19804 * limitations under the License.
19805 * =============================================================================
19806 */const l6=`
19807  // OpenGL ES does not support round function.
19808  // The algorithm is based on banker's rounding.
19809  float base = floor(x);
19810  if ((x - base) < 0.5) {
19811    return floor(x);
19812  } else if ((x - base) > 0.5) {
19813    return ceil(x);
19814  } else {
19815    if (mod(base, 2.0) == 0.0) {
19816      return base;
19817    } else {
19818      return base + 1.0;
19819    }
19820  }
19821`,u6=Te({opSnippet:l6}),c6={kernelName:ba,backendName:"webgl",kernelFunc:u6};/**
19822 * @license
19823 * Copyright 2020 Google LLC. All Rights Reserved.
19824 * Licensed under the Apache License, Version 2.0 (the "License");
19825 * you may not use this file except in compliance with the License.
19826 * You may obtain a copy of the License at
19827 *
19828 * http://www.apache.org/licenses/LICENSE-2.0
19829 *
19830 * Unless required by applicable law or agreed to in writing, software
19831 * distributed under the License is distributed on an "AS IS" BASIS,
19832 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19833 * See the License for the specific language governing permissions and
19834 * limitations under the License.
19835 * =============================================================================
19836 */const h6="return inversesqrt(x);",d6=Te({opSnippet:h6,cpuKernelImpl:NU}),p6={kernelName:wa,backendName:"webgl",kernelFunc:d6};/**
19837 * @license
19838 * Copyright 2018 Google LLC. All Rights Reserved.
19839 * Licensed under the Apache License, Version 2.0 (the "License");
19840 * you may not use this file except in compliance with the License.
19841 * You may obtain a copy of the License at
19842 *
19843 * http://www.apache.org/licenses/LICENSE-2.0
19844 *
19845 * Unless required by applicable law or agreed to in writing, software
19846 * distributed under the License is distributed on an "AS IS" BASIS,
19847 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19848 * See the License for the specific language governing permissions and
19849 * limitations under the License.
19850 * =============================================================================
19851 */class bg{constructor(e,t,s,r,a,o,i=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;const u=Fe(a.length),c=Fe(o.length);let h="";s===1?h="i":s===2&&(h="i, j");const d=`getIndices(${h})`;let p="";r===1?p="i":r===2&&(p="i, coords[1]");const f=`getUpdates(${p})`;let g="";l&&(g="coords[0], coords[1]");const m=`getDefaultValue(${g})`,y=t>1?"strides[j]":"strides";this.userCode=`
19852        ${u} strides = ${u}(${a});
19853
19854        void main() {
19855          ${c} coords = getOutputCoords();
19856          float sum = 0.0;
19857          bool found = false;
19858          for (int i = 0; i < ${e}; i++) {
19859            int flattenedIndex = 0;
19860            for (int j = 0; j < ${t}; j++) {
19861              int index = round(${d});
19862              flattenedIndex += index * ${y};
19863            }
19864            if (flattenedIndex == coords[0]) {
19865              sum += ${f};
19866              found = true;
19867            }
19868          }
19869          setOutput(mix(${m}, sum, float(found)));
19870        }
19871      `}}/**
19872 * @license
19873 * Copyright 2023 Google LLC.
19874 * Licensed under the Apache License, Version 2.0 (the "License");
19875 * you may not use this file except in compliance with the License.
19876 * You may obtain a copy of the License at
19877 *
19878 * http://www.apache.org/licenses/LICENSE-2.0
19879 *
19880 * Unless required by applicable law or agreed to in writing, software
19881 * distributed under the License is distributed on an "AS IS" BASIS,
19882 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19883 * See the License for the specific language governing permissions and
19884 * limitations under the License.
19885 * =============================================================================
19886 */class f6{constructor(e,t,s,r,a,o,i=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=o;const u=Fe(a.length),c=Fe(o.length);let h="";s===1?h="i":s===2&&(h="i, j");const d=`getIndices(${h})`;let p="";r===1?p="i":r===2&&(p="i, coords[1]");const f=`getUpdates(${p})`;let g="";l&&(g="coords[0], coords[1]");const m=`getDefaultValue(${g})`,y=t>1?"strides[j]":"strides",x=t>1?"strides[j + 1]":"strides";this.userCode=`
19887        ${u} strides = ${u}(${a});
19888
19889        void main() {
19890          ${c} coords = getOutputCoords();
19891          vec4 sum = vec4(0.);
19892          vec4 found = vec4(0.);
19893          for (int i = 0; i < ${e}; i+=2) {
19894            ivec2 flattenedIndex = ivec2(0);
19895            for (int j = 0; j < ${t}; j+=2) {
19896              ivec4 index = round(${d});
19897              flattenedIndex += index.xz * ${y};
19898              if (j + 1 < ${t}) {
19899                flattenedIndex += index.yw * ${x};
19900              }
19901            }
19902            if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] ||
19903                flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) {
19904              vec4 updVals = ${f};
19905              if (flattenedIndex[0] == coords[0]) {
19906                sum.xy += updVals.xy;
19907                found.xy = vec2(1.);
19908              } else if (flattenedIndex[0] == coords[0] + 1) {
19909                sum.zw += updVals.xy;
19910                found.zw = vec2(1.);
19911              }
19912              if (flattenedIndex[1] == coords[0]) {
19913                sum.xy += updVals.zw;
19914                found.xy = vec2(1.);
19915              } else if (flattenedIndex[1] == coords[0] + 1) {
19916                sum.zw += updVals.zw;
19917                found.zw = vec2(1.);
19918              }
19919            }
19920          }
19921          setOutput(mix(${m}, sum, found));
19922        }
19923      `}}/**
19924 * @license
19925 * Copyright 2020 Google LLC. All Rights Reserved.
19926 * Licensed under the Apache License, Version 2.0 (the "License");
19927 * you may not use this file except in compliance with the License.
19928 * You may obtain a copy of the License at
19929 *
19930 * http://www.apache.org/licenses/LICENSE-2.0
19931 *
19932 * Unless required by applicable law or agreed to in writing, software
19933 * distributed under the License is distributed on an "AS IS" BASIS,
19934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19935 * See the License for the specific language governing permissions and
19936 * limitations under the License.
19937 * =============================================================================
19938 */function m6(n){const{inputs:e,backend:t,attrs:s}=n,{indices:r,updates:a}=e,{shape:o}=s,{sliceRank:i,numUpdates:l,sliceSize:u,strides:c,outputSize:h}=Aa(a,r,o),d=[h/u,u];if(h===0)return t.makeTensorInfo(o,r.dtype);const p=ne({inputs:{x:r},backend:t,attrs:{shape:[l,i]}}),f=ne({inputs:{x:a},backend:t,attrs:{shape:[l,u]}}),g=t.makeTensorInfo([],"float32",new Float32Array([0]));let m;W().getBool("WEBGL_PACK")?m=new f6(l,i,p.shape.length,f.shape.length,c,d):m=new bg(l,i,p.shape.length,f.shape.length,c,d);const y=t.runWebGLProgram(m,[f,p,g],f.dtype),x=ne({inputs:{x:y},backend:t,attrs:{shape:o}});
vendor: 4,268 bytes, lines 19938-20021
19938return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(g),x}const g6={kernelName:Hu,backendName:"webgl",kernelFunc:m6};/**
19939 * @license
19940 * Copyright 2022 Google LLC. All Rights Reserved.
19941 * Licensed under the Apache License, Version 2.0 (the "License");
19942 * you may not use this file except in compliance with the License.
19943 * You may obtain a copy of the License at
19944 *
19945 * http://www.apache.org/licenses/LICENSE-2.0
19946 *
19947 * Unless required by applicable law or agreed to in writing, software
19948 * distributed under the License is distributed on an "AS IS" BASIS,
19949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19950 * See the License for the specific language governing permissions and
19951 * limitations under the License.
19952 * =============================================================================
19953 */class y6{constructor(e,t,s,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,s];const a="while (left < right) {",o=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=W().getNumber("WEBGL_VERSION")===2?a:o,l=r==="left"?"<":"<=";this.userCode=`
19954       int findBound(int batch, float value) {
19955         int left = 0;
19956         int right = numInputs;
19957         int mid;
19958         ${i}
19959           mid = (left + right) / 2;
19960           if (getSortedSequence(batch, mid) ${l} value) {
19961             left = mid + 1;
19962           } else {
19963             right = mid;
19964           }
19965         }
19966         return right;
19967       }
19968
19969       void main() {
19970         ivec2 coords = getOutputCoords();
19971         int batch = coords[0];
19972         int valueIndex = coords[1];
19973
19974         float value = getValues(batch, valueIndex);
19975
19976         setOutput(float(findBound(batch, value)));
19977       }
19978     `}}/**
19979 * @license
19980 * Copyright 2022 Google LLC. All Rights Reserved.
19981 * Licensed under the Apache License, Version 2.0 (the "License");
19982 * you may not use this file except in compliance with the License.
19983 * You may obtain a copy of the License at
19984 *
19985 * http://www.apache.org/licenses/LICENSE-2.0
19986 *
19987 * Unless required by applicable law or agreed to in writing, software
19988 * distributed under the License is distributed on an "AS IS" BASIS,
19989 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19990 * See the License for the specific language governing permissions and
19991 * limitations under the License.
19992 * =============================================================================
19993 */function x6(n){const{inputs:e,backend:t,attrs:s}=n,{sortedSequence:r,values:a}=e,{side:o}=s,i=new y6(r.shape[0],r.shape[1],a.shape[1],o),l=[[r.shape[1]]];return t.runWebGLProgram(i,[r,a],"int32",l)}const b6={kernelName:Du,backendName:"webgl",kernelFunc:x6};/**
19994 * @license
19995 * Copyright 2017 Google LLC. All Rights Reserved.
19996 * Licensed under the Apache License, Version 2.0 (the "License");
19997 * you may not use this file except in compliance with the License.
19998 * You may obtain a copy of the License at
19999 *
20000 * http://www.apache.org/licenses/LICENSE-2.0
20001 *
20002 * Unless required by applicable law or agreed to in writing, software
20003 * distributed under the License is distributed on an "AS IS" BASIS,
20004 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20005 * See the License for the specific language governing permissions and
20006 * limitations under the License.
20007 * =============================================================================
20008 */class w6{constructor(e,t,s){this.variableNames=["c","a","b"],this.outputShape=t;let r,a;if(s>4)throw Error(`Where for rank ${s} is not yet supported`);if(s===1)a="resRC",r="resRC";else{const i=["resRC.x","resRC.y","resRC.z","resRC.w"],l=[],u=[];for(let c=0;c<t.length;c++)u.push(`${i[c]}`),c<e&&l.push(`${i[c]}`);r=l.join(),a=u.join()}const o=Fe(s);this.userCode=`
20009      void main() {
20010        ${o} resRC = getOutputCoords();
20011        float cVal = getC(${r});
20012        if (cVal >= 1.0) {
20013          setOutput(getA(${a}));
20014        } else {
20015          setOutput(getB(${a}));
20016        }
20017      }
20018    `}}/**
20019 * @license
20020 * Copyright 2020 Google LLC. All Rights Reserved.
20021 * Licensed under the Apache License, Version 2.0 (the "License");
20022 * you may not use this file except in compliance with the License.
20023 * You may obtain a copy of the License at
20024 *
20025 * http://www.apache.org/licenses/LICENSE-2.0
20026 *
20027 * Unless required by applicable law or agreed to in writing, software
20028 * distributed under the License is distributed on an "AS IS" BASIS,
20029 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20030 * See the License for the specific language governing permissions and
20031 * limitations under the License.
20032 * =============================================================================
20033 */function v6(n){const{inputs:e,backend:t}=n,{condition:s,t:r,e:a}=e,o=new w6(s.shape.length,r.shape,r.shape.length);return t.runWebGLProgram(o,[s,r,a],bn(r.dtype,a.dtype))}const C6={kernelName:Ko,backendName:"webgl",kernelFunc:v6};/**
20034 * @license
20035 * Copyright 2020 Google LLC. All Rights Reserved.
20036 * Licensed under the Apache License, Version 2.0 (the "License");
20037 * you may not use this file except in compliance with the License.
20038 * You may obtain a copy of the License at
20039 *
20040 * http://www.apache.org/licenses/LICENSE-2.0
20041 *
20042 * Unless required by applicable law or agreed to in writing, software
20043 * distributed under the License is distributed on an "AS IS" BASIS,
20044 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20045 * See the License for the specific language governing permissions and
20046 * limitations under the License.
20047 * =============================================================================
20048 */const $6=`
20049  // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
20050  // see: https://arxiv.org/abs/1706.02515
20051  float scaleAlpha = ${Ud};
20052  float scale = ${Gd};
20053  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
20054`,N6=Te({opSnippet:$6}),I6={kernelName:va,backendName:"webgl",kernelFunc:N6};/**
20055 * @license
20056 * Copyright 2020 Google LLC. All Rights Reserved.
20057 * Licensed under the Apache License, Version 2.0 (the "License");
20058 * you may not use this file except in compliance with the License.
20059 * You may obtain a copy of the License at
20060 *
20061 * http://www.apache.org/licenses/LICENSE-2.0
20062 *
20063 * Unless required by applicable law or agreed to in writing, software
20064 * distributed under the License is distributed on an "AS IS" BASIS,
20065 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20066 * See the License for the specific language governing permissions and
20067 * limitations under the License.
20068 * =============================================================================
20069 */const S6=Qa+`
20070  return 1.0 / (1.0 + exp(-1.0 * x));
20071`,k6=`
20072  vec4 result = 1.0 / (1.0 + exp(-1.0 * x));
20073  bvec4 isNaN = isnan(x);
20074
20075  result.r = isNaN.r ? x.r : result.r;
20076  result.g = isNaN.g ? x.g : result.g;
20077  result.b = isNaN.b ? x.b : result.b;
20078  result.a = isNaN.a ? x.a : result.a;
20079
20080  return result;
20081`,T6=Te({opSnippet:S6,packedOpSnippet:k6,cpuKernelImpl:SU}),E6={kernelName:Li,backendName:"webgl",kernelFunc:T6};/**
20082 * @license
20083 * Copyright 2020 Google LLC. All Rights Reserved.
20084 * Licensed under the Apache License, Version 2.0 (the "License");
20085 * you may not use this file except in compliance with the License.
20086 * You may obtain a copy of the License at
20087 *
20088 * http://www.apache.org/licenses/LICENSE-2.0
20089 *
20090 * Unless required by applicable law or agreed to in writing, software
20091 * distributed under the License is distributed on an "AS IS" BASIS,
20092 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20093 * See the License for the specific language governing permissions and
20094 * limitations under the License.
20095 * =============================================================================
20096 */const R6=`
20097  if (isnan(x)) { return 0.0; }
20098  return sign(x);
20099`,D6=Te({opSnippet:R6}),A6={kernelName:Ca,backendName:"webgl",kernelFunc:D6};/**
20100 * @license
20101 * Copyright 2020 Google LLC. All Rights Reserved.
20102 * Licensed under the Apache License, Version 2.0 (the "License");
20103 * you may not use this file except in compliance with the License.
20104 * You may obtain a copy of the License at
20105 *
20106 * http://www.apache.org/licenses/LICENSE-2.0
20107 *
20108 * Unless required by applicable law or agreed to in writing, softw
20108are
20109 * distributed under the License is distributed on an "AS IS" BASIS,
20110 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20111 * See the License for the specific language governing permissions and
20112 * limitations under the License.
20113 * =============================================================================
20114 */const O6=Qa+`
20115  return sin(x);
20116`,_6=`
20117  vec4 result = sin(x);
20118  bvec4 isNaN = isnan(x);
20119  ${$r}
20120  return result;
20121`,F6=Te({opSnippet:O6,packedOpSnippet:_6}),L6={kernelName:$a,backendName:"webgl",kernelFunc:F6};/**
20122 * @license
20123 * Copyright 2020 Google LLC. All Rights Reserved.
20124 * Licensed under the Apache License, Version 2.0 (the "License");
20125 * you may not use this file except in compliance with the License.
20126 * You may obtain a copy of the License at
20127 *
20128 * http://www.apache.org/licenses/LICENSE-2.0
20129 *
20130 * Unless required by applicable law or agreed to in writing, software
20131 * distributed under the License is distributed on an "AS IS" BASIS,
20132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20133 * See the License for the specific language governing permissions and
20134 * limitations under the License.
20135 * =============================================================================
20136 */const P6=`
20137  float e2x = exp(x);
20138  return (e2x - 1.0 / e2x) / 2.0;
20139`,z6=Te({opSnippet:P6}),V6={kernelName:Na,backendName:"webgl",kernelFunc:z6};/**
20140 * @license
20141 * Copyright 2020 Google LLC. All Rights Reserved.
20142 * Licensed under the Apache License, Version 2.0 (the "License");
20143 * you may not use this file except in compliance with the License.
20144 * You may obtain a copy of the License at
20145 *
20146 * http://www.apache.org/licenses/LICENSE-2.0
20147 *
20148 * Unless required by applicable law or agreed to in writing, software
20149 * distributed under the License is distributed on an "AS IS" BASIS,
20150 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20151 * See the License for the specific language governing permissions and
20152 * limitations under the License.
20153 * =============================================================================
20154 */const B6=`
20155  float epsilon = 1.1920928955078125e-7;
20156  float threshold = log(epsilon) + 2.0;
20157
20158  bool too_large = x > -threshold;
20159  bool too_small = x < threshold;
20160
20161  float result;
20162  float exp_x = exp(x);
20163
20164  if (too_large){
20165    result = x;
20166  }
20167  else if (too_small){
20168    result = exp_x;
20169  }
20170  else{
20171    result = log(exp_x + 1.0);
20172  }
20173  return result;
20174`,M6=Te({opSnippet:B6}),W6={kernelName:ma,backendName:"webgl",kernelFunc:M6};/**
20175 * @license
20176 * Copyright 2020 Google LLC. All Rights Reserved.
20177 * Licensed under the Apache License, Version 2.0 (the "License");
20178 * you may not use this file except in compliance with the License.
20179 * You may obtain a copy of the License at
20180 *
20181 * http://www.apache.org/licenses/LICENSE-2.0
20182 *
20183 * Unless required by applicable law or agreed to in writing, software
20184 * distributed under the License is distributed on an "AS IS" BASIS,
20185 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20186 * See the License for the specific language governing permissions and
20187 * limitations under the License.
20188 * =============================================================================
20189 */const U6=n=>{const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{blockShape:a,paddings:o}=s;I(r.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const i=a.reduce((y,x)=>y*x),l=[[0,0]];l.push(...o);for(let y=1+a.length;y<r.shape.length;++y)l.push([0,0]);const u=[],c=vC({inputs:{x:r},backend:t,attrs:{paddings:l,constantValue:0}}),h=Fc(c.shape,a,i,!1),d=Lc(h.length,a.length,!1),p=Pc(c.shape,a,i,!1),f=ne({inputs:{x:c},backend:t,attrs:{shape:h}}),g=_t({inputs:{x:f},backend:t,attrs:{perm:d}}),m=ne({inputs:{x:g},backend:t,attrs:{shape:p}});return u.push(c),u.push(f),u.push(g),u.forEach(y=>t.disposeIntermediateTensorInfo(y)),m},G6={kernelName:mi,backendName:"webgl",kernelFunc:U6};/**
20190 * @license
20191 * Copyright 2021 Google LLC. All Rights Reserved.
20192 * Licensed under the Apache License, Version 2.0 (the "License");
20193 * you may not use this file except in compliance with the License.
20194 * You may obtain a copy of the License at
20195 *
20196 * http://www.apache.org/licenses/LICENSE-2.0
20197 *
20198 * Unless required by applicable law or agreed to in writing, softw
20198are
20199 * distributed under the License is distributed on an "AS IS" BASIS,
20200 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20201 * See the License for the specific language governing permissions and
20202 * limitations under the License.
20203 * =============================================================================
20204 */function H6(n){const{inputs:e,backend:t}=n,{indices:s,values:r,denseShape:a,defaultValue:o}=e;if(a.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
20205         ${a.shape}`);if(s.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
20206         ${s.shape}`);if(r.shape.length!==1)throw new Error(`Values must be a vector, saw:
20207         ${r.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
20208        ${o.shape}`);const i=t.readSync(s.dataId),l=t.readSync(r.dataId),u=t.readSync(a.dataId),c=t.readSync(o.dataId)[0],[h,d,p,f,g]=TU(i,s.shape,s.dtype,l,r.dtype,u,c);return[t.makeTensorInfo(d,s.dtype,h),t.makeTensorInfo([d[0]],r.dtype,p),t.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(m=>Number(m)))),t.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const j6={kernelName:rc,backendName:"webgl",kernelFunc:H6};/**
20209 * @license
20210 * Copyright 2021 Google LLC. All Rights Reserved.
20211 * Licensed under the Apache License, Version 2.0 (the "License");
20212 * you may not use this file except in compliance with the License.
20213 * You may obtain a copy of the License at
20214 *
20215 * http://www.apache.org/licenses/LICENSE-2.0
20216 *
20217 * Unless required by applicable law or agreed to in writing, software
20218 * distributed under the License is distributed on an "AS IS" BASIS,
20219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20220 * See the License for the specific language governing permissions and
20221 * limitations under the License.
20222 * =============================================================================
20223 */function q6(n){const{inputs:e,backend:t}=n,{inputIndices:s,inputShape:r,newShape:a}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${r.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(r.dataId)),i=t.readSync(s.dataId),l=Array.from(t.readSync(a.dataId)),[u,c,h]=EU(i,s.shape,s.dtype,o,l);return[t.makeTensorInfo(c,s.dtype,u),t.makeTensorInfo([h.length],a.dtype,new Int32Array(h))]}const K6={kernelName:ac,backendName:"webgl",kernelFunc:q6};/**
20224 * @license
20225 * Copyright 2021 Google LLC. All Rights Reserved.
20226 * Licensed under the Apache License, Version 2.0 (the "License");
20227 * you may not use this file except in compliance with the License.
20228 * You may obtain a copy of the License at
20229 *
20230 * http://www.apache.org/licenses/LICENSE-2.0
20231 *
20232 * Unless required by applicable law or agreed to in writing, software
20233 * distributed under the License is distributed on an "AS IS" BASIS,
20234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20235 * See the License for the specific language governing permissions and
20236 * limitations under the License.
20237 * =============================================================================
20238 */function X6(n){const{inputs:e,backend:t}=n,{data:s,indices:r,segmentIds:a}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
20239              ${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
20240              ${a.shape}`);const o=t.readSync(s.dataId),i=t.readSync(r.dataId),l=t.readSync(a.dataId),[u,c]=Gv(o,s.shape,s.dtype,i,l,!0);return t.makeTensorInfo(c,s.dtype,u)}const Y6={kernelName:oc,backendName:"webgl",kernelFunc:X6};/**
20241 * @license
20242 * Copyright 2021 Google LLC. All Rights Reserved.
20243 * Licensed under the Apache License, Version 2.0 (the "License");
20244 * you may not use this file except in compliance with the License.
20245 * You may obtain a copy of the License at
20246 *
20247 * http://www.apache.org/licenses/LICENSE-2.0
20248 *
20249 * Unless required by applicable law or agreed to in writing, softw
20249are
20250 * distributed under the License is distributed on an "AS IS" BASIS,
20251 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20252 * See the License for the specific language governing permissions and
20253 * limitations under the License.
20254 * =============================================================================
20255 */function J6(n){const{inputs:e,backend:t}=n,{data:s,indices:r,segmentIds:a}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
20256             ${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
20257             ${a.shape}`);const o=t.readSync(s.dataId),i=t.readSync(r.dataId),l=t.readSync(a.dataId),[u,c]=Gv(o,s.shape,s.dtype,i,l);return t.makeTensorInfo(c,s.dtype,u)}const Z6={kernelName:ic,backendName:"webgl",kernelFunc:J6};/**
20258 * @license
20259 * Copyright 2020 Google LLC. All Rights Reserved.
20260 * Licensed under the Apache License, Version 2.0 (the "License");
20261 * you may not use this file except in compliance with the License.
20262 * You may obtain a copy of the License at
20263 *
20264 * http://www.apache.org/licenses/LICENSE-2.0
20265 *
20266 * Unless required by applicable law or agreed to in writing, software
20267 * distributed under the License is distributed on an "AS IS" BASIS,
20268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20269 * See the License for the specific language governing permissions and
20270 * limitations under the License.
20271 * =============================================================================
20272 */function Q6(n){const{inputs:e,backend:t,attrs:s}=n,{sparseIndices:r,sparseValues:a,defaultValue:o}=e,{outputShape:i}=s,{sliceRank:l,numUpdates:u,sliceSize:c,strides:h,outputSize:d}=Aa(a,r,i),p=!1;if(a.dtype==="string"){const y=t.bufferSync(r),x=t.bufferSync(a),v=Gi(t.readSync(o.dataId)[0]),b=IU(y,x,i,d,c,u,l,h,v,p);return t.makeTensorInfo(i,b.dtype,b.values)}const f=new bg(u,l,r.shape.length,a.shape.length,h,[d,1],p),g=t.runWebGLProgram(f,[a,r,o],a.dtype),m=ne({inputs:{x:g},backend:t,attrs:{shape:i}});return t.disposeIntermediateTensorInfo(g),m}const eY={kernelName:ju,backendName:"webgl",kernelFunc:Q6};/**
20273 * @license
20274 * Copyright 2020 Google LLC. All Rights Reserved.
20275 * Licensed under the Apache License, Version 2.0 (the "License");
20276 * you may not use this file except in compliance with the License.
20277 * You may obtain a copy of the License at
20278 *
20279 * http://www.apache.org/licenses/LICENSE-2.0
20280 *
20281 * Unless required by applicable law or agreed to in writing, software
20282 * distributed under the License is distributed on an "AS IS" BASIS,
20283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20284 * See the License for the specific language governing permissions and
20285 * limitations under the License.
20286 * =============================================================================
20287 */function tY(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{numOrSizeSplits:a,axis:o}=s,i=Ie(o,r.shape)[0],l=Gx(r,a,i),u=r.shape.length,c=new Array(u).fill(0),h=r.shape.slice();return l.map(d=>{const p=[...h];p[i]=d;const f=eo({inputs:{x:r},backend:t,attrs:{begin:c,size:p}});return c[i]+=d,f})}const nY={kernelName:bi,backendName:"webgl",kernelFunc:tY};/**
20288 * @license
20289 * Copyright 2020 Google LLC. All Rights Reserved.
20290 * Licensed under the Apache License, Version 2.0 (the "License");
20291 * you may not use this file except in compliance with the License.
20292 * You may obtain a copy of the License at
20293 *
20294 * http://www.apache.org/licenses/LICENSE-2.0
20295 *
20296 * Unless required by applicable law or agreed to in writing, software
20297 * distributed under the License is distributed on an "AS IS" BASIS,
20298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20299 * See the License for the specific language governing permissions and
20300 * limitations under the License.
20301 * =============================================================================
20302 */const Gy="return sqrt(x);",sY=Te({opSnippet:Gy,packedOpSnippet:Gy,cpuKernelImpl:RU}),rY={kernelName:Pi,backendName:"webgl",kernelFunc:sY};/**
20303 * @license
20304 * Copyright 2019 Google LLC. All Rights Reserved.
20305 * Licensed under the Apache License, Version 2.0 (the "License");
20306 * you may not use this file except in compliance with the License.
20307 * You may obtain a copy of the License at
20308 *
20309 * http://www.apache.org/licenses/LICENSE-2.0
20310 *
20311 * Unless required by applicable law or agreed to in writing, software
20312 * distributed under the License is distributed on an "AS IS" BASIS,
20313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20314 * See the License for the specific language governing permissions and
20315 * limitations under the License.
20316 * =============================================================================
20317 */const aY="return x * x;",oY=Te({opSnippet:aY}),iY={kernelName:Ec,backendName:"webgl",kernelFunc:oY};/**
20318 * @license
20319 * Copyright 2020 Google LLC. All Rights Reserved.
20320 * Licensed under the Apache License, Version 2.0 (the "License");
20321 * you may not use this file except in compliance with the License.
20322 * You may obtain a copy of the License at
20323 *
20324 * http://www.apache.org/licenses/LICENSE-2.0
20325 *
20326 * Unless required by applicable law or agreed to in writing, software
20327 * distributed under the License is distributed on an "AS IS" BASIS,
20328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20329 * See the License for the specific language governing permissions and
20330 * limitations under the License.
20331 * =============================================================================
20332 */const Hy="return (a - b) * (a - b);",lY=Nt({opSnippet:Hy,packedOpSnippet:Hy}),uY={kernelName:Ia,backendName:"webgl",kernelFunc:lY};/**
20333 * @license
20334 * Copyright 2023 Google LLC.
20335 * Licensed under the Apache License, Version 2.0 (the "License");
20336 * you may not use this file except in compliance with the License.
20337 * You may obtain a copy of the License at
20338 *
20339 * http://www.apache.org/licenses/LICENSE-2.0
20340 *
20341 * Unless required by applicable law or agreed to in writing, software
20342 * distributed under the License is distributed on an "AS IS" BASIS,
20343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20344 * See the License for the specific language governing permissions and
20345 * limitations under the License.
20346 * =============================================================================
20347 */function cY(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");const a=t.readSync(r.dataId),o=Dr(a),i=DU(o,"string",s);return t.makeTensorInfo(r.shape,"string",i)}const hY={kernelName:Si,backendName:"webgl",kernelFunc:cY};/**
20348 * @license
20349 * Copyright 2020 Google LLC. All Rights Reserved.
20350 * Licensed under the Apache License, Version 2.0 (the "License");
20351 * you may not use this file except in compliance with the License.
20352 * You may obtain a copy of the License at
20353 *
20354 * http://www.apache.org/licenses/LICENSE-2.0
20355 *
20356 * Unless required by applicable law or agreed to in writing, software
20357 * distributed under the License is distributed on an "AS IS" BASIS,
20358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20359 * See the License for the specific language governing permissions and
20360 * limitations under the License.
20361 * =============================================================================
20362 */function dY({inputs:n,attrs:e,backend:t}){const{x:s}=n,r=Cn+`
20363    return x > 0.0 ? 1.0 : float(${e.alpha});
20364  `,a=new Bn(s.shape,r);return t.runWebGLProgram(a,[s],s.dtype)}const pY={kernelName:zi,backendName:"webgl",kernelFunc:dY};/**
20365 * @license
20366 * Copyright 2017 Google LLC. All Rights Reserved.
20367 * Licensed under the Apache License, Version 2.0 (the "License");
20368 * you may not use this file except in compliance with the License.
20369 * You may obtain a copy of the License at
20370 *
20371 * http://www.apache.org/licenses/LICENSE-2.0
20372 *
20373 * Unless required by applicable law or agreed to in writing, software
20374 * distributed under the License is distributed on an "AS IS" BASIS,
20375 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20376 * See the License for the specific language governing permissions and
20377 * limitations under the License.
20378 * =============================================================================
20379 */class fY{constructor(e,t,s){this.variableNames=["x"],this.outputShape=s;const r=s.length,a=Fe(s.length),o=Fe(s.length);let i="";if(r===1)i="coords * strides + begin";else{let l=0;i=s.map((u,c)=>(l++,s.length===1?`coords * strides[${c}] + begin[${c}]`:`coords[${l-1}] * strides[${c}] + begin[${c}]`)).join(",")}this.userCode=`
20380      ${a} begin = ${a}(${e});
20381      ${a} strides = ${a}(${t});
20382
20383      void main() {
20384        ${o} coords = getOutputCoords();
20385        setOutput(getX(${i}));
20386      }
20387    `}}/**
20388 * @license
20389 * Copyright 2020 Google LLC. All Rights Reserved.
20390 * Licensed under the Apache License, Version 2.0 (the "License");
20391 * you may not use this file except in compliance with the License.
20392 * You may obtain a copy of the License at
20393 *
20394 * http://www.apache.org/licenses/LICENSE-2.0
20395 *
20396 * Unless required by applicable law or agreed to in writing, software
20397 * distributed under the License is distributed on an "AS IS" BASIS,
20398 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20399 * See the License for the specific language governing permissions and
20400 * limitations under the License.
20401 * =============================================================================
20402 */function mY(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{begin:a,end:o,strides:i,beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:h,shrinkAxisMask:d}=s,{finalShapeSparse:p,finalShape:f,isIdentity:g,sliceDim0:m,isSimpleSlice:y,begin:x,end:v,strides:b}=Hx(r.shape,a,o,i,l,u,c,h,d);let C;if(g)C=ne({inputs:{x:r},backend:t,attrs:{shape:f}});else if(m||y){I(r.shape.length>=1,()=>`Input must have rank at least 1, got: ${r.shape.length}`);const S=jx(x,v,b),k=eo({inputs:{x:r},backend:t,attrs:{begin:x,size:S}});C=ne({inputs:{x:k},backend:t,attrs:{shape:f}}),t.disposeIntermediateTensorInfo(k)}else if(t.shouldExecuteOnCPU([r])){const k=t.readSync(r.dataId),T=$e(r.shape,r.dtype,k),E=AU(p,T,b,x);C=t.makeTensorInfo(f,r.dtype,E.values)}else{const k=new fY(x,b,p);C=t.runWebGLProgram(k,[r],r.dtype)}const $=ne({inputs:{x:C},backend:t,attrs:{shape:f}});return t.disposeIntermediateTensorInfo(C),$}const gY={kernelName:Mu,backendName:"webgl",kernelFunc:mY};/**
20403 * @license
20404 * Copyright 2021 Google LLC. All Rights Reserved.
20405 * Licensed under the Apache License, Version 2.0 (the "License");
20406 * you may not use this file except in compliance with the License.
20407 * You may obtain a copy of the License at
20408 *
20409 * http://www.apache.org/licenses/LICENSE-2.0
20410 *
20411 * Unless required by applicable law or agreed to in writing, software
20412 * distributed under the License is distributed on an "AS IS" BASIS,
20413 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20414 * See the License for the specific language governing permissions and
20415 * limitations under the License.
20416 * =============================================================================
20417 */function yY(n){const{inputs:e,backend:t,attrs:s}=n,{separator:r,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:u}=s,{data:c,dataSplits:h}=e,d=t.readSync(c.dataId),p=t.readSync(h.dataId),[f,g]=OU(d,p,r,a,o,i,l,u);return[t.makeTensorInfo([f.length],"string",f),t.makeTensorInfo(h.shape,"int32",g)]}const xY={kernelName:lc,backendName:"webgl",kernelFunc:yY};/**
20418 * @license
20419 * Copyright 2021 Google LLC. All Rights Reserved.
20420 * Licensed under the Apache License, Version 2.0 (the "License");
20421 * you may not use this file except in compliance with the License.
20422 * You may obtain a copy of the License at
20423 *
20424 * http://www.apache.org/licenses/LICENSE-2.0
20425 *
20426 * Unless required by applicable law or agreed to in writing, software
20427 * distributed under the License is distributed on an "AS IS" BASIS,
20428 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20429 * See the License for the specific language governing permissions and
20430 * limitations under the License.
20431 * =============================================================================
20432 */function bY(n){const{inputs:e,backend:t,attrs:s}=n,{skipEmpty:r}=s,{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),l=t.readSync(o.dataId)[0],[u,c,h]=_U(i,l,r),d=c.length;return[t.makeTensorInfo([d,2],"int32",u),t.makeTensorInfo([d],"string",c),t.makeTensorInfo([2],"int32",new Int32Array(h))]}const wY={kernelName:uc,backendName:"webgl",kernelFunc:bY};/**
20433 * @license
20434 * Copyright 2021 Google LLC. All Rights Reserved.
20435 * Licensed under the Apache License, Version 2.0 (the "License");
20436 * you may not use this file except in compliance with the License.
20437 * You may obtain a copy of the License at
20438 *
20439 * http://www.apache.org/licenses/LICENSE-2.0
20440 *
20441 * Unless required by applicable law or agreed to in writing, softw
20441are
20442 * distributed under the License is distributed on an "AS IS" BASIS,
20443 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20444 * See the License for the specific language governing permissions and
20445 * limitations under the License.
20446 * =============================================================================
20447 */function vY(n){const{inputs:e,backend:t,attrs:s}=n,{numBuckets:r}=s,{input:a}=e;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");const o=t.readSync(a.dataId),i=FU(o,r);return t.makeTensorInfo(a.shape,"int32",i)}const CY={kernelName:cc,backendName:"webgl",kernelFunc:vY};/**
20448 * @license
20449 * Copyright 2020 Google LLC. All Rights Reserved.
20450 * Licensed under the Apache License, Version 2.0 (the "License");
20451 * you may not use this file except in compliance with the License.
20452 * You may obtain a copy of the License at
20453 *
20454 * http://www.apache.org/licenses/LICENSE-2.0
20455 *
20456 * Unless required by applicable law or agreed to in writing, software
20457 * distributed under the License is distributed on an "AS IS" BASIS,
20458 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20459 * See the License for the specific language governing permissions and
20460 * limitations under the License.
20461 * =============================================================================
20462 */const $Y="return tan(x);",NY=Te({opSnippet:$Y}),IY={kernelName:Sa,backendName:"webgl",kernelFunc:NY};/**
20463 * @license
20464 * Copyright 2020 Google LLC. All Rights Reserved.
20465 * Licensed under the Apache License, Version 2.0 (the "License");
20466 * you may not use this file except in compliance with the License.
20467 * You may obtain a copy of the License at
20468 *
20469 * http://www.apache.org/licenses/LICENSE-2.0
20470 *
20471 * Unless required by applicable law or agreed to in writing, software
20472 * distributed under the License is distributed on an "AS IS" BASIS,
20473 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20474 * See the License for the specific language governing permissions and
20475 * limitations under the License.
20476 * =============================================================================
20477 */const SY=`
20478  float e2x = exp(-2.0 * abs(x));
20479  return sign(x) * (1.0 - e2x) / (1.0 + e2x);
20480`,kY=Te({opSnippet:SY}),TY={kernelName:Zr,backendName:"webgl",kernelFunc:kY};/**
20481 * @license
20482 * Copyright 2022 Google LLC. All Rights Reserved.
20483 * Licensed under the Apache License, Version 2.0 (the "License");
20484 * you may not use this file except in compliance with the License.
20485 * You may obtain a copy of the License at
20486 *
20487 * http://www.apache.org/licenses/LICENSE-2.0
20488 *
20489 * Unless required by applicable law or agreed to in writing, software
20490 * distributed under the License is distributed on an "AS IS" BASIS,
20491 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20492 * See the License for the specific language governing permissions and
20493 * limitations under the License.
20494 * =============================================================================
20495 */function EY(n){const{inputs:e,backend:t,attrs:s}=n,{tensor:r,indices:a,updates:o}=e,{sliceRank:i,numUpdates:l,sliceSize:u,strides:c,outputSize:h}=Aa(o,a,r.shape),d=[h/u,u];if(h===0)return t.makeTensorInfo(r.shape,a.dtype);const p=ne({inputs:{x:a},backend:t,attrs:{shape:[l,i]}}),f=ne({inputs:{x:o},backend:t,attrs:{shape:[l,u]}}),g=ne({inputs:{x:r},backend:t,attrs:{shape:d}}),m=new bg(l,i,p.shape.length,f.shape.length,c,d,!1,!0),y=t.runWebGLProgram(m,[f,p,g],g.dtype),x=ne({inputs:{x:y},backend:t,attrs:{shape:r.shape}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(f),t.disposeIntermediateTensorInfo(g),t.disposeIntermediateTensorInfo(y),x}const RY={kernelName:Wu,backendName:"webgl",kernelFunc:EY};/**
20496 * @license
20497 * Copyright 2017 Google LLC. All Rights Reserved.
20498 * Licensed under the Apache License, Version 2.0 (the "License");
20499 * you may not use this file except in compliance with the License.
20500 * You may obtain a copy of the License at
20501 *
20502 * http://www.apache.org/licenses/LICENSE-2.0
20503 *
20504 * Unless required by applicable law or agreed to in writing, softw
20504are
20505 * distributed under the License is distributed on an "AS IS" BASIS,
20506 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20507 * See the License for the specific language governing permissions and
20508 * limitations under the License.
20509 * =============================================================================
20510 */class DY{constructor(e,t){this.variableNames=["A"];const s=new Array(e.length);for(let o=0;o<s.length;o++)s[o]=e[o]*t[o];this.outputShape=s,this.rank=s.length;const r=Fe(this.rank),a=AY(e);this.userCode=`
20511      void main() {
20512        ${r} resRC = getOutputCoords();
20513        setOutput(getA(${a}));
20514      }
20515    `}}function AY(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"],s=[];for(let r=0;r<n.length;r++)s.push(`imod(${t[r]}, ${n[r]})`);return s.join()}/**
20516 * @license
20517 * Copyright 2020 Google LLC. All Rights Reserved.
20518 * Licensed under the Apache License, Version 2.0 (the "License");
20519 * you may not use this file except in compliance with the License.
20520 * You may obtain a copy of the License at
20521 *
20522 * http://www.apache.org/licenses/LICENSE-2.0
20523 *
20524 * Unless required by applicable law or agreed to in writing, software
20525 * distributed under the License is distributed on an "AS IS" BASIS,
20526 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20527 * See the License for the specific language governing permissions and
20528 * limitations under the License.
20529 * =============================================================================
20530 */function $C(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{reps:a}=s;if(r.dtype==="string"||r.shape.length>5){const l=t.readSync(r.dataId),u=r.dtype==="string"?l.map(d=>Gi(d)):l,c=$e(r.shape,r.dtype,u),h=PU(c,a);return t.makeTensorInfo(h.shape,h.dtype,h.values)}const o=new DY(r.shape,a);return t.runWebGLProgram(o,[r],r.dtype)}const OY={kernelName:Qr,backendName:"webgl",kernelFunc:$C};class _Y{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=`
20531       void main() {
20532         ivec2 coords = getOutputCoords();
20533         int batch = coords[0];
20534         int elemIdx = coords[1];
20535
20536         // We compare elements pair-wise within a group of size 2 * inc.
20537         // The comparing rule for each group alternates between ascending
20538         // and descending. Within each group, we compare each pair at
20539         // positions i and i+inc. To decide whether an element at position i
20540         // is x0 or x1, we mod it by 2 * inc, if the result is smaller than
20541         // inc, it is in the first half of the group, we denote it as x0,
20542         // otherwise we denote it as x1.
20543         // For example, as shown in the Bitonic top K paper referenced above,
20544         // Figure5(a) shows that element[1] is in the
20545         // second half of the group when group size is 2, but it is in the
20546         // first half of the group when group size is 4.
20547
20548         bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;
20549         int i = isFirstInPair ? elemIdx : elemIdx - inc;
20550
20551         int i0 = firstPass == 1 ? i : int(getIndices(batch, i));
20552         int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));
20553         float x0 = i0 < n ? getX(batch, i0) : negativeInf;
20554         float x1 = i1 < n ? getX(batch, i1) : negativeInf;
20555
20556         // Denotes which direction indices are in (ascending or descending).
20557         bool reverse = imod(elemIdx, 2 * dir) >= dir;
20558         bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);
20559         if (reverse == isGreater) { // Elements in opposite order of direction
20560           int iTemp = i0;
20561           i0 = i1;
20562           i1 = iTemp;
20563         }
20564         if (isFirstInPair) {
20565            setOutput(float(i0));
20566         } else {
20567            setOutput(float(i1));
20568         }
20569       }
20570     `}}class FY{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=`
20571    void main() {
20572         // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...
20573         ivec2 coords = getOutputCoords();
20574         int batch = coords[0];
20575         int elemIdx = coords[1];
20576
20577         // The output size is half of the previous size.
20578         // If the previous sequence is | | | | _ _ _ _  | | | |  _ _ _ _ (k=4),
20579         // we only need to output the indices at positions |, the indices at
20580         // positions _ can be thrown away, see Figure5(b) After Phase 2
20581         // (Merge phase) in the Bitonic Top K paper referenced above.
20582         // For example, the paper shows we only need to output the orange bars.
20583         // The output sequence should look like this | | | | | | | |.
20584         // Because the sequence is halved, to map the output index back
20585         // to the previous sequence to find the corresponding value,
20586         // we need to double the index. When we double the index,
20587         // we basically interpolate a position, so 2i looks like
20588         // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position
20589         // of each 2k positions by - elemIdx % k. E.g. for output at
20590         // index 4,5,6,7, we want to get the corresponding element at
20591         // original index 8,9,10,11, for output at index 8,9,10,11,
20592         // we want to get the corresponding element at original index
20593         // 16,17,18,19, so on and so forth.
20594
20595         int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));
20596         int i0 = firstPass == 1 ? i : int(getIndices(batch, i));
20597         int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));
20598
20599         float x0 = getX(batch, i0);
20600         float x1 = i1 < n ? getX(batch, i1) : x0;
20601
20602         setOutput(x0 >= x1 ? float(i0) : float(i1));
20603       }
20604     `}}/**
20605 * @license
20606 * Copyright 2020 Google LLC. All Rights Reserved.
20607 * Licensed under the Apache License, Version 2.0 (the "License");
20608 * you may not use this file except in compliance with the License.
20609 * You may obtain a copy of the License at
20610 *
20611 * http://www.apache.org/licenses/LICENSE-2.0
20612 *
20613 * Unless required by applicable law or agreed to in writing, software
20614 * distributed under the License is distributed on an "AS IS" BASIS,
20615 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20616 * See the License for the specific language governing permissions and
20617 * limitations under the License.
20618 * =============================================================================
20619 */function Us(n,e){e!==null&&n.disposeIntermediateTensorInfo(e)}function jy(n){let e=1;for(;e<n;)e*=2;return e}function LY(n){const{inputs:e,backend:t,attrs:s}=n,{x:r}=e,{k:a,sorted:o}=s,i=W().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),l=W().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),u=r.shape,c=u[u.length-1];if(t.shouldExecuteOnCPU([r])||c<i||a>l){const E=t.readSync(r.dataId),[_,z]=zU(E,u,r.dtype,a,o);return[t.makeTensorInfo(_.shape,_.dtype,_.values),t.makeTensorInfo(z.shape,z.dtype,z.values)]}if(a===0)return u[u.length-1]=0,[t.makeTensorInfo(u,r.dtype,[]),t.makeTensorInfo(u,"int32",[])];if(c===1)return[r,vl({attrs:{shape:u,dtype:"int32",value:0},backend:t})];const h=t.texData.get(r.dataId),d=h!==null&&h.isPacked,p=d?t.unpackTensor(r):r,g=H(u)/c,m=ne({inputs:{x:p},attrs:{shape:[g,c]},backend:t});d&&Us(t,p);const y=jy(a),x=jy(c);let v=null;const b=()=>v===null?[m,m]:[m,v],C=(E,_,z)=>{const P=b(),V=new _Y(z),M=[[c],[v===null?1:0],[Number.NEGATIVE_INFINITY],[E],[_]],j=v;v=t.runWebGLProgram(V,P,"int32",M),Us(t,j)};for(let E=1;E<y;E*=2){const _=E*2;for(let z=E;z>=1;z/=2)C(_,z,[g,x])}for(let E=x;E>y;E/=2){const _=b(),z=new FY([g,E/2]),V=[[c],[v===null?1:0],[y]],B=v;v=t.runWebGLProgram(z,_,"int32",V),Us(t,B);const M=y/2,j=M*2;for(let U=M;U>=1;U/=2)C(j,U,v.shape)}let $=v;v=eo({inputs:{x:v},backend:t,attrs:{begin:0,size:[g,a]}}),Us(t,$);let S=mC({inputs:{x:m,indices:v},backend:t,attrs:{axis:1,batchDims:1}});Us(t,m);const k=u.slice(0,-1);k.push(a),$=v,v=ne({inputs:{x:v},attrs:{shape:k},backend:t}),Us(t,$);const T=S;return S=ne({inputs:{x:S},attrs:{shape:k},backend:t}),Us(t,T),[S,v]}const PY={kernelName:Uu,backendName:"webgl",kernelFunc:LY};/**
20620 * @license
20621 * Copyright 2021 Google LLC. All Rights Reserved.
20622 * Licensed under the Apache License, Version 2.0 (the "License");
20623 * you may not use this file except in compliance with the License.
20624 * You may obtain a copy of the License at
20625 *
20626 * http://www.apache.org/licenses/LICENSE-2.0
20627 *
20628 * Unless required by applicable law or agreed to in writing, software
20629 * distributed under the License is distributed on an "AS IS" BASIS,
20630 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20631 * See the License for the specific language governing permissions and
20632 * limitations under the License.
20633 * =============================================================================
20634 */class zY{constructor(e,t,s,r,a,o){this.variableNames=["Image","Transforms"],this.outputShape=o;const i=s==="nearest"?1:2;let l;switch(r){case"constant":l=1;break;case"reflect":l=2;break;case"wrap":l=3;break;case"nearest":l=4;break;default:l=1;break}this.userCode=`
20635            float mapCoord(float outCoord, float len) {
20636              float inCoord = outCoord;
20637              if(${l} == 2) {
20638                if (inCoord < 0.0) {
20639                  if (len <= 1.0) {
20640                    inCoord = 0.0;
20641                  } else {
20642                    float sz2 = 2.0 * len;
20643                    if (inCoord < sz2) {
20644                      inCoord = sz2 * float(int(float(-inCoord / sz2))) +
20645                      inCoord;
20646                    }
20647                    inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;
20648                  }
20649                } else if (inCoord > len - 1.0) {
20650                  if (len <= 1.0) {
20651                    inCoord = 0.0;
20652                  } else {
20653                    float sz2 = 2.0 * len;
20654                    inCoord -= sz2 * float(int(float(inCoord / sz2)));
20655                    if (inCoord >= len) {
20656                      inCoord = sz2 - inCoord - 1.0;
20657                    }
20658                  }
20659                }
20660                return clamp(inCoord, 0.0, len - 1.0);
20661              } else if (${l} == 3) {
20662                if (inCoord < 0.0) {
20663                  if (len <= 1.0) {
20664                    inCoord = 0.0;
20665                  } else {
20666                    float sz = len - 1.0;
20667                    inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);
20668                  }
20669                } else if (inCoord > len - 1.0) {
20670                  if (len <= 1.0) {
20671                    inCoord = 0.0;
20672                  } else {
20673                    float sz = len - 1.0;
20674                    inCoord -= len * float(int(float(inCoord / sz)));
20675                  }
20676                }
20677                return clamp(inCoord, 0.0, len - 1.0);
20678              } else if (${l} == 4) {
20679                return clamp(outCoord, 0.0, len - 1.0);
20680              } else {
20681                return outCoord;
20682              }
20683            }
20684
20685            float readWithFillValue(int batch, int coordY, int coordX,
20686              int channel) {
20687              float outputValue;
20688              if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {
20689                  outputValue = getImage(batch, coordY, coordX, channel);
20690              } else {
20691                outputValue = float(${a});
20692              }
20693              return outputValue;
20694            }
20695
20696            void main() {
20697              ivec4 coords = getOutputCoords();
20698              float outputValue;
20699              int batch = coords[0];
20700              int x = coords[2];
20701              int y = coords[1];
20702              int channel = coords[3];
20703              float xf = float(x);
20704              float yf = float(y);
20705              float a1 = getTransforms(batch, 0);
20706              float a2 = getTransforms(batch, 1);
20707              float a3 = getTransforms(batch, 2);
20708              float b1 = getTransforms(batch, 3);
20709              float b2 = getTransforms(batch, 4);
20710              float b3 = getTransforms(batch, 5);
20711              float c1 = getTransforms(batch, 6);
20712              float c2 = getTransforms(batch, 7);
20713              float projection = c1 * xf + c2 * yf + 1.0;
20714              if (projection == 0.0) {
20715                outputValue = float(${a});
20716              } else {
20717                float inX = (a1 * xf + a2 * yf + a3) / projection;
20718                float inY = (b1 * xf + b2 * yf + b3) / projection;
20719                float mapX = mapCoord(inX, float(${t}));
20720                float mapY = mapCoord(inY, float(${e}));
20721
20722                if (${i} == 1) {
20723                  int coordY = int(round(mapY));
20724                  int coordX = int(round(mapX));
20725                  outputValue = readWithFillValue(batch, coordY, coordX,
20726                    channel);
20727                } else {
20728                  float yFloor = floor(mapY);
20729                  float xFloor = floor(mapX);
20730                  float yCeil = yFloor + 1.0;
20731                  float xCeil = xFloor + 1.0;
20732                  float valueYFloor = (xCeil - mapX) *
20733                  readWithFillValue(batch, int(yFloor), int(xFloor), channel) +
20734                  (mapX - xFloor) *
20735                  readWithFillValue(batch, int(yFloor), int(xCeil), channel);
20736                  float valueYCeil = (xCeil - mapX) *
20737                  readWithFillValue(batch, int(yCeil), int(xFloor), channel) +
20738                  (mapX - xFloor) *
20739                  readWithFillValue(batch, int(yCeil), int(xCeil), channel);
20740                  outputValue = (yCeil - mapY) * valueYFloor +
20741                  (mapY - yFloor) * valueYCeil;
20742                }
20743              }
20744              setOutput(outputValue);
20745            }
20746        `}}/**
20747 * @license
20748 * Copyright 2021 Google LLC. All Rights Reserved.
20749 * Licensed under the Apache License, Version 2.0 (the "License");
20750 * you may not use this file except in compliance with the License.
20751 * You may obtain a copy of the License at
20752 *
20753 * http://www.apache.org/licenses/LICENSE-2.0
20754 *
20755 * Unless required by applicable law or agreed to in writing, software
20756 * distributed under the License is distributed on an "AS IS" BASIS,
20757 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20758 * See the License for the specific language governing permissions and
20759 * limitations under the License.
20760 * =============================================================================
20761 */function VY(n){const{inputs:e,backend:t,attrs:s}=n,{image:r,transforms:a}=e,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=s,[c,h,d,p]=r.shape,[f,g]=u??[h,d],m=[c,f,g,p],y=new zY(h,d,o,i,l,m);return t.runWebGLProgram(y,[r,a],"float32")}const BY={kernelName:sc,backendName:"webgl",kernelFunc:VY};/**
20762 * @license
20763 * Copyright 2020 Google LLC. All Rights Reserved.
20764 * Licensed under the Apache License, Version 2.0 (the License);
20765 * you may not use this file except in compliance with the License.
20766 * You may obtain a copy of the License at
20767 *
20768 * http://www.apache.org/licenses/LICENSE-2.0
20769 *
20770 * Unless required by applicable law or agreed to in writing, software
20771 * distributed under the License is distributed on an AS IS BASIS,
20772 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20773 * See the License for the specific language governing permissions and
20774 * limitations under the License.
20775 * =============================================================================
20776 */function MY(n){const{inputs:e,attrs:t,backend:s}=n,{axis:r}=t,{x:a}=e;qa(a,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const o=s.readSync(a.dataId),{outputValues:i,outputShape:l,indices:u}=VU(o,r,a.shape,a.dtype);return[s.makeTensorInfo(l,a.dtype,i),s.makeTensorInfo([u.length],"int32",u)]}const WY={kernelName:Gu,backendName:"webgl",kernelFunc:MY};/**
20777 * @license
20778 * Copyright 2020 Google LLC. All Rights Reserved.
20779 * Licensed under the Apache License, Version 2.0 (the "License");
20780 * you may not use this file except in compliance with the License.
20781 * You may obtain a copy of the License at
20782 *
20783 * http://www.apache.org/licenses/LICENSE-2.0
20784 *
20785 * Unless required by applicable law or agreed to in writing, software
20786 * distributed under the License is distributed on an "AS IS" BASIS,
20787 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20788 * See the License for the specific language governing permissions and
20789 * limitations under the License.
20790 * =============================================================================
20791 */function UY(n){const{inputs:e,backend:t,attrs:s}=n,{value:r}=e;let{axis:a}=s;a<0&&(a+=r.shape.length);const o=r,i=o.shape.length,l=r.shape[a],u=new Array(i-1);let c=0;for(let g=0;g<i;g++)g!==a&&(u[c++]=o.shape[g]);const h=[],d=new Array(i).fill(0),p=o.shape.slice();p[a]=1;const f=new Array(l);for(let g=0;g<f.length;g++){d[a]=g;
vendor: 4,264 bytes, lines 20791-20915
20791const m=eo({inputs:{x:o},backend:t,attrs:{begin:d,size:p}}),y=ne({inputs:{x:m},backend:t,attrs:{shape:u}});f[g]=y,h.push(m)}return h.forEach(g=>t.disposeIntermediateTensorInfo(g)),f}const GY={kernelName:Ci,backendName:"webgl",kernelFunc:UY};/**
20792 * @license
20793 * Copyright 2018 Google LLC. All Rights Reserved.
20794 * Licensed under the Apache License, Version 2.0 (the "License");
20795 * you may not use this file except in compliance with the License.
20796 * You may obtain a copy of the License at
20797 *
20798 * http://www.apache.org/licenses/LICENSE-2.0
20799 *
20800 * Unless required by applicable law or agreed to in writing, software
20801 * distributed under the License is distributed on an "AS IS" BASIS,
20802 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20803 * See the License for the specific language governing permissions and
20804 * limitations under the License.
20805 * =============================================================================
20806 */class HY{constructor(e,t){this.variableNames=["x","segmentIds"];const s=e.windowSize,r=e.batchSize,a=e.inSize,o=e.numSegments,i=o*Math.ceil(a/s);this.outputShape=[r,i];const l="0.0",u="sumValue",c=Math.floor(s/4)*4,h=s%4,d=`
20807        sumValue += dot(values, segFilter);
20808    `;let p="";a%s>0&&(p=`
20809        if (inIdx < 0 || inIdx >= ${a}) {
20810          return initializationValue;
20811        }
20812      `);let f="";a%s>0&&(f=`
20813        if (inIdx < 0 || inIdx >= ${a}) {
20814          return -1.0;
20815        }
20816      `),this.userCode=`
20817      const float initializationValue = ${l};
20818
20819      float getValue(int batch, int inIdx) {
20820        ${p}
20821        return getX(batch, inIdx);
20822      }
20823
20824      float getSegmentIdAtIndex(int inIdx) {
20825        ${f}
20826        return getSegmentIds(inIdx);
20827      }
20828
20829      void main() {
20830        ivec2 coords = getOutputCoords();
20831        int batch = coords[0];
20832        int outIdx = coords[1];
20833        int inOffset = int(floor(float(outIdx) / float(
20834          ${o})) * float(${s}));
20835        int currentSeg = int(mod(float(outIdx), float(${o})));
20836
20837        float sumValue = 0.0;
20838
20839        for (int i = 0; i < ${c}; i += 4) {
20840          int inIdx = inOffset + i;
20841          vec4 values = vec4(
20842            getValue(batch, inIdx),
20843            getValue(batch, inIdx + 1),
20844            getValue(batch, inIdx + 2),
20845            getValue(batch, inIdx + 3)
20846          );
20847
20848          vec4 segFilter = vec4(
20849            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
20850            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
20851            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
20852            int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0
20853          );
20854
20855          ${d}
20856        }
20857
20858        int inIdx = inOffset + ${c};
20859        if (${h===1}) {
20860          vec4 values = vec4(
20861            getValue(batch, inIdx),
20862            initializationValue,
20863            initializationValue,
20864            initializationValue
20865          );
20866
20867          int inIdxSeg = int(getSegmentIdAtIndex(inIdx));
20868
20869          vec4 segFilter = vec4(
20870            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
20871            0,
20872            0,
20873            0
20874          );
20875
20876          ${d}
20877        } else if (${h===2}) {
20878          vec4 values = vec4(
20879            getValue(batch, inIdx),
20880            getValue(batch, inIdx + 1),
20881            initializationValue,
20882            initializationValue
20883          );
20884
20885          vec4 segFilter = vec4(
20886            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
20887            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
20888              0,
20889              0
20890          );
20891
20892          ${d}
20893        } else if (${h===3}) {
20894          vec4 values = vec4(
20895            getValue(batch, inIdx),
20896            getValue(batch, inIdx + 1),
20897            getValue(batch, inIdx + 2),
20898            initializationValue
20899          );
20900
20901          vec4 segFilter = vec4(
20902            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
20903            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
20904            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
20905            0
20906          );
20907
20908          ${d}
20909        }
20910        setOutput(${u});
20911      }
20912    `}}/**
20913 * @license
20914 * Copyright 2020 Google LLC. All Rights Reserved.
20915 * Licensed under the Apache License, Version 2.0 (the "License");
20916 * you may not use this file except in compliance with the License.
20917 * You may obtain a copy of the License at
20918 *
20919 * http://www.apache.org/licenses/LICENSE-2.0
20920 *
20921 * Unless required by applicable law or agreed to in writing, software
20922 * distributed under the License is distributed on an "AS IS" BASIS,
20923 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20924 * See the License for the specific language governing permissions and
20925 * limitations under the License.
20926 * =============================================================================
20927 */function jY(n){const{inputs:e,backend:t,attrs:s}=n,{x:r,segmentIds:a}=e,{numSegments:o}=s,i=r.shape.length,l=[];let u=0;const c=Xe([u],i);let h=r;c!=null&&(h=_t({inputs:{x:r},backend:t,attrs:{perm:c}}),l.push(h),u=st(1,i)[0]);const d=g$(h.shape,u,o),p=H([h.shape[u]]),f=ne({inputs:{x:h},backend:t,attrs:{shape:[-1,p]}});l.push(f);const g=Vc(r.dtype),m=(b,C,$,S,k)=>{const T=b.shape[0],E=b.shape[1],_=y$(E,k),z={windowSize:_,inSize:E,batchSize:T,numSegments:k},P=new HY(z,C),V=t.compileAndRun(P,[b,$],S);if(l.push(V),V.shape[1]===k)return V;const B=CC({backend:t,attrs:{start:0,stop:k,step:1,dtype:"float32"}}),M=$C({inputs:{x:B},backend:t,attrs:{reps:[E/_]}});return l.push(B),l.push(M),m(V,C,M,S,k)},y=m(f,"unsortedSegmentSum",a,g,o),x=ne({inputs:{x:y},backend:t,attrs:{shape:d}});let v=x;if(c!=null){l.push(x);const b=pr(c);v=_t({inputs:{x:v},backend:t,attrs:{perm:b}})}return l.forEach(b=>t.disposeIntermediateTensorInfo(b)),v}const qY={kernelName:vi,backendName:"webgl",kernelFunc:jY};/**
20928 * @license
20929 * Copyright 2020 Google LLC. All Rights Reserved.
20930 * Licensed under the Apache License, Version 2.0 (the "License");
20931 * you may not use this file except in compliance with the License.
20932 * You may obtain a copy of the License at
20933 *
20934 * http://www.apache.org/licenses/LICENSE-2.0
20935 *
20936 * Unless required by applicable law or agreed to in writing, software
20937 * distributed under the License is distributed on an "AS IS" BASIS,
20938 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20939 * See the License for the specific language governing permissions and
20940 * limitations under the License.
20941 * =============================================================================
20942 */const KY=[DG,OG,LG,VG,MG,GG,jG,KG,ZG,eH,sH,oH,uH,pH,gH,xH,wH,NH,SH,TH,AH,VH,MH,HH,qH,QH,tj,aj,fG,lj,pj,yj,$j,Sj,Tj,Rj,Aj,Lj,Vj,Wj,Gj,jj,Kj,Jj,Qj,sq,aq,lq,hq,pq,yq,vq,Iq,Tq,Dq,Aq,_q,Lq,zq,Bq,Wq,jq,Xq,Zq,eK,sK,oK,cK,fK,pG,gK,hj,bK,CK,IK,gG,EK,OK,FK,VK,WK,jK,XK,QK,sX,oX,lX,dX,fX,gX,wX,CX,NX,SX,TX,AX,LX,BX,KX,bG,ZX,t5,r5,i5,XH,c5,d5,f5,y5,v5,xG,$5,I5,k5,E5,R5,YH,GX,O5,P5,M5,vG,H5,K5,Z5,t6,a6,i6,c6,p6,g6,b6,C6,I6,E6,A6,L6,V6,PH,jX,W6,G6,j6,K6,Y6,Z6,eY,nY,rY,iY,uY,hY,pY,gY,xY,wY,CY,HX,TG,IY,TY,RY,OY,PY,BY,EG,WY,GY,qY,h5];for(const n of KY)ep(n);/** @license See the LICENSE file. */const XY="4.22.0";/**
20943 * @license
20944 * Copyright 2018 Google LLC. All Rights Reserved.
20945 * Licensed under the Apache License, Version 2.0 (the "License");
20946 * you may not use this file except in compliance with the License.
20947 * You may obtain a copy of the License at
20948 *
20949 * http://www.apache.org/licenses/LICENSE-2.0
20950 *
20951 * Unless required by applicable law or agreed to in writing, software
20952 * distributed under the License is distributed on an "AS IS" BASIS,
20953 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20954 * See the License for the specific language governing permissions and
20955 * limitations under the License.
20956 * =============================================================================
20957 */const YY={"tfjs-core":lw,"tfjs-backend-cpu":O1,"tfjs-backend-webgl":qv,"tfjs-data":G0,"tfjs-layers":Ih,"tfjs-converter":T0,tfjs:XY},r8=Object.freeze(Object.defineProperty({__proto__:null,Abs:pc,Acos:Hr,Acosh:jr,AdadeltaOptimizer:ax,AdagradOptimizer:ix,AdamOptimizer:rx,AdamaxOptimizer:ox,Add:ki,AddN:Do,All:xu,Any:bu,ArgMax:Ao,ArgMin:Oo,Asin:qr,Asinh:Kr,Atan:Xr,Atan2:Yr,Atanh:Jr,AvgPool:_o,AvgPool3D:Fo,AvgPool3DGrad:fc,AvgPoolGrad:mc,BatchMatMul:Po,BatchToSpaceND:zo,Bincount:vu,BitwiseAnd:Bo,BroadcastArgs:Cu,BroadcastTo:lx,Callback:$0,CallbackList:Sw,Cast:gc,Ceil:ea,ClipByValue:na,Complex:Yd,ComplexAbs:yc,Concat:Lo,Conv2D:Mo,Conv2DBackpropFilter:Ku,Conv2DBackpropInput:Wo,Conv3D:Uo,Conv3DBackpropFilterV2:xc,Conv3DBackpropInputV2:$u,Cos:sa,Cosh:ra,CropAndResize:Ju,Cumprod:Nu,Cumsum:Go,CustomCallback:Tw,DataStorage:Xd,DenseBincount:Iu,DepthToSpace:Su,DepthwiseConv2dNative:Ho,DepthwiseConv2dNativeBackpropFilter:Xu,DepthwiseConv2dNativeBackpropInput:Yu,Diag:ku,Dilation2D:jo,Dilation2DBackpropFilter:Kl,Dilation2DBackpropInput:Xl,Draw:dc,get ENV(){return x$},EarlyStopping:N0,Einsum:Tu,Elu:Ti,EluGrad:bc,Environment:b$,Equal:qo,Erf:aa,Exp:oa,ExpandDims:Jo,Expm1:ia,FFT:Vu,Fill:Zd,FlipLeftRight:Zu,Floor:la,FloorDiv:Ei,FromPixels:ql,FusedBatchNorm:Vo,FusedConv2D:go,FusedDepthwiseConv2D:yo,GPGPUContext:Wl,GatherNd:qu,GatherV2:Zo,GraphModel:Hm,Greater:Qo,GreaterEqual:ua,History:kw,IFFT:Bu,Identity:wc,Imag:Eu,InputSpec:tt,IsFinite:ca,IsInf:ha,IsNan:da,KernelBackend:Kd,LRN:ni,LRNGrad:Cc,LayerVariable:Cw,LayersModel:ss,LeakyRelu:vc,Less:ei,LessEqual:ti,LinSpace:Ru,Log:pa,Log1p:fa,LogSoftmax:ux,LogicalAnd:ri,LogicalNot:ai,LogicalOr:oi,LogicalXor:w$,LowerBound:v$,MathBacken
20957dCPU:ml,MathBackendWebGL:bl,MatrixBandPart:C$,Max:Xo,MaxPool:ii,MaxPool3D:li,MaxPool3DGrad:$c,MaxPoolGrad:Nc,MaxPoolWithArgmax:Au,Maximum:Ri,Mean:ui,Min:Yo,Minimum:ga,MirrorPad:ci,Mod:ya,MomentumOptimizer:nx,Multinomial:Ou,Multiply:Di,Neg:si,NonMaxSuppressionV3:ec,NonMaxSuppressionV4:nc,NonMaxSuppressionV5:tc,NotEqual:hi,OP_SCOPE_SUFFIX:fx,OneHot:di,OnesLike:pi,Optimizer:px,OptimizerConstructors:uw,Pack:wi,PadV2:fi,Pool:$$,Pow:Ai,Prelu:Ic,Prod:gi,RMSPropOptimizer:sx,RNN:Ln,RaggedGather:_u,RaggedRange:Fu,RaggedTensorToTensor:Lu,Range:Pu,get Rank(){return N$},Real:zu,RealDiv:Oi,Reciprocal:xa,get Reduction(){return Et},Relu:Fi,Relu6:_i,Reshape:Sc,ResizeBilinear:Ni,ResizeBilinearGrad:kc,ResizeNearestNeighbor:Ii,ResizeNearestNeighborGrad:Tc,Reverse:yi,RotateWithOffset:Qu,Round:ba,Rsqrt:wa,SGDOptimizer:tx,ScatterNd:Hu,SearchSorted:Du,Select:Ko,Selu:va,Sequential:ir,Sigmoid:Li,Sign:Ca,Sin:$a,Sinh:Na,Slice:wu,Softmax:xi,Softplus:ma,SpaceToBatchND:mi,SparseFillEmptyRows:rc,SparseReshape:ac,SparseSegmentMean:oc,SparseSegmentSum:ic,SparseToDense:ju,SplitV:bi,Sqrt:Pi,Square:Ec,SquaredDifference:Ia,StaticRegexReplace:Si,Step:zi,StridedSlice:Mu,StringNGrams:lc,StringSplit:uc,StringToHashBucketFast:cc,Sub:Vi,Sum:Rc,SymbolicTensor:An,Tan:Sa,Tanh:Zr,Tensor:lt,TensorBuffer:bt,TensorScatterUpdate:Wu,Tile:Qr,TopK:Uu,Transform:sc,Transpose:Js,Unique:Gu,Unpack:Ci,UnsortedSegmentSum:vi,UpperBound:I$,Variable:S$,ZerosLike:Dc,_FusedMatMul:xo,abs:rt,acos:sp,acosh:rp,add:te,addN:Xx,all:Bc,any:vo,argMax:nr,argMin:ap,asin:op,asinh:ip,atan:lp,atan2:up,atanh:cp,avgPool:Hi,avgPool3d:hp,backend:dx,backend_util:Kx,basicLSTMCell:Yx,batchNorm:Oa,batchNorm2d:dp,batchNorm3d:pp,batchNorm4d:fp,batchToSpaceND:ji,bincount:mp,bitwiseAnd:Jx,booleanMaskAsync:_b,broadcastArgs:Zx,broadcastTo:Qs,broadcast_util:k$,browser:H2,buffer:$e,callbacks:eF,cast:ee,ceil:gp,clipByValue:Mt,clone:ts,complex:Cs,concat:Je,concat1d:yp,concat2d:xp,concat3d:bp,concat4d:wp,constraints:VD,conv1d:Mc,conv2d:rs,conv2dTranspose:Wc,conv3d:Cp,conv3dTranspose:$p,copyRegisteredKernels:T$,cos:qi,cosh:Uc,cosineWindow:uh,cumprod:Co,cumsum:Gc,customGrad:Hn,data:pP,denseBincount:Yl,deprecationWarn:E$,depthToSpace:Np,depthwiseConv2d:_a,deregisterOp:sF,device_util:R$,diag:eb,dilation2d:Ip,disableDeprecationWarnings:D$,dispose:Re,disposeVariables:A$,div:he,divNoNan:Sp,dot:kp,dropout:af,einsum:js,elu:Bi,enableDebugMode:O$,enableProdMode:_$,enclosingPowerOfTwo:of,engine:Sn,ensureShape:tb,env:W,equal:Yt,erf:Hc,euclideanNorm:Tp,exp:Wt,expandDims:mt,expm1:Ep,eye:jc,fft:rl,fill:ta,findBackend:F$,findBackendFactory:L$,floor:La,floorDiv:Hd,forceHalfFloat:Kv,fused:Ub,gather:Pa,gatherND:zb,gather_util:P$,getBackend:z$,getGradient:V$,getKernel:Wd,getKernelsForBackend:B$,gpgpu_util:q4,grad:M$,grads:W$,greater:Lt,greaterEqual:os,ifft:zr,imag:Ki,image:yn,inTopKAsync:Vb,initializers:tA,input:Ww,io:pf,irfft:rh,isFinite:Rp,isInf:Dp,isNaN:Ap,keep:ct,kernel_impls:q2,layers:R_,leakyRelu:Ac,less:_r,lessEqual:Ls,linalg:cf,linspace:sb,loadGraphModel:TL,loadGraphModelSync:EL,loadLayersModel:HA,localResponseNormalization:Op,log:Jt,log1p:Xi,logSigmoid:_p,logSoftmax:qc,logSumExp:Yi,logicalAnd:wn,logicalNot:Ji,logicalOr:Kc,logicalXor:Fp,losses:Yb,lowerBound:rb,matMul:ve,math:L2,max:on,maxPool:Zi,maxPool3d:Lp,maxPoolWithArgmax:ab,maximum:as,mean:je,memory:Zh,meshgrid:ob,metrics:q_,min:Or,minimum:Ss,mirrorPad:Pp,mod:zp,model:KA,models:K_,moments:Qi,movingAverage:Fb,mul:O,multiRNNCell:ib,multinomial:lb,neg:Ve,nextFrame:ff,norm:Fa,notEqual:sr,oneHot:Fr,ones:Vt,onesLike:Zt,op:R,outerProduct:ub,pad:is,pad1d:cb,pad2d:hb,pad3d:db,pad4d:pb,pool:Vp,pow:As,prelu:Oc,print:mx,prod:Bp,profile:U$,raggedGather:fb,raggedRange:mb,raggedTensorToTensor:gb,rand:yb,randomGamma:vb,randomNormal:Yc,randomStandardNormal:Cb,randomUniform:Ps,randomUniformInt:$b,range:rr,ready:G$,real:Lr,reciprocal:Yp,registerBackend:Jd,registerCallbackConstructor:YA,registerGradient:hx,registerKernel:ep,registerOp:nF,regularizers:Z_,relu:Kn,relu6:jd,removeBackend:H$,reshape:D,reverse:un,reverse1d:Nb,reverse2d:Ib,reverse3d:Sb,reverse4d:kb,rfft:al,round:Jc,rsqrt:Zc,scalar:pe,scatterND:Lb,scatter_util:j$,searchSorted:Xc,selu:Qc,separableConv2d:eh,sequential:XA,serialization:q$,setBackend:K$,setPlatform:X$,setWebGLContext:Y1,setdiff1dAsync:Tb,shared:A1,sigmoid:Mn,sign:Jp,signal:Xb,sin:th,sinh:nh,slice:Se,slice1d:tl,slice2d:sh,slice3d:nl,slice4d:Pr,slice_util:Y$,softmax:sl,softplus:gr,spaceToBatchND:el,sparse:Jb,sparseToDense:Pb,spectral:Kb,split:Bt,sqrt:ln,square:Ye,squaredDifference:ah,squeeze:zs,stack:Ot,step:Ea,stridedSlice:Zp,string:Zb,sub:ie,sum:oe,sumOutType:Vc,tan:Qp,tanh:Is,tensor:En,tensor1d:xt,tensor2d:bs,tensor3d:ef,tensor4d:Eb,tensor5d:Rb,tensor6d:Db,tensorScatterUpdate:Ab,tensor_util:J$,test_util:PS,tidy:L,tile:sn,time:Z$,topk:tf,train:Hs,transpose:Ne,truncatedNormal:oh,unique:nf,unregisterGradient:Q$,unregisterKernel:eN,unsortedSegmentSum:ih,unstack:cn,upcastType:bn,upperBound:Ob,util:tN,valueAndGrad:nN,valueAndGrads:sN,variable:sf,variableGrads:rN,version:YY,version_converter:T0,version_core:lw,version_cpu:O1,version_layers:Ih,version_
20957webgl:qv,webgl:dG,webgl_util:QW,where:dt,whereAsync:rf,zeros:et,zerosLike:Be},Symbol.toStringTag,{value:"Module"}));export{TL as a,iw as f,yn as i,HA as l,KA as m,r8 as t,et as z};

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.