@genai-fi/nanogpt 0.10.1 → 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-DgA3z9oO.js → RealDiv-KAPDe8zB.js} +28 -30
- package/dist/Reshape-BYkmUnAv.js +14 -0
- package/dist/{Reshape-_kILl6tK.js → Reshape-Zt6eb7yh.js} +18 -20
- package/dist/TeachableLLM.js +10 -11
- package/dist/{axis_util-BvHEw88j.js → axis_util-BaG7mf5A.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-D-rUb2ty.js → backend_util-RCe-rHaj.js} +59 -60
- package/dist/{backend_webgpu-B0u2ndUn.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-DcJk7YHS.js → concat_util-DpW8mL_l.js} +1 -1
- package/dist/{dataset-0xP8GjwI.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-xuidcwI4.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-CNLFZWea.js → gelu-CjNPL4OH.js} +10 -11
- package/dist/{gpgpu_math-DDVJCn6-.js → gpgpu_math-DAOmgtXR.js} +841 -1015
- package/dist/{index-CjOj7j-u.js → index-BwexR4lA.js} +262 -263
- package/dist/index-DOvlwCh-.js +3520 -0
- package/dist/{kernel_funcs_utils-Dg_-E44D.js → kernel_funcs_utils-CCzYdUZg.js} +129 -131
- package/dist/layers/BaseLayer.js +14 -15
- 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--R5hOwDG.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-DY6Kk2Dl.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-5EL-8VAQ.js → scatter_nd_util-lvSiX8q4.js} +1 -1
- package/dist/selu_util-kbhpTdYD.js +44 -0
- package/dist/{shared-BRksrJb3.js → shared-DT1TkE6w.js} +1 -1
- package/dist/{shared-BuAXb4CI.js → shared-dntlHIDQ.js} +343 -345
- package/dist/slice-BfEGSH82.js +12 -0
- package/dist/{slice_util-DtEldBfK.js → slice_util-uTKwiEpW.js} +1 -1
- package/dist/{softmax-ZHVebtR1.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-G4Ys2GxX.js → tensor2d-Bs9wZRc7.js} +6 -7
- package/dist/{tensor4d-B8roDgtc.js → tensor4d-BARPdTaS.js} +6 -7
- package/dist/{tfjs_backend-kNyO5L2d.js → tfjs_backend-y1cvNhLA.js} +244 -253
- 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 -711
- 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-Bhn5bHYv.js → variable-WawDEaAb.js} +1 -1
- package/dist/{webgpu_program-Cigz-7RF.js → webgpu_program-DuOXPQol.js} +178 -172
- package/dist/{webgpu_util-BBCnKm2X.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-CF6odzV4.js +0 -16
- package/dist/broadcast_to-CwF7XIeu.js +0 -30
- package/dist/complex-CSlYz-2T.js +0 -13
- package/dist/concat-BHlIJeyT.js +0 -19
- package/dist/dropout-C1pM3f11.js +0 -99
- package/dist/expand_dims-BPG4fwBP.js +0 -13
- package/dist/gather-DykLGqmW.js +0 -10
- package/dist/index-ZyQhjEPo.js +0 -2157
- package/dist/log_sum_exp-DWI-76TI.js +0 -41
- package/dist/mat_mul-DeAh4uTH.js +0 -12
- package/dist/mod-Gt1rMB4n.js +0 -12
- package/dist/mulmat_packed_gpu-BMFhLwta.js +0 -55
- package/dist/ones-CAMiP4I2.js +0 -15
- package/dist/ops-CNI3TwqM.js +0 -645
- package/dist/pack16-CFUqumar.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 -10
- package/dist/patches/tape.d.ts +0 -12
- package/dist/patches/tape.js +0 -5
- package/dist/range-BMS52eQi.js +0 -11
- package/dist/reciprocal-CTmshQ9J.js +0 -10
- package/dist/register_all_kernels-Bwu1PTuU.js +0 -12307
- package/dist/relu-yZ2-7WxU.js +0 -10
- package/dist/reshape-DevtBWtf.js +0 -10
- package/dist/rope-B5UUMsPi.js +0 -32
- package/dist/selu_util-D1w6yyTO.js +0 -303
- package/dist/sin-BGfy2HZo.js +0 -16
- package/dist/slice-D_gkkqZK.js +0 -13
- package/dist/split-DrfihRpZ.js +0 -10
- package/dist/squeeze-DZEpeblb.js +0 -11
- package/dist/stack-yOIAalTq.js +0 -13
- package/dist/sum-_fzj5ZTB.js +0 -12
- package/dist/tensor-DdQUJZlz.js +0 -909
- package/dist/tensor-f35l8Odg.js +0 -8
- package/dist/tensor1d-CeZuc-Rv.js +0 -12
- package/dist/tensor_util-DV-FP5Q3.js +0 -523
- package/dist/tile-BzyEiF-F.js +0 -13
- package/dist/transpose-DKELTqhe.js +0 -38
- package/dist/zeros-2gldETuK.js +0 -14
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { A as c, B as e, E as a, S as l } from "./index-DOvlwCh-.js";
|
|
2
|
+
function p(r, n, o) {
|
|
3
|
+
const s = e(r, "x", "slice", "string_or_numeric");
|
|
4
|
+
if (s.rank === 0)
|
|
5
|
+
throw new Error("Slicing scalar is not possible");
|
|
6
|
+
const t = { x: s }, i = { begin: n, size: o };
|
|
7
|
+
return a.runKernel(l, t, i);
|
|
8
|
+
}
|
|
9
|
+
const x = /* @__PURE__ */ c({ slice_: p });
|
|
10
|
+
export {
|
|
11
|
+
x as s
|
|
12
|
+
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { A as r, B as f, E as i } from "./index-
|
|
2
|
-
import { S as e } from "./tensor_util-DV-FP5Q3.js";
|
|
1
|
+
import { A as r, B as f, E as e, Q as i } from "./index-DOvlwCh-.js";
|
|
3
2
|
function l(s, o = -1) {
|
|
4
3
|
const t = f(s, "logits", "softmax", "float32");
|
|
5
4
|
if (o === -1 && (o = t.rank - 1), o !== t.rank - 1)
|
|
6
5
|
throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${o}`);
|
|
7
6
|
const n = { logits: t }, a = { dim: o };
|
|
8
|
-
return
|
|
7
|
+
return e.runKernel(i, n, a);
|
|
9
8
|
}
|
|
10
|
-
const
|
|
9
|
+
const p = /* @__PURE__ */ r({ softmax_: l });
|
|
11
10
|
export {
|
|
12
|
-
|
|
11
|
+
p as s
|
|
13
12
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { A as p, B as i, E as a, U as c } from "./index-DOvlwCh-.js";
|
|
2
|
+
function e(t, s, n = 0) {
|
|
3
|
+
const o = { x: i(t, "x", "split") }, r = { numOrSizeSplits: s, axis: n };
|
|
4
|
+
return a.runKernel(c, o, r);
|
|
5
|
+
}
|
|
6
|
+
const u = /* @__PURE__ */ p({ split_: e });
|
|
7
|
+
export {
|
|
8
|
+
u as s
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { A as o, B as n, V as a } from "./index-DOvlwCh-.js";
|
|
2
|
+
import { r as t } from "./reshape-ByE68wS9.js";
|
|
3
|
+
function p(s, r) {
|
|
4
|
+
const e = n(s, "x", "squeeze", "string_or_numeric");
|
|
5
|
+
return t(e, a(e.shape, r).newShape);
|
|
6
|
+
}
|
|
7
|
+
const i = /* @__PURE__ */ o({ squeeze_: p });
|
|
8
|
+
export {
|
|
9
|
+
i as s
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { A as e, G as c, l as n, E as k, W as i } from "./index-DOvlwCh-.js";
|
|
2
|
+
function u(r, t = 0) {
|
|
3
|
+
const s = c(r, "tensors", "stack", "string_or_numeric");
|
|
4
|
+
n(s.length >= 1, () => "Pass at least one tensor to tf.stack"), s.length > 0 && n(t <= s[0].rank, () => "Axis must be <= rank of the tensor");
|
|
5
|
+
const o = s, a = { axis: t };
|
|
6
|
+
return k.runKernel(i, o, a);
|
|
7
|
+
}
|
|
8
|
+
const l = /* @__PURE__ */ e({ stack_: u });
|
|
9
|
+
export {
|
|
10
|
+
l as s
|
|
11
|
+
};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { l as _, aG as P, A as k, B as M, E as v, aH as F, aI as J, aJ as X, aK as q, aL as Q, aM as Y } from "./index-DOvlwCh-.js";
|
|
2
|
+
function it(t, n, e, o, s = "NHWC", f) {
|
|
3
|
+
const l = t[3], r = [...n, l], c = nt(s);
|
|
4
|
+
return B(t, r, e, f, o, null, null, c);
|
|
5
|
+
}
|
|
6
|
+
function ft(t, n, e, o, s, f, l = "channelsLast") {
|
|
7
|
+
const [r, c] = T(n);
|
|
8
|
+
let u;
|
|
9
|
+
if (l === "channelsLast")
|
|
10
|
+
u = [r, c, t[3], t[3]];
|
|
11
|
+
else if (l === "channelsFirst")
|
|
12
|
+
u = [r, c, t[1], t[1]];
|
|
13
|
+
else
|
|
14
|
+
throw new Error(`Unknown dataFormat ${l}`);
|
|
15
|
+
return B(t, u, e, o, s, f, !1, l);
|
|
16
|
+
}
|
|
17
|
+
function ht(t, n, e, o, s, f, l = "NDHWC") {
|
|
18
|
+
const [r, c, u] = K(n);
|
|
19
|
+
let h, i;
|
|
20
|
+
if (l === "NDHWC")
|
|
21
|
+
i = "channelsLast", h = [r, c, u, t[4], t[4]];
|
|
22
|
+
else if (l === "NCDHW")
|
|
23
|
+
i = "channelsFirst", h = [r, c, u, t[1], t[1]];
|
|
24
|
+
else
|
|
25
|
+
throw new Error(`Unknown dataFormat ${l}`);
|
|
26
|
+
return Z(t, h, e, o, s, !1, i, f);
|
|
27
|
+
}
|
|
28
|
+
function B(t, n, e, o, s, f, l = !1, r = "channelsLast") {
|
|
29
|
+
let [c, u, h, i] = [-1, -1, -1, -1];
|
|
30
|
+
if (r === "channelsLast")
|
|
31
|
+
[c, u, h, i] = t;
|
|
32
|
+
else if (r === "channelsFirst")
|
|
33
|
+
[c, i, u, h] = t;
|
|
34
|
+
else
|
|
35
|
+
throw new Error(`Unknown dataFormat ${r}`);
|
|
36
|
+
const [a, p, , $] = n, [w, g] = T(e), [x, y] = T(o), L = A(a, x), b = A(p, y), { padInfo: C, outHeight: E, outWidth: D } = d(s, u, h, w, g, L, b, f, r), I = l ? $ * i : $;
|
|
37
|
+
let m;
|
|
38
|
+
return r === "channelsFirst" ? m = [c, I, E, D] : r === "channelsLast" && (m = [c, E, D, I]), {
|
|
39
|
+
batchSize: c,
|
|
40
|
+
dataFormat: r,
|
|
41
|
+
inHeight: u,
|
|
42
|
+
inWidth: h,
|
|
43
|
+
inChannels: i,
|
|
44
|
+
outHeight: E,
|
|
45
|
+
outWidth: D,
|
|
46
|
+
outChannels: I,
|
|
47
|
+
padInfo: C,
|
|
48
|
+
strideHeight: w,
|
|
49
|
+
strideWidth: g,
|
|
50
|
+
filterHeight: a,
|
|
51
|
+
filterWidth: p,
|
|
52
|
+
effectiveFilterHeight: L,
|
|
53
|
+
effectiveFilterWidth: b,
|
|
54
|
+
dilationHeight: x,
|
|
55
|
+
dilationWidth: y,
|
|
56
|
+
inShape: t,
|
|
57
|
+
outShape: m,
|
|
58
|
+
filterShape: n
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function Z(t, n, e, o, s, f = !1, l = "channelsLast", r) {
|
|
62
|
+
let [c, u, h, i, a] = [-1, -1, -1, -1, -1];
|
|
63
|
+
if (l === "channelsLast")
|
|
64
|
+
[c, u, h, i, a] = t;
|
|
65
|
+
else if (l === "channelsFirst")
|
|
66
|
+
[c, a, u, h, i] = t;
|
|
67
|
+
else
|
|
68
|
+
throw new Error(`Unknown dataFormat ${l}`);
|
|
69
|
+
const [p, $, w, , g] = n, [x, y, L] = K(e), [b, C, E] = K(o), D = A(p, b), I = A($, C), m = A(w, E), { padInfo: G, outDepth: N, outHeight: R, outWidth: W } = tt(s, u, h, i, x, y, L, D, I, m, r), H = f ? g * a : g;
|
|
70
|
+
let O;
|
|
71
|
+
return l === "channelsFirst" ? O = [c, H, N, R, W] : l === "channelsLast" && (O = [c, N, R, W, H]), {
|
|
72
|
+
batchSize: c,
|
|
73
|
+
dataFormat: l,
|
|
74
|
+
inDepth: u,
|
|
75
|
+
inHeight: h,
|
|
76
|
+
inWidth: i,
|
|
77
|
+
inChannels: a,
|
|
78
|
+
outDepth: N,
|
|
79
|
+
outHeight: R,
|
|
80
|
+
outWidth: W,
|
|
81
|
+
outChannels: H,
|
|
82
|
+
padInfo: G,
|
|
83
|
+
strideDepth: x,
|
|
84
|
+
strideHeight: y,
|
|
85
|
+
strideWidth: L,
|
|
86
|
+
filterDepth: p,
|
|
87
|
+
filterHeight: $,
|
|
88
|
+
filterWidth: w,
|
|
89
|
+
effectiveFilterDepth: D,
|
|
90
|
+
effectiveFilterHeight: I,
|
|
91
|
+
effectiveFilterWidth: m,
|
|
92
|
+
dilationDepth: b,
|
|
93
|
+
dilationHeight: C,
|
|
94
|
+
dilationWidth: E,
|
|
95
|
+
inShape: t,
|
|
96
|
+
outShape: O,
|
|
97
|
+
filterShape: n
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function z(t, n, e, o, s) {
|
|
101
|
+
o == null && (o = j(t, n, e));
|
|
102
|
+
const f = t[0], l = t[1], r = U((f - n + 2 * o) / e + 1, s), c = U((l - n + 2 * o) / e + 1, s);
|
|
103
|
+
return [r, c];
|
|
104
|
+
}
|
|
105
|
+
function S(t, n, e, o, s, f) {
|
|
106
|
+
s == null && (s = j(t, n[0], o[0]));
|
|
107
|
+
const l = [0, 0, 0, e];
|
|
108
|
+
for (let r = 0; r < 3; r++)
|
|
109
|
+
t[r] + 2 * s >= n[r] && (l[r] = U((t[r] - n[r] + 2 * s) / o[r] + 1, f));
|
|
110
|
+
return l;
|
|
111
|
+
}
|
|
112
|
+
function j(t, n, e, o = 1) {
|
|
113
|
+
const s = A(n, o);
|
|
114
|
+
return Math.floor((t[0] * (e - 1) - e + s) / 2);
|
|
115
|
+
}
|
|
116
|
+
function T(t) {
|
|
117
|
+
return typeof t == "number" ? [t, t, t] : t.length === 2 ? [t[0], t[1], 1] : t;
|
|
118
|
+
}
|
|
119
|
+
function K(t) {
|
|
120
|
+
return typeof t == "number" ? [t, t, t] : t;
|
|
121
|
+
}
|
|
122
|
+
function A(t, n) {
|
|
123
|
+
return n <= 1 ? t : t + (t - 1) * (n - 1);
|
|
124
|
+
}
|
|
125
|
+
function d(t, n, e, o, s, f, l, r, c) {
|
|
126
|
+
let u, h, i;
|
|
127
|
+
if (typeof t == "number") {
|
|
128
|
+
u = { top: t, bottom: t, left: t, right: t, type: t === 0 ? "VALID" : "NUMBER" };
|
|
129
|
+
const p = z([n, e], f, o, t, r);
|
|
130
|
+
h = p[0], i = p[1];
|
|
131
|
+
} else if (t === "same") {
|
|
132
|
+
h = Math.ceil(n / o), i = Math.ceil(e / s);
|
|
133
|
+
const a = Math.max(0, (h - 1) * o + f - n), p = Math.max(0, (i - 1) * s + l - e), $ = Math.floor(a / 2), w = a - $, g = Math.floor(p / 2), x = p - g;
|
|
134
|
+
u = { top: $, bottom: w, left: g, right: x, type: "SAME" };
|
|
135
|
+
} else if (t === "valid")
|
|
136
|
+
u = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, h = Math.ceil((n - f + 1) / o), i = Math.ceil((e - l + 1) / s);
|
|
137
|
+
else if (typeof t == "object") {
|
|
138
|
+
const a = c === "channelsLast" ? t[1][0] : t[2][0], p = c === "channelsLast" ? t[1][1] : t[2][1], $ = c === "channelsLast" ? t[2][0] : t[3][0], w = c === "channelsLast" ? t[2][1] : t[3][1];
|
|
139
|
+
u = { top: a, bottom: p, left: $, right: w, type: a === 0 && p === 0 && $ === 0 && w === 0 ? "VALID" : "EXPLICIT" }, h = U((n - f + a + p) / o + 1, r), i = U((e - l + $ + w) / s + 1, r);
|
|
140
|
+
} else
|
|
141
|
+
throw Error(`Unknown padding parameter: ${t}`);
|
|
142
|
+
return { padInfo: u, outHeight: h, outWidth: i };
|
|
143
|
+
}
|
|
144
|
+
function tt(t, n, e, o, s, f, l, r, c, u, h) {
|
|
145
|
+
let i, a, p, $;
|
|
146
|
+
if (t === "valid" && (t = 0), typeof t == "number") {
|
|
147
|
+
i = {
|
|
148
|
+
top: t,
|
|
149
|
+
bottom: t,
|
|
150
|
+
left: t,
|
|
151
|
+
right: t,
|
|
152
|
+
front: t,
|
|
153
|
+
back: t,
|
|
154
|
+
type: t === 0 ? "VALID" : "NUMBER"
|
|
155
|
+
};
|
|
156
|
+
const g = S([n, e, o, 1], [r, c, u], 1, [s, f, l], t, h);
|
|
157
|
+
a = g[0], p = g[1], $ = g[2];
|
|
158
|
+
} else if (t === "same") {
|
|
159
|
+
a = Math.ceil(n / s), p = Math.ceil(e / f), $ = Math.ceil(o / l);
|
|
160
|
+
const w = (a - 1) * s + r - n, g = (p - 1) * f + c - e, x = ($ - 1) * l + u - o, y = Math.floor(w / 2), L = w - y, b = Math.floor(g / 2), C = g - b, E = Math.floor(x / 2), D = x - E;
|
|
161
|
+
i = { top: b, bottom: C, left: E, right: D, front: y, back: L, type: "SAME" };
|
|
162
|
+
} else
|
|
163
|
+
throw Error(`Unknown padding parameter: ${t}`);
|
|
164
|
+
return { padInfo: i, outDepth: a, outHeight: p, outWidth: $ };
|
|
165
|
+
}
|
|
166
|
+
function U(t, n) {
|
|
167
|
+
if (!n)
|
|
168
|
+
return Math.trunc(t);
|
|
169
|
+
switch (n) {
|
|
170
|
+
case "round":
|
|
171
|
+
return Math.round(t);
|
|
172
|
+
case "ceil":
|
|
173
|
+
return Math.ceil(t);
|
|
174
|
+
case "floor":
|
|
175
|
+
return Math.floor(t);
|
|
176
|
+
default:
|
|
177
|
+
throw new Error(`Unknown roundingMode ${n}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function V(t) {
|
|
181
|
+
const [n, e, o] = T(t);
|
|
182
|
+
return n === 1 && e === 1 && o === 1;
|
|
183
|
+
}
|
|
184
|
+
function at(t, n) {
|
|
185
|
+
return V(t) || V(n);
|
|
186
|
+
}
|
|
187
|
+
function pt(t) {
|
|
188
|
+
return T(t).every((n) => n > 0);
|
|
189
|
+
}
|
|
190
|
+
function nt(t) {
|
|
191
|
+
if (t === "NHWC")
|
|
192
|
+
return "channelsLast";
|
|
193
|
+
if (t === "NCHW")
|
|
194
|
+
return "channelsFirst";
|
|
195
|
+
throw new Error(`Unknown dataFormat ${t}`);
|
|
196
|
+
}
|
|
197
|
+
function $t(t, n, e) {
|
|
198
|
+
if (e != null) {
|
|
199
|
+
if (typeof n == "string")
|
|
200
|
+
throw Error(`Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${n}.`);
|
|
201
|
+
if (typeof n == "number")
|
|
202
|
+
_(P(n), () => `Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${n}.`);
|
|
203
|
+
else if (typeof n == "object")
|
|
204
|
+
n.forEach((o) => {
|
|
205
|
+
o.forEach((s) => {
|
|
206
|
+
_(P(s), () => `Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${s}.`);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
else
|
|
210
|
+
throw Error(`Error in ${t}: Unknown padding parameter: ${n}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function et(t) {
|
|
214
|
+
const e = { x: M(t, "x", "sigmoid", "float32") };
|
|
215
|
+
return v.runKernel(F, e);
|
|
216
|
+
}
|
|
217
|
+
const gt = /* @__PURE__ */ k({ sigmoid_: et });
|
|
218
|
+
function ot(t) {
|
|
219
|
+
const e = { x: M(t, "x", "elu", "float32") };
|
|
220
|
+
return v.runKernel(J, e);
|
|
221
|
+
}
|
|
222
|
+
const wt = /* @__PURE__ */ k({ elu_: ot });
|
|
223
|
+
function st(t, n = 0.2) {
|
|
224
|
+
const o = { x: M(t, "x", "leakyRelu") }, s = { alpha: n };
|
|
225
|
+
return v.runKernel(X, o, s);
|
|
226
|
+
}
|
|
227
|
+
const xt = /* @__PURE__ */ k({ leakyRelu_: st });
|
|
228
|
+
function rt(t, n) {
|
|
229
|
+
const e = M(t, "x", "prelu"), o = M(n, "alpha", "prelu"), s = { x: e, alpha: o };
|
|
230
|
+
return v.runKernel(q, s);
|
|
231
|
+
}
|
|
232
|
+
const Et = /* @__PURE__ */ k({ prelu_: rt });
|
|
233
|
+
function lt(t) {
|
|
234
|
+
const e = { x: M(t, "x", "relu6") };
|
|
235
|
+
return v.runKernel(Q, e);
|
|
236
|
+
}
|
|
237
|
+
const yt = /* @__PURE__ */ k({ relu6_: lt });
|
|
238
|
+
function ct(t, n = 0) {
|
|
239
|
+
const o = { x: M(t, "x", "step") }, s = { alpha: n };
|
|
240
|
+
return v.runKernel(Y, o, s);
|
|
241
|
+
}
|
|
242
|
+
const bt = /* @__PURE__ */ k({ step_: ct });
|
|
243
|
+
export {
|
|
244
|
+
bt as a,
|
|
245
|
+
B as b,
|
|
246
|
+
$t as c,
|
|
247
|
+
Z as d,
|
|
248
|
+
wt as e,
|
|
249
|
+
j as f,
|
|
250
|
+
it as g,
|
|
251
|
+
ft as h,
|
|
252
|
+
ht as i,
|
|
253
|
+
nt as j,
|
|
254
|
+
at as k,
|
|
255
|
+
xt as l,
|
|
256
|
+
pt as m,
|
|
257
|
+
Et as p,
|
|
258
|
+
yt as r,
|
|
259
|
+
gt as s,
|
|
260
|
+
V as t
|
|
261
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { A as e, B as u, X as c, E as l, Y as m } from "./index-DOvlwCh-.js";
|
|
2
|
+
function i(t, n = null, o = !1) {
|
|
3
|
+
let s = u(t, "x", "sum");
|
|
4
|
+
s.dtype === "bool" && (s = c(s, "int32"));
|
|
5
|
+
const r = { x: s }, a = { axis: n, keepDims: o };
|
|
6
|
+
return l.runKernel(m, r, a);
|
|
7
|
+
}
|
|
8
|
+
const f = /* @__PURE__ */ e({ sum_: i });
|
|
9
|
+
export {
|
|
10
|
+
f as s
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { $ as n, a0 as o, a1 as s } from "./index-DOvlwCh-.js";
|
|
2
|
+
function h(r, e) {
|
|
3
|
+
n(r);
|
|
4
|
+
const a = o(r, e);
|
|
5
|
+
if (a.length !== 1)
|
|
6
|
+
throw new Error("tensor1d() requires values to be a flat/TypedArray");
|
|
7
|
+
return s(r, null, a, e);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
h as t
|
|
11
|
+
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (a(o), r != null && r.length !== 2)
|
|
1
|
+
import { $ as t, a0 as a, a1 as s } from "./index-DOvlwCh-.js";
|
|
2
|
+
function i(n, r, o) {
|
|
3
|
+
if (t(n), r != null && r.length !== 2)
|
|
5
4
|
throw new Error("tensor2d() requires shape to have two numbers");
|
|
6
|
-
const e =
|
|
5
|
+
const e = a(n, o);
|
|
7
6
|
if (e.length !== 2 && e.length !== 1)
|
|
8
7
|
throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");
|
|
9
8
|
if (e.length === 1 && r == null)
|
|
10
9
|
throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");
|
|
11
|
-
return s(
|
|
10
|
+
return s(n, r, e, o);
|
|
12
11
|
}
|
|
13
12
|
export {
|
|
14
|
-
|
|
13
|
+
i as t
|
|
15
14
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (s(o), r != null && r.length !== 4)
|
|
1
|
+
import { $ as t, a0 as a, a1 as s } from "./index-DOvlwCh-.js";
|
|
2
|
+
function i(n, r, o) {
|
|
3
|
+
if (t(n), r != null && r.length !== 4)
|
|
5
4
|
throw new Error("tensor4d() requires shape to have four numbers");
|
|
6
|
-
const e =
|
|
5
|
+
const e = a(n, o);
|
|
7
6
|
if (e.length !== 4 && e.length !== 1)
|
|
8
7
|
throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");
|
|
9
8
|
if (e.length === 1 && r == null)
|
|
10
9
|
throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");
|
|
11
|
-
return
|
|
10
|
+
return s(n, r, e, o);
|
|
12
11
|
}
|
|
13
12
|
export {
|
|
14
|
-
|
|
13
|
+
i as t
|
|
15
14
|
};
|