@genai-fi/nanogpt 0.18.1 → 0.19.1
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 +30 -30
- package/dist/{RealDiv-ioj6Z-ox.js → RealDiv-CGwv0liw.js} +9 -9
- package/dist/{Reshape-BZC-ebeR.js → Reshape-BW__R4mZ.js} +7 -7
- package/dist/{Reshape-pwprEaej.js → Reshape-CPBkTIH2.js} +1 -1
- package/dist/TeachableLLM.js +17 -17
- package/dist/Trainer.js +97 -95
- package/dist/{axis_util-QWWgLjut.js → axis_util-GTVlo58H.js} +1 -1
- package/dist/backend.js +2 -2
- package/dist/{backend_util-qwSFfxYx.js → backend_util-GaFarB78.js} +21 -21
- package/dist/{backend_webgpu-DI2wXEC2.js → backend_webgpu-BqASlsbV.js} +8 -8
- package/dist/{broadcast_to-C_EJTVTZ.js → broadcast_to-eS93CCN_.js} +2 -2
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +5 -5
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/matMulGelu.js +2 -2
- package/dist/checks/normRMS.js +6 -6
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.js +6 -6
- package/dist/checks/qkv.js +2 -2
- package/dist/checks/rope.js +2 -2
- package/dist/{clip_by_value-CLAD4h_I.js → clip_by_value-DDA7rrcT.js} +1 -1
- package/dist/complex-DI35Q-gW.js +11 -0
- package/dist/{concat-Dqk7Xk7h.js → concat-CAQpCret.js} +5 -5
- package/dist/{concat_util-C1Mxe27t.js → concat_util-D18dJ4fD.js} +1 -1
- package/dist/data/textLoader.d.ts +1 -1
- package/dist/data/textLoader.js +68 -58
- package/dist/{dataset-DlqAN81i.js → dataset-CGGp1z9P.js} +3 -3
- package/dist/{dropout_util-N0z8Os-K.js → dropout_util--NxWuYg2.js} +1 -1
- package/dist/{expand_dims-D0rBtgT1.js → expand_dims-Bkd1YD5x.js} +4 -4
- package/dist/{exports_initializers-DIOZQt_L.js → exports_initializers-CYzKLjN7.js} +1 -1
- package/dist/{floor-CymuCmTO.js → floor-BQtb-Azg.js} +1 -1
- package/dist/{gather-DEyjXNb1.js → gather-qIqEqaGn.js} +1 -1
- package/dist/{gelu-DpTCC3eB.js → gelu-B220X1Go.js} +1 -1
- package/dist/{gpgpu_math-3bCb5ooU.js → gpgpu_math-BwvV12df.js} +25 -25
- package/dist/{index-DSGwv2Yx.js → index-CUXkjxiT.js} +33 -33
- package/dist/{index-BQvB7LCC.js → index-CjOWnMXP.js} +15 -15
- package/dist/{kernel_funcs_utils-DGqzNlHT.js → kernel_funcs_utils-pq0CK9co.js} +6 -6
- package/dist/layers/BaseLayer.js +4 -4
- package/dist/layers/CausalSelfAttention.d.ts +1 -0
- package/dist/layers/CausalSelfAttention.js +14 -14
- package/dist/layers/LoRA.js +4 -4
- package/dist/layers/MLP.js +4 -4
- package/dist/layers/PositionEmbedding.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.js +6 -6
- package/dist/layers/TransformerBlock.d.ts +1 -0
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/layers/WeightStore.js +2 -2
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +9 -9
- package/dist/loader/save.js +38 -31
- package/dist/main.js +9 -9
- package/dist/{matMul16-BIT70Vya.js → matMul16-BcVC_E62.js} +3 -3
- package/dist/{matMulGelu-CsZnh18H.js → matMulGelu-JNLZqKQp.js} +18 -18
- package/dist/mat_mul-DhG0Newp.js +11 -0
- package/dist/mod-CSdCpRjf.js +11 -0
- package/dist/models/NanoGPTV1.js +2 -2
- package/dist/models/NanoGPTV2.js +2 -2
- package/dist/models/model.d.ts +1 -0
- package/dist/models/model.js +9 -9
- package/dist/{not_equal-CkQKkKZy.js → not_equal-hurPF26l.js} +15 -15
- package/dist/{ones-DbVB5N58.js → ones-BytntneX.js} +3 -3
- package/dist/ops/adamAdjust.js +3 -3
- package/dist/ops/adamMoments.js +3 -3
- package/dist/ops/add16.js +1 -1
- package/dist/ops/appendCache.js +6 -6
- package/dist/ops/attentionMask.js +3 -3
- package/dist/ops/concat16.js +3 -3
- package/dist/ops/cpu/adamAdjust.js +9 -9
- package/dist/ops/cpu/adamMoments.js +5 -5
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +6 -6
- package/dist/ops/cpu/fusedSoftmax.js +4 -4
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +4 -4
- package/dist/ops/cpu/matMul16.js +2 -2
- package/dist/ops/cpu/matMulGelu.js +7 -7
- package/dist/ops/cpu/matMulMul.js +2 -2
- package/dist/ops/cpu/mulDropout.js +5 -5
- 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 +5 -5
- package/dist/ops/dot16.js +2 -2
- package/dist/ops/dropout.js +6 -6
- package/dist/ops/dropout16.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/globalNorm.js +7 -7
- package/dist/ops/grads/add16.js +1 -1
- package/dist/ops/grads/attentionMask.js +2 -2
- package/dist/ops/grads/dropout16.js +1 -1
- package/dist/ops/grads/gelu.js +2 -2
- package/dist/ops/grads/matMul16.js +3 -3
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/mul16.js +1 -1
- package/dist/ops/grads/normRMS.js +7 -7
- package/dist/ops/grads/pack16.js +3 -3
- package/dist/ops/grads/qkv.js +11 -11
- package/dist/ops/grads/rope.js +2 -2
- package/dist/ops/grads/softmax16.js +1 -1
- package/dist/ops/grads/unpack16.js +2 -2
- package/dist/ops/matMul16.js +3 -3
- package/dist/ops/matMulGelu.js +6 -6
- package/dist/ops/matMulMul.js +3 -3
- package/dist/ops/mul16.js +1 -1
- package/dist/ops/mulDrop.js +3 -3
- package/dist/ops/normRMS.js +4 -4
- package/dist/ops/pack16.js +2 -2
- package/dist/ops/qkv.js +3 -3
- package/dist/ops/reshape16.js +6 -6
- package/dist/ops/rope.js +2 -2
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.js +2 -2
- package/dist/ops/softmax16.js +1 -1
- package/dist/ops/sub16.js +1 -1
- package/dist/ops/sum16.js +6 -6
- package/dist/ops/transpose16.js +3 -3
- package/dist/ops/unpack16.js +2 -2
- 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/dropout16.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +7 -7
- package/dist/ops/webgl/gatherSub.js +3 -3
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMul16.js +13 -13
- package/dist/ops/webgl/matMulGelu.js +4 -4
- package/dist/ops/webgl/matMulMul.js +2 -2
- 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 +2 -2
- package/dist/ops/webgpu/adamAdjust.js +3 -3
- package/dist/ops/webgpu/adamMoments.js +3 -3
- package/dist/ops/webgpu/add16.js +6 -6
- package/dist/ops/webgpu/appendCache.js +3 -3
- package/dist/ops/webgpu/attentionMask.js +2 -2
- package/dist/ops/webgpu/attentionMask32_program.js +2 -2
- package/dist/ops/webgpu/clipScale.js +7 -7
- package/dist/ops/webgpu/concat16.js +5 -5
- package/dist/ops/webgpu/dropout16.js +6 -6
- package/dist/ops/webgpu/gatherSub.js +3 -3
- package/dist/ops/webgpu/gelu.js +8 -8
- package/dist/ops/webgpu/matMul16.js +16 -16
- package/dist/ops/webgpu/matMul16_program.js +2 -2
- package/dist/ops/webgpu/mul16.js +5 -5
- package/dist/ops/webgpu/norm2.js +1 -1
- package/dist/ops/webgpu/normRMS.js +2 -2
- package/dist/ops/webgpu/normRMSGrad.js +4 -4
- package/dist/ops/webgpu/pack16.js +4 -4
- package/dist/ops/webgpu/pack16_program.js +2 -2
- package/dist/ops/webgpu/qkv.js +2 -2
- package/dist/ops/webgpu/rope.js +3 -3
- package/dist/ops/webgpu/scatterSub.js +3 -3
- package/dist/ops/webgpu/slice16.js +4 -4
- package/dist/ops/webgpu/softmax16.js +4 -4
- 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 +4 -4
- package/dist/ops/webgpu/sub16.js +6 -6
- package/dist/ops/webgpu/sum16.js +3 -3
- package/dist/ops/webgpu/transpose16.js +8 -8
- package/dist/ops/webgpu/transpose16_program.js +2 -2
- package/dist/ops/webgpu/transpose16_shared_program.js +3 -3
- package/dist/ops/webgpu/unpack16.js +3 -3
- package/dist/ops/webgpu/utils/binary_op.js +3 -3
- package/dist/ops/webgpu/utils/reductions.js +5 -5
- package/dist/{ops-CURIZSVt.js → ops-CsXeTq1P.js} +100 -100
- package/dist/{pack16-WlOSOuZA.js → pack16-bqltoUlR.js} +2 -2
- package/dist/patches/webgpu_backend.js +6 -6
- package/dist/patches/webgpu_base.js +1 -1
- package/dist/patches/webgpu_program.js +2 -2
- package/dist/{random_normal-CIm8lk2-.js → random_normal-IBRrha8a.js} +1 -1
- package/dist/{random_width-B_fVXhGx.js → random_width-DN5ZtQkM.js} +131 -131
- package/dist/{range-BDxO73mk.js → range-C-CjF-LI.js} +1 -1
- package/dist/relu-J_X6MUzx.js +9 -0
- package/dist/{reshape-BIN71H3p.js → reshape-BDOuCSNW.js} +1 -1
- package/dist/{resize_nearest_neighbor-C6_0dAnK.js → resize_nearest_neighbor-BojqlfRe.js} +41 -41
- package/dist/{rope-CC5RjmKU.js → rope-DcrZM_e6.js} +5 -5
- package/dist/{scatter_nd_util-C-x73Cj6.js → scatter_nd_util-ByNJaL6I.js} +1 -1
- package/dist/{segment_util-4zuHV5IG.js → segment_util-Dasb2Zaf.js} +2 -2
- package/dist/{selu_util-BXdhy_W6.js → selu_util-BLhIqRkw.js} +5 -5
- package/dist/{shared-zTaJ5siv.js → shared-3agzAqQ_.js} +1 -1
- package/dist/{shared-DRWDyk9w.js → shared-CagdqkLh.js} +6 -6
- package/dist/slice-BzS11Qh0.js +12 -0
- package/dist/{slice_util-DPY56GzQ.js → slice_util-CC35pLmT.js} +5 -5
- package/dist/{softmax-BLGJqdwx.js → softmax-D4q1LJN7.js} +1 -1
- package/dist/split-C2Sj255c.js +9 -0
- package/dist/{squeeze-O_YWJpw_.js → squeeze-ho4wLUek.js} +2 -2
- package/dist/{stack-z6QE7kmP.js → stack-DudVrtmG.js} +1 -1
- package/dist/{step-DQY6_ABw.js → step-BTxPtq1r.js} +4 -4
- package/dist/{sum-D39FeU5h.js → sum-BpiwSWvg.js} +3 -3
- package/dist/{tensor-D8e0Gd7c.js → tensor-BWFldCso.js} +1 -1
- package/dist/{tensor1d-BMl0eZYV.js → tensor1d-LMGMIUlr.js} +1 -1
- package/dist/{tensor2d-DTtQ1QcT.js → tensor2d-BnXMKScO.js} +1 -1
- package/dist/{tensor4d-Dj4rDssL.js → tensor4d-C6UCG_u8.js} +1 -1
- package/dist/{tfjs_backend-Bk3PmK91.js → tfjs_backend-BGnG-ppu.js} +65 -65
- package/dist/{tile-CsWlVKKz.js → tile-CFy-xTO6.js} +1 -1
- package/dist/tokeniser/BaseTokeniser.d.ts +4 -0
- package/dist/tokeniser/BaseTokeniser.js +61 -56
- package/dist/tokeniser/type.d.ts +8 -0
- package/dist/training/AdamW.js +2 -2
- package/dist/training/BasicTrainer.d.ts +1 -0
- package/dist/training/BasicTrainer.js +95 -79
- package/dist/training/DatasetBuilder.d.ts +6 -2
- package/dist/training/DatasetBuilder.js +60 -41
- package/dist/training/Evaluator.d.ts +1 -2
- package/dist/training/Evaluator.js +21 -31
- package/dist/training/SFTTrainer.d.ts +3 -2
- package/dist/training/SFTTrainer.js +4 -3
- package/dist/training/orthoGrad.js +1 -1
- package/dist/training/sparseCrossEntropy.js +38 -38
- package/dist/training/tasks/ConversationTask.d.ts +4 -0
- package/dist/training/tasks/ConversationTask.js +7 -7
- package/dist/training/tasks/PretrainingTask.d.ts +4 -0
- package/dist/training/tasks/PretrainingTask.js +11 -7
- package/dist/training/tasks/StartSentenceTask.d.ts +4 -0
- package/dist/training/tasks/StartSentenceTask.js +5 -5
- package/dist/training/tasks/Task.d.ts +12 -0
- package/dist/training/tasks/Task.js +55 -31
- package/dist/training/types.d.ts +1 -0
- package/dist/training/validation.d.ts +1 -1
- package/dist/training/validation.js +33 -32
- package/dist/{transpose-Qxz-4os3.js → transpose-9kRxIXWR.js} +7 -7
- package/dist/{unsorted_segment_sum-BfFVV9Zm.js → unsorted_segment_sum-DJvk5xnh.js} +20 -20
- package/dist/utilities/dummy.js +6 -6
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.js +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/sentences.js +5 -5
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-SSATClyt.js → variable-Ck482e3n.js} +1 -1
- package/dist/{webgpu_program-CbjdYLYk.js → webgpu_program-B4HmApL1.js} +1 -1
- package/dist/{webgpu_util-DuofJBMo.js → webgpu_util-DYlGSwOJ.js} +7 -7
- package/dist/{zeros-Bw0puq_w.js → zeros-DvZpK8s6.js} +2 -2
- package/dist/{zeros_like-rOHr54NY.js → zeros_like-CWjDdwr-.js} +69 -69
- package/package.json +1 -1
- package/dist/complex-3DpPEG9B.js +0 -11
- package/dist/mat_mul-DP86qZtZ.js +0 -11
- package/dist/mod-BXjLYwvM.js +0 -11
- package/dist/readers-17HLdxVM.js +0 -12
- package/dist/relu-DTvZKBsZ.js +0 -9
- package/dist/slice-BvItlgXu.js +0 -12
- package/dist/split-BN9LkEgS.js +0 -9
- package/dist/training/SFTDatasetBuilder.d.ts +0 -23
- package/dist/training/SFTDatasetBuilder.js +0 -85
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { o as
|
|
2
|
-
import { t as
|
|
3
|
-
import { e as R } from "./expand_dims-
|
|
4
|
-
import { t as x } from "./tensor1d-
|
|
1
|
+
import { o as h, q as u, x as p, E as k, bd as ds, be as hs, a5 as bs, bf as gs, bg as Es, L as W, bh as $s, bi as ys, bj as _s, bk as Ns, a as $, m as d, j as G, i as S, f as Ss, a1 as b, bl as ks, w as K, d as Is, a6 as L, a_ as ns, n as Ts, a2 as Ms } from "./index-CUXkjxiT.js";
|
|
2
|
+
import { t as v } from "./tile-CFy-xTO6.js";
|
|
3
|
+
import { e as R } from "./expand_dims-Bkd1YD5x.js";
|
|
4
|
+
import { t as x } from "./tensor1d-LMGMIUlr.js";
|
|
5
5
|
import { n as xs, a as As, b as ws } from "./non_max_suppression_impl-B2W7YjZB.js";
|
|
6
|
-
import { r as Os, l as ls, g as es, a as rs, m as Q, b as Gs, c as Ls, u as us, n as ps, s as Bs, d as Ds, e as Ws, f as Rs } from "./resize_nearest_neighbor-
|
|
7
|
-
import { s as ms } from "./split-
|
|
8
|
-
import { s as _ } from "./sum-
|
|
9
|
-
import { w as q, a as qs, n as zs, b as as, e as ss, l as Vs } from "./not_equal-
|
|
10
|
-
import { s as T } from "./slice-
|
|
11
|
-
import { r as F } from "./range-
|
|
12
|
-
import { t as Cs } from "./tensor-
|
|
13
|
-
import { n as C, t as is } from "./transpose-
|
|
14
|
-
import { r as O } from "./reshape-
|
|
15
|
-
import { s as U } from "./stack-
|
|
16
|
-
import { z as
|
|
17
|
-
import { s as
|
|
18
|
-
import { c as
|
|
19
|
-
import { m as w } from "./mat_mul-
|
|
20
|
-
import { t as
|
|
21
|
-
import { o as
|
|
22
|
-
import { r as fs } from "./relu-
|
|
23
|
-
import { e as
|
|
6
|
+
import { r as Os, l as ls, g as es, a as rs, m as Q, b as Gs, c as Ls, u as us, n as ps, s as Bs, d as Ds, e as Ws, f as Rs } from "./resize_nearest_neighbor-BojqlfRe.js";
|
|
7
|
+
import { s as ms } from "./split-C2Sj255c.js";
|
|
8
|
+
import { s as _ } from "./sum-BpiwSWvg.js";
|
|
9
|
+
import { w as q, a as qs, n as zs, b as as, e as ss, l as Vs } from "./not_equal-hurPF26l.js";
|
|
10
|
+
import { s as T } from "./slice-BzS11Qh0.js";
|
|
11
|
+
import { r as F } from "./range-C-CjF-LI.js";
|
|
12
|
+
import { t as Cs } from "./tensor-BWFldCso.js";
|
|
13
|
+
import { n as C, t as is } from "./transpose-9kRxIXWR.js";
|
|
14
|
+
import { r as O } from "./reshape-BDOuCSNW.js";
|
|
15
|
+
import { s as U } from "./stack-DudVrtmG.js";
|
|
16
|
+
import { z as Ps } from "./zeros-DvZpK8s6.js";
|
|
17
|
+
import { s as Ys } from "./squeeze-ho4wLUek.js";
|
|
18
|
+
import { c as X } from "./concat-CAQpCret.js";
|
|
19
|
+
import { m as w } from "./mat_mul-DhG0Newp.js";
|
|
20
|
+
import { t as J } from "./tensor2d-BnXMKScO.js";
|
|
21
|
+
import { o as js } from "./ones-BytntneX.js";
|
|
22
|
+
import { r as fs } from "./relu-J_X6MUzx.js";
|
|
23
|
+
import { e as vs } from "./axis_util-GTVlo58H.js";
|
|
24
24
|
function Fs(t, a, n) {
|
|
25
25
|
const r = u(t, "x", "bincount"), e = u(a, "weights", "bincount");
|
|
26
26
|
p(r.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${r.dtype}`), p(n >= 0, () => `size must be non-negative, but got ${n}.`), p(e.size === r.size || e.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${e.shape}.`);
|
|
27
27
|
const s = { x: r, weights: e }, o = { size: n };
|
|
28
|
-
return k.runKernel(
|
|
28
|
+
return k.runKernel(ds, s, o);
|
|
29
29
|
}
|
|
30
|
-
const Us = /* @__PURE__ */
|
|
30
|
+
const Us = /* @__PURE__ */ h({ bincount_: Fs });
|
|
31
31
|
function Zs(t, ...a) {
|
|
32
32
|
const n = a.map((e, s) => u(e, `tensors${s}`, "einsum")), r = { equation: t };
|
|
33
|
-
return k.runKernel(
|
|
33
|
+
return k.runKernel(hs, n, r);
|
|
34
34
|
}
|
|
35
|
-
const V = /* @__PURE__ */
|
|
35
|
+
const V = /* @__PURE__ */ h({ einsum_: Zs });
|
|
36
36
|
function Hs(t, a, n, r = "float32") {
|
|
37
37
|
a == null && (a = t);
|
|
38
38
|
const e = bs([t, a], r), s = t <= a ? t : a;
|
|
@@ -42,11 +42,11 @@ function Hs(t, a, n, r = "float32") {
|
|
|
42
42
|
if (n == null)
|
|
43
43
|
return o;
|
|
44
44
|
if (n.length === 1)
|
|
45
|
-
return
|
|
45
|
+
return v(R(o, 0), [n[0], 1, 1]);
|
|
46
46
|
if (n.length === 2)
|
|
47
|
-
return
|
|
47
|
+
return v(R(R(o, 0), 0), [n[0], n[1], 1, 1]);
|
|
48
48
|
if (n.length === 3)
|
|
49
|
-
return
|
|
49
|
+
return v(R(R(R(o, 0), 0), 0), [
|
|
50
50
|
n[0],
|
|
51
51
|
n[1],
|
|
52
52
|
n[2],
|
|
@@ -55,28 +55,28 @@ function Hs(t, a, n, r = "float32") {
|
|
|
55
55
|
]);
|
|
56
56
|
throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`);
|
|
57
57
|
}
|
|
58
|
-
const Ks = /* @__PURE__ */
|
|
59
|
-
function
|
|
58
|
+
const Ks = /* @__PURE__ */ h({ eye_: Hs });
|
|
59
|
+
function Xs(t, a, n, r, e = "bilinear", s = 0) {
|
|
60
60
|
const o = u(t, "image", "cropAndResize"), i = u(a, "boxes", "cropAndResize", "float32"), l = u(n, "boxInd", "cropAndResize", "int32"), c = i.shape[0];
|
|
61
61
|
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(l.rank === 1 && l.shape[0] === c, () => `Error in cropAndResize: boxInd must be have size [${c}] but had shape ${i.shape}.`), p(r.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`), p(r[0] >= 1 && r[1] >= 1, () => `cropSize must be atleast [1,1], but was ${r}`), p(e === "bilinear" || e === "nearest", () => `method must be bilinear or nearest, but was ${e}`);
|
|
62
62
|
const f = { image: o, boxes: i, boxInd: l }, m = { method: e, extrapolationValue: s, cropSize: r };
|
|
63
63
|
return k.runKernel(gs, f, m);
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const Js = /* @__PURE__ */ h({ cropAndResize_: Xs });
|
|
66
66
|
function Qs(t) {
|
|
67
67
|
const a = u(t, "image", "flipLeftRight", "float32");
|
|
68
68
|
p(a.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${a.rank}.`);
|
|
69
69
|
const n = { image: a };
|
|
70
70
|
return k.runKernel(Es, n, {});
|
|
71
71
|
}
|
|
72
|
-
const sn = /* @__PURE__ */
|
|
72
|
+
const sn = /* @__PURE__ */ h({ flipLeftRight_: Qs });
|
|
73
73
|
function nn(t) {
|
|
74
74
|
const a = u(t, "image", "grayscaleToRGB"), n = a.rank - 1, r = a.shape[n];
|
|
75
75
|
p(a.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${a.rank}.`), p(r === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);
|
|
76
76
|
const e = new Array(a.rank);
|
|
77
|
-
return e.fill(1, 0, n), e[n] = 3,
|
|
77
|
+
return e.fill(1, 0, n), e[n] = 3, v(a, e);
|
|
78
78
|
}
|
|
79
|
-
const en = /* @__PURE__ */
|
|
79
|
+
const en = /* @__PURE__ */ h({ grayscaleToRGB_: nn });
|
|
80
80
|
function tn(t) {
|
|
81
81
|
const a = u(t, "image", "RGBToGrayscale"), n = a.rank - 1, r = a.shape[n];
|
|
82
82
|
p(a.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${a.rank}.`), p(r === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`);
|
|
@@ -103,14 +103,14 @@ function tn(t) {
|
|
|
103
103
|
}
|
|
104
104
|
return i = R(i, -1), W(i, e);
|
|
105
105
|
}
|
|
106
|
-
const on = /* @__PURE__ */
|
|
106
|
+
const on = /* @__PURE__ */ h({ rgbToGrayscale_: tn });
|
|
107
107
|
function rn(t, a, n = 0, r = 0.5) {
|
|
108
108
|
const e = u(t, "image", "rotateWithOffset", "float32");
|
|
109
109
|
p(e.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${e.rank}.`);
|
|
110
110
|
const s = { image: e }, o = { radians: a, fillValue: n, center: r };
|
|
111
111
|
return k.runKernel($s, s, o);
|
|
112
112
|
}
|
|
113
|
-
const an = /* @__PURE__ */
|
|
113
|
+
const an = /* @__PURE__ */ h({ rotateWithOffset_: rn });
|
|
114
114
|
function z(t, a, n, r, e, s) {
|
|
115
115
|
r == null && (r = 0.5), e == null && (e = Number.NEGATIVE_INFINITY), s == null && (s = 0);
|
|
116
116
|
const o = t.shape[0];
|
|
@@ -122,7 +122,7 @@ function cn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY) {
|
|
|
122
122
|
const l = { maxOutputSize: n, iouThreshold: r, scoreThreshold: e };
|
|
123
123
|
return k.runKernel(ys, { boxes: s, scores: o }, l);
|
|
124
124
|
}
|
|
125
|
-
const ln = /* @__PURE__ */
|
|
125
|
+
const ln = /* @__PURE__ */ h({ nonMaxSuppression_: cn });
|
|
126
126
|
async function un(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY) {
|
|
127
127
|
const s = u(t, "boxes", "nonMaxSuppressionAsync"), o = u(a, "scores", "nonMaxSuppressionAsync"), i = z(s, o, n, r, e);
|
|
128
128
|
n = i.maxOutputSize, r = i.iouThreshold, e = i.scoreThreshold;
|
|
@@ -136,8 +136,8 @@ function mn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = 0) {
|
|
|
136
136
|
const c = { boxes: o, scores: i }, f = { maxOutputSize: n, iouThreshold: r, scoreThreshold: e, softNmsSigma: s }, m = k.runKernel(_s, c, f);
|
|
137
137
|
return { selectedIndices: m[0], selectedScores: m[1] };
|
|
138
138
|
}
|
|
139
|
-
const fn = /* @__PURE__ */
|
|
140
|
-
async function
|
|
139
|
+
const fn = /* @__PURE__ */ h({ nonMaxSuppressionWithScore_: mn });
|
|
140
|
+
async function dn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = 0) {
|
|
141
141
|
const o = u(t, "boxes", "nonMaxSuppressionAsync"), i = u(a, "scores", "nonMaxSuppressionAsync"), l = z(o, i, n, r, e, s);
|
|
142
142
|
n = l.maxOutputSize, r = l.iouThreshold, e = l.scoreThreshold, s = l.softNmsSigma;
|
|
143
143
|
const c = await Promise.all([o.data(), i.data()]), f = c[0], m = c[1], { selectedIndices: E, selectedScores: g } = As(f, m, n, r, e, s);
|
|
@@ -146,7 +146,7 @@ async function hn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = 0) {
|
|
|
146
146
|
selectedScores: x(g)
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
const
|
|
149
|
+
const hn = dn;
|
|
150
150
|
function bn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = !1) {
|
|
151
151
|
const o = u(t, "boxes", "nonMaxSuppression"), i = u(a, "scores", "nonMaxSuppression"), l = z(
|
|
152
152
|
o,
|
|
@@ -164,7 +164,7 @@ function bn(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = !1) {
|
|
|
164
164
|
}, y = k.runKernel(Ns, E, g);
|
|
165
165
|
return { selectedIndices: y[0], validOutputs: y[1] };
|
|
166
166
|
}
|
|
167
|
-
const gn = /* @__PURE__ */
|
|
167
|
+
const gn = /* @__PURE__ */ h({ nonMaxSuppressionPadded_: bn });
|
|
168
168
|
async function En(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = !1) {
|
|
169
169
|
const o = u(t, "boxes", "nonMaxSuppressionAsync"), i = u(a, "scores", "nonMaxSuppressionAsync"), l = z(
|
|
170
170
|
o,
|
|
@@ -183,10 +183,10 @@ async function En(t, a, n, r = 0.5, e = Number.NEGATIVE_INFINITY, s = !1) {
|
|
|
183
183
|
const $n = En;
|
|
184
184
|
function yn(t, a = "binary", n = !1, r = 0.5) {
|
|
185
185
|
const e = u(t, "image", "threshold"), s = 0.2989, o = 0.587, i = 0.114, l = e.shape[0] * e.shape[1];
|
|
186
|
-
let c =
|
|
186
|
+
let c = d(x([r]), 255), f, m, E, g;
|
|
187
187
|
if (p(e.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${e.rank}.`), p(e.shape[2] === 3 || e.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${e.shape[2]}.`), p(e.dtype === "int32" || e.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${e.dtype}.`), p(a === "otsu" || a === "binary", () => `Method must be binary or otsu, but was ${a}`), e.shape[2] === 3) {
|
|
188
188
|
[f, m, E] = ms(e, [1, 1, 1], -1);
|
|
189
|
-
const I =
|
|
189
|
+
const I = d(f, s), A = d(m, o), D = d(E, i);
|
|
190
190
|
g = G(G(I, A), D);
|
|
191
191
|
} else
|
|
192
192
|
g = t;
|
|
@@ -195,41 +195,41 @@ function yn(t, a = "binary", n = !1, r = 0.5) {
|
|
|
195
195
|
c = _n(I, l);
|
|
196
196
|
}
|
|
197
197
|
const y = n ? ls(g, c) : es(g, c);
|
|
198
|
-
return W(
|
|
198
|
+
return W(d(y, 255), "int32");
|
|
199
199
|
}
|
|
200
200
|
function _n(t, a) {
|
|
201
201
|
let n = x([-1]), r = x([0]), e = x([0]), s, o, i, l, c, f;
|
|
202
202
|
for (let m = 0; m < t.size - 1; m++) {
|
|
203
203
|
s = T(t, 0, m + 1), o = T(t, m + 1), c = S(_(s), a), f = S(_(o), a);
|
|
204
|
-
const E = _(
|
|
204
|
+
const E = _(d(s, F(0, s.size)));
|
|
205
205
|
i = S(E, _(s));
|
|
206
|
-
const g = Ss(o.shape, s.size), y = G(F(0, o.size), g), M =
|
|
206
|
+
const g = Ss(o.shape, s.size), y = G(F(0, o.size), g), M = d(o, y);
|
|
207
207
|
l = S(_(M), _(o));
|
|
208
|
-
const I = b(i, l), A = b(i, l), D =
|
|
209
|
-
e =
|
|
210
|
-
const
|
|
211
|
-
r = q(
|
|
208
|
+
const I = b(i, l), A = b(i, l), D = d(c, f);
|
|
209
|
+
e = d(d(D, I), A);
|
|
210
|
+
const P = es(e, r);
|
|
211
|
+
r = q(P, e, r), n = q(P, x([m]), n);
|
|
212
212
|
}
|
|
213
213
|
return n;
|
|
214
214
|
}
|
|
215
|
-
const Nn = /* @__PURE__ */
|
|
215
|
+
const Nn = /* @__PURE__ */ h({ threshold_: yn });
|
|
216
216
|
function Sn(t, a, n = "nearest", r = "constant", e = 0, s) {
|
|
217
217
|
const o = u(t, "image", "transform", "float32"), i = u(a, "transforms", "transform", "float32");
|
|
218
218
|
p(o.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${o.rank}.`), p(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"), p(s == null || s.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${s}.`);
|
|
219
219
|
const l = { image: o, transforms: i }, c = { interpolation: n, fillMode: r, fillValue: e, outputShape: s };
|
|
220
220
|
return k.runKernel(ks, l, c);
|
|
221
221
|
}
|
|
222
|
-
const kn = /* @__PURE__ */
|
|
222
|
+
const kn = /* @__PURE__ */ h({ transform_: Sn });
|
|
223
223
|
function In(t, a, n) {
|
|
224
224
|
const r = u(t, "a", "bandPart");
|
|
225
225
|
p(r.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${r.rank}.`);
|
|
226
226
|
const e = r.shape, [s, o] = r.shape.slice(-2);
|
|
227
227
|
let i, l;
|
|
228
228
|
typeof a == "number" ? (p(a % 1 === 0, () => `bandPart(): numLower must be an integer, got ${a}.`), p(a <= s, () => `bandPart(): numLower (${a}) must not be greater than the number of rows (${s}).`), i = u(a < 0 ? s : a, "numLower", "bandPart")) : (p(a.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = q(rs(a, 0), s, Q(a, s))), 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}).`), l = u(n < 0 ? o : n, "numUpper", "bandPart")) : (p(n.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), l = q(rs(n, 0), o, Q(n, o)));
|
|
229
|
-
const c = O(F(0, s, 1, "int32"), [-1, 1]), f = F(0, o, 1, "int32"), m = b(c, f), E = Gs(ls(m, i), Ls(m, C(l))), g =
|
|
229
|
+
const c = O(F(0, s, 1, "int32"), [-1, 1]), f = F(0, o, 1, "int32"), m = b(c, f), E = Gs(ls(m, i), Ls(m, C(l))), g = Ps([s, o], r.dtype);
|
|
230
230
|
return O(U(us(O(r, [-1, s, o])).map((y) => q(E, y, g))), e);
|
|
231
231
|
}
|
|
232
|
-
const Tn = /* @__PURE__ */
|
|
232
|
+
const Tn = /* @__PURE__ */ h({ bandPart_: In });
|
|
233
233
|
function Mn(t) {
|
|
234
234
|
let a;
|
|
235
235
|
if (Array.isArray(t)) {
|
|
@@ -238,7 +238,7 @@ function Mn(t) {
|
|
|
238
238
|
for (let s = 1; s < t.length; ++s)
|
|
239
239
|
p(t[s].shape[0] === e, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${t[s].shape[0]} vs. ${e})`);
|
|
240
240
|
} else
|
|
241
|
-
a = !0, t = ms(t, t.shape[0], 0).map((e) =>
|
|
241
|
+
a = !0, t = ms(t, t.shape[0], 0).map((e) => Ys(e, [0]));
|
|
242
242
|
p(t.length <= t[0].shape[0], () => `Gram-Schmidt: Number of vectors (${t.length}) exceeds number of dimensions (${t[0].shape[0]}).`);
|
|
243
243
|
const n = [], r = t;
|
|
244
244
|
for (let e = 0; e < t.length; ++e)
|
|
@@ -246,14 +246,14 @@ function Mn(t) {
|
|
|
246
246
|
let s = r[e];
|
|
247
247
|
if (e > 0)
|
|
248
248
|
for (let o = 0; o < e; ++o) {
|
|
249
|
-
const i =
|
|
249
|
+
const i = d(_(d(n[o], s)), n[o]);
|
|
250
250
|
s = b(s, i);
|
|
251
251
|
}
|
|
252
252
|
return S(s, ps(s, "euclidean"));
|
|
253
253
|
}));
|
|
254
254
|
return a ? U(n, 0) : n;
|
|
255
255
|
}
|
|
256
|
-
const xn = /* @__PURE__ */
|
|
256
|
+
const xn = /* @__PURE__ */ h({ gramSchmidt_: Mn });
|
|
257
257
|
function An(t, a = !1) {
|
|
258
258
|
if (p(t.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${t.rank}`), t.rank === 2)
|
|
259
259
|
return cs(t, a);
|
|
@@ -276,30 +276,30 @@ function cs(t, a = !1) {
|
|
|
276
276
|
p(t.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`);
|
|
277
277
|
const n = t.shape[0], r = t.shape[1];
|
|
278
278
|
let e = Ks(n), s = K(t);
|
|
279
|
-
const o =
|
|
279
|
+
const o = J([[1]], [1, 1]);
|
|
280
280
|
let i = K(o);
|
|
281
281
|
const l = n >= r ? r : n;
|
|
282
282
|
for (let c = 0; c < l; ++c) {
|
|
283
283
|
const f = s, m = i, E = e;
|
|
284
284
|
[i, s, e] = k.tidy(() => {
|
|
285
|
-
const g = T(s, [c, c], [n - c, 1]), y = ps(g), M = T(s, [c, c], [1, 1]), I = q(es(M, 0),
|
|
286
|
-
D.shape[0] === 1 ? i = K(o) : i =
|
|
285
|
+
const g = T(s, [c, c], [n - c, 1]), y = ps(g), M = T(s, [c, c], [1, 1]), I = q(es(M, 0), J([[-1]]), J([[1]])), A = b(M, d(I, y)), D = S(g, A);
|
|
286
|
+
D.shape[0] === 1 ? i = K(o) : i = X([
|
|
287
287
|
o,
|
|
288
288
|
T(D, [1, 0], [D.shape[0] - 1, D.shape[1]])
|
|
289
289
|
], 0);
|
|
290
|
-
const
|
|
290
|
+
const P = C(S(w(I, A), y)), Y = T(s, [c, 0], [n - c, r]), Z = d(P, i), ts = is(i);
|
|
291
291
|
if (c === 0)
|
|
292
|
-
s = b(
|
|
292
|
+
s = b(Y, w(Z, w(ts, Y)));
|
|
293
293
|
else {
|
|
294
|
-
const H = b(
|
|
295
|
-
s =
|
|
294
|
+
const H = b(Y, w(Z, w(ts, Y)));
|
|
295
|
+
s = X([T(s, [0, 0], [c, r]), H], 0);
|
|
296
296
|
}
|
|
297
|
-
const os = is(Z),
|
|
297
|
+
const os = is(Z), j = T(e, [0, c], [n, e.shape[1] - c]);
|
|
298
298
|
if (c === 0)
|
|
299
|
-
e = b(
|
|
299
|
+
e = b(j, w(w(j, i), os));
|
|
300
300
|
else {
|
|
301
|
-
const H = b(
|
|
302
|
-
e =
|
|
301
|
+
const H = b(j, w(w(j, i), os));
|
|
302
|
+
e = X([T(e, [0, 0], [n, c]), H], 1);
|
|
303
303
|
}
|
|
304
304
|
return [i, s, e];
|
|
305
305
|
}), Is([f, m, E]);
|
|
@@ -307,7 +307,7 @@ function cs(t, a = !1) {
|
|
|
307
307
|
return !a && n > r && (e = T(e, [0, 0], [n, r]), s = T(s, [0, 0], [r, r])), [e, s];
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
|
-
const wn = /* @__PURE__ */
|
|
310
|
+
const wn = /* @__PURE__ */ h({ qr_: An });
|
|
311
311
|
var N;
|
|
312
312
|
(function(t) {
|
|
313
313
|
t[t.NONE = 0] = "NONE", t[t.MEAN = 1] = "MEAN", t[t.SUM = 2] = "SUM", t[t.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS";
|
|
@@ -316,7 +316,7 @@ function On(t, a, n = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
|
316
316
|
const r = u(t, "losses", "computeWeightedLoss");
|
|
317
317
|
let e = null;
|
|
318
318
|
a != null && (e = u(a, "weights", "computeWeightedLoss"));
|
|
319
|
-
const s = e == null ? r :
|
|
319
|
+
const s = e == null ? r : d(r, e);
|
|
320
320
|
if (n === N.NONE)
|
|
321
321
|
return s;
|
|
322
322
|
if (n === N.SUM)
|
|
@@ -333,13 +333,13 @@ function On(t, a, n = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
|
333
333
|
if (e == null)
|
|
334
334
|
return S(_(s), $(r.size));
|
|
335
335
|
{
|
|
336
|
-
const o =
|
|
336
|
+
const o = d(e, js(r.shape)), i = W(_(zs(o, $(0))), "float32");
|
|
337
337
|
return S(_(s), i);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
throw Error(`Unknown reduction: ${n}`);
|
|
341
341
|
}
|
|
342
|
-
const B = /* @__PURE__ */
|
|
342
|
+
const B = /* @__PURE__ */ h({ computeWeightedLoss_: On });
|
|
343
343
|
function Gn(t, a, n, r = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
344
344
|
const e = u(t, "labels", "absoluteDifference"), s = u(a, "predictions", "absoluteDifference");
|
|
345
345
|
let o = null;
|
|
@@ -347,80 +347,80 @@ function Gn(t, a, n, r = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
|
347
347
|
const i = ns(b(e, s));
|
|
348
348
|
return B(i, o, r);
|
|
349
349
|
}
|
|
350
|
-
const Ln = /* @__PURE__ */
|
|
350
|
+
const Ln = /* @__PURE__ */ h({ absoluteDifference_: Gn });
|
|
351
351
|
function Bn(t, a, n, r, e = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
352
352
|
const s = u(t, "labels", "cosineDistance"), o = u(a, "predictions", "cosineDistance");
|
|
353
353
|
let i = null;
|
|
354
354
|
r != null && (i = u(r, "weights", "cosineDistance")), L(s.shape, o.shape, "Error in cosineDistance: ");
|
|
355
|
-
const l = $(1), c = b(l, _(
|
|
355
|
+
const l = $(1), c = b(l, _(d(s, o), n, !0));
|
|
356
356
|
return B(c, i, e);
|
|
357
357
|
}
|
|
358
|
-
const Dn = /* @__PURE__ */
|
|
358
|
+
const Dn = /* @__PURE__ */ h({ cosineDistance_: Bn });
|
|
359
359
|
function Wn(t, a, n, r = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
360
360
|
let e = u(t, "labels", "hingeLoss");
|
|
361
361
|
const s = u(a, "predictions", "hingeLoss");
|
|
362
362
|
let o = null;
|
|
363
363
|
n != null && (o = u(n, "weights", "hingeLoss")), L(e.shape, s.shape, "Error in hingeLoss: ");
|
|
364
364
|
const i = $(1);
|
|
365
|
-
e = b(
|
|
366
|
-
const l = fs(b(i,
|
|
365
|
+
e = b(d($(2), e), i);
|
|
366
|
+
const l = fs(b(i, d(e, s)));
|
|
367
367
|
return B(l, o, r);
|
|
368
368
|
}
|
|
369
|
-
const Rn = /* @__PURE__ */
|
|
369
|
+
const Rn = /* @__PURE__ */ h({ hingeLoss_: Wn });
|
|
370
370
|
function qn(t, a, n, r = 1, e = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
371
371
|
const s = u(t, "labels", "huberLoss"), o = u(a, "predictions", "huberLoss");
|
|
372
372
|
let i = null;
|
|
373
373
|
n != null && (i = u(n, "weights", "huberLoss")), L(s.shape, o.shape, "Error in huberLoss: ");
|
|
374
|
-
const l = $(r), c = ns(b(o, s)), f = Q(c, l), m = b(c, f), E = G(
|
|
374
|
+
const l = $(r), c = ns(b(o, s)), f = Q(c, l), m = b(c, f), E = G(d($(0.5), Ts(f)), d(l, m));
|
|
375
375
|
return B(E, i, e);
|
|
376
376
|
}
|
|
377
|
-
const zn = /* @__PURE__ */
|
|
377
|
+
const zn = /* @__PURE__ */ h({ huberLoss_: qn });
|
|
378
378
|
function Vn(t, a, n, r = 1e-7, e = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
379
379
|
const s = u(t, "labels", "logLoss"), o = u(a, "predictions", "logLoss");
|
|
380
380
|
let i = null;
|
|
381
381
|
n != null && (i = u(n, "weights", "logLoss")), L(s.shape, o.shape, "Error in logLoss: ");
|
|
382
|
-
const l = $(1), c = $(r), f = C(
|
|
382
|
+
const l = $(1), c = $(r), f = C(d(s, as(G(o, c)))), m = d(b(l, s), as(G(b(l, o), c))), E = b(f, m);
|
|
383
383
|
return B(E, i, e);
|
|
384
384
|
}
|
|
385
|
-
const Cn = /* @__PURE__ */
|
|
386
|
-
function
|
|
385
|
+
const Cn = /* @__PURE__ */ h({ logLoss_: Vn });
|
|
386
|
+
function Pn(t, a, n, r = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
387
387
|
const e = u(t, "labels", "meanSquaredError"), s = u(a, "predictions", "meanSquaredError");
|
|
388
388
|
let o = null;
|
|
389
389
|
n != null && (o = u(n, "weights", "meanSquaredError")), L(e.shape, s.shape, "Error in meanSquaredError: ");
|
|
390
390
|
const i = Bs(e, s);
|
|
391
391
|
return B(i, o, r);
|
|
392
392
|
}
|
|
393
|
-
const
|
|
394
|
-
function
|
|
393
|
+
const Yn = /* @__PURE__ */ h({ meanSquaredError_: Pn });
|
|
394
|
+
function jn(t, a) {
|
|
395
395
|
const n = u(t, "labels", "sigmoidCrossEntropyWithLogits"), r = u(a, "logits", "sigmoidCrossEntropyWithLogits");
|
|
396
396
|
L(n.shape, r.shape, "Error in sigmoidCrossEntropyWithLogits: ");
|
|
397
|
-
const e = fs(r), s =
|
|
397
|
+
const e = fs(r), s = d(r, n), o = Ds(ss(C(ns(r))));
|
|
398
398
|
return G(b(e, s), o);
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function vn(t, a, n, r = 0, e = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
401
401
|
let s = u(t, "multiClassLabels", "sigmoidCrossEntropy");
|
|
402
402
|
const o = u(a, "logits", "sigmoidCrossEntropy");
|
|
403
403
|
let i = null;
|
|
404
404
|
if (n != null && (i = u(n, "weights", "sigmoidCrossEntropy")), L(s.shape, o.shape, "Error in sigmoidCrossEntropy: "), r > 0) {
|
|
405
405
|
const c = $(r), f = $(1), m = $(0.5);
|
|
406
|
-
s = G(
|
|
406
|
+
s = G(d(s, b(f, c)), d(m, c));
|
|
407
407
|
}
|
|
408
|
-
const l =
|
|
408
|
+
const l = jn(s, o);
|
|
409
409
|
return B(l, i, e);
|
|
410
410
|
}
|
|
411
|
-
const Fn = /* @__PURE__ */
|
|
411
|
+
const Fn = /* @__PURE__ */ h({ sigmoidCrossEntropy_: vn });
|
|
412
412
|
function Un(t, a, n = -1) {
|
|
413
413
|
if (n === -1 && (n = a.rank - 1), n !== a.rank - 1)
|
|
414
414
|
throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${a.rank} and dim was ${n}`);
|
|
415
415
|
return Ms((e, s, o) => {
|
|
416
416
|
const l = Vs(s, [n], !0), c = b(W(s, "float32"), l);
|
|
417
417
|
o([e, c]);
|
|
418
|
-
const f = C(
|
|
418
|
+
const f = C(d(c, e));
|
|
419
419
|
return { value: _(f, [n]), gradFunc: (g, y) => {
|
|
420
|
-
const [M, I] = y, A =
|
|
420
|
+
const [M, I] = y, A = vs(g.shape, [n]);
|
|
421
421
|
return [
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
d(O(g, A), b(W(M, "float32"), ss(I))),
|
|
423
|
+
d(O(g, A), b(ss(I), W(M, "float32")))
|
|
424
424
|
];
|
|
425
425
|
} };
|
|
426
426
|
})(t, a);
|
|
@@ -431,12 +431,12 @@ function Zn(t, a, n, r = 0, e = N.SUM_BY_NONZERO_WEIGHTS) {
|
|
|
431
431
|
let i = null;
|
|
432
432
|
if (n != null && (i = u(n, "weights", "softmaxCrossEntropy")), L(s.shape, o.shape, "Error in softmaxCrossEntropy: "), r > 0) {
|
|
433
433
|
const c = $(r), f = $(1), m = $(s.shape[1]);
|
|
434
|
-
s = G(
|
|
434
|
+
s = G(d(s, b(f, c)), S(c, m));
|
|
435
435
|
}
|
|
436
436
|
const l = Un(s, o);
|
|
437
437
|
return B(l, i, e);
|
|
438
438
|
}
|
|
439
|
-
const Hn = /* @__PURE__ */
|
|
439
|
+
const Hn = /* @__PURE__ */ h({ softmaxCrossEntropy_: Zn });
|
|
440
440
|
const $e = {
|
|
441
441
|
flipLeftRight: sn,
|
|
442
442
|
grayscaleToRGB: en,
|
|
@@ -444,11 +444,11 @@ const $e = {
|
|
|
444
444
|
resizeBilinear: Rs,
|
|
445
445
|
rgbToGrayscale: on,
|
|
446
446
|
rotateWithOffset: an,
|
|
447
|
-
cropAndResize:
|
|
447
|
+
cropAndResize: Js,
|
|
448
448
|
nonMaxSuppression: ln,
|
|
449
449
|
nonMaxSuppressionAsync: pn,
|
|
450
450
|
nonMaxSuppressionWithScore: fn,
|
|
451
|
-
nonMaxSuppressionWithScoreAsync:
|
|
451
|
+
nonMaxSuppressionWithScoreAsync: hn,
|
|
452
452
|
nonMaxSuppressionPadded: gn,
|
|
453
453
|
nonMaxSuppressionPaddedAsync: $n,
|
|
454
454
|
threshold: Nn,
|
|
@@ -464,7 +464,7 @@ const $e = {
|
|
|
464
464
|
hingeLoss: Rn,
|
|
465
465
|
huberLoss: zn,
|
|
466
466
|
logLoss: Cn,
|
|
467
|
-
meanSquaredError:
|
|
467
|
+
meanSquaredError: Yn,
|
|
468
468
|
sigmoidCrossEntropy: Fn,
|
|
469
469
|
softmaxCrossEntropy: Hn
|
|
470
470
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as o, h as i } from "./index-CUXkjxiT.js";
|
|
2
2
|
import { isPackedTensor as t } from "./utilities/packed.js";
|
|
3
|
-
import { s as u } from "./slice-
|
|
3
|
+
import { s as u } from "./slice-BzS11Qh0.js";
|
|
4
4
|
const s = {
|
|
5
5
|
kernelName: "Unpack16",
|
|
6
6
|
inputsToSave: [],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../webgpu_util-
|
|
3
|
-
import { W as P } from "../backend_webgpu-
|
|
1
|
+
import { U as c, af as l, ab as m, x as n } from "../index-CUXkjxiT.js";
|
|
2
|
+
import "../webgpu_util-DYlGSwOJ.js";
|
|
3
|
+
import { W as P } from "../backend_webgpu-BqASlsbV.js";
|
|
4
4
|
import { compileProgram as y } from "./webgpu_program.js";
|
|
5
|
-
import { m as M } from "../webgpu_program-
|
|
5
|
+
import { m as M } from "../webgpu_program-B4HmApL1.js";
|
|
6
6
|
const b = (o, s) => {
|
|
7
7
|
const i = o.limits.maxComputeWorkgroupsPerDimension, t = s.dispatchLayout, a = s.dispatch;
|
|
8
8
|
if (a.every((r) => r <= i))
|
|
@@ -17,7 +17,7 @@ const b = (o, s) => {
|
|
|
17
17
|
() => "Total dispatch size exceeds WebGPU maximum."
|
|
18
18
|
), [e, e, e]) : [e, e, 1];
|
|
19
19
|
};
|
|
20
|
-
class
|
|
20
|
+
class U extends P {
|
|
21
21
|
subgroupMaxSize;
|
|
22
22
|
subgroupMinSize;
|
|
23
23
|
constructor(s, i) {
|
|
@@ -52,5 +52,5 @@ class v extends P {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export {
|
|
55
|
-
|
|
55
|
+
U as default
|
|
56
56
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ab as z,
|
|
2
|
-
import { g as A, d as b, a as x, b as g, s as L, t as l, c as y } from "../webgpu_program-
|
|
1
|
+
import { ab as z, x as F, ac as O, ad as _ } from "../index-CUXkjxiT.js";
|
|
2
|
+
import { g as A, d as b, a as x, b as g, s as L, t as l, c as y } from "../webgpu_program-B4HmApL1.js";
|
|
3
3
|
var N = /* @__PURE__ */ ((s) => (s[s.FROM_PIXELS = 0] = "FROM_PIXELS", s[s.DRAW = 1] = "DRAW", s))(N || {});
|
|
4
4
|
const H = (s, t, e, o, u) => {
|
|
5
5
|
const a = { dtype: o.dtype, shape: o.shape }, n = D(e, a, t), r = s.createShaderModule({ code: n, label: t.constructor.name });
|