@genai-fi/nanogpt 0.5.0 → 0.5.2
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 +95 -46
- package/dist/NanoGPTModel.d.ts +3 -2
- package/dist/NanoGPTModel.js +91 -76
- package/dist/{Reshape-BE5rA4rT.js → Reshape-Bt_t7RNz.js} +4 -4
- package/dist/TeachableLLM.js +1 -1
- package/dist/TiedEmbedding-DORsPlNL.js +44 -0
- package/dist/{axis_util-97KkkyRQ.js → axis_util-CVbf1vmL.js} +3 -3
- package/dist/{broadcast_to-CMlkG8NS.js → broadcast_to-BBoMQXbL.js} +4 -4
- package/dist/{concat-Cxbo2sOz.js → concat-BRRtq4S2.js} +1 -1
- package/dist/dataset-ZHEPJmED.js +1226 -0
- package/dist/{dropout-kbDY39Ci.js → dropout-lQm_YyX3.js} +1 -1
- package/dist/{gather-Bxe1Qip8.js → gather-BWyutxwi.js} +3 -3
- package/dist/{gpgpu_math-C0zyxKFi.js → gpgpu_math-Df7gzJWH.js} +1 -1
- package/dist/{index-iNhkcAEQ.js → index-CnHyhpKc.js} +32 -32
- package/dist/{kernel_funcs_utils-C4eIk4fE.js → kernel_funcs_utils-Dqo82NH4.js} +25 -25
- package/dist/layers/BaseLayer.js +114 -3
- package/dist/layers/CausalSelfAttention.d.ts +2 -3
- package/dist/layers/CausalSelfAttention.js +31 -30
- package/dist/layers/MLP.js +10 -9
- package/dist/layers/RMSNorm.js +12 -11
- package/dist/layers/RoPECache.js +3 -3
- package/dist/layers/TiedEmbedding.js +8 -6
- package/dist/layers/TransformerBlock.js +2 -2
- package/dist/{log_sum_exp-CkumwesB.js → log_sum_exp-CRH7Np9v.js} +12 -12
- package/dist/main.js +1 -1
- package/dist/{mat_mul-D0SifYfJ.js → mat_mul-DeGU1U_C.js} +3 -3
- package/dist/{max-CYaAjEEp.js → max-CcnEArWK.js} +3 -3
- package/dist/{moments-B06NlR_V.js → moments-DLTE6-1p.js} +4 -4
- package/dist/{norm-D3676xIo.js → norm-BpWsOapl.js} +5 -5
- package/dist/{ones-BIeFnPHR.js → ones-CDWGzVnm.js} +6 -6
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +5 -5
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +1 -1
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +27 -27
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +1 -1
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +1 -1
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/node/sparseCrossEntropy.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +36 -36
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/matMulGelu.js +22 -22
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/{ops-ObfXLHYQ.js → ops-DzQTmLIl.js} +60 -60
- package/dist/{TiedEmbedding-DsDRvLB0.js → random_width-DI2h9CMs.js} +1215 -1250
- package/dist/{range-BsFU-SNG.js → range-CkOJ7090.js} +1 -1
- package/dist/{reshape-DxTPgnwL.js → reshape-CTIbqjwm.js} +1 -1
- package/dist/{sin-BOX-JVAj.js → sin-HzioENy_.js} +5 -5
- package/dist/{slice_util-D-kaD4ZV.js → slice_util-n4wHKmex.js} +1 -1
- package/dist/{softmax-BjsptB07.js → softmax-DX6qXAbm.js} +2 -2
- package/dist/{split-BCbrzthj.js → split-CVwhL8Oe.js} +3 -3
- package/dist/{stack--cqr9Dgc.js → stack-S2-D2JAQ.js} +1 -1
- package/dist/{sum-B_92TaHD.js → sum-UdfvaNhB.js} +4 -4
- package/dist/{tensor-CfiPXsW4.js → tensor-IZex6Bwp.js} +1 -1
- package/dist/{tensor2d-tSxWdFMH.js → tensor2d-CqtBzOKq.js} +1 -1
- package/dist/{tfjs_backend-NucKez4s.js → tfjs_backend-DX9yVvwk.js} +41 -41
- package/dist/tokeniser/CharTokeniser.js +27 -27
- package/dist/tokeniser/bpe.d.ts +1 -0
- package/dist/tokeniser/bpe.js +38 -35
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +22 -1242
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +5 -5
- package/dist/training/sparseCrossEntropy.js +4 -4
- package/dist/utilities/dummy.js +2 -2
- package/dist/utilities/generate.js +3 -3
- package/dist/utilities/load.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/save.js +5 -5
- package/dist/utilities/weights.js +2 -2
- package/dist/variable-BGvK-VN3.js +23 -0
- package/dist/{zeros-NMYTayy7.js → zeros-CYMicyqz.js} +3 -3
- package/package.json +1 -1
- package/dist/BaseLayer-BhrMN8JO.js +0 -135
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { o as h,
|
|
2
|
-
import { r as _ } from "./reshape-
|
|
3
|
-
import { s as un } from "./split-
|
|
4
|
-
import { s as q } from "./sum-
|
|
5
|
-
import { b as X } from "./broadcast_to-
|
|
6
|
-
import { r as O } from "./range-
|
|
7
|
-
import { t as Ln } from "./tensor-
|
|
8
|
-
import { s as Y } from "./stack
|
|
9
|
-
import { c as Xn, z as
|
|
10
|
-
import { n as ln } from "./norm-
|
|
11
|
-
import { c as
|
|
12
|
-
import { m as T } from "./mat_mul-
|
|
13
|
-
import { t as
|
|
1
|
+
import { o as h, j as l, E as f, aA as hn, l as p, aB as fn, Q as w, aC as dn, aD as bn, aE as gn, L as $n, al as xn, u as j, aF as kn, aG as yn, aH as In, aI as _n, aJ as En, aK as Mn, aL as Nn, D, aM as An, aN as Tn, aO as Sn, aP as wn, I as zn, J as Bn, K as qn, aQ as Kn, t as Gn, aR as J, aS as Rn, aT as Dn, aU as Pn, aV as Vn, aW as vn, aX as jn, f as Fn, aY as Wn, aZ as On, b as k, a9 as Z, am as G, g as Yn, s as S, a_ as Cn, y as L, a as Jn } from "./index-CnHyhpKc.js";
|
|
2
|
+
import { r as _ } from "./reshape-CTIbqjwm.js";
|
|
3
|
+
import { s as un } from "./split-CVwhL8Oe.js";
|
|
4
|
+
import { s as q } from "./sum-UdfvaNhB.js";
|
|
5
|
+
import { b as X } from "./broadcast_to-BBoMQXbL.js";
|
|
6
|
+
import { r as O } from "./range-CkOJ7090.js";
|
|
7
|
+
import { t as Ln } from "./tensor-IZex6Bwp.js";
|
|
8
|
+
import { s as Y } from "./stack-S2-D2JAQ.js";
|
|
9
|
+
import { c as Xn, z as Qn } from "./zeros-CYMicyqz.js";
|
|
10
|
+
import { n as ln } from "./norm-BpWsOapl.js";
|
|
11
|
+
import { c as Q } from "./concat-BRRtq4S2.js";
|
|
12
|
+
import { m as T } from "./mat_mul-DeGU1U_C.js";
|
|
13
|
+
import { t as H } from "./tensor2d-CqtBzOKq.js";
|
|
14
14
|
/**
|
|
15
15
|
* @license
|
|
16
16
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -27,14 +27,14 @@ import { t as Q } from "./tensor2d-tSxWdFMH.js";
|
|
|
27
27
|
* limitations under the License.
|
|
28
28
|
* =============================================================================
|
|
29
29
|
*/
|
|
30
|
-
function
|
|
30
|
+
function Hn(r, t, n) {
|
|
31
31
|
const e = l(r, "x", "slice", "string_or_numeric");
|
|
32
32
|
if (e.rank === 0)
|
|
33
33
|
throw new Error("Slicing scalar is not possible");
|
|
34
34
|
const s = { x: e }, a = { begin: t, size: n };
|
|
35
35
|
return f.runKernel(hn, s, a);
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const M = /* @__PURE__ */ h({ slice_: Hn });
|
|
38
38
|
/**
|
|
39
39
|
* @license
|
|
40
40
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -126,7 +126,7 @@ function se(r, t = 0) {
|
|
|
126
126
|
const e = { input: n }, s = { dim: t };
|
|
127
127
|
return f.runKernel(gn, e, s);
|
|
128
128
|
}
|
|
129
|
-
const
|
|
129
|
+
const K = /* @__PURE__ */ h({ expandDims_: se });
|
|
130
130
|
/**
|
|
131
131
|
* @license
|
|
132
132
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -175,11 +175,11 @@ function re(r, t, n, e = "float32") {
|
|
|
175
175
|
if (n == null)
|
|
176
176
|
return o;
|
|
177
177
|
if (n.length === 1)
|
|
178
|
-
return W(
|
|
178
|
+
return W(K(o, 0), [n[0], 1, 1]);
|
|
179
179
|
if (n.length === 2)
|
|
180
|
-
return W(
|
|
180
|
+
return W(K(K(o, 0), 0), [n[0], n[1], 1, 1]);
|
|
181
181
|
if (n.length === 3)
|
|
182
|
-
return W(
|
|
182
|
+
return W(K(K(K(o, 0), 0), 0), [
|
|
183
183
|
n[0],
|
|
184
184
|
n[1],
|
|
185
185
|
n[2],
|
|
@@ -320,7 +320,7 @@ const pn = /* @__PURE__ */ h({ lessEqual_: me });
|
|
|
320
320
|
*/
|
|
321
321
|
function he(r) {
|
|
322
322
|
const n = { x: l(r, "x", "neg") };
|
|
323
|
-
return f.runKernel(
|
|
323
|
+
return f.runKernel(Mn, n);
|
|
324
324
|
}
|
|
325
325
|
const nn = /* @__PURE__ */ h({ neg_: he });
|
|
326
326
|
/**
|
|
@@ -343,7 +343,7 @@ function fe(r, t) {
|
|
|
343
343
|
const n = l(r, "a", "logicalAnd", "bool"), e = l(t, "b", "logicalAnd", "bool");
|
|
344
344
|
w(n.shape, e.shape);
|
|
345
345
|
const s = { a: n, b: e };
|
|
346
|
-
return f.runKernel(
|
|
346
|
+
return f.runKernel(Nn, s);
|
|
347
347
|
}
|
|
348
348
|
const de = /* @__PURE__ */ h({ logicalAnd_: fe });
|
|
349
349
|
/**
|
|
@@ -448,7 +448,7 @@ const Ie = /* @__PURE__ */ h({ squeeze_: ye });
|
|
|
448
448
|
* limitations under the License.
|
|
449
449
|
* =============================================================================
|
|
450
450
|
*/
|
|
451
|
-
function
|
|
451
|
+
function N(r, t) {
|
|
452
452
|
zn(r);
|
|
453
453
|
const n = Bn(r, t);
|
|
454
454
|
if (n.length !== 1)
|
|
@@ -475,7 +475,7 @@ function _e(r, t = 0) {
|
|
|
475
475
|
const n = l(r, "x", "unstack", "string_or_numeric");
|
|
476
476
|
p(t >= -n.shape.length && t < n.shape.length, () => `Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`);
|
|
477
477
|
const e = { value: n }, s = { axis: t };
|
|
478
|
-
return f.runKernel(
|
|
478
|
+
return f.runKernel(Kn, e, s);
|
|
479
479
|
}
|
|
480
480
|
const mn = /* @__PURE__ */ h({ unstack_: _e });
|
|
481
481
|
/**
|
|
@@ -501,7 +501,7 @@ function Ee(r, t, n) {
|
|
|
501
501
|
}), e.rank <= 1)
|
|
502
502
|
return e.clone();
|
|
503
503
|
const s = { x: e }, a = { perm: t };
|
|
504
|
-
return e.dtype === "complex64" ?
|
|
504
|
+
return e.dtype === "complex64" ? Gn(() => {
|
|
505
505
|
let o = $e(e), i = le(e);
|
|
506
506
|
return o = f.runKernel(J, { x: o }, a), i = f.runKernel(J, { x: i }, a), n && (i = nn(i)), Xn(o, i);
|
|
507
507
|
}) : f.runKernel(J, s, a);
|
|
@@ -523,13 +523,13 @@ const an = /* @__PURE__ */ h({ transpose_: Ee });
|
|
|
523
523
|
* limitations under the License.
|
|
524
524
|
* =============================================================================
|
|
525
525
|
*/
|
|
526
|
-
function
|
|
526
|
+
function Me(r, t, n, e, s = "bilinear", a = 0) {
|
|
527
527
|
const o = l(r, "image", "cropAndResize"), i = l(t, "boxes", "cropAndResize", "float32"), u = l(n, "boxInd", "cropAndResize", "int32"), c = i.shape[0];
|
|
528
528
|
p(o.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`), p(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${c},4] but had shape ${i.shape}.`), p(u.rank === 1 && u.shape[0] === c, () => `Error in cropAndResize: boxInd must be have size [${c}] but had shape ${i.shape}.`), p(e.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${e.length}.`), p(e[0] >= 1 && e[1] >= 1, () => `cropSize must be atleast [1,1], but was ${e}`), p(s === "bilinear" || s === "nearest", () => `method must be bilinear or nearest, but was ${s}`);
|
|
529
529
|
const d = { image: o, boxes: i, boxInd: u }, m = { method: s, extrapolationValue: a, cropSize: e };
|
|
530
530
|
return f.runKernel(Rn, d, m);
|
|
531
531
|
}
|
|
532
|
-
const
|
|
532
|
+
const Ne = /* @__PURE__ */ h({ cropAndResize_: Me });
|
|
533
533
|
/**
|
|
534
534
|
* @license
|
|
535
535
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -595,7 +595,7 @@ const we = /* @__PURE__ */ h({ grayscaleToRGB_: Se });
|
|
|
595
595
|
function ze(r) {
|
|
596
596
|
const t = l(r, "image", "RGBToGrayscale"), n = t.rank - 1, e = t.shape[n];
|
|
597
597
|
p(t.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${t.rank}.`), p(e === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${e}.`);
|
|
598
|
-
const s = t.dtype, a = D(t, "float32"), o =
|
|
598
|
+
const s = t.dtype, a = D(t, "float32"), o = N([0.2989, 0.587, 0.114]);
|
|
599
599
|
let i;
|
|
600
600
|
switch (t.rank) {
|
|
601
601
|
case 2:
|
|
@@ -616,7 +616,7 @@ function ze(r) {
|
|
|
616
616
|
default:
|
|
617
617
|
throw new Error("Not a valid tensor rank.");
|
|
618
618
|
}
|
|
619
|
-
return i =
|
|
619
|
+
return i = K(i, -1), D(i, s);
|
|
620
620
|
}
|
|
621
621
|
const Be = /* @__PURE__ */ h({ rgbToGrayscale_: ze });
|
|
622
622
|
/**
|
|
@@ -641,7 +641,7 @@ function qe(r, t, n = 0, e = 0.5) {
|
|
|
641
641
|
const a = { image: s }, o = { radians: t, fillValue: n, center: e };
|
|
642
642
|
return f.runKernel(Pn, a, o);
|
|
643
643
|
}
|
|
644
|
-
const
|
|
644
|
+
const Ke = /* @__PURE__ */ h({ rotateWithOffset_: qe });
|
|
645
645
|
/**
|
|
646
646
|
* @license
|
|
647
647
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -679,13 +679,13 @@ function P(r, t, n, e, s, a) {
|
|
|
679
679
|
* limitations under the License.
|
|
680
680
|
* =============================================================================
|
|
681
681
|
*/
|
|
682
|
-
function
|
|
682
|
+
function Ge(r, t, n, e = 0.5, s = Number.NEGATIVE_INFINITY) {
|
|
683
683
|
const a = l(r, "boxes", "nonMaxSuppression", "float32"), o = l(t, "scores", "nonMaxSuppression", "float32"), i = P(a, o, n, e, s);
|
|
684
684
|
n = i.maxOutputSize, e = i.iouThreshold, s = i.scoreThreshold;
|
|
685
685
|
const u = { maxOutputSize: n, iouThreshold: e, scoreThreshold: s };
|
|
686
686
|
return f.runKernel(Vn, { boxes: a, scores: o }, u);
|
|
687
687
|
}
|
|
688
|
-
const Re = /* @__PURE__ */ h({ nonMaxSuppression_:
|
|
688
|
+
const Re = /* @__PURE__ */ h({ nonMaxSuppression_: Ge });
|
|
689
689
|
/**
|
|
690
690
|
* @license
|
|
691
691
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
@@ -835,7 +835,7 @@ async function Ce(r, t, n, e = 0.5, s = Number.NEGATIVE_INFINITY) {
|
|
|
835
835
|
const a = l(r, "boxes", "nonMaxSuppressionAsync"), o = l(t, "scores", "nonMaxSuppressionAsync"), i = P(a, o, n, e, s);
|
|
836
836
|
n = i.maxOutputSize, e = i.iouThreshold, s = i.scoreThreshold;
|
|
837
837
|
const u = await Promise.all([a.data(), o.data()]), c = u[0], d = u[1], { selectedIndices: m } = je(c, d, n, e, s);
|
|
838
|
-
return a !== r && a.dispose(), o !== t && o.dispose(),
|
|
838
|
+
return a !== r && a.dispose(), o !== t && o.dispose(), N(m, "int32");
|
|
839
839
|
}
|
|
840
840
|
const Je = Ce;
|
|
841
841
|
/**
|
|
@@ -877,16 +877,16 @@ const Xe = /* @__PURE__ */ h({ nonMaxSuppressionWithScore_: Le });
|
|
|
877
877
|
* limitations under the License.
|
|
878
878
|
* =============================================================================
|
|
879
879
|
*/
|
|
880
|
-
async function
|
|
880
|
+
async function Qe(r, t, n, e = 0.5, s = Number.NEGATIVE_INFINITY, a = 0) {
|
|
881
881
|
const o = l(r, "boxes", "nonMaxSuppressionAsync"), i = l(t, "scores", "nonMaxSuppressionAsync"), u = P(o, i, n, e, s, a);
|
|
882
882
|
n = u.maxOutputSize, e = u.iouThreshold, s = u.scoreThreshold, a = u.softNmsSigma;
|
|
883
883
|
const c = await Promise.all([o.data(), i.data()]), d = c[0], m = c[1], { selectedIndices: $, selectedScores: g } = We(d, m, n, e, s, a);
|
|
884
884
|
return o !== r && o.dispose(), i !== t && i.dispose(), {
|
|
885
|
-
selectedIndices:
|
|
886
|
-
selectedScores:
|
|
885
|
+
selectedIndices: N($, "int32"),
|
|
886
|
+
selectedScores: N(g)
|
|
887
887
|
};
|
|
888
888
|
}
|
|
889
|
-
const
|
|
889
|
+
const He = Qe;
|
|
890
890
|
/**
|
|
891
891
|
* @license
|
|
892
892
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -948,7 +948,7 @@ async function ns(r, t, n, e = 0.5, s = Number.NEGATIVE_INFINITY, a = !1) {
|
|
|
948
948
|
/* softNmsSigma */
|
|
949
949
|
), c = u.maxOutputSize, d = u.iouThreshold, m = u.scoreThreshold, [$, g] = await Promise.all([o.data(), i.data()]), { selectedIndices: x, validOutputs: y } = Fe($, g, c, d, m, a);
|
|
950
950
|
return o !== r && o.dispose(), i !== t && i.dispose(), {
|
|
951
|
-
selectedIndices:
|
|
951
|
+
selectedIndices: N(x, "int32"),
|
|
952
952
|
validOutputs: Fn(y, "int32")
|
|
953
953
|
};
|
|
954
954
|
}
|
|
@@ -1021,7 +1021,7 @@ const as = /* @__PURE__ */ h({ resizeNearestNeighbor_: rs });
|
|
|
1021
1021
|
*/
|
|
1022
1022
|
function os(r, t = "binary", n = !1, e = 0.5) {
|
|
1023
1023
|
const s = l(r, "image", "threshold"), a = 0.2989, o = 0.587, i = 0.114, u = s.shape[0] * s.shape[1];
|
|
1024
|
-
let c = k(
|
|
1024
|
+
let c = k(N([e]), 255), d, m, $, g;
|
|
1025
1025
|
if (p(s.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${s.rank}.`), p(s.shape[2] === 3 || s.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${s.shape[2]}.`), p(s.dtype === "int32" || s.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${s.dtype}.`), p(t === "otsu" || t === "binary", () => `Method must be binary or otsu, but was ${t}`), s.shape[2] === 3) {
|
|
1026
1026
|
[d, m, $] = un(s, [1, 1, 1], -1);
|
|
1027
1027
|
const b = k(d, a), E = k(m, o), I = k($, i);
|
|
@@ -1036,17 +1036,17 @@ function os(r, t = "binary", n = !1, e = 0.5) {
|
|
|
1036
1036
|
return D(k(x, 255), "int32");
|
|
1037
1037
|
}
|
|
1038
1038
|
function is(r, t) {
|
|
1039
|
-
let n =
|
|
1039
|
+
let n = N([-1]), e = N([0]), s = N([0]), a, o, i, u, c, d;
|
|
1040
1040
|
for (let m = 0; m < r.size - 1; m++) {
|
|
1041
|
-
a =
|
|
1041
|
+
a = M(r, 0, m + 1), o = M(r, m + 1), c = G(q(a), t), d = G(q(o), t);
|
|
1042
1042
|
const $ = q(k(a, O(0, a.size)));
|
|
1043
|
-
i =
|
|
1043
|
+
i = G($, q(a));
|
|
1044
1044
|
const g = Yn(o.shape, a.size), x = Z(O(0, o.size), g), y = k(o, x);
|
|
1045
|
-
u =
|
|
1045
|
+
u = G(q(y), q(o));
|
|
1046
1046
|
const b = S(i, u), E = S(i, u), I = k(c, d);
|
|
1047
1047
|
s = k(k(I, b), E);
|
|
1048
1048
|
const A = U(s, e);
|
|
1049
|
-
e = R(A, s, e), n = R(A,
|
|
1049
|
+
e = R(A, s, e), n = R(A, N([m]), n);
|
|
1050
1050
|
}
|
|
1051
1051
|
return n;
|
|
1052
1052
|
}
|
|
@@ -1096,7 +1096,7 @@ function ps(r, t, n) {
|
|
|
1096
1096
|
const s = e.shape, [a, o] = e.shape.slice(-2);
|
|
1097
1097
|
let i, u;
|
|
1098
1098
|
typeof t == "number" ? (p(t % 1 === 0, () => `bandPart(): numLower must be an integer, got ${t}.`), p(t <= a, () => `bandPart(): numLower (${t}) must not be greater than the number of rows (${a}).`), i = l(t < 0 ? a : t, "numLower", "bandPart")) : (p(t.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = R(tn(t, 0), a, rn(t, a))), typeof n == "number" ? (p(n % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${n}.`), p(n <= o, () => `bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`), u = l(n < 0 ? o : n, "numUpper", "bandPart")) : (p(n.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), u = R(tn(n, 0), o, rn(n, o)));
|
|
1099
|
-
const c = _(O(0, a, 1, "int32"), [-1, 1]), d = O(0, o, 1, "int32"), m = S(c, d), $ = de(pn(m, i), ce(m, nn(u))), g =
|
|
1099
|
+
const c = _(O(0, a, 1, "int32"), [-1, 1]), d = O(0, o, 1, "int32"), m = S(c, d), $ = de(pn(m, i), ce(m, nn(u))), g = Qn([a, o], e.dtype);
|
|
1100
1100
|
return _(Y(mn(_(e, [-1, a, o])).map((x) => R($, x, g))), s);
|
|
1101
1101
|
}
|
|
1102
1102
|
const ms = /* @__PURE__ */ h({ bandPart_: ps });
|
|
@@ -1135,7 +1135,7 @@ function hs(r) {
|
|
|
1135
1135
|
const i = k(q(k(n[o], a)), n[o]);
|
|
1136
1136
|
a = S(a, i);
|
|
1137
1137
|
}
|
|
1138
|
-
return
|
|
1138
|
+
return G(a, ln(a, "euclidean"));
|
|
1139
1139
|
}));
|
|
1140
1140
|
return t ? Y(n, 0) : n;
|
|
1141
1141
|
}
|
|
@@ -1178,35 +1178,35 @@ function cn(r, t = !1) {
|
|
|
1178
1178
|
p(r.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${r.shape.length}D Tensor.`);
|
|
1179
1179
|
const n = r.shape[0], e = r.shape[1];
|
|
1180
1180
|
let s = ae(n), a = L(r);
|
|
1181
|
-
const o =
|
|
1181
|
+
const o = H([[1]], [1, 1]);
|
|
1182
1182
|
let i = L(o);
|
|
1183
1183
|
const u = n >= e ? e : n;
|
|
1184
1184
|
for (let c = 0; c < u; ++c) {
|
|
1185
1185
|
const d = a, m = i, $ = s;
|
|
1186
1186
|
[i, a, s] = f.tidy(() => {
|
|
1187
|
-
const g =
|
|
1188
|
-
I.shape[0] === 1 ? i = L(o) : i =
|
|
1187
|
+
const g = M(a, [c, c], [n - c, 1]), x = ln(g), y = M(a, [c, c], [1, 1]), b = R(U(y, 0), H([[-1]]), H([[1]])), E = S(y, k(b, x)), I = G(g, E);
|
|
1188
|
+
I.shape[0] === 1 ? i = L(o) : i = Q([
|
|
1189
1189
|
o,
|
|
1190
|
-
|
|
1190
|
+
M(I, [1, 0], [I.shape[0] - 1, I.shape[1]])
|
|
1191
1191
|
], 0);
|
|
1192
|
-
const A = nn(
|
|
1192
|
+
const A = nn(G(T(b, E), x)), z = M(a, [c, 0], [n - c, e]), B = k(A, i), V = an(i);
|
|
1193
1193
|
if (c === 0)
|
|
1194
1194
|
a = S(z, T(B, T(V, z)));
|
|
1195
1195
|
else {
|
|
1196
1196
|
const C = S(z, T(B, T(V, z)));
|
|
1197
|
-
a =
|
|
1197
|
+
a = Q([M(a, [0, 0], [c, e]), C], 0);
|
|
1198
1198
|
}
|
|
1199
|
-
const sn = an(B), F =
|
|
1199
|
+
const sn = an(B), F = M(s, [0, c], [n, s.shape[1] - c]);
|
|
1200
1200
|
if (c === 0)
|
|
1201
1201
|
s = S(F, T(T(F, i), sn));
|
|
1202
1202
|
else {
|
|
1203
1203
|
const C = S(F, T(T(F, i), sn));
|
|
1204
|
-
s =
|
|
1204
|
+
s = Q([M(s, [0, 0], [n, c]), C], 1);
|
|
1205
1205
|
}
|
|
1206
1206
|
return [i, a, s];
|
|
1207
1207
|
}), Jn([d, m, $]);
|
|
1208
1208
|
}
|
|
1209
|
-
return !t && n > e && (s =
|
|
1209
|
+
return !t && n > e && (s = M(s, [0, 0], [n, e]), a = M(a, [0, 0], [e, e])), [s, a];
|
|
1210
1210
|
});
|
|
1211
1211
|
}
|
|
1212
1212
|
const bs = /* @__PURE__ */ h({ qr_: ds });
|
|
@@ -1232,12 +1232,12 @@ const ws = {
|
|
|
1232
1232
|
resizeNearestNeighbor: as,
|
|
1233
1233
|
resizeBilinear: ts,
|
|
1234
1234
|
rgbToGrayscale: Be,
|
|
1235
|
-
rotateWithOffset:
|
|
1236
|
-
cropAndResize:
|
|
1235
|
+
rotateWithOffset: Ke,
|
|
1236
|
+
cropAndResize: Ne,
|
|
1237
1237
|
nonMaxSuppression: Re,
|
|
1238
1238
|
nonMaxSuppressionAsync: Je,
|
|
1239
1239
|
nonMaxSuppressionWithScore: Xe,
|
|
1240
|
-
nonMaxSuppressionWithScoreAsync:
|
|
1240
|
+
nonMaxSuppressionWithScoreAsync: He,
|
|
1241
1241
|
nonMaxSuppressionPadded: Ue,
|
|
1242
1242
|
nonMaxSuppressionPaddedAsync: es,
|
|
1243
1243
|
threshold: cs,
|
|
@@ -1256,14 +1256,14 @@ export {
|
|
|
1256
1256
|
U as f,
|
|
1257
1257
|
ce as g,
|
|
1258
1258
|
tn as h,
|
|
1259
|
-
|
|
1259
|
+
K as i,
|
|
1260
1260
|
Ie as j,
|
|
1261
1261
|
ws as k,
|
|
1262
1262
|
zs as l,
|
|
1263
1263
|
rn as m,
|
|
1264
1264
|
nn as n,
|
|
1265
|
-
|
|
1266
|
-
|
|
1265
|
+
M as s,
|
|
1266
|
+
N as t,
|
|
1267
1267
|
mn as u,
|
|
1268
1268
|
R as w
|
|
1269
1269
|
};
|