@genai-fi/nanogpt 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Generator.js +11761 -171
- package/dist/{RealDiv-zz7FpkKX.js → RealDiv-KAPDe8zB.js} +23 -25
- package/dist/Reshape-BYkmUnAv.js +14 -0
- package/dist/{Reshape-CHdUjC72.js → Reshape-Zt6eb7yh.js} +18 -20
- package/dist/TeachableLLM.js +10 -11
- package/dist/{axis_util-BsIr9ZNu.js → axis_util-BaG7mf5A.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-B1XRLuq9.js → backend_util-RCe-rHaj.js} +72 -73
- package/dist/{backend_webgpu-CqpfEImu.js → backend_webgpu-DE3ACOLx.js} +45 -47
- package/dist/broadcast_to-B3eYlZm7.js +28 -0
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/matMulGelu.js +7 -11
- package/dist/checks/normRMS.js +9 -9
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.js +2 -2
- package/dist/checks/qkv.js +12 -13
- package/dist/checks/rope.js +2 -2
- package/dist/clip_by_value-BnO7-a88.js +12 -0
- package/dist/complex-DjxcVmoX.js +11 -0
- package/dist/concat-BV8bt5H-.js +17 -0
- package/dist/{concat_util-iBYIyuQe.js → concat_util-DpW8mL_l.js} +1 -1
- package/dist/{dataset-D2P7rHAw.js → dataset-BcwmTGYc.js} +137 -139
- package/dist/dropout-BcvN9JYi.js +92 -0
- package/dist/expand_dims-DT4tEPwA.js +11 -0
- package/dist/{exports_initializers-CZSUJoVE.js → exports_initializers-Hta_rEnm.js} +1 -1
- package/dist/floor-D5QdR_le.js +9 -0
- package/dist/gather-D3JcZUaI.js +9 -0
- package/dist/{gelu-Bmhopi0J.js → gelu-CjNPL4OH.js} +10 -11
- package/dist/{gpgpu_math-DsCcikas.js → gpgpu_math-DAOmgtXR.js} +841 -1015
- package/dist/{index-DRyE072i.js → index-BwexR4lA.js} +262 -263
- package/dist/index-DOvlwCh-.js +3520 -0
- package/dist/{kernel_funcs_utils-CWfOAPGO.js → kernel_funcs_utils-CCzYdUZg.js} +130 -132
- package/dist/layers/BaseLayer.js +15 -16
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +4 -4
- package/dist/layers/PositionEmbedding.js +7 -7
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +9 -9
- package/dist/layers/TiedEmbedding.js +6 -6
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +13 -14
- package/dist/log_sum_exp-ngO0-4pK.js +39 -0
- package/dist/main.js +49 -50
- package/dist/{matMul16-fEAJ4smh.js → matMul16-BWRSOCWB.js} +14 -15
- package/dist/matMulGelu-CzfgT6Wq.js +163 -0
- package/dist/mat_mul-SjpJRLyL.js +11 -0
- package/dist/mod-AnXEvvpo.js +11 -0
- package/dist/models/NanoGPTV1.js +2 -2
- package/dist/models/model.js +13 -14
- package/dist/ones-D2rT0xk2.js +14 -0
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/add16.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/concat16.js +2 -2
- package/dist/ops/cpu/adamAdjust.js +13 -14
- package/dist/ops/cpu/adamMoments.js +6 -7
- package/dist/ops/cpu/appendCache.js +7 -8
- package/dist/ops/cpu/attentionMask.js +7 -7
- package/dist/ops/cpu/fusedSoftmax.js +10 -11
- package/dist/ops/cpu/gatherSub.js +9 -10
- package/dist/ops/cpu/gelu.js +9 -10
- package/dist/ops/cpu/matMul16.js +6 -7
- package/dist/ops/cpu/matMulGelu.js +5 -6
- package/dist/ops/cpu/matMulMul.js +3 -4
- package/dist/ops/cpu/mulDropout.js +3 -4
- package/dist/ops/cpu/normRMS.js +10 -11
- package/dist/ops/cpu/qkv.js +8 -9
- package/dist/ops/cpu/rope.js +5 -6
- package/dist/ops/cpu/scatterSub.js +17 -19
- package/dist/ops/dot16.js +2 -2
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/add16.js +11 -12
- package/dist/ops/grads/attentionMask.js +5 -6
- package/dist/ops/grads/gelu.js +3 -4
- package/dist/ops/grads/matMul16.js +4 -5
- package/dist/ops/grads/matMulGelu.js +9 -10
- package/dist/ops/grads/normRMS.js +7 -8
- package/dist/ops/grads/pack16.js +4 -5
- package/dist/ops/grads/qkv.js +17 -19
- package/dist/ops/grads/rope.js +3 -5
- package/dist/ops/grads/softmax16.js +3 -4
- package/dist/ops/grads/unpack16.js +3 -4
- package/dist/ops/grads/utils.d.ts +1 -0
- package/dist/ops/grads/utils.js +8 -4
- package/dist/ops/matMul16.js +3 -3
- package/dist/ops/matMulGelu.js +2 -2
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mul16.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/pack16.js +3 -4
- package/dist/ops/qkv.js +4 -8
- package/dist/ops/reshape16.js +14 -16
- package/dist/ops/rope.d.ts +1 -1
- package/dist/ops/rope.js +3 -8
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.js +2 -2
- package/dist/ops/softmax16.js +5 -8
- package/dist/ops/sub16.js +1 -1
- package/dist/ops/sum16.js +2 -2
- package/dist/ops/transpose16.js +23 -24
- package/dist/ops/unpack16.js +2 -2
- package/dist/ops/webgl/adamAdjust.js +2 -3
- package/dist/ops/webgl/adamMoments.js +1 -2
- package/dist/ops/webgl/appendCache.js +1 -2
- package/dist/ops/webgl/attentionMask.js +4 -5
- package/dist/ops/webgl/fusedSoftmax.js +4 -6
- package/dist/ops/webgl/gatherSub.js +6 -7
- package/dist/ops/webgl/gelu.js +2 -3
- package/dist/ops/webgl/log.js +11 -12
- package/dist/ops/webgl/matMul16.js +10 -11
- package/dist/ops/webgl/matMulGelu.js +7 -111
- package/dist/ops/webgl/matMulMul.js +9 -10
- package/dist/ops/webgl/mulDropout.js +8 -9
- package/dist/ops/webgl/normRMS.js +2 -3
- package/dist/ops/webgl/qkv.js +5 -6
- package/dist/ops/webgl/rope.js +7 -8
- package/dist/ops/webgl/scatterSub.js +5 -6
- package/dist/ops/webgpu/adamAdjust.js +10 -12
- package/dist/ops/webgpu/adamMoments.js +8 -10
- package/dist/ops/webgpu/add16.js +8 -9
- package/dist/ops/webgpu/appendCache.js +23 -25
- package/dist/ops/webgpu/attentionMask.js +8 -10
- package/dist/ops/webgpu/attentionMask32_program.js +2 -2
- package/dist/ops/webgpu/concat16.js +12 -14
- package/dist/ops/webgpu/gatherSub.js +11 -13
- package/dist/ops/webgpu/gelu.js +28 -29
- package/dist/ops/webgpu/matMul16.js +26 -28
- package/dist/ops/webgpu/matMul16_program.js +4 -5
- package/dist/ops/webgpu/mul16.js +9 -10
- package/dist/ops/webgpu/normRMS.js +15 -17
- package/dist/ops/webgpu/normRMSGrad.js +21 -28
- package/dist/ops/webgpu/pack16.js +12 -13
- package/dist/ops/webgpu/pack16_program.js +2 -2
- package/dist/ops/webgpu/qkv.js +16 -18
- package/dist/ops/webgpu/rope.js +25 -27
- package/dist/ops/webgpu/scatterSub.js +7 -9
- package/dist/ops/webgpu/slice16.js +21 -23
- package/dist/ops/webgpu/softmax16.js +17 -19
- package/dist/ops/webgpu/softmax16_program.js +2 -2
- package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
- package/dist/ops/webgpu/softmax16grad.js +7 -8
- package/dist/ops/webgpu/sub16.js +7 -8
- package/dist/ops/webgpu/sum16.js +18 -20
- package/dist/ops/webgpu/transpose16.js +19 -20
- package/dist/ops/webgpu/transpose16_program.js +2 -2
- package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
- package/dist/ops/webgpu/unpack16.js +3 -4
- package/dist/ops/webgpu/utils/binary_op.js +7 -8
- package/dist/ops/webgpu/utils/reductions.js +14 -22
- package/dist/ops-B5yanEdW.js +476 -0
- package/dist/pack16-nQ6JaLo-.js +39 -0
- package/dist/patches/webgpu_backend.js +19 -20
- package/dist/patches/webgpu_base.js +1 -1
- package/dist/patches/webgpu_program.js +21 -22
- package/dist/{random_width-BVV9HveY.js → random_width-or-CEftb.js} +2506 -2761
- package/dist/range-BklejeeW.js +10 -0
- package/dist/relu-CP0ZcxWO.js +9 -0
- package/dist/reshape-ByE68wS9.js +9 -0
- package/dist/resize_nearest_neighbor-B19mCEg2.js +175 -0
- package/dist/rope-Ir4mTyD1.js +24 -0
- package/dist/{scatter_nd_util-C7zXRT_h.js → scatter_nd_util-lvSiX8q4.js} +1 -1
- package/dist/selu_util-kbhpTdYD.js +44 -0
- package/dist/{shared-CHhxz-O5.js → shared-DT1TkE6w.js} +1 -1
- package/dist/{shared-D2NP_CpY.js → shared-dntlHIDQ.js} +343 -345
- package/dist/slice-BfEGSH82.js +12 -0
- package/dist/{slice_util-DyjSAD0u.js → slice_util-uTKwiEpW.js} +1 -1
- package/dist/{softmax-C9JQEtnO.js → softmax-CA5jFsLR.js} +4 -5
- package/dist/split-CVLc0w--.js +9 -0
- package/dist/squeeze-C7Z2srUo.js +10 -0
- package/dist/stack-Cf4n9h0N.js +11 -0
- package/dist/step-CINUs5QB.js +261 -0
- package/dist/sum-DWAtNGez.js +11 -0
- package/dist/tensor-DJoc7gJU.js +8 -0
- package/dist/tensor1d-D11P_7Dp.js +11 -0
- package/dist/{tensor2d-CSB4KOb0.js → tensor2d-Bs9wZRc7.js} +6 -7
- package/dist/{tensor4d-D7bLqGqz.js → tensor4d-BARPdTaS.js} +6 -7
- package/dist/{tfjs_backend-CNkSTL0c.js → tfjs_backend-y1cvNhLA.js} +255 -264
- package/dist/tile-mbfagpsB.js +11 -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/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +2 -2
- package/dist/training/sparseCrossEntropy.js +5 -5
- package/dist/transpose-ClWiBS_b.js +36 -0
- package/dist/unsorted_segment_sum-BDDhB_E6.js +277 -0
- package/dist/utilities/dummy.js +3 -3
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.d.ts +1 -4
- package/dist/utilities/packed.js +10 -745
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/sentences.js +5 -5
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-DzfrwYuP.js → variable-WawDEaAb.js} +1 -1
- package/dist/{webgpu_program-DzaQiqel.js → webgpu_program-DuOXPQol.js} +178 -172
- package/dist/{webgpu_util-0_ubCEHJ.js → webgpu_util-RxEF33Rj.js} +34 -35
- package/dist/zeros-KnWaWf-X.js +13 -0
- package/dist/zeros_like-DvE73F4e.js +721 -0
- package/package.json +4 -2
- package/dist/Reshape-CDVLyVfz.js +0 -16
- package/dist/broadcast_to-B0ChcDaz.js +0 -30
- package/dist/complex-BBiRlsVq.js +0 -13
- package/dist/concat-DmBLPVGC.js +0 -19
- package/dist/dropout-B1x1kYMa.js +0 -99
- package/dist/expand_dims-ouvfxQ1n.js +0 -13
- package/dist/gather-CH9sdacz.js +0 -10
- package/dist/index-D6Q1lPZO.js +0 -2157
- package/dist/log_sum_exp-D3ftBNY5.js +0 -41
- package/dist/mat_mul-C59XWcJd.js +0 -12
- package/dist/mod-DESSvHIU.js +0 -12
- package/dist/mulmat_packed_gpu-Coh6qbJk.js +0 -55
- package/dist/ones-jU9jlQvM.js +0 -15
- package/dist/ops-BFDtP6th.js +0 -645
- package/dist/pack16-CmVZs6af.js +0 -41
- package/dist/patches/PackedTensor.d.ts +0 -12
- package/dist/patches/PackedTensor.js +0 -11
- package/dist/patches/engine.d.ts +0 -261
- package/dist/patches/engine.js +0 -12
- package/dist/patches/tape.d.ts +0 -12
- package/dist/patches/tape.js +0 -5
- package/dist/range-ZZZD60Fx.js +0 -11
- package/dist/reciprocal-CrYlsAGD.js +0 -10
- package/dist/register_all_kernels-nvj2k7OC.js +0 -12307
- package/dist/relu-BYDneVPn.js +0 -10
- package/dist/reshape-CaPQzFvz.js +0 -10
- package/dist/rope-s4W2XO9B.js +0 -32
- package/dist/selu_util-BGPXmd4B.js +0 -303
- package/dist/sin-Djs4aQiu.js +0 -16
- package/dist/slice-DvovR5wq.js +0 -13
- package/dist/split-DBck65sX.js +0 -10
- package/dist/squeeze-C00Ipm_7.js +0 -11
- package/dist/stack-ChnHwRpX.js +0 -13
- package/dist/sum-ywRJj3Zr.js +0 -12
- package/dist/tensor-0r5yOo2R.js +0 -8
- package/dist/tensor-CzmOBsdf.js +0 -909
- package/dist/tensor1d-BlUT89BP.js +0 -12
- package/dist/tensor_util-DfwaWayG.js +0 -523
- package/dist/tile-CR074jmp.js +0 -13
- package/dist/transpose-DH4gmHvu.js +0 -38
- package/dist/zeros-DBFVbpv5.js +0 -14
|
@@ -1,84 +1,82 @@
|
|
|
1
|
-
import { d as v, t as y } from "./index-
|
|
2
|
-
import { s as
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _(r, t) {
|
|
8
|
-
return b(r, t);
|
|
1
|
+
import { aC as S, a8 as h, j as N, d as v, aD as o, aE as p, aF as g, l as k, t as y } from "./index-DOvlwCh-.js";
|
|
2
|
+
import { s as R } from "./index-CieiGp4Y.js";
|
|
3
|
+
import { s as $ } from "./stack-Cf4n9h0N.js";
|
|
4
|
+
import { t as B } from "./tensor-DJoc7gJU.js";
|
|
5
|
+
function _(s, t) {
|
|
6
|
+
return b(s, t);
|
|
9
7
|
}
|
|
10
|
-
function b(
|
|
11
|
-
if (
|
|
8
|
+
function b(s, t, e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set()) {
|
|
9
|
+
if (s == null)
|
|
12
10
|
return null;
|
|
13
|
-
if (typeof Blob == "function" &&
|
|
14
|
-
return
|
|
15
|
-
if (
|
|
11
|
+
if (typeof Blob == "function" && s instanceof Blob)
|
|
12
|
+
return s.slice();
|
|
13
|
+
if (r.has(s))
|
|
16
14
|
throw new Error("Circular references are not supported.");
|
|
17
|
-
if (e.has(
|
|
18
|
-
return e.get(
|
|
19
|
-
const n = t(
|
|
15
|
+
if (e.has(s))
|
|
16
|
+
return e.get(s);
|
|
17
|
+
const n = t(s);
|
|
20
18
|
if (n.recurse && n.value !== null)
|
|
21
19
|
throw new Error("A deep map function may not return both a value and recurse=true.");
|
|
22
20
|
if (n.recurse)
|
|
23
|
-
if (c(
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
for (const l in
|
|
27
|
-
const
|
|
28
|
-
|
|
21
|
+
if (c(s)) {
|
|
22
|
+
const a = Array.isArray(s) ? [] : {};
|
|
23
|
+
r.add(s);
|
|
24
|
+
for (const l in s) {
|
|
25
|
+
const d = s[l], m = b(d, t, e, r);
|
|
26
|
+
a[l] = m;
|
|
29
27
|
}
|
|
30
|
-
return
|
|
28
|
+
return r.delete(s), s.__proto__ && (a.__proto__ = s.__proto__), a;
|
|
31
29
|
} else
|
|
32
|
-
throw new Error(`Can't recurse into non-iterable type: ${
|
|
33
|
-
else return e.set(
|
|
30
|
+
throw new Error(`Can't recurse into non-iterable type: ${s}`);
|
|
31
|
+
else return e.set(s, n.value), n.value;
|
|
34
32
|
}
|
|
35
|
-
function P(
|
|
36
|
-
return E(
|
|
33
|
+
function P(s, t = I) {
|
|
34
|
+
return E(s, t);
|
|
37
35
|
}
|
|
38
|
-
function E(
|
|
39
|
-
const
|
|
40
|
-
if (e.has(
|
|
36
|
+
function E(s, t, e = /* @__PURE__ */ new Set()) {
|
|
37
|
+
const r = s[0];
|
|
38
|
+
if (e.has(r))
|
|
41
39
|
throw new Error("Circular references are not supported.");
|
|
42
|
-
const n = t(
|
|
40
|
+
const n = t(s);
|
|
43
41
|
if (n.recurse && n.value !== null)
|
|
44
42
|
throw new Error("A deep zip function may not return both a value and recurse=true.");
|
|
45
43
|
if (n.recurse)
|
|
46
|
-
if (c(
|
|
47
|
-
const
|
|
48
|
-
e.add(
|
|
49
|
-
for (const l in
|
|
50
|
-
const
|
|
51
|
-
|
|
44
|
+
if (c(r)) {
|
|
45
|
+
const a = Array.isArray(r) ? [] : {};
|
|
46
|
+
e.add(r);
|
|
47
|
+
for (const l in r) {
|
|
48
|
+
const d = s.map((T) => T[l]), m = E(d, t, e);
|
|
49
|
+
a[l] = m;
|
|
52
50
|
}
|
|
53
|
-
return e.delete(
|
|
51
|
+
return e.delete(r), a;
|
|
54
52
|
} else
|
|
55
|
-
throw new Error(`Can't recurse into non-iterable type: ${
|
|
53
|
+
throw new Error(`Can't recurse into non-iterable type: ${r}`);
|
|
56
54
|
else return n.value;
|
|
57
55
|
}
|
|
58
|
-
function I(
|
|
59
|
-
return
|
|
56
|
+
function I(s) {
|
|
57
|
+
return s === null ? null : c(s[0]) ? { value: null, recurse: !0 } : { value: s, recurse: !1 };
|
|
60
58
|
}
|
|
61
|
-
function c(
|
|
59
|
+
function c(s) {
|
|
62
60
|
let t = !1;
|
|
63
61
|
if (N().get("IS_BROWSER"))
|
|
64
|
-
t =
|
|
62
|
+
t = s instanceof TextDecoder;
|
|
65
63
|
else {
|
|
66
64
|
const { StringDecoder: e } = require("string_decoder");
|
|
67
|
-
t =
|
|
65
|
+
t = s instanceof e;
|
|
68
66
|
}
|
|
69
|
-
return
|
|
67
|
+
return s != null && !ArrayBuffer.isView(s) && (Array.isArray(s) || typeof s == "object" && !(s instanceof h) && !(s instanceof Promise) && !t);
|
|
70
68
|
}
|
|
71
|
-
function M(
|
|
72
|
-
return
|
|
69
|
+
function M(s) {
|
|
70
|
+
return s == null || L(s) || Array.isArray(s) || typeof s == "object" && s instanceof h || S(s);
|
|
73
71
|
}
|
|
74
|
-
function L(
|
|
75
|
-
return
|
|
72
|
+
function L(s) {
|
|
73
|
+
return s === null || typeof s != "object" && typeof s != "function";
|
|
76
74
|
}
|
|
77
|
-
function D(
|
|
78
|
-
return _(
|
|
75
|
+
function D(s) {
|
|
76
|
+
return _(s, O);
|
|
79
77
|
}
|
|
80
|
-
function O(
|
|
81
|
-
return
|
|
78
|
+
function O(s) {
|
|
79
|
+
return s instanceof h ? { value: s.clone(), recurse: !1 } : c(s) ? { value: null, recurse: !0 } : { value: s, recurse: !1 };
|
|
82
80
|
}
|
|
83
81
|
class z {
|
|
84
82
|
/**
|
|
@@ -187,8 +185,8 @@ class z {
|
|
|
187
185
|
shuffleExcise(t) {
|
|
188
186
|
if (this.isEmpty())
|
|
189
187
|
throw new RangeError("Ring buffer is empty.");
|
|
190
|
-
const e = this.wrap(this.begin + t),
|
|
191
|
-
return this.set(e, this.pop()),
|
|
188
|
+
const e = this.wrap(this.begin + t), r = this.get(e);
|
|
189
|
+
return this.set(e, this.pop()), r;
|
|
192
190
|
}
|
|
193
191
|
}
|
|
194
192
|
class f extends z {
|
|
@@ -211,23 +209,23 @@ class f extends z {
|
|
|
211
209
|
* Doubles the capacity of the buffer.
|
|
212
210
|
*/
|
|
213
211
|
expand() {
|
|
214
|
-
const t = this.capacity * 2, e = new Array(t),
|
|
215
|
-
for (let n = 0; n <
|
|
212
|
+
const t = this.capacity * 2, e = new Array(t), r = this.length();
|
|
213
|
+
for (let n = 0; n < r; n++)
|
|
216
214
|
e[n] = this.get(this.wrap(this.begin + n));
|
|
217
|
-
this.data = e, this.capacity = t, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end =
|
|
215
|
+
this.data = e, this.capacity = t, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = r;
|
|
218
216
|
}
|
|
219
217
|
}
|
|
220
218
|
f.INITIAL_CAPACITY = 32;
|
|
221
|
-
function H(
|
|
222
|
-
return new G(
|
|
219
|
+
function H(s) {
|
|
220
|
+
return new G(s);
|
|
223
221
|
}
|
|
224
|
-
function q(
|
|
225
|
-
return new W(
|
|
222
|
+
function q(s) {
|
|
223
|
+
return new W(s);
|
|
226
224
|
}
|
|
227
|
-
function Q(
|
|
228
|
-
return new A(
|
|
225
|
+
function Q(s, t) {
|
|
226
|
+
return new A(s, t);
|
|
229
227
|
}
|
|
230
|
-
class
|
|
228
|
+
class i {
|
|
231
229
|
/**
|
|
232
230
|
* Collect all remaining elements of a bounded stream into an array.
|
|
233
231
|
* Obviously this will succeed only for small streams that fit in memory.
|
|
@@ -256,9 +254,9 @@ class a {
|
|
|
256
254
|
*/
|
|
257
255
|
async toArrayForTest() {
|
|
258
256
|
const t = this.prefetch(100), e = [];
|
|
259
|
-
let
|
|
260
|
-
for (; !
|
|
261
|
-
e.push(
|
|
257
|
+
let r = await t.next();
|
|
258
|
+
for (; !r.done; )
|
|
259
|
+
e.push(r.value), r = await t.next();
|
|
262
260
|
return e;
|
|
263
261
|
}
|
|
264
262
|
/**
|
|
@@ -281,9 +279,9 @@ class a {
|
|
|
281
279
|
* fully processed.
|
|
282
280
|
*/
|
|
283
281
|
async resolveWhile(t) {
|
|
284
|
-
let e = await this.next(),
|
|
285
|
-
for (; !e.done &&
|
|
286
|
-
e = await this.next(),
|
|
282
|
+
let e = await this.next(), r = t(e.value);
|
|
283
|
+
for (; !e.done && r; )
|
|
284
|
+
e = await this.next(), r = t(e.value);
|
|
287
285
|
}
|
|
288
286
|
/**
|
|
289
287
|
* Handles errors thrown on this stream using a provided handler function.
|
|
@@ -298,7 +296,7 @@ class a {
|
|
|
298
296
|
* throw an `Error`.
|
|
299
297
|
*/
|
|
300
298
|
handleErrors(t) {
|
|
301
|
-
return new
|
|
299
|
+
return new j(this, t);
|
|
302
300
|
}
|
|
303
301
|
// TODO(soergel): Implement reduce() etc.
|
|
304
302
|
/**
|
|
@@ -427,8 +425,8 @@ class a {
|
|
|
427
425
|
* @returns A `LazyIterator` of batches of elements, represented as an object
|
|
428
426
|
* with collections at the leaves.
|
|
429
427
|
*/
|
|
430
|
-
columnMajorBatch(t, e = !0,
|
|
431
|
-
return this.rowMajorBatch(t, e).map((
|
|
428
|
+
columnMajorBatch(t, e = !0, r = I) {
|
|
429
|
+
return this.rowMajorBatch(t, e).map((a) => P(a, r));
|
|
432
430
|
}
|
|
433
431
|
/**
|
|
434
432
|
* Concatenate this `LazyIterator` with another.
|
|
@@ -494,7 +492,7 @@ class a {
|
|
|
494
492
|
return new U(this);
|
|
495
493
|
}
|
|
496
494
|
}
|
|
497
|
-
class G extends
|
|
495
|
+
class G extends i {
|
|
498
496
|
constructor(t) {
|
|
499
497
|
super(), this.items = t, this.trav = 0;
|
|
500
498
|
}
|
|
@@ -508,7 +506,7 @@ class G extends a {
|
|
|
508
506
|
return this.trav++, { value: D(t), done: !1 };
|
|
509
507
|
}
|
|
510
508
|
}
|
|
511
|
-
class W extends
|
|
509
|
+
class W extends i {
|
|
512
510
|
constructor(t) {
|
|
513
511
|
super(), this.nextFn = t;
|
|
514
512
|
}
|
|
@@ -523,7 +521,7 @@ class W extends a {
|
|
|
523
521
|
}
|
|
524
522
|
}
|
|
525
523
|
}
|
|
526
|
-
class U extends
|
|
524
|
+
class U extends i {
|
|
527
525
|
constructor(t) {
|
|
528
526
|
super(), this.upstream = t, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
529
527
|
}
|
|
@@ -537,7 +535,7 @@ class U extends a {
|
|
|
537
535
|
return this.upstream.next();
|
|
538
536
|
}
|
|
539
537
|
}
|
|
540
|
-
class Y extends
|
|
538
|
+
class Y extends i {
|
|
541
539
|
constructor(t, e) {
|
|
542
540
|
super(), this.upstream = t, this.maxCount = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
543
541
|
}
|
|
@@ -557,7 +555,7 @@ class Y extends a {
|
|
|
557
555
|
return this.upstream.next();
|
|
558
556
|
}
|
|
559
557
|
}
|
|
560
|
-
class J extends
|
|
558
|
+
class J extends i {
|
|
561
559
|
constructor(t, e) {
|
|
562
560
|
super(), this.upstream = t, this.maxCount = e, this.count = 0;
|
|
563
561
|
}
|
|
@@ -568,9 +566,9 @@ class J extends a {
|
|
|
568
566
|
return this.count++ >= this.maxCount ? { value: null, done: !0 } : this.upstream.next();
|
|
569
567
|
}
|
|
570
568
|
}
|
|
571
|
-
class V extends
|
|
572
|
-
constructor(t, e,
|
|
573
|
-
super(), this.upstream = t, this.batchSize = e, this.enableSmallLastBatch =
|
|
569
|
+
class V extends i {
|
|
570
|
+
constructor(t, e, r = !0) {
|
|
571
|
+
super(), this.upstream = t, this.batchSize = e, this.enableSmallLastBatch = r, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
574
572
|
}
|
|
575
573
|
summary() {
|
|
576
574
|
return `${this.upstream.summary()} -> RowMajorBatch`;
|
|
@@ -589,7 +587,7 @@ class V extends a {
|
|
|
589
587
|
return { value: t, done: !1 };
|
|
590
588
|
}
|
|
591
589
|
}
|
|
592
|
-
class X extends
|
|
590
|
+
class X extends i {
|
|
593
591
|
constructor(t, e) {
|
|
594
592
|
super(), this.upstream = t, this.predicate = e, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
595
593
|
}
|
|
@@ -608,7 +606,7 @@ class X extends a {
|
|
|
608
606
|
}
|
|
609
607
|
}
|
|
610
608
|
}
|
|
611
|
-
class K extends
|
|
609
|
+
class K extends i {
|
|
612
610
|
constructor(t, e) {
|
|
613
611
|
super(), this.upstream = t, this.transform = e;
|
|
614
612
|
}
|
|
@@ -619,13 +617,13 @@ class K extends a {
|
|
|
619
617
|
const t = await this.upstream.next();
|
|
620
618
|
if (t.done)
|
|
621
619
|
return { value: null, done: !0 };
|
|
622
|
-
const e = o(t.value),
|
|
623
|
-
for (const
|
|
624
|
-
p(
|
|
625
|
-
return { value:
|
|
620
|
+
const e = o(t.value), r = this.transform(t.value), n = o(r);
|
|
621
|
+
for (const a of e)
|
|
622
|
+
p(a, n) || a.dispose();
|
|
623
|
+
return { value: r, done: !1 };
|
|
626
624
|
}
|
|
627
625
|
}
|
|
628
|
-
class
|
|
626
|
+
class j extends i {
|
|
629
627
|
constructor(t, e) {
|
|
630
628
|
super(), this.upstream = t, this.handler = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
631
629
|
}
|
|
@@ -645,7 +643,7 @@ class Z extends a {
|
|
|
645
643
|
}
|
|
646
644
|
}
|
|
647
645
|
}
|
|
648
|
-
class w extends
|
|
646
|
+
class w extends i {
|
|
649
647
|
constructor(t, e) {
|
|
650
648
|
super(), this.upstream = t, this.transform = e;
|
|
651
649
|
}
|
|
@@ -656,13 +654,13 @@ class w extends a {
|
|
|
656
654
|
const t = await this.upstream.next();
|
|
657
655
|
if (t.done)
|
|
658
656
|
return { value: null, done: !0 };
|
|
659
|
-
const e = o(t.value),
|
|
660
|
-
for (const
|
|
661
|
-
p(
|
|
662
|
-
return { value:
|
|
657
|
+
const e = o(t.value), r = await this.transform(t.value), n = o(r);
|
|
658
|
+
for (const a of e)
|
|
659
|
+
p(a, n) || a.dispose();
|
|
660
|
+
return { value: r, done: !1 };
|
|
663
661
|
}
|
|
664
662
|
}
|
|
665
|
-
class
|
|
663
|
+
class Z extends i {
|
|
666
664
|
constructor() {
|
|
667
665
|
super(), this.outputQueue = new f(), this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
668
666
|
}
|
|
@@ -676,7 +674,7 @@ class j extends a {
|
|
|
676
674
|
return { value: this.outputQueue.shift(), done: !1 };
|
|
677
675
|
}
|
|
678
676
|
}
|
|
679
|
-
class tt extends
|
|
677
|
+
class tt extends Z {
|
|
680
678
|
constructor(t, e) {
|
|
681
679
|
super(), this.upstream = t, this.transform = e;
|
|
682
680
|
}
|
|
@@ -687,14 +685,14 @@ class tt extends j {
|
|
|
687
685
|
const t = await this.upstream.next();
|
|
688
686
|
if (t.done)
|
|
689
687
|
return !1;
|
|
690
|
-
const e = o(t.value),
|
|
691
|
-
this.outputQueue.pushAll(
|
|
692
|
-
for (const
|
|
693
|
-
p(
|
|
688
|
+
const e = o(t.value), r = this.transform(t.value), n = o(r);
|
|
689
|
+
this.outputQueue.pushAll(r);
|
|
690
|
+
for (const a of e)
|
|
691
|
+
p(a, n) || a.dispose();
|
|
694
692
|
return !0;
|
|
695
693
|
}
|
|
696
694
|
}
|
|
697
|
-
class A extends
|
|
695
|
+
class A extends i {
|
|
698
696
|
constructor(t, e) {
|
|
699
697
|
super(), this.baseErrorHandler = e, this.lastRead = null, this.iterator = null, this.moreIterators = t;
|
|
700
698
|
}
|
|
@@ -706,20 +704,20 @@ class A extends a {
|
|
|
706
704
|
}
|
|
707
705
|
async readFromChain(t) {
|
|
708
706
|
if (await t, this.iterator == null) {
|
|
709
|
-
const
|
|
710
|
-
if (
|
|
707
|
+
const r = await this.moreIterators.next();
|
|
708
|
+
if (r.done)
|
|
711
709
|
return { value: null, done: !0 };
|
|
712
|
-
this.iterator =
|
|
710
|
+
this.iterator = r.value, this.baseErrorHandler != null && (this.iterator = this.iterator.handleErrors(this.baseErrorHandler));
|
|
713
711
|
}
|
|
714
712
|
const e = await this.iterator.next();
|
|
715
713
|
return e.done ? (this.iterator = null, this.readFromChain(t)) : e;
|
|
716
714
|
}
|
|
717
715
|
}
|
|
718
716
|
var x;
|
|
719
|
-
(function(
|
|
720
|
-
|
|
717
|
+
(function(s) {
|
|
718
|
+
s[s.FAIL = 0] = "FAIL", s[s.SHORTEST = 1] = "SHORTEST", s[s.LONGEST = 2] = "LONGEST";
|
|
721
719
|
})(x || (x = {}));
|
|
722
|
-
class C extends
|
|
720
|
+
class C extends i {
|
|
723
721
|
constructor(t, e) {
|
|
724
722
|
super(), this.upstream = t, this.bufferSize = e, this.buffer = new z(e);
|
|
725
723
|
}
|
|
@@ -741,8 +739,8 @@ class C extends a {
|
|
|
741
739
|
}
|
|
742
740
|
}
|
|
743
741
|
class et extends C {
|
|
744
|
-
constructor(t, e,
|
|
745
|
-
super(t, e), this.upstream = t, this.windowSize = e, this.upstreamExhausted = !1, this.random =
|
|
742
|
+
constructor(t, e, r) {
|
|
743
|
+
super(t, e), this.upstream = t, this.windowSize = e, this.upstreamExhausted = !1, this.random = R.alea(r || g().toString()), this.lastRead = Promise.resolve({ value: null, done: !1 });
|
|
746
744
|
}
|
|
747
745
|
async next() {
|
|
748
746
|
return this.lastRead = this.lastRead.then(() => this.serialNext()), this.lastRead;
|
|
@@ -764,7 +762,7 @@ class et extends C {
|
|
|
764
762
|
return { value: null, done: !0 };
|
|
765
763
|
}
|
|
766
764
|
}
|
|
767
|
-
class
|
|
765
|
+
class F {
|
|
768
766
|
constructor() {
|
|
769
767
|
this.size = null;
|
|
770
768
|
}
|
|
@@ -829,11 +827,11 @@ class T {
|
|
|
829
827
|
* @doc {heading: 'Data', subheading: 'Classes'}
|
|
830
828
|
*/
|
|
831
829
|
batch(t, e = !0) {
|
|
832
|
-
const
|
|
830
|
+
const r = this;
|
|
833
831
|
k(t > 0, () => `batchSize needs to be positive, but it is
|
|
834
832
|
${t}`);
|
|
835
833
|
let n;
|
|
836
|
-
return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await
|
|
834
|
+
return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await r.iterator()).columnMajorBatch(t, e, st), n);
|
|
837
835
|
}
|
|
838
836
|
/**
|
|
839
837
|
* Concatenates this `Dataset` with another.
|
|
@@ -852,8 +850,8 @@ class T {
|
|
|
852
850
|
*/
|
|
853
851
|
concatenate(t) {
|
|
854
852
|
const e = this;
|
|
855
|
-
let
|
|
856
|
-
return this.size === 1 / 0 || t.size === 1 / 0 ?
|
|
853
|
+
let r;
|
|
854
|
+
return this.size === 1 / 0 || t.size === 1 / 0 ? r = 1 / 0 : this.size != null && t.size != null ? r = this.size + t.size : r = null, u(async () => (await e.iterator()).concatenate(await t.iterator()), r);
|
|
857
855
|
}
|
|
858
856
|
/**
|
|
859
857
|
* Filters this dataset according to `predicate`.
|
|
@@ -873,8 +871,8 @@ class T {
|
|
|
873
871
|
*/
|
|
874
872
|
filter(t) {
|
|
875
873
|
const e = this;
|
|
876
|
-
let
|
|
877
|
-
return this.size === 1 / 0 ?
|
|
874
|
+
let r;
|
|
875
|
+
return this.size === 1 / 0 ? r = 1 / 0 : r = null, u(async () => (await e.iterator()).filter((n) => y(() => t(n))), r);
|
|
878
876
|
}
|
|
879
877
|
/**
|
|
880
878
|
* Apply a function to every element of the dataset.
|
|
@@ -912,7 +910,7 @@ class T {
|
|
|
912
910
|
*/
|
|
913
911
|
map(t) {
|
|
914
912
|
const e = this;
|
|
915
|
-
return u(async () => (await e.iterator()).map((
|
|
913
|
+
return u(async () => (await e.iterator()).map((r) => y(() => t(r))), this.size);
|
|
916
914
|
}
|
|
917
915
|
/**
|
|
918
916
|
* Maps this dataset through an async 1-to-1 transform.
|
|
@@ -976,11 +974,11 @@ class T {
|
|
|
976
974
|
*/
|
|
977
975
|
repeat(t) {
|
|
978
976
|
const e = this;
|
|
979
|
-
let
|
|
980
|
-
return this.size != null && t > 0 ?
|
|
977
|
+
let r;
|
|
978
|
+
return this.size != null && t > 0 ? r = this.size * t : t === 0 ? r = 0 : this.size != null && (t === void 0 || t < 0) ? r = 1 / 0 : r = null, u(async () => {
|
|
981
979
|
const n = q(async () => ({ value: await e.iterator(), done: !1 }));
|
|
982
980
|
return Q(n.take(t));
|
|
983
|
-
},
|
|
981
|
+
}, r);
|
|
984
982
|
}
|
|
985
983
|
/**
|
|
986
984
|
* Creates a `Dataset` that skips `count` initial elements from this dataset.
|
|
@@ -1001,8 +999,8 @@ class T {
|
|
|
1001
999
|
*/
|
|
1002
1000
|
skip(t) {
|
|
1003
1001
|
const e = this;
|
|
1004
|
-
let
|
|
1005
|
-
return this.size != null && t >= 0 && this.size >= t ?
|
|
1002
|
+
let r;
|
|
1003
|
+
return this.size != null && t >= 0 && this.size >= t ? r = this.size - t : this.size != null && (this.size < t || t === void 0 || t < 0) ? r = 0 : r = null, u(async () => (await e.iterator()).skip(t), r);
|
|
1006
1004
|
}
|
|
1007
1005
|
/**
|
|
1008
1006
|
* Pseudorandomly shuffles the elements of this dataset. This is done in a
|
|
@@ -1025,13 +1023,13 @@ class T {
|
|
|
1025
1023
|
*
|
|
1026
1024
|
* @doc {heading: 'Data', subheading: 'Classes'}
|
|
1027
1025
|
*/
|
|
1028
|
-
shuffle(t, e,
|
|
1026
|
+
shuffle(t, e, r = !0) {
|
|
1029
1027
|
if (t == null || t < 0)
|
|
1030
1028
|
throw this.size == null ? new RangeError("`Dataset.shuffle()` requires bufferSize to be specified.") : new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);
|
|
1031
|
-
const n = this,
|
|
1029
|
+
const n = this, a = R.alea(e || g().toString());
|
|
1032
1030
|
return u(async () => {
|
|
1033
|
-
let l =
|
|
1034
|
-
return
|
|
1031
|
+
let l = a.int32();
|
|
1032
|
+
return r && (l += a.int32()), (await n.iterator()).shuffle(t, l.toString());
|
|
1035
1033
|
}, this.size);
|
|
1036
1034
|
}
|
|
1037
1035
|
/**
|
|
@@ -1053,8 +1051,8 @@ class T {
|
|
|
1053
1051
|
*/
|
|
1054
1052
|
take(t) {
|
|
1055
1053
|
const e = this;
|
|
1056
|
-
let
|
|
1057
|
-
return this.size != null && this.size > t ?
|
|
1054
|
+
let r;
|
|
1055
|
+
return this.size != null && this.size > t ? r = t : this.size != null && this.size <= t ? r = this.size : r = null, u(async () => (await e.iterator()).take(t), r);
|
|
1058
1056
|
}
|
|
1059
1057
|
/**
|
|
1060
1058
|
* Collect all elements of this dataset into an array.
|
|
@@ -1094,9 +1092,9 @@ class T {
|
|
|
1094
1092
|
return (await this.iterator()).toArrayForTest();
|
|
1095
1093
|
}
|
|
1096
1094
|
}
|
|
1097
|
-
|
|
1098
|
-
function u(
|
|
1099
|
-
return new class extends
|
|
1095
|
+
F.MAX_BUFFER_SIZE = 1e4;
|
|
1096
|
+
function u(s, t = null) {
|
|
1097
|
+
return new class extends F {
|
|
1100
1098
|
constructor() {
|
|
1101
1099
|
super(...arguments), this.size = t;
|
|
1102
1100
|
}
|
|
@@ -1105,20 +1103,20 @@ function u(r, t = null) {
|
|
|
1105
1103
|
* from any underlying `Dataset`s.
|
|
1106
1104
|
*/
|
|
1107
1105
|
async iterator() {
|
|
1108
|
-
return
|
|
1106
|
+
return s();
|
|
1109
1107
|
}
|
|
1110
1108
|
}();
|
|
1111
1109
|
}
|
|
1112
|
-
function
|
|
1113
|
-
if (
|
|
1110
|
+
function st(s) {
|
|
1111
|
+
if (s === null)
|
|
1114
1112
|
return null;
|
|
1115
|
-
const t =
|
|
1116
|
-
return M(t) ? { value:
|
|
1113
|
+
const t = s[0];
|
|
1114
|
+
return M(t) ? { value: rt(s), recurse: !1 } : { value: null, recurse: !0 };
|
|
1117
1115
|
}
|
|
1118
|
-
function
|
|
1119
|
-
if (
|
|
1116
|
+
function rt(s) {
|
|
1117
|
+
if (s.length === 0)
|
|
1120
1118
|
throw new Error("Can't make a batch of zero elements.");
|
|
1121
|
-
return
|
|
1119
|
+
return s[0] instanceof h ? $(s) : B(s);
|
|
1122
1120
|
}
|
|
1123
1121
|
export {
|
|
1124
1122
|
u as d,
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { A as l, C as h, at as d, n as f, B as m, l as u, a8 as p, w as g, x as V, m as v } from "./index-DOvlwCh-.js";
|
|
2
|
+
import { f as w } from "./floor-D5QdR_le.js";
|
|
3
|
+
import { s as c } from "./index-CieiGp4Y.js";
|
|
4
|
+
class N {
|
|
5
|
+
constructor(t, e, s, n, o) {
|
|
6
|
+
this.mean = t, this.stdDev = e, this.dtype = s, this.nextVal = NaN, this.truncated = n, this.truncated && (this.upper = this.mean + this.stdDev * 2, this.lower = this.mean - this.stdDev * 2);
|
|
7
|
+
const a = o || Math.random();
|
|
8
|
+
this.random = c.alea(a.toString());
|
|
9
|
+
}
|
|
10
|
+
/** Returns next sample from a Gaussian distribution. */
|
|
11
|
+
nextValue() {
|
|
12
|
+
if (!isNaN(this.nextVal)) {
|
|
13
|
+
const n = this.nextVal;
|
|
14
|
+
return this.nextVal = NaN, n;
|
|
15
|
+
}
|
|
16
|
+
let t, e, s = !1;
|
|
17
|
+
for (; !s; ) {
|
|
18
|
+
let n, o, a;
|
|
19
|
+
do
|
|
20
|
+
n = 2 * this.random() - 1, o = 2 * this.random() - 1, a = n * n + o * o;
|
|
21
|
+
while (a >= 1 || a === 0);
|
|
22
|
+
const i = Math.sqrt(-2 * Math.log(a) / a);
|
|
23
|
+
t = this.mean + this.stdDev * n * i, e = this.mean + this.stdDev * o * i, (!this.truncated || this.isValidTruncated(t)) && (s = !0);
|
|
24
|
+
}
|
|
25
|
+
return (!this.truncated || this.isValidTruncated(e)) && (this.nextVal = this.convertValue(e)), this.convertValue(t);
|
|
26
|
+
}
|
|
27
|
+
/** Handles proper rounding for non-floating-point numbers. */
|
|
28
|
+
convertValue(t) {
|
|
29
|
+
return this.dtype == null || this.dtype === "float32" ? t : Math.round(t);
|
|
30
|
+
}
|
|
31
|
+
/** Returns true if less than 2-standard-deviations from the mean. */
|
|
32
|
+
isValidTruncated(t) {
|
|
33
|
+
return t <= this.upper && t >= this.lower;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class b {
|
|
37
|
+
constructor(t = 0, e = 1, s, n) {
|
|
38
|
+
if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = t, this.range = e - t, this.dtype = s, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
|
|
39
|
+
throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);
|
|
40
|
+
this.random = c.alea(n);
|
|
41
|
+
}
|
|
42
|
+
convertValue(t) {
|
|
43
|
+
return this.canReturnFloat() ? t : Math.round(t);
|
|
44
|
+
}
|
|
45
|
+
nextValue() {
|
|
46
|
+
return this.convertValue(this.min + this.range * this.random());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function T(r, t = 0, e = 1, s, n) {
|
|
50
|
+
if (h(r), s != null && s === "bool")
|
|
51
|
+
throw new Error(`Unsupported data type ${s}`);
|
|
52
|
+
const o = new N(t, e, s, !1, n), a = d(r, s);
|
|
53
|
+
for (let i = 0; i < a.values.length; i++)
|
|
54
|
+
a.values[i] = o.nextValue();
|
|
55
|
+
return a.toTensor();
|
|
56
|
+
}
|
|
57
|
+
const U = /* @__PURE__ */ l({ randomNormal_: T });
|
|
58
|
+
function x(r, t = 0, e = 1, s = "float32", n) {
|
|
59
|
+
h(r);
|
|
60
|
+
const o = d(r, s), a = new b(t, e, null, n);
|
|
61
|
+
for (let i = 0; i < o.values.length; i++)
|
|
62
|
+
o.values[i] = a.nextValue();
|
|
63
|
+
return o.toTensor();
|
|
64
|
+
}
|
|
65
|
+
const y = /* @__PURE__ */ l({ randomUniform_: x });
|
|
66
|
+
function M(r, t) {
|
|
67
|
+
if (t == null)
|
|
68
|
+
return r.shape.slice();
|
|
69
|
+
if (f(r.shape, t))
|
|
70
|
+
return t;
|
|
71
|
+
if (r.shape.length === t.length) {
|
|
72
|
+
const e = [];
|
|
73
|
+
for (let s = 0; s < r.shape.length; s++)
|
|
74
|
+
t[s] == null && r.shape[s] != null ? e.push(r.shape[s]) : e.push(t[s]);
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
79
|
+
function D(r, t, e, s) {
|
|
80
|
+
const n = m(r, "x", "dropout");
|
|
81
|
+
if (u(n.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${n.dtype} tensor instead.`), u(t >= 0 && t < 1, () => `rate must be a float in the range [0, 1), but got ${t}.`), t === 0)
|
|
82
|
+
return r instanceof p ? n.clone() : n;
|
|
83
|
+
const o = M(n, e), a = 1 - t, i = g(w(V(y(o, 0, 1, "float32", s), a)), a);
|
|
84
|
+
return v(n, i);
|
|
85
|
+
}
|
|
86
|
+
const F = /* @__PURE__ */ l({ dropout_: D });
|
|
87
|
+
export {
|
|
88
|
+
N as M,
|
|
89
|
+
y as a,
|
|
90
|
+
F as d,
|
|
91
|
+
U as r
|
|
92
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { A as o, B as a, l as i, E as m, I as p } from "./index-DOvlwCh-.js";
|
|
2
|
+
function c(t, n = 0) {
|
|
3
|
+
const s = a(t, "x", "expandDims", "string_or_numeric");
|
|
4
|
+
i(n <= s.rank, () => "Axis must be <= rank of the tensor");
|
|
5
|
+
const r = { input: s }, e = { dim: n };
|
|
6
|
+
return m.runKernel(p, r, e);
|
|
7
|
+
}
|
|
8
|
+
const x = /* @__PURE__ */ o({ expandDims_: c });
|
|
9
|
+
export {
|
|
10
|
+
x as e
|
|
11
|
+
};
|