@genai-fi/nanogpt 0.7.3 → 0.8.0
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.d.ts +25 -2
- package/dist/Generator.js +150 -49
- package/dist/{RealDiv-Dy0p8Bvo.js → RealDiv-N8TpOMYv.js} +14 -14
- package/dist/{Reshape-DvudQDvJ.js → Reshape-B-lWQRnF.js} +1 -1
- package/dist/{Reshape-DH5srBP0.js → Reshape-Bo8HzP8V.js} +5 -5
- package/dist/TeachableLLM.d.ts +6 -6
- package/dist/TeachableLLM.js +31 -31
- package/dist/Trainer.d.ts +13 -2
- package/dist/Trainer.js +21 -12
- package/dist/{axis_util-BzbKo31C.js → axis_util-DubwyOhW.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-TE7aTPhZ.js → backend_util-BJ-_jSeK.js} +46 -46
- package/dist/{broadcast_to-CdbwV-Dj.js → broadcast_to-BYfCp5iL.js} +2 -2
- package/dist/{concat-CsxrgovM.js → concat-BmDqqFsa.js} +1 -1
- package/dist/{dataset-CtdBYwjo.js → dataset-CJmEGu6D.js} +5 -5
- package/dist/{dropout-DYs5QFGQ.js → dropout-sx0sjVAT.js} +8 -8
- package/dist/exports_initializers-DAKM8UO9.js +16 -0
- package/dist/{gather-CMMy2KEG.js → gather-C1siEkdp.js} +1 -1
- package/dist/{gelu-C-dPj6Ku.js → gelu-Bd3UBBxg.js} +1 -1
- package/dist/{gpgpu_math-DGNLNL4I.js → gpgpu_math-TFLxaLkw.js} +26 -26
- package/dist/{index-CLthM0TO.js → index-BaPo_0H8.js} +185 -185
- package/dist/{index-BoWRt-10.js → index-CUQrfsw_.js} +266 -265
- package/dist/{kernel_funcs_utils-BYKWV8Aa.js → kernel_funcs_utils-P9aFa232.js} +9 -9
- package/dist/layers/BaseLayer.d.ts +8 -13
- package/dist/layers/BaseLayer.js +25 -13
- package/dist/layers/CausalSelfAttention.d.ts +3 -2
- package/dist/layers/CausalSelfAttention.js +28 -28
- package/dist/layers/MLP.d.ts +3 -2
- package/dist/layers/MLP.js +16 -20
- package/dist/layers/PositionEmbedding.d.ts +9 -0
- package/dist/layers/PositionEmbedding.js +45 -0
- package/dist/layers/RMSNorm.d.ts +3 -2
- package/dist/layers/RMSNorm.js +6 -6
- package/dist/layers/RoPECache.d.ts +1 -1
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.d.ts +3 -2
- package/dist/layers/TiedEmbedding.js +29 -7
- package/dist/layers/TransformerBlock.d.ts +3 -2
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/load.d.ts +2 -2
- package/dist/loader/loadHF.d.ts +2 -2
- package/dist/loader/loadTransformers.d.ts +4 -2
- package/dist/loader/loadTransformers.js +10 -9
- package/dist/loader/newZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.js +42 -51
- package/dist/loader/save.d.ts +8 -0
- package/dist/loader/save.js +62 -0
- package/dist/{log_sum_exp-DbjkV734.js → log_sum_exp-C142qZqY.js} +14 -14
- package/dist/main.d.ts +5 -4
- package/dist/main.js +22 -18
- package/dist/{mat_mul-8m8pfdcx.js → mat_mul-DMkduNJu.js} +1 -1
- package/dist/{max-Ddnnb5xe.js → max-B3JOcNGb.js} +1 -1
- package/dist/mod-uUuj4gSb.js +27 -0
- package/dist/models/NanoGPTV1.d.ts +15 -0
- package/dist/models/NanoGPTV1.js +71 -0
- package/dist/{config.d.ts → models/config.d.ts} +1 -0
- package/dist/{config.js → models/config.js} +1 -0
- package/dist/models/factory.d.ts +3 -0
- package/dist/models/factory.js +14 -0
- package/dist/models/model.d.ts +26 -0
- package/dist/models/model.js +68 -0
- package/dist/{mulmat_packed_gpu-VSekgsNv.js → mulmat_packed_gpu-Cm2gw-c8.js} +1 -1
- package/dist/{ones-Dj0SDhHf.js → ones-ZdgQGBCP.js} +2 -2
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/adamAdjust.js +9 -9
- package/dist/ops/cpu/adamMoments.js +2 -2
- 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 +3 -3
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +2 -2
- 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 +11 -11
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +2 -2
- 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/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +4 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/adamAdjust.js +2 -2
- package/dist/ops/webgl/adamMoments.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 +4 -4
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMulGelu.js +10 -10
- 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/webgpu/adamAdjust.js +3 -3
- package/dist/ops/webgpu/adamMoments.js +3 -3
- package/dist/ops/webgpu/appendCache.js +3 -3
- package/dist/ops/webgpu/attentionMask.js +3 -3
- package/dist/ops/webgpu/gatherSub.js +3 -3
- package/dist/ops/webgpu/gelu.js +3 -3
- package/dist/ops/webgpu/normRMS.js +2 -2
- package/dist/ops/webgpu/normRMSGrad.js +5 -5
- package/dist/ops/webgpu/qkv.js +3 -3
- package/dist/ops/webgpu/rope.js +3 -3
- package/dist/ops/webgpu/scatterSub.js +3 -3
- package/dist/ops/webgpu/utils/reductions.js +4 -4
- package/dist/{ops-BFGCx8Ri.js → ops-C_1K_-35.js} +103 -103
- package/dist/{random_width-sZORGo5k.js → random_width-D8Pwy_na.js} +136 -136
- package/dist/{range-CRuAh-gd.js → range-LVHrSLdi.js} +1 -1
- package/dist/{reciprocal-BvGAyKyu.js → reciprocal-CaR9e67G.js} +1 -1
- package/dist/{register_all_kernels-BwDSRN-f.js → register_all_kernels-DUshvVWP.js} +2026 -2049
- package/dist/{reshape-CdBq1WJ6.js → reshape-DEfQGSin.js} +1 -1
- package/dist/{scatter_nd_util-DUstGbU1.js → scatter_nd_util-CUPPNLaA.js} +1 -1
- package/dist/{selu_util-BJEXVvjX.js → selu_util-8vv5JxQV.js} +3 -3
- package/dist/{shared-B8ztnyEk.js → shared-CkNorDcU.js} +83 -83
- package/dist/{shared-wS99K7_n.js → shared-D1elLckx.js} +1 -1
- package/dist/{sin-BeA3tsEd.js → sin-D2CKKmyR.js} +1 -1
- package/dist/{slice-BiOsknYS.js → slice-BnyE-M_7.js} +1 -1
- package/dist/{softmax-Bv_6lyMX.js → softmax-DLoZWYBx.js} +1 -1
- package/dist/{split-B-dikLRw.js → split-By_n4TKP.js} +1 -1
- package/dist/{stack-B17UN2nn.js → stack-DkdFLq37.js} +1 -1
- package/dist/{sum-66ew2byf.js → sum-l_0SqM4h.js} +3 -3
- package/dist/{tensor-JwS7ZYY6.js → tensor-BAQdLqoU.js} +1 -1
- package/dist/{tensor2d-wxPAnDQy.js → tensor2d-BHy261cI.js} +1 -1
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/Evaluator.d.ts +2 -2
- package/dist/training/FullTrainer.d.ts +3 -3
- package/dist/training/FullTrainer.js +61 -69
- package/dist/training/Trainer.d.ts +15 -3
- package/dist/training/Trainer.js +39 -47
- package/dist/training/sparseCrossEntropy.js +9 -9
- package/dist/utilities/dummy.d.ts +4 -4
- package/dist/utilities/dummy.js +13 -13
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/parameters.d.ts +1 -1
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-BuddVFLa.js → variable-C9hihzDB.js} +1 -1
- package/dist/{webgpu_program-PFzf1hAQ.js → webgpu_program-dFEVbDPL.js} +1 -1
- package/dist/{webgpu_util-D____QpY.js → webgpu_util-DLImlSc6.js} +27 -27
- package/dist/{zeros--BdLQ3oG.js → zeros-VZ72lWXM.js} +1 -1
- package/package.json +2 -3
- package/dist/NanoGPTModel.d.ts +0 -52
- package/dist/NanoGPTModel.js +0 -203
- package/dist/TiedEmbedding-BxOerUmB.js +0 -43
- package/dist/utilities/generate.d.ts +0 -3
- package/dist/utilities/generate.js +0 -22
- package/dist/utilities/save.d.ts +0 -9
- package/dist/utilities/save.js +0 -61
package/dist/ops/webgpu/rope.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as c } from "../../webgpu_program-
|
|
2
|
-
import { f as m, c as l } from "../../webgpu_util-
|
|
3
|
-
import { f as x,
|
|
1
|
+
import { g as c } from "../../webgpu_program-dFEVbDPL.js";
|
|
2
|
+
import { f as m, c as l } from "../../webgpu_util-DLImlSc6.js";
|
|
3
|
+
import { f as x, a3 as f } from "../../index-CUQrfsw_.js";
|
|
4
4
|
class S {
|
|
5
5
|
variableNames = ["x", "sin", "cos"];
|
|
6
6
|
outputShape;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as p } from "../../webgpu_program-
|
|
2
|
-
import { f as u, c as d } from "../../webgpu_util-
|
|
3
|
-
import { f as h,
|
|
1
|
+
import { g as p } from "../../webgpu_program-dFEVbDPL.js";
|
|
2
|
+
import { f as u, c as d } from "../../webgpu_util-DLImlSc6.js";
|
|
3
|
+
import { f as h, a3 as o } from "../../index-CUQrfsw_.js";
|
|
4
4
|
class b {
|
|
5
5
|
variableNames = ["labels", "softmaxProbs", "dy"];
|
|
6
6
|
outputShape;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { p as l, j as d } from "../../../index-
|
|
2
|
-
import { g as p } from "../../../webgpu_program-
|
|
3
|
-
import { r as f } from "../../../Reshape-
|
|
4
|
-
import { c as x } from "../../../axis_util-
|
|
1
|
+
import { p as l, j as d } from "../../../index-CUQrfsw_.js";
|
|
2
|
+
import { g as p } from "../../../webgpu_program-dFEVbDPL.js";
|
|
3
|
+
import { r as f } from "../../../Reshape-B-lWQRnF.js";
|
|
4
|
+
import { c as x } from "../../../axis_util-DubwyOhW.js";
|
|
5
5
|
function I(e, r, t, s, u) {
|
|
6
6
|
return `
|
|
7
7
|
fn DIV_CEIL(a : u32, b : u32) -> u32 {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { B as m, C as u, l, E as f,
|
|
1
|
+
import { B as m, C as u, n as l, E as f, aR as gn, l as S, aS as $n, aT as kn, aU as yn, p as En, aV as w, w as rn, x as _n, b as pn, aW as In, aX as An, W as Nn, an as Tn, N as v, aY as xn, aZ as wn, a_ as Sn, a$ as Mn, b0 as zn, b1 as qn, b2 as Bn, $ as G, b3 as Kn, b4 as Gn, b5 as Rn, aI as Dn, y as vn, z as Vn, A as Pn, b6 as jn, t as Fn, b7 as L, b8 as Wn, b9 as Yn, ba as On, bb as Cn, bc as Ln, bd as Xn, be as Jn, bf as Zn, a as $, q as U, o as q, h as Hn, c as N, bg as Qn, F as X, d as Un } from "./index-CUQrfsw_.js";
|
|
2
2
|
import { n as ne, a as ee, b as se } from "./non_max_suppression_impl-CsEgBuMA.js";
|
|
3
|
-
import { r as k } from "./reshape-
|
|
4
|
-
import { s as mn } from "./split-
|
|
5
|
-
import { s as E } from "./sum-
|
|
6
|
-
import { b as
|
|
7
|
-
import { s as _ } from "./slice-
|
|
8
|
-
import { r as W } from "./range-
|
|
9
|
-
import { t as te } from "./tensor-
|
|
10
|
-
import { s as Y } from "./stack-
|
|
11
|
-
import { c as re, z as ae } from "./zeros
|
|
12
|
-
import { e as oe } from "./axis_util-
|
|
13
|
-
import { m as
|
|
14
|
-
import { c as
|
|
15
|
-
import { m as
|
|
16
|
-
import { t as
|
|
3
|
+
import { r as k } from "./reshape-DEfQGSin.js";
|
|
4
|
+
import { s as mn } from "./split-By_n4TKP.js";
|
|
5
|
+
import { s as E } from "./sum-l_0SqM4h.js";
|
|
6
|
+
import { b as J } from "./broadcast_to-BYfCp5iL.js";
|
|
7
|
+
import { s as _ } from "./slice-BnyE-M_7.js";
|
|
8
|
+
import { r as W } from "./range-LVHrSLdi.js";
|
|
9
|
+
import { t as te } from "./tensor-BAQdLqoU.js";
|
|
10
|
+
import { s as Y } from "./stack-DkdFLq37.js";
|
|
11
|
+
import { c as re, z as ae } from "./zeros-VZ72lWXM.js";
|
|
12
|
+
import { e as oe } from "./axis_util-DubwyOhW.js";
|
|
13
|
+
import { m as Z } from "./max-B3JOcNGb.js";
|
|
14
|
+
import { c as H } from "./concat-BmDqqFsa.js";
|
|
15
|
+
import { m as A } from "./mat_mul-DMkduNJu.js";
|
|
16
|
+
import { t as Q } from "./tensor2d-BHy261cI.js";
|
|
17
17
|
/**
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -54,14 +54,14 @@ const ce = /* @__PURE__ */ m({ bincount_: ie });
|
|
|
54
54
|
* =============================================================================
|
|
55
55
|
*/
|
|
56
56
|
function ue(s, e, n) {
|
|
57
|
-
const r = u(e, "a", "where"), t = u(n, "b", "where"), a = u(s, "condition", "where", "bool"), o = S(S(a.shape, r.shape), t.shape), i =
|
|
57
|
+
const r = u(e, "a", "where"), t = u(n, "b", "where"), a = u(s, "condition", "where", "bool"), o = S(S(a.shape, r.shape), t.shape), i = J(a, o), p = J(r, o), c = J(t, o), h = {
|
|
58
58
|
condition: i,
|
|
59
59
|
t: p,
|
|
60
60
|
e: c
|
|
61
61
|
};
|
|
62
|
-
return f.runKernel($n,
|
|
62
|
+
return f.runKernel($n, h);
|
|
63
63
|
}
|
|
64
|
-
const
|
|
64
|
+
const K = /* @__PURE__ */ m({ where_: ue });
|
|
65
65
|
/**
|
|
66
66
|
* @license
|
|
67
67
|
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
@@ -139,7 +139,7 @@ function fn(s, e, n = null) {
|
|
|
139
139
|
if (e === 1)
|
|
140
140
|
return E(w(s), n);
|
|
141
141
|
if (e === 1 / 0)
|
|
142
|
-
return
|
|
142
|
+
return Z(w(s), n);
|
|
143
143
|
if (e === -1 / 0)
|
|
144
144
|
return an(w(s), n);
|
|
145
145
|
if (e === "euclidean" || e === 2)
|
|
@@ -148,9 +148,9 @@ function fn(s, e, n = null) {
|
|
|
148
148
|
}
|
|
149
149
|
if (Array.isArray(n) && n.length === 2) {
|
|
150
150
|
if (e === 1)
|
|
151
|
-
return
|
|
151
|
+
return Z(E(w(s), n[0]), n[1] - 1);
|
|
152
152
|
if (e === 1 / 0)
|
|
153
|
-
return
|
|
153
|
+
return Z(E(w(s), n[1]), n[0]);
|
|
154
154
|
if (e === -1 / 0)
|
|
155
155
|
return an(E(w(s), n[1]), n[0]);
|
|
156
156
|
if (e === "fro" || e === "euclidean")
|
|
@@ -159,7 +159,7 @@ function fn(s, e, n = null) {
|
|
|
159
159
|
}
|
|
160
160
|
throw new Error(`Error in norm: invalid axis: ${n}`);
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const bn = /* @__PURE__ */ m({ norm_: me });
|
|
163
163
|
/**
|
|
164
164
|
* @license
|
|
165
165
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -180,7 +180,7 @@ function fe(s, e = 0) {
|
|
|
180
180
|
const n = u(s, "x", "expandDims", "string_or_numeric");
|
|
181
181
|
l(e <= n.rank, () => "Axis must be <= rank of the tensor");
|
|
182
182
|
const r = { input: n }, t = { dim: e };
|
|
183
|
-
return f.runKernel(
|
|
183
|
+
return f.runKernel(An, r, t);
|
|
184
184
|
}
|
|
185
185
|
const z = /* @__PURE__ */ m({ expandDims_: fe });
|
|
186
186
|
/**
|
|
@@ -199,13 +199,13 @@ const z = /* @__PURE__ */ m({ expandDims_: fe });
|
|
|
199
199
|
* limitations under the License.
|
|
200
200
|
* =============================================================================
|
|
201
201
|
*/
|
|
202
|
-
function
|
|
202
|
+
function be(s, e) {
|
|
203
203
|
const n = u(s, "x", "tile", "string_or_numeric");
|
|
204
204
|
l(n.rank === e.length, () => `Error in transpose: rank of input ${n.rank} must match length of reps ${e}.`);
|
|
205
205
|
const r = { x: n }, t = { reps: e };
|
|
206
|
-
return f.runKernel(
|
|
206
|
+
return f.runKernel(Nn, r, t);
|
|
207
207
|
}
|
|
208
|
-
const F = /* @__PURE__ */ m({ tile_:
|
|
208
|
+
const F = /* @__PURE__ */ m({ tile_: be });
|
|
209
209
|
/**
|
|
210
210
|
* @license
|
|
211
211
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -222,7 +222,7 @@ const F = /* @__PURE__ */ m({ tile_: he });
|
|
|
222
222
|
* limitations under the License.
|
|
223
223
|
* =============================================================================
|
|
224
224
|
*/
|
|
225
|
-
function
|
|
225
|
+
function he(s, e, n, r = "float32") {
|
|
226
226
|
e == null && (e = s);
|
|
227
227
|
const t = Tn([s, e], r), a = s <= e ? s : e;
|
|
228
228
|
for (let i = 0; i < a; ++i)
|
|
@@ -244,7 +244,7 @@ function be(s, e, n, r = "float32") {
|
|
|
244
244
|
]);
|
|
245
245
|
throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`);
|
|
246
246
|
}
|
|
247
|
-
const de = /* @__PURE__ */ m({ eye_:
|
|
247
|
+
const de = /* @__PURE__ */ m({ eye_: he });
|
|
248
248
|
/**
|
|
249
249
|
* @license
|
|
250
250
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -357,7 +357,7 @@ function Ie(s, e) {
|
|
|
357
357
|
const t = { a: n, b: r };
|
|
358
358
|
return f.runKernel(zn, t);
|
|
359
359
|
}
|
|
360
|
-
const
|
|
360
|
+
const hn = /* @__PURE__ */ m({ lessEqual_: Ie });
|
|
361
361
|
/**
|
|
362
362
|
* @license
|
|
363
363
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -374,11 +374,11 @@ const bn = /* @__PURE__ */ m({ lessEqual_: Ie });
|
|
|
374
374
|
* limitations under the License.
|
|
375
375
|
* =============================================================================
|
|
376
376
|
*/
|
|
377
|
-
function
|
|
377
|
+
function Ae(s) {
|
|
378
378
|
const n = { x: u(s, "x", "neg") };
|
|
379
379
|
return f.runKernel(qn, n);
|
|
380
380
|
}
|
|
381
|
-
const en = /* @__PURE__ */ m({ neg_:
|
|
381
|
+
const en = /* @__PURE__ */ m({ neg_: Ae });
|
|
382
382
|
/**
|
|
383
383
|
* @license
|
|
384
384
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -395,13 +395,13 @@ const en = /* @__PURE__ */ m({ neg_: Ne });
|
|
|
395
395
|
* limitations under the License.
|
|
396
396
|
* =============================================================================
|
|
397
397
|
*/
|
|
398
|
-
function
|
|
398
|
+
function Ne(s, e) {
|
|
399
399
|
const n = u(s, "a", "logicalAnd", "bool"), r = u(e, "b", "logicalAnd", "bool");
|
|
400
400
|
S(n.shape, r.shape);
|
|
401
401
|
const t = { a: n, b: r };
|
|
402
402
|
return f.runKernel(Bn, t);
|
|
403
403
|
}
|
|
404
|
-
const Te = /* @__PURE__ */ m({ logicalAnd_:
|
|
404
|
+
const Te = /* @__PURE__ */ m({ logicalAnd_: Ne });
|
|
405
405
|
/**
|
|
406
406
|
* @license
|
|
407
407
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -420,9 +420,9 @@ const Te = /* @__PURE__ */ m({ logicalAnd_: Ae });
|
|
|
420
420
|
*/
|
|
421
421
|
function xe(s, e) {
|
|
422
422
|
let n = u(s, "a", "minimum"), r = u(e, "b", "minimum");
|
|
423
|
-
[n, r] = v(n, r), n.dtype === "bool" && (n =
|
|
423
|
+
[n, r] = v(n, r), n.dtype === "bool" && (n = G(n, "int32"), r = G(r, "int32")), S(n.shape, r.shape);
|
|
424
424
|
const t = { a: n, b: r };
|
|
425
|
-
return f.runKernel(
|
|
425
|
+
return f.runKernel(Kn, t);
|
|
426
426
|
}
|
|
427
427
|
const cn = /* @__PURE__ */ m({ minimum_: xe });
|
|
428
428
|
/**
|
|
@@ -443,7 +443,7 @@ const cn = /* @__PURE__ */ m({ minimum_: xe });
|
|
|
443
443
|
*/
|
|
444
444
|
function we(s) {
|
|
445
445
|
const n = { input: u(s, "input", "real") };
|
|
446
|
-
return f.runKernel(
|
|
446
|
+
return f.runKernel(Gn, n);
|
|
447
447
|
}
|
|
448
448
|
const Se = /* @__PURE__ */ m({ real_: we });
|
|
449
449
|
/**
|
|
@@ -527,13 +527,13 @@ function I(s, e) {
|
|
|
527
527
|
* limitations under the License.
|
|
528
528
|
* =============================================================================
|
|
529
529
|
*/
|
|
530
|
-
function
|
|
530
|
+
function Ke(s, e = 0) {
|
|
531
531
|
const n = u(s, "x", "unstack", "string_or_numeric");
|
|
532
532
|
l(e >= -n.shape.length && e < n.shape.length, () => `Axis = ${e} is not in [-${n.shape.length}, ${n.shape.length})`);
|
|
533
533
|
const r = { value: n }, t = { axis: e };
|
|
534
534
|
return f.runKernel(jn, r, t);
|
|
535
535
|
}
|
|
536
|
-
const dn = /* @__PURE__ */ m({ unstack_:
|
|
536
|
+
const dn = /* @__PURE__ */ m({ unstack_: Ke });
|
|
537
537
|
/**
|
|
538
538
|
* @license
|
|
539
539
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -550,7 +550,7 @@ const dn = /* @__PURE__ */ m({ unstack_: Ge });
|
|
|
550
550
|
* limitations under the License.
|
|
551
551
|
* =============================================================================
|
|
552
552
|
*/
|
|
553
|
-
function
|
|
553
|
+
function Ge(s, e, n) {
|
|
554
554
|
const r = u(s, "x", "transpose");
|
|
555
555
|
if (e == null && (e = r.shape.map((o, i) => i).reverse()), l(r.rank === e.length, () => `Error in transpose: rank of input ${r.rank} must match length of perm ${e}.`), e.forEach((o) => {
|
|
556
556
|
l(o >= 0 && o < r.rank, () => `All entries in 'perm' must be between 0 and ${r.rank - 1} but got ${e}`);
|
|
@@ -562,7 +562,7 @@ function Ke(s, e, n) {
|
|
|
562
562
|
return o = f.runKernel(L, { x: o }, a), i = f.runKernel(L, { x: i }, a), n && (i = en(i)), re(o, i);
|
|
563
563
|
}) : f.runKernel(L, t, a);
|
|
564
564
|
}
|
|
565
|
-
const un = /* @__PURE__ */ m({ transpose_:
|
|
565
|
+
const un = /* @__PURE__ */ m({ transpose_: Ge });
|
|
566
566
|
/**
|
|
567
567
|
* @license
|
|
568
568
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -582,8 +582,8 @@ const un = /* @__PURE__ */ m({ transpose_: Ke });
|
|
|
582
582
|
function Re(s, e, n, r, t = "bilinear", a = 0) {
|
|
583
583
|
const o = u(s, "image", "cropAndResize"), i = u(e, "boxes", "cropAndResize", "float32"), p = u(n, "boxInd", "cropAndResize", "int32"), c = i.shape[0];
|
|
584
584
|
l(o.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`), l(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${c},4] but had shape ${i.shape}.`), l(p.rank === 1 && p.shape[0] === c, () => `Error in cropAndResize: boxInd must be have size [${c}] but had shape ${i.shape}.`), l(r.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`), l(r[0] >= 1 && r[1] >= 1, () => `cropSize must be atleast [1,1], but was ${r}`), l(t === "bilinear" || t === "nearest", () => `method must be bilinear or nearest, but was ${t}`);
|
|
585
|
-
const
|
|
586
|
-
return f.runKernel(Wn,
|
|
585
|
+
const h = { image: o, boxes: i, boxInd: p }, b = { method: t, extrapolationValue: a, cropSize: r };
|
|
586
|
+
return f.runKernel(Wn, h, b);
|
|
587
587
|
}
|
|
588
588
|
const De = /* @__PURE__ */ m({ cropAndResize_: Re });
|
|
589
589
|
/**
|
|
@@ -651,7 +651,7 @@ const je = /* @__PURE__ */ m({ grayscaleToRGB_: Pe });
|
|
|
651
651
|
function Fe(s) {
|
|
652
652
|
const e = u(s, "image", "RGBToGrayscale"), n = e.rank - 1, r = e.shape[n];
|
|
653
653
|
l(e.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`), l(r === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`);
|
|
654
|
-
const t = e.dtype, a =
|
|
654
|
+
const t = e.dtype, a = G(e, "float32"), o = I([0.2989, 0.587, 0.114]);
|
|
655
655
|
let i;
|
|
656
656
|
switch (e.rank) {
|
|
657
657
|
case 2:
|
|
@@ -672,7 +672,7 @@ function Fe(s) {
|
|
|
672
672
|
default:
|
|
673
673
|
throw new Error("Not a valid tensor rank.");
|
|
674
674
|
}
|
|
675
|
-
return i = z(i, -1),
|
|
675
|
+
return i = z(i, -1), G(i, t);
|
|
676
676
|
}
|
|
677
677
|
const We = /* @__PURE__ */ m({ rgbToGrayscale_: Fe });
|
|
678
678
|
/**
|
|
@@ -761,10 +761,10 @@ const Le = /* @__PURE__ */ m({ nonMaxSuppression_: Ce });
|
|
|
761
761
|
async function Xe(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY) {
|
|
762
762
|
const a = u(s, "boxes", "nonMaxSuppressionAsync"), o = u(e, "scores", "nonMaxSuppressionAsync"), i = R(a, o, n, r, t);
|
|
763
763
|
n = i.maxOutputSize, r = i.iouThreshold, t = i.scoreThreshold;
|
|
764
|
-
const p = await Promise.all([a.data(), o.data()]), c = p[0],
|
|
765
|
-
return a !== s && a.dispose(), o !== e && o.dispose(), I(
|
|
764
|
+
const p = await Promise.all([a.data(), o.data()]), c = p[0], h = p[1], { selectedIndices: b } = ne(c, h, n, r, t);
|
|
765
|
+
return a !== s && a.dispose(), o !== e && o.dispose(), I(b, "int32");
|
|
766
766
|
}
|
|
767
|
-
const
|
|
767
|
+
const Je = Xe;
|
|
768
768
|
/**
|
|
769
769
|
* @license
|
|
770
770
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -781,13 +781,13 @@ const Ze = Xe;
|
|
|
781
781
|
* limitations under the License.
|
|
782
782
|
* =============================================================================
|
|
783
783
|
*/
|
|
784
|
-
function
|
|
784
|
+
function Ze(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = 0) {
|
|
785
785
|
const o = u(s, "boxes", "nonMaxSuppression"), i = u(e, "scores", "nonMaxSuppression"), p = R(o, i, n, r, t, a);
|
|
786
786
|
n = p.maxOutputSize, r = p.iouThreshold, t = p.scoreThreshold, a = p.softNmsSigma;
|
|
787
|
-
const c = { boxes: o, scores: i },
|
|
788
|
-
return { selectedIndices:
|
|
787
|
+
const c = { boxes: o, scores: i }, h = { maxOutputSize: n, iouThreshold: r, scoreThreshold: t, softNmsSigma: a }, b = f.runKernel(Ln, c, h);
|
|
788
|
+
return { selectedIndices: b[0], selectedScores: b[1] };
|
|
789
789
|
}
|
|
790
|
-
const
|
|
790
|
+
const He = /* @__PURE__ */ m({ nonMaxSuppressionWithScore_: Ze });
|
|
791
791
|
/**
|
|
792
792
|
* @license
|
|
793
793
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -804,16 +804,16 @@ const Qe = /* @__PURE__ */ m({ nonMaxSuppressionWithScore_: Je });
|
|
|
804
804
|
* limitations under the License.
|
|
805
805
|
* =============================================================================
|
|
806
806
|
*/
|
|
807
|
-
async function
|
|
807
|
+
async function Qe(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = 0) {
|
|
808
808
|
const o = u(s, "boxes", "nonMaxSuppressionAsync"), i = u(e, "scores", "nonMaxSuppressionAsync"), p = R(o, i, n, r, t, a);
|
|
809
809
|
n = p.maxOutputSize, r = p.iouThreshold, t = p.scoreThreshold, a = p.softNmsSigma;
|
|
810
|
-
const c = await Promise.all([o.data(), i.data()]),
|
|
810
|
+
const c = await Promise.all([o.data(), i.data()]), h = c[0], b = c[1], { selectedIndices: g, selectedScores: d } = ee(h, b, n, r, t, a);
|
|
811
811
|
return o !== s && o.dispose(), i !== e && i.dispose(), {
|
|
812
812
|
selectedIndices: I(g, "int32"),
|
|
813
813
|
selectedScores: I(d)
|
|
814
814
|
};
|
|
815
815
|
}
|
|
816
|
-
const Ue =
|
|
816
|
+
const Ue = Qe;
|
|
817
817
|
/**
|
|
818
818
|
* @license
|
|
819
819
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -839,10 +839,10 @@ function ns(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = !1) {
|
|
|
839
839
|
t,
|
|
840
840
|
null
|
|
841
841
|
/* softNmsSigma */
|
|
842
|
-
), c = p.maxOutputSize,
|
|
842
|
+
), c = p.maxOutputSize, h = p.iouThreshold, b = p.scoreThreshold, g = { boxes: o, scores: i }, d = {
|
|
843
843
|
maxOutputSize: c,
|
|
844
|
-
iouThreshold:
|
|
845
|
-
scoreThreshold:
|
|
844
|
+
iouThreshold: h,
|
|
845
|
+
scoreThreshold: b,
|
|
846
846
|
padToMaxOutputSize: a
|
|
847
847
|
}, y = f.runKernel(Xn, g, d);
|
|
848
848
|
return { selectedIndices: y[0], validOutputs: y[1] };
|
|
@@ -873,7 +873,7 @@ async function ss(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = !1) {
|
|
|
873
873
|
t,
|
|
874
874
|
null
|
|
875
875
|
/* softNmsSigma */
|
|
876
|
-
), c = p.maxOutputSize,
|
|
876
|
+
), c = p.maxOutputSize, h = p.iouThreshold, b = p.scoreThreshold, [g, d] = await Promise.all([o.data(), i.data()]), { selectedIndices: y, validOutputs: M } = se(g, d, c, h, b, a);
|
|
877
877
|
return o !== s && o.dispose(), i !== e && i.dispose(), {
|
|
878
878
|
selectedIndices: I(y, "int32"),
|
|
879
879
|
validOutputs: pn(M, "int32")
|
|
@@ -901,7 +901,7 @@ function rs(s, e, n = !1, r = !1) {
|
|
|
901
901
|
l(t.rank === 3 || t.rank === 4, () => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${t.rank}.`), l(e.length === 2, () => `Error in resizeBilinear: new shape must 2D, but got shape ${e}.`), l(r === !1 || n === !1, () => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");
|
|
902
902
|
let a = t, o = !1;
|
|
903
903
|
t.rank === 3 && (o = !0, a = k(t, [1, t.shape[0], t.shape[1], t.shape[2]]));
|
|
904
|
-
const i = { images: a }, p = { alignCorners: n, halfPixelCenters: r, size: e }, c = f.runKernel(
|
|
904
|
+
const i = { images: a }, p = { alignCorners: n, halfPixelCenters: r, size: e }, c = f.runKernel(Jn, i, p);
|
|
905
905
|
return o ? k(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
|
|
906
906
|
}
|
|
907
907
|
const as = /* @__PURE__ */ m({ resizeBilinear_: rs });
|
|
@@ -926,7 +926,7 @@ function os(s, e, n = !1, r = !1) {
|
|
|
926
926
|
l(t.rank === 3 || t.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${t.rank}.`), l(e.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`), l(t.dtype === "float32" || t.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), l(r === !1 || n === !1, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");
|
|
927
927
|
let a = t, o = !1;
|
|
928
928
|
t.rank === 3 && (o = !0, a = k(t, [1, t.shape[0], t.shape[1], t.shape[2]]));
|
|
929
|
-
const i = { images: a }, p = { alignCorners: n, halfPixelCenters: r, size: e }, c = f.runKernel(
|
|
929
|
+
const i = { images: a }, p = { alignCorners: n, halfPixelCenters: r, size: e }, c = f.runKernel(Zn, i, p);
|
|
930
930
|
return o ? k(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
|
|
931
931
|
}
|
|
932
932
|
const is = /* @__PURE__ */ m({ resizeNearestNeighbor_: os });
|
|
@@ -948,32 +948,32 @@ const is = /* @__PURE__ */ m({ resizeNearestNeighbor_: os });
|
|
|
948
948
|
*/
|
|
949
949
|
function cs(s, e = "binary", n = !1, r = 0.5) {
|
|
950
950
|
const t = u(s, "image", "threshold"), a = 0.2989, o = 0.587, i = 0.114, p = t.shape[0] * t.shape[1];
|
|
951
|
-
let c = $(I([r]), 255),
|
|
951
|
+
let c = $(I([r]), 255), h, b, g, d;
|
|
952
952
|
if (l(t.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${t.rank}.`), l(t.shape[2] === 3 || t.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${t.shape[2]}.`), l(t.dtype === "int32" || t.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${t.dtype}.`), l(e === "otsu" || e === "binary", () => `Method must be binary or otsu, but was ${e}`), t.shape[2] === 3) {
|
|
953
|
-
[
|
|
954
|
-
const T = $(
|
|
953
|
+
[h, b, g] = mn(t, [1, 1, 1], -1);
|
|
954
|
+
const T = $(h, a), B = $(b, o), x = $(g, i);
|
|
955
955
|
d = U(U(T, B), x);
|
|
956
956
|
} else
|
|
957
957
|
d = s;
|
|
958
958
|
if (e === "otsu") {
|
|
959
|
-
const T = ce(
|
|
959
|
+
const T = ce(G(ze(d), "int32"), te([]), 256);
|
|
960
960
|
c = us(T, p);
|
|
961
961
|
}
|
|
962
|
-
const y = n ?
|
|
963
|
-
return
|
|
962
|
+
const y = n ? hn(d, c) : nn(d, c);
|
|
963
|
+
return G($(y, 255), "int32");
|
|
964
964
|
}
|
|
965
965
|
function us(s, e) {
|
|
966
|
-
let n = I([-1]), r = I([0]), t = I([0]), a, o, i, p, c,
|
|
967
|
-
for (let
|
|
968
|
-
a = _(s, 0,
|
|
966
|
+
let n = I([-1]), r = I([0]), t = I([0]), a, o, i, p, c, h;
|
|
967
|
+
for (let b = 0; b < s.size - 1; b++) {
|
|
968
|
+
a = _(s, 0, b + 1), o = _(s, b + 1), c = q(E(a), e), h = q(E(o), e);
|
|
969
969
|
const g = E($(a, W(0, a.size)));
|
|
970
970
|
i = q(g, E(a));
|
|
971
|
-
const d =
|
|
971
|
+
const d = Hn(o.shape, a.size), y = U(W(0, o.size), d), M = $(o, y);
|
|
972
972
|
p = q(E(M), E(o));
|
|
973
|
-
const T =
|
|
973
|
+
const T = N(i, p), B = N(i, p), x = $(c, h);
|
|
974
974
|
t = $($(x, T), B);
|
|
975
975
|
const V = nn(t, r);
|
|
976
|
-
r =
|
|
976
|
+
r = K(V, t, r), n = K(V, I([b]), n);
|
|
977
977
|
}
|
|
978
978
|
return n;
|
|
979
979
|
}
|
|
@@ -998,7 +998,7 @@ function ps(s, e, n = "nearest", r = "constant", t = 0, a) {
|
|
|
998
998
|
const o = u(s, "image", "transform", "float32"), i = u(e, "transforms", "transform", "float32");
|
|
999
999
|
l(o.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${o.rank}.`), l(i.rank === 2 && (i.shape[0] === o.shape[0] || i.shape[0] === 1) && i.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), l(a == null || a.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${a}.`);
|
|
1000
1000
|
const p = { image: o, transforms: i }, c = { interpolation: n, fillMode: r, fillValue: t, outputShape: a };
|
|
1001
|
-
return f.runKernel(
|
|
1001
|
+
return f.runKernel(Qn, p, c);
|
|
1002
1002
|
}
|
|
1003
1003
|
const ms = /* @__PURE__ */ m({ transform_: ps });
|
|
1004
1004
|
/**
|
|
@@ -1022,11 +1022,11 @@ function fs(s, e, n) {
|
|
|
1022
1022
|
l(r.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${r.rank}.`);
|
|
1023
1023
|
const t = r.shape, [a, o] = r.shape.slice(-2);
|
|
1024
1024
|
let i, p;
|
|
1025
|
-
typeof e == "number" ? (l(e % 1 === 0, () => `bandPart(): numLower must be an integer, got ${e}.`), l(e <= a, () => `bandPart(): numLower (${e}) must not be greater than the number of rows (${a}).`), i = u(e < 0 ? a : e, "numLower", "bandPart")) : (l(e.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i =
|
|
1026
|
-
const c = k(W(0, a, 1, "int32"), [-1, 1]),
|
|
1027
|
-
return k(Y(dn(k(r, [-1, a, o])).map((y) =>
|
|
1025
|
+
typeof e == "number" ? (l(e % 1 === 0, () => `bandPart(): numLower must be an integer, got ${e}.`), l(e <= a, () => `bandPart(): numLower (${e}) must not be greater than the number of rows (${a}).`), i = u(e < 0 ? a : e, "numLower", "bandPart")) : (l(e.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = K(on(e, 0), a, cn(e, a))), typeof n == "number" ? (l(n % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${n}.`), l(n <= o, () => `bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`), p = u(n < 0 ? o : n, "numUpper", "bandPart")) : (l(n.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), p = K(on(n, 0), o, cn(n, o)));
|
|
1026
|
+
const c = k(W(0, a, 1, "int32"), [-1, 1]), h = W(0, o, 1, "int32"), b = N(c, h), g = Te(hn(b, i), ke(b, en(p))), d = ae([a, o], r.dtype);
|
|
1027
|
+
return k(Y(dn(k(r, [-1, a, o])).map((y) => K(g, y, d))), t);
|
|
1028
1028
|
}
|
|
1029
|
-
const
|
|
1029
|
+
const bs = /* @__PURE__ */ m({ bandPart_: fs });
|
|
1030
1030
|
/**
|
|
1031
1031
|
* @license
|
|
1032
1032
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1043,7 +1043,7 @@ const hs = /* @__PURE__ */ m({ bandPart_: fs });
|
|
|
1043
1043
|
* limitations under the License.
|
|
1044
1044
|
* =============================================================================
|
|
1045
1045
|
*/
|
|
1046
|
-
function
|
|
1046
|
+
function hs(s) {
|
|
1047
1047
|
let e;
|
|
1048
1048
|
if (Array.isArray(s)) {
|
|
1049
1049
|
e = !1, l(s != null && s.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
|
|
@@ -1060,13 +1060,13 @@ function bs(s) {
|
|
|
1060
1060
|
if (t > 0)
|
|
1061
1061
|
for (let o = 0; o < t; ++o) {
|
|
1062
1062
|
const i = $(E($(n[o], a)), n[o]);
|
|
1063
|
-
a =
|
|
1063
|
+
a = N(a, i);
|
|
1064
1064
|
}
|
|
1065
|
-
return q(a,
|
|
1065
|
+
return q(a, bn(a, "euclidean"));
|
|
1066
1066
|
}));
|
|
1067
1067
|
return e ? Y(n, 0) : n;
|
|
1068
1068
|
}
|
|
1069
|
-
const ds = /* @__PURE__ */ m({ gramSchmidt_:
|
|
1069
|
+
const ds = /* @__PURE__ */ m({ gramSchmidt_: hs });
|
|
1070
1070
|
/**
|
|
1071
1071
|
* @license
|
|
1072
1072
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1093,8 +1093,8 @@ function gs(s, e = !1) {
|
|
|
1093
1093
|
s.shape[s.shape.length - 1]
|
|
1094
1094
|
]), 0), t = [], a = [];
|
|
1095
1095
|
r.forEach((p) => {
|
|
1096
|
-
const [c,
|
|
1097
|
-
t.push(c), a.push(
|
|
1096
|
+
const [c, h] = ln(p, e);
|
|
1097
|
+
t.push(c), a.push(h);
|
|
1098
1098
|
});
|
|
1099
1099
|
const o = k(Y(t, 0), s.shape), i = k(Y(a, 0), s.shape);
|
|
1100
1100
|
return [o, i];
|
|
@@ -1105,33 +1105,33 @@ function ln(s, e = !1) {
|
|
|
1105
1105
|
l(s.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${s.shape.length}D Tensor.`);
|
|
1106
1106
|
const n = s.shape[0], r = s.shape[1];
|
|
1107
1107
|
let t = de(n), a = X(s);
|
|
1108
|
-
const o =
|
|
1108
|
+
const o = Q([[1]], [1, 1]);
|
|
1109
1109
|
let i = X(o);
|
|
1110
1110
|
const p = n >= r ? r : n;
|
|
1111
1111
|
for (let c = 0; c < p; ++c) {
|
|
1112
|
-
const
|
|
1112
|
+
const h = a, b = i, g = t;
|
|
1113
1113
|
[i, a, t] = f.tidy(() => {
|
|
1114
|
-
const d = _(a, [c, c], [n - c, 1]), y =
|
|
1115
|
-
x.shape[0] === 1 ? i = X(o) : i =
|
|
1114
|
+
const d = _(a, [c, c], [n - c, 1]), y = bn(d), M = _(a, [c, c], [1, 1]), T = K(nn(M, 0), Q([[-1]]), Q([[1]])), B = N(M, $(T, y)), x = q(d, B);
|
|
1115
|
+
x.shape[0] === 1 ? i = X(o) : i = H([
|
|
1116
1116
|
o,
|
|
1117
1117
|
_(x, [1, 0], [x.shape[0] - 1, x.shape[1]])
|
|
1118
1118
|
], 0);
|
|
1119
|
-
const V = en(q(
|
|
1119
|
+
const V = en(q(A(T, B), y)), P = _(a, [c, 0], [n - c, r]), O = $(V, i), sn = un(i);
|
|
1120
1120
|
if (c === 0)
|
|
1121
|
-
a =
|
|
1121
|
+
a = N(P, A(O, A(sn, P)));
|
|
1122
1122
|
else {
|
|
1123
|
-
const C =
|
|
1124
|
-
a =
|
|
1123
|
+
const C = N(P, A(O, A(sn, P)));
|
|
1124
|
+
a = H([_(a, [0, 0], [c, r]), C], 0);
|
|
1125
1125
|
}
|
|
1126
1126
|
const tn = un(O), j = _(t, [0, c], [n, t.shape[1] - c]);
|
|
1127
1127
|
if (c === 0)
|
|
1128
|
-
t =
|
|
1128
|
+
t = N(j, A(A(j, i), tn));
|
|
1129
1129
|
else {
|
|
1130
|
-
const C =
|
|
1131
|
-
t =
|
|
1130
|
+
const C = N(j, A(A(j, i), tn));
|
|
1131
|
+
t = H([_(t, [0, 0], [n, c]), C], 1);
|
|
1132
1132
|
}
|
|
1133
1133
|
return [i, a, t];
|
|
1134
|
-
}), Un([
|
|
1134
|
+
}), Un([h, b, g]);
|
|
1135
1135
|
}
|
|
1136
1136
|
return !e && n > r && (t = _(t, [0, 0], [n, r]), a = _(a, [0, 0], [r, r])), [t, a];
|
|
1137
1137
|
});
|
|
@@ -1153,7 +1153,7 @@ const $s = /* @__PURE__ */ m({ qr_: gs });
|
|
|
1153
1153
|
* limitations under the License.
|
|
1154
1154
|
* =============================================================================
|
|
1155
1155
|
*/
|
|
1156
|
-
const
|
|
1156
|
+
const Gs = {
|
|
1157
1157
|
flipLeftRight: Ve,
|
|
1158
1158
|
grayscaleToRGB: je,
|
|
1159
1159
|
resizeNearestNeighbor: is,
|
|
@@ -1162,21 +1162,21 @@ const Ks = {
|
|
|
1162
1162
|
rotateWithOffset: Oe,
|
|
1163
1163
|
cropAndResize: De,
|
|
1164
1164
|
nonMaxSuppression: Le,
|
|
1165
|
-
nonMaxSuppressionAsync:
|
|
1166
|
-
nonMaxSuppressionWithScore:
|
|
1165
|
+
nonMaxSuppressionAsync: Je,
|
|
1166
|
+
nonMaxSuppressionWithScore: He,
|
|
1167
1167
|
nonMaxSuppressionWithScoreAsync: Ue,
|
|
1168
1168
|
nonMaxSuppressionPadded: es,
|
|
1169
1169
|
nonMaxSuppressionPaddedAsync: ts,
|
|
1170
1170
|
threshold: ls,
|
|
1171
1171
|
transform: ms
|
|
1172
1172
|
}, Rs = {
|
|
1173
|
-
bandPart:
|
|
1173
|
+
bandPart: bs,
|
|
1174
1174
|
gramSchmidt: ds,
|
|
1175
1175
|
qr: $s
|
|
1176
1176
|
};
|
|
1177
1177
|
export {
|
|
1178
1178
|
Te as a,
|
|
1179
|
-
|
|
1179
|
+
hn as b,
|
|
1180
1180
|
F as c,
|
|
1181
1181
|
nn as d,
|
|
1182
1182
|
on as e,
|
|
@@ -1184,12 +1184,12 @@ export {
|
|
|
1184
1184
|
ke as g,
|
|
1185
1185
|
I as h,
|
|
1186
1186
|
de as i,
|
|
1187
|
-
|
|
1187
|
+
Gs as j,
|
|
1188
1188
|
an as k,
|
|
1189
1189
|
Rs as l,
|
|
1190
1190
|
cn as m,
|
|
1191
1191
|
en as n,
|
|
1192
|
-
|
|
1192
|
+
bn as o,
|
|
1193
1193
|
Ee as p,
|
|
1194
1194
|
as as q,
|
|
1195
1195
|
Se as r,
|
|
@@ -1197,6 +1197,6 @@ export {
|
|
|
1197
1197
|
un as t,
|
|
1198
1198
|
dn as u,
|
|
1199
1199
|
is as v,
|
|
1200
|
-
|
|
1200
|
+
K as w,
|
|
1201
1201
|
ze as x
|
|
1202
1202
|
};
|