@genai-fi/nanogpt 0.6.0 → 0.6.1
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.
- package/dist/Generator.js +7 -7
- package/dist/NanoGPTModel.js +70 -121
- package/dist/RealDiv-7xu-pkZN.js +540 -0
- package/dist/Reshape-BYC1oUku.js +127 -0
- package/dist/TeachableLLM.d.ts +2 -0
- package/dist/TeachableLLM.js +34 -27
- package/dist/{TiedEmbedding-BhxWO8QR.js → TiedEmbedding-C1HBot-5.js} +12 -13
- package/dist/{axis_util-D17qZRQm.js → axis_util-CCNL7jea.js} +14 -12
- package/dist/{broadcast_to-BMQLjvt_.js → broadcast_to-CddAF879.js} +2 -2
- package/dist/{concat-DhZfF1GY.js → concat-XOK9ANZu.js} +7 -7
- package/dist/{dataset-oilnemHf.js → dataset-BFFipD1c.js} +5 -5
- package/dist/{dropout-CrMQPCeG.js → dropout-xlKRoJyU.js} +9 -9
- package/dist/{gather-DZCMHZuN.js → gather-DKtUaTtA.js} +1 -1
- package/dist/gpgpu_math-B_ycgZ4W.js +3115 -0
- package/dist/{index-bMBtI-WR.js → index-CamYe_M8.js} +843 -646
- package/dist/{kernel_funcs_utils-CNmjLWnB.js → kernel_funcs_utils-D5MS0JFg.js} +232 -138
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +13 -33
- package/dist/layers/TiedEmbedding.js +6 -7
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/{log_sum_exp-BHdkCb4s.js → log_sum_exp-CV_5-TTu.js} +15 -15
- package/dist/main.js +23 -20
- package/dist/{mat_mul-BsrLfy81.js → mat_mul-CAbRFWUj.js} +4 -4
- package/dist/{max-DechV4Bc.js → max-JBBv7aUf.js} +3 -3
- package/dist/mulmat_packed_gpu-DW4doKL_.js +71 -0
- package/dist/{norm-B9hWHZH1.js → norm-B9dQTFYn.js} +12 -12
- package/dist/{ones-g0K8jVwm.js → ones-CMHNqMr6.js} +2 -2
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +5 -5
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +1 -1
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +18 -49
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +1 -1
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +1 -1
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/node/sparseCrossEntropy.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +8 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +29 -560
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMulGelu.js +48 -115
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/{ops-Mv7Ta72x.js → ops-DqtYemmV.js} +143 -135
- package/dist/{random_width-BBAWzDym.js → random_width-CLMQG5Jn.js} +6925 -6291
- package/dist/{range-DMaG9A3G.js → range-DqYjKnuG.js} +1 -1
- package/dist/{gpgpu_math-Ctc31slO.js → reciprocal-z49filta.js} +7 -5
- package/dist/register_all_kernels-COt6wLD0.js +21397 -0
- package/dist/{reshape-T4yDEqoF.js → reshape-C45vIIRU.js} +1 -1
- package/dist/scatter_nd_util-qgtnviTE.js +46 -0
- package/dist/selu_util-4QV_GXTB.js +740 -0
- package/dist/{shared-XNAoXhOa.js → shared-ByfrGA97.js} +1462 -1089
- package/dist/{sin-EEhbrRO_.js → sin-9JBrfVaB.js} +1 -1
- package/dist/{softmax-B2_IKPDR.js → softmax-DvMvui-_.js} +1 -1
- package/dist/{split-dcks18H1.js → split-DxrHrPFK.js} +4 -4
- package/dist/{stack-lpJ5kYvE.js → stack-DgaoDmnF.js} +1 -1
- package/dist/{sum-CutF5lj2.js → sum-BpcpxNEh.js} +3 -3
- package/dist/{tensor-C15NA2LA.js → tensor-CDz5x1mP.js} +1 -1
- package/dist/{tensor2d-DZ_e5eKM.js → tensor2d-jO8JY5Jd.js} +1 -1
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +3 -3
- package/dist/training/sparseCrossEntropy.js +4 -4
- package/dist/utilities/dummy.d.ts +6 -0
- package/dist/utilities/dummy.js +31 -10
- package/dist/utilities/generate.js +3 -3
- package/dist/utilities/load.js +1 -1
- package/dist/utilities/profile.d.ts +5 -0
- package/dist/utilities/profile.js +10 -7
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-CdRKKp8x.js → variable-CLVXjN7F.js} +1 -1
- package/dist/{zeros-CAbHfODe.js → zeros-DUkkVccu.js} +8 -8
- package/package.json +3 -9
- package/dist/Reshape-CLOrdpve.js +0 -212
- package/dist/slice_util-Ddk0uxGJ.js +0 -49
- package/dist/tfjs_backend-BDb8r9qx.js +0 -1010
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
import { k as N, ao as H, q as _, w as S, E as L, ap as te, aq as ne, al as se, an as re, ar as ie, as as oe, at as le, b as ue, au as fe, av as O } from "./index-CamYe_M8.js";
|
|
2
|
+
import { r as ce } from "./reshape-C45vIIRU.js";
|
|
3
|
+
import { s as ae } from "./sum-BpcpxNEh.js";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
* =============================================================================
|
|
19
|
+
*/
|
|
20
|
+
function Xe(e, t, n, s, r = "NHWC", u) {
|
|
21
|
+
const i = e[3], o = [...t, i], c = Ae(r);
|
|
22
|
+
return X(e, o, n, u, s, null, null, c);
|
|
23
|
+
}
|
|
24
|
+
function Be(e, t, n, s, r, u, i = "channelsLast") {
|
|
25
|
+
const [o, c] = T(t);
|
|
26
|
+
let a;
|
|
27
|
+
if (i === "channelsLast")
|
|
28
|
+
a = [o, c, e[3], e[3]];
|
|
29
|
+
else if (i === "channelsFirst")
|
|
30
|
+
a = [o, c, e[1], e[1]];
|
|
31
|
+
else
|
|
32
|
+
throw new Error(`Unknown dataFormat ${i}`);
|
|
33
|
+
return X(e, a, n, s, r, u, !1, i);
|
|
34
|
+
}
|
|
35
|
+
function je(e, t, n, s, r, u, i = "NDHWC") {
|
|
36
|
+
const [o, c, a] = W(t);
|
|
37
|
+
let p, g;
|
|
38
|
+
if (i === "NDHWC")
|
|
39
|
+
g = "channelsLast", p = [o, c, a, e[4], e[4]];
|
|
40
|
+
else if (i === "NCDHW")
|
|
41
|
+
g = "channelsFirst", p = [o, c, a, e[1], e[1]];
|
|
42
|
+
else
|
|
43
|
+
throw new Error(`Unknown dataFormat ${i}`);
|
|
44
|
+
return he(e, p, n, s, r, !1, g, u);
|
|
45
|
+
}
|
|
46
|
+
function X(e, t, n, s, r, u, i = !1, o = "channelsLast") {
|
|
47
|
+
let [c, a, p, g] = [-1, -1, -1, -1];
|
|
48
|
+
if (o === "channelsLast")
|
|
49
|
+
[c, a, p, g] = e;
|
|
50
|
+
else if (o === "channelsFirst")
|
|
51
|
+
[c, g, a, p] = e;
|
|
52
|
+
else
|
|
53
|
+
throw new Error(`Unknown dataFormat ${o}`);
|
|
54
|
+
const [l, h, , d] = t, [A, m] = T(n), [b, M] = T(s), f = G(l, b), w = G(h, M), { padInfo: E, outHeight: I, outWidth: x } = de(r, a, p, A, m, f, w, u, o), y = i ? d * g : d;
|
|
55
|
+
let $;
|
|
56
|
+
return o === "channelsFirst" ? $ = [c, y, I, x] : o === "channelsLast" && ($ = [c, I, x, y]), {
|
|
57
|
+
batchSize: c,
|
|
58
|
+
dataFormat: o,
|
|
59
|
+
inHeight: a,
|
|
60
|
+
inWidth: p,
|
|
61
|
+
inChannels: g,
|
|
62
|
+
outHeight: I,
|
|
63
|
+
outWidth: x,
|
|
64
|
+
outChannels: y,
|
|
65
|
+
padInfo: E,
|
|
66
|
+
strideHeight: A,
|
|
67
|
+
strideWidth: m,
|
|
68
|
+
filterHeight: l,
|
|
69
|
+
filterWidth: h,
|
|
70
|
+
effectiveFilterHeight: f,
|
|
71
|
+
effectiveFilterWidth: w,
|
|
72
|
+
dilationHeight: b,
|
|
73
|
+
dilationWidth: M,
|
|
74
|
+
inShape: e,
|
|
75
|
+
outShape: $,
|
|
76
|
+
filterShape: t
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function he(e, t, n, s, r, u = !1, i = "channelsLast", o) {
|
|
80
|
+
let [c, a, p, g, l] = [-1, -1, -1, -1, -1];
|
|
81
|
+
if (i === "channelsLast")
|
|
82
|
+
[c, a, p, g, l] = e;
|
|
83
|
+
else if (i === "channelsFirst")
|
|
84
|
+
[c, l, a, p, g] = e;
|
|
85
|
+
else
|
|
86
|
+
throw new Error(`Unknown dataFormat ${i}`);
|
|
87
|
+
const [h, d, A, , m] = t, [b, M, f] = W(n), [w, E, I] = W(s), x = G(h, w), y = G(d, E), $ = G(A, I), { padInfo: C, outDepth: k, outHeight: D, outWidth: F } = me(r, a, p, g, b, M, f, x, y, $, o), V = u ? m * l : m;
|
|
88
|
+
let U;
|
|
89
|
+
return i === "channelsFirst" ? U = [c, V, k, D, F] : i === "channelsLast" && (U = [c, k, D, F, V]), {
|
|
90
|
+
batchSize: c,
|
|
91
|
+
dataFormat: i,
|
|
92
|
+
inDepth: a,
|
|
93
|
+
inHeight: p,
|
|
94
|
+
inWidth: g,
|
|
95
|
+
inChannels: l,
|
|
96
|
+
outDepth: k,
|
|
97
|
+
outHeight: D,
|
|
98
|
+
outWidth: F,
|
|
99
|
+
outChannels: V,
|
|
100
|
+
padInfo: C,
|
|
101
|
+
strideDepth: b,
|
|
102
|
+
strideHeight: M,
|
|
103
|
+
strideWidth: f,
|
|
104
|
+
filterDepth: h,
|
|
105
|
+
filterHeight: d,
|
|
106
|
+
filterWidth: A,
|
|
107
|
+
effectiveFilterDepth: x,
|
|
108
|
+
effectiveFilterHeight: y,
|
|
109
|
+
effectiveFilterWidth: $,
|
|
110
|
+
dilationDepth: w,
|
|
111
|
+
dilationHeight: E,
|
|
112
|
+
dilationWidth: I,
|
|
113
|
+
inShape: e,
|
|
114
|
+
outShape: U,
|
|
115
|
+
filterShape: t
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function ge(e, t, n, s, r) {
|
|
119
|
+
s == null && (s = B(e, t, n));
|
|
120
|
+
const u = e[0], i = e[1], o = R((u - t + 2 * s) / n + 1, r), c = R((i - t + 2 * s) / n + 1, r);
|
|
121
|
+
return [o, c];
|
|
122
|
+
}
|
|
123
|
+
function pe(e, t, n, s, r, u) {
|
|
124
|
+
r == null && (r = B(e, t[0], s[0]));
|
|
125
|
+
const i = [0, 0, 0, n];
|
|
126
|
+
for (let o = 0; o < 3; o++)
|
|
127
|
+
e[o] + 2 * r >= t[o] && (i[o] = R((e[o] - t[o] + 2 * r) / s[o] + 1, u));
|
|
128
|
+
return i;
|
|
129
|
+
}
|
|
130
|
+
function B(e, t, n, s = 1) {
|
|
131
|
+
const r = G(t, s);
|
|
132
|
+
return Math.floor((e[0] * (n - 1) - n + r) / 2);
|
|
133
|
+
}
|
|
134
|
+
function T(e) {
|
|
135
|
+
return typeof e == "number" ? [e, e, e] : e.length === 2 ? [e[0], e[1], 1] : e;
|
|
136
|
+
}
|
|
137
|
+
function W(e) {
|
|
138
|
+
return typeof e == "number" ? [e, e, e] : e;
|
|
139
|
+
}
|
|
140
|
+
function G(e, t) {
|
|
141
|
+
return t <= 1 ? e : e + (e - 1) * (t - 1);
|
|
142
|
+
}
|
|
143
|
+
function de(e, t, n, s, r, u, i, o, c) {
|
|
144
|
+
let a, p, g;
|
|
145
|
+
if (typeof e == "number") {
|
|
146
|
+
a = { top: e, bottom: e, left: e, right: e, type: e === 0 ? "VALID" : "NUMBER" };
|
|
147
|
+
const h = ge([t, n], u, s, e, o);
|
|
148
|
+
p = h[0], g = h[1];
|
|
149
|
+
} else if (e === "same") {
|
|
150
|
+
p = Math.ceil(t / s), g = Math.ceil(n / r);
|
|
151
|
+
const l = Math.max(0, (p - 1) * s + u - t), h = Math.max(0, (g - 1) * r + i - n), d = Math.floor(l / 2), A = l - d, m = Math.floor(h / 2), b = h - m;
|
|
152
|
+
a = { top: d, bottom: A, left: m, right: b, type: "SAME" };
|
|
153
|
+
} else if (e === "valid")
|
|
154
|
+
a = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, p = Math.ceil((t - u + 1) / s), g = Math.ceil((n - i + 1) / r);
|
|
155
|
+
else if (typeof e == "object") {
|
|
156
|
+
const l = c === "channelsLast" ? e[1][0] : e[2][0], h = c === "channelsLast" ? e[1][1] : e[2][1], d = c === "channelsLast" ? e[2][0] : e[3][0], A = c === "channelsLast" ? e[2][1] : e[3][1];
|
|
157
|
+
a = { top: l, bottom: h, left: d, right: A, type: l === 0 && h === 0 && d === 0 && A === 0 ? "VALID" : "EXPLICIT" }, p = R((t - u + l + h) / s + 1, o), g = R((n - i + d + A) / r + 1, o);
|
|
158
|
+
} else
|
|
159
|
+
throw Error(`Unknown padding parameter: ${e}`);
|
|
160
|
+
return { padInfo: a, outHeight: p, outWidth: g };
|
|
161
|
+
}
|
|
162
|
+
function me(e, t, n, s, r, u, i, o, c, a, p) {
|
|
163
|
+
let g, l, h, d;
|
|
164
|
+
if (e === "valid" && (e = 0), typeof e == "number") {
|
|
165
|
+
g = {
|
|
166
|
+
top: e,
|
|
167
|
+
bottom: e,
|
|
168
|
+
left: e,
|
|
169
|
+
right: e,
|
|
170
|
+
front: e,
|
|
171
|
+
back: e,
|
|
172
|
+
type: e === 0 ? "VALID" : "NUMBER"
|
|
173
|
+
};
|
|
174
|
+
const m = pe([t, n, s, 1], [o, c, a], 1, [r, u, i], e, p);
|
|
175
|
+
l = m[0], h = m[1], d = m[2];
|
|
176
|
+
} else if (e === "same") {
|
|
177
|
+
l = Math.ceil(t / r), h = Math.ceil(n / u), d = Math.ceil(s / i);
|
|
178
|
+
const A = (l - 1) * r + o - t, m = (h - 1) * u + c - n, b = (d - 1) * i + a - s, M = Math.floor(A / 2), f = A - M, w = Math.floor(m / 2), E = m - w, I = Math.floor(b / 2), x = b - I;
|
|
179
|
+
g = { top: w, bottom: E, left: I, right: x, front: M, back: f, type: "SAME" };
|
|
180
|
+
} else
|
|
181
|
+
throw Error(`Unknown padding parameter: ${e}`);
|
|
182
|
+
return { padInfo: g, outDepth: l, outHeight: h, outWidth: d };
|
|
183
|
+
}
|
|
184
|
+
function R(e, t) {
|
|
185
|
+
if (!t)
|
|
186
|
+
return Math.trunc(e);
|
|
187
|
+
switch (t) {
|
|
188
|
+
case "round":
|
|
189
|
+
return Math.round(e);
|
|
190
|
+
case "ceil":
|
|
191
|
+
return Math.ceil(e);
|
|
192
|
+
case "floor":
|
|
193
|
+
return Math.floor(e);
|
|
194
|
+
default:
|
|
195
|
+
throw new Error(`Unknown roundingMode ${t}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function P(e) {
|
|
199
|
+
const [t, n, s] = T(e);
|
|
200
|
+
return t === 1 && n === 1 && s === 1;
|
|
201
|
+
}
|
|
202
|
+
function qe(e, t) {
|
|
203
|
+
return P(e) || P(t);
|
|
204
|
+
}
|
|
205
|
+
function Je(e) {
|
|
206
|
+
return T(e).every((t) => t > 0);
|
|
207
|
+
}
|
|
208
|
+
function Ae(e) {
|
|
209
|
+
if (e === "NHWC")
|
|
210
|
+
return "channelsLast";
|
|
211
|
+
if (e === "NCHW")
|
|
212
|
+
return "channelsFirst";
|
|
213
|
+
throw new Error(`Unknown dataFormat ${e}`);
|
|
214
|
+
}
|
|
215
|
+
function Qe(e, t, n) {
|
|
216
|
+
if (n != null) {
|
|
217
|
+
if (typeof t == "string")
|
|
218
|
+
throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);
|
|
219
|
+
if (typeof t == "number")
|
|
220
|
+
N(H(t), () => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);
|
|
221
|
+
else if (typeof t == "object")
|
|
222
|
+
t.forEach((s) => {
|
|
223
|
+
s.forEach((r) => {
|
|
224
|
+
N(H(r), () => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${r}.`);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
else
|
|
228
|
+
throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @license
|
|
233
|
+
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
234
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
235
|
+
* you may not use this file except in compliance with the License.
|
|
236
|
+
* You may obtain a copy of the License at
|
|
237
|
+
*
|
|
238
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
239
|
+
*
|
|
240
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
241
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
242
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
243
|
+
* See the License for the specific language governing permissions and
|
|
244
|
+
* limitations under the License.
|
|
245
|
+
* =============================================================================
|
|
246
|
+
*/
|
|
247
|
+
function we(e) {
|
|
248
|
+
const n = { x: S(e, "x", "sigmoid", "float32") };
|
|
249
|
+
return L.runKernel(te, n);
|
|
250
|
+
}
|
|
251
|
+
const Ee = /* @__PURE__ */ _({ sigmoid_: we });
|
|
252
|
+
/**
|
|
253
|
+
* @license
|
|
254
|
+
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
255
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
256
|
+
* you may not use this file except in compliance with the License.
|
|
257
|
+
* You may obtain a copy of the License at
|
|
258
|
+
*
|
|
259
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
260
|
+
*
|
|
261
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
262
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
263
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
264
|
+
* See the License for the specific language governing permissions and
|
|
265
|
+
* limitations under the License.
|
|
266
|
+
* =============================================================================
|
|
267
|
+
*/
|
|
268
|
+
function be(e) {
|
|
269
|
+
const n = { x: S(e, "x", "elu", "float32") };
|
|
270
|
+
return L.runKernel(ne, n);
|
|
271
|
+
}
|
|
272
|
+
const $e = /* @__PURE__ */ _({ elu_: be });
|
|
273
|
+
/**
|
|
274
|
+
* @license
|
|
275
|
+
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
276
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
277
|
+
* you may not use this file except in compliance with the License.
|
|
278
|
+
* You may obtain a copy of the License at
|
|
279
|
+
*
|
|
280
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
281
|
+
*
|
|
282
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
283
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
284
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
285
|
+
* See the License for the specific language governing permissions and
|
|
286
|
+
* limitations under the License.
|
|
287
|
+
* =============================================================================
|
|
288
|
+
*/
|
|
289
|
+
function Ie(e, t = 0.2) {
|
|
290
|
+
const s = { x: S(e, "x", "leakyRelu") }, r = { alpha: t };
|
|
291
|
+
return L.runKernel(se, s, r);
|
|
292
|
+
}
|
|
293
|
+
const xe = /* @__PURE__ */ _({ leakyRelu_: Ie });
|
|
294
|
+
/**
|
|
295
|
+
* @license
|
|
296
|
+
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
297
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
298
|
+
* you may not use this file except in compliance with the License.
|
|
299
|
+
* You may obtain a copy of the License at
|
|
300
|
+
*
|
|
301
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
302
|
+
*
|
|
303
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
304
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
305
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
306
|
+
* See the License for the specific language governing permissions and
|
|
307
|
+
* limitations under the License.
|
|
308
|
+
* =============================================================================
|
|
309
|
+
*/
|
|
310
|
+
function ye(e, t) {
|
|
311
|
+
const n = S(e, "x", "prelu"), s = S(t, "alpha", "prelu"), r = { x: n, alpha: s };
|
|
312
|
+
return L.runKernel(re, r);
|
|
313
|
+
}
|
|
314
|
+
const ke = /* @__PURE__ */ _({ prelu_: ye });
|
|
315
|
+
/**
|
|
316
|
+
* @license
|
|
317
|
+
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
318
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
319
|
+
* you may not use this file except in compliance with the License.
|
|
320
|
+
* You may obtain a copy of the License at
|
|
321
|
+
*
|
|
322
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
323
|
+
*
|
|
324
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
325
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
326
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
327
|
+
* See the License for the specific language governing permissions and
|
|
328
|
+
* limitations under the License.
|
|
329
|
+
* =============================================================================
|
|
330
|
+
*/
|
|
331
|
+
function Me(e) {
|
|
332
|
+
const n = { x: S(e, "x", "relu") };
|
|
333
|
+
return L.runKernel(ie, n);
|
|
334
|
+
}
|
|
335
|
+
const Se = /* @__PURE__ */ _({ relu_: Me });
|
|
336
|
+
/**
|
|
337
|
+
* @license
|
|
338
|
+
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
339
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
340
|
+
* you may not use this file except in compliance with the License.
|
|
341
|
+
* You may obtain a copy of the License at
|
|
342
|
+
*
|
|
343
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
344
|
+
*
|
|
345
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
346
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
347
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
348
|
+
* See the License for the specific language governing permissions and
|
|
349
|
+
* limitations under the License.
|
|
350
|
+
* =============================================================================
|
|
351
|
+
*/
|
|
352
|
+
function De(e) {
|
|
353
|
+
const n = { x: S(e, "x", "relu6") };
|
|
354
|
+
return L.runKernel(oe, n);
|
|
355
|
+
}
|
|
356
|
+
const Ne = /* @__PURE__ */ _({ relu6_: De });
|
|
357
|
+
/**
|
|
358
|
+
* @license
|
|
359
|
+
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
360
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
361
|
+
* you may not use this file except in compliance with the License.
|
|
362
|
+
* You may obtain a copy of the License at
|
|
363
|
+
*
|
|
364
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
365
|
+
*
|
|
366
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
367
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
368
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
369
|
+
* See the License for the specific language governing permissions and
|
|
370
|
+
* limitations under the License.
|
|
371
|
+
* =============================================================================
|
|
372
|
+
*/
|
|
373
|
+
function _e(e, t = 0) {
|
|
374
|
+
const s = { x: S(e, "x", "step") }, r = { alpha: t };
|
|
375
|
+
return L.runKernel(le, s, r);
|
|
376
|
+
}
|
|
377
|
+
const Le = /* @__PURE__ */ _({ step_: _e });
|
|
378
|
+
/**
|
|
379
|
+
* @license
|
|
380
|
+
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
381
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
382
|
+
* you may not use this file except in compliance with the License.
|
|
383
|
+
* You may obtain a copy of the License at
|
|
384
|
+
*
|
|
385
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
386
|
+
*
|
|
387
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
388
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
389
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
390
|
+
* See the License for the specific language governing permissions and
|
|
391
|
+
* limitations under the License.
|
|
392
|
+
* =============================================================================
|
|
393
|
+
*/
|
|
394
|
+
function Ye(e, t, n) {
|
|
395
|
+
if (n == null || n === "linear")
|
|
396
|
+
return e;
|
|
397
|
+
if (n === "relu")
|
|
398
|
+
return ue(e, Le(t));
|
|
399
|
+
throw new Error(`Cannot compute gradient for fused activation ${n}.`);
|
|
400
|
+
}
|
|
401
|
+
function Ze(e, t) {
|
|
402
|
+
let n = t;
|
|
403
|
+
const s = fe(e.shape, t.shape);
|
|
404
|
+
return s.length > 0 && (n = ae(n, s)), ce(n, e.shape);
|
|
405
|
+
}
|
|
406
|
+
function ze(e, t, n, s) {
|
|
407
|
+
if (t === "linear")
|
|
408
|
+
return e;
|
|
409
|
+
if (t === "relu")
|
|
410
|
+
return Se(e);
|
|
411
|
+
if (t === "elu")
|
|
412
|
+
return $e(e);
|
|
413
|
+
if (t === "relu6")
|
|
414
|
+
return Ne(e);
|
|
415
|
+
if (t === "prelu")
|
|
416
|
+
return ke(e, n);
|
|
417
|
+
if (t === "leakyrelu")
|
|
418
|
+
return xe(e, s);
|
|
419
|
+
if (t === "sigmoid")
|
|
420
|
+
return Ee(e);
|
|
421
|
+
throw new Error(`Unknown fused activation ${t}.`);
|
|
422
|
+
}
|
|
423
|
+
const et = (e, t) => !(e > 0) || t === "linear";
|
|
424
|
+
/**
|
|
425
|
+
* @license
|
|
426
|
+
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
427
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
428
|
+
* you may not use this file except in compliance with the License.
|
|
429
|
+
* You may obtain a copy of the License at
|
|
430
|
+
*
|
|
431
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
432
|
+
*
|
|
433
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
434
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
435
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
436
|
+
* See the License for the specific language governing permissions and
|
|
437
|
+
* limitations under the License.
|
|
438
|
+
* =============================================================================
|
|
439
|
+
*/
|
|
440
|
+
const v = -2, Ce = -1;
|
|
441
|
+
function Ge(e, t, n) {
|
|
442
|
+
const s = e.shape.length;
|
|
443
|
+
N(s === t.length, () => `Error in slice${s}D: Length of begin ${t} must match the rank of the array (${s}).`), N(s === n.length, () => `Error in slice${s}D: Length of size ${n} must match the rank of the array (${s}).`);
|
|
444
|
+
for (let r = 0; r < s; ++r)
|
|
445
|
+
N(t[r] + n[r] <= e.shape[r], () => `Error in slice${s}D: begin[${r}] + size[${r}] (${t[r] + n[r]}) would overflow input.shape[${r}] (${e.shape[r]})`);
|
|
446
|
+
}
|
|
447
|
+
function Te(e) {
|
|
448
|
+
const t = [];
|
|
449
|
+
let n = 0;
|
|
450
|
+
for (; e > 0; )
|
|
451
|
+
e & 1 && t.push(n), e /= 2, n++;
|
|
452
|
+
return t;
|
|
453
|
+
}
|
|
454
|
+
function Re(e, t, n) {
|
|
455
|
+
const s = [];
|
|
456
|
+
for (let r = 0; r < e.length; r++)
|
|
457
|
+
s[r] = Math.ceil((t[r] - e[r]) / n[r]);
|
|
458
|
+
return s;
|
|
459
|
+
}
|
|
460
|
+
function j(e, t, n, s) {
|
|
461
|
+
const r = [...e];
|
|
462
|
+
for (let u = r.length; u < s.length; u++)
|
|
463
|
+
r.push(1);
|
|
464
|
+
for (let u = 0; u < n; u++)
|
|
465
|
+
u === 0 ? r[t] = 1 : (r.splice(
|
|
466
|
+
t,
|
|
467
|
+
0,
|
|
468
|
+
1
|
|
469
|
+
/* element to add */
|
|
470
|
+
), r.pop());
|
|
471
|
+
return r;
|
|
472
|
+
}
|
|
473
|
+
function q(e, t, n) {
|
|
474
|
+
return n <= e ? n : n - (t - 1);
|
|
475
|
+
}
|
|
476
|
+
function J(e, t) {
|
|
477
|
+
const n = [];
|
|
478
|
+
for (let s = 0; s < e; s++)
|
|
479
|
+
n.push(t + s);
|
|
480
|
+
return n;
|
|
481
|
+
}
|
|
482
|
+
function Oe(e, t, n, s, r, u, i, o, c) {
|
|
483
|
+
const a = e.length;
|
|
484
|
+
let p = new Array(a), g = new Array(a), l = new Array(a);
|
|
485
|
+
if (t.length && n > 0) {
|
|
486
|
+
const h = t[0], d = n + 1;
|
|
487
|
+
p = Q(i, h, d, s, e), g = Y(o, h, d, r, e), l = j(u, h, d, e);
|
|
488
|
+
} else
|
|
489
|
+
for (let h = 0; h < a; h++)
|
|
490
|
+
p[h] = z(i, s, u, e, h, c), g[h] = ee(o, r, u, e, h, c), l[h] = Z(u, h, c);
|
|
491
|
+
return {
|
|
492
|
+
begin: p,
|
|
493
|
+
end: g,
|
|
494
|
+
strides: l
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function Q(e, t, n, s, r) {
|
|
498
|
+
const u = [...r], i = J(n, t);
|
|
499
|
+
for (let o = 0; o < u.length; o++)
|
|
500
|
+
if (i.indexOf(o) > -1)
|
|
501
|
+
u[o] = 0;
|
|
502
|
+
else {
|
|
503
|
+
const c = q(t, n, o);
|
|
504
|
+
let a = s[c];
|
|
505
|
+
e & 1 << c && (a = 0), u[o] = a;
|
|
506
|
+
}
|
|
507
|
+
return u;
|
|
508
|
+
}
|
|
509
|
+
function Y(e, t, n, s, r) {
|
|
510
|
+
const u = [...r], i = J(n, t);
|
|
511
|
+
for (let o = 0; o < u.length; o++)
|
|
512
|
+
if (i.indexOf(o) > -1)
|
|
513
|
+
u[o] = Number.MAX_SAFE_INTEGER;
|
|
514
|
+
else {
|
|
515
|
+
const c = q(t, n, o);
|
|
516
|
+
let a = s[c];
|
|
517
|
+
e & 1 << c && (a = Number.MAX_SAFE_INTEGER), u[o] = a;
|
|
518
|
+
}
|
|
519
|
+
for (let o = 0; o < u.length; o++) {
|
|
520
|
+
const c = r[o];
|
|
521
|
+
u[o] < 0 && (u[o] += c), u[o] = O(0, u[o], r[o]);
|
|
522
|
+
}
|
|
523
|
+
return u;
|
|
524
|
+
}
|
|
525
|
+
function Z(e, t, n) {
|
|
526
|
+
let s = e[t];
|
|
527
|
+
return (n & 1 << t || s == null) && (s = 1), s;
|
|
528
|
+
}
|
|
529
|
+
function z(e, t, n, s, r, u) {
|
|
530
|
+
let i = t[r];
|
|
531
|
+
const o = n[r] || 1;
|
|
532
|
+
(e & 1 << r || u & 1 << r || i == null) && (o > 0 ? i = Number.MIN_SAFE_INTEGER : i = Number.MAX_SAFE_INTEGER);
|
|
533
|
+
const c = s[r];
|
|
534
|
+
return i < 0 && (i += c), i = O(0, i, c - 1), i;
|
|
535
|
+
}
|
|
536
|
+
function ee(e, t, n, s, r, u) {
|
|
537
|
+
let i = t[r];
|
|
538
|
+
const o = n[r] || 1;
|
|
539
|
+
(e & 1 << r || u & 1 << r || i == null) && (o > 0 ? i = Number.MAX_SAFE_INTEGER : i = Number.MIN_SAFE_INTEGER);
|
|
540
|
+
const c = s[r];
|
|
541
|
+
return i < 0 && (i += c), o > 0 ? i = O(0, i, c) : i = O(-1, i, c - 1), i;
|
|
542
|
+
}
|
|
543
|
+
function Fe(e, t, n) {
|
|
544
|
+
let s = n.length;
|
|
545
|
+
for (let r = 0; r < n.length; r++)
|
|
546
|
+
if (n[r] > 1) {
|
|
547
|
+
s = r;
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
for (let r = s + 1; r < n.length; r++)
|
|
551
|
+
if (t[r] > 0 || n[r] !== e[r])
|
|
552
|
+
return !1;
|
|
553
|
+
return !0;
|
|
554
|
+
}
|
|
555
|
+
function Ve(e, t) {
|
|
556
|
+
let n = e.length > 0 ? e[e.length - 1] : 1;
|
|
557
|
+
for (let s = 0; s < e.length - 1; s++)
|
|
558
|
+
n += e[s] * t[s];
|
|
559
|
+
return n;
|
|
560
|
+
}
|
|
561
|
+
function Ue(e, t, n) {
|
|
562
|
+
let s;
|
|
563
|
+
const r = e.shape.length;
|
|
564
|
+
typeof t == "number" ? s = [t, ...new Array(r - 1).fill(0)] : t.length < r ? s = t.concat(new Array(r - t.length).fill(0)) : s = t.slice(), s.forEach((i) => {
|
|
565
|
+
N(i !== -1, () => "slice() does not support negative begin indexing.");
|
|
566
|
+
});
|
|
567
|
+
let u;
|
|
568
|
+
return n == null ? u = new Array(r).fill(-1) : typeof n == "number" ? u = [n, ...new Array(r - 1).fill(-1)] : n.length < r ? u = n.concat(new Array(r - n.length).fill(-1)) : u = n, u = u.map((i, o) => i >= 0 ? i : (N(i === -1, () => `Negative size values should be exactly -1 but got ${i} for the slice() size at index ${o}.`), e.shape[o] - s[o])), [s, u];
|
|
569
|
+
}
|
|
570
|
+
function We(e, t, n, s, r, u, i, o, c) {
|
|
571
|
+
let a;
|
|
572
|
+
if (s == null ? (a = new Array(t.length), a.fill(1)) : a = s, i != null && (i & i - 1) !== 0)
|
|
573
|
+
throw new Error("Multiple ellipses in slice is not allowed.");
|
|
574
|
+
let p = !1;
|
|
575
|
+
const g = {
|
|
576
|
+
dims: a.length,
|
|
577
|
+
numAddAxisAfterEllipsis: 0,
|
|
578
|
+
begin: t.slice(),
|
|
579
|
+
end: n.slice(),
|
|
580
|
+
strides: a.slice(),
|
|
581
|
+
beginMask: r,
|
|
582
|
+
endMask: u,
|
|
583
|
+
ellipsisMask: i,
|
|
584
|
+
newAxisMask: o,
|
|
585
|
+
shrinkAxisMask: c
|
|
586
|
+
};
|
|
587
|
+
for (let f = 0; f < g.dims; f++)
|
|
588
|
+
p && (1 << f & o) !== 0 && g.numAddAxisAfterEllipsis++, 1 << f & i && (p = !0);
|
|
589
|
+
p || (g.ellipsisMask |= 1 << g.dims, g.dims++);
|
|
590
|
+
const l = {
|
|
591
|
+
dims: e.length,
|
|
592
|
+
beginMask: 0,
|
|
593
|
+
endMask: 0,
|
|
594
|
+
beginValid: !1,
|
|
595
|
+
endValid: !1
|
|
596
|
+
};
|
|
597
|
+
ve(g, l);
|
|
598
|
+
let h = !0, d = !0, A = !0;
|
|
599
|
+
const m = [], b = [];
|
|
600
|
+
for (let f = 0; f < e.length; ++f) {
|
|
601
|
+
if (l.strides[f] === 0)
|
|
602
|
+
throw Error(`strides[${f}] must be non-zero`);
|
|
603
|
+
const w = !!(l.shrinkAxisMask & 1 << f), E = e[f];
|
|
604
|
+
if (E === -1) {
|
|
605
|
+
m.push(w ? 1 : -1);
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
const I = [l.beginMask & 1 << f, l.endMask & 1 << f], x = [
|
|
609
|
+
l.strides[f] > 0 ? 0 : -1,
|
|
610
|
+
l.strides[f] > 0 ? E : E - 1
|
|
611
|
+
];
|
|
612
|
+
if (w && l.strides[f] <= 0)
|
|
613
|
+
throw Error("only stride 1 allowed on non-range indexing.");
|
|
614
|
+
A = A && l.strides[f] === 1;
|
|
615
|
+
const y = !!(l.beginMask & 1 << f && l.endMask & 1 << f);
|
|
616
|
+
if (l.beginValid && l.endValid) {
|
|
617
|
+
if (w) {
|
|
618
|
+
const D = l.begin[f] < 0 ? E + l.begin[f] : l.begin[f];
|
|
619
|
+
if (l.begin[f] = D, l.end[f] = l.begin[f] + 1, D < 0 || D >= E)
|
|
620
|
+
throw Error(`slice index ${l.begin[f]} of dimension ${f} out of bounds.`);
|
|
621
|
+
} else
|
|
622
|
+
l.begin[f] = K(l.begin[f], 0, l.strides[f], E, I, x), l.end[f] = K(l.end[f], 1, l.strides[f], E, I, x);
|
|
623
|
+
const k = l.strides[f] === 1 && l.begin[f] === 0 && l.end[f] === E;
|
|
624
|
+
h = h && k, d = d && (f === 0 && l.strides[f] === 1 || k);
|
|
625
|
+
} else
|
|
626
|
+
h = h && l.strides[f] === 1 && y, d = d && (f === 0 && l.strides[f] === 1 || y);
|
|
627
|
+
let $, C = !1;
|
|
628
|
+
if (l.beginValid && l.endValid ? ($ = l.end[f] - l.begin[f], C = !0) : w ? ($ = 1, C = !0) : y && E >= 0 && (l.strides[f] < 0 ? $ = -E : $ = E, C = !0), C) {
|
|
629
|
+
let k;
|
|
630
|
+
$ === 0 || $ < 0 != l.strides[f] < 0 ? k = 0 : k = Math.trunc($ / l.strides[f]) + ($ % l.strides[f] !== 0 ? 1 : 0), m.push(k);
|
|
631
|
+
} else
|
|
632
|
+
m.push(-1);
|
|
633
|
+
}
|
|
634
|
+
for (let f = 0; f < l.finalShapeGatherIndices.length; ++f) {
|
|
635
|
+
const w = l.finalShapeGatherIndices[f];
|
|
636
|
+
w >= 0 ? b.push(m[w]) : w === v && b.push(1);
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
finalShapeSparse: b.filter((f, w) => l.finalShapeGatherIndices[w] !== v),
|
|
640
|
+
finalShape: b,
|
|
641
|
+
isIdentity: h,
|
|
642
|
+
sliceDim0: d,
|
|
643
|
+
isSimpleSlice: A,
|
|
644
|
+
begin: l.begin,
|
|
645
|
+
end: l.end,
|
|
646
|
+
strides: l.strides
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
function ve(e, t) {
|
|
650
|
+
t.beginMask = 0, t.endMask = 0, t.shrinkAxisMask = 0;
|
|
651
|
+
let n = 0;
|
|
652
|
+
t.beginValid = e.begin != null, t.endValid = e.end != null, t.begin = new Array(t.dims), t.end = new Array(t.dims), t.strides = new Array(t.dims), t.finalShapeGatherIndices = [], t.finalShapeGatherIndicesSparse = [], t.inputShapeGatherIndicesSparse = new Array(t.dims);
|
|
653
|
+
for (let s = 0; s < e.dims; s++)
|
|
654
|
+
if (1 << s & e.ellipsisMask) {
|
|
655
|
+
const r = Math.min(t.dims - (e.dims - s) + 1 + e.numAddAxisAfterEllipsis, t.dims);
|
|
656
|
+
for (; n < r; n++)
|
|
657
|
+
t.begin[n] = 0, t.end[n] = 0, t.strides[n] = 1, t.beginMask |= 1 << n, t.endMask |= 1 << n, t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(-1), t.inputShapeGatherIndicesSparse[n] = s;
|
|
658
|
+
} else if (1 << s & e.newAxisMask)
|
|
659
|
+
t.finalShapeGatherIndices.push(v), t.finalShapeGatherIndicesSparse.push(-1);
|
|
660
|
+
else {
|
|
661
|
+
if (n === t.begin.length)
|
|
662
|
+
throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`);
|
|
663
|
+
e.begin != null && (t.begin[n] = e.begin[s]), e.end != null && (t.end[n] = e.end[s]), t.strides[n] = e.strides[s], e.beginMask & 1 << s && (t.beginMask |= 1 << n), e.endMask & 1 << s && (t.endMask |= 1 << n), e.shrinkAxisMask & 1 << s ? (t.finalShapeGatherIndices.push(Ce), t.finalShapeGatherIndicesSparse.push(-1), t.shrinkAxisMask |= 1 << n) : (t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(s)), t.inputShapeGatherIndicesSparse[n] = s, n++;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function K(e, t, n, s, r, u) {
|
|
667
|
+
if (r[t])
|
|
668
|
+
return n > 0 ? u[t] : u[t + 1 & 1];
|
|
669
|
+
{
|
|
670
|
+
const i = e < 0 ? s + e : e;
|
|
671
|
+
return i < u[0] ? u[0] : i > u[1] ? u[1] : i;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
675
|
+
__proto__: null,
|
|
676
|
+
assertParamsValid: Ge,
|
|
677
|
+
computeFlatOffset: Ve,
|
|
678
|
+
computeOutShape: Re,
|
|
679
|
+
getNormalizedAxes: Oe,
|
|
680
|
+
isSliceContinous: Fe,
|
|
681
|
+
maskToAxes: Te,
|
|
682
|
+
parseSliceParams: Ue,
|
|
683
|
+
sliceInfo: We,
|
|
684
|
+
startForAxis: z,
|
|
685
|
+
startIndicesWithElidedDims: Q,
|
|
686
|
+
stopForAxis: ee,
|
|
687
|
+
stopIndicesWithElidedDims: Y,
|
|
688
|
+
stridesForAxis: Z,
|
|
689
|
+
stridesWithElidedDims: j
|
|
690
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
691
|
+
/**
|
|
692
|
+
* @license
|
|
693
|
+
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
694
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
695
|
+
* you may not use this file except in compliance with the License.
|
|
696
|
+
* You may obtain a copy of the License at
|
|
697
|
+
*
|
|
698
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
699
|
+
*
|
|
700
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
701
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
702
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
703
|
+
* See the License for the specific language governing permissions and
|
|
704
|
+
* limitations under the License.
|
|
705
|
+
* =============================================================================
|
|
706
|
+
*/
|
|
707
|
+
const nt = 1.7580993408473768, st = 1.0507009873554805;
|
|
708
|
+
export {
|
|
709
|
+
ke as A,
|
|
710
|
+
Ne as B,
|
|
711
|
+
We as C,
|
|
712
|
+
Re as D,
|
|
713
|
+
st as S,
|
|
714
|
+
nt as a,
|
|
715
|
+
ze as b,
|
|
716
|
+
Qe as c,
|
|
717
|
+
X as d,
|
|
718
|
+
he as e,
|
|
719
|
+
B as f,
|
|
720
|
+
Xe as g,
|
|
721
|
+
Be as h,
|
|
722
|
+
je as i,
|
|
723
|
+
Ae as j,
|
|
724
|
+
qe as k,
|
|
725
|
+
Ze as l,
|
|
726
|
+
Ye as m,
|
|
727
|
+
tt as n,
|
|
728
|
+
Je as o,
|
|
729
|
+
Ue as p,
|
|
730
|
+
Ge as q,
|
|
731
|
+
Fe as r,
|
|
732
|
+
et as s,
|
|
733
|
+
P as t,
|
|
734
|
+
Ve as u,
|
|
735
|
+
Le as v,
|
|
736
|
+
Ee as w,
|
|
737
|
+
$e as x,
|
|
738
|
+
Se as y,
|
|
739
|
+
xe as z
|
|
740
|
+
};
|