@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,107 +1,99 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { m as
|
|
12
|
-
import { t as
|
|
13
|
-
import { c as
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
if (y(n <= t, () => `Error in clip: min (${n}) must be less than or equal to max (${t}).`), n === t)
|
|
17
|
-
return _e(s.shape, n, s.dtype);
|
|
18
|
-
const r = { x: s }, o = { clipValueMin: n, clipValueMax: t };
|
|
19
|
-
return M.runKernel(Me, r, o);
|
|
20
|
-
}
|
|
21
|
-
const Ve = /* @__PURE__ */ g({ clipByValue_: Ge });
|
|
22
|
-
function qe(e) {
|
|
23
|
-
return j(
|
|
1
|
+
import { A as w, B as S, l as T, E as q, x as U, L as ie, h as ue, a3 as ae, a6 as le, aX as fe, aF as he, aY as Te, t as $, X as ge, m as ke, w as _e, aZ as Ie } from "./index-DOvlwCh-.js";
|
|
2
|
+
import { t as Ee } from "./tensor1d-D11P_7Dp.js";
|
|
3
|
+
import { r as Le, d as Ne } from "./dropout-BcvN9JYi.js";
|
|
4
|
+
import { s as F } from "./slice-BfEGSH82.js";
|
|
5
|
+
import { r as c } from "./reshape-ByE68wS9.js";
|
|
6
|
+
import { g as be } from "./gather-D3JcZUaI.js";
|
|
7
|
+
import { e as Fe } from "./step-CINUs5QB.js";
|
|
8
|
+
import { c as Ce } from "./clip_by_value-BnO7-a88.js";
|
|
9
|
+
import { t as Pe } from "./tile-mbfagpsB.js";
|
|
10
|
+
import { s as ve, b as Me, c as je, g as Ve } from "./selu_util-kbhpTdYD.js";
|
|
11
|
+
import { m as k } from "./mat_mul-SjpJRLyL.js";
|
|
12
|
+
import { t as Ue } from "./transpose-ClWiBS_b.js";
|
|
13
|
+
import { c as M } from "./concat-BV8bt5H-.js";
|
|
14
|
+
function Be(e) {
|
|
15
|
+
return M(
|
|
24
16
|
e,
|
|
25
17
|
0
|
|
26
18
|
/* axis */
|
|
27
19
|
);
|
|
28
20
|
}
|
|
29
|
-
const
|
|
30
|
-
function
|
|
31
|
-
return
|
|
21
|
+
const xe = /* @__PURE__ */ w({ concat1d_: Be });
|
|
22
|
+
function Ge(e, n) {
|
|
23
|
+
return M(e, n);
|
|
32
24
|
}
|
|
33
|
-
const
|
|
25
|
+
const Je = /* @__PURE__ */ w({ concat2d_: Ge });
|
|
26
|
+
function qe(e, n) {
|
|
27
|
+
return M(e, n);
|
|
28
|
+
}
|
|
29
|
+
const Ke = /* @__PURE__ */ w({ concat3d_: qe });
|
|
34
30
|
function Ze(e, n) {
|
|
35
|
-
return
|
|
31
|
+
return M(e, n);
|
|
36
32
|
}
|
|
37
|
-
const
|
|
38
|
-
function Ye(e, n) {
|
|
39
|
-
|
|
33
|
+
const Re = /* @__PURE__ */ w({ concat4d_: Ze });
|
|
34
|
+
function Ye(e, n, t) {
|
|
35
|
+
const s = S(e, "x", "slice1d");
|
|
36
|
+
return T(s.rank === 1, () => `slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`), F(s, [n], [t]);
|
|
40
37
|
}
|
|
41
|
-
const
|
|
42
|
-
function
|
|
43
|
-
const s =
|
|
44
|
-
return
|
|
38
|
+
const H = /* @__PURE__ */ w({ slice1d_: Ye });
|
|
39
|
+
function We(e, n, t) {
|
|
40
|
+
const s = S(e, "x", "slice2d");
|
|
41
|
+
return T(s.rank === 2, () => `slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`), F(s, n, t);
|
|
45
42
|
}
|
|
46
|
-
const
|
|
43
|
+
const we = /* @__PURE__ */ w({ slice2d_: We });
|
|
47
44
|
function Xe(e, n, t) {
|
|
48
|
-
const s =
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
const
|
|
52
|
-
function
|
|
53
|
-
const s =
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
const
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const U = /* @__PURE__ */ g({ slice4d_: en });
|
|
62
|
-
function nn({ a: e, b: n, transposeA: t = !1, transposeB: s = !1, bias: r, activation: o = "linear", preluActivationWeights: a, leakyreluAlpha: f = 0.2 }) {
|
|
63
|
-
if (ve(M.state.gradientDepth, o) === !1) {
|
|
64
|
-
let D = w(e, n, t, s);
|
|
65
|
-
return r != null && (D = x(D, r)), Fe(D, o, a, f);
|
|
45
|
+
const s = S(e, "x", "slice3d");
|
|
46
|
+
return T(s.rank === 3, () => `slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`), F(s, n, t);
|
|
47
|
+
}
|
|
48
|
+
const Q = /* @__PURE__ */ w({ slice3d_: Xe });
|
|
49
|
+
function He(e, n, t) {
|
|
50
|
+
const s = S(e, "x", "slice4d");
|
|
51
|
+
return T(s.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`), F(s, n, t);
|
|
52
|
+
}
|
|
53
|
+
const V = /* @__PURE__ */ w({ slice4d_: He });
|
|
54
|
+
function Qe({ a: e, b: n, transposeA: t = !1, transposeB: s = !1, bias: r, activation: o = "linear", preluActivationWeights: a, leakyreluAlpha: f = 0.2 }) {
|
|
55
|
+
if (ve(q.state.gradientDepth, o) === !1) {
|
|
56
|
+
let D = k(e, n, t, s);
|
|
57
|
+
return r != null && (D = U(D, r)), Me(D, o, a, f);
|
|
66
58
|
}
|
|
67
|
-
let i =
|
|
68
|
-
[i, u] =
|
|
69
|
-
const m = t ? i.shape[i.rank - 2] : i.shape[i.rank - 1], d = s ? u.shape[u.rank - 1] : u.shape[u.rank - 2],
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
let
|
|
73
|
-
r != null && (
|
|
59
|
+
let i = S(e, "a", "fused matMul"), u = S(n, "b", "fused matMul");
|
|
60
|
+
[i, u] = ie(i, u);
|
|
61
|
+
const m = t ? i.shape[i.rank - 2] : i.shape[i.rank - 1], d = s ? u.shape[u.rank - 1] : u.shape[u.rank - 2], _ = t ? i.shape[i.rank - 1] : i.shape[i.rank - 2], h = s ? u.shape[u.rank - 2] : u.shape[u.rank - 1], ee = i.shape.slice(0, -2), I = u.shape.slice(0, -2), ne = ue(ee), te = ue(I);
|
|
62
|
+
T(m === d, () => `Error in fused matMul: inner shapes (${m}) and (${d}) of Tensors with shapes ${i.shape} and ${u.shape} and transposeA=${t} and transposeB=${s} must match.`);
|
|
63
|
+
const x = ae(i.shape.slice(0, -2), u.shape.slice(0, -2)).concat([_, h]), G = t ? c(i, [ne, m, _]) : c(i, [ne, _, m]), J = s ? c(u, [te, h, d]) : c(u, [te, d, h]);
|
|
64
|
+
let E;
|
|
65
|
+
r != null && (E = S(r, "bias", "fused matMul"), [E] = ie(E, i), ae(x, E.shape));
|
|
74
66
|
let se;
|
|
75
|
-
a != null && (se =
|
|
76
|
-
const re = (D,
|
|
77
|
-
const [
|
|
67
|
+
a != null && (se = S(a, "prelu weights", "fused matMul"));
|
|
68
|
+
const re = (D, C) => {
|
|
69
|
+
const [A, O, y, j] = C, g = je(c(D, y.shape), y, o);
|
|
78
70
|
let L, N;
|
|
79
|
-
if (!t && !s ? (L =
|
|
80
|
-
const
|
|
81
|
-
return [L, N,
|
|
71
|
+
if (!t && !s ? (L = k(g, O, !1, !0), N = k(A, g, !0, !1)) : !t && s ? (L = k(g, O, !1, !1), N = k(g, A, !0, !1)) : t && !s ? (L = k(O, g, !1, !0), N = k(A, g, !1, !1)) : (L = k(O, g, !0, !0), N = k(g, A, !0, !0)), r != null) {
|
|
72
|
+
const ye = Ve(j, g);
|
|
73
|
+
return [L, N, ye];
|
|
82
74
|
} else
|
|
83
75
|
return [L, N];
|
|
84
76
|
}, oe = {
|
|
85
|
-
a:
|
|
77
|
+
a: G,
|
|
86
78
|
b: J,
|
|
87
|
-
bias:
|
|
79
|
+
bias: E,
|
|
88
80
|
preluActivationWeights: se
|
|
89
81
|
}, ce = { transposeA: t, transposeB: s, activation: o, leakyreluAlpha: f };
|
|
90
|
-
return r == null ?
|
|
91
|
-
const
|
|
82
|
+
return r == null ? le((C, A, O) => {
|
|
83
|
+
const y = (
|
|
92
84
|
// tslint:disable-next-line: no-unnecessary-type-assertion
|
|
93
|
-
|
|
85
|
+
q.runKernel(fe, oe, ce)
|
|
94
86
|
);
|
|
95
|
-
return O([
|
|
96
|
-
})(
|
|
97
|
-
const
|
|
87
|
+
return O([C, A, y]), { value: c(y, x), gradFunc: re };
|
|
88
|
+
})(G, J) : le((C, A, O, y) => {
|
|
89
|
+
const j = (
|
|
98
90
|
// tslint:disable-next-line: no-unnecessary-type-assertion
|
|
99
|
-
|
|
91
|
+
q.runKernel(fe, oe, ce)
|
|
100
92
|
);
|
|
101
|
-
return
|
|
102
|
-
})(
|
|
93
|
+
return y([C, A, j, O]), { value: c(j, x), gradFunc: re };
|
|
94
|
+
})(G, J, E);
|
|
103
95
|
}
|
|
104
|
-
const pe = /* @__PURE__ */
|
|
96
|
+
const pe = /* @__PURE__ */ w({ fusedMatMul_: Qe });
|
|
105
97
|
class $e extends Error {
|
|
106
98
|
constructor(n) {
|
|
107
99
|
super(n), Object.setPrototypeOf(this, $e.prototype);
|
|
@@ -117,9 +109,9 @@ class l extends Error {
|
|
|
117
109
|
super(n), Object.setPrototypeOf(this, l.prototype);
|
|
118
110
|
}
|
|
119
111
|
}
|
|
120
|
-
class
|
|
112
|
+
class v extends Error {
|
|
121
113
|
constructor(n) {
|
|
122
|
-
super(n), Object.setPrototypeOf(this,
|
|
114
|
+
super(n), Object.setPrototypeOf(this, v.prototype);
|
|
123
115
|
}
|
|
124
116
|
}
|
|
125
117
|
class z extends Error {
|
|
@@ -127,7 +119,7 @@ class z extends Error {
|
|
|
127
119
|
super(n), Object.setPrototypeOf(this, z.prototype);
|
|
128
120
|
}
|
|
129
121
|
}
|
|
130
|
-
function
|
|
122
|
+
function Tn(e, n) {
|
|
131
123
|
if (Array.isArray(e)) {
|
|
132
124
|
let t = [];
|
|
133
125
|
for (let s = 0; s < n; s++)
|
|
@@ -142,45 +134,45 @@ function de(e, n) {
|
|
|
142
134
|
if (!e)
|
|
143
135
|
throw new z(n);
|
|
144
136
|
}
|
|
145
|
-
function
|
|
137
|
+
function _n(e, n) {
|
|
146
138
|
let t = 0;
|
|
147
139
|
for (const s of e)
|
|
148
140
|
s === n && t++;
|
|
149
141
|
return t;
|
|
150
142
|
}
|
|
151
|
-
function
|
|
143
|
+
function In(e) {
|
|
152
144
|
return e.length === 1 ? e[0] : e;
|
|
153
145
|
}
|
|
154
|
-
function
|
|
146
|
+
function En(e) {
|
|
155
147
|
return Array.isArray(e) ? e : [e];
|
|
156
148
|
}
|
|
157
|
-
function
|
|
149
|
+
function Ln(e) {
|
|
158
150
|
const t = e.replace(/(.)([A-Z][a-z0-9]+)/g, "$1_$2").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
|
|
159
151
|
return t[0] !== "_" ? t : "private" + t;
|
|
160
152
|
}
|
|
161
|
-
function
|
|
153
|
+
function Nn(e) {
|
|
162
154
|
return e.length <= 1 || e.indexOf("_") === -1 ? e : e.replace(/[_]+(\w|$)/g, (n, t) => t.toUpperCase());
|
|
163
155
|
}
|
|
164
156
|
let p = {};
|
|
165
|
-
function
|
|
157
|
+
function bn(e) {
|
|
166
158
|
if (e == null)
|
|
167
159
|
return null;
|
|
168
160
|
const n = {};
|
|
169
161
|
return n.className = e.getClassName(), n.config = e.getConfig(), n;
|
|
170
162
|
}
|
|
171
|
-
function
|
|
163
|
+
function Y(e) {
|
|
172
164
|
if (!(e == null || typeof e != "object"))
|
|
173
165
|
if (Array.isArray(e))
|
|
174
|
-
e.forEach((n) =>
|
|
166
|
+
e.forEach((n) => Y(n));
|
|
175
167
|
else {
|
|
176
168
|
const n = Object.keys(e);
|
|
177
169
|
for (const t of n) {
|
|
178
170
|
const s = e[t];
|
|
179
|
-
s != null && typeof s == "object" && (!Array.isArray(s) && s.type === "ndarray" && typeof s.value == "number" ? e[t] = s.value :
|
|
171
|
+
s != null && typeof s == "object" && (!Array.isArray(s) && s.type === "ndarray" && typeof s.value == "number" ? e[t] = s.value : Y(s));
|
|
180
172
|
}
|
|
181
173
|
}
|
|
182
174
|
}
|
|
183
|
-
function
|
|
175
|
+
function Fn(e, n = {}, t = {}, s = "object", r = !1) {
|
|
184
176
|
if (typeof e == "string") {
|
|
185
177
|
const o = e;
|
|
186
178
|
let a;
|
|
@@ -215,9 +207,9 @@ function Pn(e, n = {}, t = {}, s = "object", r = !1) {
|
|
|
215
207
|
const d = Object.assign({}, p);
|
|
216
208
|
for (const h of Object.keys(t))
|
|
217
209
|
p[h] = t[h];
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
return p = Object.assign({}, d),
|
|
210
|
+
Y(o.config);
|
|
211
|
+
const _ = i(f, o.config, t, r);
|
|
212
|
+
return p = Object.assign({}, d), _;
|
|
221
213
|
} else {
|
|
222
214
|
const u = Object.assign({}, p);
|
|
223
215
|
for (const d of Object.keys(t))
|
|
@@ -227,13 +219,13 @@ function Pn(e, n = {}, t = {}, s = "object", r = !1) {
|
|
|
227
219
|
}
|
|
228
220
|
}
|
|
229
221
|
}
|
|
230
|
-
function
|
|
222
|
+
function ze(e, n) {
|
|
231
223
|
return e < n ? -1 : e > n ? 1 : 0;
|
|
232
224
|
}
|
|
233
|
-
function
|
|
234
|
-
return -1 *
|
|
225
|
+
function Cn(e, n) {
|
|
226
|
+
return -1 * ze(e, n);
|
|
235
227
|
}
|
|
236
|
-
function
|
|
228
|
+
function Pn(e) {
|
|
237
229
|
if (e == null)
|
|
238
230
|
return e;
|
|
239
231
|
const n = [];
|
|
@@ -241,7 +233,7 @@ function Bn(e) {
|
|
|
241
233
|
n.indexOf(t) === -1 && n.push(t);
|
|
242
234
|
return n;
|
|
243
235
|
}
|
|
244
|
-
function
|
|
236
|
+
function vn(e) {
|
|
245
237
|
if (e == null)
|
|
246
238
|
throw new l(`Invalid value in obj: ${JSON.stringify(e)}`);
|
|
247
239
|
for (const n in e)
|
|
@@ -249,63 +241,63 @@ function Mn(e) {
|
|
|
249
241
|
return !1;
|
|
250
242
|
return !0;
|
|
251
243
|
}
|
|
252
|
-
function
|
|
244
|
+
function B(e, n, t) {
|
|
253
245
|
if (t != null && e.indexOf(t) < 0)
|
|
254
246
|
throw new l(`${t} is not a valid ${n}. Valid values are ${e} or null/undefined.`);
|
|
255
247
|
}
|
|
256
|
-
function
|
|
248
|
+
function Mn(e, n, t = 0, s = 1 / 0) {
|
|
257
249
|
return de(t >= 0), de(s >= t), Array.isArray(e) && e.length >= t && e.length <= s && e.every((r) => typeof r === n);
|
|
258
250
|
}
|
|
259
|
-
function
|
|
260
|
-
Array.isArray(e) ? (
|
|
251
|
+
function en(e, n) {
|
|
252
|
+
Array.isArray(e) ? (T(e.length > 0, () => `${n} is unexpectedly an empty array.`), e.forEach((t, s) => en(t, `element ${s + 1} of ${n}`))) : T(Number.isInteger(e) && e > 0, () => `Expected ${n} to be a positive integer, but got ${Oe(e)}.`);
|
|
261
253
|
}
|
|
262
|
-
function
|
|
263
|
-
return e === null ? "null" : Array.isArray(e) ? "[" + e.map((n) =>
|
|
254
|
+
function Oe(e) {
|
|
255
|
+
return e === null ? "null" : Array.isArray(e) ? "[" + e.map((n) => Oe(n)).join(",") + "]" : typeof e == "string" ? `"${e}"` : `${e}`;
|
|
264
256
|
}
|
|
265
|
-
function
|
|
266
|
-
let s = t != null ? t() :
|
|
257
|
+
function jn(e, n, t) {
|
|
258
|
+
let s = t != null ? t() : he(), r;
|
|
267
259
|
return (...a) => {
|
|
268
|
-
const f = t != null ? t() :
|
|
260
|
+
const f = t != null ? t() : he();
|
|
269
261
|
return f - s < n || (s = f, r = e(...a)), r;
|
|
270
262
|
};
|
|
271
263
|
}
|
|
272
|
-
function
|
|
264
|
+
function Vn(e) {
|
|
273
265
|
return e === "relu" ? "relu" : e === "linear" ? "linear" : e === "elu" ? "elu" : null;
|
|
274
266
|
}
|
|
275
|
-
const
|
|
267
|
+
const nn = ["channelsFirst", "channelsLast"], tn = ["nearest", "bilinear"], sn = ["valid", "same", "causal"], rn = ["max", "avg"], Un = ["sum", "mul", "concat", "ave"];
|
|
276
268
|
const b = /* @__PURE__ */ new Map();
|
|
277
|
-
function
|
|
278
|
-
|
|
269
|
+
function on(e) {
|
|
270
|
+
B(nn, "DataFormat", e);
|
|
279
271
|
}
|
|
280
|
-
function
|
|
281
|
-
|
|
272
|
+
function Bn(e) {
|
|
273
|
+
B(tn, "InterpolationFormat", e);
|
|
282
274
|
}
|
|
283
|
-
function
|
|
284
|
-
|
|
275
|
+
function xn(e) {
|
|
276
|
+
B(sn, "PaddingMode", e);
|
|
285
277
|
}
|
|
286
|
-
function
|
|
287
|
-
|
|
278
|
+
function Gn(e) {
|
|
279
|
+
B(rn, "PoolMode", e);
|
|
288
280
|
}
|
|
289
|
-
const
|
|
290
|
-
function
|
|
291
|
-
|
|
281
|
+
const P = [], me = "/";
|
|
282
|
+
function Jn(e, n) {
|
|
283
|
+
P.push(e);
|
|
292
284
|
try {
|
|
293
285
|
const t = n();
|
|
294
|
-
return
|
|
286
|
+
return P.pop(), t;
|
|
295
287
|
} catch (t) {
|
|
296
|
-
throw
|
|
288
|
+
throw P.pop(), t;
|
|
297
289
|
}
|
|
298
290
|
}
|
|
299
|
-
function
|
|
300
|
-
return
|
|
291
|
+
function cn() {
|
|
292
|
+
return P.length === 0 ? "" : P.join(me) + me;
|
|
301
293
|
}
|
|
302
|
-
function
|
|
303
|
-
if (!
|
|
294
|
+
function qn(e) {
|
|
295
|
+
if (!Se(e))
|
|
304
296
|
throw new Error("Not a valid tensor name: '" + e + "'");
|
|
305
|
-
return
|
|
297
|
+
return cn() + e;
|
|
306
298
|
}
|
|
307
|
-
function
|
|
308
|
-
if (!
|
|
299
|
+
function Kn(e) {
|
|
300
|
+
if (!Se(e))
|
|
309
301
|
throw new Error("Not a valid tensor name: '" + e + "'");
|
|
310
302
|
b.has(e) || b.set(e, 0);
|
|
311
303
|
const n = b.get(e);
|
|
@@ -315,21 +307,21 @@ function Wn(e) {
|
|
|
315
307
|
} else
|
|
316
308
|
return e;
|
|
317
309
|
}
|
|
318
|
-
const
|
|
319
|
-
function
|
|
320
|
-
return !!e.match(
|
|
310
|
+
const un = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);
|
|
311
|
+
function Se(e) {
|
|
312
|
+
return !!e.match(un);
|
|
321
313
|
}
|
|
322
|
-
function
|
|
314
|
+
function Zn(e) {
|
|
323
315
|
return e === parseInt(e.toString(), 10);
|
|
324
316
|
}
|
|
325
|
-
function
|
|
317
|
+
function De(e, n, t) {
|
|
326
318
|
n == null && (n = 0), t == null && (t = e.length);
|
|
327
319
|
let s = 1;
|
|
328
320
|
for (let r = n; r < t; ++r)
|
|
329
321
|
s *= e[r];
|
|
330
322
|
return s;
|
|
331
323
|
}
|
|
332
|
-
function
|
|
324
|
+
function Rn(e) {
|
|
333
325
|
if (e.length === 0)
|
|
334
326
|
return Number.NaN;
|
|
335
327
|
let n = Number.POSITIVE_INFINITY;
|
|
@@ -339,7 +331,7 @@ function Hn(e) {
|
|
|
339
331
|
}
|
|
340
332
|
return n;
|
|
341
333
|
}
|
|
342
|
-
function
|
|
334
|
+
function Yn(e) {
|
|
343
335
|
if (e.length === 0)
|
|
344
336
|
return Number.NaN;
|
|
345
337
|
let n = Number.NEGATIVE_INFINITY;
|
|
@@ -349,7 +341,7 @@ function Qn(e) {
|
|
|
349
341
|
}
|
|
350
342
|
return n;
|
|
351
343
|
}
|
|
352
|
-
function
|
|
344
|
+
function Wn(e, n) {
|
|
353
345
|
if (n < e)
|
|
354
346
|
throw new l(`end (${n}) < begin (${e}) is forbidden.`);
|
|
355
347
|
const t = [];
|
|
@@ -358,50 +350,50 @@ function Xn(e, n) {
|
|
|
358
350
|
return t;
|
|
359
351
|
}
|
|
360
352
|
let K;
|
|
361
|
-
function
|
|
353
|
+
function Xn() {
|
|
362
354
|
return K == null && (K = Te().epsilon()), K;
|
|
363
355
|
}
|
|
364
|
-
function
|
|
356
|
+
function W() {
|
|
365
357
|
return "channelsLast";
|
|
366
358
|
}
|
|
367
|
-
function
|
|
359
|
+
function Hn(e, n) {
|
|
368
360
|
return ge(e, n);
|
|
369
361
|
}
|
|
370
|
-
function
|
|
362
|
+
function an(e, n = -1) {
|
|
371
363
|
const t = e.shape.slice();
|
|
372
364
|
return n < 0 && (n = t.length + n + 1), t.splice(n, 0, 1), c(e, t);
|
|
373
365
|
}
|
|
374
|
-
function
|
|
375
|
-
return
|
|
366
|
+
function Qn(e, n) {
|
|
367
|
+
return $(() => {
|
|
376
368
|
if (e.shape.length !== 2)
|
|
377
369
|
throw new l(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);
|
|
378
|
-
const t =
|
|
379
|
-
return
|
|
370
|
+
const t = an(e, 1);
|
|
371
|
+
return ln(t, [1, n, 1]);
|
|
380
372
|
});
|
|
381
373
|
}
|
|
382
|
-
function
|
|
383
|
-
const n = [
|
|
374
|
+
function zn(e) {
|
|
375
|
+
const n = [De(e.shape)];
|
|
384
376
|
return c(e, n);
|
|
385
377
|
}
|
|
386
|
-
function
|
|
378
|
+
function et(e) {
|
|
387
379
|
if (e.rank <= 1)
|
|
388
380
|
throw new l(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);
|
|
389
|
-
const n = [e.shape[0],
|
|
381
|
+
const n = [e.shape[0], De(e.shape, 1)];
|
|
390
382
|
return c(e, n);
|
|
391
383
|
}
|
|
392
|
-
function
|
|
393
|
-
return
|
|
384
|
+
function Z(e, n, t) {
|
|
385
|
+
return $(() => {
|
|
394
386
|
switch (e.rank) {
|
|
395
387
|
case 1:
|
|
396
|
-
return
|
|
388
|
+
return H(e, n, t);
|
|
397
389
|
case 2:
|
|
398
390
|
return we(e, [n, 0], [t, e.shape[1]]);
|
|
399
391
|
case 3:
|
|
400
|
-
return
|
|
392
|
+
return Q(e, [n, 0, 0], [t, e.shape[1], e.shape[2]]);
|
|
401
393
|
case 4:
|
|
402
|
-
return
|
|
394
|
+
return V(e, [n, 0, 0, 0], [t, e.shape[1], e.shape[2], e.shape[3]]);
|
|
403
395
|
case 5:
|
|
404
|
-
return
|
|
396
|
+
return F(e, [n, 0, 0, 0, 0], [
|
|
405
397
|
t,
|
|
406
398
|
e.shape[1],
|
|
407
399
|
e.shape[2],
|
|
@@ -409,7 +401,7 @@ function R(e, n, t) {
|
|
|
409
401
|
e.shape[4]
|
|
410
402
|
]);
|
|
411
403
|
case 6:
|
|
412
|
-
return
|
|
404
|
+
return F(e, [n, 0, 0, 0, 0, 0], [
|
|
413
405
|
t,
|
|
414
406
|
e.shape[1],
|
|
415
407
|
e.shape[2],
|
|
@@ -422,57 +414,57 @@ function R(e, n, t) {
|
|
|
422
414
|
}
|
|
423
415
|
});
|
|
424
416
|
}
|
|
425
|
-
function
|
|
426
|
-
return
|
|
417
|
+
function R(e, n, t) {
|
|
418
|
+
return $(() => {
|
|
427
419
|
switch (e.rank) {
|
|
428
420
|
case 1:
|
|
429
|
-
return
|
|
421
|
+
return H(e, n, t);
|
|
430
422
|
case 2:
|
|
431
423
|
return we(e, [0, n], [e.shape[0], t]);
|
|
432
424
|
case 3:
|
|
433
|
-
return
|
|
425
|
+
return Q(e, [0, 0, n], [e.shape[0], e.shape[1], t]);
|
|
434
426
|
case 4:
|
|
435
|
-
return
|
|
427
|
+
return V(e, [0, 0, 0, n], [e.shape[0], e.shape[1], e.shape[2], t]);
|
|
436
428
|
default:
|
|
437
429
|
throw new l(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`);
|
|
438
430
|
}
|
|
439
431
|
});
|
|
440
432
|
}
|
|
441
|
-
function
|
|
442
|
-
return
|
|
433
|
+
function nt(e, n, t, s) {
|
|
434
|
+
return $(() => {
|
|
443
435
|
switch (e.rank) {
|
|
444
436
|
case 1:
|
|
445
|
-
return
|
|
437
|
+
return H(e, n, t);
|
|
446
438
|
case 2:
|
|
447
439
|
switch (s) {
|
|
448
440
|
case 1:
|
|
449
|
-
return R(e, n, t);
|
|
450
|
-
case 2:
|
|
451
441
|
return Z(e, n, t);
|
|
442
|
+
case 2:
|
|
443
|
+
return R(e, n, t);
|
|
452
444
|
default:
|
|
453
445
|
throw new l(`The axis is not within the rank of the tensor ${s}`);
|
|
454
446
|
}
|
|
455
447
|
case 3:
|
|
456
448
|
switch (s) {
|
|
457
449
|
case 1:
|
|
458
|
-
return
|
|
450
|
+
return Z(e, n, t);
|
|
459
451
|
case 2:
|
|
460
|
-
return
|
|
452
|
+
return Q(e, [0, n, 0], [e.shape[0], t, e.shape[2]]);
|
|
461
453
|
case 3:
|
|
462
|
-
return
|
|
454
|
+
return R(e, n, t);
|
|
463
455
|
default:
|
|
464
456
|
throw new l(`The axis is not within the rank of the tensor ${s}`);
|
|
465
457
|
}
|
|
466
458
|
case 4:
|
|
467
459
|
switch (s) {
|
|
468
460
|
case 1:
|
|
469
|
-
return
|
|
461
|
+
return Z(e, n, t);
|
|
470
462
|
case 2:
|
|
471
|
-
return
|
|
463
|
+
return V(e, [0, n, 0, 0], [e.shape[0], t, e.shape[2], e.shape[3]]);
|
|
472
464
|
case 3:
|
|
473
|
-
return
|
|
465
|
+
return V(e, [0, 0, n, 0], [e.shape[0], e.shape[1], t, e.shape[3]]);
|
|
474
466
|
case 4:
|
|
475
|
-
return
|
|
467
|
+
return R(e, n, t);
|
|
476
468
|
default:
|
|
477
469
|
throw new l(`The axis is not within the rank of the tensor ${s}`);
|
|
478
470
|
}
|
|
@@ -481,39 +473,39 @@ function rt(e, n, t, s) {
|
|
|
481
473
|
}
|
|
482
474
|
});
|
|
483
475
|
}
|
|
484
|
-
function
|
|
476
|
+
function tt(e, n = -1) {
|
|
485
477
|
let t;
|
|
486
|
-
return n < 0 && (t = e[0].rank, t !== 0 ? n = t : n = 0), n === e[0].rank && (n = -1),
|
|
478
|
+
return n < 0 && (t = e[0].rank, t !== 0 ? n = t : n = 0), n === e[0].rank && (n = -1), M(e, n);
|
|
487
479
|
}
|
|
488
|
-
function
|
|
480
|
+
function st(e, n) {
|
|
489
481
|
switch (e.rank) {
|
|
490
482
|
case 1:
|
|
491
|
-
return
|
|
483
|
+
return xe([e, n]);
|
|
492
484
|
case 2:
|
|
493
|
-
return
|
|
485
|
+
return Je([e, n], 0);
|
|
494
486
|
case 3:
|
|
495
|
-
return
|
|
487
|
+
return Ke([e, n], 0);
|
|
496
488
|
case 4:
|
|
497
|
-
return
|
|
489
|
+
return Re([e, n], 0);
|
|
498
490
|
default:
|
|
499
491
|
throw new l(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`);
|
|
500
492
|
}
|
|
501
493
|
}
|
|
502
|
-
function
|
|
494
|
+
function ln(e, n) {
|
|
503
495
|
if (Array.isArray(n) || (n = [n]), e.rank !== n.length)
|
|
504
496
|
throw new l(`The length of input n (${n.length}) does not match the number of dimensions in input x (${e.rank})`);
|
|
505
|
-
return
|
|
497
|
+
return Pe(e, n);
|
|
506
498
|
}
|
|
507
|
-
function
|
|
508
|
-
return
|
|
499
|
+
function rt(e, n = 0, t = 1, s, r) {
|
|
500
|
+
return Le(e, n, t, s, r);
|
|
509
501
|
}
|
|
510
|
-
function
|
|
502
|
+
function ot(e, n, t, s) {
|
|
511
503
|
if (e.rank < 2 || n.rank < 2)
|
|
512
|
-
throw new
|
|
504
|
+
throw new v(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${n.shape}`);
|
|
513
505
|
if (n.rank >= 3) {
|
|
514
506
|
const r = e.shape.slice(-1)[0], o = n.shape.slice(-2)[0];
|
|
515
507
|
if (r !== o)
|
|
516
|
-
throw new
|
|
508
|
+
throw new v(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${n.shape}`);
|
|
517
509
|
}
|
|
518
510
|
if (e.rank === 2 && n.rank === 2)
|
|
519
511
|
return pe({
|
|
@@ -521,32 +513,32 @@ function ut(e, n, t, s) {
|
|
|
521
513
|
b: n,
|
|
522
514
|
transposeA: !1,
|
|
523
515
|
transposeB: !1,
|
|
524
|
-
bias: s ?
|
|
516
|
+
bias: s ? X(e.rank, s, W()) : null,
|
|
525
517
|
activation: t
|
|
526
518
|
});
|
|
527
519
|
{
|
|
528
520
|
const r = e.shape.slice(), o = r.pop();
|
|
529
521
|
e = c(e, [-1, o]);
|
|
530
|
-
const a = n.shape.slice(), f = a.pop(), i = a.pop(), u = [...a, f], m = Array.from({ length: n.rank }, (ee,
|
|
531
|
-
n = c(
|
|
522
|
+
const a = n.shape.slice(), f = a.pop(), i = a.pop(), u = [...a, f], m = Array.from({ length: n.rank }, (ee, I) => I === 0 ? n.rank - 2 : I <= n.rank - 2 ? I - 1 : I);
|
|
523
|
+
n = c(Ue(n, m), [i, -1]);
|
|
532
524
|
const d = [...r, ...u];
|
|
533
525
|
return c(pe({
|
|
534
526
|
a: e,
|
|
535
527
|
b: n,
|
|
536
528
|
transposeA: !1,
|
|
537
529
|
transposeB: !1,
|
|
538
|
-
bias: s ?
|
|
530
|
+
bias: s ? X(e.rank, s, W()) : null,
|
|
539
531
|
activation: t
|
|
540
532
|
}), d);
|
|
541
533
|
}
|
|
542
534
|
}
|
|
543
|
-
function
|
|
544
|
-
return
|
|
535
|
+
function ct(e, n, t) {
|
|
536
|
+
return $(() => (Array.isArray(n) ? n = Ee(n, "int32") : n = ge(n, "int32"), be(e, n, t)));
|
|
545
537
|
}
|
|
546
|
-
function
|
|
538
|
+
function it(e) {
|
|
547
539
|
return ke(e, e);
|
|
548
540
|
}
|
|
549
|
-
function
|
|
541
|
+
function X(e, n, t) {
|
|
550
542
|
const s = n.shape;
|
|
551
543
|
if (n.rank !== 1 && n.rank !== e)
|
|
552
544
|
throw new l(`Unexpected bias dimensions: ${n.rank}; expected it to be 1 or ${e}`);
|
|
@@ -569,85 +561,84 @@ function H(e, n, t) {
|
|
|
569
561
|
return n;
|
|
570
562
|
throw new l(`Unsupported input rank by biasAdd: ${n.rank}`);
|
|
571
563
|
}
|
|
572
|
-
function
|
|
573
|
-
return
|
|
564
|
+
function ut(e, n, t) {
|
|
565
|
+
return $(() => (t == null && (t = W()), on(t), U(e, X(e.rank, n, t))));
|
|
574
566
|
}
|
|
575
|
-
function
|
|
567
|
+
function at(e, n = 1) {
|
|
576
568
|
if (n !== 1)
|
|
577
|
-
throw new
|
|
578
|
-
return
|
|
569
|
+
throw new v(`Support for alpha values other than 1 (${n}) is not implemented yet.`);
|
|
570
|
+
return Fe(e);
|
|
579
571
|
}
|
|
580
|
-
function
|
|
581
|
-
return
|
|
572
|
+
function lt(e) {
|
|
573
|
+
return $(() => _e(e, U(Ie(e), 1)));
|
|
582
574
|
}
|
|
583
|
-
function
|
|
584
|
-
return
|
|
575
|
+
function ft(e, n, t, s) {
|
|
576
|
+
return $(() => Ne(e, n, t, s));
|
|
585
577
|
}
|
|
586
|
-
function
|
|
587
|
-
return
|
|
588
|
-
const n =
|
|
589
|
-
return
|
|
578
|
+
function ht(e) {
|
|
579
|
+
return $(() => {
|
|
580
|
+
const n = U(0.5, ke(0.2, e));
|
|
581
|
+
return Ce(n, 0, 1);
|
|
590
582
|
});
|
|
591
583
|
}
|
|
592
|
-
function
|
|
584
|
+
function pt(e, n, t = !1) {
|
|
593
585
|
return t ? e() : n();
|
|
594
586
|
}
|
|
595
587
|
export {
|
|
596
|
-
|
|
588
|
+
Qn as $,
|
|
597
589
|
$e as A,
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
590
|
+
ct as B,
|
|
591
|
+
Wn as C,
|
|
592
|
+
_n as D,
|
|
593
|
+
at as E,
|
|
602
594
|
ht as F,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
595
|
+
lt as G,
|
|
596
|
+
Yn as H,
|
|
597
|
+
Zn as I,
|
|
598
|
+
Mn as J,
|
|
599
|
+
ut as K,
|
|
600
|
+
nt as L,
|
|
601
|
+
Bn as M,
|
|
602
|
+
v as N,
|
|
603
|
+
en as O,
|
|
604
|
+
Vn as P,
|
|
605
|
+
xn as Q,
|
|
614
606
|
Ae as R,
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
607
|
+
W as S,
|
|
608
|
+
ln as T,
|
|
609
|
+
Rn as U,
|
|
618
610
|
l as V,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
zn as
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
R as z
|
|
611
|
+
st as W,
|
|
612
|
+
pt as X,
|
|
613
|
+
ft as Y,
|
|
614
|
+
tt as Z,
|
|
615
|
+
et as _,
|
|
616
|
+
on as a,
|
|
617
|
+
Gn as a0,
|
|
618
|
+
Un as a1,
|
|
619
|
+
De as b,
|
|
620
|
+
B as c,
|
|
621
|
+
ot as d,
|
|
622
|
+
Fn as e,
|
|
623
|
+
Kn as f,
|
|
624
|
+
qn as g,
|
|
625
|
+
In as h,
|
|
626
|
+
En as i,
|
|
627
|
+
Xn as j,
|
|
628
|
+
jn as k,
|
|
629
|
+
zn as l,
|
|
630
|
+
it as m,
|
|
631
|
+
Jn as n,
|
|
632
|
+
de as o,
|
|
633
|
+
Hn as p,
|
|
634
|
+
Nn as q,
|
|
635
|
+
rt as r,
|
|
636
|
+
bn as s,
|
|
637
|
+
Ln as t,
|
|
638
|
+
Pn as u,
|
|
639
|
+
Cn as v,
|
|
640
|
+
Tn as w,
|
|
641
|
+
vn as x,
|
|
642
|
+
Z as y,
|
|
643
|
+
an as z
|
|
653
644
|
};
|