@margoengine/compute 0.0.0-stage → 0.1.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 (71) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +736 -3
  4. package/dist/array-DbI848Wf.js +166 -0
  5. package/dist/array.d.ts +109 -0
  6. package/dist/autodiff.d.ts +22 -0
  7. package/dist/autodiff.js +143 -0
  8. package/dist/autotune.d.ts +100 -0
  9. package/dist/autotune.js +179 -0
  10. package/dist/compat-YK57ZCbA.js +4 -0
  11. package/dist/compat.d.ts +2 -0
  12. package/dist/context-C75sQQra.js +2470 -0
  13. package/dist/context.d.ts +368 -0
  14. package/dist/cpu-CdVdqP4I.js +871 -0
  15. package/dist/cpu-kernel.wasm +0 -0
  16. package/dist/cpu-load-aTmfphVu.js +5 -0
  17. package/dist/cpu-load.d.ts +3 -0
  18. package/dist/cpu-runtime.d.ts +8 -0
  19. package/dist/cpu-wasm.d.ts +42 -0
  20. package/dist/cpu-wasm.js +161 -0
  21. package/dist/cpu.d.ts +138 -0
  22. package/dist/decomp-kernel.wasm +0 -0
  23. package/dist/decomp.d.ts +42 -0
  24. package/dist/decomp.js +158 -0
  25. package/dist/distance.d.ts +85 -0
  26. package/dist/distance.js +256 -0
  27. package/dist/dtype.d.ts +36 -0
  28. package/dist/errors-CDgOgzCd.js +7 -0
  29. package/dist/expr-DwFen60A.js +995 -0
  30. package/dist/expr.d.ts +196 -0
  31. package/dist/fft.d.ts +33 -0
  32. package/dist/fft.js +168 -0
  33. package/dist/frame.d.ts +63 -0
  34. package/dist/frame.js +82 -0
  35. package/dist/graph.d.ts +75 -0
  36. package/dist/graph.js +174 -0
  37. package/dist/histogram.d.ts +17 -0
  38. package/dist/index.d.ts +17 -0
  39. package/dist/index.js +4 -0
  40. package/dist/kernel.d.ts +65 -0
  41. package/dist/linalg.d.ts +21 -0
  42. package/dist/linalg.js +149 -0
  43. package/dist/nn-extra.d.ts +130 -0
  44. package/dist/nn-extra.js +322 -0
  45. package/dist/nn.d.ts +385 -0
  46. package/dist/nn.js +704 -0
  47. package/dist/onnx-kernel.wasm +0 -0
  48. package/dist/onnx.d.ts +164 -0
  49. package/dist/onnx.js +817 -0
  50. package/dist/quant.d.ts +59 -0
  51. package/dist/quant.js +242 -0
  52. package/dist/random.d.ts +64 -0
  53. package/dist/random.js +150 -0
  54. package/dist/reduce.d.ts +34 -0
  55. package/dist/scan.d.ts +26 -0
  56. package/dist/select.d.ts +38 -0
  57. package/dist/shaders.d.ts +80 -0
  58. package/dist/shape.d.ts +23 -0
  59. package/dist/shape.js +134 -0
  60. package/dist/signal.d.ts +29 -0
  61. package/dist/signal.js +178 -0
  62. package/dist/sort.d.ts +38 -0
  63. package/dist/sparse.d.ts +136 -0
  64. package/dist/sparse.js +273 -0
  65. package/dist/stream.d.ts +39 -0
  66. package/dist/stream.js +100 -0
  67. package/dist/subgroups.d.ts +27 -0
  68. package/dist/subgroups.js +191 -0
  69. package/dist/usingCtx-igdMnAhr.js +57 -0
  70. package/dist/wgsl.d.ts +68 -0
  71. package/package.json +144 -6
@@ -0,0 +1,322 @@
1
+ import { n as e, r as t } from "./errors-CDgOgzCd.js";
2
+ import { a as n } from "./expr-DwFen60A.js";
3
+ import { Random as r } from "./random.js";
4
+ import { Module as i, Tensor as a, dropout as o, parameter as s } from "./nn.js";
5
+ import { concatenate as c, pad as l } from "./shape.js";
6
+ //#region src/nn-extra.ts
7
+ var u = (e) => e.reduce((e, t) => e * t, 1), d = (t, n) => {
8
+ if (!Number.isInteger(t) || t < 1) throw e(`${n} must be a positive integer; choose at least 1`, "compute");
9
+ return t;
10
+ }, f = (t, n, r = 0) => {
11
+ let i = typeof t == "number" ? [t, t] : t;
12
+ if (i.length !== 2 || i.some((e) => !Number.isInteger(e) || e < r)) throw e(`${n} needs two integers >= ${r}; choose valid dimensions`, "compute");
13
+ return i;
14
+ }, p = (e) => new a(e, !1, !1);
15
+ function m(e, t, n, r) {
16
+ let i = e.shape.map(() => null);
17
+ return i[t] = [n, n + r], a.made(e, e.value.slice(...i).eval(), [e], (i) => {
18
+ let o = e.shape.map((i, a) => a === t ? [n, e.shape[a] - n - r] : [0, 0]);
19
+ a.give(e, l(i, o));
20
+ });
21
+ }
22
+ function h(t, n) {
23
+ if (!t.length) throw e("Concatenation needs at least one tensor; supply inputs", "compute");
24
+ if (t.length === 1) return t[0];
25
+ let r = c(t.map((e) => e.value), n);
26
+ return a.made(t[0], r, t, (e) => {
27
+ let r = 0;
28
+ for (let i of t) {
29
+ let t = i.shape.map(() => null);
30
+ t[n] = [r, r + i.shape[n]], a.give(i, e.slice(...t).eval()), r += i.shape[n];
31
+ }
32
+ });
33
+ }
34
+ function g(e, t, r, i, o = !1) {
35
+ let s = e.context, c = s.array(t, { shape: r }), l = e.shape[0], u = e.shape[1], d = s.arange(0, l, 1, "i32"), f = d.reshape(l, ...r.map(() => 1)).mul(u).add(c).eval(), p = i ? s.array(i, { shape: r }) : void 0;
36
+ d.dispose();
37
+ let m = s.take(e.value, c, { axis: 1 }), h = p ? o ? n(p, m, 0).eval() : m.mul(p).eval() : m;
38
+ return p && m.dispose(), a.made(e, h, [e], (t) => {
39
+ let r = s.zeros(e.shape), i = p ? o ? n(p, t, 0).eval() : t.mul(p).eval() : t;
40
+ s.scatter(r, f, i, { op: "add" }), p && i.dispose(), a.give(e, r);
41
+ }, [
42
+ c,
43
+ f,
44
+ ...p ? [p] : []
45
+ ]);
46
+ }
47
+ function _(e, r, i) {
48
+ if (r.context !== i.context) throw t("Recurrent states must use the input context; move the state first", "compute");
49
+ return a.made(r, n(e, r.value, i.value).eval(), [r, i], (t) => {
50
+ a.take(r, n(e, t, 0)), a.take(i, n(e, 0, t));
51
+ });
52
+ }
53
+ var v = (t) => {
54
+ if (!(t > 0 && Number.isFinite(t))) throw e("Normalization eps must be finite and positive; choose e.g. 1e-5", "compute");
55
+ return t;
56
+ }, y = class extends i {
57
+ #e;
58
+ #t;
59
+ #n;
60
+ #r;
61
+ #i;
62
+ constructor(t, n, r = {}) {
63
+ if (super(), this.batchesTracked = 0, this.#e = d(n, "channels"), this.#t = v(r.eps ?? 1e-5), this.#n = r.axis ?? 1, this.#r = r.momentum === void 0 ? .1 : r.momentum, this.#r !== null && !(Number.isFinite(this.#r) && this.#r >= 0 && this.#r <= 1)) throw e("BatchNorm momentum must be null or in [0,1]; choose a valid weight", "compute");
64
+ this.#i = r.trackRunningStats ?? !0, this.runningMean = t.zeros(n), this.runningVar = t.ones(n), r.affine !== !1 && (this.weight = s(t.ones(n)), this.bias = s(t.zeros(n)));
65
+ }
66
+ forward(t) {
67
+ let n = this.#n < 0 ? this.#n + t.ndim : this.#n;
68
+ if (t.ndim < 2 || n < 0 || n >= t.ndim || !Number.isInteger(n) || t.shape[n] !== this.#e || t.context !== this.runningMean.context) throw e("BatchNorm input must share its context and channel dimension; use the configured axis", "compute");
69
+ let r = t.shape.map((e, t) => t === n ? this.#e : 1), i = [...t.shape.keys()].filter((e) => e !== n), a = i.reduce((e, n) => e * t.shape[n], 1), o;
70
+ if (this.training || !this.#i) {
71
+ if (a <= 1) throw e("BatchNorm training needs more than one value per channel; use eval() or a larger batch", "compute");
72
+ let n = t.mean({
73
+ axis: i,
74
+ keepdims: !0
75
+ }), r = t.sub(n), s = r.mul(r).mean({
76
+ axis: i,
77
+ keepdims: !0
78
+ });
79
+ if (this.#i) {
80
+ let e = this.#r ?? 1 / (this.batchesTracked + 1), r = t.context, i = this.runningMean.mul(1 - e).add(n.value.reshape(this.#e).mul(e)).eval(), o = this.runningVar.mul(1 - e).add(s.value.reshape(this.#e).mul(e * a / (a - 1))).eval();
81
+ r.submit([], [[
82
+ i.storage.buffer,
83
+ 0,
84
+ this.runningMean.storage.buffer,
85
+ 0,
86
+ this.#e * 4
87
+ ], [
88
+ o.storage.buffer,
89
+ 0,
90
+ this.runningVar.storage.buffer,
91
+ 0,
92
+ this.#e * 4
93
+ ]]), i.dispose(), o.dispose(), this.batchesTracked++;
94
+ }
95
+ o = r.mul(s.add(this.#t).rsqrt());
96
+ } else o = t.sub(this.runningMean.reshape(...r)).mul(p(this.runningVar.add(this.#t).rsqrt().eval().transfer(r)));
97
+ return this.weight && (o = o.mul(this.weight.reshape(...r)).add(this.bias.reshape(...r))), o;
98
+ }
99
+ async stateDict(e = {}) {
100
+ let t = { signal: e.signal };
101
+ return {
102
+ ...await super.stateDict(t),
103
+ runningMean: await this.runningMean.read(t),
104
+ runningVar: await this.runningVar.read(t),
105
+ batchesTracked: new Float32Array([this.batchesTracked])
106
+ };
107
+ }
108
+ loadStateDict(t) {
109
+ for (let n of ["runningMean", "runningVar"]) if (t[n]?.length !== this.#e) throw e(`State ${n} needs ${this.#e} values; supply the saved normalization state`, "compute");
110
+ let n = t.batchesTracked?.[0];
111
+ if (!Number.isInteger(n) || n < 0) throw e("State batchesTracked must be a nonnegative integer; supply the saved normalization state", "compute");
112
+ super.loadStateDict(t), this.runningMean.write(t.runningMean), this.runningVar.write(t.runningVar), this.batchesTracked = n;
113
+ }
114
+ release() {
115
+ this.runningMean.dispose(), this.runningVar.dispose();
116
+ }
117
+ }, b = class extends i {
118
+ #e;
119
+ #t;
120
+ #n;
121
+ #r;
122
+ constructor(t, n, r, i = {}) {
123
+ if (super(), this.#e = d(n, "groups"), this.#t = d(r, "channels"), this.#n = v(i.eps ?? 1e-5), this.#r = t, r % n) throw e("GroupNorm channels must be divisible by groups; choose a common divisor", "compute");
124
+ i.affine !== !1 && (this.weight = s(t.ones(r)), this.bias = s(t.zeros(r)));
125
+ }
126
+ forward(t) {
127
+ if (t.ndim < 2 || t.shape[1] !== this.#t || t.context !== this.#r) throw e("GroupNorm needs [batch, channels, ...spatial] in its context; check channels", "compute");
128
+ let n = t.shape[0], r = t.reshape(n, this.#e, this.#t / this.#e, ...t.shape.slice(2)), i = {
129
+ axis: [...r.shape.keys()].slice(2),
130
+ keepdims: !0
131
+ }, a = r.sub(r.mean(i)), o = a.mul(a.mul(a).mean(i).add(this.#n).rsqrt()).reshape(...t.shape), s = [
132
+ 1,
133
+ this.#t,
134
+ ...t.shape.slice(2).map(() => 1)
135
+ ];
136
+ return this.weight && (o = o.mul(this.weight.reshape(...s)).add(this.bias.reshape(...s))), o;
137
+ }
138
+ }, x = class extends i {
139
+ #e;
140
+ #t;
141
+ #n;
142
+ #r;
143
+ #i;
144
+ #a;
145
+ #o;
146
+ #s;
147
+ constructor(t, n, i, a, o = {}) {
148
+ if (super(), this.#e = d(n, "inChannels"), this.#t = d(i, "outChannels"), this.#n = d(o.groups ?? 1, "groups"), n % this.#n || i % this.#n) throw e("Transposed convolution channels must divide into groups; choose a common divisor", "compute");
149
+ if (this.#r = f(a, "kernelSize", 1), this.#i = f(o.stride ?? 1, "stride", 1), this.#a = f(o.padding ?? 0, "padding"), this.#o = f(o.dilation ?? 1, "dilation", 1), this.#s = f(o.outputPadding ?? 0, "outputPadding"), this.#s.some((e, t) => e >= Math.max(this.#i[t], this.#o[t]))) throw e("outputPadding must be less than stride or dilation; choose a smaller value", "compute");
150
+ let c = o.rng ?? new r(t), l = 1 / Math.sqrt(i / this.#n * u(this.#r));
151
+ this.weight = s(c.uniform([
152
+ n,
153
+ i / this.#n,
154
+ ...this.#r
155
+ ], {
156
+ low: -l,
157
+ high: l
158
+ })), o.bias !== !1 && (this.bias = s(c.uniform(i, {
159
+ low: -l,
160
+ high: l
161
+ })));
162
+ }
163
+ forward(e) {
164
+ return this.withOutputSize(e);
165
+ }
166
+ withOutputSize(t, n) {
167
+ if (t.ndim !== 4 || t.shape[1] !== this.#e || t.context !== this.weight.context) throw e("ConvTranspose2d needs [batch, inChannels, h, w] in its context; check input channels", "compute");
168
+ let [r, , i, a] = t.shape, [o, s] = this.#r, [c, l] = this.#i, [u, d] = this.#a, [f, p] = this.#o, _ = [(i - 1) * c - 2 * u + f * (o - 1) + 1, (a - 1) * l - 2 * d + p * (s - 1) + 1], v = n ?? [_[0] + this.#s[0], _[1] + this.#s[1]], [y, b] = v;
169
+ if (!v.every((e, t) => Number.isInteger(e) && e >= Math.max(1, _[t]) && e < _[t] + (n ? this.#i[t] : Math.max(this.#i[t], this.#o[t])))) throw e("Transposed convolution output size is outside its stride range; use the inferred output size", "compute");
170
+ let x = this.#e / this.#n, S = this.#t / this.#n, C = x * o * s, w = [], T = t.reshape(r, this.#e * i * a);
171
+ for (let e = 0; e < this.#n; e++) {
172
+ let t = new Uint32Array(y * b * C), n = new Float32Array(t.length), r = 0;
173
+ for (let m = 0; m < y; m++) for (let h = 0; h < b; h++) for (let g = 0; g < x; g++) for (let _ = 0; _ < o; _++) for (let o = 0; o < s; o++, r++) {
174
+ let s = (m + u - _ * f) / c, v = (h + d - o * p) / l;
175
+ Number.isInteger(s) && Number.isInteger(v) && s >= 0 && s < i && v >= 0 && v < a && (t[r] = ((e * x + g) * i + s) * a + v, n[r] = 1);
176
+ }
177
+ let h = g(T, t, [y * b, C], n, !0), _ = m(this.weight, 0, e * x, x).permute(1, 0, 2, 3).reshape(S, C);
178
+ w.push(h.matmul(_.permute(1, 0)));
179
+ }
180
+ let E = h(w, 2).permute(0, 2, 1).reshape(r, this.#t, y, b);
181
+ return this.bias && (E = E.add(this.bias.reshape(1, this.#t, 1, 1))), E;
182
+ }
183
+ };
184
+ function S(t, n = {}) {
185
+ let r = t.ndim - 2, i = t.shape.slice(2), a = n.mode ?? "nearest";
186
+ if (r < 1 || r > 3 || i.some((e) => e < 1)) throw e("Upsampling needs [batch, channels, 1..3 nonempty spatial axes]; reshape the input", "compute");
187
+ if (![
188
+ "nearest",
189
+ "linear",
190
+ "bilinear",
191
+ "trilinear",
192
+ "bicubic"
193
+ ].includes(a) || a === "bicubic" && r !== 2 || a === "bilinear" && r !== 2 || a === "trilinear" && r !== 3) throw e("Interpolation mode must match the spatial rank; use nearest or linear", "compute");
194
+ if (n.size !== void 0 && n.scaleFactor !== void 0) throw e("Choose either size or scaleFactor for upsampling", "compute");
195
+ let o = (e) => typeof e == "number" ? Array(r).fill(e) : [...e], s = o(n.scaleFactor ?? 2), c = n.size === void 0 ? i.map((e, t) => Math.floor(e * s[t])) : o(n.size);
196
+ if (c.length !== r || c.some((e) => !Number.isSafeInteger(e) || e < 1) || n.size === void 0 && (s.length !== r || s.some((e) => !(Number.isFinite(e) && e > 0)))) throw e("Upsampling sizes/scales must be positive and match spatial rank; supply one per axis", "compute");
197
+ let l = a === "nearest", d = l ? 1 : a === "bicubic" ? 4 : 2, f = d ** r, p = u(c), m = new Uint32Array(p * f), h = new Float32Array(m.length), _ = (e) => {
198
+ let t = -.75, n = Math.abs(e);
199
+ return n <= 1 ? 1.25 * n * n * n - 2.25 * n * n + 1 : n < 2 ? t * n * n * n - 5 * t * n * n + 8 * t * n - 4 * t : 0;
200
+ };
201
+ for (let e = 0; e < p; e++) {
202
+ let t = e, a = Array(r);
203
+ for (let e = r - 1; e >= 0; e--) {
204
+ let r = t % c[e];
205
+ t = Math.floor(t / c[e]), a[e] = l ? Math.floor(r * i[e] / c[e]) : n.alignCorners ? c[e] === 1 ? 0 : r * (i[e] - 1) / (c[e] - 1) : (r + .5) * i[e] / c[e] - .5;
206
+ }
207
+ for (let t = 0; t < f; t++) {
208
+ let n = t, o = 0, s = 1;
209
+ for (let e = r - 1, t = 1; e >= 0; t *= i[e--]) {
210
+ let r = n % d;
211
+ n = Math.floor(n / d);
212
+ let c = Math.floor(a[e]), u = l ? c : c + r - +(d === 4);
213
+ l || (s *= d === 4 ? _(a[e] - u) : r === 0 ? 1 - (a[e] - c) : a[e] - c), o += Math.min(i[e] - 1, Math.max(0, u)) * t;
214
+ }
215
+ m[e * f + t] = o, h[e * f + t] = s;
216
+ }
217
+ }
218
+ return g(t.reshape(t.shape[0] * t.shape[1], u(i)), m, [p, f], l ? void 0 : h).sum({ axis: 2 }).reshape(t.shape[0], t.shape[1], ...c);
219
+ }
220
+ var C = class extends i {
221
+ #e;
222
+ constructor(e = {}) {
223
+ super(), this.#e = {
224
+ ...e,
225
+ size: Array.isArray(e.size) ? [...e.size] : e.size,
226
+ scaleFactor: Array.isArray(e.scaleFactor) ? [...e.scaleFactor] : e.scaleFactor
227
+ };
228
+ }
229
+ forward(e) {
230
+ return S(e, this.#e);
231
+ }
232
+ }, w = class extends i {
233
+ constructor(e, t, n, r, i, a) {
234
+ super();
235
+ let o = 1 / Math.sqrt(n), c = (e) => s(a.uniform(e, {
236
+ low: -o,
237
+ high: o
238
+ }));
239
+ this.weightIH = c([r * n, t]), this.weightHH = c([r * n, n]), i && (this.biasIH = c(r * n), this.biasHH = c(r * n));
240
+ }
241
+ forward(e) {
242
+ return e.matmul(this.weightIH.permute(1, 0));
243
+ }
244
+ }, T = class extends i {
245
+ #e;
246
+ #t;
247
+ #n;
248
+ #r;
249
+ #i;
250
+ #a;
251
+ #o;
252
+ #s;
253
+ constructor(t, n, i, a, o) {
254
+ if (super(), this.cells = [], this.#e = d(n, "inputSize"), this.#t = d(i, "hiddenSize"), this.#n = d(a.numLayers ?? 1, "numLayers"), this.#r = a.bidirectional ? 2 : 1, this.#i = a.batchFirst ?? !1, this.#a = a.dropout ?? 0, this.#o = o, this.#s = a.rng ?? new r(t), !(this.#a >= 0 && this.#a < 1)) throw e("Recurrent dropout must be in [0,1); choose a valid probability", "compute");
255
+ for (let e = 0; e < this.#n; e++) for (let r = 0; r < this.#r; r++) this.cells.push(new w(t, e === 0 ? n : i * this.#r, i, o ? 4 : 3, a.bias !== !1, this.#s));
256
+ }
257
+ forward(e) {
258
+ let t = this.run(e);
259
+ return e.shape[+!!this.#i] === 0 ? (t.h.dispose(), t.c?.dispose()) : (t.h.value.dispose(), t.c?.value.dispose()), t.output;
260
+ }
261
+ run(n, r = {}) {
262
+ let i = this.#i ? n.permute(1, 0, 2) : n;
263
+ if (i.ndim !== 3 || i.shape[2] !== this.#e || i.context !== this.cells[0].weightIH.context) throw e("Recurrent input needs [time,batch,inputSize] in its context; check batchFirst and features", "compute");
264
+ let [s, c] = i.shape, l = this.#t, u = [
265
+ this.#n * this.#r,
266
+ c,
267
+ l
268
+ ], d = i.context;
269
+ for (let t of [r.h, r.c]) if (t && (t.context !== d || t.shape.length !== 3 || t.shape.some((e, t) => e !== u[t]))) throw e("Initial recurrent states need [layers*directions,batch,hidden]; use the layer state shape", "compute");
270
+ if (!this.#o && r.c) throw t("GRU has no cell state; pass only h", "compute");
271
+ if (r.lengths && (r.lengths.length !== c || r.lengths.some((e) => !Number.isInteger(e) || e < 0 || e > s))) throw e("Sequence lengths need one integer in [0,time] per batch item; supply valid lengths", "compute");
272
+ let f = r.h ?? p(d.zeros(u)), g = this.#o ? r.c ?? p(d.zeros(u)) : void 0, v = [], y = [], b = i;
273
+ for (let e = 0; e < this.#n; e++) {
274
+ let t = [];
275
+ for (let n = 0; n < this.#r; n++) {
276
+ let i = e * this.#r + n, o = this.cells[i], u = Array(s), x = m(f, 0, i, 1).reshape(c, l), S = g ? m(g, 0, i, 1).reshape(c, l) : void 0;
277
+ for (let e = 0; e < s; e++) {
278
+ let t = n === 0 ? e : s - 1 - e, i = m(b, 0, t, 1).reshape(c, b.shape[2]).matmul(o.weightIH.permute(1, 0)), f = x.matmul(o.weightHH.permute(1, 0));
279
+ o.biasIH && (i = i.add(o.biasIH)), o.biasHH && (f = f.add(o.biasHH));
280
+ let h, g;
281
+ if (this.#o) {
282
+ let e = i.add(f), t = m(e, 1, 0, l).sigmoid(), n = m(e, 1, l, l).sigmoid(), r = m(e, 1, 2 * l, l).tanh(), a = m(e, 1, 3 * l, l).sigmoid();
283
+ g = n.mul(S).add(t.mul(r)), h = a.mul(g.tanh());
284
+ } else {
285
+ let e = m(i, 1, 0, l).add(m(f, 1, 0, l)).sigmoid(), t = m(i, 1, l, l).add(m(f, 1, l, l)).sigmoid();
286
+ h = m(i, 1, 2 * l, l).add(e.mul(m(f, 1, 2 * l, l))).tanh().mul(t.mul(-1).add(1)).add(t.mul(x));
287
+ }
288
+ if (r.lengths) {
289
+ let e = d.array(r.lengths.map((e) => +(t < e)), {
290
+ shape: [c, 1],
291
+ dtype: "u32"
292
+ });
293
+ x = _(e, h, x), g && (S = _(e, g, S));
294
+ let n = _(e, x, p(d.zeros([c, l])));
295
+ u[t] = a.made(n, n.value.eval(), [n], (e) => a.give(n, e.eval()), [e]);
296
+ } else x = h, g && (S = g), u[t] = x;
297
+ }
298
+ v.push(x.reshape(1, c, l)), S && y.push(S.reshape(1, c, l)), t.push(s ? h(u.map((e) => e.reshape(1, c, l)), 0) : p(d.zeros([
299
+ 0,
300
+ c,
301
+ l
302
+ ])));
303
+ }
304
+ b = h(t, 2), this.training && this.#a && e + 1 < this.#n && (b = o(b, this.#a, this.#s));
305
+ }
306
+ return {
307
+ output: this.#i ? b.permute(1, 0, 2) : b,
308
+ h: h(v, 0),
309
+ c: this.#o ? h(y, 0) : void 0
310
+ };
311
+ }
312
+ }, E = class extends T {
313
+ constructor(e, t, n, r = {}) {
314
+ super(e, t, n, r, !0);
315
+ }
316
+ }, D = class extends T {
317
+ constructor(e, t, n, r = {}) {
318
+ super(e, t, n, r, !1);
319
+ }
320
+ };
321
+ //#endregion
322
+ export { y as BatchNorm, x as ConvTranspose2d, D as GRU, b as GroupNorm, E as LSTM, C as Upsample, S as upsample };