@genai-fi/nanogpt 0.7.3 → 0.8.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.d.ts +25 -2
- package/dist/Generator.js +152 -49
- package/dist/{RealDiv-Dy0p8Bvo.js → RealDiv-D_q39E3A.js} +13 -13
- package/dist/{Reshape-DvudQDvJ.js → Reshape-41YpQqEo.js} +1 -1
- package/dist/{Reshape-DH5srBP0.js → Reshape-Bh_jzKzV.js} +5 -5
- package/dist/TeachableLLM.d.ts +6 -6
- package/dist/TeachableLLM.js +33 -31
- package/dist/Trainer.d.ts +13 -2
- package/dist/Trainer.js +21 -12
- package/dist/{axis_util-BzbKo31C.js → axis_util-Did9235A.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-TE7aTPhZ.js → backend_util-yC3YH1jo.js} +58 -58
- package/dist/{broadcast_to-CdbwV-Dj.js → broadcast_to-CUvOdOT5.js} +2 -2
- package/dist/checks/appendCache.d.ts +1 -0
- package/dist/checks/appendCache.js +22 -0
- package/dist/checks/attentionMask.d.ts +1 -0
- package/dist/checks/attentionMask.js +37 -0
- package/dist/checks/check.d.ts +9 -0
- package/dist/checks/check.js +20 -0
- package/dist/checks/gelu.d.ts +1 -0
- package/dist/checks/gelu.js +18 -0
- package/dist/checks/index.d.ts +19 -0
- package/dist/checks/index.js +21 -0
- package/dist/checks/normRMS.d.ts +1 -0
- package/dist/checks/normRMS.js +16 -0
- package/dist/checks/normRMSGrad.d.ts +1 -0
- package/dist/checks/normRMSGrad.js +12 -0
- package/dist/checks/qkv.d.ts +1 -0
- package/dist/checks/qkv.js +25 -0
- package/dist/checks/rope.d.ts +1 -0
- package/dist/checks/rope.js +21 -0
- package/dist/{concat-CsxrgovM.js → concat-pHiVqR3L.js} +1 -1
- package/dist/{dataset-CtdBYwjo.js → dataset-DPPl-iLT.js} +9 -9
- package/dist/{dropout-DYs5QFGQ.js → dropout-CcKSfOYE.js} +18 -18
- package/dist/exports_initializers-DKk7-bsx.js +16 -0
- package/dist/{gather-CMMy2KEG.js → gather-CPg6ZlQA.js} +1 -1
- package/dist/{gelu-C-dPj6Ku.js → gelu-BkcmEEyD.js} +1 -1
- package/dist/{gpgpu_math-DGNLNL4I.js → gpgpu_math-D_ODOLix.js} +26 -26
- package/dist/{index-BoWRt-10.js → index-DdmHGZjq.js} +659 -650
- package/dist/{index-CLthM0TO.js → index-evZ57wr4.js} +185 -185
- package/dist/{kernel_funcs_utils-BYKWV8Aa.js → kernel_funcs_utils-CDfFpUab.js} +21 -21
- package/dist/layers/BaseLayer.d.ts +8 -13
- package/dist/layers/BaseLayer.js +25 -13
- package/dist/layers/CausalSelfAttention.d.ts +3 -2
- package/dist/layers/CausalSelfAttention.js +28 -28
- package/dist/layers/MLP.d.ts +3 -2
- package/dist/layers/MLP.js +16 -20
- package/dist/layers/PositionEmbedding.d.ts +9 -0
- package/dist/layers/PositionEmbedding.js +45 -0
- package/dist/layers/RMSNorm.d.ts +3 -2
- package/dist/layers/RMSNorm.js +6 -6
- package/dist/layers/RoPECache.d.ts +1 -1
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.d.ts +3 -2
- package/dist/layers/TiedEmbedding.js +29 -7
- package/dist/layers/TransformerBlock.d.ts +3 -2
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/load.d.ts +2 -2
- package/dist/loader/loadHF.d.ts +2 -2
- package/dist/loader/loadTransformers.d.ts +4 -2
- package/dist/loader/loadTransformers.js +10 -9
- package/dist/loader/newZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.js +44 -51
- package/dist/loader/save.d.ts +8 -0
- package/dist/loader/save.js +62 -0
- package/dist/{log_sum_exp-DbjkV734.js → log_sum_exp-C8yFJfZz.js} +45 -24
- package/dist/main.d.ts +6 -4
- package/dist/main.js +24 -18
- package/dist/{mat_mul-8m8pfdcx.js → mat_mul-Dpy2mMRu.js} +1 -1
- package/dist/mod-CbibJi3D.js +27 -0
- package/dist/models/NanoGPTV1.d.ts +15 -0
- package/dist/models/NanoGPTV1.js +71 -0
- package/dist/{config.d.ts → models/config.d.ts} +1 -0
- package/dist/{config.js → models/config.js} +1 -0
- package/dist/models/factory.d.ts +3 -0
- package/dist/models/factory.js +14 -0
- package/dist/models/model.d.ts +26 -0
- package/dist/models/model.js +70 -0
- package/dist/{mulmat_packed_gpu-VSekgsNv.js → mulmat_packed_gpu-q_Gmwyld.js} +1 -1
- package/dist/{ones-Dj0SDhHf.js → ones-BAqVh-eA.js} +2 -2
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/adamAdjust.js +9 -9
- package/dist/ops/cpu/adamMoments.js +2 -2
- 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 +2 -2
- 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 +7 -7
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +2 -2
- 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/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +4 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/adamAdjust.js +2 -2
- package/dist/ops/webgl/adamMoments.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 +4 -4
- 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 +10 -10
- 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/webgpu/adamAdjust.js +3 -3
- package/dist/ops/webgpu/adamMoments.js +3 -3
- package/dist/ops/webgpu/appendCache.js +3 -3
- package/dist/ops/webgpu/attentionMask.js +3 -3
- package/dist/ops/webgpu/gatherSub.js +3 -3
- package/dist/ops/webgpu/gelu.js +3 -3
- package/dist/ops/webgpu/normRMS.js +2 -2
- package/dist/ops/webgpu/normRMSGrad.js +5 -5
- package/dist/ops/webgpu/qkv.js +3 -3
- package/dist/ops/webgpu/rope.js +3 -3
- package/dist/ops/webgpu/scatterSub.js +3 -3
- package/dist/ops/webgpu/utils/reductions.js +4 -4
- package/dist/ops-542ai2vG.js +1525 -0
- package/dist/{random_width-sZORGo5k.js → random_width-DKGeiFuR.js} +1471 -1538
- package/dist/{range-CRuAh-gd.js → range-BcUvLuf5.js} +1 -1
- package/dist/{reciprocal-BvGAyKyu.js → reciprocal-DhDWSKiD.js} +1 -1
- package/dist/{register_all_kernels-BwDSRN-f.js → register_all_kernels-Do9VvZmo.js} +2488 -2534
- package/dist/{max-Ddnnb5xe.js → relu-B1AXs7p5.js} +6 -6
- package/dist/{reshape-CdBq1WJ6.js → reshape-WeJkT3ja.js} +1 -1
- package/dist/{scatter_nd_util-DUstGbU1.js → scatter_nd_util-B7yDhiQr.js} +1 -1
- package/dist/{selu_util-BJEXVvjX.js → selu_util-BgUO9gHY.js} +125 -146
- package/dist/{shared-wS99K7_n.js → shared-CZiWmQCI.js} +1 -1
- package/dist/{shared-B8ztnyEk.js → shared-V6D_md-c.js} +72 -72
- package/dist/{sin-BeA3tsEd.js → sin-CPxad7Am.js} +1 -1
- package/dist/{slice-BiOsknYS.js → slice-B7jXtPnp.js} +1 -1
- package/dist/{softmax-Bv_6lyMX.js → softmax-BfsyI4As.js} +1 -1
- package/dist/{split-B-dikLRw.js → split-BPxr8_8m.js} +1 -1
- package/dist/{stack-B17UN2nn.js → stack-BNwLzE43.js} +1 -1
- package/dist/{sum-66ew2byf.js → sum-ByFINZgi.js} +3 -3
- package/dist/{tensor-JwS7ZYY6.js → tensor-DbqgIV9B.js} +1 -1
- package/dist/tensor1d-CtJq5BOv.js +27 -0
- package/dist/{tensor2d-wxPAnDQy.js → tensor2d-CObBWBkW.js} +1 -1
- package/dist/tensor3d-BOukqWwr.js +30 -0
- package/dist/tensor4d-DLtk7Nxh.js +30 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/Evaluator.d.ts +2 -2
- package/dist/training/FullTrainer.d.ts +3 -3
- package/dist/training/FullTrainer.js +61 -69
- package/dist/training/Trainer.d.ts +15 -3
- package/dist/training/Trainer.js +39 -47
- package/dist/training/sparseCrossEntropy.js +12 -13
- package/dist/utilities/arrayClose.d.ts +1 -1
- package/dist/utilities/arrayClose.js +16 -7
- package/dist/utilities/dummy.d.ts +4 -4
- package/dist/utilities/dummy.js +13 -13
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/parameters.d.ts +1 -1
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-BuddVFLa.js → variable-DPFOJyRG.js} +1 -1
- package/dist/{webgpu_program-PFzf1hAQ.js → webgpu_program-Dhk9R5aG.js} +1 -1
- package/dist/{webgpu_util-D____QpY.js → webgpu_util-BqGnZg8t.js} +27 -27
- package/dist/{zeros--BdLQ3oG.js → zeros-Dnwix0p4.js} +1 -1
- package/package.json +2 -3
- package/dist/NanoGPTModel.d.ts +0 -52
- package/dist/NanoGPTModel.js +0 -203
- package/dist/TiedEmbedding-BxOerUmB.js +0 -43
- package/dist/ops-BFGCx8Ri.js +0 -1202
- package/dist/utilities/generate.d.ts +0 -3
- package/dist/utilities/generate.js +0 -22
- package/dist/utilities/save.d.ts +0 -9
- package/dist/utilities/save.js +0 -61
|
@@ -17,7 +17,7 @@ import { B as pt } from "./index-Tf7vU29b.js";
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
* =============================================================================
|
|
19
19
|
*/
|
|
20
|
-
const
|
|
20
|
+
const Fe = 1e-7, Re = 1e-4;
|
|
21
21
|
class Rs {
|
|
22
22
|
constructor(t, n) {
|
|
23
23
|
this.backend = t, this.dataMover = n, this.data = /* @__PURE__ */ new WeakMap(), this.dataIdsCount = 0;
|
|
@@ -38,7 +38,7 @@ class Rs {
|
|
|
38
38
|
return this.dataIdsCount;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
class
|
|
41
|
+
class xe {
|
|
42
42
|
refCount(t) {
|
|
43
43
|
return B("refCount");
|
|
44
44
|
}
|
|
@@ -84,7 +84,7 @@ class Fe {
|
|
|
84
84
|
}
|
|
85
85
|
/** Returns the smallest representable number. */
|
|
86
86
|
epsilon() {
|
|
87
|
-
return this.floatPrecision() === 32 ?
|
|
87
|
+
return this.floatPrecision() === 32 ? Fe : Re;
|
|
88
88
|
}
|
|
89
89
|
dispose() {
|
|
90
90
|
return B("dispose");
|
|
@@ -112,7 +112,7 @@ function B(e) {
|
|
|
112
112
|
function xs(e) {
|
|
113
113
|
let t = e.length, n = 0;
|
|
114
114
|
for (; t > 0; )
|
|
115
|
-
n = Math.random() * t | 0, t--,
|
|
115
|
+
n = Math.random() * t | 0, t--, Ne(e, t, n);
|
|
116
116
|
}
|
|
117
117
|
function Ns(e, t, n) {
|
|
118
118
|
return Math.max(e, Math.min(t, n));
|
|
@@ -120,7 +120,7 @@ function Ns(e, t, n) {
|
|
|
120
120
|
function $s(e) {
|
|
121
121
|
return e % 2 === 0 ? e : e + 1;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function Ne(e, t, n) {
|
|
124
124
|
const s = e[t];
|
|
125
125
|
e[t] = e[n], e[n] = s;
|
|
126
126
|
}
|
|
@@ -130,15 +130,15 @@ function Cs(e) {
|
|
|
130
130
|
t += e[n];
|
|
131
131
|
return t;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function p(e, t) {
|
|
134
134
|
if (!e)
|
|
135
135
|
throw new Error(typeof t == "string" ? t : t());
|
|
136
136
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
137
|
+
function te(e, t, n = "") {
|
|
138
|
+
p(xt(e, t), () => n + ` Shapes ${e} and ${t} must match`);
|
|
139
139
|
}
|
|
140
140
|
function Ps(e) {
|
|
141
|
-
|
|
141
|
+
p(e != null, () => "The input to the tensor constructor must be a non-null value.");
|
|
142
142
|
}
|
|
143
143
|
function z(e) {
|
|
144
144
|
if (e.length === 0)
|
|
@@ -161,14 +161,14 @@ function xt(e, t) {
|
|
|
161
161
|
return !1;
|
|
162
162
|
return !0;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function $e(e) {
|
|
165
165
|
return e % 1 === 0;
|
|
166
166
|
}
|
|
167
167
|
function _s(e) {
|
|
168
168
|
const t = Math.ceil(Math.sqrt(e));
|
|
169
169
|
return [t, Math.ceil(e / t)];
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function ht(e, t) {
|
|
172
172
|
return t <= e.length ? e : e + " ".repeat(t - e.length);
|
|
173
173
|
}
|
|
174
174
|
function Os(e, t = (r) => 0, n, s) {
|
|
@@ -213,12 +213,12 @@ function Gs(e, t) {
|
|
|
213
213
|
const r = e.slice();
|
|
214
214
|
return r[s] = t / n, r;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function Ce(e, t) {
|
|
217
217
|
const n = t.length;
|
|
218
|
-
return e = e == null ? t.map((s, r) => r) : [].concat(e),
|
|
218
|
+
return e = e == null ? t.map((s, r) => r) : [].concat(e), p(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), p(e.every((s) => $e(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s);
|
|
219
219
|
}
|
|
220
220
|
function Us(e, t) {
|
|
221
|
-
const n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null :
|
|
221
|
+
const n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : Ce(t, e).sort();
|
|
222
222
|
let o = 0;
|
|
223
223
|
for (let i = 0; i < e.length; ++i) {
|
|
224
224
|
if (a != null) {
|
|
@@ -231,9 +231,9 @@ function Us(e, t) {
|
|
|
231
231
|
return { newShape: n, keptDims: s };
|
|
232
232
|
}
|
|
233
233
|
function zs(e, t) {
|
|
234
|
-
return
|
|
234
|
+
return ee(e, t);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function ee(e, t) {
|
|
237
237
|
let n = null;
|
|
238
238
|
if (e == null || e === "float32")
|
|
239
239
|
n = new Float32Array(t);
|
|
@@ -247,14 +247,14 @@ function te(e, t) {
|
|
|
247
247
|
throw new Error(`Unknown data type ${e}`);
|
|
248
248
|
return n;
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function Pe(e, t) {
|
|
251
251
|
for (let n = 0; n < e.length; n++) {
|
|
252
252
|
const s = e[n];
|
|
253
253
|
if (isNaN(s) || !isFinite(s))
|
|
254
254
|
throw Error(`A tensor of type ${t} being uploaded contains ${s}.`);
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function Le(e) {
|
|
258
258
|
return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string";
|
|
259
259
|
}
|
|
260
260
|
function Vs(e, t) {
|
|
@@ -269,7 +269,7 @@ function It(e) {
|
|
|
269
269
|
return 1;
|
|
270
270
|
throw new Error(`Unknown dtype ${e}`);
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function _e(e) {
|
|
273
273
|
if (e == null)
|
|
274
274
|
return 0;
|
|
275
275
|
let t = 0;
|
|
@@ -278,16 +278,16 @@ function Le(e) {
|
|
|
278
278
|
function Nt(e) {
|
|
279
279
|
return typeof e == "string" || e instanceof String;
|
|
280
280
|
}
|
|
281
|
-
function
|
|
281
|
+
function Oe(e) {
|
|
282
282
|
return typeof e == "boolean";
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function Ge(e) {
|
|
285
285
|
return typeof e == "number";
|
|
286
286
|
}
|
|
287
287
|
function yt(e) {
|
|
288
|
-
return Array.isArray(e) ? yt(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" :
|
|
288
|
+
return Array.isArray(e) ? yt(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : Ge(e) ? "float32" : Nt(e) ? "string" : Oe(e) ? "bool" : "float32";
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function lt(e) {
|
|
291
291
|
return !!(e && e.constructor && e.call && e.apply);
|
|
292
292
|
}
|
|
293
293
|
function Ws(e, t) {
|
|
@@ -306,7 +306,7 @@ function $t(e) {
|
|
|
306
306
|
n[s] = n[s + 1] * e[s + 1];
|
|
307
307
|
return n;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function ne(e, t, n, s = !1) {
|
|
310
310
|
const r = new Array();
|
|
311
311
|
if (t.length === 1) {
|
|
312
312
|
const a = t[0] * (s ? 2 : 1);
|
|
@@ -315,7 +315,7 @@ function ee(e, t, n, s = !1) {
|
|
|
315
315
|
} else {
|
|
316
316
|
const a = t[0], o = t.slice(1), i = o.reduce((c, l) => c * l) * (s ? 2 : 1);
|
|
317
317
|
for (let c = 0; c < a; c++)
|
|
318
|
-
r[c] =
|
|
318
|
+
r[c] = ne(e + c * i, o, n, s);
|
|
319
319
|
}
|
|
320
320
|
return r;
|
|
321
321
|
}
|
|
@@ -327,7 +327,7 @@ function ct(e, t, n = !1) {
|
|
|
327
327
|
return [];
|
|
328
328
|
if (s !== t.length)
|
|
329
329
|
throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`);
|
|
330
|
-
return
|
|
330
|
+
return ne(0, e, t, n);
|
|
331
331
|
}
|
|
332
332
|
function js(e, t) {
|
|
333
333
|
if (Array.isArray(e))
|
|
@@ -340,13 +340,13 @@ function js(e, t) {
|
|
|
340
340
|
return Uint8Array.from(new Int32Array(e));
|
|
341
341
|
throw new Error(`Unknown dtype ${t}`);
|
|
342
342
|
}
|
|
343
|
-
function
|
|
344
|
-
const n =
|
|
343
|
+
function Ue(e, t) {
|
|
344
|
+
const n = se(e, t);
|
|
345
345
|
for (let s = 0; s < n.length; s++)
|
|
346
346
|
n[s] = 1;
|
|
347
347
|
return n;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function se(e, t) {
|
|
350
350
|
if (t == null || t === "float32" || t === "complex64")
|
|
351
351
|
return new Float32Array(e);
|
|
352
352
|
if (t === "int32")
|
|
@@ -367,7 +367,7 @@ function qs(e, t) {
|
|
|
367
367
|
}
|
|
368
368
|
function Ct(e) {
|
|
369
369
|
e.forEach((t) => {
|
|
370
|
-
|
|
370
|
+
p(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`);
|
|
371
371
|
});
|
|
372
372
|
}
|
|
373
373
|
function Ks(e, t, n) {
|
|
@@ -410,10 +410,10 @@ function Pt(e) {
|
|
|
410
410
|
* =============================================================================
|
|
411
411
|
*/
|
|
412
412
|
const Ut = "tfjsflags";
|
|
413
|
-
class
|
|
413
|
+
class ze {
|
|
414
414
|
// tslint:disable-next-line: no-any
|
|
415
415
|
constructor(t) {
|
|
416
|
-
this.global = t, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams =
|
|
416
|
+
this.global = t, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = Ve, this.populateURLFlags();
|
|
417
417
|
}
|
|
418
418
|
setPlatform(t, n) {
|
|
419
419
|
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;
|
|
@@ -473,27 +473,27 @@ class Ue {
|
|
|
473
473
|
const t = this.getQueryParams(this.global.location.search);
|
|
474
474
|
Ut in t && t[Ut].split(",").forEach((s) => {
|
|
475
475
|
const [r, a] = s.split(":");
|
|
476
|
-
this.urlFlags[r] =
|
|
476
|
+
this.urlFlags[r] = je(r, a);
|
|
477
477
|
});
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
function
|
|
480
|
+
function Ve(e) {
|
|
481
481
|
const t = {};
|
|
482
|
-
return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (
|
|
482
|
+
return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (We(t, s[0], s[1]), s.join("="))), t;
|
|
483
483
|
}
|
|
484
|
-
function
|
|
484
|
+
function We(e, t, n) {
|
|
485
485
|
e[decodeURIComponent(t)] = decodeURIComponent(n || "");
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function je(e, t) {
|
|
488
488
|
const n = t.toLowerCase();
|
|
489
489
|
return n === "true" || n === "false" ? n === "true" : `${+n}` === n ? +n : t;
|
|
490
490
|
}
|
|
491
491
|
function S() {
|
|
492
|
-
return
|
|
492
|
+
return re;
|
|
493
493
|
}
|
|
494
|
-
let
|
|
495
|
-
function
|
|
496
|
-
|
|
494
|
+
let re = null;
|
|
495
|
+
function qe(e) {
|
|
496
|
+
re = e;
|
|
497
497
|
}
|
|
498
498
|
/**
|
|
499
499
|
* @license
|
|
@@ -512,7 +512,7 @@ function je(e) {
|
|
|
512
512
|
* =============================================================================
|
|
513
513
|
*/
|
|
514
514
|
let bt;
|
|
515
|
-
function
|
|
515
|
+
function ae() {
|
|
516
516
|
if (bt == null) {
|
|
517
517
|
let e;
|
|
518
518
|
if (typeof window < "u")
|
|
@@ -529,12 +529,12 @@ function re() {
|
|
|
529
529
|
}
|
|
530
530
|
return bt;
|
|
531
531
|
}
|
|
532
|
-
function
|
|
533
|
-
const e =
|
|
532
|
+
function Ke() {
|
|
533
|
+
const e = ae();
|
|
534
534
|
return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals;
|
|
535
535
|
}
|
|
536
536
|
function Lt(e, t) {
|
|
537
|
-
const n =
|
|
537
|
+
const n = Ke();
|
|
538
538
|
if (n.has(e))
|
|
539
539
|
return n.get(e);
|
|
540
540
|
{
|
|
@@ -542,7 +542,7 @@ function Lt(e, t) {
|
|
|
542
542
|
return n.set(e, s), n.get(e);
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
-
const
|
|
545
|
+
const He = "Abs", Xs = "Acos", Js = "Acosh", oe = "Add", Ys = "AddN", Zs = "All", Qs = "Any", tr = "ArgMax", er = "ArgMin", nr = "Asin", sr = "Asinh", rr = "Atan", ar = "Atanh", or = "Atan2", ir = "AvgPool", cr = "AvgPoolGrad", lr = "AvgPool3D", ur = "AvgPool3DGrad", hr = "BatchMatMul", dr = "BatchToSpaceND", fr = "Bincount", gr = "BitwiseAnd", mr = "BroadcastTo", pr = "BroadcastArgs", ie = "Cast", yr = "Ceil", br = "ClipByValue", wr = "Complex", Xe = "ComplexAbs", Sr = "Concat", kr = "Conv2D", Ir = "Conv2DBackpropFilter", Tr = "Conv2DBackpropInput", Ar = "Conv3D", Er = "Conv3DBackpropFilterV2", vr = "Conv3DBackpropInputV2", Br = "Cos", Mr = "Cosh", Dr = "Cumprod", Fr = "Cumsum", Rr = "CropAndResize", xr = "DenseBincount", Nr = "DepthToSpace", $r = "DepthwiseConv2dNative", Cr = "DepthwiseConv2dNativeBackpropFilter", Pr = "DepthwiseConv2dNativeBackpropInput", Lr = "Diag", _r = "Dilation2D", Or = "Dilation2DBackpropInput", Gr = "Dilation2DBackpropFilter", Ur = "Draw", Je = "RealDiv", zr = "Einsum", Vr = "Elu", Wr = "EluGrad", jr = "Erf", qr = "Equal", Kr = "Exp", Hr = "ExpandDims", Xr = "Expm1", Jr = "FFT", Ye = "Fill", Yr = "FlipLeftRight", Zr = "Floor", Ze = "FloorDiv", Qr = "FusedBatchNorm", ta = "GatherV2", ea = "GatherNd", na = "Greater", sa = "GreaterEqual", ce = "Identity", ra = "IFFT", aa = "Imag", oa = "IsFinite", ia = "IsInf", ca = "IsNan", la = "LeakyRelu", ua = "Less", ha = "LessEqual", da = "LinSpace", fa = "Log", ga = "Log1p", ma = "LogicalAnd", pa = "LogicalNot", ya = "LogicalOr", ba = "LogSoftmax", wa = "LRN", Sa = "LRNGrad", ka = "Max", Qe = "Maximum", Ia = "MaxPool", Ta = "MaxPoolGrad", Aa = "MaxPool3D", Ea = "MaxPool3DGrad", va = "MaxPoolWithArgmax", Ba = "Mean", Ma = "Min", Da = "Minimum", Fa = "MirrorPad", Ra = "Mod", xa = "Multinomial", tn = "Multiply", Na = "Neg", $a = "NotEqual", Ca = "NonMaxSuppressionV3", Pa = "NonMaxSuppressionV4", La = "NonMaxSuppressionV5", _a = "OnesLike", Oa = "OneHot", Ga = "Pack", Ua = "PadV2", en = "Pow", za = "Prelu", Va = "Prod", Wa = "RaggedGather", ja = "RaggedRange", qa = "RaggedTensorToTensor", Ka = "Range", Ha = "Real", Xa = "Reciprocal", Ja = "Relu", Ya = "Reshape", Za = "ResizeNearestNeighbor", Qa = "ResizeNearestNeighborGrad", to = "ResizeBilinear", eo = "ResizeBilinearGrad", no = "Relu6", so = "Reverse", ro = "Round", ao = "Rsqrt", oo = "ScatterNd", io = "TensorScatterUpdate", co = "SearchSorted", lo = "Select", uo = "Selu", ho = "Slice", fo = "Sin", go = "Sinh", mo = "Sign", po = "Sigmoid", yo = "Softplus", nn = "Sqrt", bo = "Sum", wo = "SpaceToBatchND", So = "SplitV", ko = "Softmax", Io = "SparseFillEmptyRows", To = "SparseReshape", Ao = "SparseSegmentMean", Eo = "SparseSegmentSum", vo = "SparseToDense", Bo = "SquaredDifference", Mo = "Square", Do = "StaticRegexReplace", Fo = "StridedSlice", Ro = "StringNGrams", xo = "StringSplit", No = "StringToHashBucketFast", sn = "Sub", $o = "Tan", Co = "Tanh", Po = "Tile", Lo = "TopK", _o = "Transform", Oo = "Transpose", Go = "Unique", Uo = "Unpack", zo = "UnsortedSegmentSum", rn = "ZerosLike", Vo = "Step", Wo = "FromPixels", jo = "RotateWithOffset", qo = "_FusedMatMul", Ko = "FusedConv2D", Ho = "FusedDepthwiseConv2D";
|
|
546
546
|
/**
|
|
547
547
|
* @license
|
|
548
548
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -583,7 +583,7 @@ function Xo(...e) {
|
|
|
583
583
|
*/
|
|
584
584
|
const ft = Lt("kernelRegistry", () => /* @__PURE__ */ new Map()), Tt = Lt("gradRegistry", () => /* @__PURE__ */ new Map());
|
|
585
585
|
function zt(e, t) {
|
|
586
|
-
const n =
|
|
586
|
+
const n = le(e, t);
|
|
587
587
|
return ft.get(n);
|
|
588
588
|
}
|
|
589
589
|
function Vt(e) {
|
|
@@ -601,14 +601,14 @@ function Wt(e) {
|
|
|
601
601
|
return n;
|
|
602
602
|
}
|
|
603
603
|
function Jo(e) {
|
|
604
|
-
const { kernelName: t, backendName: n } = e, s =
|
|
604
|
+
const { kernelName: t, backendName: n } = e, s = le(t, n);
|
|
605
605
|
ft.has(s) && O(`The kernel '${t}' for backend '${n}' is already registered`), ft.set(s, e);
|
|
606
606
|
}
|
|
607
607
|
function Yo(e) {
|
|
608
608
|
const { kernelName: t } = e;
|
|
609
609
|
Tt.has(t) && S().getBool("DEBUG") && O(`Overriding the gradient for '${t}'`), Tt.set(t, e);
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function le(e, t) {
|
|
612
612
|
return `${t}_${e}`;
|
|
613
613
|
}
|
|
614
614
|
/**
|
|
@@ -627,7 +627,7 @@ function ce(e, t) {
|
|
|
627
627
|
* limitations under the License.
|
|
628
628
|
* =============================================================================
|
|
629
629
|
*/
|
|
630
|
-
function
|
|
630
|
+
function ue(e) {
|
|
631
631
|
return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray;
|
|
632
632
|
}
|
|
633
633
|
/**
|
|
@@ -647,15 +647,15 @@ function le(e) {
|
|
|
647
647
|
* =============================================================================
|
|
648
648
|
*/
|
|
649
649
|
function Zo(e, t) {
|
|
650
|
-
return t === "string" ?
|
|
650
|
+
return t === "string" ? he(e) : _t([e], t);
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function an(e, t) {
|
|
653
653
|
return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool";
|
|
654
654
|
}
|
|
655
655
|
function _t(e, t) {
|
|
656
656
|
if (t === "string")
|
|
657
657
|
throw new Error("Cannot convert a string[] to a TypedArray");
|
|
658
|
-
if (Array.isArray(e) && (e =
|
|
658
|
+
if (Array.isArray(e) && (e = ut(e)), S().getBool("DEBUG") && Pe(e, t), an(e, t))
|
|
659
659
|
return e;
|
|
660
660
|
if (t == null || t === "float32" || t === "complex64")
|
|
661
661
|
return new Float32Array(e);
|
|
@@ -672,27 +672,27 @@ function _t(e, t) {
|
|
|
672
672
|
function gt() {
|
|
673
673
|
return S().platform.now();
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function he(e, t = "utf-8") {
|
|
676
676
|
return t = t || "utf-8", S().platform.encode(e, t);
|
|
677
677
|
}
|
|
678
678
|
function jt(e, t = "utf-8") {
|
|
679
679
|
return t = t || "utf-8", S().platform.decode(e, t);
|
|
680
680
|
}
|
|
681
|
-
function
|
|
682
|
-
return S().platform.isTypedArray != null ? S().platform.isTypedArray(e) :
|
|
681
|
+
function R(e) {
|
|
682
|
+
return S().platform.isTypedArray != null ? S().platform.isTypedArray(e) : ue(e);
|
|
683
683
|
}
|
|
684
|
-
function
|
|
685
|
-
if (t == null && (t = []), typeof e == "boolean" || typeof e == "number" || typeof e == "string" || Pt(e) || e == null ||
|
|
684
|
+
function ut(e, t = [], n = !1) {
|
|
685
|
+
if (t == null && (t = []), typeof e == "boolean" || typeof e == "number" || typeof e == "string" || Pt(e) || e == null || R(e) && n)
|
|
686
686
|
t.push(e);
|
|
687
|
-
else if (Array.isArray(e) ||
|
|
687
|
+
else if (Array.isArray(e) || R(e))
|
|
688
688
|
for (let s = 0; s < e.length; ++s)
|
|
689
|
-
|
|
689
|
+
ut(e[s], t, n);
|
|
690
690
|
else {
|
|
691
691
|
let s = -1;
|
|
692
692
|
for (const r of Object.keys(e))
|
|
693
693
|
/^([1-9]+[0-9]*|0)$/.test(r) && (s = Math.max(s, Number(r)));
|
|
694
694
|
for (let r = 0; r <= s; r++)
|
|
695
|
-
|
|
695
|
+
ut(e[r], t, n);
|
|
696
696
|
}
|
|
697
697
|
return t;
|
|
698
698
|
}
|
|
@@ -712,9 +712,9 @@ function lt(e, t = [], n = !1) {
|
|
|
712
712
|
* limitations under the License.
|
|
713
713
|
* =============================================================================
|
|
714
714
|
*/
|
|
715
|
-
class
|
|
715
|
+
class on {
|
|
716
716
|
constructor(t, n) {
|
|
717
|
-
this.backendTimer = t, this.logger = n, n == null && (this.logger = new
|
|
717
|
+
this.backendTimer = t, this.logger = n, n == null && (this.logger = new ln());
|
|
718
718
|
}
|
|
719
719
|
profileKernel(t, n, s) {
|
|
720
720
|
let r;
|
|
@@ -735,7 +735,7 @@ class an {
|
|
|
735
735
|
for (let l = 0; l < r.length; l++) {
|
|
736
736
|
const u = r[l];
|
|
737
737
|
u.data().then((h) => {
|
|
738
|
-
|
|
738
|
+
cn(h, u.dtype, t);
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
return {
|
|
@@ -755,7 +755,7 @@ class an {
|
|
|
755
755
|
});
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
|
-
function
|
|
758
|
+
function cn(e, t, n) {
|
|
759
759
|
if (t !== "float32")
|
|
760
760
|
return !1;
|
|
761
761
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -765,14 +765,14 @@ function on(e, t, n) {
|
|
|
765
765
|
}
|
|
766
766
|
return !1;
|
|
767
767
|
}
|
|
768
|
-
class
|
|
768
|
+
class ln {
|
|
769
769
|
logKernelProfile(t, n, s, r, a, o) {
|
|
770
|
-
const i = typeof r == "number" ?
|
|
770
|
+
const i = typeof r == "number" ? ht(`${r}ms`, 9) : r.error, c = ht(t, 25), l = n.rank, u = n.size, h = ht(n.shape.toString(), 14);
|
|
771
771
|
let d = "";
|
|
772
772
|
for (const m in a) {
|
|
773
|
-
const
|
|
774
|
-
if (
|
|
775
|
-
const g =
|
|
773
|
+
const y = a[m];
|
|
774
|
+
if (y != null) {
|
|
775
|
+
const g = y.shape || n.shape, w = g.length;
|
|
776
776
|
d += `${m}: ${w}D ${w > 0 ? g : ""} `;
|
|
777
777
|
}
|
|
778
778
|
}
|
|
@@ -795,7 +795,7 @@ class cn {
|
|
|
795
795
|
* limitations under the License.
|
|
796
796
|
* =============================================================================
|
|
797
797
|
*/
|
|
798
|
-
function
|
|
798
|
+
function un(e, t, n) {
|
|
799
799
|
const s = {}, r = {};
|
|
800
800
|
for (let c = 0; c < t.length; c++)
|
|
801
801
|
s[t[c].id] = !0;
|
|
@@ -804,7 +804,7 @@ function ln(e, t, n) {
|
|
|
804
804
|
for (const h in u) {
|
|
805
805
|
const d = u[h];
|
|
806
806
|
let m = !1;
|
|
807
|
-
for (let
|
|
807
|
+
for (let y = 0; y < t.length; y++)
|
|
808
808
|
if (s[d.id]) {
|
|
809
809
|
l.outputs.forEach((g) => s[g.id] = !0), m = !0, r[l.id] = !0;
|
|
810
810
|
break;
|
|
@@ -840,7 +840,7 @@ function ln(e, t, n) {
|
|
|
840
840
|
}
|
|
841
841
|
return i;
|
|
842
842
|
}
|
|
843
|
-
function
|
|
843
|
+
function hn(e, t, n, s) {
|
|
844
844
|
for (let r = t.length - 1; r >= 0; r--) {
|
|
845
845
|
const a = t[r], o = [];
|
|
846
846
|
if (a.outputs.forEach((c) => {
|
|
@@ -884,13 +884,13 @@ function un(e, t, n, s) {
|
|
|
884
884
|
* =============================================================================
|
|
885
885
|
*/
|
|
886
886
|
const qt = 20, at = 3, wt = 7;
|
|
887
|
-
function
|
|
888
|
-
const r = $t(t), a =
|
|
887
|
+
function dn(e, t, n, s) {
|
|
888
|
+
const r = $t(t), a = fn(e, t, n, r), o = t.length, i = dt(e, t, n, r, a), c = ["Tensor"];
|
|
889
889
|
return s && (c.push(` dtype: ${n}`), c.push(` rank: ${o}`), c.push(` shape: [${t}]`), c.push(" values:")), c.push(i.map((l) => " " + l).join(`
|
|
890
890
|
`)), c.join(`
|
|
891
891
|
`);
|
|
892
892
|
}
|
|
893
|
-
function
|
|
893
|
+
function fn(e, t, n, s) {
|
|
894
894
|
const r = z(t), a = s[s.length - 1], o = new Array(a).fill(0), i = t.length, c = n === "complex64" ? it(e) : e;
|
|
895
895
|
if (i > 1)
|
|
896
896
|
for (let l = 0; l < r / a; l++) {
|
|
@@ -902,19 +902,19 @@ function dn(e, t, n, s) {
|
|
|
902
902
|
}
|
|
903
903
|
function ot(e, t, n) {
|
|
904
904
|
let s;
|
|
905
|
-
return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(wt))} + ${parseFloat(e[1].toFixed(wt))}j` : Nt(e) ? s = `'${e}'` : n === "bool" ? s =
|
|
905
|
+
return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(wt))} + ${parseFloat(e[1].toFixed(wt))}j` : Nt(e) ? s = `'${e}'` : n === "bool" ? s = de(e) : s = parseFloat(e.toFixed(wt)).toString(), ht(s, t);
|
|
906
906
|
}
|
|
907
|
-
function
|
|
907
|
+
function de(e) {
|
|
908
908
|
return e === 0 ? "false" : "true";
|
|
909
909
|
}
|
|
910
|
-
function
|
|
910
|
+
function dt(e, t, n, s, r, a = !0) {
|
|
911
911
|
const o = n === "complex64" ? 2 : 1, i = t[0], c = t.length;
|
|
912
912
|
if (c === 0) {
|
|
913
913
|
if (n === "complex64") {
|
|
914
914
|
const g = it(e);
|
|
915
915
|
return [ot(g[0], 0, n)];
|
|
916
916
|
}
|
|
917
|
-
return n === "bool" ? [
|
|
917
|
+
return n === "bool" ? [de(e[0])] : [e[0].toString()];
|
|
918
918
|
}
|
|
919
919
|
if (c === 1) {
|
|
920
920
|
if (i > qt) {
|
|
@@ -932,7 +932,7 @@ function ht(e, t, n, s, r, a = !0) {
|
|
|
932
932
|
if (i > qt) {
|
|
933
933
|
for (let g = 0; g < at; g++) {
|
|
934
934
|
const w = g * h, I = w + h;
|
|
935
|
-
d.push(...
|
|
935
|
+
d.push(...dt(
|
|
936
936
|
e.slice(w, I),
|
|
937
937
|
l,
|
|
938
938
|
n,
|
|
@@ -945,7 +945,7 @@ function ht(e, t, n, s, r, a = !0) {
|
|
|
945
945
|
d.push("...");
|
|
946
946
|
for (let g = i - at; g < i; g++) {
|
|
947
947
|
const w = g * h, I = w + h;
|
|
948
|
-
d.push(...
|
|
948
|
+
d.push(...dt(
|
|
949
949
|
e.slice(w, I),
|
|
950
950
|
l,
|
|
951
951
|
n,
|
|
@@ -958,7 +958,7 @@ function ht(e, t, n, s, r, a = !0) {
|
|
|
958
958
|
} else
|
|
959
959
|
for (let g = 0; g < i; g++) {
|
|
960
960
|
const w = g * h, I = w + h;
|
|
961
|
-
d.push(...
|
|
961
|
+
d.push(...dt(
|
|
962
962
|
e.slice(w, I),
|
|
963
963
|
l,
|
|
964
964
|
n,
|
|
@@ -972,12 +972,12 @@ function ht(e, t, n, s, r, a = !0) {
|
|
|
972
972
|
d[0] = "[" + (i > 0 ? d[0] + m : "");
|
|
973
973
|
for (let g = 1; g < d.length - 1; g++)
|
|
974
974
|
d[g] = " " + d[g] + m;
|
|
975
|
-
let
|
|
975
|
+
let y = `,
|
|
976
976
|
`;
|
|
977
977
|
for (let g = 2; g < c; g++)
|
|
978
|
-
|
|
978
|
+
y += `
|
|
979
979
|
`;
|
|
980
|
-
return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" :
|
|
980
|
+
return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" : y), d;
|
|
981
981
|
}
|
|
982
982
|
function it(e) {
|
|
983
983
|
const t = [];
|
|
@@ -1001,15 +1001,15 @@ function it(e) {
|
|
|
1001
1001
|
* limitations under the License.
|
|
1002
1002
|
* =============================================================================
|
|
1003
1003
|
*/
|
|
1004
|
-
class
|
|
1004
|
+
class gn {
|
|
1005
1005
|
constructor(t, n, s) {
|
|
1006
1006
|
if (this.dtype = n, this.shape = t.slice(), this.size = z(t), s != null) {
|
|
1007
1007
|
const r = s.length;
|
|
1008
|
-
|
|
1008
|
+
p(r === this.size, () => `Length of values '${r}' does not match the size inferred by the shape '${this.size}'.`);
|
|
1009
1009
|
}
|
|
1010
1010
|
if (n === "complex64")
|
|
1011
1011
|
throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");
|
|
1012
|
-
this.values = s ||
|
|
1012
|
+
this.values = s || ee(n, this.size), this.strides = $t(t);
|
|
1013
1013
|
}
|
|
1014
1014
|
/**
|
|
1015
1015
|
* Sets a value in the buffer at a given location.
|
|
@@ -1020,7 +1020,7 @@ class fn {
|
|
|
1020
1020
|
* @doc {heading: 'Tensors', subheading: 'Creation'}
|
|
1021
1021
|
*/
|
|
1022
1022
|
set(t, ...n) {
|
|
1023
|
-
n.length === 0 && (n = [0]),
|
|
1023
|
+
n.length === 0 && (n = [0]), p(n.length === this.rank, () => `The number of provided coordinates (${n.length}) must match the rank (${this.rank})`);
|
|
1024
1024
|
const s = this.locToIndex(n);
|
|
1025
1025
|
this.values[s] = t;
|
|
1026
1026
|
}
|
|
@@ -1075,17 +1075,17 @@ class fn {
|
|
|
1075
1075
|
* @doc {heading: 'Tensors', subheading: 'Creation'}
|
|
1076
1076
|
*/
|
|
1077
1077
|
toTensor() {
|
|
1078
|
-
return
|
|
1078
|
+
return x().makeTensor(this.values, this.shape, this.dtype);
|
|
1079
1079
|
}
|
|
1080
1080
|
}
|
|
1081
|
-
let
|
|
1082
|
-
function gn(e) {
|
|
1083
|
-
R = e;
|
|
1084
|
-
}
|
|
1081
|
+
let x = null, Y = null;
|
|
1085
1082
|
function mn(e) {
|
|
1083
|
+
x = e;
|
|
1084
|
+
}
|
|
1085
|
+
function pn(e) {
|
|
1086
1086
|
Y = e;
|
|
1087
1087
|
}
|
|
1088
|
-
class
|
|
1088
|
+
class M {
|
|
1089
1089
|
constructor(t, n, s, r) {
|
|
1090
1090
|
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";
|
|
1091
1091
|
}
|
|
@@ -1135,7 +1135,7 @@ class x {
|
|
|
1135
1135
|
*/
|
|
1136
1136
|
async data() {
|
|
1137
1137
|
this.throwIfDisposed();
|
|
1138
|
-
const t =
|
|
1138
|
+
const t = x().read(this.dataId);
|
|
1139
1139
|
if (this.dtype === "string") {
|
|
1140
1140
|
const n = await t;
|
|
1141
1141
|
try {
|
|
@@ -1181,7 +1181,7 @@ class x {
|
|
|
1181
1181
|
* @doc {heading: 'Tensors', subheading: 'Classes'}
|
|
1182
1182
|
*/
|
|
1183
1183
|
dataToGPU(t) {
|
|
1184
|
-
return this.throwIfDisposed(),
|
|
1184
|
+
return this.throwIfDisposed(), x().readToGPU(this.dataId, t);
|
|
1185
1185
|
}
|
|
1186
1186
|
/**
|
|
1187
1187
|
* Synchronously downloads the values from the `tf.Tensor`. This blocks the
|
|
@@ -1191,7 +1191,7 @@ class x {
|
|
|
1191
1191
|
*/
|
|
1192
1192
|
dataSync() {
|
|
1193
1193
|
this.throwIfDisposed();
|
|
1194
|
-
const t =
|
|
1194
|
+
const t = x().readSync(this.dataId);
|
|
1195
1195
|
if (this.dtype === "string")
|
|
1196
1196
|
try {
|
|
1197
1197
|
return t.map((n) => jt(n));
|
|
@@ -1203,7 +1203,7 @@ class x {
|
|
|
1203
1203
|
/** Returns the underlying bytes of the tensor's data. */
|
|
1204
1204
|
async bytes() {
|
|
1205
1205
|
this.throwIfDisposed();
|
|
1206
|
-
const t = await
|
|
1206
|
+
const t = await x().read(this.dataId);
|
|
1207
1207
|
return this.dtype === "string" ? t : new Uint8Array(t.buffer);
|
|
1208
1208
|
}
|
|
1209
1209
|
/**
|
|
@@ -1212,7 +1212,7 @@ class x {
|
|
|
1212
1212
|
* @doc {heading: 'Tensors', subheading: 'Classes'}
|
|
1213
1213
|
*/
|
|
1214
1214
|
dispose() {
|
|
1215
|
-
this.isDisposed || (this.kerasMask && this.kerasMask.dispose(),
|
|
1215
|
+
this.isDisposed || (this.kerasMask && this.kerasMask.dispose(), x().disposeTensor(this), this.isDisposedInternal = !0);
|
|
1216
1216
|
}
|
|
1217
1217
|
get isDisposed() {
|
|
1218
1218
|
return this.isDisposedInternal;
|
|
@@ -1246,23 +1246,23 @@ class x {
|
|
|
1246
1246
|
*/
|
|
1247
1247
|
toString(t = !1) {
|
|
1248
1248
|
const n = this.dataSync();
|
|
1249
|
-
return
|
|
1249
|
+
return dn(n, this.shape, this.dtype, t);
|
|
1250
1250
|
}
|
|
1251
1251
|
cast(t) {
|
|
1252
1252
|
return this.throwIfDisposed(), Y.cast(this, t);
|
|
1253
1253
|
}
|
|
1254
1254
|
variable(t = !0, n, s) {
|
|
1255
|
-
return this.throwIfDisposed(),
|
|
1255
|
+
return this.throwIfDisposed(), x().makeVariable(this, t, n, s);
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
|
-
Object.defineProperty(
|
|
1258
|
+
Object.defineProperty(M, Symbol.hasInstance, {
|
|
1259
1259
|
value: (e) => !!e && e.data != null && e.dataSync != null && e.throwIfDisposed != null
|
|
1260
1260
|
});
|
|
1261
|
-
function
|
|
1262
|
-
return Lt("Tensor", () =>
|
|
1261
|
+
function fe() {
|
|
1262
|
+
return Lt("Tensor", () => M);
|
|
1263
1263
|
}
|
|
1264
|
-
|
|
1265
|
-
class mt extends
|
|
1264
|
+
fe();
|
|
1265
|
+
class mt extends M {
|
|
1266
1266
|
constructor(t, n, s, r) {
|
|
1267
1267
|
super(t.shape, t.dtype, t.dataId, r), this.trainable = n, this.name = s;
|
|
1268
1268
|
}
|
|
@@ -1279,18 +1279,18 @@ class mt extends x {
|
|
|
1279
1279
|
throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);
|
|
1280
1280
|
if (!xt(t.shape, this.shape))
|
|
1281
1281
|
throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);
|
|
1282
|
-
|
|
1282
|
+
x().disposeTensor(this), this.dataId = t.dataId, x().incRef(
|
|
1283
1283
|
this,
|
|
1284
1284
|
null
|
|
1285
1285
|
/* backend */
|
|
1286
1286
|
);
|
|
1287
1287
|
}
|
|
1288
1288
|
dispose() {
|
|
1289
|
-
|
|
1289
|
+
x().disposeVariable(this), this.isDisposedInternal = !0;
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
1292
|
Object.defineProperty(mt, Symbol.hasInstance, {
|
|
1293
|
-
value: (e) => e instanceof
|
|
1293
|
+
value: (e) => e instanceof M && e.assign != null && e.assign instanceof Function
|
|
1294
1294
|
});
|
|
1295
1295
|
/**
|
|
1296
1296
|
* @license
|
|
@@ -1312,14 +1312,14 @@ var Kt;
|
|
|
1312
1312
|
(function(e) {
|
|
1313
1313
|
e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6";
|
|
1314
1314
|
})(Kt || (Kt = {}));
|
|
1315
|
-
var
|
|
1315
|
+
var At;
|
|
1316
1316
|
(function(e) {
|
|
1317
1317
|
e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64";
|
|
1318
|
-
})(
|
|
1319
|
-
var
|
|
1318
|
+
})(At || (At = {}));
|
|
1319
|
+
var Et;
|
|
1320
1320
|
(function(e) {
|
|
1321
1321
|
e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64";
|
|
1322
|
-
})(
|
|
1322
|
+
})(Et || (Et = {}));
|
|
1323
1323
|
var vt;
|
|
1324
1324
|
(function(e) {
|
|
1325
1325
|
e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64";
|
|
@@ -1328,27 +1328,27 @@ var Bt;
|
|
|
1328
1328
|
(function(e) {
|
|
1329
1329
|
e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64";
|
|
1330
1330
|
})(Bt || (Bt = {}));
|
|
1331
|
-
const
|
|
1331
|
+
const yn = {
|
|
1332
1332
|
float32: vt,
|
|
1333
|
-
int32:
|
|
1334
|
-
bool:
|
|
1333
|
+
int32: At,
|
|
1334
|
+
bool: Et,
|
|
1335
1335
|
complex64: Bt
|
|
1336
1336
|
};
|
|
1337
|
-
function
|
|
1337
|
+
function ge(e, t) {
|
|
1338
1338
|
if (e === "string" || t === "string") {
|
|
1339
1339
|
if (e === "string" && t === "string")
|
|
1340
1340
|
return "string";
|
|
1341
1341
|
throw new Error(`Can not upcast ${e} with ${t}`);
|
|
1342
1342
|
}
|
|
1343
|
-
return
|
|
1343
|
+
return yn[e][t];
|
|
1344
1344
|
}
|
|
1345
1345
|
function Qo(e) {
|
|
1346
|
-
return
|
|
1346
|
+
return ge(e, "int32");
|
|
1347
1347
|
}
|
|
1348
|
-
function
|
|
1348
|
+
function me(e) {
|
|
1349
1349
|
return e != null && typeof e == "object" && "texture" in e && e.texture instanceof WebGLTexture;
|
|
1350
1350
|
}
|
|
1351
|
-
function
|
|
1351
|
+
function pe(e) {
|
|
1352
1352
|
return typeof GPUBuffer < "u" && e != null && typeof e == "object" && "buffer" in e && e.buffer instanceof GPUBuffer;
|
|
1353
1353
|
}
|
|
1354
1354
|
/**
|
|
@@ -1370,32 +1370,32 @@ function me(e) {
|
|
|
1370
1370
|
function K(e, t) {
|
|
1371
1371
|
if (e.dtype === t.dtype)
|
|
1372
1372
|
return [e, t];
|
|
1373
|
-
const n =
|
|
1373
|
+
const n = ge(e.dtype, t.dtype);
|
|
1374
1374
|
return [e.cast(n), t.cast(n)];
|
|
1375
1375
|
}
|
|
1376
1376
|
function ti(e, t) {
|
|
1377
1377
|
return t.some((n) => n.id === e.id);
|
|
1378
1378
|
}
|
|
1379
|
-
function
|
|
1379
|
+
function ye(e) {
|
|
1380
1380
|
const t = [];
|
|
1381
|
-
return
|
|
1381
|
+
return be(e, t, /* @__PURE__ */ new Set()), t;
|
|
1382
1382
|
}
|
|
1383
|
-
function
|
|
1383
|
+
function be(e, t, n) {
|
|
1384
1384
|
if (e == null)
|
|
1385
1385
|
return;
|
|
1386
|
-
if (e instanceof
|
|
1386
|
+
if (e instanceof M) {
|
|
1387
1387
|
t.push(e);
|
|
1388
1388
|
return;
|
|
1389
1389
|
}
|
|
1390
|
-
if (!
|
|
1390
|
+
if (!bn(e))
|
|
1391
1391
|
return;
|
|
1392
1392
|
const s = e;
|
|
1393
1393
|
for (const r in s) {
|
|
1394
1394
|
const a = s[r];
|
|
1395
|
-
n.has(a) || (n.add(a),
|
|
1395
|
+
n.has(a) || (n.add(a), be(a, t, n));
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
|
-
function
|
|
1398
|
+
function bn(e) {
|
|
1399
1399
|
return Array.isArray(e) || typeof e == "object";
|
|
1400
1400
|
}
|
|
1401
1401
|
/**
|
|
@@ -1494,7 +1494,7 @@ class et {
|
|
|
1494
1494
|
if (!(s ? await n : n))
|
|
1495
1495
|
return !1;
|
|
1496
1496
|
}
|
|
1497
|
-
return this.backendInstance = this.registry[t], this.setupRegisteredKernels(), this.profiler = new
|
|
1497
|
+
return this.backendInstance = this.registry[t], this.setupRegisteredKernels(), this.profiler = new on(this.backendInstance), !0;
|
|
1498
1498
|
}
|
|
1499
1499
|
setupRegisteredKernels() {
|
|
1500
1500
|
Wt(this.backendName).forEach((n) => {
|
|
@@ -1518,7 +1518,7 @@ class et {
|
|
|
1518
1518
|
throw new Error(`Cannot initialize backend ${t}, no registration found.`);
|
|
1519
1519
|
try {
|
|
1520
1520
|
const s = n.factory();
|
|
1521
|
-
if (s && !(s instanceof
|
|
1521
|
+
if (s && !(s instanceof xe) && typeof s.then == "function") {
|
|
1522
1522
|
const r = ++this.pendingBackendInitId, a = s.then((o) => r < this.pendingBackendInitId ? !1 : (this.registry[t] = o, this.pendingBackendInit = null, !0)).catch((o) => (r < this.pendingBackendInitId || (this.pendingBackendInit = null, O(`Initialization of backend ${t} failed`), O(o.stack || o.message)), !1));
|
|
1523
1523
|
return this.pendingBackendInit = a, { success: a, asyncInit: !0 };
|
|
1524
1524
|
} else
|
|
@@ -1588,11 +1588,11 @@ class et {
|
|
|
1588
1588
|
* execution.
|
|
1589
1589
|
*/
|
|
1590
1590
|
clone(t) {
|
|
1591
|
-
const n = f.runKernel(
|
|
1591
|
+
const n = f.runKernel(ce, { x: t }), s = { x: t }, r = (o) => ({
|
|
1592
1592
|
x: () => {
|
|
1593
1593
|
const i = "float32", c = { x: o }, l = { dtype: i };
|
|
1594
1594
|
return f.runKernel(
|
|
1595
|
-
|
|
1595
|
+
ie,
|
|
1596
1596
|
c,
|
|
1597
1597
|
// tslint:disable-next-line: no-unnecessary-type-assertion
|
|
1598
1598
|
l
|
|
@@ -1646,28 +1646,28 @@ class et {
|
|
|
1646
1646
|
let c;
|
|
1647
1647
|
const l = St(t) ? t.kernelName : this.state.activeScope != null ? this.state.activeScope.name : "";
|
|
1648
1648
|
if (St(t)) {
|
|
1649
|
-
const { kernelName:
|
|
1649
|
+
const { kernelName: y, inputs: g, attrs: w } = t;
|
|
1650
1650
|
this.backendName == null && this.backend;
|
|
1651
|
-
const I = zt(
|
|
1652
|
-
|
|
1651
|
+
const I = zt(y, this.backendName);
|
|
1652
|
+
p(I != null, () => `Cannot find registered kernel '${y}' for backend '${this.backendName}'`), i = () => {
|
|
1653
1653
|
const _ = this.backend.numDataIds();
|
|
1654
1654
|
c = I.kernelFunc({ inputs: g, attrs: w, backend: this.backend });
|
|
1655
1655
|
const X = Array.isArray(c) ? c : [c];
|
|
1656
|
-
this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(
|
|
1656
|
+
this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(y, _, X);
|
|
1657
1657
|
const J = X.map((rt) => rt.rank != null ? rt : this.makeTensorFromTensorInfo(rt));
|
|
1658
1658
|
if (r) {
|
|
1659
|
-
const rt = this.getTensorsForGradient(
|
|
1659
|
+
const rt = this.getTensorsForGradient(y, g, J);
|
|
1660
1660
|
s = this.saveTensorsForBackwardMode(rt);
|
|
1661
1661
|
}
|
|
1662
1662
|
return J;
|
|
1663
1663
|
};
|
|
1664
1664
|
} else {
|
|
1665
|
-
const { forwardFunc:
|
|
1665
|
+
const { forwardFunc: y } = t, g = (w) => {
|
|
1666
1666
|
r && (s = w.map((I) => this.keep(this.clone(I))));
|
|
1667
1667
|
};
|
|
1668
1668
|
i = () => {
|
|
1669
1669
|
const w = this.backend.numDataIds();
|
|
1670
|
-
c = this.tidy(() =>
|
|
1670
|
+
c = this.tidy(() => y(this.backend, g));
|
|
1671
1671
|
const I = Array.isArray(c) ? c : [c];
|
|
1672
1672
|
return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(l, w, I), I;
|
|
1673
1673
|
};
|
|
@@ -1687,8 +1687,8 @@ class et {
|
|
|
1687
1687
|
totalBytesSnapshot: this.state.numBytes,
|
|
1688
1688
|
tensorsAdded: this.state.numTensors - o,
|
|
1689
1689
|
totalTensorsSnapshot: this.state.numTensors,
|
|
1690
|
-
inputShapes: Object.keys(u).map((
|
|
1691
|
-
outputShapes: n.map((
|
|
1690
|
+
inputShapes: Object.keys(u).map((y) => u[y] != null ? u[y].shape : null),
|
|
1691
|
+
outputShapes: n.map((y) => y.shape),
|
|
1692
1692
|
kernelTimeMs: m.timeMs,
|
|
1693
1693
|
extraInfo: m.extraInfo
|
|
1694
1694
|
}), Array.isArray(c) ? n : n[0];
|
|
@@ -1713,7 +1713,7 @@ class et {
|
|
|
1713
1713
|
if (r != null) {
|
|
1714
1714
|
const a = r.inputsToSave || [], o = r.outputsToSave || [];
|
|
1715
1715
|
let i;
|
|
1716
|
-
r.saveAllInputs ? (
|
|
1716
|
+
r.saveAllInputs ? (p(Array.isArray(n), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(n).map((l) => n[l])) : i = a.map((l) => n[l]);
|
|
1717
1717
|
const c = s.filter((l, u) => o[u]);
|
|
1718
1718
|
return i.concat(c);
|
|
1719
1719
|
}
|
|
@@ -1729,10 +1729,10 @@ class et {
|
|
|
1729
1729
|
throw new Error("Values passed to engine.makeTensor() are null");
|
|
1730
1730
|
s = s || "float32", r = r || this.backend;
|
|
1731
1731
|
let a = t;
|
|
1732
|
-
s === "string" && Nt(t[0]) && (a = t.map((c) =>
|
|
1733
|
-
const o = r.write(a, n, s), i = new
|
|
1732
|
+
s === "string" && Nt(t[0]) && (a = t.map((c) => he(c)));
|
|
1733
|
+
const o = r.write(a, n, s), i = new M(n, s, o, this.nextTensorId());
|
|
1734
1734
|
if (this.trackTensor(i, r), s === "string") {
|
|
1735
|
-
const c = this.state.tensorInfo.get(o), l =
|
|
1735
|
+
const c = this.state.tensorInfo.get(o), l = _e(a);
|
|
1736
1736
|
this.state.numBytes += l - c.bytes, c.bytes = l;
|
|
1737
1737
|
}
|
|
1738
1738
|
return i;
|
|
@@ -1754,7 +1754,7 @@ class et {
|
|
|
1754
1754
|
* only increments the ref count used in memory tracking.
|
|
1755
1755
|
*/
|
|
1756
1756
|
makeTensorFromTensorInfo(t, n) {
|
|
1757
|
-
const { dataId: s, shape: r, dtype: a } = t, o = new
|
|
1757
|
+
const { dataId: s, shape: r, dtype: a } = t, o = new M(r, a, s, this.nextTensorId());
|
|
1758
1758
|
return this.trackTensor(o, n), o;
|
|
1759
1759
|
}
|
|
1760
1760
|
makeVariable(t, n = !0, s, r) {
|
|
@@ -1823,7 +1823,7 @@ class et {
|
|
|
1823
1823
|
const i = { id: this.state.nextTapeNodeId++, kernelName: t, inputs: n, outputs: s, saved: a }, c = Vt(t);
|
|
1824
1824
|
c != null && (r = c.gradFunc), r != null && (i.gradient = (l) => (l = l.map((u, h) => {
|
|
1825
1825
|
if (u == null) {
|
|
1826
|
-
const d = s[h], m =
|
|
1826
|
+
const d = s[h], m = se(d.size, d.dtype);
|
|
1827
1827
|
return this.makeTensor(m, d.shape, d.dtype);
|
|
1828
1828
|
}
|
|
1829
1829
|
return u;
|
|
@@ -1855,7 +1855,7 @@ class et {
|
|
|
1855
1855
|
* as scope() without the need for a function closure.
|
|
1856
1856
|
*/
|
|
1857
1857
|
endScope(t) {
|
|
1858
|
-
const n =
|
|
1858
|
+
const n = ye(t), s = new Set(n.map((a) => a.id));
|
|
1859
1859
|
for (let a = 0; a < this.state.activeScope.track.length; a++) {
|
|
1860
1860
|
const o = this.state.activeScope.track[a];
|
|
1861
1861
|
!o.kept && !s.has(o.id) && o.dispose();
|
|
@@ -1872,22 +1872,22 @@ class et {
|
|
|
1872
1872
|
* gradient, which defaults to `1`.
|
|
1873
1873
|
*/
|
|
1874
1874
|
gradients(t, n, s, r = !1) {
|
|
1875
|
-
if (
|
|
1875
|
+
if (p(n.length > 0, () => "gradients() received an empty list of xs."), s != null && s.dtype !== "float32")
|
|
1876
1876
|
throw new Error(`dy must have 'float32' dtype, but has '${s.dtype}'`);
|
|
1877
1877
|
const a = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", t));
|
|
1878
|
-
|
|
1879
|
-
const o =
|
|
1878
|
+
p(a instanceof M, () => "The result y returned by f() must be a tensor.");
|
|
1879
|
+
const o = un(this.state.activeTape, n, a);
|
|
1880
1880
|
if (!r && o.length === 0 && n.length > 0)
|
|
1881
1881
|
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.");
|
|
1882
1882
|
return this.tidy("backward", () => {
|
|
1883
1883
|
const i = {};
|
|
1884
|
-
i[a.id] = s ??
|
|
1884
|
+
i[a.id] = s ?? wn(a.shape), hn(
|
|
1885
1885
|
i,
|
|
1886
1886
|
o,
|
|
1887
1887
|
// Pass the tidy function to avoid circular dep with `tape.ts`.
|
|
1888
1888
|
(l) => this.tidy(l),
|
|
1889
1889
|
// Pass an add function to avoide a circular dep with `tape.ts`.
|
|
1890
|
-
|
|
1890
|
+
Sn
|
|
1891
1891
|
);
|
|
1892
1892
|
const c = n.map((l) => i[l.id]);
|
|
1893
1893
|
return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((l) => {
|
|
@@ -1897,16 +1897,16 @@ class et {
|
|
|
1897
1897
|
});
|
|
1898
1898
|
}
|
|
1899
1899
|
customGrad(t) {
|
|
1900
|
-
return
|
|
1901
|
-
|
|
1900
|
+
return p(lt(t), () => "The f passed in customGrad(f) must be a function."), (...n) => {
|
|
1901
|
+
p(n.every((i) => i instanceof M), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors");
|
|
1902
1902
|
let s;
|
|
1903
1903
|
const r = {};
|
|
1904
1904
|
n.forEach((i, c) => {
|
|
1905
1905
|
r[c] = i;
|
|
1906
1906
|
});
|
|
1907
|
-
const a = (i, c) => (s = t(...n, c),
|
|
1907
|
+
const a = (i, c) => (s = t(...n, c), p(s.value instanceof M, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), p(lt(s.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), s.value), o = (i, c) => {
|
|
1908
1908
|
const l = s.gradFunc(i, c), u = Array.isArray(l) ? l : [l];
|
|
1909
|
-
|
|
1909
|
+
p(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(...)."), p(u.every((d) => d instanceof M), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");
|
|
1910
1910
|
const h = {};
|
|
1911
1911
|
return u.forEach((d, m) => {
|
|
1912
1912
|
h[m] = () => d;
|
|
@@ -1957,22 +1957,22 @@ class et {
|
|
|
1957
1957
|
}
|
|
1958
1958
|
et.nextTensorId = 0;
|
|
1959
1959
|
et.nextVariableId = 0;
|
|
1960
|
-
function
|
|
1961
|
-
const t =
|
|
1960
|
+
function wn(e) {
|
|
1961
|
+
const t = Ue(z(e), "float32");
|
|
1962
1962
|
return f.makeTensor(t, e, "float32");
|
|
1963
1963
|
}
|
|
1964
|
-
function
|
|
1965
|
-
const e =
|
|
1964
|
+
function we() {
|
|
1965
|
+
const e = ae();
|
|
1966
1966
|
if (e._tfengine == null) {
|
|
1967
|
-
const t = new
|
|
1967
|
+
const t = new ze(e);
|
|
1968
1968
|
e._tfengine = new et(t);
|
|
1969
1969
|
}
|
|
1970
|
-
return
|
|
1970
|
+
return qe(e._tfengine.ENV), mn(() => e._tfengine), e._tfengine;
|
|
1971
1971
|
}
|
|
1972
|
-
const f =
|
|
1973
|
-
function
|
|
1972
|
+
const f = we();
|
|
1973
|
+
function Sn(e, t) {
|
|
1974
1974
|
const n = { a: e, b: t };
|
|
1975
|
-
return f.runKernel(
|
|
1975
|
+
return f.runKernel(oe, n);
|
|
1976
1976
|
}
|
|
1977
1977
|
/**
|
|
1978
1978
|
* @license
|
|
@@ -1990,11 +1990,11 @@ function wn(e, t) {
|
|
|
1990
1990
|
* limitations under the License.
|
|
1991
1991
|
* =============================================================================
|
|
1992
1992
|
*/
|
|
1993
|
-
function
|
|
1993
|
+
function kn() {
|
|
1994
1994
|
return typeof navigator < "u" && navigator != null;
|
|
1995
1995
|
}
|
|
1996
1996
|
function ei(e) {
|
|
1997
|
-
if (e ||
|
|
1997
|
+
if (e || kn()) {
|
|
1998
1998
|
if (e || (e = navigator), e.product === "ReactNative")
|
|
1999
1999
|
return !0;
|
|
2000
2000
|
const t = e.userAgent || e.vendor || // tslint:disable-next-line:no-any
|
|
@@ -2008,7 +2008,7 @@ function ei(e) {
|
|
|
2008
2008
|
}
|
|
2009
2009
|
return !1;
|
|
2010
2010
|
}
|
|
2011
|
-
function
|
|
2011
|
+
function In() {
|
|
2012
2012
|
return typeof window < "u" && window.document != null || //@ts-ignore
|
|
2013
2013
|
typeof WorkerGlobalScope < "u";
|
|
2014
2014
|
}
|
|
@@ -2016,7 +2016,7 @@ const v = S();
|
|
|
2016
2016
|
v.registerFlag("DEBUG", () => !1, (e) => {
|
|
2017
2017
|
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.");
|
|
2018
2018
|
});
|
|
2019
|
-
v.registerFlag("IS_BROWSER", () =>
|
|
2019
|
+
v.registerFlag("IS_BROWSER", () => In());
|
|
2020
2020
|
v.registerFlag("IS_NODE", () => typeof Q < "u" && typeof Q.versions < "u" && typeof Q.versions.node < "u");
|
|
2021
2021
|
v.registerFlag("IS_CHROME", () => typeof navigator < "u" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
|
|
2022
2022
|
v.registerFlag("IS_SAFARI", () => typeof navigator < "u" && navigator != null && navigator.userAgent != null && /Safari/.test(navigator.userAgent) && /Apple/.test(navigator.vendor));
|
|
@@ -2044,31 +2044,31 @@ v.registerFlag("USE_SETTIMEOUTCUSTOM", () => !1);
|
|
|
2044
2044
|
* limitations under the License.
|
|
2045
2045
|
* =============================================================================
|
|
2046
2046
|
*/
|
|
2047
|
-
function
|
|
2047
|
+
function Tn(e, t) {
|
|
2048
2048
|
let n = e;
|
|
2049
|
-
if (
|
|
2049
|
+
if (R(e))
|
|
2050
2050
|
return t === "string" ? [] : [e.length];
|
|
2051
|
-
if (
|
|
2051
|
+
if (me(e)) {
|
|
2052
2052
|
const r = e.channels || "RGBA";
|
|
2053
2053
|
return [e.height, e.width * r.length];
|
|
2054
|
-
} else if (
|
|
2054
|
+
} else if (pe(e))
|
|
2055
2055
|
return [e.buffer.size / (t == null ? 4 : It(t))];
|
|
2056
2056
|
if (!Array.isArray(e))
|
|
2057
2057
|
return [];
|
|
2058
2058
|
const s = [];
|
|
2059
|
-
for (; Array.isArray(n) ||
|
|
2059
|
+
for (; Array.isArray(n) || R(n) && t !== "string"; )
|
|
2060
2060
|
s.push(n.length), n = n[0];
|
|
2061
|
-
return Array.isArray(e) && S().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") &&
|
|
2061
|
+
return Array.isArray(e) && S().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && Se(e, s, []), s;
|
|
2062
2062
|
}
|
|
2063
|
-
function
|
|
2064
|
-
if (n = n || [], !Array.isArray(e) && !
|
|
2065
|
-
|
|
2063
|
+
function Se(e, t, n) {
|
|
2064
|
+
if (n = n || [], !Array.isArray(e) && !R(e)) {
|
|
2065
|
+
p(t.length === 0, () => `Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);
|
|
2066
2066
|
return;
|
|
2067
2067
|
}
|
|
2068
|
-
|
|
2068
|
+
p(t.length > 0, () => `Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`), p(e.length === t[0], () => `Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);
|
|
2069
2069
|
const s = t.slice(1);
|
|
2070
2070
|
for (let r = 0; r < e.length; ++r)
|
|
2071
|
-
|
|
2071
|
+
Se(e[r], s, n.concat(r));
|
|
2072
2072
|
}
|
|
2073
2073
|
function Xt(e, t, n, s) {
|
|
2074
2074
|
if (e !== "string_or_numeric") {
|
|
@@ -2079,19 +2079,19 @@ function Xt(e, t, n, s) {
|
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
2081
|
function T(e, t, n, s = "numeric") {
|
|
2082
|
-
if (e instanceof
|
|
2082
|
+
if (e instanceof fe())
|
|
2083
2083
|
return Xt(s, e.dtype, t, n), e;
|
|
2084
2084
|
let r = yt(e);
|
|
2085
|
-
if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), Xt(s, r, t, n), e == null || !
|
|
2085
|
+
if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), Xt(s, r, t, n), e == null || !R(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") {
|
|
2086
2086
|
const c = e == null ? "null" : e.constructor.name;
|
|
2087
2087
|
throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${c}'`);
|
|
2088
2088
|
}
|
|
2089
|
-
const a =
|
|
2090
|
-
!
|
|
2091
|
-
const i = r !== "string" ? _t(e, r) :
|
|
2089
|
+
const a = Tn(e, r);
|
|
2090
|
+
!R(e) && !Array.isArray(e) && (e = [e]);
|
|
2091
|
+
const i = r !== "string" ? _t(e, r) : ut(e, [], !0);
|
|
2092
2092
|
return f.makeTensor(i, a, r);
|
|
2093
2093
|
}
|
|
2094
|
-
function
|
|
2094
|
+
function An(e, t, n, s = "numeric") {
|
|
2095
2095
|
if (!Array.isArray(e))
|
|
2096
2096
|
throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);
|
|
2097
2097
|
return e.map((a, o) => T(a, `${t}[${o}]`, n, s));
|
|
@@ -2113,7 +2113,7 @@ function Tn(e, t, n, s = "numeric") {
|
|
|
2113
2113
|
* =============================================================================
|
|
2114
2114
|
*/
|
|
2115
2115
|
const En = "__op";
|
|
2116
|
-
function
|
|
2116
|
+
function F(e) {
|
|
2117
2117
|
const t = Object.keys(e);
|
|
2118
2118
|
if (t.length !== 1)
|
|
2119
2119
|
throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);
|
|
@@ -2147,28 +2147,28 @@ function D(e) {
|
|
|
2147
2147
|
* limitations under the License.
|
|
2148
2148
|
* =============================================================================
|
|
2149
2149
|
*/
|
|
2150
|
-
function
|
|
2150
|
+
function vn(e, t, n, s) {
|
|
2151
2151
|
if (s == null)
|
|
2152
2152
|
s = yt(e);
|
|
2153
2153
|
else if (s === "complex64")
|
|
2154
2154
|
throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
|
|
2155
|
-
if (
|
|
2155
|
+
if (pe(e) || me(e)) {
|
|
2156
2156
|
if (s !== "float32" && s !== "int32")
|
|
2157
2157
|
throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`);
|
|
2158
2158
|
return f.backend.createTensorFromGPUData(e, t || n, s);
|
|
2159
2159
|
}
|
|
2160
|
-
if (!
|
|
2160
|
+
if (!R(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string")
|
|
2161
2161
|
throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");
|
|
2162
2162
|
if (t != null) {
|
|
2163
2163
|
Ct(t);
|
|
2164
2164
|
const r = z(t), a = z(n);
|
|
2165
|
-
|
|
2165
|
+
p(r === a, () => `Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);
|
|
2166
2166
|
for (let o = 0; o < n.length; ++o) {
|
|
2167
2167
|
const i = n[o], c = o === n.length - 1 ? i !== z(t.slice(o)) : !0;
|
|
2168
|
-
|
|
2168
|
+
p(n[o] === t[o] || !c, () => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `);
|
|
2169
2169
|
}
|
|
2170
2170
|
}
|
|
2171
|
-
return !
|
|
2171
|
+
return !R(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? _t(e, s) : ut(e, [], !0), f.makeTensor(e, t, s);
|
|
2172
2172
|
}
|
|
2173
2173
|
class st {
|
|
2174
2174
|
/**
|
|
@@ -2182,7 +2182,7 @@ class st {
|
|
|
2182
2182
|
return new st(t).slice();
|
|
2183
2183
|
}
|
|
2184
2184
|
constructor(t) {
|
|
2185
|
-
if (this.shards = [], this.previousShardIndex = 0, t == null || (t instanceof Array || (t = [t]), t = t.map((s) =>
|
|
2185
|
+
if (this.shards = [], this.previousShardIndex = 0, t == null || (t instanceof Array || (t = [t]), t = t.map((s) => R(s) ? s.buffer : s), t.length === 0))
|
|
2186
2186
|
return;
|
|
2187
2187
|
this.bufferUniformSize = t[0].byteLength;
|
|
2188
2188
|
let n = 0;
|
|
@@ -2205,7 +2205,7 @@ class st {
|
|
|
2205
2205
|
const r = n - t, a = new ArrayBuffer(r), o = new Uint8Array(a);
|
|
2206
2206
|
let i = 0;
|
|
2207
2207
|
for (let c = s; c < this.shards.length; c++) {
|
|
2208
|
-
const l = this.shards[c], h = t + i - l.start, d = i,
|
|
2208
|
+
const l = this.shards[c], h = t + i - l.start, d = i, y = Math.min(n, l.end) - l.start, g = new Uint8Array(l.buffer, h, y - h);
|
|
2209
2209
|
if (o.set(g, d), i += g.length, n < l.end)
|
|
2210
2210
|
break;
|
|
2211
2211
|
}
|
|
@@ -2224,11 +2224,11 @@ class st {
|
|
|
2224
2224
|
}
|
|
2225
2225
|
if (n(this.shards[this.previousShardIndex]) === 0)
|
|
2226
2226
|
return this.previousShardIndex;
|
|
2227
|
-
const s =
|
|
2227
|
+
const s = Bn(this.shards, n);
|
|
2228
2228
|
return s === -1 ? -1 : (this.previousShardIndex = s, this.previousShardIndex);
|
|
2229
2229
|
}
|
|
2230
2230
|
}
|
|
2231
|
-
function
|
|
2231
|
+
function Bn(e, t) {
|
|
2232
2232
|
let n = 0, s = e.length;
|
|
2233
2233
|
for (; n <= s; ) {
|
|
2234
2234
|
const r = Math.floor((s - n) / 2) + n, a = t(e[r]);
|
|
@@ -2263,13 +2263,13 @@ function si() {
|
|
|
2263
2263
|
function ri() {
|
|
2264
2264
|
return f.memory();
|
|
2265
2265
|
}
|
|
2266
|
-
function
|
|
2266
|
+
function A(e, t) {
|
|
2267
2267
|
return f.tidy(e, t);
|
|
2268
2268
|
}
|
|
2269
|
-
function
|
|
2270
|
-
|
|
2269
|
+
function D(e) {
|
|
2270
|
+
ye(e).forEach((n) => n.dispose());
|
|
2271
2271
|
}
|
|
2272
|
-
function
|
|
2272
|
+
function Mn(e) {
|
|
2273
2273
|
return f.keep(e);
|
|
2274
2274
|
}
|
|
2275
2275
|
function ai(e) {
|
|
@@ -2297,13 +2297,13 @@ async function ui(e, t) {
|
|
|
2297
2297
|
const l = { name: i, shape: c.shape, dtype: c.dtype };
|
|
2298
2298
|
if (c.dtype === "string") {
|
|
2299
2299
|
const u = new Promise(async (h) => {
|
|
2300
|
-
const d = await c.bytes(), m = d.reduce((w, I) => w + I.length, 0) + Jt * d.length,
|
|
2300
|
+
const d = await c.bytes(), m = d.reduce((w, I) => w + I.length, 0) + Jt * d.length, y = new Uint8Array(m);
|
|
2301
2301
|
let g = 0;
|
|
2302
2302
|
for (let w = 0; w < d.length; w++) {
|
|
2303
2303
|
const I = d[w], _ = new Uint8Array(new Uint32Array([I.length]).buffer);
|
|
2304
|
-
|
|
2304
|
+
y.set(_, g), g += Jt, y.set(I, g), g += I.length;
|
|
2305
2305
|
}
|
|
2306
|
-
h(
|
|
2306
|
+
h(y);
|
|
2307
2307
|
});
|
|
2308
2308
|
s.push(u);
|
|
2309
2309
|
} else
|
|
@@ -2311,9 +2311,9 @@ async function ui(e, t) {
|
|
|
2311
2311
|
t != null && (l.group = t), n.push(l);
|
|
2312
2312
|
}
|
|
2313
2313
|
const a = await Promise.all(s);
|
|
2314
|
-
return { data:
|
|
2314
|
+
return { data: Dn(a), specs: n };
|
|
2315
2315
|
}
|
|
2316
|
-
function
|
|
2316
|
+
function Dn(e) {
|
|
2317
2317
|
if (e === null)
|
|
2318
2318
|
throw new Error(`Invalid input value: ${JSON.stringify(e)}`);
|
|
2319
2319
|
let t = 0;
|
|
@@ -2332,7 +2332,7 @@ const Ot = typeof pt < "u" && (typeof Blob > "u" || typeof atob > "u" || typeof
|
|
|
2332
2332
|
function Yt(e) {
|
|
2333
2333
|
return Ot ? pt.byteLength(e, "utf8") : new Blob([e]).size;
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2335
|
+
function Fn(e) {
|
|
2336
2336
|
if (Ot)
|
|
2337
2337
|
return pt.from(e).toString("base64");
|
|
2338
2338
|
const t = new Uint8Array(e);
|
|
@@ -2341,7 +2341,7 @@ function Dn(e) {
|
|
|
2341
2341
|
n += String.fromCharCode(t[s]);
|
|
2342
2342
|
return btoa(n);
|
|
2343
2343
|
}
|
|
2344
|
-
function
|
|
2344
|
+
function Rn(e) {
|
|
2345
2345
|
if (Ot) {
|
|
2346
2346
|
const s = pt.from(e, "base64");
|
|
2347
2347
|
return s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength);
|
|
@@ -2364,7 +2364,7 @@ function di(e, t) {
|
|
|
2364
2364
|
};
|
|
2365
2365
|
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;
|
|
2366
2366
|
}
|
|
2367
|
-
function
|
|
2367
|
+
function xn(e, t, n) {
|
|
2368
2368
|
const s = {
|
|
2369
2369
|
modelTopology: e.modelTopology,
|
|
2370
2370
|
format: e.format,
|
|
@@ -2382,9 +2382,9 @@ function Rn(e, t, n) {
|
|
|
2382
2382
|
}
|
|
2383
2383
|
async function fi(e, t) {
|
|
2384
2384
|
let n, s;
|
|
2385
|
-
return e.weightsManifest != null && ([n, s] = await t(e.weightsManifest)),
|
|
2385
|
+
return e.weightsManifest != null && ([n, s] = await t(e.weightsManifest)), xn(e, n, s);
|
|
2386
2386
|
}
|
|
2387
|
-
function
|
|
2387
|
+
function ke(e) {
|
|
2388
2388
|
if (e.modelTopology instanceof ArrayBuffer)
|
|
2389
2389
|
throw new Error("Expected JSON model topology, received ArrayBuffer.");
|
|
2390
2390
|
return {
|
|
@@ -2417,12 +2417,12 @@ function gi(e) {
|
|
|
2417
2417
|
* limitations under the License.
|
|
2418
2418
|
* =============================================================================
|
|
2419
2419
|
*/
|
|
2420
|
-
class
|
|
2420
|
+
class E {
|
|
2421
2421
|
constructor() {
|
|
2422
2422
|
this.saveRouters = [], this.loadRouters = [];
|
|
2423
2423
|
}
|
|
2424
2424
|
static getInstance() {
|
|
2425
|
-
return
|
|
2425
|
+
return E.instance == null && (E.instance = new E()), E.instance;
|
|
2426
2426
|
}
|
|
2427
2427
|
/**
|
|
2428
2428
|
* Register a save-handler router.
|
|
@@ -2431,7 +2431,7 @@ class A {
|
|
|
2431
2431
|
* of `IOHandler` with the `save` method defined or `null`.
|
|
2432
2432
|
*/
|
|
2433
2433
|
static registerSaveRouter(t) {
|
|
2434
|
-
|
|
2434
|
+
E.getInstance().saveRouters.push(t);
|
|
2435
2435
|
}
|
|
2436
2436
|
/**
|
|
2437
2437
|
* Register a load-handler router.
|
|
@@ -2440,7 +2440,7 @@ class A {
|
|
|
2440
2440
|
* of `IOHandler` with the `load` method defined or `null`.
|
|
2441
2441
|
*/
|
|
2442
2442
|
static registerLoadRouter(t) {
|
|
2443
|
-
|
|
2443
|
+
E.getInstance().loadRouters.push(t);
|
|
2444
2444
|
}
|
|
2445
2445
|
/**
|
|
2446
2446
|
* Look up IOHandler for saving, given a URL-like string.
|
|
@@ -2451,7 +2451,7 @@ class A {
|
|
|
2451
2451
|
* @throws Error, if more than one match is found.
|
|
2452
2452
|
*/
|
|
2453
2453
|
static getSaveHandlers(t) {
|
|
2454
|
-
return
|
|
2454
|
+
return E.getHandlers(t, "save");
|
|
2455
2455
|
}
|
|
2456
2456
|
/**
|
|
2457
2457
|
* Look up IOHandler for loading, given a URL-like string.
|
|
@@ -2462,17 +2462,17 @@ class A {
|
|
|
2462
2462
|
* handler routers.
|
|
2463
2463
|
*/
|
|
2464
2464
|
static getLoadHandlers(t, n) {
|
|
2465
|
-
return
|
|
2465
|
+
return E.getHandlers(t, "load", n);
|
|
2466
2466
|
}
|
|
2467
2467
|
static getHandlers(t, n, s) {
|
|
2468
2468
|
const r = [];
|
|
2469
|
-
return (n === "load" ?
|
|
2469
|
+
return (n === "load" ? E.getInstance().loadRouters : E.getInstance().saveRouters).forEach((o) => {
|
|
2470
2470
|
const i = o(t, s);
|
|
2471
2471
|
i !== null && r.push(i);
|
|
2472
2472
|
}), r;
|
|
2473
2473
|
}
|
|
2474
2474
|
}
|
|
2475
|
-
const mi = (e) =>
|
|
2475
|
+
const mi = (e) => E.getSaveHandlers(e);
|
|
2476
2476
|
/**
|
|
2477
2477
|
* @license
|
|
2478
2478
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -2490,7 +2490,7 @@ const mi = (e) => A.getSaveHandlers(e);
|
|
|
2490
2490
|
* =============================================================================
|
|
2491
2491
|
*/
|
|
2492
2492
|
const Mt = "tensorflowjs", Dt = 1, U = "models_store", L = "model_info_store";
|
|
2493
|
-
function
|
|
2493
|
+
function Ie() {
|
|
2494
2494
|
if (!S().getBool("IS_BROWSER"))
|
|
2495
2495
|
throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");
|
|
2496
2496
|
const e = typeof window > "u" ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB;
|
|
@@ -2504,7 +2504,7 @@ function Ft(e) {
|
|
|
2504
2504
|
}
|
|
2505
2505
|
class W {
|
|
2506
2506
|
constructor(t) {
|
|
2507
|
-
if (this.indexedDB =
|
|
2507
|
+
if (this.indexedDB = Ie(), t == null || !t)
|
|
2508
2508
|
throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");
|
|
2509
2509
|
this.modelPath = t;
|
|
2510
2510
|
}
|
|
@@ -2544,7 +2544,7 @@ class W {
|
|
|
2544
2544
|
}, l.onerror = (u) => (o.close(), r(l.error)), i.oncomplete = () => o.close();
|
|
2545
2545
|
} else {
|
|
2546
2546
|
n.weightData = st.join(n.weightData);
|
|
2547
|
-
const i =
|
|
2547
|
+
const i = ke(n), c = o.transaction(L, "readwrite");
|
|
2548
2548
|
let l = c.objectStore(L), u;
|
|
2549
2549
|
try {
|
|
2550
2550
|
u = l.put({ modelPath: this.modelPath, modelArtifactsInfo: i });
|
|
@@ -2562,10 +2562,10 @@ class W {
|
|
|
2562
2562
|
modelArtifacts: n,
|
|
2563
2563
|
modelArtifactsInfo: i
|
|
2564
2564
|
});
|
|
2565
|
-
} catch (
|
|
2566
|
-
return r(
|
|
2565
|
+
} catch (y) {
|
|
2566
|
+
return r(y);
|
|
2567
2567
|
}
|
|
2568
|
-
m.onsuccess = () => s({ modelArtifactsInfo: i }), m.onerror = (
|
|
2568
|
+
m.onsuccess = () => s({ modelArtifactsInfo: i }), m.onerror = (y) => {
|
|
2569
2569
|
l = c.objectStore(L);
|
|
2570
2570
|
const g = l.delete(this.modelPath);
|
|
2571
2571
|
g.onsuccess = () => (o.close(), r(m.error)), g.onerror = (w) => (o.close(), r(m.error));
|
|
@@ -2579,18 +2579,18 @@ class W {
|
|
|
2579
2579
|
}
|
|
2580
2580
|
}
|
|
2581
2581
|
W.URL_SCHEME = "indexeddb://";
|
|
2582
|
-
const
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
function
|
|
2582
|
+
const Te = (e) => S().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(W.URL_SCHEME) ? Nn(e.slice(W.URL_SCHEME.length)) : null;
|
|
2583
|
+
E.registerSaveRouter(Te);
|
|
2584
|
+
E.registerLoadRouter(Te);
|
|
2585
|
+
function Nn(e) {
|
|
2586
2586
|
return new W(e);
|
|
2587
2587
|
}
|
|
2588
|
-
function
|
|
2588
|
+
function $n(e) {
|
|
2589
2589
|
return e.startsWith(W.URL_SCHEME) ? e.slice(W.URL_SCHEME.length) : e;
|
|
2590
2590
|
}
|
|
2591
|
-
class
|
|
2591
|
+
class Cn {
|
|
2592
2592
|
constructor() {
|
|
2593
|
-
this.indexedDB =
|
|
2593
|
+
this.indexedDB = Ie();
|
|
2594
2594
|
}
|
|
2595
2595
|
async listModels() {
|
|
2596
2596
|
return new Promise((t, n) => {
|
|
@@ -2607,7 +2607,7 @@ class $n {
|
|
|
2607
2607
|
});
|
|
2608
2608
|
}
|
|
2609
2609
|
async removeModel(t) {
|
|
2610
|
-
return t =
|
|
2610
|
+
return t = $n(t), new Promise((n, s) => {
|
|
2611
2611
|
const r = this.indexedDB.open(Mt, Dt);
|
|
2612
2612
|
r.onupgradeneeded = () => Ft(r), r.onsuccess = () => {
|
|
2613
2613
|
const a = r.result, o = a.transaction(L, "readwrite"), i = o.objectStore(L), c = i.get(t);
|
|
@@ -2619,7 +2619,7 @@ class $n {
|
|
|
2619
2619
|
const u = i.delete(t), h = () => {
|
|
2620
2620
|
l = a.transaction(U, "readwrite");
|
|
2621
2621
|
const m = l.objectStore(U).delete(t);
|
|
2622
|
-
m.onsuccess = () => n(c.result.modelArtifactsInfo), m.onerror = (
|
|
2622
|
+
m.onsuccess = () => n(c.result.modelArtifactsInfo), m.onerror = (y) => s(c.error);
|
|
2623
2623
|
};
|
|
2624
2624
|
u.onsuccess = h, u.onerror = (d) => (h(), a.close(), s(c.error));
|
|
2625
2625
|
}
|
|
@@ -2646,27 +2646,27 @@ class $n {
|
|
|
2646
2646
|
* limitations under the License.
|
|
2647
2647
|
* =============================================================================
|
|
2648
2648
|
*/
|
|
2649
|
-
const P = "/", Z = "tensorflowjs_models",
|
|
2649
|
+
const P = "/", Z = "tensorflowjs_models", Ae = "info", Pn = "model_topology", Ln = "weight_specs", _n = "weight_data", On = "model_metadata";
|
|
2650
2650
|
function Ee(e) {
|
|
2651
2651
|
return {
|
|
2652
|
-
info: [Z, e,
|
|
2653
|
-
topology: [Z, e,
|
|
2654
|
-
weightSpecs: [Z, e,
|
|
2655
|
-
weightData: [Z, e,
|
|
2656
|
-
modelMetadata: [Z, e,
|
|
2652
|
+
info: [Z, e, Ae].join(P),
|
|
2653
|
+
topology: [Z, e, Pn].join(P),
|
|
2654
|
+
weightSpecs: [Z, e, Ln].join(P),
|
|
2655
|
+
weightData: [Z, e, _n].join(P),
|
|
2656
|
+
modelMetadata: [Z, e, On].join(P)
|
|
2657
2657
|
};
|
|
2658
2658
|
}
|
|
2659
|
-
function
|
|
2659
|
+
function ve(e) {
|
|
2660
2660
|
for (const t of Object.values(e))
|
|
2661
2661
|
window.localStorage.removeItem(t);
|
|
2662
2662
|
}
|
|
2663
|
-
function
|
|
2663
|
+
function Gn(e) {
|
|
2664
2664
|
const t = e.split(P);
|
|
2665
2665
|
if (t.length < 3)
|
|
2666
2666
|
throw new Error(`Invalid key format: ${e}`);
|
|
2667
2667
|
return t.slice(1, t.length - 1).join(P);
|
|
2668
2668
|
}
|
|
2669
|
-
function
|
|
2669
|
+
function Un(e) {
|
|
2670
2670
|
return e.startsWith(j.URL_SCHEME) ? e.slice(j.URL_SCHEME.length) : e;
|
|
2671
2671
|
}
|
|
2672
2672
|
class j {
|
|
@@ -2690,9 +2690,9 @@ class j {
|
|
|
2690
2690
|
if (t.modelTopology instanceof ArrayBuffer)
|
|
2691
2691
|
throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");
|
|
2692
2692
|
{
|
|
2693
|
-
const n = JSON.stringify(t.modelTopology), s = JSON.stringify(t.weightSpecs), r =
|
|
2693
|
+
const n = JSON.stringify(t.modelTopology), s = JSON.stringify(t.weightSpecs), r = ke(t), a = st.join(t.weightData);
|
|
2694
2694
|
try {
|
|
2695
|
-
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,
|
|
2695
|
+
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, Fn(a));
|
|
2696
2696
|
const o = {
|
|
2697
2697
|
format: t.format,
|
|
2698
2698
|
generatedBy: t.generatedBy,
|
|
@@ -2705,7 +2705,7 @@ class j {
|
|
|
2705
2705
|
};
|
|
2706
2706
|
return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(o)), { modelArtifactsInfo: r };
|
|
2707
2707
|
} catch {
|
|
2708
|
-
throw
|
|
2708
|
+
throw ve(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`);
|
|
2709
2709
|
}
|
|
2710
2710
|
}
|
|
2711
2711
|
}
|
|
@@ -2739,38 +2739,38 @@ class j {
|
|
|
2739
2739
|
const o = this.LS.getItem(this.keys.weightData);
|
|
2740
2740
|
if (o == null)
|
|
2741
2741
|
throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);
|
|
2742
|
-
return n.weightData =
|
|
2742
|
+
return n.weightData = Rn(o), n;
|
|
2743
2743
|
}
|
|
2744
2744
|
}
|
|
2745
2745
|
j.URL_SCHEME = "localstorage://";
|
|
2746
|
-
const
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
function
|
|
2746
|
+
const Be = (e) => S().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(j.URL_SCHEME) ? zn(e.slice(j.URL_SCHEME.length)) : null;
|
|
2747
|
+
E.registerSaveRouter(Be);
|
|
2748
|
+
E.registerLoadRouter(Be);
|
|
2749
|
+
function zn(e) {
|
|
2750
2750
|
return new j(e);
|
|
2751
2751
|
}
|
|
2752
|
-
class
|
|
2752
|
+
class Vn {
|
|
2753
2753
|
constructor() {
|
|
2754
|
-
|
|
2754
|
+
p(S().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), p(typeof window > "u" || typeof window.localStorage < "u", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage;
|
|
2755
2755
|
}
|
|
2756
2756
|
async listModels() {
|
|
2757
|
-
const t = {}, n = Z + P, s = P +
|
|
2757
|
+
const t = {}, n = Z + P, s = P + Ae;
|
|
2758
2758
|
for (let r = 0; r < this.LS.length; ++r) {
|
|
2759
2759
|
const a = this.LS.key(r);
|
|
2760
2760
|
if (a.startsWith(n) && a.endsWith(s)) {
|
|
2761
|
-
const o =
|
|
2761
|
+
const o = Gn(a);
|
|
2762
2762
|
t[o] = JSON.parse(this.LS.getItem(a));
|
|
2763
2763
|
}
|
|
2764
2764
|
}
|
|
2765
2765
|
return t;
|
|
2766
2766
|
}
|
|
2767
2767
|
async removeModel(t) {
|
|
2768
|
-
t =
|
|
2768
|
+
t = Un(t);
|
|
2769
2769
|
const n = Ee(t);
|
|
2770
2770
|
if (this.LS.getItem(n.info) == null)
|
|
2771
2771
|
throw new Error(`Cannot find model at path '${t}'`);
|
|
2772
2772
|
const s = JSON.parse(this.LS.getItem(n.info));
|
|
2773
|
-
return
|
|
2773
|
+
return ve(n), s;
|
|
2774
2774
|
}
|
|
2775
2775
|
}
|
|
2776
2776
|
/**
|
|
@@ -2804,9 +2804,9 @@ class N {
|
|
|
2804
2804
|
* of `IOHandler` with the `save` method defined or `null`.
|
|
2805
2805
|
*/
|
|
2806
2806
|
static registerManager(t, n) {
|
|
2807
|
-
|
|
2807
|
+
p(t != null, () => "scheme must not be undefined or null."), t.endsWith(Zt) && (t = t.slice(0, t.indexOf(Zt))), p(t.length > 0, () => "scheme must not be an empty string.");
|
|
2808
2808
|
const s = N.getInstance();
|
|
2809
|
-
|
|
2809
|
+
p(s.managers[t] == null, () => `A model store manager is already registered for scheme '${t}'.`), s.managers[t] = n;
|
|
2810
2810
|
}
|
|
2811
2811
|
static getManager(t) {
|
|
2812
2812
|
const n = N.getInstance().managers[t];
|
|
@@ -2834,7 +2834,7 @@ class N {
|
|
|
2834
2834
|
* limitations under the License.
|
|
2835
2835
|
* =============================================================================
|
|
2836
2836
|
*/
|
|
2837
|
-
class
|
|
2837
|
+
class Wn {
|
|
2838
2838
|
constructor() {
|
|
2839
2839
|
this.messageName = "setTimeoutCustom", this.functionRefs = [], this.handledMessageCount = 0, this.hasEventListener = !1;
|
|
2840
2840
|
}
|
|
@@ -2872,31 +2872,31 @@ class Vn {
|
|
|
2872
2872
|
}, !0));
|
|
2873
2873
|
}
|
|
2874
2874
|
isTypedArray(t) {
|
|
2875
|
-
return
|
|
2875
|
+
return ue(t);
|
|
2876
2876
|
}
|
|
2877
2877
|
}
|
|
2878
2878
|
if (S().get("IS_BROWSER")) {
|
|
2879
|
-
S().setPlatform("browser", new
|
|
2879
|
+
S().setPlatform("browser", new Wn());
|
|
2880
2880
|
try {
|
|
2881
|
-
N.registerManager(j.URL_SCHEME, new
|
|
2881
|
+
N.registerManager(j.URL_SCHEME, new Vn());
|
|
2882
2882
|
} catch {
|
|
2883
2883
|
}
|
|
2884
2884
|
try {
|
|
2885
|
-
N.registerManager(W.URL_SCHEME, new
|
|
2885
|
+
N.registerManager(W.URL_SCHEME, new Cn());
|
|
2886
2886
|
} catch {
|
|
2887
2887
|
}
|
|
2888
2888
|
}
|
|
2889
|
-
const
|
|
2889
|
+
const jn = {
|
|
2890
2890
|
// tslint:disable-next-line:no-require-imports
|
|
2891
2891
|
importFetch: () => require("node-fetch")
|
|
2892
2892
|
};
|
|
2893
2893
|
let kt;
|
|
2894
|
-
class
|
|
2894
|
+
class qn {
|
|
2895
2895
|
constructor() {
|
|
2896
2896
|
this.util = require("util"), this.textEncoder = new this.util.TextEncoder();
|
|
2897
2897
|
}
|
|
2898
2898
|
fetch(t, n) {
|
|
2899
|
-
return S().global.fetch != null ? S().global.fetch(t, n) : (kt == null && (kt =
|
|
2899
|
+
return S().global.fetch != null ? S().global.fetch(t, n) : (kt == null && (kt = jn.importFetch()), kt(t, n));
|
|
2900
2900
|
}
|
|
2901
2901
|
now() {
|
|
2902
2902
|
const t = Q.hrtime();
|
|
@@ -2914,7 +2914,7 @@ class jn {
|
|
|
2914
2914
|
return this.util.types.isFloat32Array(t) || this.util.types.isInt32Array(t) || this.util.types.isUint8Array(t) || this.util.types.isUint8ClampedArray(t);
|
|
2915
2915
|
}
|
|
2916
2916
|
}
|
|
2917
|
-
S().get("IS_NODE") && !S().get("IS_BROWSER") && S().setPlatform("node", new
|
|
2917
|
+
S().get("IS_NODE") && !S().get("IS_BROWSER") && S().setPlatform("node", new qn());
|
|
2918
2918
|
/**
|
|
2919
2919
|
* @license
|
|
2920
2920
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -2931,8 +2931,8 @@ S().get("IS_NODE") && !S().get("IS_BROWSER") && S().setPlatform("node", new jn()
|
|
|
2931
2931
|
* limitations under the License.
|
|
2932
2932
|
* =============================================================================
|
|
2933
2933
|
*/
|
|
2934
|
-
function
|
|
2935
|
-
return t = t || "float32", Ct(e), new
|
|
2934
|
+
function Kn(e, t = "float32", n) {
|
|
2935
|
+
return t = t || "float32", Ct(e), new gn(e, t, n);
|
|
2936
2936
|
}
|
|
2937
2937
|
/**
|
|
2938
2938
|
* @license
|
|
@@ -2950,16 +2950,16 @@ function qn(e, t = "float32", n) {
|
|
|
2950
2950
|
* limitations under the License.
|
|
2951
2951
|
* =============================================================================
|
|
2952
2952
|
*/
|
|
2953
|
-
function
|
|
2953
|
+
function Hn(e, t) {
|
|
2954
2954
|
const n = T(e, "x", "cast");
|
|
2955
|
-
if (!
|
|
2955
|
+
if (!Le(t))
|
|
2956
2956
|
throw new Error(`Failed to cast to unknown dtype ${t}`);
|
|
2957
2957
|
if (t === "string" && n.dtype !== "string" || t !== "string" && n.dtype === "string")
|
|
2958
2958
|
throw new Error("Only strings can be casted to strings");
|
|
2959
2959
|
const s = { x: n }, r = { dtype: t };
|
|
2960
|
-
return f.runKernel(
|
|
2960
|
+
return f.runKernel(ie, s, r);
|
|
2961
2961
|
}
|
|
2962
|
-
const Rt = /* @__PURE__ */
|
|
2962
|
+
const Rt = /* @__PURE__ */ F({ cast_: Hn });
|
|
2963
2963
|
/**
|
|
2964
2964
|
* @license
|
|
2965
2965
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -2976,11 +2976,11 @@ const Rt = /* @__PURE__ */ D({ cast_: Kn });
|
|
|
2976
2976
|
* limitations under the License.
|
|
2977
2977
|
* =============================================================================
|
|
2978
2978
|
*/
|
|
2979
|
-
function
|
|
2979
|
+
function Xn(e) {
|
|
2980
2980
|
const n = { x: T(e, "x", "clone", "string_or_numeric") };
|
|
2981
|
-
return f.runKernel(
|
|
2981
|
+
return f.runKernel(ce, n);
|
|
2982
2982
|
}
|
|
2983
|
-
const
|
|
2983
|
+
const Jn = /* @__PURE__ */ F({ clone_: Xn });
|
|
2984
2984
|
/**
|
|
2985
2985
|
* @license
|
|
2986
2986
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -2997,7 +2997,7 @@ const Xn = /* @__PURE__ */ D({ clone_: Hn });
|
|
|
2997
2997
|
* limitations under the License.
|
|
2998
2998
|
* =============================================================================
|
|
2999
2999
|
*/
|
|
3000
|
-
function
|
|
3000
|
+
function Yn(e, t = !1) {
|
|
3001
3001
|
console.log(e.toString(t));
|
|
3002
3002
|
}
|
|
3003
3003
|
/**
|
|
@@ -3016,14 +3016,14 @@ function Jn(e, t = !1) {
|
|
|
3016
3016
|
* limitations under the License.
|
|
3017
3017
|
* =============================================================================
|
|
3018
3018
|
*/
|
|
3019
|
-
|
|
3020
|
-
const
|
|
3021
|
-
buffer:
|
|
3019
|
+
we();
|
|
3020
|
+
const Zn = {
|
|
3021
|
+
buffer: Kn,
|
|
3022
3022
|
cast: Rt,
|
|
3023
|
-
clone:
|
|
3024
|
-
print:
|
|
3023
|
+
clone: Jn,
|
|
3024
|
+
print: Yn
|
|
3025
3025
|
};
|
|
3026
|
-
|
|
3026
|
+
pn(Zn);
|
|
3027
3027
|
/**
|
|
3028
3028
|
* @license
|
|
3029
3029
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3040,13 +3040,13 @@ mn(Yn);
|
|
|
3040
3040
|
* limitations under the License.
|
|
3041
3041
|
* =============================================================================
|
|
3042
3042
|
*/
|
|
3043
|
-
function
|
|
3043
|
+
function Qn(e, t) {
|
|
3044
3044
|
let n = T(e, "a", "add"), s = T(t, "b", "add");
|
|
3045
3045
|
[n, s] = K(n, s);
|
|
3046
3046
|
const r = { a: n, b: s };
|
|
3047
|
-
return f.runKernel(
|
|
3047
|
+
return f.runKernel(oe, r);
|
|
3048
3048
|
}
|
|
3049
|
-
const k = /* @__PURE__ */
|
|
3049
|
+
const k = /* @__PURE__ */ F({ add_: Qn });
|
|
3050
3050
|
/**
|
|
3051
3051
|
* @license
|
|
3052
3052
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3063,13 +3063,13 @@ const k = /* @__PURE__ */ D({ add_: Zn });
|
|
|
3063
3063
|
* limitations under the License.
|
|
3064
3064
|
* =============================================================================
|
|
3065
3065
|
*/
|
|
3066
|
-
function
|
|
3066
|
+
function ts(e, t) {
|
|
3067
3067
|
let n = T(e, "a", "floorDiv"), s = T(t, "b", "floorDiv");
|
|
3068
3068
|
[n, s] = K(n, s);
|
|
3069
3069
|
const r = { a: n, b: s };
|
|
3070
|
-
return f.runKernel(
|
|
3070
|
+
return f.runKernel(Ze, r);
|
|
3071
3071
|
}
|
|
3072
|
-
const
|
|
3072
|
+
const es = /* @__PURE__ */ F({ floorDiv_: ts });
|
|
3073
3073
|
/**
|
|
3074
3074
|
* @license
|
|
3075
3075
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3086,14 +3086,14 @@ const ts = /* @__PURE__ */ D({ floorDiv_: Qn });
|
|
|
3086
3086
|
* limitations under the License.
|
|
3087
3087
|
* =============================================================================
|
|
3088
3088
|
*/
|
|
3089
|
-
function
|
|
3089
|
+
function ns(e, t) {
|
|
3090
3090
|
let n = T(e, "a", "div"), s = T(t, "b", "div");
|
|
3091
3091
|
if ([n, s] = K(n, s), n.dtype === "int32" && s.dtype === "int32")
|
|
3092
|
-
return
|
|
3092
|
+
return es(n, s);
|
|
3093
3093
|
const r = { a: n, b: s }, a = {};
|
|
3094
|
-
return f.runKernel(
|
|
3094
|
+
return f.runKernel(Je, r, a);
|
|
3095
3095
|
}
|
|
3096
|
-
const $ = /* @__PURE__ */
|
|
3096
|
+
const $ = /* @__PURE__ */ F({ div_: ns });
|
|
3097
3097
|
/**
|
|
3098
3098
|
* @license
|
|
3099
3099
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3110,13 +3110,13 @@ const $ = /* @__PURE__ */ D({ div_: es });
|
|
|
3110
3110
|
* limitations under the License.
|
|
3111
3111
|
* =============================================================================
|
|
3112
3112
|
*/
|
|
3113
|
-
function
|
|
3113
|
+
function ss(e, t) {
|
|
3114
3114
|
let n = T(e, "a", "mul"), s = T(t, "b", "mul");
|
|
3115
3115
|
[n, s] = K(n, s);
|
|
3116
3116
|
const r = { a: n, b: s };
|
|
3117
|
-
return f.runKernel(
|
|
3117
|
+
return f.runKernel(tn, r);
|
|
3118
3118
|
}
|
|
3119
|
-
const b = /* @__PURE__ */
|
|
3119
|
+
const b = /* @__PURE__ */ F({ mul_: ss });
|
|
3120
3120
|
/**
|
|
3121
3121
|
* @license
|
|
3122
3122
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -3133,17 +3133,17 @@ const b = /* @__PURE__ */ D({ mul_: ns });
|
|
|
3133
3133
|
* limitations under the License.
|
|
3134
3134
|
* =============================================================================
|
|
3135
3135
|
*/
|
|
3136
|
-
function
|
|
3136
|
+
function rs(e) {
|
|
3137
3137
|
const t = T(e, "x", "abs");
|
|
3138
3138
|
if (t.dtype === "complex64") {
|
|
3139
3139
|
const n = { x: t };
|
|
3140
|
-
return f.runKernel(
|
|
3140
|
+
return f.runKernel(Xe, n);
|
|
3141
3141
|
} else {
|
|
3142
3142
|
const n = { x: t };
|
|
3143
|
-
return f.runKernel(
|
|
3143
|
+
return f.runKernel(He, n);
|
|
3144
3144
|
}
|
|
3145
3145
|
}
|
|
3146
|
-
const
|
|
3146
|
+
const as = /* @__PURE__ */ F({ abs_: rs });
|
|
3147
3147
|
/**
|
|
3148
3148
|
* @license
|
|
3149
3149
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3160,10 +3160,10 @@ const rs = /* @__PURE__ */ D({ abs_: ss });
|
|
|
3160
3160
|
* limitations under the License.
|
|
3161
3161
|
* =============================================================================
|
|
3162
3162
|
*/
|
|
3163
|
-
function
|
|
3163
|
+
function os(e, t, n) {
|
|
3164
3164
|
Ct(e), n = n || yt(t);
|
|
3165
3165
|
const s = { shape: e, value: t, dtype: n };
|
|
3166
|
-
return f.runKernel(
|
|
3166
|
+
return f.runKernel(Ye, {}, s);
|
|
3167
3167
|
}
|
|
3168
3168
|
/**
|
|
3169
3169
|
* @license
|
|
@@ -3197,7 +3197,7 @@ function yi(e, t) {
|
|
|
3197
3197
|
}
|
|
3198
3198
|
return n;
|
|
3199
3199
|
}
|
|
3200
|
-
function
|
|
3200
|
+
function is(e, t) {
|
|
3201
3201
|
const n = Math.max(e.length, t.length), s = new Array(n);
|
|
3202
3202
|
for (let r = 0; r < n; r++) {
|
|
3203
3203
|
let a = e[e.length - r - 1];
|
|
@@ -3231,11 +3231,11 @@ function os(e, t) {
|
|
|
3231
3231
|
* limitations under the License.
|
|
3232
3232
|
* =============================================================================
|
|
3233
3233
|
*/
|
|
3234
|
-
function
|
|
3234
|
+
function cs(e) {
|
|
3235
3235
|
const n = { x: T(e, "x", "zerosLike") };
|
|
3236
|
-
return f.runKernel(
|
|
3236
|
+
return f.runKernel(rn, n);
|
|
3237
3237
|
}
|
|
3238
|
-
const C = /* @__PURE__ */
|
|
3238
|
+
const C = /* @__PURE__ */ F({ zerosLike_: cs });
|
|
3239
3239
|
/**
|
|
3240
3240
|
* @license
|
|
3241
3241
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3252,13 +3252,13 @@ const C = /* @__PURE__ */ D({ zerosLike_: is });
|
|
|
3252
3252
|
* limitations under the License.
|
|
3253
3253
|
* =============================================================================
|
|
3254
3254
|
*/
|
|
3255
|
-
function
|
|
3255
|
+
function ls(e, t) {
|
|
3256
3256
|
let n = T(e, "base", "pow"), s = T(t, "exp", "pow");
|
|
3257
3257
|
[n, s] = K(n, s);
|
|
3258
3258
|
const r = { a: n, b: s };
|
|
3259
|
-
return f.runKernel(
|
|
3259
|
+
return f.runKernel(en, r);
|
|
3260
3260
|
}
|
|
3261
|
-
const Qt = /* @__PURE__ */
|
|
3261
|
+
const Qt = /* @__PURE__ */ F({ pow_: ls });
|
|
3262
3262
|
/**
|
|
3263
3263
|
* @license
|
|
3264
3264
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -3276,11 +3276,11 @@ const Qt = /* @__PURE__ */ D({ pow_: cs });
|
|
|
3276
3276
|
* =============================================================================
|
|
3277
3277
|
*/
|
|
3278
3278
|
function q(e, t) {
|
|
3279
|
-
if ((
|
|
3279
|
+
if ((R(e) && t !== "string" || Array.isArray(e)) && t !== "complex64")
|
|
3280
3280
|
throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");
|
|
3281
|
-
if (t === "string" &&
|
|
3281
|
+
if (t === "string" && R(e) && !(e instanceof Uint8Array))
|
|
3282
3282
|
throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");
|
|
3283
|
-
return
|
|
3283
|
+
return vn(e, [], [], t);
|
|
3284
3284
|
}
|
|
3285
3285
|
/**
|
|
3286
3286
|
* @license
|
|
@@ -3298,11 +3298,11 @@ function q(e, t) {
|
|
|
3298
3298
|
* limitations under the License.
|
|
3299
3299
|
* =============================================================================
|
|
3300
3300
|
*/
|
|
3301
|
-
function
|
|
3301
|
+
function us(e) {
|
|
3302
3302
|
const n = { x: T(e, "x", "sqrt", "float32") };
|
|
3303
|
-
return f.runKernel(
|
|
3303
|
+
return f.runKernel(nn, n);
|
|
3304
3304
|
}
|
|
3305
|
-
const nt = /* @__PURE__ */
|
|
3305
|
+
const nt = /* @__PURE__ */ F({ sqrt_: us });
|
|
3306
3306
|
/**
|
|
3307
3307
|
* @license
|
|
3308
3308
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
@@ -3319,11 +3319,11 @@ const nt = /* @__PURE__ */ D({ sqrt_: ls });
|
|
|
3319
3319
|
* limitations under the License.
|
|
3320
3320
|
* =============================================================================
|
|
3321
3321
|
*/
|
|
3322
|
-
function
|
|
3322
|
+
function hs(e) {
|
|
3323
3323
|
const t = T(e, "x", "square"), n = {};
|
|
3324
3324
|
return f.runKernel("Square", { x: t }, n);
|
|
3325
3325
|
}
|
|
3326
|
-
const V = /* @__PURE__ */
|
|
3326
|
+
const V = /* @__PURE__ */ F({ square_: hs });
|
|
3327
3327
|
/**
|
|
3328
3328
|
* @license
|
|
3329
3329
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -3341,17 +3341,24 @@ const V = /* @__PURE__ */ D({ square_: us });
|
|
|
3341
3341
|
* =============================================================================
|
|
3342
3342
|
*/
|
|
3343
3343
|
function bi(e) {
|
|
3344
|
-
return
|
|
3345
|
-
|
|
3346
|
-
const s =
|
|
3344
|
+
return p(lt(e), () => "The f passed in grads(f) must be a function"), (t, n) => {
|
|
3345
|
+
p(Array.isArray(t), () => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");
|
|
3346
|
+
const s = An(t, "args", "tf.grads", "string_or_numeric"), r = n != null ? T(n, "dy", "tf.grads") : null;
|
|
3347
3347
|
return f.tidy(() => {
|
|
3348
3348
|
const { value: a, grads: o } = f.gradients(() => e(...s), s, r);
|
|
3349
|
-
return r != null &&
|
|
3349
|
+
return r != null && te(a.shape, r.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), Me(o), o;
|
|
3350
3350
|
});
|
|
3351
3351
|
};
|
|
3352
3352
|
}
|
|
3353
|
-
function
|
|
3354
|
-
|
|
3353
|
+
function wi(e) {
|
|
3354
|
+
return p(lt(e), () => "The f passed in valueAndGrads(f) must be a function"), (t, n) => {
|
|
3355
|
+
p(Array.isArray(t) && t.every((r) => r instanceof M), () => "The args passed in valueAndGrads(f)(args) must be array of tensors"), p(n == null || n instanceof M, () => "The dy passed in valueAndGrads(f)(args, dy) must be a tensor");
|
|
3356
|
+
const s = f.gradients(() => e(...t), t, n);
|
|
3357
|
+
return n != null && te(s.value.shape, n.shape, "The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), Me(s.grads), s;
|
|
3358
|
+
};
|
|
3359
|
+
}
|
|
3360
|
+
function ds(e, t) {
|
|
3361
|
+
p(lt(e), () => "The f passed in variableGrads(f) must be a function"), p(t == null || Array.isArray(t) && t.every((l) => l instanceof mt), () => "The varList passed in variableGrads(f, varList) must be an array of variables");
|
|
3355
3362
|
const n = t != null;
|
|
3356
3363
|
if (!n) {
|
|
3357
3364
|
t = [];
|
|
@@ -3359,18 +3366,18 @@ function hs(e, t) {
|
|
|
3359
3366
|
t.push(f.registeredVariables[l]);
|
|
3360
3367
|
}
|
|
3361
3368
|
const s = n ? t.filter((l) => !l.trainable) : null, r = t.length;
|
|
3362
|
-
t = t.filter((l) => l.trainable),
|
|
3369
|
+
t = t.filter((l) => l.trainable), p(t.length > 0, () => `variableGrads() expects at least one of the input variables to be trainable, but none of the ${r} variables is trainable.`);
|
|
3363
3370
|
const a = !0, { value: o, grads: i } = f.gradients(e, t, null, a);
|
|
3364
|
-
|
|
3371
|
+
p(i.some((l) => l != null), () => "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."), p(o.rank === 0, () => `The f passed in variableGrads(f) must return a scalar, but it returned a rank-${o.rank} tensor`);
|
|
3365
3372
|
const c = {};
|
|
3366
3373
|
return t.forEach((l, u) => {
|
|
3367
3374
|
i[u] != null && (c[l.name] = i[u]);
|
|
3368
3375
|
}), s?.forEach((l) => c[l.name] = null), { value: o, grads: c };
|
|
3369
3376
|
}
|
|
3370
|
-
function
|
|
3377
|
+
function Si(e) {
|
|
3371
3378
|
return f.customGrad(e);
|
|
3372
3379
|
}
|
|
3373
|
-
function
|
|
3380
|
+
function Me(e) {
|
|
3374
3381
|
if (e.filter((n) => n == null).length > 0)
|
|
3375
3382
|
throw new Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that
|
|
3376
3383
|
the f you passed encloses all operations that lead from x to y.`);
|
|
@@ -3395,9 +3402,9 @@ function fs(e, t) {
|
|
|
3395
3402
|
let n = T(e, "a", "sub"), s = T(t, "b", "sub");
|
|
3396
3403
|
[n, s] = K(n, s);
|
|
3397
3404
|
const r = { a: n, b: s };
|
|
3398
|
-
return f.runKernel(
|
|
3405
|
+
return f.runKernel(sn, r);
|
|
3399
3406
|
}
|
|
3400
|
-
const tt = /* @__PURE__ */
|
|
3407
|
+
const tt = /* @__PURE__ */ F({ sub_: fs });
|
|
3401
3408
|
/**
|
|
3402
3409
|
* @license
|
|
3403
3410
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -3416,11 +3423,11 @@ const tt = /* @__PURE__ */ D({ sub_: fs });
|
|
|
3416
3423
|
*/
|
|
3417
3424
|
function gs(e, t) {
|
|
3418
3425
|
let n = T(e, "a", "maximum"), s = T(t, "b", "maximum");
|
|
3419
|
-
[n, s] = K(n, s), n.dtype === "bool" && (n = Rt(n, "int32"), s = Rt(s, "int32")),
|
|
3426
|
+
[n, s] = K(n, s), n.dtype === "bool" && (n = Rt(n, "int32"), s = Rt(s, "int32")), is(n.shape, s.shape);
|
|
3420
3427
|
const r = { a: n, b: s };
|
|
3421
|
-
return f.runKernel(
|
|
3428
|
+
return f.runKernel(Qe, r);
|
|
3422
3429
|
}
|
|
3423
|
-
const ms = /* @__PURE__ */
|
|
3430
|
+
const ms = /* @__PURE__ */ F({ maximum_: gs });
|
|
3424
3431
|
/**
|
|
3425
3432
|
* @license
|
|
3426
3433
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -3484,7 +3491,7 @@ class G {
|
|
|
3484
3491
|
}
|
|
3485
3492
|
}
|
|
3486
3493
|
function ws(e, t, n) {
|
|
3487
|
-
|
|
3494
|
+
p(e.className != null, () => "Class being registered does not have the static className property defined."), p(typeof e.className == "string", () => "className is required to be a string, but got type " + typeof e.className), p(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);
|
|
3488
3495
|
const s = n, r = t + ">" + s;
|
|
3489
3496
|
return G.register(e), ps.set(r, e), ys.set(e, r), e;
|
|
3490
3497
|
}
|
|
@@ -3526,7 +3533,7 @@ class H extends bs {
|
|
|
3526
3533
|
this.applyGradients(o);
|
|
3527
3534
|
} else
|
|
3528
3535
|
this.applyGradients(a);
|
|
3529
|
-
return
|
|
3536
|
+
return D(a), n ? r : (r.dispose(), null);
|
|
3530
3537
|
}
|
|
3531
3538
|
/**
|
|
3532
3539
|
* The number of iterations that this optimizer instance has been invoked for.
|
|
@@ -3551,13 +3558,13 @@ class H extends bs {
|
|
|
3551
3558
|
* @doc {heading: 'Training', subheading: 'Optimizers'}
|
|
3552
3559
|
*/
|
|
3553
3560
|
computeGradients(t, n) {
|
|
3554
|
-
return
|
|
3561
|
+
return ds(t, n);
|
|
3555
3562
|
}
|
|
3556
3563
|
/**
|
|
3557
3564
|
* Dispose the variables (if any) owned by this optimizer instance.
|
|
3558
3565
|
*/
|
|
3559
3566
|
dispose() {
|
|
3560
|
-
this.iterations_ != null &&
|
|
3567
|
+
this.iterations_ != null && D(this.iterations_);
|
|
3561
3568
|
}
|
|
3562
3569
|
async saveIterations() {
|
|
3563
3570
|
return this.iterations_ == null && (this.iterations_ = 0), {
|
|
@@ -3615,16 +3622,16 @@ class Ss extends H {
|
|
|
3615
3622
|
const a = f.registeredVariables[s], o = !1;
|
|
3616
3623
|
this.accumulatedGrads[r] == null && (this.accumulatedGrads[r] = {
|
|
3617
3624
|
originalName: `${s}/accum_grad`,
|
|
3618
|
-
variable:
|
|
3625
|
+
variable: A(() => C(a).variable(o))
|
|
3619
3626
|
}), this.accumulatedUpdates[r] == null && (this.accumulatedUpdates[r] = {
|
|
3620
3627
|
originalName: `${s}/accum_var`,
|
|
3621
|
-
variable:
|
|
3628
|
+
variable: A(() => C(a).variable(o))
|
|
3622
3629
|
});
|
|
3623
3630
|
const i = Array.isArray(t) ? t[r].tensor : t[s];
|
|
3624
3631
|
if (i == null)
|
|
3625
3632
|
return;
|
|
3626
3633
|
const c = this.accumulatedGrads[r].variable, l = this.accumulatedUpdates[r].variable;
|
|
3627
|
-
|
|
3634
|
+
A(() => {
|
|
3628
3635
|
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));
|
|
3629
3636
|
c.assign(u), l.assign(d);
|
|
3630
3637
|
const m = k(b(h, -this.learningRate), a);
|
|
@@ -3633,7 +3640,7 @@ class Ss extends H {
|
|
|
3633
3640
|
}), this.incrementIterations();
|
|
3634
3641
|
}
|
|
3635
3642
|
dispose() {
|
|
3636
|
-
this.accumulatedUpdates != null && (
|
|
3643
|
+
this.accumulatedUpdates != null && (D(this.accumulatedGrads.map((t) => t.variable)), D(this.accumulatedUpdates.map((t) => t.variable)));
|
|
3637
3644
|
}
|
|
3638
3645
|
async getWeights() {
|
|
3639
3646
|
const t = [...this.accumulatedGrads, ...this.accumulatedUpdates];
|
|
@@ -3691,13 +3698,13 @@ class ks extends H {
|
|
|
3691
3698
|
const a = f.registeredVariables[s];
|
|
3692
3699
|
this.accumulatedGrads[r] == null && (this.accumulatedGrads[r] = {
|
|
3693
3700
|
originalName: `${s}/accumulator`,
|
|
3694
|
-
variable:
|
|
3701
|
+
variable: A(() => os(a.shape, this.initialAccumulatorValue).variable(!1))
|
|
3695
3702
|
});
|
|
3696
3703
|
const o = Array.isArray(t) ? t[r].tensor : t[s];
|
|
3697
3704
|
if (o == null)
|
|
3698
3705
|
return;
|
|
3699
3706
|
const i = this.accumulatedGrads[r].variable;
|
|
3700
|
-
|
|
3707
|
+
A(() => {
|
|
3701
3708
|
const c = k(i, V(o));
|
|
3702
3709
|
i.assign(c);
|
|
3703
3710
|
const l = k(b($(o, nt(k(c, f.backend.epsilon()))), -this.learningRate), a);
|
|
@@ -3706,7 +3713,7 @@ class ks extends H {
|
|
|
3706
3713
|
}), this.incrementIterations();
|
|
3707
3714
|
}
|
|
3708
3715
|
dispose() {
|
|
3709
|
-
this.accumulatedGrads != null &&
|
|
3716
|
+
this.accumulatedGrads != null && D(this.accumulatedGrads.map((t) => t.variable));
|
|
3710
3717
|
}
|
|
3711
3718
|
async getWeights() {
|
|
3712
3719
|
return [await this.saveIterations()].concat(this.accumulatedGrads.map((t) => ({ name: t.originalName, tensor: t.variable })));
|
|
@@ -3749,42 +3756,42 @@ class Is extends H {
|
|
|
3749
3756
|
return "Adam";
|
|
3750
3757
|
}
|
|
3751
3758
|
constructor(t, n, s, r = null) {
|
|
3752
|
-
super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [],
|
|
3759
|
+
super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], A(() => {
|
|
3753
3760
|
this.accBeta1 = q(n).variable(), this.accBeta2 = q(s).variable();
|
|
3754
3761
|
}), r == null && (this.epsilon = f.backend.epsilon());
|
|
3755
3762
|
}
|
|
3756
3763
|
applyGradients(t) {
|
|
3757
3764
|
const n = Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t);
|
|
3758
|
-
|
|
3765
|
+
A(() => {
|
|
3759
3766
|
const s = tt(1, this.accBeta1), r = tt(1, this.accBeta2);
|
|
3760
3767
|
n.forEach((a, o) => {
|
|
3761
3768
|
const i = f.registeredVariables[a], c = !1;
|
|
3762
3769
|
this.accumulatedFirstMoment[o] == null && (this.accumulatedFirstMoment[o] = {
|
|
3763
3770
|
originalName: `${a}/m`,
|
|
3764
|
-
variable:
|
|
3771
|
+
variable: A(() => C(i).variable(c))
|
|
3765
3772
|
}), this.accumulatedSecondMoment[o] == null && (this.accumulatedSecondMoment[o] = {
|
|
3766
3773
|
originalName: `${a}/v`,
|
|
3767
|
-
variable:
|
|
3774
|
+
variable: A(() => C(i).variable(c))
|
|
3768
3775
|
});
|
|
3769
3776
|
const l = Array.isArray(t) ? t[o].tensor : t[a];
|
|
3770
3777
|
if (l == null)
|
|
3771
3778
|
return;
|
|
3772
|
-
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)),
|
|
3779
|
+
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)), y = $(d, s), g = $(m, r);
|
|
3773
3780
|
u.assign(d), h.assign(m);
|
|
3774
|
-
const w = k(b($(
|
|
3781
|
+
const w = k(b($(y, k(nt(g), this.epsilon)), -this.learningRate), i);
|
|
3775
3782
|
i.assign(w);
|
|
3776
3783
|
}), this.accBeta1.assign(b(this.accBeta1, this.beta1)), this.accBeta2.assign(b(this.accBeta2, this.beta2));
|
|
3777
3784
|
}), this.incrementIterations();
|
|
3778
3785
|
}
|
|
3779
3786
|
dispose() {
|
|
3780
|
-
this.accBeta1.dispose(), this.accBeta2.dispose(), this.accumulatedFirstMoment != null &&
|
|
3787
|
+
this.accBeta1.dispose(), this.accBeta2.dispose(), this.accumulatedFirstMoment != null && D(this.accumulatedFirstMoment.map((t) => t.variable)), this.accumulatedSecondMoment != null && D(this.accumulatedSecondMoment.map((t) => t.variable));
|
|
3781
3788
|
}
|
|
3782
3789
|
async getWeights() {
|
|
3783
3790
|
const t = [...this.accumulatedFirstMoment, ...this.accumulatedSecondMoment];
|
|
3784
3791
|
return [await this.saveIterations()].concat(t.map((n) => ({ name: n.originalName, tensor: n.variable })));
|
|
3785
3792
|
}
|
|
3786
3793
|
async setWeights(t) {
|
|
3787
|
-
t = await this.extractIterations(t),
|
|
3794
|
+
t = await this.extractIterations(t), A(() => {
|
|
3788
3795
|
this.accBeta1.assign(Qt(this.beta1, this.iterations_ + 1)), this.accBeta2.assign(Qt(this.beta2, this.iterations_ + 1));
|
|
3789
3796
|
});
|
|
3790
3797
|
const n = t.length / 2, s = !1;
|
|
@@ -3831,13 +3838,13 @@ class Ts extends H {
|
|
|
3831
3838
|
return "Adamax";
|
|
3832
3839
|
}
|
|
3833
3840
|
constructor(t, n, s, r = null, a = 0) {
|
|
3834
|
-
super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.decay = a, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [],
|
|
3841
|
+
super(), this.learningRate = t, this.beta1 = n, this.beta2 = s, this.epsilon = r, this.decay = a, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], A(() => {
|
|
3835
3842
|
this.iteration = q(0).variable(), this.accBeta1 = q(n).variable();
|
|
3836
3843
|
}), r == null && (this.epsilon = f.backend.epsilon());
|
|
3837
3844
|
}
|
|
3838
3845
|
applyGradients(t) {
|
|
3839
3846
|
const n = Array.isArray(t) ? t.map((s) => s.name) : Object.keys(t);
|
|
3840
|
-
|
|
3847
|
+
A(() => {
|
|
3841
3848
|
const s = tt(1, this.accBeta1), r = $(-this.learningRate, k(b(this.iteration, this.decay), 1));
|
|
3842
3849
|
n.forEach((a, o) => {
|
|
3843
3850
|
const i = f.registeredVariables[a], c = !1;
|
|
@@ -3851,7 +3858,7 @@ class Ts extends H {
|
|
|
3851
3858
|
const l = Array.isArray(t) ? t[o].tensor : t[a];
|
|
3852
3859
|
if (l == null)
|
|
3853
3860
|
return;
|
|
3854
|
-
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),
|
|
3861
|
+
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), y = as(l), g = ms(m, y);
|
|
3855
3862
|
u.assign(d), h.assign(g);
|
|
3856
3863
|
const w = k(b($(r, s), $(d, k(g, this.epsilon))), i);
|
|
3857
3864
|
i.assign(w);
|
|
@@ -3859,7 +3866,7 @@ class Ts extends H {
|
|
|
3859
3866
|
}), this.incrementIterations();
|
|
3860
3867
|
}
|
|
3861
3868
|
dispose() {
|
|
3862
|
-
this.accBeta1.dispose(), this.iteration.dispose(), this.accumulatedFirstMoment != null &&
|
|
3869
|
+
this.accBeta1.dispose(), this.iteration.dispose(), this.accumulatedFirstMoment != null && D(this.accumulatedFirstMoment.map((t) => t.variable)), this.accumulatedWeightedInfNorm != null && D(this.accumulatedWeightedInfNorm.map((t) => t.variable));
|
|
3863
3870
|
}
|
|
3864
3871
|
async getWeights() {
|
|
3865
3872
|
throw new Error("getWeights() is not implemented for Adamax yet.");
|
|
@@ -3897,7 +3904,7 @@ class Ts extends H {
|
|
|
3897
3904
|
* limitations under the License.
|
|
3898
3905
|
* =============================================================================
|
|
3899
3906
|
*/
|
|
3900
|
-
class
|
|
3907
|
+
class De extends H {
|
|
3901
3908
|
/** @nocollapse */
|
|
3902
3909
|
static get className() {
|
|
3903
3910
|
return "SGD";
|
|
@@ -3911,7 +3918,7 @@ class Be extends H {
|
|
|
3911
3918
|
if (a == null)
|
|
3912
3919
|
return;
|
|
3913
3920
|
const o = f.registeredVariables[s];
|
|
3914
|
-
|
|
3921
|
+
A(() => {
|
|
3915
3922
|
const i = k(b(this.c, a), o);
|
|
3916
3923
|
o.assign(i);
|
|
3917
3924
|
});
|
|
@@ -3921,7 +3928,7 @@ class Be extends H {
|
|
|
3921
3928
|
* Sets the learning rate of the optimizer.
|
|
3922
3929
|
*/
|
|
3923
3930
|
setLearningRate(t) {
|
|
3924
|
-
this.learningRate = t, this.c != null && this.c.dispose(), this.c =
|
|
3931
|
+
this.learningRate = t, this.c != null && this.c.dispose(), this.c = Mn(q(-t));
|
|
3925
3932
|
}
|
|
3926
3933
|
dispose() {
|
|
3927
3934
|
this.c.dispose();
|
|
@@ -3957,7 +3964,7 @@ class Be extends H {
|
|
|
3957
3964
|
* limitations under the License.
|
|
3958
3965
|
* =============================================================================
|
|
3959
3966
|
*/
|
|
3960
|
-
class
|
|
3967
|
+
class As extends De {
|
|
3961
3968
|
/** @nocollapse */
|
|
3962
3969
|
// Name matters for Python compatibility.
|
|
3963
3970
|
static get className() {
|
|
@@ -3971,10 +3978,10 @@ class Es extends Be {
|
|
|
3971
3978
|
const a = f.registeredVariables[s];
|
|
3972
3979
|
this.accumulations[r] == null && (this.accumulations[r] = {
|
|
3973
3980
|
originalName: `${s}/momentum`,
|
|
3974
|
-
variable:
|
|
3981
|
+
variable: A(() => C(a).variable(!1))
|
|
3975
3982
|
});
|
|
3976
3983
|
const o = this.accumulations[r].variable, i = Array.isArray(t) ? t[r].tensor : t[s];
|
|
3977
|
-
i != null &&
|
|
3984
|
+
i != null && A(() => {
|
|
3978
3985
|
let c;
|
|
3979
3986
|
const l = k(b(this.m, o), i);
|
|
3980
3987
|
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);
|
|
@@ -3982,7 +3989,7 @@ class Es extends Be {
|
|
|
3982
3989
|
}), this.incrementIterations();
|
|
3983
3990
|
}
|
|
3984
3991
|
dispose() {
|
|
3985
|
-
this.m.dispose(), this.accumulations != null &&
|
|
3992
|
+
this.m.dispose(), this.accumulations != null && D(this.accumulations.map((t) => t.variable));
|
|
3986
3993
|
}
|
|
3987
3994
|
/**
|
|
3988
3995
|
* Sets the momentum of the optimizer.
|
|
@@ -4028,7 +4035,7 @@ class Es extends Be {
|
|
|
4028
4035
|
* limitations under the License.
|
|
4029
4036
|
* =============================================================================
|
|
4030
4037
|
*/
|
|
4031
|
-
class
|
|
4038
|
+
class Es extends H {
|
|
4032
4039
|
/** @nocollapse */
|
|
4033
4040
|
static get className() {
|
|
4034
4041
|
return "RMSProp";
|
|
@@ -4042,24 +4049,24 @@ class As extends H {
|
|
|
4042
4049
|
const a = f.registeredVariables[s], o = !1;
|
|
4043
4050
|
this.accumulatedMeanSquares[r] == null && (this.accumulatedMeanSquares[r] = {
|
|
4044
4051
|
originalName: `${s}/rms`,
|
|
4045
|
-
variable:
|
|
4052
|
+
variable: A(() => C(a).variable(o))
|
|
4046
4053
|
}), this.accumulatedMoments[r] == null && (this.accumulatedMoments[r] = {
|
|
4047
4054
|
originalName: `${s}/momentum`,
|
|
4048
|
-
variable:
|
|
4055
|
+
variable: A(() => C(a).variable(o))
|
|
4049
4056
|
}), this.accumulatedMeanGrads[r] == null && this.centered && (this.accumulatedMeanGrads[r] = {
|
|
4050
4057
|
originalName: `${s}/mg`,
|
|
4051
|
-
variable:
|
|
4058
|
+
variable: A(() => C(a).variable(o))
|
|
4052
4059
|
});
|
|
4053
4060
|
const i = Array.isArray(t) ? t[r].tensor : t[s];
|
|
4054
4061
|
if (i == null)
|
|
4055
4062
|
return;
|
|
4056
4063
|
const c = this.accumulatedMeanSquares[r].variable, l = this.accumulatedMoments[r].variable;
|
|
4057
|
-
|
|
4064
|
+
A(() => {
|
|
4058
4065
|
const u = k(b(c, this.decay), b(V(i), 1 - this.decay));
|
|
4059
4066
|
if (this.centered) {
|
|
4060
|
-
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)))),
|
|
4061
|
-
c.assign(u), h.assign(d), l.assign(
|
|
4062
|
-
const g = tt(a,
|
|
4067
|
+
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)))), y = k(b(l, this.momentum), m);
|
|
4068
|
+
c.assign(u), h.assign(d), l.assign(y);
|
|
4069
|
+
const g = tt(a, y);
|
|
4063
4070
|
a.assign(g);
|
|
4064
4071
|
} else {
|
|
4065
4072
|
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))));
|
|
@@ -4071,7 +4078,7 @@ class As extends H {
|
|
|
4071
4078
|
}), this.incrementIterations();
|
|
4072
4079
|
}
|
|
4073
4080
|
dispose() {
|
|
4074
|
-
this.accumulatedMeanSquares != null &&
|
|
4081
|
+
this.accumulatedMeanSquares != null && D(this.accumulatedMeanSquares.map((t) => t.variable)), this.accumulatedMeanGrads != null && this.centered && D(this.accumulatedMeanGrads.map((t) => t.variable)), this.accumulatedMoments != null && D(this.accumulatedMoments.map((t) => t.variable));
|
|
4075
4082
|
}
|
|
4076
4083
|
async getWeights() {
|
|
4077
4084
|
const t = [...this.accumulatedMeanSquares, ...this.accumulatedMoments];
|
|
@@ -4126,9 +4133,9 @@ const vs = [
|
|
|
4126
4133
|
ks,
|
|
4127
4134
|
Is,
|
|
4128
4135
|
Ts,
|
|
4129
|
-
Es,
|
|
4130
4136
|
As,
|
|
4131
|
-
|
|
4137
|
+
Es,
|
|
4138
|
+
De
|
|
4132
4139
|
];
|
|
4133
4140
|
function Bs() {
|
|
4134
4141
|
for (const e of vs)
|
|
@@ -4152,297 +4159,299 @@ function Bs() {
|
|
|
4152
4159
|
*/
|
|
4153
4160
|
Bs();
|
|
4154
4161
|
export {
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4162
|
+
ho as $,
|
|
4163
|
+
Tn as A,
|
|
4164
|
+
vn as B,
|
|
4165
|
+
F as C,
|
|
4166
|
+
T as D,
|
|
4160
4167
|
f as E,
|
|
4161
|
-
|
|
4168
|
+
An as F,
|
|
4162
4169
|
ta as G,
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
+
Jn as H,
|
|
4171
|
+
Sr as I,
|
|
4172
|
+
Si as J,
|
|
4173
|
+
bi as K,
|
|
4174
|
+
C as L,
|
|
4175
|
+
Ct as M,
|
|
4176
|
+
Ue as N,
|
|
4170
4177
|
H as O,
|
|
4171
4178
|
Ga as P,
|
|
4172
|
-
|
|
4179
|
+
K as Q,
|
|
4173
4180
|
Ka as R,
|
|
4174
4181
|
ko as S,
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4182
|
+
M as T,
|
|
4183
|
+
hr as U,
|
|
4184
|
+
Ya as V,
|
|
4185
|
+
So as W,
|
|
4186
|
+
Po as X,
|
|
4187
|
+
Ra as Y,
|
|
4188
|
+
Xa as Z,
|
|
4189
|
+
Ja as _,
|
|
4183
4190
|
b as a,
|
|
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
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4191
|
+
aa as a$,
|
|
4192
|
+
Rt as a0,
|
|
4193
|
+
bo as a1,
|
|
4194
|
+
ni as a2,
|
|
4195
|
+
$t as a3,
|
|
4196
|
+
te as a4,
|
|
4197
|
+
Gs as a5,
|
|
4198
|
+
xa as a6,
|
|
4199
|
+
oo as a7,
|
|
4200
|
+
ea as a8,
|
|
4201
|
+
Sn as a9,
|
|
4202
|
+
Zo as aA,
|
|
4203
|
+
Qo as aB,
|
|
4204
|
+
Je as aC,
|
|
4205
|
+
E as aD,
|
|
4206
|
+
st as aE,
|
|
4207
|
+
di as aF,
|
|
4208
|
+
ke as aG,
|
|
4209
|
+
fi as aH,
|
|
4210
|
+
gi as aI,
|
|
4211
|
+
Us as aJ,
|
|
4212
|
+
_s as aK,
|
|
4213
|
+
$s as aL,
|
|
4214
|
+
ht as aM,
|
|
4215
|
+
Ws as aN,
|
|
4216
|
+
jt as aO,
|
|
4217
|
+
he as aP,
|
|
4218
|
+
Xo as aQ,
|
|
4219
|
+
O as aR,
|
|
4220
|
+
fr as aS,
|
|
4221
|
+
lo as aT,
|
|
4222
|
+
zr as aU,
|
|
4223
|
+
Ma as aV,
|
|
4224
|
+
as as aW,
|
|
4225
|
+
V as aX,
|
|
4226
|
+
Hr as aY,
|
|
4227
|
+
na as aZ,
|
|
4228
|
+
sa as a_,
|
|
4229
|
+
wr as aa,
|
|
4230
|
+
se as ab,
|
|
4231
|
+
Br as ac,
|
|
4232
|
+
fo as ad,
|
|
4233
|
+
pi as ae,
|
|
4234
|
+
xt as af,
|
|
4235
|
+
S as ag,
|
|
4236
|
+
ka as ah,
|
|
4237
|
+
Kr as ai,
|
|
4238
|
+
fa as aj,
|
|
4239
|
+
R as ak,
|
|
4240
|
+
ye as al,
|
|
4241
|
+
ti as am,
|
|
4242
|
+
gt as an,
|
|
4243
|
+
Zr as ao,
|
|
4244
|
+
Kn as ap,
|
|
4245
|
+
$e as aq,
|
|
4239
4246
|
po as ar,
|
|
4240
4247
|
Vr as as,
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
+
la as at,
|
|
4249
|
+
za as au,
|
|
4250
|
+
no as av,
|
|
4251
|
+
Vo as aw,
|
|
4252
|
+
yi as ax,
|
|
4253
|
+
Ns as ay,
|
|
4254
|
+
ce as az,
|
|
4248
4255
|
q as b,
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4256
|
+
jr as b$,
|
|
4257
|
+
ua as b0,
|
|
4258
|
+
ha as b1,
|
|
4259
|
+
ga as b2,
|
|
4260
|
+
Na as b3,
|
|
4261
|
+
ma as b4,
|
|
4262
|
+
Ba as b5,
|
|
4263
|
+
Da as b6,
|
|
4264
|
+
$a as b7,
|
|
4265
|
+
Ha as b8,
|
|
4266
|
+
ro as b9,
|
|
4267
|
+
Qe as bA,
|
|
4268
|
+
tn as bB,
|
|
4269
|
+
Va as bC,
|
|
4270
|
+
ao as bD,
|
|
4271
|
+
gn as bE,
|
|
4272
|
+
nn as bF,
|
|
4273
|
+
Do as bG,
|
|
4274
|
+
sn as bH,
|
|
4275
|
+
Ne as bI,
|
|
4276
|
+
Zs as bJ,
|
|
4277
|
+
Qs as bK,
|
|
4278
|
+
tr as bL,
|
|
4279
|
+
ir as bM,
|
|
4280
|
+
lr as bN,
|
|
4281
|
+
Co as bO,
|
|
4282
|
+
dr as bP,
|
|
4283
|
+
Qr as bQ,
|
|
4284
|
+
br as bR,
|
|
4285
|
+
kr as bS,
|
|
4286
|
+
Tr as bT,
|
|
4287
|
+
Ar as bU,
|
|
4288
|
+
vr as bV,
|
|
4289
|
+
Mr as bW,
|
|
4290
|
+
Dr as bX,
|
|
4291
|
+
Fr as bY,
|
|
4292
|
+
xr as bZ,
|
|
4293
|
+
$r as b_,
|
|
4294
|
+
Bo as ba,
|
|
4295
|
+
Uo as bb,
|
|
4296
|
+
Oo as bc,
|
|
4297
|
+
Rr as bd,
|
|
4298
|
+
Yr as be,
|
|
4299
|
+
jo as bf,
|
|
4300
|
+
Ca as bg,
|
|
4301
|
+
La as bh,
|
|
4302
|
+
Pa as bi,
|
|
4303
|
+
to as bj,
|
|
4304
|
+
Za as bk,
|
|
4305
|
+
_o as bl,
|
|
4306
|
+
He as bm,
|
|
4307
|
+
zs as bn,
|
|
4308
|
+
Hs as bo,
|
|
4309
|
+
Ks as bp,
|
|
4310
|
+
ie as bq,
|
|
4311
|
+
Vs as br,
|
|
4312
|
+
_t as bs,
|
|
4313
|
+
oe as bt,
|
|
4314
|
+
gr as bu,
|
|
4315
|
+
ee as bv,
|
|
4316
|
+
yr as bw,
|
|
4317
|
+
qr as bx,
|
|
4318
|
+
Xr as by,
|
|
4319
|
+
Ze as bz,
|
|
4313
4320
|
tt as c,
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4321
|
+
Ge as c$,
|
|
4322
|
+
yo as c0,
|
|
4323
|
+
pa as c1,
|
|
4324
|
+
Ia as c2,
|
|
4325
|
+
Aa as c3,
|
|
4326
|
+
Oa as c4,
|
|
4327
|
+
_a as c5,
|
|
4328
|
+
Ua as c6,
|
|
4329
|
+
wo as c7,
|
|
4330
|
+
so as c8,
|
|
4331
|
+
uo as c9,
|
|
4332
|
+
Xe as cA,
|
|
4333
|
+
Er as cB,
|
|
4334
|
+
_r as cC,
|
|
4335
|
+
Gr as cD,
|
|
4336
|
+
Or as cE,
|
|
4337
|
+
Wr as cF,
|
|
4338
|
+
oa as cG,
|
|
4339
|
+
ia as cH,
|
|
4340
|
+
ca as cI,
|
|
4341
|
+
ba as cJ,
|
|
4342
|
+
Sa as cK,
|
|
4343
|
+
wa as cL,
|
|
4344
|
+
Ea as cM,
|
|
4345
|
+
Ta as cN,
|
|
4346
|
+
Fa as cO,
|
|
4347
|
+
en as cP,
|
|
4348
|
+
eo as cQ,
|
|
4349
|
+
Qa as cR,
|
|
4350
|
+
mo as cS,
|
|
4351
|
+
Mo as cT,
|
|
4352
|
+
$o as cU,
|
|
4353
|
+
ms as cV,
|
|
4354
|
+
rn as cW,
|
|
4355
|
+
li as cX,
|
|
4356
|
+
ws as cY,
|
|
4357
|
+
bs as cZ,
|
|
4358
|
+
G as c_,
|
|
4359
|
+
go as ca,
|
|
4360
|
+
zo as cb,
|
|
4361
|
+
Ir as cc,
|
|
4362
|
+
Ko as cd,
|
|
4363
|
+
Cr as ce,
|
|
4364
|
+
Pr as cf,
|
|
4365
|
+
qo as cg,
|
|
4366
|
+
De as ch,
|
|
4367
|
+
As as ci,
|
|
4368
|
+
Es as cj,
|
|
4369
|
+
Is as ck,
|
|
4370
|
+
Ss as cl,
|
|
4371
|
+
Ts as cm,
|
|
4372
|
+
ks as cn,
|
|
4373
|
+
Xs as co,
|
|
4374
|
+
Js as cp,
|
|
4375
|
+
Ys as cq,
|
|
4376
|
+
er as cr,
|
|
4377
|
+
nr as cs,
|
|
4378
|
+
sr as ct,
|
|
4379
|
+
or as cu,
|
|
4380
|
+
rr as cv,
|
|
4381
|
+
ar as cw,
|
|
4382
|
+
ur as cx,
|
|
4383
|
+
cr as cy,
|
|
4384
|
+
mr as cz,
|
|
4385
|
+
D as d,
|
|
4386
|
+
xs as d0,
|
|
4387
|
+
mi as d1,
|
|
4388
|
+
ui as d2,
|
|
4389
|
+
hi as d3,
|
|
4390
|
+
xe as d4,
|
|
4391
|
+
Rs as d5,
|
|
4392
|
+
js as d6,
|
|
4393
|
+
ut as d7,
|
|
4394
|
+
Cs as d8,
|
|
4395
|
+
Nt as d9,
|
|
4396
|
+
es as dA,
|
|
4397
|
+
ct as dB,
|
|
4398
|
+
qs as dC,
|
|
4399
|
+
Wa as dD,
|
|
4400
|
+
ja as dE,
|
|
4401
|
+
qa as dF,
|
|
4402
|
+
Io as dG,
|
|
4403
|
+
To as dH,
|
|
4404
|
+
xo as dI,
|
|
4405
|
+
No as dJ,
|
|
4406
|
+
ei as dK,
|
|
4407
|
+
Os as dL,
|
|
4408
|
+
It as dM,
|
|
4409
|
+
In as dN,
|
|
4410
|
+
ci as da,
|
|
4411
|
+
Ye as db,
|
|
4412
|
+
yt as dc,
|
|
4413
|
+
Ls as dd,
|
|
4414
|
+
pr as de,
|
|
4415
|
+
Nr as df,
|
|
4416
|
+
Lr as dg,
|
|
4417
|
+
Ur as dh,
|
|
4418
|
+
Jr as di,
|
|
4419
|
+
Wo as dj,
|
|
4420
|
+
Ho as dk,
|
|
4421
|
+
ra as dl,
|
|
4422
|
+
da as dm,
|
|
4423
|
+
ya as dn,
|
|
4424
|
+
va as dp,
|
|
4425
|
+
co as dq,
|
|
4426
|
+
Ao as dr,
|
|
4427
|
+
Eo as ds,
|
|
4428
|
+
vo as dt,
|
|
4429
|
+
Fo as du,
|
|
4430
|
+
Ro as dv,
|
|
4431
|
+
io as dw,
|
|
4432
|
+
Lo as dx,
|
|
4433
|
+
Go as dy,
|
|
4434
|
+
fe as dz,
|
|
4426
4435
|
si as e,
|
|
4427
4436
|
Jo as f,
|
|
4428
4437
|
ii as g,
|
|
4429
|
-
|
|
4438
|
+
os as h,
|
|
4430
4439
|
Yo as i,
|
|
4431
4440
|
z as j,
|
|
4432
|
-
|
|
4433
|
-
|
|
4441
|
+
Mn as k,
|
|
4442
|
+
is as l,
|
|
4434
4443
|
ri as m,
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4444
|
+
p as n,
|
|
4445
|
+
$ as o,
|
|
4446
|
+
Ce as p,
|
|
4447
|
+
k as q,
|
|
4439
4448
|
oi as r,
|
|
4440
4449
|
ai as s,
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4450
|
+
A as t,
|
|
4451
|
+
ge as u,
|
|
4452
|
+
ds as v,
|
|
4453
|
+
nt as w,
|
|
4445
4454
|
Qt as x,
|
|
4446
4455
|
wi as y,
|
|
4447
|
-
|
|
4456
|
+
Ps as z
|
|
4448
4457
|
};
|