@genai-fi/nanogpt 0.24.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +78 -281
  2. package/dist/{RealDiv-CNsvC4AU.js → RealDiv-CSnvtN2E.js} +20 -20
  3. package/dist/{Reshape-dnm9bO3B.js → Reshape-BlylqwWy.js} +12 -12
  4. package/dist/TeachableLLM.d.ts +10 -14
  5. package/dist/TeachableLLM.js +201 -2
  6. package/dist/api/responses.d.ts +81 -0
  7. package/dist/api/responses.js +169 -0
  8. package/dist/api/training.d.ts +70 -0
  9. package/dist/api/training.js +205 -0
  10. package/dist/data/docx.js +9 -3036
  11. package/dist/data/stream.d.ts +2 -2
  12. package/dist/data/textLoader.d.ts +1 -1
  13. package/dist/data/textLoader.js +1 -1
  14. package/dist/data.d.ts +3 -0
  15. package/dist/data.js +12 -0
  16. package/dist/{dist-BqAU9-yi.js → dist-CwK5S7Ls.js} +2168 -2168
  17. package/dist/{gpgpu_math-DBYEAAdI.js → gpgpu_math-20tPK8LM.js} +458 -458
  18. package/dist/{Generator.d.ts → inference/Generator.d.ts} +16 -44
  19. package/dist/inference/Generator.js +271 -0
  20. package/dist/inference/tokenisePrompt.d.ts +4 -0
  21. package/dist/inference/tokenisePrompt.js +13 -0
  22. package/dist/inference/types.d.ts +44 -8
  23. package/dist/inference/utilities.d.ts +9 -0
  24. package/dist/inference/utilities.js +20 -0
  25. package/dist/jszip.min-DKa1Rjyn.js +3033 -0
  26. package/dist/{kernel_funcs_utils-D-mATnGR.js → kernel_funcs_utils-ql8Y8qPn.js} +96 -93
  27. package/dist/layers/MLP.d.ts +1 -1
  28. package/dist/layers/PositionEmbedding.d.ts +2 -1
  29. package/dist/layers/PositionEmbedding.js +1 -1
  30. package/dist/layers/RMSNorm.d.ts +1 -1
  31. package/dist/layers/TiedEmbedding.js +1 -1
  32. package/dist/layers.d.ts +4 -0
  33. package/dist/layers.js +14 -0
  34. package/dist/loader/load.js +58 -2
  35. package/dist/loader/loadHF.d.ts +1 -1
  36. package/dist/loader/loadHF.js +17 -2
  37. package/dist/loader/loadTransformers.js +46 -2
  38. package/dist/loader/newZipLoad.js +25 -2
  39. package/dist/loader/oldZipLoad.d.ts +1 -1
  40. package/dist/loader/oldZipLoad.js +37 -2
  41. package/dist/loader/save.js +75 -2
  42. package/dist/loader/types.d.ts +3 -3
  43. package/dist/main.d.ts +34 -35
  44. package/dist/main.js +12327 -20
  45. package/dist/{matMulGelu-BAIgQaRx.js → matMulGelu-CBoqTZM7.js} +2 -2
  46. package/dist/models/NanoGPTV1.js +95 -2
  47. package/dist/models/NanoGPTV2.js +86 -2
  48. package/dist/models/factory.js +13 -2
  49. package/dist/models/model.js +76 -2
  50. package/dist/models.d.ts +4 -0
  51. package/dist/models.js +14 -0
  52. package/dist/ops/dot16.js +1 -1
  53. package/dist/ops/matMulGelu.js +1 -1
  54. package/dist/ops/webgl/adamAdjust.js +1 -1
  55. package/dist/ops/webgl/fusedSoftmax.js +2 -2
  56. package/dist/ops/webgl/gelu.js +2 -2
  57. package/dist/ops/webgl/log.js +5 -5
  58. package/dist/ops/webgl/matMulGelu.js +1 -1
  59. package/dist/ops/webgl/matMulMul.js +1 -1
  60. package/dist/{tfjs_backend-CydPRQTc.js → tfjs_backend-h5weiy1O.js} +36 -36
  61. package/dist/tokenise.d.ts +4 -0
  62. package/dist/tokenise.js +15 -0
  63. package/dist/training/BasicTrainer.d.ts +5 -10
  64. package/dist/training/BasicTrainer.js +80 -88
  65. package/dist/training/configure.d.ts +3 -0
  66. package/dist/training/configure.js +32 -0
  67. package/dist/training/factory.d.ts +6 -0
  68. package/dist/training/factory.js +8 -0
  69. package/dist/training/prepareData.d.ts +22 -0
  70. package/dist/training/prepareData.js +49 -0
  71. package/dist/training/tasks/tokenStream.d.ts +2 -1
  72. package/dist/training/types.d.ts +14 -1
  73. package/dist/training/validateOptions.d.ts +2 -0
  74. package/dist/training/validateOptions.js +19 -0
  75. package/dist/utilities/arrayShape.d.ts +1 -0
  76. package/dist/utilities/arrayShape.js +8 -0
  77. package/dist/utilities/waitForModel.d.ts +1 -1
  78. package/dist/v4-BK7K-jy_.js +30 -0
  79. package/package.json +8 -2
  80. package/dist/Generator.js +0 -2
  81. package/dist/Trainer-Cr7csbTD.js +0 -228
  82. package/dist/Trainer.d.ts +0 -45
  83. package/dist/Trainer.js +0 -2
  84. package/dist/main-Dz72vadm.js +0 -13267
@@ -1,334 +1,7 @@
1
1
  import { Ln as e, Ms as t, Ns as n, Ps as r, Rs as i, cc as a, ic as o, oc as s, sc as c, tc as l } from "./dist-Da20xy8E.js";
2
2
  import { t as u } from "./backend_util-DAV0I34P.js";
3
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/canvas_util.js
4
- var d = {}, f = {
5
- alpha: !1,
6
- antialias: !1,
7
- premultipliedAlpha: !1,
8
- preserveDrawingBuffer: !1,
9
- depth: !1,
10
- stencil: !1,
11
- failIfMajorPerformanceCaveat: !0
12
- };
13
- function p(e, t) {
14
- d[e] = t;
15
- }
16
- function m(e, t) {
17
- if (!(e in d) || t != null) {
18
- let n = g(e, t);
19
- if (n !== null) d[e] = n;
20
- else return console.log("Could not get context for WebGL version", e), null;
21
- }
22
- let n = d[e];
23
- return n == null || n.isContextLost() ? (delete d[e], m(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), d[e]);
24
- }
25
- function h(e) {
26
- if (!t().getBool("IS_SAFARI") && typeof OffscreenCanvas < "u" && e === 2) return new OffscreenCanvas(300, 150);
27
- if (typeof document < "u") return document.createElement("canvas");
28
- throw Error("Cannot create a canvas in this context");
29
- }
30
- function g(e, n) {
31
- if (e !== 1 && e !== 2) throw Error("Cannot get WebGL rendering context, WebGL is disabled.");
32
- let r = n ?? h(e);
33
- return r.addEventListener("webglcontextlost", (t) => {
34
- t.preventDefault(), delete d[e];
35
- }, !1), t().getBool("SOFTWARE_WEBGL_ENABLED") && (f.failIfMajorPerformanceCaveat = !1), e === 1 ? r.getContext("webgl", f) || r.getContext("experimental-webgl", f) : r.getContext("webgl2", f);
36
- }
37
- //#endregion
38
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/tex_util.js
39
- var _;
40
- (function(e) {
41
- e[e.DENSE = 0] = "DENSE", e[e.SHARED_BATCH = 1] = "SHARED_BATCH";
42
- })(_ ||= {});
43
- var v;
44
- (function(e) {
45
- e[e.RENDER = 0] = "RENDER", e[e.UPLOAD = 1] = "UPLOAD", e[e.PIXELS = 2] = "PIXELS", e[e.DOWNLOAD = 3] = "DOWNLOAD";
46
- })(v ||= {});
47
- var y;
48
- (function(e) {
49
- e[e.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", e[e.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", e[e.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", e[e.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", e[e.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16";
50
- })(y ||= {});
51
- function b(e, t) {
52
- return [t, e];
53
- }
54
- function x(e, t) {
55
- return e * t;
56
- }
57
- function ee(e) {
58
- let t = s(e);
59
- return c(Math.ceil(t / 4));
60
- }
61
- function S(e, t) {
62
- return [Math.max(1, Math.ceil(t / 2)), Math.max(1, Math.ceil(e / 2))];
63
- }
64
- function C(e, t) {
65
- let [n, r] = S(e, t);
66
- return n * r * 4;
67
- }
68
- function w(e, n) {
69
- let r = e, i, a, o, s, c, l, u, d, f, p;
70
- return t().getNumber("WEBGL_VERSION") === 2 ? (i = r.R32F, a = r.R16F, o = r.RGBA16F, s = r.RGBA32F, c = r.RED, u = 4, d = 1, f = r.HALF_FLOAT, p = r.FLOAT, l = r.RGBA8) : (i = e.RGBA, a = e.RGBA, o = e.RGBA, s = r.RGBA, c = e.RGBA, u = 4, d = 4, f = n == null ? null : n.HALF_FLOAT_OES, p = e.FLOAT, l = e.RGBA), {
71
- internalFormatFloat: i,
72
- internalFormatHalfFloat: a,
73
- internalFormatPackedHalfFloat: o,
74
- internalFormatPackedFloat: s,
75
- textureFormatFloat: c,
76
- downloadTextureFormat: l,
77
- downloadUnpackNumChannels: u,
78
- defaultNumChannels: d,
79
- textureTypeHalfFloat: f,
80
- textureTypeFloat: p
81
- };
82
- }
83
- //#endregion
84
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/webgl_util.js
85
- function T(e, n) {
86
- let r = n();
87
- return t().getBool("DEBUG") && te(e), r;
88
- }
89
- function te(e) {
90
- let t = e.getError();
91
- if (t !== e.NO_ERROR) throw Error("WebGL Error: " + ae(e, t));
92
- }
93
- var ne = 5.96e-8, re = 65504;
94
- function ie(e) {
95
- return !!(t().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || e === 0 || ne < Math.abs(e) && Math.abs(e) < re);
96
- }
97
- function ae(e, t) {
98
- switch (t) {
99
- case e.NO_ERROR: return "NO_ERROR";
100
- case e.INVALID_ENUM: return "INVALID_ENUM";
101
- case e.INVALID_VALUE: return "INVALID_VALUE";
102
- case e.INVALID_OPERATION: return "INVALID_OPERATION";
103
- case e.INVALID_FRAMEBUFFER_OPERATION: return "INVALID_FRAMEBUFFER_OPERATION";
104
- case e.OUT_OF_MEMORY: return "OUT_OF_MEMORY";
105
- case e.CONTEXT_LOST_WEBGL: return "CONTEXT_LOST_WEBGL";
106
- default: return `Unknown error code ${t}`;
107
- }
108
- }
109
- function oe(e, t) {
110
- return A(e, () => e.getExtension(t), "Extension \"" + t + "\" not supported on this browser.");
111
- }
112
- function se(e, t) {
113
- let n = A(e, () => e.createShader(e.VERTEX_SHADER), "Unable to create vertex WebGLShader.");
114
- if (T(e, () => e.shaderSource(n, t)), T(e, () => e.compileShader(n)), e.getShaderParameter(n, e.COMPILE_STATUS) === !1) throw console.log(e.getShaderInfoLog(n)), Error("Failed to compile vertex shader.");
115
- return n;
116
- }
117
- function ce(e, n) {
118
- let r = A(e, () => e.createShader(e.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
119
- if (T(e, () => e.shaderSource(r, n)), T(e, () => e.compileShader(r)), t().get("ENGINE_COMPILE_ONLY")) return r;
120
- if (e.getShaderParameter(r, e.COMPILE_STATUS) === !1) throw E(n, e.getShaderInfoLog(r)), Error("Failed to compile fragment shader.");
121
- return r;
122
- }
123
- var le = /ERROR: [0-9]+:([0-9]+):/g;
124
- function E(e, t) {
125
- let n = le.exec(t);
126
- if (n == null) {
127
- console.log(`Couldn't parse line number in error: ${t}`), console.log(e);
128
- return;
129
- }
130
- let r = +n[1], i = e.split("\n"), a = i.length.toString().length + 2, s = i.map((e, t) => o((t + 1).toString(), a) + e), c = 0;
131
- for (let e = 0; e < s.length; e++) c = Math.max(s[e].length, c);
132
- let l = s.slice(0, r - 1), u = s.slice(r - 1, r), d = s.slice(r);
133
- console.log(l.join("\n")), console.log(t.split("\n")[0]), console.log(`%c ${o(u[0], c)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(d.join("\n"));
134
- }
135
- function ue(e) {
136
- return A(e, () => e.createProgram(), "Unable to create WebGLProgram.");
137
- }
138
- function de(e, n) {
139
- if (T(e, () => e.linkProgram(n)), !t().get("ENGINE_COMPILE_ONLY") && e.getProgramParameter(n, e.LINK_STATUS) === !1) throw console.log(e.getProgramInfoLog(n)), Error("Failed to link vertex and fragment shaders.");
140
- }
141
- function fe(e, t) {
142
- if (T(e, () => e.validateProgram(t)), e.getProgramParameter(t, e.VALIDATE_STATUS) === !1) throw console.log(e.getProgramInfoLog(t)), Error("Shader program validation failed.");
143
- }
144
- function pe(e, t) {
145
- let n = A(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
146
- return T(e, () => e.bindBuffer(e.ARRAY_BUFFER, n)), T(e, () => e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
147
- }
148
- function me(e, t) {
149
- let n = A(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
150
- return T(e, () => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n)), T(e, () => e.bufferData(e.ELEMENT_ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
151
- }
152
- function he(e) {
153
- return A(e, () => e.createTexture(), "Unable to create WebGLTexture.");
154
- }
155
- function ge(e, n) {
156
- let r = t().getNumber("WEBGL_MAX_TEXTURE_SIZE");
157
- if (e <= 0 || n <= 0) {
158
- let t = `[${e}x${n}]`;
159
- throw Error("Requested texture size " + t + " is invalid.");
160
- }
161
- if (e > r || n > r) {
162
- let t = `[${e}x${n}]`, i = `[${r}x${r}]`;
163
- throw Error("Requested texture size " + t + " greater than WebGL maximum on this browser / GPU " + i + ".");
164
- }
165
- }
166
- function _e(e) {
167
- return A(e, () => e.createFramebuffer(), "Unable to create WebGLFramebuffer.");
168
- }
169
- function ve(e, t, n, r, i, a, o) {
170
- let s = e.getAttribLocation(t, n);
171
- return s === -1 ? !1 : (T(e, () => e.bindBuffer(e.ARRAY_BUFFER, r)), T(e, () => e.vertexAttribPointer(s, i, e.FLOAT, !1, a, o)), T(e, () => e.enableVertexAttribArray(s)), !0);
172
- }
173
- function ye(e, t, n) {
174
- we(e, n), T(e, () => e.activeTexture(e.TEXTURE0 + n)), T(e, () => e.bindTexture(e.TEXTURE_2D, t));
175
- }
176
- function be(e, t, n) {
177
- return A(e, () => e.getUniformLocation(t, n), "uniform \"" + n + "\" not present in program.");
178
- }
179
- function xe(e, t, n) {
180
- return e.getUniformLocation(t, n);
181
- }
182
- function Se(e, t, n, r) {
183
- T(e, () => ye(e, t, r)), T(e, () => e.uniform1i(n, r));
184
- }
185
- function Ce(e, t, n) {
186
- T(e, () => e.bindFramebuffer(e.FRAMEBUFFER, n)), T(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0));
187
- }
188
- function D(e, t) {
189
- T(e, () => e.bindFramebuffer(e.FRAMEBUFFER, t)), T(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, null, 0));
190
- }
191
- function O(e) {
192
- let t = e.checkFramebufferStatus(e.FRAMEBUFFER);
193
- if (t !== e.FRAMEBUFFER_COMPLETE) throw Error("Error binding framebuffer: " + k(e, t));
194
- }
195
- function k(e, t) {
196
- switch (t) {
197
- case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
198
- case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
199
- case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
200
- case e.FRAMEBUFFER_UNSUPPORTED: return "FRAMEBUFFER_UNSUPPORTED";
201
- default: return `unknown error ${t}`;
202
- }
203
- }
204
- function A(e, t, n) {
205
- let r = T(e, () => t());
206
- if (r == null) throw Error(n);
207
- return r;
208
- }
209
- function we(e, t) {
210
- let n = e.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, r = t + e.TEXTURE0;
211
- if (r < e.TEXTURE0 || r > n) {
212
- let e = `[gl.TEXTURE0, gl.TEXTURE${n}]`;
213
- throw Error(`textureUnit must be in ${e}.`);
214
- }
215
- }
216
- function j(e, t = 2) {
217
- return s(e.slice(0, e.length - t));
218
- }
219
- function M(e) {
220
- if (e.length === 0) throw Error("Cannot get rows and columns of an empty shape array.");
221
- return [e.length > 1 ? e[e.length - 2] : 1, e[e.length - 1]];
222
- }
223
- function Te(e) {
224
- let t = [
225
- 1,
226
- 1,
227
- 1
228
- ];
229
- return e.length === 0 || e.length === 1 && e[0] === 1 || (t = [j(e), ...M(e)]), t;
230
- }
231
- function Ee(e, n = !1) {
232
- let r = t().getNumber("WEBGL_MAX_TEXTURE_SIZE"), i = t().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
233
- i === Infinity && t().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (i = r / 2), n && (r *= 2, i *= 2, e = e.map((t, n) => n >= e.length - 2 ? l(e[n]) : e[n]), e.length === 1 && (e = [2, e[0]])), e.length !== 2 && (e = a(e).newShape);
234
- let o = s(e), u = null;
235
- e.length <= 1 && o <= r ? u = [1, o] : e.length === 2 && e[0] <= r && e[1] <= r ? u = e : e.length === 3 && e[0] * e[1] <= r && e[2] <= r ? u = [e[0] * e[1], e[2]] : e.length === 3 && e[0] <= r && e[1] * e[2] <= r ? u = [e[0], e[1] * e[2]] : e.length === 4 && e[0] * e[1] * e[2] <= r && e[3] <= r ? u = [e[0] * e[1] * e[2], e[3]] : e.length === 4 && e[0] <= r && e[1] * e[2] * e[3] <= r && (u = [e[0], e[1] * e[2] * e[3]]);
236
- let d = u != null && Math.max(...u) > i && Math.min(...u) <= (n ? 2 : 1) && Math.min(...u) > 0;
237
- if (u == null || d) if (n) {
238
- let t = j(e), n = 2, r = 2;
239
- e.length && ([n, r] = M(e)), o = n / 2 * t * (r / 2), u = c(o).map((e) => e * 2);
240
- } else u = c(o);
241
- return u;
242
- }
243
- function N(e) {
244
- return e % 2 == 0;
245
- }
246
- function De(e, t) {
247
- if (e = e.slice(-2), t = t.slice(-2), n(e, t) || !e.length || !t.length || e[0] === 0 || e[1] === 0 || t[0] === 0 || t[1] === 0) return !0;
248
- if (e.length !== t.length) {
249
- let n = e[e.length - 1], r = t[t.length - 1];
250
- if (n === r || N(n) && N(r) && (e[0] === 1 || t[0] === 1)) return !0;
251
- }
252
- return e[1] === t[1] && N(e[0]) && N(t[0]);
253
- }
254
- var P, F;
255
- function Oe(e) {
256
- if (P == null) {
257
- let t = m(e);
258
- P = t.getParameter(t.MAX_TEXTURE_SIZE);
259
- }
260
- return P;
261
- }
262
- function ke(e) {
263
- if (F == null) {
264
- let t = m(e);
265
- F = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
266
- }
267
- return Math.min(16, F);
268
- }
269
- function Ae(e) {
270
- if (e === 0) return 0;
271
- let t, n = m(e);
272
- return t = I(n, "EXT_disjoint_timer_query_webgl2") && e === 2 ? 2 : +!!I(n, "EXT_disjoint_timer_query"), t;
273
- }
274
- function I(e, t) {
275
- return e.getExtension(t) != null;
276
- }
277
- function je(e) {
278
- try {
279
- if (m(e) != null) return !0;
280
- } catch (e) {
281
- return console.log("Error when getting WebGL context: ", e), !1;
282
- }
283
- return !1;
284
- }
285
- function Me(e) {
286
- if (e === 0) return !1;
287
- let t = m(e);
288
- if (e === 1) {
289
- if (!I(t, "OES_texture_float")) return !1;
290
- } else if (!I(t, "EXT_color_buffer_float")) return !1;
291
- return L(t);
292
- }
293
- function Ne(e) {
294
- if (e === 0) return !1;
295
- let t = m(e);
296
- if (e === 1) {
297
- if (!I(t, "OES_texture_float") || !I(t, "WEBGL_color_buffer_float")) return !1;
298
- } else {
299
- if (I(t, "EXT_color_buffer_float")) return L(t);
300
- let e = "EXT_color_buffer_half_float";
301
- return I(t, e) ? Pe(t, t.getExtension(e)) : !1;
302
- }
303
- return L(t);
304
- }
305
- function L(e) {
306
- let t = w(e), n = e.createTexture();
307
- e.bindTexture(e.TEXTURE_2D, n), e.texImage2D(e.TEXTURE_2D, 0, t.internalFormatFloat, 1, 1, 0, t.textureFormatFloat, t.textureTypeFloat, null);
308
- let r = e.createFramebuffer();
309
- e.bindFramebuffer(e.FRAMEBUFFER, r), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, n, 0);
310
- let i = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
311
- return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(n), e.deleteFramebuffer(r), i;
312
- }
313
- function Pe(e, t) {
314
- let n = w(e, t), r = e.createTexture();
315
- e.bindTexture(e.TEXTURE_2D, r), e.texImage2D(e.TEXTURE_2D, 0, n.internalFormatHalfFloat, 1, 1, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null);
316
- let i = e.createFramebuffer();
317
- e.bindFramebuffer(e.FRAMEBUFFER, i), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0);
318
- let a = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
319
- return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(i), a;
320
- }
321
- function Fe(e) {
322
- return e === 2 ? m(e).fenceSync != null : !1;
323
- }
324
- function Ie(e, t) {
325
- Array.isArray(e) || (e = [e]), e.forEach((e) => {
326
- e != null && r(e.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGL backend.`);
327
- });
328
- }
329
- //#endregion
330
3
  //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/glsl_version.js
331
- function R() {
4
+ function d() {
332
5
  let e, n, r, i, a, o, s, c, l, u;
333
6
  return t().getNumber("WEBGL_VERSION") === 2 ? (e = "#version 300 es", n = "in", r = "out", i = "in", a = "texture", o = "outputColor", s = "out vec4 outputColor;", c = t().getBool("WEBGL2_ISNAN_CUSTOM") ? "\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n " : "", l = "", u = "\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n ") : (e = "", n = "attribute", r = "varying", i = "varying", a = "texture2D", o = "gl_FragColor", s = "", c = "\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ", l = "\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ", u = "\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "), {
334
7
  version: e,
@@ -345,25 +18,25 @@ function R() {
345
18
  }
346
19
  //#endregion
347
20
  //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/shader_compiler_util.js
348
- function z(e, t, n = "index") {
21
+ function f(e, t, n = "index") {
349
22
  let r = i(t);
350
23
  return r.map((t, i) => `${`int ${e[i]} = ${n} / ${t}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${t}` : `index -= ${e[i]} * ${t}`};`).join("");
351
24
  }
352
- function B(e, t, n = "index") {
25
+ function p(e, t, n = "index") {
353
26
  let r = i(t);
354
27
  return r.map((t, i) => `${`int ${e[i]} = ${n} / outShapeStrides[${i}]`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * outShapeStrides[${i}]` : `index -= ${e[i]} * outShapeStrides[${i}]`};`).join("");
355
28
  }
356
- function Le(e, t) {
29
+ function m(e, t) {
357
30
  let n = e.length, r = e.map((e) => `${t}[${e}]`), i = Array(n - 1);
358
31
  i[n - 2] = r[n - 1];
359
32
  for (let e = n - 3; e >= 0; --e) i[e] = `(${i[e + 1]} * ${r[e + 1]})`;
360
33
  return i;
361
34
  }
362
- function Re(e, t, n = "index") {
363
- let r = Le(e.map((e, t) => t), t);
35
+ function h(e, t, n = "index") {
36
+ let r = m(e.map((e, t) => t), t);
364
37
  return r.map((t, i) => `${`int ${e[i]} = ${n} / ${r[i]}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${r[i]}` : `index -= ${e[i]} * ${r[i]}`};`).join("");
365
38
  }
366
- function ze(e) {
39
+ function g(e) {
367
40
  let t = i(e).map((e) => e.toString());
368
41
  return `
369
42
  int getFlatIndex(ivec3 coords) {
@@ -371,16 +44,16 @@ function ze(e) {
371
44
  }
372
45
  `;
373
46
  }
374
- function Be() {
47
+ function _() {
375
48
  return "\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n";
376
49
  }
377
- var Ve = "\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n", { getBroadcastDims: V } = u;
378
- function He(e, t, n) {
50
+ var v = "\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n", { getBroadcastDims: y } = u;
51
+ function b(e, t, n) {
379
52
  let r = [];
380
53
  if (e.forEach((e) => {
381
54
  let t = s(e.shapeInfo.logicalShape);
382
55
  if (e.shapeInfo.isUniform ? r.push(`uniform float ${e.name}${t > 1 ? `[${t}]` : ""};`) : (r.push(`uniform sampler2D ${e.name};`), r.push(`uniform int offset${e.name};`)), n.enableShapeUniforms) {
383
- let { uniformShape: t } = Y(n.packedInputs, e.shapeInfo.logicalShape, e.shapeInfo.texShape);
56
+ let { uniformShape: t } = A(n.packedInputs, e.shapeInfo.logicalShape, e.shapeInfo.texShape);
384
57
  switch (t.length) {
385
58
  case 1:
386
59
  r.push(`uniform int ${e.name}Shape;`);
@@ -419,88 +92,88 @@ function He(e, t, n) {
419
92
  n.customUniforms && n.customUniforms.forEach((e) => {
420
93
  r.push(`uniform ${e.type} ${e.name}${e.arrayIndex ? `[${e.arrayIndex}]` : ""};`);
421
94
  });
422
- let i = r.join("\n"), a = e.map((e) => Ue(e, t, n.packedInputs, n.enableShapeUniforms)).join("\n"), o = t.texShape, c = R(), l = Ke(c), u, d, f = Ye(c);
423
- return t.isPacked ? (u = We(t.logicalShape, o, n.enableShapeUniforms), d = Je(c)) : (u = Ge(t.logicalShape, o, n.enableShapeUniforms), d = qe(c)), n.packedInputs && (f += $e), [
424
- f,
95
+ let i = r.join("\n"), a = e.map((e) => ee(e, t, n.packedInputs, n.enableShapeUniforms)).join("\n"), o = t.texShape, c = d(), l = re(c), u, f, p = oe(c);
96
+ return t.isPacked ? (u = te(t.logicalShape, o, n.enableShapeUniforms), f = ae(c)) : (u = ne(t.logicalShape, o, n.enableShapeUniforms), f = ie(c)), n.packedInputs && (p += ue), [
97
+ p,
425
98
  l,
426
- d,
99
+ f,
427
100
  i,
428
101
  u,
429
102
  a,
430
103
  n.userCode
431
104
  ].join("\n");
432
105
  }
433
- function H(e, t = !1) {
106
+ function x(e, t = !1) {
434
107
  let n = e.shapeInfo.logicalShape;
435
108
  switch (n.length) {
436
- case 0: return dt(e, t);
437
- case 1: return pt(e, t);
438
- case 2: return ht(e, t);
439
- case 3: return _t(e, t);
440
- case 4: return yt(e, t);
441
- case 5: return K(e);
442
- case 6: return bt(e);
109
+ case 0: return Se(e, t);
110
+ case 1: return we(e, t);
111
+ case 2: return Ee(e, t);
112
+ case 3: return E(e, t);
113
+ case 4: return De(e, t);
114
+ case 5: return Oe(e);
115
+ case 6: return ke(e);
443
116
  default: throw Error(`${n.length}-D input sampling is not yet supported`);
444
117
  }
445
118
  }
446
- function U(e, t) {
119
+ function S(e, t) {
447
120
  switch (e.shapeInfo.logicalShape.length) {
448
- case 0: return ut(e);
449
- case 1: return ft(e, t);
450
- case 2: return mt(e, t);
451
- case 3: return gt(e, t);
452
- default: return vt(e, t);
121
+ case 0: return xe(e);
122
+ case 1: return Ce(e, t);
123
+ case 2: return Te(e, t);
124
+ case 3: return T(e, t);
125
+ default: return D(e, t);
453
126
  }
454
127
  }
455
- function Ue(e, t, n = !1, r) {
128
+ function ee(e, t, n = !1, r) {
456
129
  let i = "";
457
- n ? i += U(e, r) : i += H(e, r);
130
+ n ? i += S(e, r) : i += x(e, r);
458
131
  let a = e.shapeInfo.logicalShape, o = t.logicalShape;
459
- return a.length <= o.length && (n ? i += xt(e, t) : i += St(e, t)), i;
132
+ return a.length <= o.length && (n ? i += Ae(e, t) : i += je(e, t)), i;
460
133
  }
461
- function We(e, t, n) {
134
+ function te(e, t, n) {
462
135
  switch (e.length) {
463
- case 0: return W();
464
- case 1: return et(e, t, n);
465
- case 2: return ct(e, t, n);
466
- case 3: return nt(e, t, n);
467
- default: return it(e, t, n);
136
+ case 0: return C();
137
+ case 1: return de(e, t, n);
138
+ case 2: return ye(e, t, n);
139
+ case 3: return pe(e, t, n);
140
+ default: return he(e, t, n);
468
141
  }
469
142
  }
470
- function Ge(e, t, n) {
143
+ function ne(e, t, n) {
471
144
  switch (e.length) {
472
- case 0: return W();
473
- case 1: return tt(e, t, n);
474
- case 2: return lt(e, t, n);
475
- case 3: return rt(e, t, n);
476
- case 4: return at(e, t, n);
477
- case 5: return ot(e, t);
478
- case 6: return st(e, t);
145
+ case 0: return C();
146
+ case 1: return fe(e, t, n);
147
+ case 2: return be(e, t, n);
148
+ case 3: return me(e, t, n);
149
+ case 4: return ge(e, t, n);
150
+ case 5: return _e(e, t);
151
+ case 6: return ve(e, t);
479
152
  default: throw Error(`${e.length}-D output sampling is not yet supported`);
480
153
  }
481
154
  }
482
- function Ke(e) {
155
+ function re(e) {
483
156
  return `
484
157
  float sampleTexture(sampler2D textureSampler, vec2 uv) {
485
158
  return ${e.texture2D}(textureSampler, uv).r;
486
159
  }
487
160
  `;
488
161
  }
489
- function qe(e) {
162
+ function ie(e) {
490
163
  return `
491
164
  void setOutput(float val) {
492
165
  ${e.output} = vec4(val, 0, 0, 0);
493
166
  }
494
167
  `;
495
168
  }
496
- function Je(e) {
169
+ function ae(e) {
497
170
  return `
498
171
  void setOutput(vec4 val) {
499
172
  ${e.output} = val;
500
173
  }
501
174
  `;
502
175
  }
503
- function Ye(e) {
176
+ function oe(e) {
504
177
  return `${e.version}
505
178
  precision highp float;
506
179
  precision highp int;
@@ -556,16 +229,16 @@ function Ye(e) {
556
229
  return fract((p3.x + p3.y) * p3.z);
557
230
  }
558
231
 
559
- ${Xe}
560
- ${Ze}
561
- ${Qe}
232
+ ${se}
233
+ ${ce}
234
+ ${le}
562
235
  `;
563
236
  }
564
- var Xe = "\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", Ze = "\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", Qe = "\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", $e = "\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";
565
- function W() {
237
+ var se = "\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", ce = "\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", le = "\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", ue = "\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";
238
+ function C() {
566
239
  return "\n int getOutputCoords() {\n return 0;\n }\n ";
567
240
  }
568
- function et(e, t, n) {
241
+ function de(e, t, n) {
569
242
  let r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)];
570
243
  return r[0] === 1 ? n ? "\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n " : `
571
244
  int getOutputCoords() {
@@ -583,7 +256,7 @@ function et(e, t, n) {
583
256
  }
584
257
  `;
585
258
  }
586
- function tt(e, t, n) {
259
+ function fe(e, t, n) {
587
260
  return t[0] === 1 ? n ? "\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n " : `
588
261
  int getOutputCoords() {
589
262
  return int(resultUV.x * ${t[1]}.0);
@@ -600,7 +273,7 @@ function tt(e, t, n) {
600
273
  }
601
274
  `;
602
275
  }
603
- function nt(e, t, n) {
276
+ function pe(e, t, n) {
604
277
  if (n) return "\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";
605
278
  let r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], i = Math.ceil(e[2] / 2), a = i * Math.ceil(e[1] / 2);
606
279
  return `
@@ -619,13 +292,13 @@ function nt(e, t, n) {
619
292
  }
620
293
  `;
621
294
  }
622
- function rt(e, t, n) {
295
+ function me(e, t, n) {
623
296
  if (n) return `
624
297
  ivec3 getOutputCoords() {
625
298
  ivec2 resTexRC = ivec2(resultUV.yx *
626
299
  vec2(outTexShape[0], outTexShape[1]));
627
300
  int index = resTexRC.x * outTexShape[1] + resTexRC.y;
628
- ${B([
301
+ ${p([
629
302
  "r",
630
303
  "c",
631
304
  "d"
@@ -633,7 +306,7 @@ function rt(e, t, n) {
633
306
  return ivec3(r, c, d);
634
307
  }
635
308
  `;
636
- let r = z([
309
+ let r = f([
637
310
  "r",
638
311
  "c",
639
312
  "d"
@@ -648,7 +321,7 @@ function rt(e, t, n) {
648
321
  }
649
322
  `;
650
323
  }
651
- function it(e, t, n) {
324
+ function he(e, t, n) {
652
325
  if (n) return "\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";
653
326
  let r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], i = Math.ceil(e[e.length - 1] / 2), a = i * Math.ceil(e[e.length - 2] / 2), o = a, s = "", c = "b, r, c";
654
327
  for (let t = 2; t < e.length - 1; t++) o *= e[e.length - t - 1], s = `
@@ -673,13 +346,13 @@ function it(e, t, n) {
673
346
  }
674
347
  `;
675
348
  }
676
- function at(e, t, n) {
349
+ function ge(e, t, n) {
677
350
  if (n) return `
678
351
  ivec4 getOutputCoords() {
679
352
  ivec2 resTexRC = ivec2(resultUV.yx *
680
353
  vec2(outTexShape[0], outTexShape[1]));
681
354
  int index = resTexRC.x * outTexShape[1] + resTexRC.y;
682
- ${B([
355
+ ${p([
683
356
  "r",
684
357
  "c",
685
358
  "d",
@@ -688,7 +361,7 @@ function at(e, t, n) {
688
361
  return ivec4(r, c, d, d2);
689
362
  }
690
363
  `;
691
- let r = z([
364
+ let r = f([
692
365
  "r",
693
366
  "c",
694
367
  "d",
@@ -704,8 +377,8 @@ function at(e, t, n) {
704
377
  }
705
378
  `;
706
379
  }
707
- function ot(e, t) {
708
- let n = z([
380
+ function _e(e, t) {
381
+ let n = f([
709
382
  "r",
710
383
  "c",
711
384
  "d",
@@ -726,8 +399,8 @@ function ot(e, t) {
726
399
  }
727
400
  `;
728
401
  }
729
- function st(e, t) {
730
- let n = z([
402
+ function ve(e, t) {
403
+ let n = f([
731
404
  "r",
732
405
  "c",
733
406
  "d",
@@ -748,7 +421,7 @@ function st(e, t) {
748
421
  }
749
422
  `;
750
423
  }
751
- function ct(e, t, r) {
424
+ function ye(e, t, r) {
752
425
  let i = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)];
753
426
  if (n(e, t)) return r ? "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n " : `
754
427
  ivec2 getOutputCoords() {
@@ -769,7 +442,7 @@ function ct(e, t, r) {
769
442
  }
770
443
  `;
771
444
  }
772
- function lt(e, t, r) {
445
+ function be(e, t, r) {
773
446
  return n(e, t) ? r ? "\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n " : `
774
447
  ivec2 getOutputCoords() {
775
448
  return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));
@@ -799,18 +472,18 @@ function lt(e, t, r) {
799
472
  }
800
473
  `;
801
474
  }
802
- function G(e) {
475
+ function w(e) {
803
476
  return `offset${e}`;
804
477
  }
805
- function ut(e) {
478
+ function xe(e) {
806
479
  let t = e.name;
807
480
  return `
808
481
  vec4 ${"get" + t.charAt(0).toUpperCase() + t.slice(1)}() {
809
- return ${R().texture2D}(${t}, halfCR);
482
+ return ${d().texture2D}(${t}, halfCR);
810
483
  }
811
484
  `;
812
485
  }
813
- function dt(e, t) {
486
+ function Se(e, t) {
814
487
  let n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1);
815
488
  if (e.shapeInfo.isUniform) return `float ${r}() {return ${n};}`;
816
489
  let [i, a] = e.shapeInfo.texShape;
@@ -819,7 +492,7 @@ function dt(e, t) {
819
492
  return sampleTexture(${n}, halfCR);
820
493
  }
821
494
  `;
822
- let o = G(n);
495
+ let o = w(n);
823
496
  if (t) return `
824
497
  float ${r}() {
825
498
  vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${o});
@@ -834,8 +507,8 @@ function dt(e, t) {
834
507
  }
835
508
  `;
836
509
  }
837
- function ft(e, t) {
838
- let n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = e.shapeInfo.texShape, a = R();
510
+ function Ce(e, t) {
511
+ let n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = e.shapeInfo.texShape, a = d();
839
512
  if (t) return `
840
513
  vec4 ${r}(int index) {
841
514
  ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));
@@ -853,11 +526,11 @@ function ft(e, t) {
853
526
  }
854
527
  `;
855
528
  }
856
- function pt(e, t) {
529
+ function we(e, t) {
857
530
  let n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1);
858
531
  if (e.shapeInfo.isUniform) return `
859
532
  float ${r}(int index) {
860
- ${q(e)}
533
+ ${O(e)}
861
534
  }
862
535
  `;
863
536
  let i = e.shapeInfo.texShape, a = i[0], o = i[1];
@@ -866,7 +539,7 @@ function pt(e, t) {
866
539
  return sampleTexture(${n}, halfCR);
867
540
  }
868
541
  `;
869
- let s = G(n);
542
+ let s = w(n);
870
543
  return o === 1 ? t ? `
871
544
  float ${r}(int index) {
872
545
  vec2 uv = vec2(0.5, (float(index + ${s}) + 0.5) / float(${n}TexShape[0]));
@@ -899,8 +572,8 @@ function pt(e, t) {
899
572
  }
900
573
  `;
901
574
  }
902
- function mt(e, t) {
903
- let r = e.shapeInfo.logicalShape, i = e.name, a = "get" + i.charAt(0).toUpperCase() + i.slice(1), o = e.shapeInfo.texShape, s = o[0], c = o[1], l = R();
575
+ function Te(e, t) {
576
+ let r = e.shapeInfo.logicalShape, i = e.name, a = "get" + i.charAt(0).toUpperCase() + i.slice(1), o = e.shapeInfo.texShape, s = o[0], c = o[1], l = d();
904
577
  if (o != null && n(r, o)) return t ? `
905
578
  vec4 ${a}(int row, int col) {
906
579
  vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}TexShape[1], ${i}TexShape[0]);
@@ -930,7 +603,7 @@ function mt(e, t) {
930
603
  }
931
604
  `;
932
605
  }
933
- function ht(e, t) {
606
+ function Ee(e, t) {
934
607
  let r = e.shapeInfo.logicalShape, i = e.name, o = "get" + i.charAt(0).toUpperCase() + i.slice(1), s = e.shapeInfo.texShape;
935
608
  if (s != null && n(r, s)) {
936
609
  if (t) return `
@@ -949,18 +622,18 @@ function ht(e, t) {
949
622
  }
950
623
  let { newShape: c, keptDims: l } = a(r), u = c;
951
624
  if (u.length < r.length) return `
952
- ${H(X(e, u), t)}
625
+ ${x(j(e, u), t)}
953
626
  float ${o}(int row, int col) {
954
- return ${o}(${Z(["row", "col"], l)});
627
+ return ${o}(${M(["row", "col"], l)});
955
628
  }
956
629
  `;
957
630
  if (e.shapeInfo.isUniform) return `
958
631
  float ${o}(int row, int col) {
959
632
  int index = round(dot(vec2(row, col), vec2(${r[1]}, 1)));
960
- ${q(e)}
633
+ ${O(e)}
961
634
  }
962
635
  `;
963
- let d = s[0], f = s[1], p = G(i);
636
+ let d = s[0], f = s[1], p = w(i);
964
637
  return f === 1 ? t ? `
965
638
  float ${o}(int row, int col) {
966
639
  float index = dot(vec3(row, col, ${p}), vec3(${i}Shape[1], 1, 1));
@@ -1001,19 +674,19 @@ function ht(e, t) {
1001
674
  }
1002
675
  `;
1003
676
  }
1004
- function gt(e, t) {
677
+ function T(e, t) {
1005
678
  let n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, o = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)];
1006
679
  if (n[0] === 1) return `
1007
- ${U(X(e, n.slice(1)), t)}
680
+ ${S(j(e, n.slice(1)), t)}
1008
681
  vec4 ${i}(int b, int row, int col) {
1009
- return ${i}(${Z([
682
+ return ${i}(${M([
1010
683
  "b",
1011
684
  "row",
1012
685
  "col"
1013
686
  ], [1, 2])});
1014
687
  }
1015
688
  `;
1016
- let s = R();
689
+ let s = d();
1017
690
  if (t) return `
1018
691
  vec4 ${i}(int b, int row, int col) {
1019
692
  ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));
@@ -1033,12 +706,12 @@ function gt(e, t) {
1033
706
  }
1034
707
  `;
1035
708
  }
1036
- function _t(e, t) {
709
+ function E(e, t) {
1037
710
  let n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), o = n[1] * n[2], s = n[2], { newShape: c, keptDims: l } = a(n), u = c;
1038
711
  if (u.length < n.length) return `
1039
- ${H(X(e, u), t)}
712
+ ${x(j(e, u), t)}
1040
713
  float ${i}(int row, int col, int depth) {
1041
- return ${i}(${Z([
714
+ return ${i}(${M([
1042
715
  "row",
1043
716
  "col",
1044
717
  "depth"
@@ -1049,7 +722,7 @@ function _t(e, t) {
1049
722
  float ${i}(int row, int col, int depth) {
1050
723
  int index = round(dot(vec3(row, col, depth),
1051
724
  vec3(${o}, ${s}, 1)));
1052
- ${q(e)}
725
+ ${O(e)}
1053
726
  }
1054
727
  `;
1055
728
  let d = e.shapeInfo.texShape, f = d[0], p = d[1], m = e.shapeInfo.flatOffset;
@@ -1086,7 +759,7 @@ function _t(e, t) {
1086
759
  return sampleTexture(${r}, uv);
1087
760
  }
1088
761
  `;
1089
- let h = G(r);
762
+ let h = w(r);
1090
763
  return t ? `
1091
764
  float ${i}(int row, int col, int depth) {
1092
765
  // Explicitly use integer operations as dot() only works on floats.
@@ -1105,8 +778,8 @@ function _t(e, t) {
1105
778
  }
1106
779
  `;
1107
780
  }
1108
- function vt(e, t) {
1109
- let n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = R();
781
+ function D(e, t) {
782
+ let n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = d();
1110
783
  if (t) return `
1111
784
  vec4 ${r}(int b2, int b, int row, int col) {
1112
785
  int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));
@@ -1120,11 +793,11 @@ function vt(e, t) {
1120
793
  vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${i.texture2D}(${n}, uv);
1121
794
  }
1122
795
  `;
1123
- let a = e.shapeInfo.logicalShape, o = a.length, s = e.shapeInfo.texShape, c = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)], l = c[0], u = c[1], d = Math.ceil(a[o - 1] / 2), f = d * Math.ceil(a[o - 2] / 2), p = "int b, int row, int col", m = `b * ${f} + (row / 2) * ${d} + (col / 2)`;
1124
- for (let e = 2; e < o - 1; e++) p = `int b${e}, ` + p, f *= a[o - e - 1], m = `b${e} * ${f} + ` + m;
796
+ let a = e.shapeInfo.logicalShape, o = a.length, s = e.shapeInfo.texShape, c = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)], l = c[0], u = c[1], f = Math.ceil(a[o - 1] / 2), p = f * Math.ceil(a[o - 2] / 2), m = "int b, int row, int col", h = `b * ${p} + (row / 2) * ${f} + (col / 2)`;
797
+ for (let e = 2; e < o - 1; e++) m = `int b${e}, ` + m, p *= a[o - e - 1], h = `b${e} * ${p} + ` + h;
1125
798
  return `
1126
- vec4 ${r}(${p}) {
1127
- int index = ${m};
799
+ vec4 ${r}(${m}) {
800
+ int index = ${h};
1128
801
  int texR = index / ${u};
1129
802
  int texC = index - texR * ${u};
1130
803
  vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${u}, ${l});
@@ -1132,12 +805,12 @@ function vt(e, t) {
1132
805
  }
1133
806
  `;
1134
807
  }
1135
- function yt(e, t) {
808
+ function De(e, t) {
1136
809
  let n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), o = n[3], s = n[2] * o, c = n[1] * s, { newShape: l, keptDims: u } = a(n);
1137
810
  if (l.length < n.length) return `
1138
- ${H(X(e, l), t)}
811
+ ${x(j(e, l), t)}
1139
812
  float ${i}(int row, int col, int depth, int depth2) {
1140
- return ${i}(${Z([
813
+ return ${i}(${M([
1141
814
  "row",
1142
815
  "col",
1143
816
  "depth",
@@ -1149,7 +822,7 @@ function yt(e, t) {
1149
822
  float ${i}(int row, int col, int depth, int depth2) {
1150
823
  int index = round(dot(vec4(row, col, depth, depth2),
1151
824
  vec4(${c}, ${s}, ${o}, 1)));
1152
- ${q(e)}
825
+ ${O(e)}
1153
826
  }
1154
827
  `;
1155
828
  let d = e.shapeInfo.flatOffset, f = e.shapeInfo.texShape, p = f[0], m = f[1], h = `int stride2 = ${r}Shape[3];`, g = `int stride1 = ${r}Shape[2] * stride2;`, _ = `int stride0 = ${r}Shape[1] * stride1;`;
@@ -1195,7 +868,7 @@ function yt(e, t) {
1195
868
  return sampleTexture(${r}, uv);
1196
869
  }
1197
870
  `;
1198
- let v = G(r);
871
+ let v = w(r);
1199
872
  return t ? `
1200
873
  float ${i}(int row, int col, int depth, int depth2) {
1201
874
  // Explicitly use integer operations as dot() only works on floats.
@@ -1217,12 +890,12 @@ function yt(e, t) {
1217
890
  }
1218
891
  `;
1219
892
  }
1220
- function K(e) {
893
+ function Oe(e) {
1221
894
  let t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = t[4], o = t[3] * i, s = t[2] * o, c = t[1] * s, { newShape: l, keptDims: u } = a(t);
1222
895
  if (l.length < t.length) return `
1223
- ${H(X(e, l))}
896
+ ${x(j(e, l))}
1224
897
  float ${r}(int row, int col, int depth, int depth2, int depth3) {
1225
- return ${r}(${Z([
898
+ return ${r}(${M([
1226
899
  "row",
1227
900
  "col",
1228
901
  "depth",
@@ -1237,7 +910,7 @@ function K(e) {
1237
910
  vec4(row, col, depth, depth2),
1238
911
  vec4(${c}, ${s}, ${o}, ${i})) +
1239
912
  depth3;
1240
- ${q(e)}
913
+ ${O(e)}
1241
914
  }
1242
915
  `;
1243
916
  let d = e.shapeInfo.flatOffset, f = e.shapeInfo.texShape, p = f[0], m = f[1];
@@ -1265,19 +938,19 @@ function K(e) {
1265
938
  float ${r}(int row, int col, int depth, int depth2, int depth3) {
1266
939
  // Explicitly use integer operations as dot() only works on floats.
1267
940
  int index = row * ${c} + col * ${s} + depth * ${o} +
1268
- depth2 * ${i} + depth3 + ${G(n)};
941
+ depth2 * ${i} + depth3 + ${w(n)};
1269
942
  vec2 uv = uvFromFlat(${p}, ${m}, index);
1270
943
  return sampleTexture(${n}, uv);
1271
944
  }
1272
945
  `;
1273
946
  }
1274
- function bt(e) {
947
+ function ke(e) {
1275
948
  let t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: i, keptDims: o } = a(t);
1276
949
  if (i.length < t.length) return `
1277
- ${H(X(e, i))}
950
+ ${x(j(e, i))}
1278
951
  float ${r}(int row, int col, int depth,
1279
952
  int depth2, int depth3, int depth4) {
1280
- return ${r}(${Z([
953
+ return ${r}(${M([
1281
954
  "row",
1282
955
  "col",
1283
956
  "depth",
@@ -1297,7 +970,7 @@ function bt(e) {
1297
970
  dot(
1298
971
  vec2(depth3, depth4),
1299
972
  vec2(${s}, 1)));
1300
- ${q(e)}
973
+ ${O(e)}
1301
974
  }
1302
975
  `;
1303
976
  let f = e.shapeInfo.flatOffset, p = e.shapeInfo.texShape, m = p[0], h = p[1];
@@ -1330,13 +1003,13 @@ function bt(e) {
1330
1003
  int depth2, int depth3, int depth4) {
1331
1004
  // Explicitly use integer operations as dot() only works on floats.
1332
1005
  int index = row * ${d} + col * ${u} + depth * ${l} +
1333
- depth2 * ${c} + depth3 * ${s} + depth4 + ${G(n)};
1006
+ depth2 * ${c} + depth3 * ${s} + depth4 + ${w(n)};
1334
1007
  vec2 uv = uvFromFlat(${m}, ${h}, index);
1335
1008
  return sampleTexture(${n}, uv);
1336
1009
  }
1337
1010
  `;
1338
1011
  }
1339
- function q(e) {
1012
+ function O(e) {
1340
1013
  let t = e.name, n = s(e.shapeInfo.logicalShape);
1341
1014
  return n < 2 ? `return ${t};` : `
1342
1015
  for (int i = 0; i < ${n}; i++) {
@@ -1346,8 +1019,8 @@ function q(e) {
1346
1019
  }
1347
1020
  `;
1348
1021
  }
1349
- function xt(e, t) {
1350
- let n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = e.shapeInfo.logicalShape.length, o = t.logicalShape.length, c = V(e.shapeInfo.logicalShape, t.logicalShape), l = J(o), u = o - a, d, f = [
1022
+ function Ae(e, t) {
1023
+ let n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = e.shapeInfo.logicalShape.length, o = t.logicalShape.length, c = y(e.shapeInfo.logicalShape, t.logicalShape), l = k(o), u = o - a, d, f = [
1351
1024
  "x",
1352
1025
  "y",
1353
1026
  "z",
@@ -1374,14 +1047,14 @@ function xt(e, t) {
1374
1047
  }
1375
1048
  `;
1376
1049
  }
1377
- function St(e, t) {
1050
+ function je(e, t) {
1378
1051
  let r = e.name, i = r.charAt(0).toUpperCase() + r.slice(1), a = "get" + i + "AtOutCoords", o = t.texShape, s = e.shapeInfo.texShape, c = e.shapeInfo.logicalShape.length, l = t.logicalShape.length;
1379
1052
  if (!e.shapeInfo.isUniform && c === l && e.shapeInfo.flatOffset == null && n(s, o)) return `
1380
1053
  float ${a}() {
1381
1054
  return sampleTexture(${r}, resultUV);
1382
1055
  }
1383
1056
  `;
1384
- let u = J(l), d = V(e.shapeInfo.logicalShape, t.logicalShape), f = l - c, p, m = [
1057
+ let u = k(l), d = y(e.shapeInfo.logicalShape, t.logicalShape), f = l - c, p, m = [
1385
1058
  "x",
1386
1059
  "y",
1387
1060
  "z",
@@ -1399,7 +1072,7 @@ function St(e, t) {
1399
1072
  }
1400
1073
  `;
1401
1074
  }
1402
- function J(e) {
1075
+ function k(e) {
1403
1076
  if (e <= 1) return "int";
1404
1077
  if (e === 2) return "ivec2";
1405
1078
  if (e === 3) return "ivec3";
@@ -1408,7 +1081,7 @@ function J(e) {
1408
1081
  if (e === 6) return "ivec6";
1409
1082
  throw Error(`GPU for rank ${e} is not yet supported`);
1410
1083
  }
1411
- function Y(e, t, r) {
1084
+ function A(e, t, r) {
1412
1085
  let { newShape: i, keptDims: o } = a(t), s = t.length, c = e && s === 3 && t[0] === 1, l = c ? t.slice(1) : i, u = !e && s > 1 && !n(t, r) && i.length < s || c;
1413
1086
  return {
1414
1087
  useSqueezeShape: u,
@@ -1416,14 +1089,341 @@ function Y(e, t, r) {
1416
1089
  keptDims: o
1417
1090
  };
1418
1091
  }
1419
- function X(e, t) {
1092
+ function j(e, t) {
1420
1093
  let n = JSON.parse(JSON.stringify(e));
1421
1094
  return n.shapeInfo.logicalShape = t, n;
1422
1095
  }
1423
- function Z(e, t) {
1096
+ function M(e, t) {
1424
1097
  return t.map((t) => e[t]).join(", ");
1425
1098
  }
1426
1099
  //#endregion
1100
+ //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/canvas_util.js
1101
+ var N = {}, P = {
1102
+ alpha: !1,
1103
+ antialias: !1,
1104
+ premultipliedAlpha: !1,
1105
+ preserveDrawingBuffer: !1,
1106
+ depth: !1,
1107
+ stencil: !1,
1108
+ failIfMajorPerformanceCaveat: !0
1109
+ };
1110
+ function Me(e, t) {
1111
+ N[e] = t;
1112
+ }
1113
+ function F(e, t) {
1114
+ if (!(e in N) || t != null) {
1115
+ let n = Pe(e, t);
1116
+ if (n !== null) N[e] = n;
1117
+ else return console.log("Could not get context for WebGL version", e), null;
1118
+ }
1119
+ let n = N[e];
1120
+ return n == null || n.isContextLost() ? (delete N[e], F(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), N[e]);
1121
+ }
1122
+ function Ne(e) {
1123
+ if (!t().getBool("IS_SAFARI") && typeof OffscreenCanvas < "u" && e === 2) return new OffscreenCanvas(300, 150);
1124
+ if (typeof document < "u") return document.createElement("canvas");
1125
+ throw Error("Cannot create a canvas in this context");
1126
+ }
1127
+ function Pe(e, n) {
1128
+ if (e !== 1 && e !== 2) throw Error("Cannot get WebGL rendering context, WebGL is disabled.");
1129
+ let r = n ?? Ne(e);
1130
+ return r.addEventListener("webglcontextlost", (t) => {
1131
+ t.preventDefault(), delete N[e];
1132
+ }, !1), t().getBool("SOFTWARE_WEBGL_ENABLED") && (P.failIfMajorPerformanceCaveat = !1), e === 1 ? r.getContext("webgl", P) || r.getContext("experimental-webgl", P) : r.getContext("webgl2", P);
1133
+ }
1134
+ //#endregion
1135
+ //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/tex_util.js
1136
+ var I;
1137
+ (function(e) {
1138
+ e[e.DENSE = 0] = "DENSE", e[e.SHARED_BATCH = 1] = "SHARED_BATCH";
1139
+ })(I ||= {});
1140
+ var L;
1141
+ (function(e) {
1142
+ e[e.RENDER = 0] = "RENDER", e[e.UPLOAD = 1] = "UPLOAD", e[e.PIXELS = 2] = "PIXELS", e[e.DOWNLOAD = 3] = "DOWNLOAD";
1143
+ })(L ||= {});
1144
+ var R;
1145
+ (function(e) {
1146
+ e[e.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", e[e.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", e[e.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", e[e.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", e[e.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16";
1147
+ })(R ||= {});
1148
+ function Fe(e, t) {
1149
+ return [t, e];
1150
+ }
1151
+ function Ie(e, t) {
1152
+ return e * t;
1153
+ }
1154
+ function Le(e) {
1155
+ let t = s(e);
1156
+ return c(Math.ceil(t / 4));
1157
+ }
1158
+ function z(e, t) {
1159
+ return [Math.max(1, Math.ceil(t / 2)), Math.max(1, Math.ceil(e / 2))];
1160
+ }
1161
+ function Re(e, t) {
1162
+ let [n, r] = z(e, t);
1163
+ return n * r * 4;
1164
+ }
1165
+ function B(e, n) {
1166
+ let r = e, i, a, o, s, c, l, u, d, f, p;
1167
+ return t().getNumber("WEBGL_VERSION") === 2 ? (i = r.R32F, a = r.R16F, o = r.RGBA16F, s = r.RGBA32F, c = r.RED, u = 4, d = 1, f = r.HALF_FLOAT, p = r.FLOAT, l = r.RGBA8) : (i = e.RGBA, a = e.RGBA, o = e.RGBA, s = r.RGBA, c = e.RGBA, u = 4, d = 4, f = n == null ? null : n.HALF_FLOAT_OES, p = e.FLOAT, l = e.RGBA), {
1168
+ internalFormatFloat: i,
1169
+ internalFormatHalfFloat: a,
1170
+ internalFormatPackedHalfFloat: o,
1171
+ internalFormatPackedFloat: s,
1172
+ textureFormatFloat: c,
1173
+ downloadTextureFormat: l,
1174
+ downloadUnpackNumChannels: u,
1175
+ defaultNumChannels: d,
1176
+ textureTypeHalfFloat: f,
1177
+ textureTypeFloat: p
1178
+ };
1179
+ }
1180
+ //#endregion
1181
+ //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/webgl_util.js
1182
+ function V(e, n) {
1183
+ let r = n();
1184
+ return t().getBool("DEBUG") && ze(e), r;
1185
+ }
1186
+ function ze(e) {
1187
+ let t = e.getError();
1188
+ if (t !== e.NO_ERROR) throw Error("WebGL Error: " + Ue(e, t));
1189
+ }
1190
+ var Be = 5.96e-8, Ve = 65504;
1191
+ function He(e) {
1192
+ return !!(t().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || e === 0 || Be < Math.abs(e) && Math.abs(e) < Ve);
1193
+ }
1194
+ function Ue(e, t) {
1195
+ switch (t) {
1196
+ case e.NO_ERROR: return "NO_ERROR";
1197
+ case e.INVALID_ENUM: return "INVALID_ENUM";
1198
+ case e.INVALID_VALUE: return "INVALID_VALUE";
1199
+ case e.INVALID_OPERATION: return "INVALID_OPERATION";
1200
+ case e.INVALID_FRAMEBUFFER_OPERATION: return "INVALID_FRAMEBUFFER_OPERATION";
1201
+ case e.OUT_OF_MEMORY: return "OUT_OF_MEMORY";
1202
+ case e.CONTEXT_LOST_WEBGL: return "CONTEXT_LOST_WEBGL";
1203
+ default: return `Unknown error code ${t}`;
1204
+ }
1205
+ }
1206
+ function We(e, t) {
1207
+ return W(e, () => e.getExtension(t), "Extension \"" + t + "\" not supported on this browser.");
1208
+ }
1209
+ function Ge(e, t) {
1210
+ let n = W(e, () => e.createShader(e.VERTEX_SHADER), "Unable to create vertex WebGLShader.");
1211
+ if (V(e, () => e.shaderSource(n, t)), V(e, () => e.compileShader(n)), e.getShaderParameter(n, e.COMPILE_STATUS) === !1) throw console.log(e.getShaderInfoLog(n)), Error("Failed to compile vertex shader.");
1212
+ return n;
1213
+ }
1214
+ function Ke(e, n) {
1215
+ let r = W(e, () => e.createShader(e.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
1216
+ if (V(e, () => e.shaderSource(r, n)), V(e, () => e.compileShader(r)), t().get("ENGINE_COMPILE_ONLY")) return r;
1217
+ if (e.getShaderParameter(r, e.COMPILE_STATUS) === !1) throw U(n, e.getShaderInfoLog(r)), Error("Failed to compile fragment shader.");
1218
+ return r;
1219
+ }
1220
+ var H = /ERROR: [0-9]+:([0-9]+):/g;
1221
+ function U(e, t) {
1222
+ let n = H.exec(t);
1223
+ if (n == null) {
1224
+ console.log(`Couldn't parse line number in error: ${t}`), console.log(e);
1225
+ return;
1226
+ }
1227
+ let r = +n[1], i = e.split("\n"), a = i.length.toString().length + 2, s = i.map((e, t) => o((t + 1).toString(), a) + e), c = 0;
1228
+ for (let e = 0; e < s.length; e++) c = Math.max(s[e].length, c);
1229
+ let l = s.slice(0, r - 1), u = s.slice(r - 1, r), d = s.slice(r);
1230
+ console.log(l.join("\n")), console.log(t.split("\n")[0]), console.log(`%c ${o(u[0], c)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(d.join("\n"));
1231
+ }
1232
+ function qe(e) {
1233
+ return W(e, () => e.createProgram(), "Unable to create WebGLProgram.");
1234
+ }
1235
+ function Je(e, n) {
1236
+ if (V(e, () => e.linkProgram(n)), !t().get("ENGINE_COMPILE_ONLY") && e.getProgramParameter(n, e.LINK_STATUS) === !1) throw console.log(e.getProgramInfoLog(n)), Error("Failed to link vertex and fragment shaders.");
1237
+ }
1238
+ function Ye(e, t) {
1239
+ if (V(e, () => e.validateProgram(t)), e.getProgramParameter(t, e.VALIDATE_STATUS) === !1) throw console.log(e.getProgramInfoLog(t)), Error("Shader program validation failed.");
1240
+ }
1241
+ function Xe(e, t) {
1242
+ let n = W(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
1243
+ return V(e, () => e.bindBuffer(e.ARRAY_BUFFER, n)), V(e, () => e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
1244
+ }
1245
+ function Ze(e, t) {
1246
+ let n = W(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
1247
+ return V(e, () => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n)), V(e, () => e.bufferData(e.ELEMENT_ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
1248
+ }
1249
+ function Qe(e) {
1250
+ return W(e, () => e.createTexture(), "Unable to create WebGLTexture.");
1251
+ }
1252
+ function $e(e, n) {
1253
+ let r = t().getNumber("WEBGL_MAX_TEXTURE_SIZE");
1254
+ if (e <= 0 || n <= 0) {
1255
+ let t = `[${e}x${n}]`;
1256
+ throw Error("Requested texture size " + t + " is invalid.");
1257
+ }
1258
+ if (e > r || n > r) {
1259
+ let t = `[${e}x${n}]`, i = `[${r}x${r}]`;
1260
+ throw Error("Requested texture size " + t + " greater than WebGL maximum on this browser / GPU " + i + ".");
1261
+ }
1262
+ }
1263
+ function et(e) {
1264
+ return W(e, () => e.createFramebuffer(), "Unable to create WebGLFramebuffer.");
1265
+ }
1266
+ function tt(e, t, n, r, i, a, o) {
1267
+ let s = e.getAttribLocation(t, n);
1268
+ return s === -1 ? !1 : (V(e, () => e.bindBuffer(e.ARRAY_BUFFER, r)), V(e, () => e.vertexAttribPointer(s, i, e.FLOAT, !1, a, o)), V(e, () => e.enableVertexAttribArray(s)), !0);
1269
+ }
1270
+ function nt(e, t, n) {
1271
+ ut(e, n), V(e, () => e.activeTexture(e.TEXTURE0 + n)), V(e, () => e.bindTexture(e.TEXTURE_2D, t));
1272
+ }
1273
+ function rt(e, t, n) {
1274
+ return W(e, () => e.getUniformLocation(t, n), "uniform \"" + n + "\" not present in program.");
1275
+ }
1276
+ function it(e, t, n) {
1277
+ return e.getUniformLocation(t, n);
1278
+ }
1279
+ function at(e, t, n, r) {
1280
+ V(e, () => nt(e, t, r)), V(e, () => e.uniform1i(n, r));
1281
+ }
1282
+ function ot(e, t, n) {
1283
+ V(e, () => e.bindFramebuffer(e.FRAMEBUFFER, n)), V(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0));
1284
+ }
1285
+ function st(e, t) {
1286
+ V(e, () => e.bindFramebuffer(e.FRAMEBUFFER, t)), V(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, null, 0));
1287
+ }
1288
+ function ct(e) {
1289
+ let t = e.checkFramebufferStatus(e.FRAMEBUFFER);
1290
+ if (t !== e.FRAMEBUFFER_COMPLETE) throw Error("Error binding framebuffer: " + lt(e, t));
1291
+ }
1292
+ function lt(e, t) {
1293
+ switch (t) {
1294
+ case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
1295
+ case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
1296
+ case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
1297
+ case e.FRAMEBUFFER_UNSUPPORTED: return "FRAMEBUFFER_UNSUPPORTED";
1298
+ default: return `unknown error ${t}`;
1299
+ }
1300
+ }
1301
+ function W(e, t, n) {
1302
+ let r = V(e, () => t());
1303
+ if (r == null) throw Error(n);
1304
+ return r;
1305
+ }
1306
+ function ut(e, t) {
1307
+ let n = e.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, r = t + e.TEXTURE0;
1308
+ if (r < e.TEXTURE0 || r > n) {
1309
+ let e = `[gl.TEXTURE0, gl.TEXTURE${n}]`;
1310
+ throw Error(`textureUnit must be in ${e}.`);
1311
+ }
1312
+ }
1313
+ function G(e, t = 2) {
1314
+ return s(e.slice(0, e.length - t));
1315
+ }
1316
+ function K(e) {
1317
+ if (e.length === 0) throw Error("Cannot get rows and columns of an empty shape array.");
1318
+ return [e.length > 1 ? e[e.length - 2] : 1, e[e.length - 1]];
1319
+ }
1320
+ function dt(e) {
1321
+ let t = [
1322
+ 1,
1323
+ 1,
1324
+ 1
1325
+ ];
1326
+ return e.length === 0 || e.length === 1 && e[0] === 1 || (t = [G(e), ...K(e)]), t;
1327
+ }
1328
+ function ft(e, n = !1) {
1329
+ let r = t().getNumber("WEBGL_MAX_TEXTURE_SIZE"), i = t().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
1330
+ i === Infinity && t().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (i = r / 2), n && (r *= 2, i *= 2, e = e.map((t, n) => n >= e.length - 2 ? l(e[n]) : e[n]), e.length === 1 && (e = [2, e[0]])), e.length !== 2 && (e = a(e).newShape);
1331
+ let o = s(e), u = null;
1332
+ e.length <= 1 && o <= r ? u = [1, o] : e.length === 2 && e[0] <= r && e[1] <= r ? u = e : e.length === 3 && e[0] * e[1] <= r && e[2] <= r ? u = [e[0] * e[1], e[2]] : e.length === 3 && e[0] <= r && e[1] * e[2] <= r ? u = [e[0], e[1] * e[2]] : e.length === 4 && e[0] * e[1] * e[2] <= r && e[3] <= r ? u = [e[0] * e[1] * e[2], e[3]] : e.length === 4 && e[0] <= r && e[1] * e[2] * e[3] <= r && (u = [e[0], e[1] * e[2] * e[3]]);
1333
+ let d = u != null && Math.max(...u) > i && Math.min(...u) <= (n ? 2 : 1) && Math.min(...u) > 0;
1334
+ if (u == null || d) if (n) {
1335
+ let t = G(e), n = 2, r = 2;
1336
+ e.length && ([n, r] = K(e)), o = n / 2 * t * (r / 2), u = c(o).map((e) => e * 2);
1337
+ } else u = c(o);
1338
+ return u;
1339
+ }
1340
+ function q(e) {
1341
+ return e % 2 == 0;
1342
+ }
1343
+ function pt(e, t) {
1344
+ if (e = e.slice(-2), t = t.slice(-2), n(e, t) || !e.length || !t.length || e[0] === 0 || e[1] === 0 || t[0] === 0 || t[1] === 0) return !0;
1345
+ if (e.length !== t.length) {
1346
+ let n = e[e.length - 1], r = t[t.length - 1];
1347
+ if (n === r || q(n) && q(r) && (e[0] === 1 || t[0] === 1)) return !0;
1348
+ }
1349
+ return e[1] === t[1] && q(e[0]) && q(t[0]);
1350
+ }
1351
+ var J, Y;
1352
+ function mt(e) {
1353
+ if (J == null) {
1354
+ let t = F(e);
1355
+ J = t.getParameter(t.MAX_TEXTURE_SIZE);
1356
+ }
1357
+ return J;
1358
+ }
1359
+ function ht(e) {
1360
+ if (Y == null) {
1361
+ let t = F(e);
1362
+ Y = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
1363
+ }
1364
+ return Math.min(16, Y);
1365
+ }
1366
+ function gt(e) {
1367
+ if (e === 0) return 0;
1368
+ let t, n = F(e);
1369
+ return t = X(n, "EXT_disjoint_timer_query_webgl2") && e === 2 ? 2 : +!!X(n, "EXT_disjoint_timer_query"), t;
1370
+ }
1371
+ function X(e, t) {
1372
+ return e.getExtension(t) != null;
1373
+ }
1374
+ function _t(e) {
1375
+ try {
1376
+ if (F(e) != null) return !0;
1377
+ } catch (e) {
1378
+ return console.log("Error when getting WebGL context: ", e), !1;
1379
+ }
1380
+ return !1;
1381
+ }
1382
+ function vt(e) {
1383
+ if (e === 0) return !1;
1384
+ let t = F(e);
1385
+ if (e === 1) {
1386
+ if (!X(t, "OES_texture_float")) return !1;
1387
+ } else if (!X(t, "EXT_color_buffer_float")) return !1;
1388
+ return Z(t);
1389
+ }
1390
+ function yt(e) {
1391
+ if (e === 0) return !1;
1392
+ let t = F(e);
1393
+ if (e === 1) {
1394
+ if (!X(t, "OES_texture_float") || !X(t, "WEBGL_color_buffer_float")) return !1;
1395
+ } else {
1396
+ if (X(t, "EXT_color_buffer_float")) return Z(t);
1397
+ let e = "EXT_color_buffer_half_float";
1398
+ return X(t, e) ? bt(t, t.getExtension(e)) : !1;
1399
+ }
1400
+ return Z(t);
1401
+ }
1402
+ function Z(e) {
1403
+ let t = B(e), n = e.createTexture();
1404
+ e.bindTexture(e.TEXTURE_2D, n), e.texImage2D(e.TEXTURE_2D, 0, t.internalFormatFloat, 1, 1, 0, t.textureFormatFloat, t.textureTypeFloat, null);
1405
+ let r = e.createFramebuffer();
1406
+ e.bindFramebuffer(e.FRAMEBUFFER, r), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, n, 0);
1407
+ let i = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
1408
+ return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(n), e.deleteFramebuffer(r), i;
1409
+ }
1410
+ function bt(e, t) {
1411
+ let n = B(e, t), r = e.createTexture();
1412
+ e.bindTexture(e.TEXTURE_2D, r), e.texImage2D(e.TEXTURE_2D, 0, n.internalFormatHalfFloat, 1, 1, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null);
1413
+ let i = e.createFramebuffer();
1414
+ e.bindFramebuffer(e.FRAMEBUFFER, i), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0);
1415
+ let a = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
1416
+ return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(i), a;
1417
+ }
1418
+ function xt(e) {
1419
+ return e === 2 ? F(e).fenceSync != null : !1;
1420
+ }
1421
+ function St(e, t) {
1422
+ Array.isArray(e) || (e = [e]), e.forEach((e) => {
1423
+ e != null && r(e.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGL backend.`);
1424
+ });
1425
+ }
1426
+ //#endregion
1427
1427
  //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/gpgpu_math.js
1428
1428
  function Ct(e, n, r, i) {
1429
1429
  let a = r.map((e, t) => {
@@ -1444,7 +1444,7 @@ function Ct(e, n, r, i) {
1444
1444
  isUniform: !1,
1445
1445
  isPacked: i.texData.isPacked,
1446
1446
  flatOffset: null
1447
- }, c = He(a, s, n), l = ce(e.gl, c), u = e.createProgram(l);
1447
+ }, c = b(a, s, n), l = Ke(e.gl, c), u = e.createProgram(l);
1448
1448
  return t().get("ENGINE_COMPILE_ONLY") ? {
1449
1449
  program: n,
1450
1450
  fragmentShader: l,
@@ -1507,7 +1507,7 @@ function wt(e, n, r, a, o) {
1507
1507
  for (let t = 0; t < r.length; ++t) {
1508
1508
  let i = r[t], { uniform: a, offset: o, shape: c, texShape: l } = n.variablesLocations[t];
1509
1509
  if (c) {
1510
- let { uniformShape: t } = Y(n.program.packedInputs, i.shape, i.texData.texShape);
1510
+ let { uniformShape: t } = A(n.program.packedInputs, i.shape, i.texData.texShape);
1511
1511
  switch (t.length) {
1512
1512
  case 1:
1513
1513
  e.gl.uniform1iv(c, new Int32Array(t));
@@ -1586,7 +1586,7 @@ function Tt(r, a, o) {
1586
1586
  a.concat(o).forEach((t) => {
1587
1587
  let a = t.texData != null && t.texData.slice != null && t.texData.slice.flatOffset > 0;
1588
1588
  if (r.enableShapeUniforms && !t.isUniform) {
1589
- let l = t.texData.texShape, { useSqueezeShape: u, uniformShape: d, keptDims: f } = Y(r.packedInputs, t.shape, l), p = "", m = "", h = "";
1589
+ let l = t.texData.texShape, { useSqueezeShape: u, uniformShape: d, keptDims: f } = A(r.packedInputs, t.shape, l), p = "", m = "", h = "";
1590
1590
  if (d.length === 1 && r.packedInputs) {
1591
1591
  let e = [Math.ceil(l[0] / 2), Math.ceil(l[1] / 2)];
1592
1592
  p = `${e[0] > 1}_${e[1] > 1}`;
@@ -1609,4 +1609,4 @@ function Et(e) {
1609
1609
  return t().getBool("WEBGL_USE_SHAPES_UNIFORMS") && e <= 4;
1610
1610
  }
1611
1611
  //#endregion
1612
- export { C as $, be as A, Fe as B, pe as C, oe as D, j as E, Oe as F, O as G, de as H, I, _ as J, fe as K, Me as L, Te as M, Ee as N, ke as O, Ae as P, S as Q, Ne as R, me as S, se as T, E as U, je as V, D as W, v as X, y as Y, ee as Z, ve as _, Et as a, _e as b, ze as c, Re as d, w as et, B as f, Se as g, Ce as h, wt as i, p as it, M as j, xe as k, Be as l, Ie as m, Q as n, b as nt, J as o, R as p, ge as q, Tt as r, m as rt, Ve as s, Ct as t, x as tt, z as u, T as v, he as w, ue as x, ie as y, De as z };
1612
+ export { g as $, yt as A, I as B, K as C, mt as D, gt as E, U as F, Re as G, L as H, st as I, Fe as J, B as K, ct as L, xt as M, _t as N, X as O, Je as P, v as Q, Ye as R, rt as S, ft as T, Le as U, R as V, z as W, Me as X, F as Y, k as Z, Ge as _, Et as a, ht as b, at as c, He as d, _ as et, et as f, Qe as g, Xe as h, wt as i, d as it, pt as j, vt as k, tt as l, Ze as m, Q as n, h as nt, St as o, qe as p, Ie as q, Tt as r, p as rt, ot as s, Ct as t, f as tt, V as u, G as v, dt as w, it as x, We as y, $e as z };