@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { p as
|
|
3
|
-
import { B as
|
|
1
|
+
import { g as Gt } from "./index-D5v913EJ.js";
|
|
2
|
+
import { p as Q } from "./index-xuotMAFm.js";
|
|
3
|
+
import { B as pt } from "./index-Tf7vU29b.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -17,60 +17,80 @@ import { B as mt } from "./index-Tf7vU29b.js";
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
* =============================================================================
|
|
19
19
|
*/
|
|
20
|
-
const Me = 1e-7,
|
|
20
|
+
const Me = 1e-7, De = 1e-4;
|
|
21
|
+
class Rs {
|
|
22
|
+
constructor(t, n) {
|
|
23
|
+
this.backend = t, this.dataMover = n, this.data = /* @__PURE__ */ new WeakMap(), this.dataIdsCount = 0;
|
|
24
|
+
}
|
|
25
|
+
get(t) {
|
|
26
|
+
return this.data.has(t) || this.dataMover.moveData(this.backend, t), this.data.get(t);
|
|
27
|
+
}
|
|
28
|
+
set(t, n) {
|
|
29
|
+
this.dataIdsCount++, this.data.set(t, n);
|
|
30
|
+
}
|
|
31
|
+
has(t) {
|
|
32
|
+
return this.data.has(t);
|
|
33
|
+
}
|
|
34
|
+
delete(t) {
|
|
35
|
+
return this.dataIdsCount--, this.data.delete(t);
|
|
36
|
+
}
|
|
37
|
+
numDataIds() {
|
|
38
|
+
return this.dataIdsCount;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
21
41
|
class Fe {
|
|
22
42
|
refCount(t) {
|
|
23
|
-
return
|
|
43
|
+
return B("refCount");
|
|
24
44
|
}
|
|
25
45
|
incRef(t) {
|
|
26
|
-
return
|
|
46
|
+
return B("incRef");
|
|
27
47
|
}
|
|
28
48
|
timerAvailable() {
|
|
29
49
|
return !0;
|
|
30
50
|
}
|
|
31
51
|
time(t) {
|
|
32
|
-
return
|
|
52
|
+
return B("time");
|
|
33
53
|
}
|
|
34
54
|
read(t) {
|
|
35
|
-
return
|
|
55
|
+
return B("read");
|
|
36
56
|
}
|
|
37
57
|
readSync(t) {
|
|
38
|
-
return
|
|
58
|
+
return B("readSync");
|
|
39
59
|
}
|
|
40
60
|
readToGPU(t, n) {
|
|
41
|
-
return
|
|
61
|
+
return B("readToGPU");
|
|
42
62
|
}
|
|
43
63
|
numDataIds() {
|
|
44
|
-
return
|
|
64
|
+
return B("numDataIds");
|
|
45
65
|
}
|
|
46
66
|
disposeData(t, n) {
|
|
47
|
-
return
|
|
67
|
+
return B("disposeData");
|
|
48
68
|
}
|
|
49
69
|
write(t, n, s) {
|
|
50
|
-
return
|
|
70
|
+
return B("write");
|
|
51
71
|
}
|
|
52
72
|
move(t, n, s, r, a) {
|
|
53
|
-
return
|
|
73
|
+
return B("move");
|
|
54
74
|
}
|
|
55
75
|
createTensorFromGPUData(t, n, s) {
|
|
56
|
-
return
|
|
76
|
+
return B("createTensorFromGPUData");
|
|
57
77
|
}
|
|
58
78
|
memory() {
|
|
59
|
-
return
|
|
79
|
+
return B("memory");
|
|
60
80
|
}
|
|
61
81
|
/** Returns the highest precision for floats in bits (e.g. 16 or 32) */
|
|
62
82
|
floatPrecision() {
|
|
63
|
-
return
|
|
83
|
+
return B("floatPrecision");
|
|
64
84
|
}
|
|
65
85
|
/** Returns the smallest representable number. */
|
|
66
86
|
epsilon() {
|
|
67
|
-
return this.floatPrecision() === 32 ? Me :
|
|
87
|
+
return this.floatPrecision() === 32 ? Me : De;
|
|
68
88
|
}
|
|
69
89
|
dispose() {
|
|
70
|
-
return
|
|
90
|
+
return B("dispose");
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
|
-
function
|
|
93
|
+
function B(e) {
|
|
74
94
|
throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`);
|
|
75
95
|
}
|
|
76
96
|
/**
|
|
@@ -89,23 +109,35 @@ function v(e) {
|
|
|
89
109
|
* limitations under the License.
|
|
90
110
|
* =============================================================================
|
|
91
111
|
*/
|
|
92
|
-
function
|
|
112
|
+
function xs(e) {
|
|
93
113
|
let t = e.length, n = 0;
|
|
94
114
|
for (; t > 0; )
|
|
95
115
|
n = Math.random() * t | 0, t--, Re(e, t, n);
|
|
96
116
|
}
|
|
117
|
+
function Ns(e, t, n) {
|
|
118
|
+
return Math.max(e, Math.min(t, n));
|
|
119
|
+
}
|
|
120
|
+
function $s(e) {
|
|
121
|
+
return e % 2 === 0 ? e : e + 1;
|
|
122
|
+
}
|
|
97
123
|
function Re(e, t, n) {
|
|
98
124
|
const s = e[t];
|
|
99
125
|
e[t] = e[n], e[n] = s;
|
|
100
126
|
}
|
|
127
|
+
function Cs(e) {
|
|
128
|
+
let t = 0;
|
|
129
|
+
for (let n = 0; n < e.length; n++)
|
|
130
|
+
t += e[n];
|
|
131
|
+
return t;
|
|
132
|
+
}
|
|
101
133
|
function y(e, t) {
|
|
102
134
|
if (!e)
|
|
103
135
|
throw new Error(typeof t == "string" ? t : t());
|
|
104
136
|
}
|
|
105
|
-
function
|
|
106
|
-
y(
|
|
137
|
+
function xe(e, t, n = "") {
|
|
138
|
+
y(xt(e, t), () => n + ` Shapes ${e} and ${t} must match`);
|
|
107
139
|
}
|
|
108
|
-
function
|
|
140
|
+
function Ps(e) {
|
|
109
141
|
y(e != null, () => "The input to the tensor constructor must be a non-null value.");
|
|
110
142
|
}
|
|
111
143
|
function z(e) {
|
|
@@ -116,7 +148,7 @@ function z(e) {
|
|
|
116
148
|
t *= e[n];
|
|
117
149
|
return t;
|
|
118
150
|
}
|
|
119
|
-
function
|
|
151
|
+
function xt(e, t) {
|
|
120
152
|
if (e === t)
|
|
121
153
|
return !0;
|
|
122
154
|
if (e == null || t == null || e.length !== t.length)
|
|
@@ -126,13 +158,36 @@ function Rt(e, t) {
|
|
|
126
158
|
return !1;
|
|
127
159
|
return !0;
|
|
128
160
|
}
|
|
129
|
-
function
|
|
161
|
+
function Ne(e) {
|
|
130
162
|
return e % 1 === 0;
|
|
131
163
|
}
|
|
132
|
-
function
|
|
164
|
+
function Ls(e) {
|
|
165
|
+
const t = Math.ceil(Math.sqrt(e));
|
|
166
|
+
return [t, Math.ceil(e / t)];
|
|
167
|
+
}
|
|
168
|
+
function ut(e, t) {
|
|
133
169
|
return t <= e.length ? e : e + " ".repeat(t - e.length);
|
|
134
170
|
}
|
|
135
|
-
function
|
|
171
|
+
function _s(e, t = (r) => 0, n, s) {
|
|
172
|
+
return new Promise((r, a) => {
|
|
173
|
+
let o = 0;
|
|
174
|
+
const i = () => {
|
|
175
|
+
if (e()) {
|
|
176
|
+
r();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
o++;
|
|
180
|
+
const c = t(o);
|
|
181
|
+
if (n != null && o >= n) {
|
|
182
|
+
a();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
s != null ? s(i, c) : setTimeout(i, c);
|
|
186
|
+
};
|
|
187
|
+
i();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function Os(e, t) {
|
|
136
191
|
let n = 1, s = -1;
|
|
137
192
|
for (let a = 0; a < e.length; ++a)
|
|
138
193
|
if (e[a] >= 0)
|
|
@@ -155,12 +210,12 @@ function Rs(e, t) {
|
|
|
155
210
|
const r = e.slice();
|
|
156
211
|
return r[s] = t / n, r;
|
|
157
212
|
}
|
|
158
|
-
function
|
|
213
|
+
function $e(e, t) {
|
|
159
214
|
const n = t.length;
|
|
160
|
-
return e = e == null ? t.map((s, r) => r) : [].concat(e), y(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), y(e.every((s) =>
|
|
215
|
+
return e = e == null ? t.map((s, r) => r) : [].concat(e), y(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), y(e.every((s) => Ne(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s);
|
|
161
216
|
}
|
|
162
|
-
function
|
|
163
|
-
const n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null :
|
|
217
|
+
function Gs(e, t) {
|
|
218
|
+
const n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : $e(t, e).sort();
|
|
164
219
|
let o = 0;
|
|
165
220
|
for (let i = 0; i < e.length; ++i) {
|
|
166
221
|
if (a != null) {
|
|
@@ -172,7 +227,7 @@ function Ds(e, t) {
|
|
|
172
227
|
}
|
|
173
228
|
return { newShape: n, keptDims: s };
|
|
174
229
|
}
|
|
175
|
-
function
|
|
230
|
+
function Us(e, t) {
|
|
176
231
|
return te(e, t);
|
|
177
232
|
}
|
|
178
233
|
function te(e, t) {
|
|
@@ -199,7 +254,10 @@ function Ce(e, t) {
|
|
|
199
254
|
function Pe(e) {
|
|
200
255
|
return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string";
|
|
201
256
|
}
|
|
202
|
-
function
|
|
257
|
+
function zs(e, t) {
|
|
258
|
+
return !(t === "complex64" || t === "float32" && e !== "complex64" || t === "int32" && e !== "float32" && e !== "complex64" || t === "bool" && e === "bool");
|
|
259
|
+
}
|
|
260
|
+
function It(e) {
|
|
203
261
|
if (e === "float32" || e === "int32")
|
|
204
262
|
return 4;
|
|
205
263
|
if (e === "complex64")
|
|
@@ -214,7 +272,7 @@ function Le(e) {
|
|
|
214
272
|
let t = 0;
|
|
215
273
|
return e.forEach((n) => t += n.length), t;
|
|
216
274
|
}
|
|
217
|
-
function
|
|
275
|
+
function Nt(e) {
|
|
218
276
|
return typeof e == "string" || e instanceof String;
|
|
219
277
|
}
|
|
220
278
|
function _e(e) {
|
|
@@ -223,13 +281,13 @@ function _e(e) {
|
|
|
223
281
|
function Oe(e) {
|
|
224
282
|
return typeof e == "number";
|
|
225
283
|
}
|
|
226
|
-
function
|
|
227
|
-
return Array.isArray(e) ?
|
|
284
|
+
function yt(e) {
|
|
285
|
+
return Array.isArray(e) ? yt(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : Oe(e) ? "float32" : Nt(e) ? "string" : _e(e) ? "bool" : "float32";
|
|
228
286
|
}
|
|
229
|
-
function
|
|
287
|
+
function dt(e) {
|
|
230
288
|
return !!(e && e.constructor && e.call && e.apply);
|
|
231
289
|
}
|
|
232
|
-
function
|
|
290
|
+
function Vs(e, t) {
|
|
233
291
|
for (let n = t; n < e; ++n)
|
|
234
292
|
if (e % n === 0)
|
|
235
293
|
return n;
|
|
@@ -258,7 +316,7 @@ function ee(e, t, n, s = !1) {
|
|
|
258
316
|
}
|
|
259
317
|
return r;
|
|
260
318
|
}
|
|
261
|
-
function
|
|
319
|
+
function ct(e, t, n = !1) {
|
|
262
320
|
if (e.length === 0)
|
|
263
321
|
return t[0];
|
|
264
322
|
const s = e.reduce((r, a) => r * a) * (n ? 2 : 1);
|
|
@@ -268,6 +326,17 @@ function Gt(e, t, n = !1) {
|
|
|
268
326
|
throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`);
|
|
269
327
|
return ee(0, e, t, n);
|
|
270
328
|
}
|
|
329
|
+
function Ws(e, t) {
|
|
330
|
+
if (Array.isArray(e))
|
|
331
|
+
return e;
|
|
332
|
+
if (t === "float32")
|
|
333
|
+
return e instanceof Float32Array ? e : new Float32Array(e);
|
|
334
|
+
if (t === "int32")
|
|
335
|
+
return e instanceof Int32Array ? e : new Int32Array(e);
|
|
336
|
+
if (t === "bool" || t === "string")
|
|
337
|
+
return Uint8Array.from(new Int32Array(e));
|
|
338
|
+
throw new Error(`Unknown dtype ${t}`);
|
|
339
|
+
}
|
|
271
340
|
function Ge(e, t) {
|
|
272
341
|
const n = ne(e, t);
|
|
273
342
|
for (let s = 0; s < n.length; s++)
|
|
@@ -283,12 +352,22 @@ function ne(e, t) {
|
|
|
283
352
|
return new Uint8Array(e);
|
|
284
353
|
throw new Error(`Unknown data type ${t}`);
|
|
285
354
|
}
|
|
286
|
-
function
|
|
355
|
+
function js(e, t) {
|
|
356
|
+
const n = e.reduce((s, r) => s * r, 1);
|
|
357
|
+
if (t == null || t === "float32")
|
|
358
|
+
return ct(e, new Float32Array(n));
|
|
359
|
+
if (t === "int32")
|
|
360
|
+
return ct(e, new Int32Array(n));
|
|
361
|
+
if (t === "bool")
|
|
362
|
+
return ct(e, new Uint8Array(n));
|
|
363
|
+
throw new Error(`Unknown data type ${t}`);
|
|
364
|
+
}
|
|
365
|
+
function Ct(e) {
|
|
287
366
|
e.forEach((t) => {
|
|
288
367
|
y(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`);
|
|
289
368
|
});
|
|
290
369
|
}
|
|
291
|
-
function
|
|
370
|
+
function qs(e, t, n) {
|
|
292
371
|
if (t === 0)
|
|
293
372
|
return 0;
|
|
294
373
|
if (t === 1)
|
|
@@ -298,7 +377,7 @@ function Cs(e, t, n) {
|
|
|
298
377
|
s += n[r] * e[r];
|
|
299
378
|
return s;
|
|
300
379
|
}
|
|
301
|
-
function
|
|
380
|
+
function Ks(e, t, n) {
|
|
302
381
|
if (t === 0)
|
|
303
382
|
return [];
|
|
304
383
|
if (t === 1)
|
|
@@ -308,7 +387,7 @@ function Ps(e, t, n) {
|
|
|
308
387
|
s[r] = Math.floor(e / n[r]), e -= s[r] * n[r];
|
|
309
388
|
return s[s.length - 1] = e, s;
|
|
310
389
|
}
|
|
311
|
-
function
|
|
390
|
+
function Pt(e) {
|
|
312
391
|
return e && e.then && typeof e.then == "function";
|
|
313
392
|
}
|
|
314
393
|
/**
|
|
@@ -334,12 +413,12 @@ class Ue {
|
|
|
334
413
|
this.global = t, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = ze, this.populateURLFlags();
|
|
335
414
|
}
|
|
336
415
|
setPlatform(t, n) {
|
|
337
|
-
this.platform != null && (
|
|
416
|
+
this.platform != null && (S().getBool("IS_TEST") || S().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`)), this.platformName = t, this.platform = n;
|
|
338
417
|
}
|
|
339
418
|
registerFlag(t, n, s) {
|
|
340
419
|
if (this.flagRegistry[t] = { evaluationFn: n, setHook: s }, this.urlFlags[t] != null) {
|
|
341
420
|
const r = this.urlFlags[t];
|
|
342
|
-
|
|
421
|
+
S().getBool("IS_TEST") || S().getBool("PROD") || console.warn(`Setting feature override from URL ${t}: ${r}.`), this.set(t, r);
|
|
343
422
|
}
|
|
344
423
|
}
|
|
345
424
|
async getAsync(t) {
|
|
@@ -349,7 +428,7 @@ class Ue {
|
|
|
349
428
|
if (t in this.flags)
|
|
350
429
|
return this.flags[t];
|
|
351
430
|
const n = this.evaluateFlag(t);
|
|
352
|
-
if (
|
|
431
|
+
if (Pt(n))
|
|
353
432
|
throw new Error(`Flag ${t} cannot be synchronously evaluated. Please use getAsync() instead.`);
|
|
354
433
|
return this.flags[t] = n, this.flags[t];
|
|
355
434
|
}
|
|
@@ -406,7 +485,7 @@ function We(e, t) {
|
|
|
406
485
|
const n = t.toLowerCase();
|
|
407
486
|
return n === "true" || n === "false" ? n === "true" : `${+n}` === n ? +n : t;
|
|
408
487
|
}
|
|
409
|
-
function
|
|
488
|
+
function S() {
|
|
410
489
|
return se;
|
|
411
490
|
}
|
|
412
491
|
let se = null;
|
|
@@ -429,30 +508,30 @@ function je(e) {
|
|
|
429
508
|
* limitations under the License.
|
|
430
509
|
* =============================================================================
|
|
431
510
|
*/
|
|
432
|
-
let
|
|
511
|
+
let bt;
|
|
433
512
|
function re() {
|
|
434
|
-
if (
|
|
513
|
+
if (bt == null) {
|
|
435
514
|
let e;
|
|
436
515
|
if (typeof window < "u")
|
|
437
516
|
e = window;
|
|
438
|
-
else if (typeof
|
|
439
|
-
e =
|
|
440
|
-
else if (typeof
|
|
441
|
-
e =
|
|
517
|
+
else if (typeof Gt < "u")
|
|
518
|
+
e = Gt;
|
|
519
|
+
else if (typeof Q < "u")
|
|
520
|
+
e = Q;
|
|
442
521
|
else if (typeof self < "u")
|
|
443
522
|
e = self;
|
|
444
523
|
else
|
|
445
524
|
throw new Error("Could not find a global object");
|
|
446
|
-
|
|
525
|
+
bt = e;
|
|
447
526
|
}
|
|
448
|
-
return
|
|
527
|
+
return bt;
|
|
449
528
|
}
|
|
450
|
-
function
|
|
529
|
+
function qe() {
|
|
451
530
|
const e = re();
|
|
452
531
|
return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals;
|
|
453
532
|
}
|
|
454
|
-
function
|
|
455
|
-
const n =
|
|
533
|
+
function Lt(e, t) {
|
|
534
|
+
const n = qe();
|
|
456
535
|
if (n.has(e))
|
|
457
536
|
return n.get(e);
|
|
458
537
|
{
|
|
@@ -460,7 +539,7 @@ function Pt(e, t) {
|
|
|
460
539
|
return n.set(e, s), n.get(e);
|
|
461
540
|
}
|
|
462
541
|
}
|
|
463
|
-
const
|
|
542
|
+
const Ke = "Abs", Hs = "Acos", Xs = "Acosh", ae = "Add", Js = "AddN", Ys = "All", Zs = "Any", Qs = "ArgMax", tr = "ArgMin", er = "Asin", nr = "Asinh", sr = "Atan", rr = "Atanh", ar = "Atan2", or = "AvgPool", ir = "AvgPoolGrad", cr = "AvgPool3D", lr = "AvgPool3DGrad", ur = "BatchMatMul", hr = "BatchToSpaceND", dr = "Bincount", fr = "BitwiseAnd", gr = "BroadcastTo", mr = "BroadcastArgs", oe = "Cast", pr = "Ceil", yr = "ClipByValue", br = "Complex", He = "ComplexAbs", wr = "Concat", Sr = "Conv2D", kr = "Conv2DBackpropFilter", Ir = "Conv2DBackpropInput", Tr = "Conv3D", Er = "Conv3DBackpropFilterV2", Ar = "Conv3DBackpropInputV2", vr = "Cos", Br = "Cosh", Mr = "Cumprod", Dr = "Cumsum", Fr = "CropAndResize", Rr = "DenseBincount", xr = "DepthToSpace", Nr = "DepthwiseConv2dNative", $r = "DepthwiseConv2dNativeBackpropFilter", Cr = "DepthwiseConv2dNativeBackpropInput", Pr = "Diag", Lr = "Dilation2D", _r = "Dilation2DBackpropInput", Or = "Dilation2DBackpropFilter", Gr = "Draw", Xe = "RealDiv", Ur = "Einsum", zr = "Elu", Vr = "EluGrad", Wr = "Erf", jr = "Equal", qr = "Exp", Kr = "ExpandDims", Hr = "Expm1", Xr = "FFT", Je = "Fill", Jr = "FlipLeftRight", Yr = "Floor", Ye = "FloorDiv", Zr = "FusedBatchNorm", Qr = "GatherV2", ta = "GatherNd", ea = "Greater", na = "GreaterEqual", ie = "Identity", sa = "IFFT", ra = "Imag", aa = "IsFinite", oa = "IsInf", ia = "IsNan", ca = "LeakyRelu", la = "Less", ua = "LessEqual", ha = "LinSpace", da = "Log", fa = "Log1p", ga = "LogicalAnd", ma = "LogicalNot", pa = "LogicalOr", ya = "LogSoftmax", ba = "LRN", wa = "LRNGrad", Sa = "Max", Ze = "Maximum", ka = "MaxPool", Ia = "MaxPoolGrad", Ta = "MaxPool3D", Ea = "MaxPool3DGrad", Aa = "MaxPoolWithArgmax", va = "Mean", Ba = "Min", Ma = "Minimum", Da = "MirrorPad", Fa = "Mod", Ra = "Multinomial", Qe = "Multiply", xa = "Neg", Na = "NotEqual", $a = "NonMaxSuppressionV3", Ca = "NonMaxSuppressionV4", Pa = "NonMaxSuppressionV5", La = "OnesLike", _a = "OneHot", Oa = "Pack", Ga = "PadV2", tn = "Pow", Ua = "Prelu", za = "Prod", Va = "RaggedGather", Wa = "RaggedRange", ja = "RaggedTensorToTensor", qa = "Range", Ka = "Real", Ha = "Reciprocal", Xa = "Relu", Ja = "Reshape", Ya = "ResizeNearestNeighbor", Za = "ResizeNearestNeighborGrad", Qa = "ResizeBilinear", to = "ResizeBilinearGrad", eo = "Relu6", no = "Reverse", so = "Round", ro = "Rsqrt", ao = "ScatterNd", oo = "TensorScatterUpdate", io = "SearchSorted", co = "Select", lo = "Selu", uo = "Slice", ho = "Sin", fo = "Sinh", go = "Sign", mo = "Sigmoid", po = "Softplus", en = "Sqrt", yo = "Sum", bo = "SpaceToBatchND", wo = "SplitV", So = "Softmax", ko = "SparseFillEmptyRows", Io = "SparseReshape", To = "SparseSegmentMean", Eo = "SparseSegmentSum", Ao = "SparseToDense", vo = "SquaredDifference", Bo = "Square", Mo = "StaticRegexReplace", Do = "StridedSlice", Fo = "StringNGrams", Ro = "StringSplit", xo = "StringToHashBucketFast", nn = "Sub", No = "Tan", $o = "Tanh", Co = "Tile", Po = "TopK", Lo = "Transform", _o = "Transpose", Oo = "Unique", Go = "Unpack", Uo = "UnsortedSegmentSum", sn = "ZerosLike", zo = "Step", Vo = "FromPixels", Wo = "RotateWithOffset", jo = "_FusedMatMul", qo = "FusedConv2D", Ko = "FusedDepthwiseConv2D";
|
|
464
543
|
/**
|
|
465
544
|
* @license
|
|
466
545
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -478,7 +557,10 @@ const qe = "Abs", Ls = "Acos", _s = "Acosh", ae = "Add", Os = "AddN", Gs = "All"
|
|
|
478
557
|
* =============================================================================
|
|
479
558
|
*/
|
|
480
559
|
function O(...e) {
|
|
481
|
-
|
|
560
|
+
S().getBool("IS_TEST") || S().getBool("PROD") || console.warn(...e);
|
|
561
|
+
}
|
|
562
|
+
function Ho(...e) {
|
|
563
|
+
S().getBool("IS_TEST") || S().getBool("PROD") || console.log(...e);
|
|
482
564
|
}
|
|
483
565
|
/**
|
|
484
566
|
* @license
|
|
@@ -496,13 +578,13 @@ function O(...e) {
|
|
|
496
578
|
* limitations under the License.
|
|
497
579
|
* =============================================================================
|
|
498
580
|
*/
|
|
499
|
-
const ft =
|
|
581
|
+
const ft = Lt("kernelRegistry", () => /* @__PURE__ */ new Map()), Tt = Lt("gradRegistry", () => /* @__PURE__ */ new Map());
|
|
500
582
|
function zt(e, t) {
|
|
501
583
|
const n = ce(e, t);
|
|
502
584
|
return ft.get(n);
|
|
503
585
|
}
|
|
504
586
|
function Vt(e) {
|
|
505
|
-
return
|
|
587
|
+
return Tt.get(e);
|
|
506
588
|
}
|
|
507
589
|
function Wt(e) {
|
|
508
590
|
const t = ft.entries(), n = [];
|
|
@@ -515,13 +597,13 @@ function Wt(e) {
|
|
|
515
597
|
}
|
|
516
598
|
return n;
|
|
517
599
|
}
|
|
518
|
-
function
|
|
600
|
+
function Xo(e) {
|
|
519
601
|
const { kernelName: t, backendName: n } = e, s = ce(t, n);
|
|
520
602
|
ft.has(s) && O(`The kernel '${t}' for backend '${n}' is already registered`), ft.set(s, e);
|
|
521
603
|
}
|
|
522
|
-
function
|
|
604
|
+
function Jo(e) {
|
|
523
605
|
const { kernelName: t } = e;
|
|
524
|
-
|
|
606
|
+
Tt.has(t) && S().getBool("DEBUG") && O(`Overriding the gradient for '${t}'`), Tt.set(t, e);
|
|
525
607
|
}
|
|
526
608
|
function ce(e, t) {
|
|
527
609
|
return `${t}_${e}`;
|
|
@@ -561,16 +643,16 @@ function le(e) {
|
|
|
561
643
|
* limitations under the License.
|
|
562
644
|
* =============================================================================
|
|
563
645
|
*/
|
|
564
|
-
function
|
|
565
|
-
return t === "string" ? ue(e) :
|
|
646
|
+
function Yo(e, t) {
|
|
647
|
+
return t === "string" ? ue(e) : _t([e], t);
|
|
566
648
|
}
|
|
567
649
|
function rn(e, t) {
|
|
568
650
|
return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool";
|
|
569
651
|
}
|
|
570
|
-
function
|
|
652
|
+
function _t(e, t) {
|
|
571
653
|
if (t === "string")
|
|
572
654
|
throw new Error("Cannot convert a string[] to a TypedArray");
|
|
573
|
-
if (Array.isArray(e) && (e =
|
|
655
|
+
if (Array.isArray(e) && (e = lt(e)), S().getBool("DEBUG") && Ce(e, t), rn(e, t))
|
|
574
656
|
return e;
|
|
575
657
|
if (t == null || t === "float32" || t === "complex64")
|
|
576
658
|
return new Float32Array(e);
|
|
@@ -584,30 +666,30 @@ function Lt(e, t) {
|
|
|
584
666
|
} else
|
|
585
667
|
throw new Error(`Unknown data type ${t}`);
|
|
586
668
|
}
|
|
587
|
-
function
|
|
588
|
-
return
|
|
669
|
+
function gt() {
|
|
670
|
+
return S().platform.now();
|
|
589
671
|
}
|
|
590
672
|
function ue(e, t = "utf-8") {
|
|
591
|
-
return t = t || "utf-8",
|
|
673
|
+
return t = t || "utf-8", S().platform.encode(e, t);
|
|
592
674
|
}
|
|
593
675
|
function jt(e, t = "utf-8") {
|
|
594
|
-
return t = t || "utf-8",
|
|
676
|
+
return t = t || "utf-8", S().platform.decode(e, t);
|
|
595
677
|
}
|
|
596
678
|
function F(e) {
|
|
597
|
-
return
|
|
679
|
+
return S().platform.isTypedArray != null ? S().platform.isTypedArray(e) : le(e);
|
|
598
680
|
}
|
|
599
|
-
function
|
|
600
|
-
if (t == null && (t = []), typeof e == "boolean" || typeof e == "number" || typeof e == "string" ||
|
|
681
|
+
function lt(e, t = [], n = !1) {
|
|
682
|
+
if (t == null && (t = []), typeof e == "boolean" || typeof e == "number" || typeof e == "string" || Pt(e) || e == null || F(e) && n)
|
|
601
683
|
t.push(e);
|
|
602
684
|
else if (Array.isArray(e) || F(e))
|
|
603
685
|
for (let s = 0; s < e.length; ++s)
|
|
604
|
-
|
|
686
|
+
lt(e[s], t, n);
|
|
605
687
|
else {
|
|
606
688
|
let s = -1;
|
|
607
689
|
for (const r of Object.keys(e))
|
|
608
690
|
/^([1-9]+[0-9]*|0)$/.test(r) && (s = Math.max(s, Number(r)));
|
|
609
691
|
for (let r = 0; r <= s; r++)
|
|
610
|
-
|
|
692
|
+
lt(e[r], t, n);
|
|
611
693
|
}
|
|
612
694
|
return t;
|
|
613
695
|
}
|
|
@@ -637,16 +719,16 @@ class an {
|
|
|
637
719
|
r = s();
|
|
638
720
|
};
|
|
639
721
|
let o;
|
|
640
|
-
const i =
|
|
722
|
+
const i = gt();
|
|
641
723
|
if (this.backendTimer.timerAvailable())
|
|
642
724
|
o = this.backendTimer.time(a);
|
|
643
725
|
else {
|
|
644
726
|
a();
|
|
645
727
|
for (const l of r)
|
|
646
728
|
l.dataSync();
|
|
647
|
-
o = Promise.resolve({ kernelMs:
|
|
729
|
+
o = Promise.resolve({ kernelMs: gt() - i });
|
|
648
730
|
}
|
|
649
|
-
if (
|
|
731
|
+
if (S().getBool("CHECK_COMPUTATION_FOR_ERRORS"))
|
|
650
732
|
for (let l = 0; l < r.length; l++) {
|
|
651
733
|
const u = r[l];
|
|
652
734
|
u.data().then((h) => {
|
|
@@ -682,16 +764,16 @@ function on(e, t, n) {
|
|
|
682
764
|
}
|
|
683
765
|
class cn {
|
|
684
766
|
logKernelProfile(t, n, s, r, a, o) {
|
|
685
|
-
const i = typeof r == "number" ?
|
|
686
|
-
let
|
|
767
|
+
const i = typeof r == "number" ? ut(`${r}ms`, 9) : r.error, c = ut(t, 25), l = n.rank, u = n.size, h = ut(n.shape.toString(), 14);
|
|
768
|
+
let d = "";
|
|
687
769
|
for (const m in a) {
|
|
688
770
|
const p = a[m];
|
|
689
771
|
if (p != null) {
|
|
690
|
-
const
|
|
691
|
-
|
|
772
|
+
const f = p.shape || n.shape, w = f.length;
|
|
773
|
+
d += `${m}: ${w}D ${w > 0 ? f : ""} `;
|
|
692
774
|
}
|
|
693
775
|
}
|
|
694
|
-
console.log(`%c${c} %c${i} %c${l}D ${h} %c${u} %c${
|
|
776
|
+
console.log(`%c${c} %c${i} %c${l}D ${h} %c${u} %c${d} %c${o}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue");
|
|
695
777
|
}
|
|
696
778
|
}
|
|
697
779
|
/**
|
|
@@ -717,11 +799,11 @@ function ln(e, t, n) {
|
|
|
717
799
|
for (let c = 0; c < e.length; c++) {
|
|
718
800
|
const l = e[c], u = l.inputs;
|
|
719
801
|
for (const h in u) {
|
|
720
|
-
const
|
|
802
|
+
const d = u[h];
|
|
721
803
|
let m = !1;
|
|
722
804
|
for (let p = 0; p < t.length; p++)
|
|
723
|
-
if (s[
|
|
724
|
-
l.outputs.forEach((
|
|
805
|
+
if (s[d.id]) {
|
|
806
|
+
l.outputs.forEach((f) => s[f.id] = !0), m = !0, r[l.id] = !0;
|
|
725
807
|
break;
|
|
726
808
|
}
|
|
727
809
|
if (m)
|
|
@@ -735,8 +817,8 @@ function ln(e, t, n) {
|
|
|
735
817
|
const l = e[c], u = l.inputs;
|
|
736
818
|
for (let h = 0; h < l.outputs.length; h++)
|
|
737
819
|
if (a[l.outputs[h].id]) {
|
|
738
|
-
for (const
|
|
739
|
-
a[u[
|
|
820
|
+
for (const d in u)
|
|
821
|
+
a[u[d].id] = !0, o[l.id] = !0;
|
|
740
822
|
break;
|
|
741
823
|
}
|
|
742
824
|
}
|
|
@@ -745,9 +827,9 @@ function ln(e, t, n) {
|
|
|
745
827
|
const l = e[c];
|
|
746
828
|
if (r[l.id] && o[l.id]) {
|
|
747
829
|
const u = {};
|
|
748
|
-
for (const
|
|
749
|
-
const m = l.inputs[
|
|
750
|
-
s[m.id] && (u[
|
|
830
|
+
for (const d in l.inputs) {
|
|
831
|
+
const m = l.inputs[d];
|
|
832
|
+
s[m.id] && (u[d] = m);
|
|
751
833
|
}
|
|
752
834
|
const h = Object.assign({}, l);
|
|
753
835
|
h.inputs = u, h.outputs = l.outputs, i.push(h);
|
|
@@ -771,7 +853,7 @@ function un(e, t, n, s) {
|
|
|
771
853
|
if (l.dtype !== "float32")
|
|
772
854
|
throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${c} must have 'float32' dtype, but has '${l.dtype}'`);
|
|
773
855
|
const u = a.inputs[c];
|
|
774
|
-
if (!
|
|
856
|
+
if (!xt(l.shape, u.shape))
|
|
775
857
|
throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${c}' has shape '${l.shape}', which does not match the shape of the input '${u.shape}'`);
|
|
776
858
|
if (e[u.id] == null)
|
|
777
859
|
e[u.id] = l;
|
|
@@ -798,14 +880,14 @@ function un(e, t, n, s) {
|
|
|
798
880
|
* limitations under the License.
|
|
799
881
|
* =============================================================================
|
|
800
882
|
*/
|
|
801
|
-
const
|
|
883
|
+
const qt = 20, at = 3, wt = 7;
|
|
802
884
|
function hn(e, t, n, s) {
|
|
803
|
-
const r = $t(t), a =
|
|
885
|
+
const r = $t(t), a = dn(e, t, n, r), o = t.length, i = ht(e, t, n, r, a), c = ["Tensor"];
|
|
804
886
|
return s && (c.push(` dtype: ${n}`), c.push(` rank: ${o}`), c.push(` shape: [${t}]`), c.push(" values:")), c.push(i.map((l) => " " + l).join(`
|
|
805
887
|
`)), c.join(`
|
|
806
888
|
`);
|
|
807
889
|
}
|
|
808
|
-
function
|
|
890
|
+
function dn(e, t, n, s) {
|
|
809
891
|
const r = z(t), a = s[s.length - 1], o = new Array(a).fill(0), i = t.length, c = n === "complex64" ? it(e) : e;
|
|
810
892
|
if (i > 1)
|
|
811
893
|
for (let l = 0; l < r / a; l++) {
|
|
@@ -817,37 +899,37 @@ function fn(e, t, n, s) {
|
|
|
817
899
|
}
|
|
818
900
|
function ot(e, t, n) {
|
|
819
901
|
let s;
|
|
820
|
-
return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(
|
|
902
|
+
return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(wt))} + ${parseFloat(e[1].toFixed(wt))}j` : Nt(e) ? s = `'${e}'` : n === "bool" ? s = he(e) : s = parseFloat(e.toFixed(wt)).toString(), ut(s, t);
|
|
821
903
|
}
|
|
822
904
|
function he(e) {
|
|
823
905
|
return e === 0 ? "false" : "true";
|
|
824
906
|
}
|
|
825
|
-
function
|
|
907
|
+
function ht(e, t, n, s, r, a = !0) {
|
|
826
908
|
const o = n === "complex64" ? 2 : 1, i = t[0], c = t.length;
|
|
827
909
|
if (c === 0) {
|
|
828
910
|
if (n === "complex64") {
|
|
829
|
-
const
|
|
830
|
-
return [ot(
|
|
911
|
+
const f = it(e);
|
|
912
|
+
return [ot(f[0], 0, n)];
|
|
831
913
|
}
|
|
832
914
|
return n === "bool" ? [he(e[0])] : [e[0].toString()];
|
|
833
915
|
}
|
|
834
916
|
if (c === 1) {
|
|
835
|
-
if (i >
|
|
917
|
+
if (i > qt) {
|
|
836
918
|
const w = at * o;
|
|
837
919
|
let I = Array.from(e.slice(0, w)), _ = Array.from(e.slice((i - at) * o, i * o));
|
|
838
920
|
return n === "complex64" && (I = it(I), _ = it(_)), [
|
|
839
|
-
"[" + I.map((
|
|
921
|
+
"[" + I.map((X, J) => ot(X, r[J], n)).join(", ") + ", ..., " + _.map((X, J) => ot(X, r[i - at + J], n)).join(", ") + "]"
|
|
840
922
|
];
|
|
841
923
|
}
|
|
842
924
|
return [
|
|
843
925
|
"[" + (n === "complex64" ? it(e) : Array.from(e)).map((w, I) => ot(w, r[I], n)).join(", ") + "]"
|
|
844
926
|
];
|
|
845
927
|
}
|
|
846
|
-
const l = t.slice(1), u = s.slice(1), h = s[0] * o,
|
|
847
|
-
if (i >
|
|
848
|
-
for (let
|
|
849
|
-
const w =
|
|
850
|
-
|
|
928
|
+
const l = t.slice(1), u = s.slice(1), h = s[0] * o, d = [];
|
|
929
|
+
if (i > qt) {
|
|
930
|
+
for (let f = 0; f < at; f++) {
|
|
931
|
+
const w = f * h, I = w + h;
|
|
932
|
+
d.push(...ht(
|
|
851
933
|
e.slice(w, I),
|
|
852
934
|
l,
|
|
853
935
|
n,
|
|
@@ -857,42 +939,42 @@ function ut(e, t, n, s, r, a = !0) {
|
|
|
857
939
|
/* isLast */
|
|
858
940
|
));
|
|
859
941
|
}
|
|
860
|
-
|
|
861
|
-
for (let
|
|
862
|
-
const w =
|
|
863
|
-
|
|
942
|
+
d.push("...");
|
|
943
|
+
for (let f = i - at; f < i; f++) {
|
|
944
|
+
const w = f * h, I = w + h;
|
|
945
|
+
d.push(...ht(
|
|
864
946
|
e.slice(w, I),
|
|
865
947
|
l,
|
|
866
948
|
n,
|
|
867
949
|
u,
|
|
868
950
|
r,
|
|
869
|
-
|
|
951
|
+
f === i - 1
|
|
870
952
|
/* isLast */
|
|
871
953
|
));
|
|
872
954
|
}
|
|
873
955
|
} else
|
|
874
|
-
for (let
|
|
875
|
-
const w =
|
|
876
|
-
|
|
956
|
+
for (let f = 0; f < i; f++) {
|
|
957
|
+
const w = f * h, I = w + h;
|
|
958
|
+
d.push(...ht(
|
|
877
959
|
e.slice(w, I),
|
|
878
960
|
l,
|
|
879
961
|
n,
|
|
880
962
|
u,
|
|
881
963
|
r,
|
|
882
|
-
|
|
964
|
+
f === i - 1
|
|
883
965
|
/* isLast */
|
|
884
966
|
));
|
|
885
967
|
}
|
|
886
968
|
const m = c === 2 ? "," : "";
|
|
887
|
-
|
|
888
|
-
for (let
|
|
889
|
-
f
|
|
969
|
+
d[0] = "[" + (i > 0 ? d[0] + m : "");
|
|
970
|
+
for (let f = 1; f < d.length - 1; f++)
|
|
971
|
+
d[f] = " " + d[f] + m;
|
|
890
972
|
let p = `,
|
|
891
973
|
`;
|
|
892
|
-
for (let
|
|
974
|
+
for (let f = 2; f < c; f++)
|
|
893
975
|
p += `
|
|
894
976
|
`;
|
|
895
|
-
return
|
|
977
|
+
return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" : p), d;
|
|
896
978
|
}
|
|
897
979
|
function it(e) {
|
|
898
980
|
const t = [];
|
|
@@ -916,7 +998,7 @@ function it(e) {
|
|
|
916
998
|
* limitations under the License.
|
|
917
999
|
* =============================================================================
|
|
918
1000
|
*/
|
|
919
|
-
class
|
|
1001
|
+
class fn {
|
|
920
1002
|
constructor(t, n, s) {
|
|
921
1003
|
if (this.dtype = n, this.shape = t.slice(), this.size = z(t), s != null) {
|
|
922
1004
|
const r = s.length;
|
|
@@ -1000,7 +1082,7 @@ function gn(e) {
|
|
|
1000
1082
|
function mn(e) {
|
|
1001
1083
|
Y = e;
|
|
1002
1084
|
}
|
|
1003
|
-
class
|
|
1085
|
+
class x {
|
|
1004
1086
|
constructor(t, n, s, r) {
|
|
1005
1087
|
this.kept = !1, this.isDisposedInternal = !1, this.shape = t.slice(), this.dtype = n || "float32", this.size = z(t), this.strides = $t(t), this.dataId = s, this.id = r, this.rankType = this.rank < 5 ? this.rank.toString() : "higher";
|
|
1006
1088
|
}
|
|
@@ -1031,7 +1113,7 @@ class D {
|
|
|
1031
1113
|
*/
|
|
1032
1114
|
async array() {
|
|
1033
1115
|
const t = await this.data();
|
|
1034
|
-
return
|
|
1116
|
+
return ct(this.shape, t, this.dtype === "complex64");
|
|
1035
1117
|
}
|
|
1036
1118
|
/**
|
|
1037
1119
|
* Returns the tensor data as a nested array. The transfer of data is done
|
|
@@ -1040,7 +1122,7 @@ class D {
|
|
|
1040
1122
|
* @doc {heading: 'Tensors', subheading: 'Classes'}
|
|
1041
1123
|
*/
|
|
1042
1124
|
arraySync() {
|
|
1043
|
-
return
|
|
1125
|
+
return ct(this.shape, this.dataSync(), this.dtype === "complex64");
|
|
1044
1126
|
}
|
|
1045
1127
|
/**
|
|
1046
1128
|
* Asynchronously downloads the values from the `tf.Tensor`. Returns a
|
|
@@ -1170,14 +1252,14 @@ class D {
|
|
|
1170
1252
|
return this.throwIfDisposed(), R().makeVariable(this, t, n, s);
|
|
1171
1253
|
}
|
|
1172
1254
|
}
|
|
1173
|
-
Object.defineProperty(
|
|
1255
|
+
Object.defineProperty(x, Symbol.hasInstance, {
|
|
1174
1256
|
value: (e) => !!e && e.data != null && e.dataSync != null && e.throwIfDisposed != null
|
|
1175
1257
|
});
|
|
1176
|
-
function
|
|
1177
|
-
return
|
|
1258
|
+
function de() {
|
|
1259
|
+
return Lt("Tensor", () => x);
|
|
1178
1260
|
}
|
|
1179
|
-
|
|
1180
|
-
class
|
|
1261
|
+
de();
|
|
1262
|
+
class mt extends x {
|
|
1181
1263
|
constructor(t, n, s, r) {
|
|
1182
1264
|
super(t.shape, t.dtype, t.dataId, r), this.trainable = n, this.name = s;
|
|
1183
1265
|
}
|
|
@@ -1192,7 +1274,7 @@ class gt extends D {
|
|
|
1192
1274
|
assign(t) {
|
|
1193
1275
|
if (t.dtype !== this.dtype)
|
|
1194
1276
|
throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);
|
|
1195
|
-
if (!
|
|
1277
|
+
if (!xt(t.shape, this.shape))
|
|
1196
1278
|
throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);
|
|
1197
1279
|
R().disposeTensor(this), this.dataId = t.dataId, R().incRef(
|
|
1198
1280
|
this,
|
|
@@ -1204,8 +1286,8 @@ class gt extends D {
|
|
|
1204
1286
|
R().disposeVariable(this), this.isDisposedInternal = !0;
|
|
1205
1287
|
}
|
|
1206
1288
|
}
|
|
1207
|
-
Object.defineProperty(
|
|
1208
|
-
value: (e) => e instanceof
|
|
1289
|
+
Object.defineProperty(mt, Symbol.hasInstance, {
|
|
1290
|
+
value: (e) => e instanceof x && e.assign != null && e.assign instanceof Function
|
|
1209
1291
|
});
|
|
1210
1292
|
/**
|
|
1211
1293
|
* @license
|
|
@@ -1223,33 +1305,33 @@ Object.defineProperty(gt, Symbol.hasInstance, {
|
|
|
1223
1305
|
* limitations under the License.
|
|
1224
1306
|
* =============================================================================
|
|
1225
1307
|
*/
|
|
1226
|
-
var
|
|
1308
|
+
var Kt;
|
|
1227
1309
|
(function(e) {
|
|
1228
1310
|
e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6";
|
|
1229
|
-
})(
|
|
1230
|
-
var Tt;
|
|
1231
|
-
(function(e) {
|
|
1232
|
-
e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64";
|
|
1233
|
-
})(Tt || (Tt = {}));
|
|
1311
|
+
})(Kt || (Kt = {}));
|
|
1234
1312
|
var Et;
|
|
1235
1313
|
(function(e) {
|
|
1236
|
-
e.float32 = "float32", e.int32 = "int32", e.bool = "
|
|
1314
|
+
e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64";
|
|
1237
1315
|
})(Et || (Et = {}));
|
|
1238
1316
|
var At;
|
|
1239
1317
|
(function(e) {
|
|
1240
|
-
e.float32 = "float32", e.int32 = "
|
|
1318
|
+
e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64";
|
|
1241
1319
|
})(At || (At = {}));
|
|
1320
|
+
var vt;
|
|
1321
|
+
(function(e) {
|
|
1322
|
+
e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64";
|
|
1323
|
+
})(vt || (vt = {}));
|
|
1242
1324
|
var Bt;
|
|
1243
1325
|
(function(e) {
|
|
1244
1326
|
e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64";
|
|
1245
1327
|
})(Bt || (Bt = {}));
|
|
1246
1328
|
const pn = {
|
|
1247
|
-
float32:
|
|
1248
|
-
int32:
|
|
1249
|
-
bool:
|
|
1329
|
+
float32: vt,
|
|
1330
|
+
int32: Et,
|
|
1331
|
+
bool: At,
|
|
1250
1332
|
complex64: Bt
|
|
1251
1333
|
};
|
|
1252
|
-
function
|
|
1334
|
+
function fe(e, t) {
|
|
1253
1335
|
if (e === "string" || t === "string") {
|
|
1254
1336
|
if (e === "string" && t === "string")
|
|
1255
1337
|
return "string";
|
|
@@ -1257,8 +1339,8 @@ function de(e, t) {
|
|
|
1257
1339
|
}
|
|
1258
1340
|
return pn[e][t];
|
|
1259
1341
|
}
|
|
1260
|
-
function
|
|
1261
|
-
return
|
|
1342
|
+
function Zo(e) {
|
|
1343
|
+
return fe(e, "int32");
|
|
1262
1344
|
}
|
|
1263
1345
|
function ge(e) {
|
|
1264
1346
|
return e != null && typeof e == "object" && "texture" in e && e.texture instanceof WebGLTexture;
|
|
@@ -1282,13 +1364,13 @@ function me(e) {
|
|
|
1282
1364
|
* limitations under the License.
|
|
1283
1365
|
* =============================================================================
|
|
1284
1366
|
*/
|
|
1285
|
-
function
|
|
1367
|
+
function K(e, t) {
|
|
1286
1368
|
if (e.dtype === t.dtype)
|
|
1287
1369
|
return [e, t];
|
|
1288
|
-
const n =
|
|
1370
|
+
const n = fe(e.dtype, t.dtype);
|
|
1289
1371
|
return [e.cast(n), t.cast(n)];
|
|
1290
1372
|
}
|
|
1291
|
-
function
|
|
1373
|
+
function Qo(e, t) {
|
|
1292
1374
|
return t.some((n) => n.id === e.id);
|
|
1293
1375
|
}
|
|
1294
1376
|
function pe(e) {
|
|
@@ -1298,7 +1380,7 @@ function pe(e) {
|
|
|
1298
1380
|
function ye(e, t, n) {
|
|
1299
1381
|
if (e == null)
|
|
1300
1382
|
return;
|
|
1301
|
-
if (e instanceof
|
|
1383
|
+
if (e instanceof x) {
|
|
1302
1384
|
t.push(e);
|
|
1303
1385
|
return;
|
|
1304
1386
|
}
|
|
@@ -1329,7 +1411,7 @@ function yn(e) {
|
|
|
1329
1411
|
* limitations under the License.
|
|
1330
1412
|
* =============================================================================
|
|
1331
1413
|
*/
|
|
1332
|
-
function
|
|
1414
|
+
function St(e) {
|
|
1333
1415
|
return e.kernelName != null;
|
|
1334
1416
|
}
|
|
1335
1417
|
class Ht {
|
|
@@ -1559,35 +1641,35 @@ class et {
|
|
|
1559
1641
|
let i;
|
|
1560
1642
|
this.backendName == null && this.backend;
|
|
1561
1643
|
let c;
|
|
1562
|
-
const l =
|
|
1563
|
-
if (
|
|
1564
|
-
const { kernelName: p, inputs:
|
|
1644
|
+
const l = St(t) ? t.kernelName : this.state.activeScope != null ? this.state.activeScope.name : "";
|
|
1645
|
+
if (St(t)) {
|
|
1646
|
+
const { kernelName: p, inputs: f, attrs: w } = t;
|
|
1565
1647
|
this.backendName == null && this.backend;
|
|
1566
1648
|
const I = zt(p, this.backendName);
|
|
1567
1649
|
y(I != null, () => `Cannot find registered kernel '${p}' for backend '${this.backendName}'`), i = () => {
|
|
1568
1650
|
const _ = this.backend.numDataIds();
|
|
1569
|
-
c = I.kernelFunc({ inputs:
|
|
1570
|
-
const
|
|
1571
|
-
this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(p, _,
|
|
1572
|
-
const
|
|
1651
|
+
c = I.kernelFunc({ inputs: f, attrs: w, backend: this.backend });
|
|
1652
|
+
const X = Array.isArray(c) ? c : [c];
|
|
1653
|
+
this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(p, _, X);
|
|
1654
|
+
const J = X.map((rt) => rt.rank != null ? rt : this.makeTensorFromTensorInfo(rt));
|
|
1573
1655
|
if (r) {
|
|
1574
|
-
const rt = this.getTensorsForGradient(p,
|
|
1656
|
+
const rt = this.getTensorsForGradient(p, f, J);
|
|
1575
1657
|
s = this.saveTensorsForBackwardMode(rt);
|
|
1576
1658
|
}
|
|
1577
|
-
return
|
|
1659
|
+
return J;
|
|
1578
1660
|
};
|
|
1579
1661
|
} else {
|
|
1580
|
-
const { forwardFunc: p } = t,
|
|
1662
|
+
const { forwardFunc: p } = t, f = (w) => {
|
|
1581
1663
|
r && (s = w.map((I) => this.keep(this.clone(I))));
|
|
1582
1664
|
};
|
|
1583
1665
|
i = () => {
|
|
1584
1666
|
const w = this.backend.numDataIds();
|
|
1585
|
-
c = this.tidy(() => p(this.backend,
|
|
1667
|
+
c = this.tidy(() => p(this.backend, f));
|
|
1586
1668
|
const I = Array.isArray(c) ? c : [c];
|
|
1587
1669
|
return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(l, w, I), I;
|
|
1588
1670
|
};
|
|
1589
1671
|
}
|
|
1590
|
-
const { inputs: u, attrs: h } = t,
|
|
1672
|
+
const { inputs: u, attrs: h } = t, d = St(t) ? null : t.backwardsFunc;
|
|
1591
1673
|
let m;
|
|
1592
1674
|
return this.scopedRun(
|
|
1593
1675
|
// Stop recording to a tape when running a kernel.
|
|
@@ -1596,7 +1678,7 @@ class et {
|
|
|
1596
1678
|
() => {
|
|
1597
1679
|
!this.ENV.getBool("DEBUG") && !this.state.profiling ? n = i() : (m = this.profiler.profileKernel(l, u, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(m), n = m.outputs);
|
|
1598
1680
|
}
|
|
1599
|
-
), r && this.addTapeNode(l, u, n,
|
|
1681
|
+
), r && this.addTapeNode(l, u, n, d, s, h), this.state.profiling && this.state.activeProfile.kernels.push({
|
|
1600
1682
|
name: l,
|
|
1601
1683
|
bytesAdded: this.state.numBytes - a,
|
|
1602
1684
|
totalBytesSnapshot: this.state.numBytes,
|
|
@@ -1644,8 +1726,8 @@ class et {
|
|
|
1644
1726
|
throw new Error("Values passed to engine.makeTensor() are null");
|
|
1645
1727
|
s = s || "float32", r = r || this.backend;
|
|
1646
1728
|
let a = t;
|
|
1647
|
-
s === "string" &&
|
|
1648
|
-
const o = r.write(a, n, s), i = new
|
|
1729
|
+
s === "string" && Nt(t[0]) && (a = t.map((c) => ue(c)));
|
|
1730
|
+
const o = r.write(a, n, s), i = new x(n, s, o, this.nextTensorId());
|
|
1649
1731
|
if (this.trackTensor(i, r), s === "string") {
|
|
1650
1732
|
const c = this.state.tensorInfo.get(o), l = Le(a);
|
|
1651
1733
|
this.state.numBytes += l - c.bytes, c.bytes = l;
|
|
@@ -1669,12 +1751,12 @@ class et {
|
|
|
1669
1751
|
* only increments the ref count used in memory tracking.
|
|
1670
1752
|
*/
|
|
1671
1753
|
makeTensorFromTensorInfo(t, n) {
|
|
1672
|
-
const { dataId: s, shape: r, dtype: a } = t, o = new
|
|
1754
|
+
const { dataId: s, shape: r, dtype: a } = t, o = new x(r, a, s, this.nextTensorId());
|
|
1673
1755
|
return this.trackTensor(o, n), o;
|
|
1674
1756
|
}
|
|
1675
1757
|
makeVariable(t, n = !0, s, r) {
|
|
1676
1758
|
s = s || this.nextVariableId().toString(), r != null && r !== t.dtype && (t = t.cast(r));
|
|
1677
|
-
const a = new
|
|
1759
|
+
const a = new mt(t, n, s, this.nextTensorId());
|
|
1678
1760
|
if (this.state.registeredVariables[a.name] != null)
|
|
1679
1761
|
throw new Error(`Variable with name ${a.name} was already registered`);
|
|
1680
1762
|
return this.state.registeredVariables[a.name] = a, this.incRef(a, this.backend), a;
|
|
@@ -1682,12 +1764,12 @@ class et {
|
|
|
1682
1764
|
trackTensor(t, n) {
|
|
1683
1765
|
this.state.numTensors++, t.dtype === "string" && this.state.numStringTensors++;
|
|
1684
1766
|
let s = 0;
|
|
1685
|
-
t.dtype !== "complex64" && t.dtype !== "string" && (s = t.size *
|
|
1767
|
+
t.dtype !== "complex64" && t.dtype !== "string" && (s = t.size * It(t.dtype)), this.state.numBytes += s, this.state.tensorInfo.has(t.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(t.dataId, {
|
|
1686
1768
|
backend: n || this.backend,
|
|
1687
1769
|
dtype: t.dtype,
|
|
1688
1770
|
shape: t.shape,
|
|
1689
1771
|
bytes: s
|
|
1690
|
-
})), t instanceof
|
|
1772
|
+
})), t instanceof mt || this.track(t);
|
|
1691
1773
|
}
|
|
1692
1774
|
// Track the tensor by dataId and increase the refCount for the dataId in the
|
|
1693
1775
|
// backend.
|
|
@@ -1705,7 +1787,7 @@ class et {
|
|
|
1705
1787
|
return;
|
|
1706
1788
|
const n = this.state.tensorInfo.get(t.dataId);
|
|
1707
1789
|
if (this.state.numTensors--, t.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= n.bytes), t.dtype !== "complex64" && t.dtype !== "string") {
|
|
1708
|
-
const s = t.size *
|
|
1790
|
+
const s = t.size * It(t.dtype);
|
|
1709
1791
|
this.state.numBytes -= s;
|
|
1710
1792
|
}
|
|
1711
1793
|
n.backend.disposeData(t.dataId) && this.removeDataId(t.dataId, n.backend);
|
|
@@ -1738,8 +1820,8 @@ class et {
|
|
|
1738
1820
|
const i = { id: this.state.nextTapeNodeId++, kernelName: t, inputs: n, outputs: s, saved: a }, c = Vt(t);
|
|
1739
1821
|
c != null && (r = c.gradFunc), r != null && (i.gradient = (l) => (l = l.map((u, h) => {
|
|
1740
1822
|
if (u == null) {
|
|
1741
|
-
const
|
|
1742
|
-
return this.makeTensor(m,
|
|
1823
|
+
const d = s[h], m = ne(d.size, d.dtype);
|
|
1824
|
+
return this.makeTensor(m, d.shape, d.dtype);
|
|
1743
1825
|
}
|
|
1744
1826
|
return u;
|
|
1745
1827
|
}), r(l.length > 1 ? l : l[0], a, o))), this.state.activeTape.push(i);
|
|
@@ -1790,7 +1872,7 @@ class et {
|
|
|
1790
1872
|
if (y(n.length > 0, () => "gradients() received an empty list of xs."), s != null && s.dtype !== "float32")
|
|
1791
1873
|
throw new Error(`dy must have 'float32' dtype, but has '${s.dtype}'`);
|
|
1792
1874
|
const a = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", t));
|
|
1793
|
-
y(a instanceof
|
|
1875
|
+
y(a instanceof x, () => "The result y returned by f() must be a tensor.");
|
|
1794
1876
|
const o = ln(this.state.activeTape, n, a);
|
|
1795
1877
|
if (!r && o.length === 0 && n.length > 0)
|
|
1796
1878
|
throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");
|
|
@@ -1812,19 +1894,19 @@ class et {
|
|
|
1812
1894
|
});
|
|
1813
1895
|
}
|
|
1814
1896
|
customGrad(t) {
|
|
1815
|
-
return y(
|
|
1816
|
-
y(n.every((i) => i instanceof
|
|
1897
|
+
return y(dt(t), () => "The f passed in customGrad(f) must be a function."), (...n) => {
|
|
1898
|
+
y(n.every((i) => i instanceof x), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors");
|
|
1817
1899
|
let s;
|
|
1818
1900
|
const r = {};
|
|
1819
1901
|
n.forEach((i, c) => {
|
|
1820
1902
|
r[c] = i;
|
|
1821
1903
|
});
|
|
1822
|
-
const a = (i, c) => (s = t(...n, c), y(s.value instanceof
|
|
1904
|
+
const a = (i, c) => (s = t(...n, c), y(s.value instanceof x, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), y(dt(s.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), s.value), o = (i, c) => {
|
|
1823
1905
|
const l = s.gradFunc(i, c), u = Array.isArray(l) ? l : [l];
|
|
1824
|
-
y(u.length === n.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), y(u.every((
|
|
1906
|
+
y(u.length === n.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), y(u.every((d) => d instanceof x), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");
|
|
1825
1907
|
const h = {};
|
|
1826
|
-
return u.forEach((
|
|
1827
|
-
h[m] = () =>
|
|
1908
|
+
return u.forEach((d, m) => {
|
|
1909
|
+
h[m] = () => d;
|
|
1828
1910
|
}), h;
|
|
1829
1911
|
};
|
|
1830
1912
|
return this.runKernelFunc({
|
|
@@ -1844,8 +1926,8 @@ class et {
|
|
|
1844
1926
|
return this.state.tensorInfo.get(t).backend.readToGPU(t, n);
|
|
1845
1927
|
}
|
|
1846
1928
|
async time(t) {
|
|
1847
|
-
const n =
|
|
1848
|
-
return s.wallMs =
|
|
1929
|
+
const n = gt(), s = await this.backend.time(t);
|
|
1930
|
+
return s.wallMs = gt() - n, s;
|
|
1849
1931
|
}
|
|
1850
1932
|
/**
|
|
1851
1933
|
* Tracks a Tensor in the current scope to be automatically cleaned up
|
|
@@ -1906,25 +1988,43 @@ function wn(e, t) {
|
|
|
1906
1988
|
* =============================================================================
|
|
1907
1989
|
*/
|
|
1908
1990
|
function Sn() {
|
|
1991
|
+
return typeof navigator < "u" && navigator != null;
|
|
1992
|
+
}
|
|
1993
|
+
function ti(e) {
|
|
1994
|
+
if (e || Sn()) {
|
|
1995
|
+
if (e || (e = navigator), e.product === "ReactNative")
|
|
1996
|
+
return !0;
|
|
1997
|
+
const t = e.userAgent || e.vendor || // tslint:disable-next-line:no-any
|
|
1998
|
+
(typeof window < "u" ? window.opera : "");
|
|
1999
|
+
if (!t) {
|
|
2000
|
+
const n = e;
|
|
2001
|
+
return n.userAgentData && n.userAgentData.mobile;
|
|
2002
|
+
}
|
|
2003
|
+
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t) || // tslint:disable-next-line:max-line-length
|
|
2004
|
+
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4));
|
|
2005
|
+
}
|
|
2006
|
+
return !1;
|
|
2007
|
+
}
|
|
2008
|
+
function kn() {
|
|
1909
2009
|
return typeof window < "u" && window.document != null || //@ts-ignore
|
|
1910
2010
|
typeof WorkerGlobalScope < "u";
|
|
1911
2011
|
}
|
|
1912
|
-
const
|
|
1913
|
-
|
|
2012
|
+
const v = S();
|
|
2013
|
+
v.registerFlag("DEBUG", () => !1, (e) => {
|
|
1914
2014
|
e && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.");
|
|
1915
2015
|
});
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
2016
|
+
v.registerFlag("IS_BROWSER", () => kn());
|
|
2017
|
+
v.registerFlag("IS_NODE", () => typeof Q < "u" && typeof Q.versions < "u" && typeof Q.versions.node < "u");
|
|
2018
|
+
v.registerFlag("IS_CHROME", () => typeof navigator < "u" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
|
|
2019
|
+
v.registerFlag("IS_SAFARI", () => typeof navigator < "u" && navigator != null && navigator.userAgent != null && /Safari/.test(navigator.userAgent) && /Apple/.test(navigator.vendor));
|
|
2020
|
+
v.registerFlag("PROD", () => !1);
|
|
2021
|
+
v.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", () => v.getBool("DEBUG"));
|
|
2022
|
+
v.registerFlag("DEPRECATION_WARNINGS_ENABLED", () => !0);
|
|
2023
|
+
v.registerFlag("IS_TEST", () => !1);
|
|
2024
|
+
v.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", () => v.getBool("DEBUG"));
|
|
2025
|
+
v.registerFlag("WRAP_TO_IMAGEBITMAP", () => !1);
|
|
2026
|
+
v.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU", () => !1);
|
|
2027
|
+
v.registerFlag("USE_SETTIMEOUTCUSTOM", () => !1);
|
|
1928
2028
|
/**
|
|
1929
2029
|
* @license
|
|
1930
2030
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -1941,7 +2041,7 @@ B.registerFlag("USE_SETTIMEOUTCUSTOM", () => !1);
|
|
|
1941
2041
|
* limitations under the License.
|
|
1942
2042
|
* =============================================================================
|
|
1943
2043
|
*/
|
|
1944
|
-
function
|
|
2044
|
+
function In(e, t) {
|
|
1945
2045
|
let n = e;
|
|
1946
2046
|
if (F(e))
|
|
1947
2047
|
return t === "string" ? [] : [e.length];
|
|
@@ -1949,13 +2049,13 @@ function kn(e, t) {
|
|
|
1949
2049
|
const r = e.channels || "RGBA";
|
|
1950
2050
|
return [e.height, e.width * r.length];
|
|
1951
2051
|
} else if (me(e))
|
|
1952
|
-
return [e.buffer.size / (t == null ? 4 :
|
|
2052
|
+
return [e.buffer.size / (t == null ? 4 : It(t))];
|
|
1953
2053
|
if (!Array.isArray(e))
|
|
1954
2054
|
return [];
|
|
1955
2055
|
const s = [];
|
|
1956
2056
|
for (; Array.isArray(n) || F(n) && t !== "string"; )
|
|
1957
2057
|
s.push(n.length), n = n[0];
|
|
1958
|
-
return Array.isArray(e) &&
|
|
2058
|
+
return Array.isArray(e) && S().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && we(e, s, []), s;
|
|
1959
2059
|
}
|
|
1960
2060
|
function we(e, t, n) {
|
|
1961
2061
|
if (n = n || [], !Array.isArray(e) && !F(e)) {
|
|
@@ -1967,7 +2067,7 @@ function we(e, t, n) {
|
|
|
1967
2067
|
for (let r = 0; r < e.length; ++r)
|
|
1968
2068
|
we(e[r], s, n.concat(r));
|
|
1969
2069
|
}
|
|
1970
|
-
function
|
|
2070
|
+
function Xt(e, t, n, s) {
|
|
1971
2071
|
if (e !== "string_or_numeric") {
|
|
1972
2072
|
if (e == null)
|
|
1973
2073
|
throw new Error("Expected dtype cannot be null.");
|
|
@@ -1976,19 +2076,19 @@ function Jt(e, t, n, s) {
|
|
|
1976
2076
|
}
|
|
1977
2077
|
}
|
|
1978
2078
|
function T(e, t, n, s = "numeric") {
|
|
1979
|
-
if (e instanceof
|
|
1980
|
-
return
|
|
1981
|
-
let r =
|
|
1982
|
-
if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s),
|
|
2079
|
+
if (e instanceof de())
|
|
2080
|
+
return Xt(s, e.dtype, t, n), e;
|
|
2081
|
+
let r = yt(e);
|
|
2082
|
+
if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), Xt(s, r, t, n), e == null || !F(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") {
|
|
1983
2083
|
const c = e == null ? "null" : e.constructor.name;
|
|
1984
2084
|
throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${c}'`);
|
|
1985
2085
|
}
|
|
1986
|
-
const a =
|
|
2086
|
+
const a = In(e, r);
|
|
1987
2087
|
!F(e) && !Array.isArray(e) && (e = [e]);
|
|
1988
|
-
const i = r !== "string" ?
|
|
2088
|
+
const i = r !== "string" ? _t(e, r) : lt(e, [], !0);
|
|
1989
2089
|
return g.makeTensor(i, a, r);
|
|
1990
2090
|
}
|
|
1991
|
-
function
|
|
2091
|
+
function Tn(e, t, n, s = "numeric") {
|
|
1992
2092
|
if (!Array.isArray(e))
|
|
1993
2093
|
throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);
|
|
1994
2094
|
return e.map((a, o) => T(a, `${t}[${o}]`, n, s));
|
|
@@ -2009,19 +2109,19 @@ function In(e, t, n, s = "numeric") {
|
|
|
2009
2109
|
* limitations under the License.
|
|
2010
2110
|
* =============================================================================
|
|
2011
2111
|
*/
|
|
2012
|
-
const
|
|
2013
|
-
function
|
|
2112
|
+
const En = "__op";
|
|
2113
|
+
function D(e) {
|
|
2014
2114
|
const t = Object.keys(e);
|
|
2015
2115
|
if (t.length !== 1)
|
|
2016
2116
|
throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);
|
|
2017
2117
|
let n = t[0];
|
|
2018
2118
|
const s = e[n];
|
|
2019
|
-
n.endsWith("_") && (n = n.substring(0, n.length - 1)), n = n +
|
|
2119
|
+
n.endsWith("_") && (n = n.substring(0, n.length - 1)), n = n + En;
|
|
2020
2120
|
const r = (...a) => {
|
|
2021
2121
|
g.startScope(n);
|
|
2022
2122
|
try {
|
|
2023
2123
|
const o = s(...a);
|
|
2024
|
-
return
|
|
2124
|
+
return Pt(o) && console.error("Cannot return a Promise inside of tidy."), g.endScope(o), o;
|
|
2025
2125
|
} catch (o) {
|
|
2026
2126
|
throw g.endScope(null), o;
|
|
2027
2127
|
}
|
|
@@ -2044,9 +2144,9 @@ function N(e) {
|
|
|
2044
2144
|
* limitations under the License.
|
|
2045
2145
|
* =============================================================================
|
|
2046
2146
|
*/
|
|
2047
|
-
function
|
|
2147
|
+
function An(e, t, n, s) {
|
|
2048
2148
|
if (s == null)
|
|
2049
|
-
s =
|
|
2149
|
+
s = yt(e);
|
|
2050
2150
|
else if (s === "complex64")
|
|
2051
2151
|
throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
|
|
2052
2152
|
if (me(e) || ge(e)) {
|
|
@@ -2057,7 +2157,7 @@ function En(e, t, n, s) {
|
|
|
2057
2157
|
if (!F(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string")
|
|
2058
2158
|
throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");
|
|
2059
2159
|
if (t != null) {
|
|
2060
|
-
|
|
2160
|
+
Ct(t);
|
|
2061
2161
|
const r = z(t), a = z(n);
|
|
2062
2162
|
y(r === a, () => `Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);
|
|
2063
2163
|
for (let o = 0; o < n.length; ++o) {
|
|
@@ -2065,7 +2165,7 @@ function En(e, t, n, s) {
|
|
|
2065
2165
|
y(n[o] === t[o] || !c, () => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `);
|
|
2066
2166
|
}
|
|
2067
2167
|
}
|
|
2068
|
-
return !F(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ?
|
|
2168
|
+
return !F(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? _t(e, s) : lt(e, [], !0), g.makeTensor(e, t, s);
|
|
2069
2169
|
}
|
|
2070
2170
|
class st {
|
|
2071
2171
|
/**
|
|
@@ -2102,8 +2202,8 @@ class st {
|
|
|
2102
2202
|
const r = n - t, a = new ArrayBuffer(r), o = new Uint8Array(a);
|
|
2103
2203
|
let i = 0;
|
|
2104
2204
|
for (let c = s; c < this.shards.length; c++) {
|
|
2105
|
-
const l = this.shards[c], h = t + i - l.start,
|
|
2106
|
-
if (o.set(
|
|
2205
|
+
const l = this.shards[c], h = t + i - l.start, d = i, p = Math.min(n, l.end) - l.start, f = new Uint8Array(l.buffer, h, p - h);
|
|
2206
|
+
if (o.set(f, d), i += f.length, n < l.end)
|
|
2107
2207
|
break;
|
|
2108
2208
|
}
|
|
2109
2209
|
return a;
|
|
@@ -2121,11 +2221,11 @@ class st {
|
|
|
2121
2221
|
}
|
|
2122
2222
|
if (n(this.shards[this.previousShardIndex]) === 0)
|
|
2123
2223
|
return this.previousShardIndex;
|
|
2124
|
-
const s =
|
|
2224
|
+
const s = vn(this.shards, n);
|
|
2125
2225
|
return s === -1 ? -1 : (this.previousShardIndex = s, this.previousShardIndex);
|
|
2126
2226
|
}
|
|
2127
2227
|
}
|
|
2128
|
-
function
|
|
2228
|
+
function vn(e, t) {
|
|
2129
2229
|
let n = 0, s = e.length;
|
|
2130
2230
|
for (; n <= s; ) {
|
|
2131
2231
|
const r = Math.floor((s - n) / 2) + n, a = t(e[r]);
|
|
@@ -2151,13 +2251,13 @@ function An(e, t) {
|
|
|
2151
2251
|
* limitations under the License.
|
|
2152
2252
|
* =============================================================================
|
|
2153
2253
|
*/
|
|
2154
|
-
function
|
|
2254
|
+
function ei() {
|
|
2155
2255
|
g.disposeVariables();
|
|
2156
2256
|
}
|
|
2157
|
-
function
|
|
2257
|
+
function ni() {
|
|
2158
2258
|
return g;
|
|
2159
2259
|
}
|
|
2160
|
-
function
|
|
2260
|
+
function si() {
|
|
2161
2261
|
return g.memory();
|
|
2162
2262
|
}
|
|
2163
2263
|
function E(e, t) {
|
|
@@ -2169,11 +2269,14 @@ function M(e) {
|
|
|
2169
2269
|
function Bn(e) {
|
|
2170
2270
|
return g.keep(e);
|
|
2171
2271
|
}
|
|
2172
|
-
function
|
|
2272
|
+
function ri(e, t, n = 1) {
|
|
2273
|
+
return g.registerBackend(e, t, n);
|
|
2274
|
+
}
|
|
2275
|
+
function ai() {
|
|
2173
2276
|
return g.backend;
|
|
2174
2277
|
}
|
|
2175
|
-
const
|
|
2176
|
-
async function
|
|
2278
|
+
const Jt = 4;
|
|
2279
|
+
async function oi(e, t) {
|
|
2177
2280
|
const n = [], s = [], r = Array.isArray(e) ? e.map((o) => o.name) : Object.keys(e);
|
|
2178
2281
|
for (let o = 0; o < r.length; ++o) {
|
|
2179
2282
|
const i = r[o], c = Array.isArray(e) ? e[o].tensor : e[i];
|
|
@@ -2182,11 +2285,11 @@ async function bo(e, t) {
|
|
|
2182
2285
|
const l = { name: i, shape: c.shape, dtype: c.dtype };
|
|
2183
2286
|
if (c.dtype === "string") {
|
|
2184
2287
|
const u = new Promise(async (h) => {
|
|
2185
|
-
const
|
|
2186
|
-
let
|
|
2187
|
-
for (let w = 0; w <
|
|
2188
|
-
const I =
|
|
2189
|
-
p.set(_,
|
|
2288
|
+
const d = await c.bytes(), m = d.reduce((w, I) => w + I.length, 0) + Jt * d.length, p = new Uint8Array(m);
|
|
2289
|
+
let f = 0;
|
|
2290
|
+
for (let w = 0; w < d.length; w++) {
|
|
2291
|
+
const I = d[w], _ = new Uint8Array(new Uint32Array([I.length]).buffer);
|
|
2292
|
+
p.set(_, f), f += Jt, p.set(I, f), f += I.length;
|
|
2190
2293
|
}
|
|
2191
2294
|
h(p);
|
|
2192
2295
|
});
|
|
@@ -2196,9 +2299,9 @@ async function bo(e, t) {
|
|
|
2196
2299
|
t != null && (l.group = t), n.push(l);
|
|
2197
2300
|
}
|
|
2198
2301
|
const a = await Promise.all(s);
|
|
2199
|
-
return { data:
|
|
2302
|
+
return { data: Mn(a), specs: n };
|
|
2200
2303
|
}
|
|
2201
|
-
function
|
|
2304
|
+
function Mn(e) {
|
|
2202
2305
|
if (e === null)
|
|
2203
2306
|
throw new Error(`Invalid input value: ${JSON.stringify(e)}`);
|
|
2204
2307
|
let t = 0;
|
|
@@ -2213,22 +2316,22 @@ function vn(e) {
|
|
|
2213
2316
|
s.set(new Uint8Array(a.buffer), r), r += a.byteLength;
|
|
2214
2317
|
}), s.buffer;
|
|
2215
2318
|
}
|
|
2216
|
-
const
|
|
2319
|
+
const Ot = typeof pt < "u" && (typeof Blob > "u" || typeof atob > "u" || typeof btoa > "u");
|
|
2217
2320
|
function Yt(e) {
|
|
2218
|
-
return
|
|
2321
|
+
return Ot ? pt.byteLength(e, "utf8") : new Blob([e]).size;
|
|
2219
2322
|
}
|
|
2220
|
-
function
|
|
2221
|
-
if (
|
|
2222
|
-
return
|
|
2323
|
+
function Dn(e) {
|
|
2324
|
+
if (Ot)
|
|
2325
|
+
return pt.from(e).toString("base64");
|
|
2223
2326
|
const t = new Uint8Array(e);
|
|
2224
2327
|
let n = "";
|
|
2225
2328
|
for (let s = 0, r = t.length; s < r; s++)
|
|
2226
2329
|
n += String.fromCharCode(t[s]);
|
|
2227
2330
|
return btoa(n);
|
|
2228
2331
|
}
|
|
2229
|
-
function
|
|
2230
|
-
if (
|
|
2231
|
-
const s =
|
|
2332
|
+
function Fn(e) {
|
|
2333
|
+
if (Ot) {
|
|
2334
|
+
const s = pt.from(e, "base64");
|
|
2232
2335
|
return s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength);
|
|
2233
2336
|
}
|
|
2234
2337
|
const t = atob(e), n = new Uint8Array(t.length);
|
|
@@ -2236,9 +2339,39 @@ function Nn(e) {
|
|
|
2236
2339
|
n.set([t.charCodeAt(s)], s);
|
|
2237
2340
|
return n.buffer;
|
|
2238
2341
|
}
|
|
2239
|
-
function
|
|
2342
|
+
function ii(e) {
|
|
2240
2343
|
return st.join(e);
|
|
2241
2344
|
}
|
|
2345
|
+
function ci(e, t) {
|
|
2346
|
+
const n = {
|
|
2347
|
+
modelTopology: e.modelTopology,
|
|
2348
|
+
format: e.format,
|
|
2349
|
+
generatedBy: e.generatedBy,
|
|
2350
|
+
convertedBy: e.convertedBy,
|
|
2351
|
+
weightsManifest: t
|
|
2352
|
+
};
|
|
2353
|
+
return e.signature != null && (n.signature = e.signature), e.userDefinedMetadata != null && (n.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (n.modelInitializer = e.modelInitializer), e.initializerSignature != null && (n.initializerSignature = e.initializerSignature), e.trainingConfig != null && (n.trainingConfig = e.trainingConfig), n;
|
|
2354
|
+
}
|
|
2355
|
+
function Rn(e, t, n) {
|
|
2356
|
+
const s = {
|
|
2357
|
+
modelTopology: e.modelTopology,
|
|
2358
|
+
format: e.format,
|
|
2359
|
+
generatedBy: e.generatedBy,
|
|
2360
|
+
convertedBy: e.convertedBy
|
|
2361
|
+
};
|
|
2362
|
+
if (e.trainingConfig != null && (s.trainingConfig = e.trainingConfig), e.weightsManifest != null) {
|
|
2363
|
+
if (!t)
|
|
2364
|
+
throw new Error("modelJSON has weightsManifest but weightSpecs is null");
|
|
2365
|
+
if (!n)
|
|
2366
|
+
throw new Error("modelJSON has weightsManifest but weightData is null");
|
|
2367
|
+
s.weightSpecs = t, s.weightData = n;
|
|
2368
|
+
}
|
|
2369
|
+
return e.signature != null && (s.signature = e.signature), e.userDefinedMetadata != null && (s.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (s.modelInitializer = e.modelInitializer), e.initializerSignature != null && (s.initializerSignature = e.initializerSignature), s;
|
|
2370
|
+
}
|
|
2371
|
+
async function li(e, t) {
|
|
2372
|
+
let n, s;
|
|
2373
|
+
return e.weightsManifest != null && ([n, s] = await t(e.weightsManifest)), Rn(e, n, s);
|
|
2374
|
+
}
|
|
2242
2375
|
function Se(e) {
|
|
2243
2376
|
if (e.modelTopology instanceof ArrayBuffer)
|
|
2244
2377
|
throw new Error("Expected JSON model topology, received ArrayBuffer.");
|
|
@@ -2250,6 +2383,12 @@ function Se(e) {
|
|
|
2250
2383
|
weightDataBytes: e.weightData == null ? 0 : new st(e.weightData).byteLength
|
|
2251
2384
|
};
|
|
2252
2385
|
}
|
|
2386
|
+
function ui(e) {
|
|
2387
|
+
const t = [];
|
|
2388
|
+
for (const n of e)
|
|
2389
|
+
t.push(...n.weights);
|
|
2390
|
+
return t;
|
|
2391
|
+
}
|
|
2253
2392
|
/**
|
|
2254
2393
|
* @license
|
|
2255
2394
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -2321,7 +2460,7 @@ class A {
|
|
|
2321
2460
|
}), r;
|
|
2322
2461
|
}
|
|
2323
2462
|
}
|
|
2324
|
-
const
|
|
2463
|
+
const hi = (e) => A.getSaveHandlers(e);
|
|
2325
2464
|
/**
|
|
2326
2465
|
* @license
|
|
2327
2466
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -2338,16 +2477,16 @@ const So = (e) => A.getSaveHandlers(e);
|
|
|
2338
2477
|
* limitations under the License.
|
|
2339
2478
|
* =============================================================================
|
|
2340
2479
|
*/
|
|
2341
|
-
const
|
|
2480
|
+
const Mt = "tensorflowjs", Dt = 1, U = "models_store", L = "model_info_store";
|
|
2342
2481
|
function ke() {
|
|
2343
|
-
if (!
|
|
2482
|
+
if (!S().getBool("IS_BROWSER"))
|
|
2344
2483
|
throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");
|
|
2345
2484
|
const e = typeof window > "u" ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB;
|
|
2346
2485
|
if (t == null)
|
|
2347
2486
|
throw new Error("The current browser does not appear to support IndexedDB.");
|
|
2348
2487
|
return t;
|
|
2349
2488
|
}
|
|
2350
|
-
function
|
|
2489
|
+
function Ft(e) {
|
|
2351
2490
|
const t = e.result;
|
|
2352
2491
|
t.createObjectStore(U, { keyPath: "modelPath" }), t.createObjectStore(L, { keyPath: "modelPath" });
|
|
2353
2492
|
}
|
|
@@ -2381,8 +2520,8 @@ class W {
|
|
|
2381
2520
|
*/
|
|
2382
2521
|
databaseAction(t, n) {
|
|
2383
2522
|
return new Promise((s, r) => {
|
|
2384
|
-
const a = this.indexedDB.open(
|
|
2385
|
-
a.onupgradeneeded = () =>
|
|
2523
|
+
const a = this.indexedDB.open(Mt, Dt);
|
|
2524
|
+
a.onupgradeneeded = () => Ft(a), a.onsuccess = () => {
|
|
2386
2525
|
const o = a.result;
|
|
2387
2526
|
if (n == null) {
|
|
2388
2527
|
const i = o.transaction(U, "readonly"), l = i.objectStore(U).get(this.modelPath);
|
|
@@ -2397,16 +2536,16 @@ class W {
|
|
|
2397
2536
|
let l = c.objectStore(L), u;
|
|
2398
2537
|
try {
|
|
2399
2538
|
u = l.put({ modelPath: this.modelPath, modelArtifactsInfo: i });
|
|
2400
|
-
} catch (
|
|
2401
|
-
return r(
|
|
2539
|
+
} catch (d) {
|
|
2540
|
+
return r(d);
|
|
2402
2541
|
}
|
|
2403
2542
|
let h;
|
|
2404
2543
|
u.onsuccess = () => {
|
|
2405
2544
|
h = o.transaction(U, "readwrite");
|
|
2406
|
-
const
|
|
2545
|
+
const d = h.objectStore(U);
|
|
2407
2546
|
let m;
|
|
2408
2547
|
try {
|
|
2409
|
-
m =
|
|
2548
|
+
m = d.put({
|
|
2410
2549
|
modelPath: this.modelPath,
|
|
2411
2550
|
modelArtifacts: n,
|
|
2412
2551
|
modelArtifactsInfo: i
|
|
@@ -2416,10 +2555,10 @@ class W {
|
|
|
2416
2555
|
}
|
|
2417
2556
|
m.onsuccess = () => s({ modelArtifactsInfo: i }), m.onerror = (p) => {
|
|
2418
2557
|
l = c.objectStore(L);
|
|
2419
|
-
const
|
|
2420
|
-
|
|
2558
|
+
const f = l.delete(this.modelPath);
|
|
2559
|
+
f.onsuccess = () => (o.close(), r(m.error)), f.onerror = (w) => (o.close(), r(m.error));
|
|
2421
2560
|
};
|
|
2422
|
-
}, u.onerror = (
|
|
2561
|
+
}, u.onerror = (d) => (o.close(), r(u.error)), c.oncomplete = () => {
|
|
2423
2562
|
h == null ? o.close() : h.oncomplete = () => o.close();
|
|
2424
2563
|
};
|
|
2425
2564
|
}
|
|
@@ -2428,23 +2567,23 @@ class W {
|
|
|
2428
2567
|
}
|
|
2429
2568
|
}
|
|
2430
2569
|
W.URL_SCHEME = "indexeddb://";
|
|
2431
|
-
const Ie = (e) =>
|
|
2570
|
+
const Ie = (e) => S().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(W.URL_SCHEME) ? xn(e.slice(W.URL_SCHEME.length)) : null;
|
|
2432
2571
|
A.registerSaveRouter(Ie);
|
|
2433
2572
|
A.registerLoadRouter(Ie);
|
|
2434
|
-
function
|
|
2573
|
+
function xn(e) {
|
|
2435
2574
|
return new W(e);
|
|
2436
2575
|
}
|
|
2437
|
-
function
|
|
2576
|
+
function Nn(e) {
|
|
2438
2577
|
return e.startsWith(W.URL_SCHEME) ? e.slice(W.URL_SCHEME.length) : e;
|
|
2439
2578
|
}
|
|
2440
|
-
class
|
|
2579
|
+
class $n {
|
|
2441
2580
|
constructor() {
|
|
2442
2581
|
this.indexedDB = ke();
|
|
2443
2582
|
}
|
|
2444
2583
|
async listModels() {
|
|
2445
2584
|
return new Promise((t, n) => {
|
|
2446
|
-
const s = this.indexedDB.open(
|
|
2447
|
-
s.onupgradeneeded = () =>
|
|
2585
|
+
const s = this.indexedDB.open(Mt, Dt);
|
|
2586
|
+
s.onupgradeneeded = () => Ft(s), s.onsuccess = () => {
|
|
2448
2587
|
const r = s.result, a = r.transaction(L, "readonly"), i = a.objectStore(L).getAll();
|
|
2449
2588
|
i.onsuccess = () => {
|
|
2450
2589
|
const c = {};
|
|
@@ -2456,9 +2595,9 @@ class Dn {
|
|
|
2456
2595
|
});
|
|
2457
2596
|
}
|
|
2458
2597
|
async removeModel(t) {
|
|
2459
|
-
return t =
|
|
2460
|
-
const r = this.indexedDB.open(
|
|
2461
|
-
r.onupgradeneeded = () =>
|
|
2598
|
+
return t = Nn(t), new Promise((n, s) => {
|
|
2599
|
+
const r = this.indexedDB.open(Mt, Dt);
|
|
2600
|
+
r.onupgradeneeded = () => Ft(r), r.onsuccess = () => {
|
|
2462
2601
|
const a = r.result, o = a.transaction(L, "readwrite"), i = o.objectStore(L), c = i.get(t);
|
|
2463
2602
|
let l;
|
|
2464
2603
|
c.onsuccess = () => {
|
|
@@ -2470,7 +2609,7 @@ class Dn {
|
|
|
2470
2609
|
const m = l.objectStore(U).delete(t);
|
|
2471
2610
|
m.onsuccess = () => n(c.result.modelArtifactsInfo), m.onerror = (p) => s(c.error);
|
|
2472
2611
|
};
|
|
2473
|
-
u.onsuccess = h, u.onerror = (
|
|
2612
|
+
u.onsuccess = h, u.onerror = (d) => (h(), a.close(), s(c.error));
|
|
2474
2613
|
}
|
|
2475
2614
|
}, c.onerror = (u) => (a.close(), s(c.error)), o.oncomplete = () => {
|
|
2476
2615
|
l == null ? a.close() : l.oncomplete = () => a.close();
|
|
@@ -2495,32 +2634,32 @@ class Dn {
|
|
|
2495
2634
|
* limitations under the License.
|
|
2496
2635
|
* =============================================================================
|
|
2497
2636
|
*/
|
|
2498
|
-
const P = "/",
|
|
2637
|
+
const P = "/", Z = "tensorflowjs_models", Te = "info", Cn = "model_topology", Pn = "weight_specs", Ln = "weight_data", _n = "model_metadata";
|
|
2499
2638
|
function Ee(e) {
|
|
2500
2639
|
return {
|
|
2501
|
-
info: [
|
|
2502
|
-
topology: [
|
|
2503
|
-
weightSpecs: [
|
|
2504
|
-
weightData: [
|
|
2505
|
-
modelMetadata: [
|
|
2640
|
+
info: [Z, e, Te].join(P),
|
|
2641
|
+
topology: [Z, e, Cn].join(P),
|
|
2642
|
+
weightSpecs: [Z, e, Pn].join(P),
|
|
2643
|
+
weightData: [Z, e, Ln].join(P),
|
|
2644
|
+
modelMetadata: [Z, e, _n].join(P)
|
|
2506
2645
|
};
|
|
2507
2646
|
}
|
|
2508
2647
|
function Ae(e) {
|
|
2509
2648
|
for (const t of Object.values(e))
|
|
2510
2649
|
window.localStorage.removeItem(t);
|
|
2511
2650
|
}
|
|
2512
|
-
function
|
|
2651
|
+
function On(e) {
|
|
2513
2652
|
const t = e.split(P);
|
|
2514
2653
|
if (t.length < 3)
|
|
2515
2654
|
throw new Error(`Invalid key format: ${e}`);
|
|
2516
2655
|
return t.slice(1, t.length - 1).join(P);
|
|
2517
2656
|
}
|
|
2518
|
-
function
|
|
2657
|
+
function Gn(e) {
|
|
2519
2658
|
return e.startsWith(j.URL_SCHEME) ? e.slice(j.URL_SCHEME.length) : e;
|
|
2520
2659
|
}
|
|
2521
2660
|
class j {
|
|
2522
2661
|
constructor(t) {
|
|
2523
|
-
if (!
|
|
2662
|
+
if (!S().getBool("IS_BROWSER") || typeof window > "u" || typeof window.localStorage > "u")
|
|
2524
2663
|
throw new Error("The current environment does not support local storage.");
|
|
2525
2664
|
if (this.LS = window.localStorage, t == null || !t)
|
|
2526
2665
|
throw new Error("For local storage, modelPath must not be null, undefined or empty.");
|
|
@@ -2541,7 +2680,7 @@ class j {
|
|
|
2541
2680
|
{
|
|
2542
2681
|
const n = JSON.stringify(t.modelTopology), s = JSON.stringify(t.weightSpecs), r = Se(t), a = st.join(t.weightData);
|
|
2543
2682
|
try {
|
|
2544
|
-
this.LS.setItem(this.keys.info, JSON.stringify(r)), this.LS.setItem(this.keys.topology, n), this.LS.setItem(this.keys.weightSpecs, s), this.LS.setItem(this.keys.weightData,
|
|
2683
|
+
this.LS.setItem(this.keys.info, JSON.stringify(r)), this.LS.setItem(this.keys.topology, n), this.LS.setItem(this.keys.weightSpecs, s), this.LS.setItem(this.keys.weightData, Dn(a));
|
|
2545
2684
|
const o = {
|
|
2546
2685
|
format: t.format,
|
|
2547
2686
|
generatedBy: t.generatedBy,
|
|
@@ -2588,33 +2727,33 @@ class j {
|
|
|
2588
2727
|
const o = this.LS.getItem(this.keys.weightData);
|
|
2589
2728
|
if (o == null)
|
|
2590
2729
|
throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);
|
|
2591
|
-
return n.weightData =
|
|
2730
|
+
return n.weightData = Fn(o), n;
|
|
2592
2731
|
}
|
|
2593
2732
|
}
|
|
2594
2733
|
j.URL_SCHEME = "localstorage://";
|
|
2595
|
-
const
|
|
2596
|
-
A.registerSaveRouter(
|
|
2597
|
-
A.registerLoadRouter(
|
|
2598
|
-
function
|
|
2734
|
+
const ve = (e) => S().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(j.URL_SCHEME) ? Un(e.slice(j.URL_SCHEME.length)) : null;
|
|
2735
|
+
A.registerSaveRouter(ve);
|
|
2736
|
+
A.registerLoadRouter(ve);
|
|
2737
|
+
function Un(e) {
|
|
2599
2738
|
return new j(e);
|
|
2600
2739
|
}
|
|
2601
|
-
class
|
|
2740
|
+
class zn {
|
|
2602
2741
|
constructor() {
|
|
2603
|
-
y(
|
|
2742
|
+
y(S().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), y(typeof window > "u" || typeof window.localStorage < "u", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage;
|
|
2604
2743
|
}
|
|
2605
2744
|
async listModels() {
|
|
2606
|
-
const t = {}, n =
|
|
2745
|
+
const t = {}, n = Z + P, s = P + Te;
|
|
2607
2746
|
for (let r = 0; r < this.LS.length; ++r) {
|
|
2608
2747
|
const a = this.LS.key(r);
|
|
2609
2748
|
if (a.startsWith(n) && a.endsWith(s)) {
|
|
2610
|
-
const o =
|
|
2749
|
+
const o = On(a);
|
|
2611
2750
|
t[o] = JSON.parse(this.LS.getItem(a));
|
|
2612
2751
|
}
|
|
2613
2752
|
}
|
|
2614
2753
|
return t;
|
|
2615
2754
|
}
|
|
2616
2755
|
async removeModel(t) {
|
|
2617
|
-
t =
|
|
2756
|
+
t = Gn(t);
|
|
2618
2757
|
const n = Ee(t);
|
|
2619
2758
|
if (this.LS.getItem(n.info) == null)
|
|
2620
2759
|
throw new Error(`Cannot find model at path '${t}'`);
|
|
@@ -2638,13 +2777,13 @@ class Gn {
|
|
|
2638
2777
|
* limitations under the License.
|
|
2639
2778
|
* =============================================================================
|
|
2640
2779
|
*/
|
|
2641
|
-
const
|
|
2642
|
-
class
|
|
2780
|
+
const Zt = "://";
|
|
2781
|
+
class N {
|
|
2643
2782
|
constructor() {
|
|
2644
2783
|
this.managers = {};
|
|
2645
2784
|
}
|
|
2646
2785
|
static getInstance() {
|
|
2647
|
-
return
|
|
2786
|
+
return N.instance == null && (N.instance = new N()), N.instance;
|
|
2648
2787
|
}
|
|
2649
2788
|
/**
|
|
2650
2789
|
* Register a save-handler router.
|
|
@@ -2653,18 +2792,18 @@ class $ {
|
|
|
2653
2792
|
* of `IOHandler` with the `save` method defined or `null`.
|
|
2654
2793
|
*/
|
|
2655
2794
|
static registerManager(t, n) {
|
|
2656
|
-
y(t != null, () => "scheme must not be undefined or null."), t.endsWith(
|
|
2657
|
-
const s =
|
|
2795
|
+
y(t != null, () => "scheme must not be undefined or null."), t.endsWith(Zt) && (t = t.slice(0, t.indexOf(Zt))), y(t.length > 0, () => "scheme must not be an empty string.");
|
|
2796
|
+
const s = N.getInstance();
|
|
2658
2797
|
y(s.managers[t] == null, () => `A model store manager is already registered for scheme '${t}'.`), s.managers[t] = n;
|
|
2659
2798
|
}
|
|
2660
2799
|
static getManager(t) {
|
|
2661
|
-
const n =
|
|
2800
|
+
const n = N.getInstance().managers[t];
|
|
2662
2801
|
if (n == null)
|
|
2663
2802
|
throw new Error(`Cannot find model manager for scheme '${t}'`);
|
|
2664
2803
|
return n;
|
|
2665
2804
|
}
|
|
2666
2805
|
static getSchemes() {
|
|
2667
|
-
return Object.keys(
|
|
2806
|
+
return Object.keys(N.getInstance().managers);
|
|
2668
2807
|
}
|
|
2669
2808
|
}
|
|
2670
2809
|
/**
|
|
@@ -2683,7 +2822,7 @@ class $ {
|
|
|
2683
2822
|
* limitations under the License.
|
|
2684
2823
|
* =============================================================================
|
|
2685
2824
|
*/
|
|
2686
|
-
class
|
|
2825
|
+
class Vn {
|
|
2687
2826
|
constructor() {
|
|
2688
2827
|
this.messageName = "setTimeoutCustom", this.functionRefs = [], this.handledMessageCount = 0, this.hasEventListener = !1;
|
|
2689
2828
|
}
|
|
@@ -2706,7 +2845,7 @@ class Un {
|
|
|
2706
2845
|
// Interleaving window.postMessage and setTimeout will trick the browser and
|
|
2707
2846
|
// avoid the clamp.
|
|
2708
2847
|
setTimeoutCustom(t, n) {
|
|
2709
|
-
if (typeof window > "u" || !
|
|
2848
|
+
if (typeof window > "u" || !S().getBool("USE_SETTIMEOUTCUSTOM")) {
|
|
2710
2849
|
setTimeout(t, n);
|
|
2711
2850
|
return;
|
|
2712
2851
|
}
|
|
@@ -2724,31 +2863,31 @@ class Un {
|
|
|
2724
2863
|
return le(t);
|
|
2725
2864
|
}
|
|
2726
2865
|
}
|
|
2727
|
-
if (
|
|
2728
|
-
|
|
2866
|
+
if (S().get("IS_BROWSER")) {
|
|
2867
|
+
S().setPlatform("browser", new Vn());
|
|
2729
2868
|
try {
|
|
2730
|
-
|
|
2869
|
+
N.registerManager(j.URL_SCHEME, new zn());
|
|
2731
2870
|
} catch {
|
|
2732
2871
|
}
|
|
2733
2872
|
try {
|
|
2734
|
-
|
|
2873
|
+
N.registerManager(W.URL_SCHEME, new $n());
|
|
2735
2874
|
} catch {
|
|
2736
2875
|
}
|
|
2737
2876
|
}
|
|
2738
|
-
const
|
|
2877
|
+
const Wn = {
|
|
2739
2878
|
// tslint:disable-next-line:no-require-imports
|
|
2740
2879
|
importFetch: () => require("node-fetch")
|
|
2741
2880
|
};
|
|
2742
|
-
let
|
|
2743
|
-
class
|
|
2881
|
+
let kt;
|
|
2882
|
+
class jn {
|
|
2744
2883
|
constructor() {
|
|
2745
2884
|
this.util = require("util"), this.textEncoder = new this.util.TextEncoder();
|
|
2746
2885
|
}
|
|
2747
2886
|
fetch(t, n) {
|
|
2748
|
-
return
|
|
2887
|
+
return S().global.fetch != null ? S().global.fetch(t, n) : (kt == null && (kt = Wn.importFetch()), kt(t, n));
|
|
2749
2888
|
}
|
|
2750
2889
|
now() {
|
|
2751
|
-
const t =
|
|
2890
|
+
const t = Q.hrtime();
|
|
2752
2891
|
return t[0] * 1e3 + t[1] / 1e6;
|
|
2753
2892
|
}
|
|
2754
2893
|
encode(t, n) {
|
|
@@ -2763,7 +2902,7 @@ class Vn {
|
|
|
2763
2902
|
return this.util.types.isFloat32Array(t) || this.util.types.isInt32Array(t) || this.util.types.isUint8Array(t) || this.util.types.isUint8ClampedArray(t);
|
|
2764
2903
|
}
|
|
2765
2904
|
}
|
|
2766
|
-
|
|
2905
|
+
S().get("IS_NODE") && !S().get("IS_BROWSER") && S().setPlatform("node", new jn());
|
|
2767
2906
|
/**
|
|
2768
2907
|
* @license
|
|
2769
2908
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -2780,8 +2919,8 @@ k().get("IS_NODE") && !k().get("IS_BROWSER") && k().setPlatform("node", new Vn()
|
|
|
2780
2919
|
* limitations under the License.
|
|
2781
2920
|
* =============================================================================
|
|
2782
2921
|
*/
|
|
2783
|
-
function
|
|
2784
|
-
return t = t || "float32",
|
|
2922
|
+
function qn(e, t = "float32", n) {
|
|
2923
|
+
return t = t || "float32", Ct(e), new fn(e, t, n);
|
|
2785
2924
|
}
|
|
2786
2925
|
/**
|
|
2787
2926
|
* @license
|
|
@@ -2799,7 +2938,7 @@ function Wn(e, t = "float32", n) {
|
|
|
2799
2938
|
* limitations under the License.
|
|
2800
2939
|
* =============================================================================
|
|
2801
2940
|
*/
|
|
2802
|
-
function
|
|
2941
|
+
function Kn(e, t) {
|
|
2803
2942
|
const n = T(e, "x", "cast");
|
|
2804
2943
|
if (!Pe(t))
|
|
2805
2944
|
throw new Error(`Failed to cast to unknown dtype ${t}`);
|
|
@@ -2808,7 +2947,7 @@ function jn(e, t) {
|
|
|
2808
2947
|
const s = { x: n }, r = { dtype: t };
|
|
2809
2948
|
return g.runKernel(oe, s, r);
|
|
2810
2949
|
}
|
|
2811
|
-
const
|
|
2950
|
+
const Rt = /* @__PURE__ */ D({ cast_: Kn });
|
|
2812
2951
|
/**
|
|
2813
2952
|
* @license
|
|
2814
2953
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -2825,11 +2964,11 @@ const Ft = /* @__PURE__ */ N({ cast_: jn });
|
|
|
2825
2964
|
* limitations under the License.
|
|
2826
2965
|
* =============================================================================
|
|
2827
2966
|
*/
|
|
2828
|
-
function
|
|
2967
|
+
function Hn(e) {
|
|
2829
2968
|
const n = { x: T(e, "x", "clone", "string_or_numeric") };
|
|
2830
2969
|
return g.runKernel(ie, n);
|
|
2831
2970
|
}
|
|
2832
|
-
const
|
|
2971
|
+
const Xn = /* @__PURE__ */ D({ clone_: Hn });
|
|
2833
2972
|
/**
|
|
2834
2973
|
* @license
|
|
2835
2974
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -2846,7 +2985,7 @@ const qn = /* @__PURE__ */ N({ clone_: Kn });
|
|
|
2846
2985
|
* limitations under the License.
|
|
2847
2986
|
* =============================================================================
|
|
2848
2987
|
*/
|
|
2849
|
-
function
|
|
2988
|
+
function Jn(e, t = !1) {
|
|
2850
2989
|
console.log(e.toString(t));
|
|
2851
2990
|
}
|
|
2852
2991
|
/**
|
|
@@ -2866,13 +3005,13 @@ function Hn(e, t = !1) {
|
|
|
2866
3005
|
* =============================================================================
|
|
2867
3006
|
*/
|
|
2868
3007
|
be();
|
|
2869
|
-
const
|
|
2870
|
-
buffer:
|
|
2871
|
-
cast:
|
|
2872
|
-
clone:
|
|
2873
|
-
print:
|
|
3008
|
+
const Yn = {
|
|
3009
|
+
buffer: qn,
|
|
3010
|
+
cast: Rt,
|
|
3011
|
+
clone: Xn,
|
|
3012
|
+
print: Jn
|
|
2874
3013
|
};
|
|
2875
|
-
mn(
|
|
3014
|
+
mn(Yn);
|
|
2876
3015
|
/**
|
|
2877
3016
|
* @license
|
|
2878
3017
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -2889,13 +3028,13 @@ mn(Jn);
|
|
|
2889
3028
|
* limitations under the License.
|
|
2890
3029
|
* =============================================================================
|
|
2891
3030
|
*/
|
|
2892
|
-
function
|
|
3031
|
+
function Zn(e, t) {
|
|
2893
3032
|
let n = T(e, "a", "add"), s = T(t, "b", "add");
|
|
2894
|
-
[n, s] =
|
|
3033
|
+
[n, s] = K(n, s);
|
|
2895
3034
|
const r = { a: n, b: s };
|
|
2896
3035
|
return g.runKernel(ae, r);
|
|
2897
3036
|
}
|
|
2898
|
-
const
|
|
3037
|
+
const k = /* @__PURE__ */ D({ add_: Zn });
|
|
2899
3038
|
/**
|
|
2900
3039
|
* @license
|
|
2901
3040
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -2912,13 +3051,13 @@ const S = /* @__PURE__ */ N({ add_: Xn });
|
|
|
2912
3051
|
* limitations under the License.
|
|
2913
3052
|
* =============================================================================
|
|
2914
3053
|
*/
|
|
2915
|
-
function
|
|
3054
|
+
function Qn(e, t) {
|
|
2916
3055
|
let n = T(e, "a", "floorDiv"), s = T(t, "b", "floorDiv");
|
|
2917
|
-
[n, s] =
|
|
3056
|
+
[n, s] = K(n, s);
|
|
2918
3057
|
const r = { a: n, b: s };
|
|
2919
3058
|
return g.runKernel(Ye, r);
|
|
2920
3059
|
}
|
|
2921
|
-
const
|
|
3060
|
+
const ts = /* @__PURE__ */ D({ floorDiv_: Qn });
|
|
2922
3061
|
/**
|
|
2923
3062
|
* @license
|
|
2924
3063
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -2935,14 +3074,14 @@ const Qn = /* @__PURE__ */ N({ floorDiv_: Yn });
|
|
|
2935
3074
|
* limitations under the License.
|
|
2936
3075
|
* =============================================================================
|
|
2937
3076
|
*/
|
|
2938
|
-
function
|
|
3077
|
+
function es(e, t) {
|
|
2939
3078
|
let n = T(e, "a", "div"), s = T(t, "b", "div");
|
|
2940
|
-
if ([n, s] =
|
|
2941
|
-
return
|
|
3079
|
+
if ([n, s] = K(n, s), n.dtype === "int32" && s.dtype === "int32")
|
|
3080
|
+
return ts(n, s);
|
|
2942
3081
|
const r = { a: n, b: s }, a = {};
|
|
2943
|
-
return g.runKernel(
|
|
3082
|
+
return g.runKernel(Xe, r, a);
|
|
2944
3083
|
}
|
|
2945
|
-
const
|
|
3084
|
+
const $ = /* @__PURE__ */ D({ div_: es });
|
|
2946
3085
|
/**
|
|
2947
3086
|
* @license
|
|
2948
3087
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -2959,13 +3098,13 @@ const x = /* @__PURE__ */ N({ div_: Zn });
|
|
|
2959
3098
|
* limitations under the License.
|
|
2960
3099
|
* =============================================================================
|
|
2961
3100
|
*/
|
|
2962
|
-
function
|
|
3101
|
+
function ns(e, t) {
|
|
2963
3102
|
let n = T(e, "a", "mul"), s = T(t, "b", "mul");
|
|
2964
|
-
[n, s] =
|
|
3103
|
+
[n, s] = K(n, s);
|
|
2965
3104
|
const r = { a: n, b: s };
|
|
2966
|
-
return g.runKernel(
|
|
3105
|
+
return g.runKernel(Qe, r);
|
|
2967
3106
|
}
|
|
2968
|
-
const b = /* @__PURE__ */
|
|
3107
|
+
const b = /* @__PURE__ */ D({ mul_: ns });
|
|
2969
3108
|
/**
|
|
2970
3109
|
* @license
|
|
2971
3110
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -2982,17 +3121,17 @@ const b = /* @__PURE__ */ N({ mul_: ts });
|
|
|
2982
3121
|
* limitations under the License.
|
|
2983
3122
|
* =============================================================================
|
|
2984
3123
|
*/
|
|
2985
|
-
function
|
|
3124
|
+
function ss(e) {
|
|
2986
3125
|
const t = T(e, "x", "abs");
|
|
2987
3126
|
if (t.dtype === "complex64") {
|
|
2988
3127
|
const n = { x: t };
|
|
2989
3128
|
return g.runKernel(He, n);
|
|
2990
3129
|
} else {
|
|
2991
3130
|
const n = { x: t };
|
|
2992
|
-
return g.runKernel(
|
|
3131
|
+
return g.runKernel(Ke, n);
|
|
2993
3132
|
}
|
|
2994
3133
|
}
|
|
2995
|
-
const
|
|
3134
|
+
const rs = /* @__PURE__ */ D({ abs_: ss });
|
|
2996
3135
|
/**
|
|
2997
3136
|
* @license
|
|
2998
3137
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3009,10 +3148,10 @@ const ns = /* @__PURE__ */ N({ abs_: es });
|
|
|
3009
3148
|
* limitations under the License.
|
|
3010
3149
|
* =============================================================================
|
|
3011
3150
|
*/
|
|
3012
|
-
function
|
|
3013
|
-
|
|
3151
|
+
function as(e, t, n) {
|
|
3152
|
+
Ct(e), n = n || yt(t);
|
|
3014
3153
|
const s = { shape: e, value: t, dtype: n };
|
|
3015
|
-
return g.runKernel(
|
|
3154
|
+
return g.runKernel(Je, {}, s);
|
|
3016
3155
|
}
|
|
3017
3156
|
/**
|
|
3018
3157
|
* @license
|
|
@@ -3030,7 +3169,7 @@ function ss(e, t, n) {
|
|
|
3030
3169
|
* limitations under the License.
|
|
3031
3170
|
* =============================================================================
|
|
3032
3171
|
*/
|
|
3033
|
-
function
|
|
3172
|
+
function di(e, t) {
|
|
3034
3173
|
const n = e.length, s = [];
|
|
3035
3174
|
for (let r = 0; r < n; r++) {
|
|
3036
3175
|
const a = n - 1 - r, o = e[a] || 1;
|
|
@@ -3038,7 +3177,7 @@ function ko(e, t) {
|
|
|
3038
3177
|
}
|
|
3039
3178
|
return s;
|
|
3040
3179
|
}
|
|
3041
|
-
function
|
|
3180
|
+
function fi(e, t) {
|
|
3042
3181
|
const n = [];
|
|
3043
3182
|
for (let s = 0; s < t.length; s++) {
|
|
3044
3183
|
const r = e[e.length - s - 1], a = t.length - s - 1, o = t[a];
|
|
@@ -3046,7 +3185,7 @@ function Io(e, t) {
|
|
|
3046
3185
|
}
|
|
3047
3186
|
return n;
|
|
3048
3187
|
}
|
|
3049
|
-
function
|
|
3188
|
+
function os(e, t) {
|
|
3050
3189
|
const n = Math.max(e.length, t.length), s = new Array(n);
|
|
3051
3190
|
for (let r = 0; r < n; r++) {
|
|
3052
3191
|
let a = e[e.length - r - 1];
|
|
@@ -3080,11 +3219,11 @@ function rs(e, t) {
|
|
|
3080
3219
|
* limitations under the License.
|
|
3081
3220
|
* =============================================================================
|
|
3082
3221
|
*/
|
|
3083
|
-
function
|
|
3222
|
+
function is(e) {
|
|
3084
3223
|
const n = { x: T(e, "x", "zerosLike") };
|
|
3085
3224
|
return g.runKernel(sn, n);
|
|
3086
3225
|
}
|
|
3087
|
-
const C = /* @__PURE__ */
|
|
3226
|
+
const C = /* @__PURE__ */ D({ zerosLike_: is });
|
|
3088
3227
|
/**
|
|
3089
3228
|
* @license
|
|
3090
3229
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3101,13 +3240,13 @@ const C = /* @__PURE__ */ N({ zerosLike_: as });
|
|
|
3101
3240
|
* limitations under the License.
|
|
3102
3241
|
* =============================================================================
|
|
3103
3242
|
*/
|
|
3104
|
-
function
|
|
3243
|
+
function cs(e, t) {
|
|
3105
3244
|
let n = T(e, "base", "pow"), s = T(t, "exp", "pow");
|
|
3106
|
-
[n, s] =
|
|
3245
|
+
[n, s] = K(n, s);
|
|
3107
3246
|
const r = { a: n, b: s };
|
|
3108
3247
|
return g.runKernel(tn, r);
|
|
3109
3248
|
}
|
|
3110
|
-
const
|
|
3249
|
+
const Qt = /* @__PURE__ */ D({ pow_: cs });
|
|
3111
3250
|
/**
|
|
3112
3251
|
* @license
|
|
3113
3252
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -3124,12 +3263,12 @@ const Zt = /* @__PURE__ */ N({ pow_: os });
|
|
|
3124
3263
|
* limitations under the License.
|
|
3125
3264
|
* =============================================================================
|
|
3126
3265
|
*/
|
|
3127
|
-
function
|
|
3266
|
+
function q(e, t) {
|
|
3128
3267
|
if ((F(e) && t !== "string" || Array.isArray(e)) && t !== "complex64")
|
|
3129
3268
|
throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");
|
|
3130
3269
|
if (t === "string" && F(e) && !(e instanceof Uint8Array))
|
|
3131
3270
|
throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");
|
|
3132
|
-
return
|
|
3271
|
+
return An(e, [], [], t);
|
|
3133
3272
|
}
|
|
3134
3273
|
/**
|
|
3135
3274
|
* @license
|
|
@@ -3147,11 +3286,11 @@ function K(e, t) {
|
|
|
3147
3286
|
* limitations under the License.
|
|
3148
3287
|
* =============================================================================
|
|
3149
3288
|
*/
|
|
3150
|
-
function
|
|
3289
|
+
function ls(e) {
|
|
3151
3290
|
const n = { x: T(e, "x", "sqrt", "float32") };
|
|
3152
3291
|
return g.runKernel(en, n);
|
|
3153
3292
|
}
|
|
3154
|
-
const nt = /* @__PURE__ */
|
|
3293
|
+
const nt = /* @__PURE__ */ D({ sqrt_: ls });
|
|
3155
3294
|
/**
|
|
3156
3295
|
* @license
|
|
3157
3296
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
@@ -3168,11 +3307,11 @@ const nt = /* @__PURE__ */ N({ sqrt_: is });
|
|
|
3168
3307
|
* limitations under the License.
|
|
3169
3308
|
* =============================================================================
|
|
3170
3309
|
*/
|
|
3171
|
-
function
|
|
3310
|
+
function us(e) {
|
|
3172
3311
|
const t = T(e, "x", "square"), n = {};
|
|
3173
3312
|
return g.runKernel("Square", { x: t }, n);
|
|
3174
3313
|
}
|
|
3175
|
-
const V = /* @__PURE__ */
|
|
3314
|
+
const V = /* @__PURE__ */ D({ square_: us });
|
|
3176
3315
|
/**
|
|
3177
3316
|
* @license
|
|
3178
3317
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -3189,18 +3328,18 @@ const V = /* @__PURE__ */ N({ square_: cs });
|
|
|
3189
3328
|
* limitations under the License.
|
|
3190
3329
|
* =============================================================================
|
|
3191
3330
|
*/
|
|
3192
|
-
function
|
|
3193
|
-
return y(
|
|
3331
|
+
function gi(e) {
|
|
3332
|
+
return y(dt(e), () => "The f passed in grads(f) must be a function"), (t, n) => {
|
|
3194
3333
|
y(Array.isArray(t), () => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");
|
|
3195
|
-
const s =
|
|
3334
|
+
const s = Tn(t, "args", "tf.grads", "string_or_numeric"), r = n != null ? T(n, "dy", "tf.grads") : null;
|
|
3196
3335
|
return g.tidy(() => {
|
|
3197
3336
|
const { value: a, grads: o } = g.gradients(() => e(...s), s, r);
|
|
3198
|
-
return r != null &&
|
|
3337
|
+
return r != null && xe(a.shape, r.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), ds(o), o;
|
|
3199
3338
|
});
|
|
3200
3339
|
};
|
|
3201
3340
|
}
|
|
3202
|
-
function
|
|
3203
|
-
y(
|
|
3341
|
+
function hs(e, t) {
|
|
3342
|
+
y(dt(e), () => "The f passed in variableGrads(f) must be a function"), y(t == null || Array.isArray(t) && t.every((l) => l instanceof mt), () => "The varList passed in variableGrads(f, varList) must be an array of variables");
|
|
3204
3343
|
const n = t != null;
|
|
3205
3344
|
if (!n) {
|
|
3206
3345
|
t = [];
|
|
@@ -3216,10 +3355,10 @@ function ls(e, t) {
|
|
|
3216
3355
|
i[u] != null && (c[l.name] = i[u]);
|
|
3217
3356
|
}), s?.forEach((l) => c[l.name] = null), { value: o, grads: c };
|
|
3218
3357
|
}
|
|
3219
|
-
function
|
|
3358
|
+
function mi(e) {
|
|
3220
3359
|
return g.customGrad(e);
|
|
3221
3360
|
}
|
|
3222
|
-
function
|
|
3361
|
+
function ds(e) {
|
|
3223
3362
|
if (e.filter((n) => n == null).length > 0)
|
|
3224
3363
|
throw new Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that
|
|
3225
3364
|
the f you passed encloses all operations that lead from x to y.`);
|
|
@@ -3240,13 +3379,13 @@ function us(e) {
|
|
|
3240
3379
|
* limitations under the License.
|
|
3241
3380
|
* =============================================================================
|
|
3242
3381
|
*/
|
|
3243
|
-
function
|
|
3382
|
+
function fs(e, t) {
|
|
3244
3383
|
let n = T(e, "a", "sub"), s = T(t, "b", "sub");
|
|
3245
|
-
[n, s] =
|
|
3384
|
+
[n, s] = K(n, s);
|
|
3246
3385
|
const r = { a: n, b: s };
|
|
3247
3386
|
return g.runKernel(nn, r);
|
|
3248
3387
|
}
|
|
3249
|
-
const tt = /* @__PURE__ */
|
|
3388
|
+
const tt = /* @__PURE__ */ D({ sub_: fs });
|
|
3250
3389
|
/**
|
|
3251
3390
|
* @license
|
|
3252
3391
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3263,13 +3402,13 @@ const tt = /* @__PURE__ */ N({ sub_: hs });
|
|
|
3263
3402
|
* limitations under the License.
|
|
3264
3403
|
* =============================================================================
|
|
3265
3404
|
*/
|
|
3266
|
-
function
|
|
3405
|
+
function gs(e, t) {
|
|
3267
3406
|
let n = T(e, "a", "maximum"), s = T(t, "b", "maximum");
|
|
3268
|
-
[n, s] =
|
|
3407
|
+
[n, s] = K(n, s), n.dtype === "bool" && (n = Rt(n, "int32"), s = Rt(s, "int32")), os(n.shape, s.shape);
|
|
3269
3408
|
const r = { a: n, b: s };
|
|
3270
|
-
return g.runKernel(
|
|
3409
|
+
return g.runKernel(Ze, r);
|
|
3271
3410
|
}
|
|
3272
|
-
const
|
|
3411
|
+
const ms = /* @__PURE__ */ D({ maximum_: gs });
|
|
3273
3412
|
/**
|
|
3274
3413
|
* @license
|
|
3275
3414
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -3286,8 +3425,8 @@ const ds = /* @__PURE__ */ N({ maximum_: fs });
|
|
|
3286
3425
|
* limitations under the License.
|
|
3287
3426
|
* =============================================================================
|
|
3288
3427
|
*/
|
|
3289
|
-
const
|
|
3290
|
-
class
|
|
3428
|
+
const ps = /* @__PURE__ */ new Map(), ys = /* @__PURE__ */ new Map();
|
|
3429
|
+
class bs {
|
|
3291
3430
|
/**
|
|
3292
3431
|
* Return the class name for this class to use in serialization contexts.
|
|
3293
3432
|
*
|
|
@@ -3332,10 +3471,10 @@ class G {
|
|
|
3332
3471
|
G.getMap().classNameMap[t.className] = [t, t.fromConfig];
|
|
3333
3472
|
}
|
|
3334
3473
|
}
|
|
3335
|
-
function
|
|
3474
|
+
function ws(e, t, n) {
|
|
3336
3475
|
y(e.className != null, () => "Class being registered does not have the static className property defined."), y(typeof e.className == "string", () => "className is required to be a string, but got type " + typeof e.className), y(e.className.length > 0, () => "Class being registered has an empty-string as its className, which is disallowed."), typeof t > "u" && (t = "Custom"), typeof n > "u" && (n = e.className);
|
|
3337
3476
|
const s = n, r = t + ">" + s;
|
|
3338
|
-
return G.register(e),
|
|
3477
|
+
return G.register(e), ps.set(r, e), ys.set(e, r), e;
|
|
3339
3478
|
}
|
|
3340
3479
|
/**
|
|
3341
3480
|
* @license
|
|
@@ -3353,7 +3492,7 @@ function ys(e, t, n) {
|
|
|
3353
3492
|
* limitations under the License.
|
|
3354
3493
|
* =============================================================================
|
|
3355
3494
|
*/
|
|
3356
|
-
class H extends
|
|
3495
|
+
class H extends bs {
|
|
3357
3496
|
/**
|
|
3358
3497
|
* Executes `f()` and minimizes the scalar output of `f()` by computing
|
|
3359
3498
|
* gradients of y with respect to the list of trainable variables provided by
|
|
@@ -3400,7 +3539,7 @@ class H extends ps {
|
|
|
3400
3539
|
* @doc {heading: 'Training', subheading: 'Optimizers'}
|
|
3401
3540
|
*/
|
|
3402
3541
|
computeGradients(t, n) {
|
|
3403
|
-
return
|
|
3542
|
+
return hs(t, n);
|
|
3404
3543
|
}
|
|
3405
3544
|
/**
|
|
3406
3545
|
* Dispose the variables (if any) owned by this optimizer instance.
|
|
@@ -3412,7 +3551,7 @@ class H extends ps {
|
|
|
3412
3551
|
return this.iterations_ == null && (this.iterations_ = 0), {
|
|
3413
3552
|
name: "iter",
|
|
3414
3553
|
// TODO(cais): Use 'int64' type when available.
|
|
3415
|
-
tensor:
|
|
3554
|
+
tensor: q(this.iterations_, "int32")
|
|
3416
3555
|
};
|
|
3417
3556
|
}
|
|
3418
3557
|
async getWeights() {
|
|
@@ -3451,7 +3590,7 @@ Object.defineProperty(H, Symbol.hasInstance, {
|
|
|
3451
3590
|
* limitations under the License.
|
|
3452
3591
|
* =============================================================================
|
|
3453
3592
|
*/
|
|
3454
|
-
class
|
|
3593
|
+
class Ss extends H {
|
|
3455
3594
|
/** @nocollapse */
|
|
3456
3595
|
static get className() {
|
|
3457
3596
|
return "Adadelta";
|
|
@@ -3474,9 +3613,9 @@ class bs extends H {
|
|
|
3474
3613
|
return;
|
|
3475
3614
|
const c = this.accumulatedGrads[r].variable, l = this.accumulatedUpdates[r].variable;
|
|
3476
3615
|
E(() => {
|
|
3477
|
-
const u =
|
|
3478
|
-
c.assign(u), l.assign(
|
|
3479
|
-
const m =
|
|
3616
|
+
const u = k(b(c, this.rho), b(V(i), 1 - this.rho)), h = b($(nt(k(l, this.epsilon)), nt(k(c, this.epsilon))), i), d = k(b(l, this.rho), b(V(h), 1 - this.rho));
|
|
3617
|
+
c.assign(u), l.assign(d);
|
|
3618
|
+
const m = k(b(h, -this.learningRate), a);
|
|
3480
3619
|
a.assign(m);
|
|
3481
3620
|
});
|
|
3482
3621
|
}), this.incrementIterations();
|
|
@@ -3527,7 +3666,7 @@ class bs extends H {
|
|
|
3527
3666
|
* limitations under the License.
|
|
3528
3667
|
* =============================================================================
|
|
3529
3668
|
*/
|
|
3530
|
-
class
|
|
3669
|
+
class ks extends H {
|
|
3531
3670
|
/** @nocollapse */
|
|
3532
3671
|
static get className() {
|
|
3533
3672
|
return "Adagrad";
|
|
@@ -3540,16 +3679,16 @@ class ws extends H {
|
|
|
3540
3679
|
const a = g.registeredVariables[s];
|
|
3541
3680
|
this.accumulatedGrads[r] == null && (this.accumulatedGrads[r] = {
|
|
3542
3681
|
originalName: `${s}/accumulator`,
|
|
3543
|
-
variable: E(() =>
|
|
3682
|
+
variable: E(() => as(a.shape, this.initialAccumulatorValue).variable(!1))
|
|
3544
3683
|
});
|
|
3545
3684
|
const o = Array.isArray(t) ? t[r].tensor : t[s];
|
|
3546
3685
|
if (o == null)
|
|
3547
3686
|
return;
|
|
3548
3687
|
const i = this.accumulatedGrads[r].variable;
|
|
3549
3688
|
E(() => {
|
|
3550
|
-
const c =
|
|
3689
|
+
const c = k(i, V(o));
|
|
3551
3690
|
i.assign(c);
|
|
3552
|
-
const l =
|
|
3691
|
+
const l = k(b($(o, nt(k(c, g.backend.epsilon()))), -this.learningRate), a);
|
|
3553
3692
|
a.assign(l);
|
|
3554
3693
|
});
|
|
3555
3694
|
}), this.incrementIterations();
|
|
@@ -3592,14 +3731,14 @@ class ws extends H {
|
|
|
3592
3731
|
* limitations under the License.
|
|
3593
3732
|
* =============================================================================
|
|
3594
3733
|
*/
|
|
3595
|
-
class
|
|
3734
|
+
class Is extends H {
|
|
3596
3735
|
/** @nocollapse */
|
|
3597
3736
|
static get className() {
|
|
3598
3737
|
return "Adam";
|
|
3599
3738
|
}
|
|
3600
3739
|
constructor(t, n, s, r = null) {
|
|
3601
3740
|
super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], E(() => {
|
|
3602
|
-
this.accBeta1 =
|
|
3741
|
+
this.accBeta1 = q(n).variable(), this.accBeta2 = q(s).variable();
|
|
3603
3742
|
}), r == null && (this.epsilon = g.backend.epsilon());
|
|
3604
3743
|
}
|
|
3605
3744
|
applyGradients(t) {
|
|
@@ -3618,9 +3757,9 @@ class Ss extends H {
|
|
|
3618
3757
|
const l = Array.isArray(t) ? t[o].tensor : t[a];
|
|
3619
3758
|
if (l == null)
|
|
3620
3759
|
return;
|
|
3621
|
-
const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedSecondMoment[o].variable,
|
|
3622
|
-
u.assign(
|
|
3623
|
-
const w =
|
|
3760
|
+
const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedSecondMoment[o].variable, d = k(b(u, this.beta1), b(l, 1 - this.beta1)), m = k(b(h, this.beta2), b(V(l), 1 - this.beta2)), p = $(d, s), f = $(m, r);
|
|
3761
|
+
u.assign(d), h.assign(m);
|
|
3762
|
+
const w = k(b($(p, k(nt(f), this.epsilon)), -this.learningRate), i);
|
|
3624
3763
|
i.assign(w);
|
|
3625
3764
|
}), this.accBeta1.assign(b(this.accBeta1, this.beta1)), this.accBeta2.assign(b(this.accBeta2, this.beta2));
|
|
3626
3765
|
}), this.incrementIterations();
|
|
@@ -3634,7 +3773,7 @@ class Ss extends H {
|
|
|
3634
3773
|
}
|
|
3635
3774
|
async setWeights(t) {
|
|
3636
3775
|
t = await this.extractIterations(t), E(() => {
|
|
3637
|
-
this.accBeta1.assign(
|
|
3776
|
+
this.accBeta1.assign(Qt(this.beta1, this.iterations_ + 1)), this.accBeta2.assign(Qt(this.beta2, this.iterations_ + 1));
|
|
3638
3777
|
});
|
|
3639
3778
|
const n = t.length / 2, s = !1;
|
|
3640
3779
|
this.accumulatedFirstMoment = t.slice(0, n).map((r) => ({
|
|
@@ -3674,20 +3813,20 @@ class Ss extends H {
|
|
|
3674
3813
|
* limitations under the License.
|
|
3675
3814
|
* =============================================================================
|
|
3676
3815
|
*/
|
|
3677
|
-
class
|
|
3816
|
+
class Ts extends H {
|
|
3678
3817
|
/** @nocollapse */
|
|
3679
3818
|
static get className() {
|
|
3680
3819
|
return "Adamax";
|
|
3681
3820
|
}
|
|
3682
3821
|
constructor(t, n, s, r = null, a = 0) {
|
|
3683
3822
|
super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.decay = a, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], E(() => {
|
|
3684
|
-
this.iteration =
|
|
3823
|
+
this.iteration = q(0).variable(), this.accBeta1 = q(n).variable();
|
|
3685
3824
|
}), r == null && (this.epsilon = g.backend.epsilon());
|
|
3686
3825
|
}
|
|
3687
3826
|
applyGradients(t) {
|
|
3688
3827
|
const n = Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t);
|
|
3689
3828
|
E(() => {
|
|
3690
|
-
const s = tt(1, this.accBeta1), r =
|
|
3829
|
+
const s = tt(1, this.accBeta1), r = $(-this.learningRate, k(b(this.iteration, this.decay), 1));
|
|
3691
3830
|
n.forEach((a, o) => {
|
|
3692
3831
|
const i = g.registeredVariables[a], c = !1;
|
|
3693
3832
|
this.accumulatedFirstMoment[o] == null && (this.accumulatedFirstMoment[o] = {
|
|
@@ -3700,11 +3839,11 @@ class ks extends H {
|
|
|
3700
3839
|
const l = Array.isArray(t) ? t[o].tensor : t[a];
|
|
3701
3840
|
if (l == null)
|
|
3702
3841
|
return;
|
|
3703
|
-
const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedWeightedInfNorm[o].variable,
|
|
3704
|
-
u.assign(
|
|
3705
|
-
const w =
|
|
3842
|
+
const u = this.accumulatedFirstMoment[o].variable, h = this.accumulatedWeightedInfNorm[o].variable, d = k(b(u, this.beta1), b(l, 1 - this.beta1)), m = b(h, this.beta2), p = rs(l), f = ms(m, p);
|
|
3843
|
+
u.assign(d), h.assign(f);
|
|
3844
|
+
const w = k(b($(r, s), $(d, k(f, this.epsilon))), i);
|
|
3706
3845
|
i.assign(w);
|
|
3707
|
-
}), this.iteration.assign(
|
|
3846
|
+
}), this.iteration.assign(k(this.iteration, 1)), this.accBeta1.assign(b(this.accBeta1, this.beta1));
|
|
3708
3847
|
}), this.incrementIterations();
|
|
3709
3848
|
}
|
|
3710
3849
|
dispose() {
|
|
@@ -3746,7 +3885,7 @@ class ks extends H {
|
|
|
3746
3885
|
* limitations under the License.
|
|
3747
3886
|
* =============================================================================
|
|
3748
3887
|
*/
|
|
3749
|
-
class
|
|
3888
|
+
class Be extends H {
|
|
3750
3889
|
/** @nocollapse */
|
|
3751
3890
|
static get className() {
|
|
3752
3891
|
return "SGD";
|
|
@@ -3761,7 +3900,7 @@ class ve extends H {
|
|
|
3761
3900
|
return;
|
|
3762
3901
|
const o = g.registeredVariables[s];
|
|
3763
3902
|
E(() => {
|
|
3764
|
-
const i =
|
|
3903
|
+
const i = k(b(this.c, a), o);
|
|
3765
3904
|
o.assign(i);
|
|
3766
3905
|
});
|
|
3767
3906
|
}), this.incrementIterations();
|
|
@@ -3770,7 +3909,7 @@ class ve extends H {
|
|
|
3770
3909
|
* Sets the learning rate of the optimizer.
|
|
3771
3910
|
*/
|
|
3772
3911
|
setLearningRate(t) {
|
|
3773
|
-
this.learningRate = t, this.c != null && this.c.dispose(), this.c = Bn(
|
|
3912
|
+
this.learningRate = t, this.c != null && this.c.dispose(), this.c = Bn(q(-t));
|
|
3774
3913
|
}
|
|
3775
3914
|
dispose() {
|
|
3776
3915
|
this.c.dispose();
|
|
@@ -3806,14 +3945,14 @@ class ve extends H {
|
|
|
3806
3945
|
* limitations under the License.
|
|
3807
3946
|
* =============================================================================
|
|
3808
3947
|
*/
|
|
3809
|
-
class
|
|
3948
|
+
class Es extends Be {
|
|
3810
3949
|
/** @nocollapse */
|
|
3811
3950
|
// Name matters for Python compatibility.
|
|
3812
3951
|
static get className() {
|
|
3813
3952
|
return "Momentum";
|
|
3814
3953
|
}
|
|
3815
3954
|
constructor(t, n, s = !1) {
|
|
3816
|
-
super(t), this.learningRate = t, this.momentum = n, this.useNesterov = s, this.accumulations = [], this.m =
|
|
3955
|
+
super(t), this.learningRate = t, this.momentum = n, this.useNesterov = s, this.accumulations = [], this.m = q(this.momentum);
|
|
3817
3956
|
}
|
|
3818
3957
|
applyGradients(t) {
|
|
3819
3958
|
(Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t)).forEach((s, r) => {
|
|
@@ -3825,8 +3964,8 @@ class Is extends ve {
|
|
|
3825
3964
|
const o = this.accumulations[r].variable, i = Array.isArray(t) ? t[r].tensor : t[s];
|
|
3826
3965
|
i != null && E(() => {
|
|
3827
3966
|
let c;
|
|
3828
|
-
const l =
|
|
3829
|
-
this.useNesterov ? c =
|
|
3967
|
+
const l = k(b(this.m, o), i);
|
|
3968
|
+
this.useNesterov ? c = k(b(this.c, k(i, b(l, this.m))), a) : c = k(b(this.c, l), a), o.assign(l), a.assign(c);
|
|
3830
3969
|
});
|
|
3831
3970
|
}), this.incrementIterations();
|
|
3832
3971
|
}
|
|
@@ -3877,7 +4016,7 @@ class Is extends ve {
|
|
|
3877
4016
|
* limitations under the License.
|
|
3878
4017
|
* =============================================================================
|
|
3879
4018
|
*/
|
|
3880
|
-
class
|
|
4019
|
+
class As extends H {
|
|
3881
4020
|
/** @nocollapse */
|
|
3882
4021
|
static get className() {
|
|
3883
4022
|
return "RMSProp";
|
|
@@ -3904,16 +4043,16 @@ class Ts extends H {
|
|
|
3904
4043
|
return;
|
|
3905
4044
|
const c = this.accumulatedMeanSquares[r].variable, l = this.accumulatedMoments[r].variable;
|
|
3906
4045
|
E(() => {
|
|
3907
|
-
const u =
|
|
4046
|
+
const u = k(b(c, this.decay), b(V(i), 1 - this.decay));
|
|
3908
4047
|
if (this.centered) {
|
|
3909
|
-
const h = this.accumulatedMeanGrads[r].variable,
|
|
3910
|
-
c.assign(u), h.assign(
|
|
3911
|
-
const
|
|
3912
|
-
a.assign(
|
|
4048
|
+
const h = this.accumulatedMeanGrads[r].variable, d = k(b(h, this.decay), b(i, 1 - this.decay)), m = $(b(i, this.learningRate), nt(tt(u, k(V(d), this.epsilon)))), p = k(b(l, this.momentum), m);
|
|
4049
|
+
c.assign(u), h.assign(d), l.assign(p);
|
|
4050
|
+
const f = tt(a, p);
|
|
4051
|
+
a.assign(f);
|
|
3913
4052
|
} else {
|
|
3914
|
-
const h =
|
|
3915
|
-
c.assign(h), l.assign(
|
|
3916
|
-
const m = tt(a,
|
|
4053
|
+
const h = k(b(c, this.decay), b(V(i), 1 - this.decay)), d = k(b(l, this.momentum), $(b(i, this.learningRate), nt(k(h, this.epsilon))));
|
|
4054
|
+
c.assign(h), l.assign(d);
|
|
4055
|
+
const m = tt(a, d);
|
|
3917
4056
|
a.assign(m);
|
|
3918
4057
|
}
|
|
3919
4058
|
});
|
|
@@ -3970,18 +4109,18 @@ class Ts extends H {
|
|
|
3970
4109
|
* limitations under the License.
|
|
3971
4110
|
* =============================================================================
|
|
3972
4111
|
*/
|
|
3973
|
-
const
|
|
3974
|
-
bs,
|
|
3975
|
-
ws,
|
|
4112
|
+
const vs = [
|
|
3976
4113
|
Ss,
|
|
3977
4114
|
ks,
|
|
3978
4115
|
Is,
|
|
3979
4116
|
Ts,
|
|
3980
|
-
|
|
4117
|
+
Es,
|
|
4118
|
+
As,
|
|
4119
|
+
Be
|
|
3981
4120
|
];
|
|
3982
|
-
function
|
|
3983
|
-
for (const e of
|
|
3984
|
-
|
|
4121
|
+
function Bs() {
|
|
4122
|
+
for (const e of vs)
|
|
4123
|
+
ws(e);
|
|
3985
4124
|
}
|
|
3986
4125
|
/**
|
|
3987
4126
|
* @license
|
|
@@ -3999,237 +4138,295 @@ function As() {
|
|
|
3999
4138
|
* limitations under the License.
|
|
4000
4139
|
* =============================================================================
|
|
4001
4140
|
*/
|
|
4002
|
-
|
|
4141
|
+
Bs();
|
|
4003
4142
|
export {
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4143
|
+
ne as $,
|
|
4144
|
+
Is as A,
|
|
4145
|
+
Ge as B,
|
|
4146
|
+
K as C,
|
|
4147
|
+
ur as D,
|
|
4009
4148
|
g as E,
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4149
|
+
Ja as F,
|
|
4150
|
+
Qr as G,
|
|
4151
|
+
wo as H,
|
|
4152
|
+
Xn as I,
|
|
4153
|
+
Co as J,
|
|
4154
|
+
wr as K,
|
|
4155
|
+
Ha as L,
|
|
4156
|
+
Sa as M,
|
|
4157
|
+
Rt as N,
|
|
4158
|
+
yo as O,
|
|
4159
|
+
Oa as P,
|
|
4160
|
+
In as Q,
|
|
4161
|
+
qa as R,
|
|
4162
|
+
So as S,
|
|
4163
|
+
x as T,
|
|
4164
|
+
An as U,
|
|
4165
|
+
Ps as V,
|
|
4166
|
+
$t as W,
|
|
4167
|
+
ao as X,
|
|
4168
|
+
ta as Y,
|
|
4169
|
+
xe as Z,
|
|
4170
|
+
br as _,
|
|
4032
4171
|
M as a,
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4172
|
+
Ka as a$,
|
|
4173
|
+
vr as a0,
|
|
4174
|
+
ho as a1,
|
|
4175
|
+
Ba as a2,
|
|
4176
|
+
rs as a3,
|
|
4177
|
+
nt as a4,
|
|
4178
|
+
V as a5,
|
|
4179
|
+
Ra as a6,
|
|
4180
|
+
k as a7,
|
|
4181
|
+
qr as a8,
|
|
4182
|
+
da as a9,
|
|
4183
|
+
ci as aA,
|
|
4184
|
+
Se as aB,
|
|
4185
|
+
li as aC,
|
|
4186
|
+
ui as aD,
|
|
4187
|
+
Vs as aE,
|
|
4188
|
+
jt as aF,
|
|
4189
|
+
ue as aG,
|
|
4190
|
+
di as aH,
|
|
4191
|
+
Ho as aI,
|
|
4192
|
+
O as aJ,
|
|
4193
|
+
Gs as aK,
|
|
4194
|
+
Ls as aL,
|
|
4195
|
+
$s as aM,
|
|
4196
|
+
ut as aN,
|
|
4197
|
+
uo as aO,
|
|
4198
|
+
dr as aP,
|
|
4199
|
+
co as aQ,
|
|
4200
|
+
Ur as aR,
|
|
4201
|
+
Kr as aS,
|
|
4202
|
+
ea as aT,
|
|
4203
|
+
na as aU,
|
|
4204
|
+
ra as aV,
|
|
4205
|
+
la as aW,
|
|
4206
|
+
ua as aX,
|
|
4207
|
+
xa as aY,
|
|
4069
4208
|
ga as aZ,
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4209
|
+
Ma as a_,
|
|
4210
|
+
Os as aa,
|
|
4211
|
+
F as ab,
|
|
4212
|
+
S as ac,
|
|
4213
|
+
pe as ad,
|
|
4214
|
+
Qo as ae,
|
|
4215
|
+
gt as af,
|
|
4216
|
+
Yr as ag,
|
|
4217
|
+
qn as ah,
|
|
4218
|
+
xt as ai,
|
|
4219
|
+
$ as aj,
|
|
4220
|
+
ie as ak,
|
|
4221
|
+
ca as al,
|
|
4222
|
+
Yo as am,
|
|
4223
|
+
Ua as an,
|
|
4224
|
+
Ne as ao,
|
|
4225
|
+
mo as ap,
|
|
4226
|
+
zr as aq,
|
|
4227
|
+
Xa as ar,
|
|
4228
|
+
eo as as,
|
|
4229
|
+
zo as at,
|
|
4230
|
+
fi as au,
|
|
4231
|
+
Ns as av,
|
|
4232
|
+
Zo as aw,
|
|
4233
|
+
Xe as ax,
|
|
4234
|
+
A as ay,
|
|
4235
|
+
st as az,
|
|
4097
4236
|
b,
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4237
|
+
La as b$,
|
|
4238
|
+
so as b0,
|
|
4239
|
+
Go as b1,
|
|
4240
|
+
_o as b2,
|
|
4241
|
+
Fr as b3,
|
|
4242
|
+
Jr as b4,
|
|
4243
|
+
Wo as b5,
|
|
4244
|
+
$a as b6,
|
|
4245
|
+
Pa as b7,
|
|
4246
|
+
Ca as b8,
|
|
4247
|
+
Qa as b9,
|
|
4248
|
+
Re as bA,
|
|
4249
|
+
Ys as bB,
|
|
4250
|
+
Zs as bC,
|
|
4251
|
+
Qs as bD,
|
|
4252
|
+
or as bE,
|
|
4253
|
+
cr as bF,
|
|
4254
|
+
$o as bG,
|
|
4255
|
+
hr as bH,
|
|
4256
|
+
Zr as bI,
|
|
4257
|
+
yr as bJ,
|
|
4258
|
+
Sr as bK,
|
|
4259
|
+
Ir as bL,
|
|
4260
|
+
Tr as bM,
|
|
4261
|
+
Ar as bN,
|
|
4262
|
+
Br as bO,
|
|
4263
|
+
Mr as bP,
|
|
4264
|
+
Dr as bQ,
|
|
4265
|
+
Rr as bR,
|
|
4266
|
+
Nr as bS,
|
|
4267
|
+
Wr as bT,
|
|
4268
|
+
fa as bU,
|
|
4269
|
+
po as bV,
|
|
4270
|
+
ma as bW,
|
|
4271
|
+
ka as bX,
|
|
4272
|
+
Ta as bY,
|
|
4273
|
+
va as bZ,
|
|
4274
|
+
_a as b_,
|
|
4275
|
+
Ya as ba,
|
|
4276
|
+
Lo as bb,
|
|
4277
|
+
Ke as bc,
|
|
4278
|
+
Us as bd,
|
|
4279
|
+
Ks as be,
|
|
4280
|
+
qs as bf,
|
|
4281
|
+
oe as bg,
|
|
4282
|
+
zs as bh,
|
|
4283
|
+
_t as bi,
|
|
4284
|
+
ae as bj,
|
|
4285
|
+
fr as bk,
|
|
4286
|
+
te as bl,
|
|
4287
|
+
pr as bm,
|
|
4288
|
+
jr as bn,
|
|
4289
|
+
Hr as bo,
|
|
4290
|
+
Ye as bp,
|
|
4291
|
+
Ze as bq,
|
|
4292
|
+
Qe as br,
|
|
4293
|
+
Na as bs,
|
|
4294
|
+
za as bt,
|
|
4295
|
+
ro as bu,
|
|
4296
|
+
fn as bv,
|
|
4297
|
+
en as bw,
|
|
4298
|
+
vo as bx,
|
|
4299
|
+
Mo as by,
|
|
4300
|
+
nn as bz,
|
|
4301
|
+
mi as c,
|
|
4302
|
+
xr as c$,
|
|
4303
|
+
Ga as c0,
|
|
4304
|
+
bo as c1,
|
|
4305
|
+
no as c2,
|
|
4306
|
+
lo as c3,
|
|
4307
|
+
fo as c4,
|
|
4308
|
+
Uo as c5,
|
|
4309
|
+
kr as c6,
|
|
4310
|
+
qo as c7,
|
|
4311
|
+
$r as c8,
|
|
4312
|
+
Cr as c9,
|
|
4313
|
+
oa as cA,
|
|
4314
|
+
ia as cB,
|
|
4315
|
+
ya as cC,
|
|
4316
|
+
wa as cD,
|
|
4317
|
+
ba as cE,
|
|
4318
|
+
Ea as cF,
|
|
4319
|
+
Ia as cG,
|
|
4320
|
+
Da as cH,
|
|
4321
|
+
Fa as cI,
|
|
4322
|
+
tn as cJ,
|
|
4323
|
+
to as cK,
|
|
4324
|
+
Za as cL,
|
|
4325
|
+
go as cM,
|
|
4326
|
+
Bo as cN,
|
|
4327
|
+
No as cO,
|
|
4328
|
+
ms as cP,
|
|
4329
|
+
sn as cQ,
|
|
4330
|
+
ai as cR,
|
|
4331
|
+
ws as cS,
|
|
4332
|
+
bs as cT,
|
|
4333
|
+
G as cU,
|
|
4334
|
+
Oe as cV,
|
|
4335
|
+
H as cW,
|
|
4336
|
+
xs as cX,
|
|
4337
|
+
hi as cY,
|
|
4338
|
+
oi as cZ,
|
|
4339
|
+
ii as c_,
|
|
4340
|
+
jo as ca,
|
|
4341
|
+
Be as cb,
|
|
4342
|
+
Es as cc,
|
|
4343
|
+
As as cd,
|
|
4344
|
+
Ss as ce,
|
|
4345
|
+
Ts as cf,
|
|
4346
|
+
ks as cg,
|
|
4347
|
+
Hs as ch,
|
|
4348
|
+
Xs as ci,
|
|
4349
|
+
Js as cj,
|
|
4350
|
+
tr as ck,
|
|
4351
|
+
er as cl,
|
|
4352
|
+
nr as cm,
|
|
4353
|
+
ar as cn,
|
|
4354
|
+
sr as co,
|
|
4355
|
+
rr as cp,
|
|
4356
|
+
lr as cq,
|
|
4357
|
+
ir as cr,
|
|
4358
|
+
gr as cs,
|
|
4359
|
+
He as ct,
|
|
4360
|
+
Er as cu,
|
|
4361
|
+
Lr as cv,
|
|
4362
|
+
Or as cw,
|
|
4363
|
+
_r as cx,
|
|
4364
|
+
Vr as cy,
|
|
4365
|
+
aa as cz,
|
|
4366
|
+
ei as d,
|
|
4367
|
+
pa as d0,
|
|
4368
|
+
Xr as d1,
|
|
4369
|
+
sa as d2,
|
|
4370
|
+
Do as d3,
|
|
4371
|
+
Po as d4,
|
|
4372
|
+
Oo as d5,
|
|
4373
|
+
de as d6,
|
|
4374
|
+
ts as d7,
|
|
4375
|
+
Fe as d8,
|
|
4376
|
+
Rs as d9,
|
|
4377
|
+
oo as dA,
|
|
4378
|
+
ti as dB,
|
|
4379
|
+
_s as dC,
|
|
4380
|
+
lt as dD,
|
|
4381
|
+
Cs as dE,
|
|
4382
|
+
It as dF,
|
|
4383
|
+
kn as dG,
|
|
4384
|
+
Vo as dH,
|
|
4385
|
+
Nt as da,
|
|
4386
|
+
Ws as db,
|
|
4387
|
+
ri as dc,
|
|
4388
|
+
mr as dd,
|
|
4389
|
+
Pr as de,
|
|
4390
|
+
ct as df,
|
|
4391
|
+
js as dg,
|
|
4392
|
+
Gr as dh,
|
|
4393
|
+
Je as di,
|
|
4394
|
+
yt as dj,
|
|
4395
|
+
Ko as dk,
|
|
4396
|
+
ha as dl,
|
|
4397
|
+
Aa as dm,
|
|
4398
|
+
Va as dn,
|
|
4399
|
+
Wa as dp,
|
|
4400
|
+
ja as dq,
|
|
4401
|
+
io as dr,
|
|
4402
|
+
ko as ds,
|
|
4403
|
+
Io as dt,
|
|
4404
|
+
To as du,
|
|
4405
|
+
Eo as dv,
|
|
4406
|
+
Ao as dw,
|
|
4407
|
+
Fo as dx,
|
|
4408
|
+
Ro as dy,
|
|
4409
|
+
xo as dz,
|
|
4410
|
+
ni as e,
|
|
4411
|
+
q as f,
|
|
4412
|
+
as as g,
|
|
4413
|
+
Jo as h,
|
|
4414
|
+
z as i,
|
|
4415
|
+
os as j,
|
|
4416
|
+
y as k,
|
|
4417
|
+
Qt as l,
|
|
4418
|
+
si as m,
|
|
4419
|
+
Bn as n,
|
|
4420
|
+
gi as o,
|
|
4421
|
+
$e as p,
|
|
4422
|
+
D as q,
|
|
4423
|
+
Xo as r,
|
|
4227
4424
|
tt as s,
|
|
4228
4425
|
E as t,
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4426
|
+
fe as u,
|
|
4427
|
+
hs as v,
|
|
4428
|
+
T as w,
|
|
4429
|
+
Tn as x,
|
|
4430
|
+
Ct as y,
|
|
4234
4431
|
C as z
|
|
4235
4432
|
};
|