@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genai-fi/nanogpt",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"test": "vitest",
|
|
24
24
|
"test:gl": "playwright test",
|
|
25
25
|
"ci:test": "vitest --coverage --reporter=junit --outputFile=junit.xml",
|
|
26
|
-
"coverage": "vitest run --coverage"
|
|
26
|
+
"coverage": "vitest run --coverage",
|
|
27
|
+
"postinstall": "patch-package"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@eslint/js": "^9.32.0",
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
"eventemitter3": "^5.0.1",
|
|
55
56
|
"jszip": "^3.10.1",
|
|
56
57
|
"papaparse": "^5.5.3",
|
|
58
|
+
"patch-package": "^8.0.1",
|
|
57
59
|
"pdfjs-dist": "^5.4.149"
|
|
58
60
|
}
|
|
59
61
|
}
|
package/dist/Reshape-CDVLyVfz.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import "./index-D6Q1lPZO.js";
|
|
2
|
-
import { s as p, n as m, a as d } from "./tensor-CzmOBsdf.js";
|
|
3
|
-
import { b as c } from "./tensor_util-DfwaWayG.js";
|
|
4
|
-
function i(t) {
|
|
5
|
-
const { inputs: h, attrs: o } = t, { x: e } = h, { shape: r } = o, a = p(e.shape), s = m(r, a), n = p(s);
|
|
6
|
-
return d(a === n, () => `The new shape (${s}) has ${n} elements and the old shape (${e.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`), t.backend.incRef(e.dataId), { dataId: e.dataId, shape: s, dtype: e.dtype };
|
|
7
|
-
}
|
|
8
|
-
const $ = {
|
|
9
|
-
kernelName: c,
|
|
10
|
-
backendName: "webgpu",
|
|
11
|
-
kernelFunc: i
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
$ as a,
|
|
15
|
-
i as r
|
|
16
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { A as f, B as h, D as p, E as m } from "./index-D6Q1lPZO.js";
|
|
2
|
-
import { T as g } from "./tensor_util-DfwaWayG.js";
|
|
3
|
-
import { d as u } from "./tensor-CzmOBsdf.js";
|
|
4
|
-
import { r as T } from "./reshape-CaPQzFvz.js";
|
|
5
|
-
function b(e, o) {
|
|
6
|
-
let r = h(e, "broadcastTo", "x");
|
|
7
|
-
const a = r.shape;
|
|
8
|
-
if (u(o), o.length < r.rank)
|
|
9
|
-
throw new Error(`broadcastTo(): shape.length=${o.length} < input.rank=${r.rank}.`);
|
|
10
|
-
if (o.length > r.rank) {
|
|
11
|
-
const t = r.shape.slice();
|
|
12
|
-
for (; t.length < o.length; )
|
|
13
|
-
t.unshift(1);
|
|
14
|
-
r = T(r, t);
|
|
15
|
-
}
|
|
16
|
-
const s = r.shape, n = Array.from(o);
|
|
17
|
-
for (let t = o.length - 1; t >= 0; t--)
|
|
18
|
-
if (s[t] === o[t])
|
|
19
|
-
n[t] = 1;
|
|
20
|
-
else if (r.shape[t] !== 1)
|
|
21
|
-
throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${o}].`);
|
|
22
|
-
if (n.map((t, l) => t > 1 ? l : -1).filter((t) => t >= 0).length === 0)
|
|
23
|
-
return p(r);
|
|
24
|
-
const i = { x: r }, c = { reps: n };
|
|
25
|
-
return m.runKernel(g, i, c);
|
|
26
|
-
}
|
|
27
|
-
const N = /* @__PURE__ */ f({ broadcastTo_: b });
|
|
28
|
-
export {
|
|
29
|
-
N as b
|
|
30
|
-
};
|
package/dist/complex-BBiRlsVq.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { A as r, B as o, E as t } from "./index-D6Q1lPZO.js";
|
|
2
|
-
import { h as c } from "./tensor_util-DfwaWayG.js";
|
|
3
|
-
import { j as n } from "./tensor-CzmOBsdf.js";
|
|
4
|
-
function l(s, m) {
|
|
5
|
-
const a = o(s, "real", "complex"), e = o(m, "imag", "complex");
|
|
6
|
-
n(a.shape, e.shape, `real and imag shapes, ${a.shape} and ${e.shape}, must match in call to tf.complex().`);
|
|
7
|
-
const p = { real: a, imag: e };
|
|
8
|
-
return t.runKernel(c, p);
|
|
9
|
-
}
|
|
10
|
-
const f = /* @__PURE__ */ r({ complex_: l });
|
|
11
|
-
export {
|
|
12
|
-
f as c
|
|
13
|
-
};
|
package/dist/concat-DmBLPVGC.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { A as c, C as s, D as p, E as i } from "./index-D6Q1lPZO.js";
|
|
2
|
-
import { C as m } from "./tensor_util-DfwaWayG.js";
|
|
3
|
-
import { a as f } from "./tensor-CzmOBsdf.js";
|
|
4
|
-
function l(o, r = 0) {
|
|
5
|
-
f(o.length >= 1, () => "Pass at least one tensor to concat");
|
|
6
|
-
const t = s(o, "tensors", "concat", "string_or_numeric");
|
|
7
|
-
if (t[0].dtype === "complex64" && t.forEach((n) => {
|
|
8
|
-
if (n.dtype !== "complex64")
|
|
9
|
-
throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
10
|
-
with dtype ${n.dtype}. `);
|
|
11
|
-
}), t.length === 1)
|
|
12
|
-
return p(t[0]);
|
|
13
|
-
const e = t, a = { axis: r };
|
|
14
|
-
return i.runKernel(m, e, a);
|
|
15
|
-
}
|
|
16
|
-
const E = /* @__PURE__ */ c({ concat_: l });
|
|
17
|
-
export {
|
|
18
|
-
E as c
|
|
19
|
-
};
|
package/dist/dropout-B1x1kYMa.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { d as h, b as m, a as u, T as p } from "./tensor-CzmOBsdf.js";
|
|
2
|
-
import { A as l, B as c, E as g, J as f, l as V, n as v, m as N } from "./index-D6Q1lPZO.js";
|
|
3
|
-
import { Q as w } from "./tensor_util-DfwaWayG.js";
|
|
4
|
-
import { s as d } from "./index-CieiGp4Y.js";
|
|
5
|
-
function b(e) {
|
|
6
|
-
const r = { x: c(e, "x", "floor", "float32") };
|
|
7
|
-
return g.runKernel(w, r);
|
|
8
|
-
}
|
|
9
|
-
const x = /* @__PURE__ */ l({ floor_: b });
|
|
10
|
-
class T {
|
|
11
|
-
constructor(t, r, s, n, a) {
|
|
12
|
-
this.mean = t, this.stdDev = r, 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);
|
|
13
|
-
const o = a || Math.random();
|
|
14
|
-
this.random = d.alea(o.toString());
|
|
15
|
-
}
|
|
16
|
-
/** Returns next sample from a Gaussian distribution. */
|
|
17
|
-
nextValue() {
|
|
18
|
-
if (!isNaN(this.nextVal)) {
|
|
19
|
-
const n = this.nextVal;
|
|
20
|
-
return this.nextVal = NaN, n;
|
|
21
|
-
}
|
|
22
|
-
let t, r, s = !1;
|
|
23
|
-
for (; !s; ) {
|
|
24
|
-
let n, a, o;
|
|
25
|
-
do
|
|
26
|
-
n = 2 * this.random() - 1, a = 2 * this.random() - 1, o = n * n + a * a;
|
|
27
|
-
while (o >= 1 || o === 0);
|
|
28
|
-
const i = Math.sqrt(-2 * Math.log(o) / o);
|
|
29
|
-
t = this.mean + this.stdDev * n * i, r = this.mean + this.stdDev * a * i, (!this.truncated || this.isValidTruncated(t)) && (s = !0);
|
|
30
|
-
}
|
|
31
|
-
return (!this.truncated || this.isValidTruncated(r)) && (this.nextVal = this.convertValue(r)), this.convertValue(t);
|
|
32
|
-
}
|
|
33
|
-
/** Handles proper rounding for non-floating-point numbers. */
|
|
34
|
-
convertValue(t) {
|
|
35
|
-
return this.dtype == null || this.dtype === "float32" ? t : Math.round(t);
|
|
36
|
-
}
|
|
37
|
-
/** Returns true if less than 2-standard-deviations from the mean. */
|
|
38
|
-
isValidTruncated(t) {
|
|
39
|
-
return t <= this.upper && t >= this.lower;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
class $ {
|
|
43
|
-
constructor(t = 0, r = 1, s, n) {
|
|
44
|
-
if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = t, this.range = r - t, this.dtype = s, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
|
|
45
|
-
throw new Error(`The difference between ${t} - ${r} <= 1 and dtype is not float`);
|
|
46
|
-
this.random = d.alea(n);
|
|
47
|
-
}
|
|
48
|
-
convertValue(t) {
|
|
49
|
-
return this.canReturnFloat() ? t : Math.round(t);
|
|
50
|
-
}
|
|
51
|
-
nextValue() {
|
|
52
|
-
return this.convertValue(this.min + this.range * this.random());
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function y(e, t = 0, r = 1, s, n) {
|
|
56
|
-
if (h(e), s != null && s === "bool")
|
|
57
|
-
throw new Error(`Unsupported data type ${s}`);
|
|
58
|
-
const a = new T(t, r, s, !1, n), o = f(e, s);
|
|
59
|
-
for (let i = 0; i < o.values.length; i++)
|
|
60
|
-
o.values[i] = a.nextValue();
|
|
61
|
-
return o.toTensor();
|
|
62
|
-
}
|
|
63
|
-
const q = /* @__PURE__ */ l({ randomNormal_: y });
|
|
64
|
-
function M(e, t = 0, r = 1, s = "float32", n) {
|
|
65
|
-
h(e);
|
|
66
|
-
const a = f(e, s), o = new $(t, r, null, n);
|
|
67
|
-
for (let i = 0; i < a.values.length; i++)
|
|
68
|
-
a.values[i] = o.nextValue();
|
|
69
|
-
return a.toTensor();
|
|
70
|
-
}
|
|
71
|
-
const D = /* @__PURE__ */ l({ randomUniform_: M });
|
|
72
|
-
function E(e, t) {
|
|
73
|
-
if (t == null)
|
|
74
|
-
return e.shape.slice();
|
|
75
|
-
if (m(e.shape, t))
|
|
76
|
-
return t;
|
|
77
|
-
if (e.shape.length === t.length) {
|
|
78
|
-
const r = [];
|
|
79
|
-
for (let s = 0; s < e.shape.length; s++)
|
|
80
|
-
t[s] == null && e.shape[s] != null ? r.push(e.shape[s]) : r.push(t[s]);
|
|
81
|
-
return r;
|
|
82
|
-
}
|
|
83
|
-
return t;
|
|
84
|
-
}
|
|
85
|
-
function R(e, t, r, s) {
|
|
86
|
-
const n = c(e, "x", "dropout");
|
|
87
|
-
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)
|
|
88
|
-
return e instanceof p ? n.clone() : n;
|
|
89
|
-
const a = E(n, r), o = 1 - t, i = V(x(v(D(a, 0, 1, "float32", s), o)), o);
|
|
90
|
-
return N(n, i);
|
|
91
|
-
}
|
|
92
|
-
const I = /* @__PURE__ */ l({ dropout_: R });
|
|
93
|
-
export {
|
|
94
|
-
T as M,
|
|
95
|
-
D as a,
|
|
96
|
-
I as d,
|
|
97
|
-
x as f,
|
|
98
|
-
q as r
|
|
99
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { A as e, B as a, E as i } from "./index-D6Q1lPZO.js";
|
|
2
|
-
import { E as m } from "./tensor_util-DfwaWayG.js";
|
|
3
|
-
import { a as p } from "./tensor-CzmOBsdf.js";
|
|
4
|
-
function c(r, n = 0) {
|
|
5
|
-
const s = a(r, "x", "expandDims", "string_or_numeric");
|
|
6
|
-
p(n <= s.rank, () => "Axis must be <= rank of the tensor");
|
|
7
|
-
const t = { input: s }, o = { dim: n };
|
|
8
|
-
return i.runKernel(m, t, o);
|
|
9
|
-
}
|
|
10
|
-
const f = /* @__PURE__ */ e({ expandDims_: c });
|
|
11
|
-
export {
|
|
12
|
-
f as e
|
|
13
|
-
};
|
package/dist/gather-CH9sdacz.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { A as g, B as t, E as h } from "./index-D6Q1lPZO.js";
|
|
2
|
-
import { G as p } from "./tensor_util-DfwaWayG.js";
|
|
3
|
-
function m(n, r, s = 0, o = 0) {
|
|
4
|
-
const e = t(n, "x", "gather"), a = t(r, "indices", "gather", "int32"), i = { x: e, indices: a }, c = { axis: s, batchDims: o };
|
|
5
|
-
return h.runKernel(p, i, c);
|
|
6
|
-
}
|
|
7
|
-
const d = /* @__PURE__ */ g({ gather_: m });
|
|
8
|
-
export {
|
|
9
|
-
d as g
|
|
10
|
-
};
|