PageSourceSearch

https://beaubot-core-web.vercel.app/_next/static/chunks/6f20faa7-e69a3039c4df2ad4.js

js beaubot-core-web.vercel.app collected 2026-10-03 06:10:32 UTC 35,604 bytes, 825 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[730],{73651:(e,t,n)=>{n.d(t,{YE:()=>$,bf:()=>v,yr:()=>l});var r=n(81894),i=n(59663),o=n(64);let{getBroadcastDims:a}=r.C0T;function l(e,t,n){var l,C,T,m;let R,g,w=[];if(e.forEach(e=>{let t=r.ZSL.sizeFromShape(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?w.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(w.push(`uniform sampler2D ${e.name};`),w.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){let{uniformShape:t}=$(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:w.push(`uniform int ${e.name}Shape;`);break;case 2:w.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:w.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:w.push(`uniform ivec4 ${e.name}Shape;`)}w.push(`uniform ivec2 ${e.name}TexShape;`)}}),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:w.push("uniform int outShape;");break;case 2:w.push("uniform ivec2 outShape;"),w.push("uniform int outShapeStrides;");break;case 3:w.push("uniform ivec3 outShape;"),w.push("uniform ivec2 outShapeStrides;");break;case 4:w.push("uniform ivec4 outShape;"),w.push("uniform ivec3 outShapeStrides;")}w.push("uniform ivec2 outTexShape;")}
1n.customUniforms&&n.customUniforms.forEach(e=>{w.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)});let y=w.join("\n"),I=e.map(e=>(function(e,t,n=!1,o){let l="";n?l+=function e(t,n){switch(t.shapeInfo.logicalShape.length){case 0:let o,a,l;return a="get"+(o=t.name).charAt(0).toUpperCase()+o.slice(1),l=(0,i.B)(),`
2    vec4 ${a}() {
3      return ${l.texture2D}(${o}, halfCR);
4    }
5  `;case 1:return function(e,t){let n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=e.shapeInfo.texShape,a=(0,i.B)();if(t)return`
6    vec4 ${r}(int index) {
7      ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));
8      vec2 uv = packedUVfrom1D(
9        packedTexShape[0], packedTexShape[1], index);
10      return ${a.texture2D}(${n}, uv);
11    }
12  `;let l=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];return`
13    vec4 ${r}(int index) {
14      vec2 uv = packedUVfrom1D(
15        ${l[0]}, ${l[1]}, index);
16      return ${a.texture2D}(${n}, uv);
17    }
18  `}(t,n);case 2:return function(e,t){let n=e.shapeInfo.logicalShape,o=e.name,a="get"+o.charAt(0).toUpperCase()+o.slice(1),l=e.shapeInfo.texShape,c=l[0],u=l[1],p=(0,i.B)();if(null!=l&&r.ZSL.arraysEqual(n,l))return t?`
19      vec4 ${a}(int row, int col) {
20        vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}TexShape[1], ${o}TexShape[0]);
21
22        return ${p.texture2D}(${o}, uv);
23      }
24    `:`
25      vec4 ${a}(int row, int col) {
26        vec2 uv = (vec2(col, row) + halfCR) / vec2(${u}.0, ${c}.0);
27
28        return ${p.texture2D}(${o}, uv);
29      }
30    `;if(t)return`
31    vec4 ${a}(int row, int col) {
32      ivec2 packedTexShape = ivec2(ceil(float(${o}TexShape[0]) / 2.0), ceil(float(${o}TexShape[1]) / 2.0));
33      int valuesPerRow = int(ceil(float(${o}Shape[1]) / 2.0));
34      vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
35      return ${p.texture2D}(${o}, uv);
36    }
37  `;let x=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)],h=Math.ceil(n[1]/2);return`
38    vec4 ${a}(int row, int col) {
39      vec2 uv = packedUVfrom2D(${h}, ${x[0]}, ${x[1]}, row, col);
40      return ${p.texture2D}(${o}, uv);
41    }
42  `}(t,n);case 3:return function(t,n){let r=t.shapeInfo.logicalShape,o=t.name,a="get"+o.charAt(0).toUpperCase()+o.slice(1),l=t.shapeInfo.texShape,c=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];if(1===r[0]){let i=f(t,r.slice(1));return`
43        ${e(i,n)}
44        vec4 ${a}(int b, int row, int col) {
45          return ${a}(${S(["b","row","col"],[1,2])});
46        }
47      `}let u=(0,i.B)();if(n)return`
48    vec4 ${a}(int b, int row, int col) {
49      ivec2 packedTexShape = ivec2(ceil(float(${o}TexShape[0]) / 2.0), ceil(float(${o}TexShape[1]) / 2.0));
50      int valuesPerRow = int(ceil(float(${o}Shape[2]) / 2.0));
51      int texelsInBatch = valuesPerRow * int(ceil(float(${o}Shape[1]) / 2.0));
52      vec2 uv = packedUVfrom3D(
53        packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);
54      return ${u.texture2D}(${o}, uv);
55    }
56  `;let p=c[0],x=c[1],h=Math.ceil(r[2]/2),s=h*Math.ceil(r[1]/2);return`
57    vec4 ${a}(int b, int row, int col) {
58      vec2 uv = packedUVfrom3D(
59        ${p}, ${x}, ${s}, ${h}, b, row, col);
60      return ${u.texture2D}(${o}, uv);
61    }
62  `}(t,n);default:return function(e,t){let n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=(0,i.B)();if(t)return`
63    vec4 ${r}(int b2, int b, int row, int col) {
64      int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));
65      int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));
66      int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);
67      texelsInBatch *= ${n}Shape[1];
68      index = b2 * texelsInBatch + index;
69      ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));
70      int texR = index / packedTexShape[1];
71      int texC = index - texR * packedTexShape[1];
72      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${o.texture2D}(${n}, uv);
73    }
74  `;let a=e.shapeInfo.logicalShape,l=a.length,c=e.shapeInfo.texShape,u=[Math.ceil(c[0]/2),Math.ceil(c[1]/2)],p=u[0],x=u[1],h=Math.ceil(a[l-1]/2),s=h*Math.ceil(a[l-2]/2),d="int b, int row, int col",v=`b * ${s} + (row / 2) * ${h} + (col / 2)`;for(let e=2;e<l-1;e++)d=`int b${e}, `+d,s*=a[l-e-1],v=`b${e} * ${s} + `+v;return`
75    vec4 ${r}(${d}) {
76      int index = ${v};
77      int texR = index / ${x};
78      int texC = index - texR * ${x};
79      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${x}, ${p});
80      return ${o.texture2D}(${n}, uv);
81    }
82  `}(t,n)}}(e,o):l+=function e(t,n=!1){let i=t.shapeInfo.logicalShape;switch(i.length){case 0:return function(e,t){let n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`float ${r}() {return ${n};}`;let[i,o]=e.shapeInfo.texShape;if(1===i&&1===o)return`
83      float ${r}() {
84        return sampleTexture(${n}, halfCR);
85      }
86    `;let a=s(n);if(t)return`
87    float ${r}() {
88      vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${a});
89      return sampleTexture(${n}, uv);
90    }
91  `;let[l,c]=e.shapeInfo.texShape;return`
92    float ${r}() {
93      vec2 uv = uvFromFlat(${l}, ${c}, ${a});
94      return sampleTexture(${n}, uv);
95    }
96  `}(t,n);case 1:return function(e,t){let n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`
97      float ${r}(int index) {
98        ${d(e)}
99      }
100    `;let i=e.shapeInfo.texShape,o=i[0],a=i[1];if(1===a&&1===o)return`
101      float ${r}(int index) {
102        return sampleTexture(${n}, halfCR);
103      }
104    `;let l=s(n);return 1===a?t?`
105      float ${r}(int index) {
106        vec2 uv = vec2(0.5, (float(index + ${l}) + 0.5) / float(${n}TexShape[0]));
107        return sampleTexture(${n}, uv);
108      }
109    `:`
110      float ${r}(int index) {
111        vec2 uv = vec2(0.5, (float(index + ${l}) + 0.5) / ${o}.0);
112        return sampleTexture(${n}, uv);
113      }
114    `:1===o?t?`
115      float ${r}(int index) {
116        vec2 uv = vec2((float(index + ${l}) + 0.5) / float(${n}TexShape[1]), 0.5);
117        return sampleTexture(${n}, uv);
118      }
119    `:`
120      float ${r}(int index) {
121        vec2 uv = vec2((float(index + ${l}) + 0.5) / ${a}.0, 0.5);
122        return sampleTexture(${n}, uv);
123      }
124    `:t?`
125    float ${r}(int index) {
126      vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${l});
127      return sampleTexture(${n}, uv);
128    }
129  `:`
130    float ${r}(int index) {
131      vec2 uv = uvFromFlat(${o}, ${a}, index + ${l});
132      return sampleTexture(${n}, uv);
133    }
134  `}(t,n);case 2:return function(t,n){let i=t.shapeInfo.logicalShape,o=t.name,a="get"+o.charAt(0).toUpperCase()+o.slice(1),l=t.shapeInfo.texShape;if(null!=l&&r.ZSL.arraysEqual(i,l)){if(n)return`
135      float ${a}(int row, int col) {
136        vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}TexShape[1], ${o}TexShape[0]);
137        return sampleTexture(${o}, uv);
138      }
139    `;let e=l[0],t=l[1];return`
140    float ${a}(int row, int col) {
141      vec2 uv = (vec2(col, row) + halfCR) / vec2(${t}.0, ${e}.0);
142      return sampleTexture(${o}, uv);
143    }
144  `}let{newShape:c,keptDims:u}=r.ZSL.squeezeShape(i);if(c.length<i.length){let r=f(t,c);return`
145      ${e(r,n)}
146      float ${a}(int row, int col) {
147        return ${a}(${S(["row","col"],u)});
148      }
149    `}if(t.shapeInfo.isUniform)return`
150      float ${a}(int row, int col) {
151        int index = round(dot(vec2(row, col), vec2(${i[1]}, 1)));
152        ${d(t)}
153      }
154    `;let p=l[0],x=l[1],h=s(o);return 1===x?n?`
155      float ${a}(int row, int col) {
156        float index = dot(vec3(row, col, ${h}), vec3(${o}Shape[1], 1, 1));
157        vec2 uv = vec2(0.5, (index + 0.5) / float(${o}TexShape[0]));
158        return sampleTexture(${o}, uv);
159      }
160    `:`
161    float ${a}(int row, int col) {
162      float index = dot(vec3(row, col, ${h}), vec3(${i[1]}, 1, 1));
163      vec2 uv = vec2(0.5, (index + 0.5) / ${p}.0);
164      return sampleTexture(${o}, uv);
165    }
166  `:1===p?n?`
167      float ${a}(int row, int col) {
168        float index = dot(vec3(row, col, ${h}), vec3(${o}Shape[1], 1, 1));
169        vec2 uv = vec2((index + 0.5) / float(${o}TexShape[1]), 0.5);
170        return sampleTexture(${o}, uv);
171      }
172    `:`
173    float ${a}(int row, int col) {
174      float index = dot(vec3(row, col, ${h}), vec3(${i[1]}, 1, 1));
175      vec2 uv = vec2((index + 0.5) / ${x}.0, 0.5);
176      return sampleTexture(${o}, uv);
177    }
178  `:n?`
179      float ${a}(int row, int col) {
180        // Explicitly use integer operations as dot() only works on floats.
181        int index = row * ${o}Shape[1] + col + ${h};
182        vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index);
183        return sampleTexture(${o}, uv);
184      }
185    `:`
186  float ${a}(int row, int col) {
187    // Explicitly use integer operations as dot() only works on floats.
188    int index = row * ${i[1]} + col + ${h};
189    vec2 uv = uvFromFlat(${p}, ${x}, index);
190    return sampleTexture(${o}, uv);
191  }
192`}(t,n);case 3:return function(t,n){let i=t.shapeInfo.logicalShape,o=t.name,a="get"+o.charAt(0).toUpperCase()+o.slice(1),l=i[1]*i[2],c=i[2],{newShape:u,keptDims:p}=r.ZSL.squeezeShape(i);if(u.length<i.length){let r=f(t,u);return`
193        ${e(r,n)}
194        float ${a}(int row, int col, int depth) {
195          return ${a}(${S(["row","col","depth"],p)});
196        }
197      `}if(t.shapeInfo.isUniform)return`
198      float ${a}(int row, int col, int depth) {
199        int index = round(dot(vec3(row, col, depth),
200                          vec3(${l}, ${c}, 1)));
201        ${d(t)}
202      }
203    `;let x=t.shapeInfo.texShape,h=x[0],v=x[1],$=t.shapeInfo.flatOffset;if(v===l&&null==$)return n?`
204      float ${a}(int row, int col, int depth) {
205        int stride1 = ${o}Shape[2];
206        float texR = float(row);
207        float texC = dot(vec2(col, depth), vec2(stride1, 1));
208        vec2 uv = (vec2(texC, texR) + halfCR) /
209                   vec2(${o}TexShape[1], ${o}TexShape[0]);
210        return sampleTexture(${o}, uv);
211      }
212    `:`
213        float ${a}(int row, int col, int depth) {
214          float texR = float(row);
215          float texC = dot(vec2(col, depth), vec2(${c}, 1));
216          vec2 uv = (vec2(texC, texR) + halfCR) /
217                     vec2(${v}.0, ${h}.0);
218          return sampleTexture(${o}, uv);
219        }
220      `;if(v===c&&null==$)return n?`
221      float ${a}(int row, int col, int depth) {
222        float texR = dot(vec2(row, col), vec2(${o}Shape[1], 1));
223        float texC = float(depth);
224        vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${o}TexShape[1], ${o}TexShape[0]);
225        return sampleTexture(${o}, uv);
226      }
227    `:`
228    float ${a}(int row, int col, int depth) {
229      float texR = dot(vec2(row, col), vec2(${i[1]}, 1));
230      float texC = float(depth);
231      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${v}.0, ${h}.0);
232      return sampleTexture(${o}, uv);
233    }
234  `;let C=s(o);return n?`
235    float ${a}(int row, int col, int depth) {
236      // Explicitly use integer operations as dot() only works on floats.
237      int stride0 = ${o}Shape[1] * ${o}Shape[2];
238      int stride1 = ${o}Shape[2];
239      int index = row * stride0 + col * stride1 + depth + ${C};
240      vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index);
241      return sampleTexture(${o}, uv);
242    }
243    `:`
244      float ${a}(int row, int col, int depth) {
245        // Explicitly use integer operations as dot() only works on floats.
246        int index = row * ${l} + col * ${c} + depth + ${C};
247        vec2 uv = uvFromFlat(${h}, ${v}, index);
248        return sampleTexture(${o}, uv);
249      }
250  `}(t,n);case 4:return function(t,n){let i=t.shapeInfo.logicalShape,o=t.name,a="get"+o.charAt(0).toUpperCase()+o.slice(1),l=i[3],c=i[2]*l,u=i[1]*c,{newShape:p,keptDims:x}=r.ZSL.squeezeShape(i);if(p.length<i.length){let r=f(t,p);return`
251      ${e(r,n)}
252      float ${a}(int row, int col, int depth, int depth2) {
253        return ${a}(${S(["row","col","depth","depth2"],x)});
254      }
255    `}if(t.shapeInfo.isUniform)return`
256      float ${a}(int row, int col, int depth, int depth2) {
257        int index = round(dot(vec4(row, col, depth, depth2),
258                          vec4(${u}, ${c}, ${l}, 1)));
259        ${d(t)}
260      }
261    `;let h=t.shapeInfo.flatOffset,v=t.shapeInfo.texShape,$=v[0],C=v[1],T=`int stride2 = ${o}Shape[3];`,m=`int stride1 = ${o}Shape[2] * stride2;`,R=`int stride0 = ${o}Shape[1] * stride1;`;if(C===u&&null==h)return n?`
262      float ${a}(int row, int col, int depth, int depth2) {
263        ${T}
264        ${m}
265        float texR = float(row);
266        float texC =
267            dot(vec3(col, depth, depth2),
268                vec3(stride1, stride2, 1));
269        vec2 uv = (vec2(texC, texR) + halfCR) /
270                   vec2(${o}TexShape[1], ${o}TexShape[0]);
271        return sampleTexture(${o}, uv);
272      }
273    `:`
274      float ${a}(int row, int col, int depth, int depth2) {
275        float texR = float(row);
276        float texC =
277            dot(vec3(col, depth, depth2),
278                vec3(${c}, ${l}, 1));
279        vec2 uv = (vec2(texC, texR) + halfCR) /
280                   vec2(${C}.0, ${$}.0);
281        return sampleTexture(${o}, uv);
282      }
283    `;if(C===l&&null==h)return n?`
284      float ${a}(int row, int col, int depth, int depth2) {
285        float texR = dot(vec3(row, col, depth),
286                         vec3(${o}Shape[1] * ${o}Shape[2], ${o}Shape[2], 1));
287        float texC = float(depth2);
288        vec2 uv = (vec2(texC, texR) + halfCR) /
289                  vec2(${o}TexShape[1], ${o}TexShape[0]);
290        return sampleTexture(${o}, uv);
291      }
292    `:`
293      float ${a}(int row, int col, int depth, int depth2) {
294        float texR = dot(vec3(row, col, depth),
295                         vec3(${i[1]*i[2]}, ${i[2]}, 1));
296        float texC = float(depth2);
297        vec2 uv = (vec2(texC, texR) + halfCR) /
298                  vec2(${C}.0, ${$}.0);
299        return sampleTexture(${o}, uv);
300      }
301    `;let g=s(o);return n?`
302    float ${a}(int row, int col, int depth, int depth2) {
303      // Explicitly use integer operations as dot() only works on floats.
304      ${T}
305      ${m}
306      ${R}
307      int index = row * stride0 + col * stride1 +
308          depth * stride2 + depth2;
309      vec2 uv = uvFromFlat(${o}TexShape[0], ${o}TexShape[1], index + ${g});
310      return sampleTexture(${o}, uv);
311    }
312  `:`
313    float ${a}(int row, int col, int depth, int depth2) {
314      // Explicitly use integer operations as dot() only works on floats.
315      int index = row * ${u} + col * ${c} +
316          depth * ${l} + depth2;
317      vec2 uv = uvFromFlat(${$}, ${C}, index + ${g});
318      return sampleTexture(${o}, uv);
319    }
320  `}(t,n);case 5:return function(t){let n=t.shapeInfo.logicalShape,i=t.name,o="get"+i.charAt(0).toUpperCase()+i.slice(1),a=n[4],l=n[3]*a,c=n[2]*l,u=n[1]*c,{newShape:p,keptDims:x}=r.ZSL.squeezeShape(n);if(p.length<n.length){let n=f(t,p);return`
321      ${e(n)}
322      float ${o}(int row, int col, int depth, int depth2, int depth3) {
323        return ${o}(${S(["row","col","depth","depth2","depth3"],x)});
324      }
325    `}if(t.shapeInfo.isUniform)return`
326      float ${o}(int row, int col, int depth, int depth2, int depth3) {
327        float index = dot(
328          vec4(row, col, depth, depth2),
329          vec4(${u}, ${c}, ${l}, ${a})) +
330          depth3;
331        ${d(t)}
332      }
333    `;let h=t.shapeInfo.flatOffset,v=t.shapeInfo.texShape,$=v[0],C=v[1];if(C===u&&null==h)return`
334      float ${o}(int row, int col, int depth, int depth2, int depth3) {
335        int texR = row;
336        float texC = dot(vec4(col, depth, depth2, depth3),
337                         vec4(${c}, ${l}, ${a}, 1));
338        vec2 uv = (vec2(texC, texR) + halfCR) /
339                   vec2(${C}.0, ${$}.0);
340        return sampleTexture(${i}, uv);
341      }
342    `;if(C===a&&null==h)return`
343      float ${o}(int row, int col, int depth, int depth2, int depth3) {
344        float texR = dot(
345          vec4(row, col, depth, depth2),
346          vec4(${n[1]*n[2]*n[3]},
347               ${n[2]*n[3]}, ${n[3]}, 1));
348        int texC = depth3;
349        vec2 uv = (vec2(texC, texR) + halfCR) /
350                  vec2(${C}.0, ${$}.0);
351        return sampleTexture(${i}, uv);
352      }
353    `;let T=s(i);return`
354    float ${o}(int row, int col, int depth, int depth2, int depth3) {
355      // Explicitly use integer operations as dot() only works on floats.
356      int index = row * ${u} + col * ${c} + depth * ${l} +
357          depth2 * ${a} + depth3 + ${T};
358      vec2 uv = uvFromFlat(${$}, ${C}, index);
359      return sampleTexture(${i}, uv);
360    }
361  `}(t);case 6:return function(t){let n=t.shapeInfo.logicalShape,i=t.name,o="get"+i.charAt(0).toUpperCase()+i.slice(1),{newShape:a,keptDims:l}=r.ZSL.squeezeShape(n);if(a.length<n.length){let n=f(t,a);return`
362      ${e(n)}
363      float ${o}(int row, int col, int depth,
364                    int depth2, int depth3, int depth4) {
365        return ${o}(${S(["row","col","depth","depth2","depth3","depth4"],l)});
366      }
367    `}let c=n[5],u=n[4]*c,p=n[3]*u,x=n[2]*p,h=n[1]*x;if(t.shapeInfo.isUniform)return`
368      float ${o}(int row, int col, int depth,
369                  int depth2, int depth3, int depth4) {
370        int index = round(dot(
371          vec4(row, col, depth, depth2),
372          vec4(${h}, ${x}, ${p}, ${u})) +
373          dot(
374            vec2(depth3, depth4),
375            vec2(${c}, 1)));
376        ${d(t)}
377      }
378    `;let v=t.shapeInfo.flatOffset,$=t.shapeInfo.texShape,C=$[0],T=$[1];if(T===h&&null==v)return`
379      float ${o}(int row, int col, int depth,
380                    int depth2, int depth3, int depth4) {
381        int texR = row;
382        float texC = dot(vec4(col, depth, depth2, depth3),
383          vec4(${x}, ${p}, ${u}, ${c})) +
384               float(depth4);
385        vec2 uv = (vec2(texC, texR) + halfCR) /
386                   vec2(${T}.0, ${C}.0);
387        return sampleTexture(${i}, uv);
388      }
389    `;if(T===c&&null==v)return`
390      float ${o}(int row, int col, int depth,
391                    int depth2, int depth3, int depth4) {
392        float texR = dot(vec4(row, col, depth, depth2),
393          vec4(${n[1]*n[2]*n[3]*n[4]},
394               ${n[2]*n[3]*n[4]},
395               ${n[3]*n[4]},
396               ${n[4]})) + float(depth3);
397        int texC = depth4;
398        vec2 uv = (vec2(texC, texR) + halfCR) /
399                  vec2(${T}.0, ${C}.0);
400        return sampleTexture(${i}, uv);
401      }
402    `;let m=s(i);return`
403    float ${o}(int row, int col, int depth,
404                  int depth2, int depth3, int depth4) {
405      // Explicitly use integer operations as dot() only works on floats.
406      int index = row * ${h} + col * ${x} + depth * ${p} +
407          depth2 * ${u} + depth3 * ${c} + depth4 + ${m};
408      vec2 uv = uvFromFlat(${C}, ${T}, index);
409      return sampleTexture(${i}, uv);
410    }
411  `}(t);default:throw Error(`${i.length}-D input sampling is not yet supported`)}}(e,o);let c=e.shapeInfo.logicalShape,u=t.logicalShape;return c.length<=u.length&&(n?l+=function(e,t){let n,i=e.name,o=i.charAt(0).toUpperCase()+i.slice(1),l=e.shapeInfo.logicalShape.length,c=t.logicalShape.length,u=a(e.shapeInfo.logicalShape,t.logicalShape),p=v(c),x=c-l,h=["x","y","z","w","u","v"];n=0===l?"":c<2&&u.length>=1?"coords = 0;":u.map(e=>`coords.${h[e+x]} = 0;`).join("\n");let s="";s=c<2&&l>0?"coords":e.shapeInfo.logicalShape.map((e,t)=>`coords.${h[t+x]}`).join(", ");let d="return outputValue;",$=1===r.ZSL.sizeFromShape(e.shapeInfo.logicalShape),f=1===r.ZSL.sizeFromShape(t.logicalShape);if(1!==l||$||f){if($&&!f)d=1===c?`
412        return vec4(outputValue.x, outputValue.x, 0., 0.);
413      `:`
414        return vec4(outputValue.x);
415      `;else if(u.length){let e=l-2,t=l-1;u.indexOf(e)>-1&&u.indexOf(t)>-1?d="return vec4(outputValue.x);":u.indexOf(e)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(t)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);")}}else d=`
416      return vec4(outputValue.xy, outputValue.xy);
417    `;return`
418    vec4 ${"get"+o+"AtOutCoords"}() {
419      ${p} coords = getOutputCoords();
420      ${n}
421      vec4 outputValue = get${o}(${s});
422      ${d}
423    }
424  `}(e,t):l+=function(e,t){let n,i=e.name,o=i.charAt(0).toUpperCase()+i.slice(1),l="get"+o+"AtOutCoords",c=t.texShape,u=e.shapeInfo.texShape,p=e.shapeInfo.logicalShape.length,x=t.logicalShape.length;if(!e.shapeInfo.isUniform&&p===x&&null==e.shapeInfo.flatOffset&&r.ZSL.arraysEqual(u,c))return`
425      float ${l}() {
426        return sampleTexture(${i}, resultUV);
427      }
428    `;let h=v(x),s=a(e.shapeInfo.logicalShape,t.logicalShape),d=x-p,$=["x","y","z","w","u","v"];n=0===p?"":x<2&&s.length>=1?"coords = 0;":s.map(e=>`coords.${$[e+d]} = 0;`).join("\n");let f="";return f=x<2&&p>0?"coords":e.shapeInfo.logicalShape.map((e,t)=>`coords.${$[t+d]}`).join(", "),`
429    float ${l}() {
430      ${h} coords = getOutputCoords();
431      ${n}
432      return get${o}(${f});
433    }
434  `}(e,t)),l})(e,t,n.packedInputs,n.enableShapeUniforms)).join("\n"),U=t.texShape,k=(0,i.B)(),V=(l=k,`
435    float sampleTexture(sampler2D textureSampler, vec2 uv) {
436      return ${l.texture2D}(textureSampler, uv).r;
437    }
438  `),O=(C=k,`${C.version}
439    precision highp float;
440    precision highp int;
441    precision highp sampler2D;
442    ${C.varyingFs} vec2 resultUV;
443    ${C.defineOutput}
444    const vec2 halfCR = vec2(0.5, 0.5);
445
446    struct ivec5
447    {
448      int x;
449      int y;
450      int z;
451      int w;
452      int u;
453    };
454
455    struct ivec6
456    {
457      int x;
458      int y;
459      int z;
460      int w;
461      int u;
462      int v;
463    };
464
465    uniform float NAN;
466    ${C.defineSpecialNaN}
467    ${C.defineSpecialInf}
468    ${C.defineRound}
469
470    int imod(int x, int y) {
471      return x - y * (x / y);
472    }
473
474    int idiv(int a, int b, float sign) {
475      int res = a / b;
476      int mod = imod(a, b);
477      if (sign < 0. && mod != 0) {
478        res -= 1;
479      }
480      return res;
481    }
482
483    //Based on the work of Dave Hoskins
484    //https://www.shadertoy.com/view/4djSRW
485    #define HASHSCALE1 443.8975
486    float random(float seed){
487      vec2 p = resultUV * seed;
488      vec3 p3  = fract(vec3(p.xyx) * HASHSCALE1);
489      p3 += dot(p3, p3.yzx + 19.19);
490      return fract((p3.x + p3.y) * p3.z);
491    }
492
493    ${c}
494    ${u}
495    ${p}
496  `);return t.isPacked?(R=function(e,t,n){switch(e.length){case 0:return h();case 1:var i,o;let a;return i=t,o=n,1===(a=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)])[0]?o?`
497      int getOutputCoords() {
498        return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));
499      }
500    `:`
501      int getOutputCoords() {
502        return 2 * int(resultUV.x * ${a[1]}.0);
503      }
504    `:1===a[1]?o?`
505      int getOutputCoords() {
506        return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));
507      }
508    `:`
509      int getOutputCoords() {
510        return 2 * int(resultUV.y * ${a[0]}.0);
511      }
512    `:o?`
513    int getOutputCoords() {
514      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
515      ivec2 resTexRC = ivec2(resultUV.yx *
516                             vec2(packedTexShape[0], packedTexShape[1]));
517      return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);
518    }
519  `:`
520    int getOutputCoords() {
521      ivec2 resTexRC = ivec2(resultUV.yx *
522                             vec2(${a[0]}, ${a[1]}));
523      return 2 * (resTexRC.x * ${a[1]} + resTexRC.y);
524    }
525  `;case 2:var l=e,c=t,u=n;let p=[Math.ceil(c[0]/2),Math.ceil(c[1]/2)];if(r.ZSL.arraysEqual(l,c))return u?`
526      ivec2 getOutputCoords() {
527        ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
528        return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));
529      }
530    `:`
531      ivec2 getOutputCoords() {
532        return 2 * ivec2(resultUV.yx * vec2(${p[0]}, ${p[1]}));
533      }
534    `;let x=Math.ceil(l[1]/2);return u?`
535    ivec2 getOutputCoords() {
536      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
537      int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));
538      ivec2 resTexRC = ivec2(resultUV.yx *
539                             vec2(packedTexShape[0], packedTexShape[1]));
540
541      int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
542      int r = 2 * (index / texelsInLogicalRow);
543      int c = imod(index, texelsInLogicalRow) * 2;
544
545      return ivec2(r, c);
546    }
547  `:`
548    ivec2 getOutputCoords() {
549      ivec2 resTexRC = ivec2(resultUV.yx *
550                             vec2(${p[0]}, ${p[1]}));
551
552      int index = resTexRC.x * ${p[1]} + resTexRC.y;
553      int r = 2 * (index / ${x});
554      int c = imod(index, ${x}) * 2;
555
556      return ivec2(r, c);
557    }
558  `;case 3:var s=e,d=t,v=n;if(v)return`
559    ivec3 getOutputCoords() {
560      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
561      int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));
562      int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));
563      ivec2 resTexRC = ivec2(resultUV.yx *
564                             vec2(packedTexShape[0], packedTexShape[1]));
565      int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
566
567      int b = index / texelsInBatch;
568      index -= b * texelsInBatch;
569
570      int r = 2 * (index / texelsInLogicalRow);
571      int c = imod(index, texelsInLogicalRow) * 2;
572
573      return ivec3(b, r, c);
574    }
575  `;let $=[Math.ceil(d[0]/2),Math.ceil(d[1]/2)],f=Math.ceil(s[2]/2),S=f*Math.ceil(s[1]/2);return`
576    ivec3 getOutputCoords() {
577      ivec2 resTexRC = ivec2(resultUV.yx *
578                             vec2(${$[0]}, ${$[1]}));
579      int index = resTexRC.x * ${$[1]} + resTexRC.y;
580
581      int b = index / ${S};
582      index -= b * ${S};
583
584      int r = 2 * (index / ${f});
585      int c = imod(index, ${f}) * 2;
586
587      return ivec3(b, r, c);
588    }
589  `;default:return function(e,t,n){if(n)return`
590    ivec4 getOutputCoords() {
591      ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
592      ivec2 resTexRC = ivec2(resultUV.yx *
593                             vec2(packedTexShape[0], packedTexShape[1]));
594      int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
595
596      int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));
597      int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));
598      int texelsInBatchN = texelsInBatch * outShape[1];
599
600      int b2 = index / texelsInBatchN;
601      index -= b2 * texelsInBatchN;
602
603      int b = index / texelsInBatch;
604      index -= b * texelsInBatch;
605
606      int r = 2 * (index / texelsInLogicalRow);
607      int c = imod(index, texelsInLogicalRow) * 2;
608
609      return ivec4(b2, b, r, c);
610    }
611  `;let r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],i=Math.ceil(e[e.length-1]/2),o=i*Math.ceil(e[e.length-2]/2),a=o,l="",c="b, r, c";for(let t=2;t<e.length-1;t++)a*=e[e.length-t-1],l=`
612      int b${t} = index / ${a};
613      index -= b${t} * ${a};
614    `+l,c=`b${t}, `+c;return`
615    ivec${e.length} getOutputCoords() {
616      ivec2 resTexRC = ivec2(resultUV.yx *
617                             vec2(${r[0]}, ${r[1]}));
618      int index = resTexRC.x * ${r[1]} + resTexRC.y;
619
620      ${l}
621
622      int b = index / ${o};
623      index -= b * ${o};
624
625      int r = 2 * (index / ${i});
626      int c = imod(index, ${i}) * 2;
627
628      return ivec${e.length}(${c});
629    }
630  `}(e,t,n)}}(t.logicalShape,U,n.enableShapeUniforms),T=k,g=`
631    void setOutput(vec4 val) {
632      ${T.output} = val;
633    }
634  `):(R=function(e,t,n){switch(e.length){case 0:return h();case 1:return i=t,a=n,1===i[0]?a?`
635      int getOutputCoords() {
636        return int(resultUV.x * float(outTexShape[1]));
637      }
638    `:`
639      int getOutputCoords() {
640        return int(resultUV.x * ${i[1]}.0);
641      }
642    `:1===i[1]?a?`
643      int getOutputCoords() {
644        return int(resultUV.y * float(outTexShape[0]));
645      }
646    `:`
647      int getOutputCoords() {
648        return int(resultUV.y * ${i[0]}.0);
649      }
650    `:a?`
651    int getOutputCoords() {
652      ivec2 resTexRC = ivec2(resultUV.yx *
653                             vec2(outTexShape[0], outTexShape[1]));
654      return resTexRC.x * outTexShape[1] + resTexRC.y;
655    }
656  `:`
657    int getOutputCoords() {
658      ivec2 resTexRC = ivec2(resultUV.yx *
659                             vec2(${i[0]}, ${i[1]}));
660      return resTexRC.x * ${i[1]} + resTexRC.y;
661    }
662  `;case 2:return l=e,c=t,u=n,r.ZSL.arraysEqual(l,c)?u?`
663      ivec2 getOutputCoords() {
664        return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));
665      }
666    `:`
667      ivec2 getOutputCoords() {
668        return ivec2(resultUV.yx * vec2(${c[0]}, ${c[1]}));
669      }
670    `:1===l[1]?u?`
671      ivec2 getOutputCoords() {
672        ivec2 resTexRC = ivec2(resultUV.yx *
673                               vec2(outTexShape[0], outTexShape[1]));
674        int index = resTexRC.x * outTexShape[1] + resTexRC.y;
675        return ivec2(index, 0);
676      }
677    `:`
678      ivec2 getOutputCoords() {
679        ivec2 resTexRC = ivec2(resultUV.yx *
680                               vec2(${c[0]}, ${c[1]}));
681        int index = resTexRC.x * ${c[1]} + resTexRC.y;
682        return ivec2(index, 0);
683      }
684    `:1===l[0]?u?`
685      ivec2 getOutputCoords() {
686        ivec2 resTexRC = ivec2(resultUV.yx *
687                               vec2(outTexShape[0], outTexShape[1]));
688        int index = resTexRC.x * outTexShape[1] + resTexRC.y;
689        return ivec2(0, index);
690      }
691    `:`
692      ivec2 getOutputCoords() {
693        ivec2 resTexRC = ivec2(resultUV.yx *
694                               vec2(${c[0]}, ${c[1]}));
695        int index = resTexRC.x * ${c[1]} + resTexRC.y;
696        return ivec2(0, index);
697      }
698    `:u?`
699    ivec2 getOutputCoords() {
700      ivec2 resTexRC = ivec2(resultUV.yx *
701                             vec2(outTexShape[0], outTexShape[1]));
702      int index = resTexRC.x * outTexShape[1] + resTexRC.y;
703      int r = index / outShape[1];
704      int c = index - r * outShape[1];
705      return ivec2(r, c);
706    }
707  `:`
708    ivec2 getOutputCoords() {
709      ivec2 resTexRC = ivec2(resultUV.yx *
710                             vec2(${c[0]}, ${c[1]}));
711      int index = resTexRC.x * ${c[1]} + resTexRC.y;
712      int r = index / ${l[1]};
713      int c = index - r * ${l[1]};
714      return ivec2(r, c);
715    }
716  `;case 3:var i,a,l,c,u,p,x,s,d,v=e,$=t,f=n;if(f){let e=o.WA(["r","c","d"],v);return`
717  ivec3 getOutputCoords() {
718    ivec2 resTexRC = ivec2(resultUV.yx *
719                           vec2(outTexShape[0], outTexShape[1]));
720    int index = resTexRC.x * outTexShape[1] + resTexRC.y;
721    ${e}
722    return ivec3(r, c, d);
723  }
724`}let S=o.UG(["r","c","d"],v);return`
725    ivec3 getOutputCoords() {
726      ivec2 resTexRC = ivec2(resultUV.yx *
727                             vec2(${$[0]}, ${$[1]}));
728      int index = resTexRC.x * ${$[1]} + resTexRC.y;
729      ${S}
730      return ivec3(r, c, d);
731    }
732  `;case 4:var C=e,T=t,m=n;if(m){let e=o.WA(["r","c","d","d2"],C);return`
733    ivec4 getOutputCoords() {
734      ivec2 resTexRC = ivec2(resultUV.yx *
735        vec2(outTexShape[0], outTexShape[1]));
736      int index = resTexRC.x * outTexShape[1] + resTexRC.y;
737      ${e}
738      return ivec4(r, c, d, d2);
739    }
740  `}let R=o.UG(["r","c","d","d2"],C);return`
741    ivec4 getOutputCoords() {
742      ivec2 resTexRC = ivec2(resultUV.yx *
743        vec2(${T[0]}, ${T[1]}));
744      int index = resTexRC.x * ${T[1]} + resTexRC.y;
745      ${R}
746      return ivec4(r, c, d, d2);
747    }
748  `;case 5:let g;return p=e,x=t,g=o.UG(["r","c","d","d2","d3"],p),`
749    ivec5 getOutputCoords() {
750      ivec2 resTexRC = ivec2(resultUV.yx * vec2(${x[0]},
751                             ${x[1]}));
752
753      int index = resTexRC.x * ${x[1]} + resTexRC.y;
754
755      ${g}
756
757      ivec5 outShape = ivec5(r, c, d, d2, d3);
758      return outShape;
759    }
760  `;case 6:let w;return s=e,d=t,w=o.UG(["r","c","d","d2","d3","d4"],s),`
761    ivec6 getOutputCoords() {
762      ivec2 resTexRC = ivec2(resultUV.yx *
763        vec2(${d[0]}, ${d[1]}));
764      int index = resTexRC.x * ${d[1]} + resTexRC.y;
765
766      ${w}
767
768      ivec6 result = ivec6(r, c, d, d2, d3, d4);
769      return result;
770    }
771  `;default:throw Error(`${e.length}-D output sampling is not yet supported`)}}(t.logicalShape,U,n.enableShapeUniforms),m=k,g=`
772    void setOutput(float val) {
773      ${m.output} = vec4(val, 0, 0, 0);
774    }
775  `),n.packedInputs&&(O+=x),[O,V,g,y,R,I,n.userCode].join("\n")}let c=`
776vec2 uvFromFlat(int texNumR, int texNumC, int index) {
777  int texR = index / texNumC;
778  int texC = index - texR * texNumC;
779  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
780}
781vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
782  int texelIndex = index / 2;
783  int texR = texelIndex / texNumC;
784  int texC = texelIndex - texR * texNumC;
785  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
786}
787`,u=`
788vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
789  int texNumC, int row, int col) {
790  int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
791  int texR = texelIndex / texNumC;
792  int texC = texelIndex - texR * texNumC;
793  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
794}
795`,p=`
796vec2 packedUVfrom3D(int texNumR, int texNumC,
797    int texelsInBatch, int texelsInLogicalRow, int b,
798    int row, int col) {
799  int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
800  int texR = index / texNumC;
801  int texC = index - texR * texNumC;
802  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
803}
804`,x=`
805  float getChannel(vec4 frag, vec2 innerDims) {
806    vec2 modCoord = mod(innerDims, 2.);
807    return modCoord.x == 0. ?
808      (modCoord.y == 0. ? frag.r : frag.g) :
809      (modCoord.y == 0. ? frag.b : frag.a);
810  }
811  float getChannel(vec4 frag, int dim) {
812    float modCoord = mod(float(dim), 2.);
813    return modCoord == 0. ? frag.r : frag.g;
814  }
815`;function h(){return`
816    int getOutputCoords() {
817      return 0;
818    }
819  `}function s(e){return`offset${e}`}function d(e){let t=e.name,n=r.ZSL.sizeFromShape(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`
820    for (int i = 0; i < ${n}; i++) {
821      if (i == index) {
822        return ${t}[i];
823      }
824    }
825  `}function v(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";else if(6===e)return"ivec6";else throw Error(`GPU for rank ${e} is not yet supported`)}function $(e,t,n){let{newShape:i,keptDims:o}=r.ZSL.squeezeShape(t),a=t.length,l=e&&3===a&&1===t[0],c=l?t.slice(1):i,u=!e&&a>1&&!r.ZSL.arraysEqual(t,n)&&i.length<a||l,p=u?c:t;return{useSqueezeShape:u,uniformShape:p,keptDims:o}}function f(e,t){let n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function S(e,t){return t.map(t=>e[t]).join(", ")}}}]);

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.