@genai-fi/nanogpt 0.8.0 → 0.8.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.d.ts +2 -1
- package/dist/Generator.js +44 -37
- package/dist/{RealDiv-N8TpOMYv.js → RealDiv-D_q39E3A.js} +14 -14
- package/dist/{Reshape-B-lWQRnF.js → Reshape-41YpQqEo.js} +1 -1
- package/dist/{Reshape-Bo8HzP8V.js → Reshape-Bh_jzKzV.js} +2 -2
- package/dist/TeachableLLM.js +7 -5
- package/dist/{axis_util-DubwyOhW.js → axis_util-Did9235A.js} +1 -1
- package/dist/backend.js +2 -2
- package/dist/{backend_util-BJ-_jSeK.js → backend_util-yC3YH1jo.js} +17 -17
- package/dist/{broadcast_to-BYfCp5iL.js → broadcast_to-CUvOdOT5.js} +2 -2
- package/dist/checks/appendCache.d.ts +1 -0
- package/dist/checks/appendCache.js +22 -0
- package/dist/checks/attentionMask.d.ts +1 -0
- package/dist/checks/attentionMask.js +37 -0
- package/dist/checks/check.d.ts +9 -0
- package/dist/checks/check.js +20 -0
- package/dist/checks/gelu.d.ts +1 -0
- package/dist/checks/gelu.js +18 -0
- package/dist/checks/index.d.ts +22 -0
- package/dist/checks/index.js +24 -0
- package/dist/checks/normRMS.d.ts +1 -0
- package/dist/checks/normRMS.js +16 -0
- package/dist/checks/normRMSGrad.d.ts +1 -0
- package/dist/checks/normRMSGrad.js +12 -0
- package/dist/checks/qkv.d.ts +1 -0
- package/dist/checks/qkv.js +50 -0
- package/dist/checks/rope.d.ts +1 -0
- package/dist/checks/rope.js +38 -0
- package/dist/checks/weights.d.ts +16 -0
- package/dist/checks/weights.js +29 -0
- package/dist/{concat-BmDqqFsa.js → concat-pHiVqR3L.js} +1 -1
- package/dist/{dataset-CJmEGu6D.js → dataset-DPPl-iLT.js} +7 -7
- package/dist/{dropout-sx0sjVAT.js → dropout-CcKSfOYE.js} +11 -11
- package/dist/{exports_initializers-DAKM8UO9.js → exports_initializers-DKk7-bsx.js} +1 -1
- package/dist/{gather-C1siEkdp.js → gather-CPg6ZlQA.js} +1 -1
- package/dist/{gelu-Bd3UBBxg.js → gelu-BkcmEEyD.js} +1 -1
- package/dist/{gpgpu_math-TFLxaLkw.js → gpgpu_math-D_ODOLix.js} +2 -2
- package/dist/{index-CUQrfsw_.js → index-DdmHGZjq.js} +655 -647
- package/dist/{index-BaPo_0H8.js → index-evZ57wr4.js} +10 -10
- package/dist/{kernel_funcs_utils-P9aFa232.js → kernel_funcs_utils-CDfFpUab.js} +15 -15
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +29 -29
- package/dist/layers/MLP.js +18 -18
- 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 +11 -11
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +9 -7
- package/dist/{log_sum_exp-C142qZqY.js → log_sum_exp-C8yFJfZz.js} +45 -24
- package/dist/main.d.ts +2 -0
- package/dist/main.js +9 -7
- package/dist/{mat_mul-DMkduNJu.js → mat_mul-Dpy2mMRu.js} +1 -1
- package/dist/{mod-uUuj4gSb.js → mod-CbibJi3D.js} +1 -1
- package/dist/models/NanoGPTV1.js +1 -1
- package/dist/models/model.js +9 -7
- package/dist/{mulmat_packed_gpu-Cm2gw-c8.js → mulmat_packed_gpu-q_Gmwyld.js} +1 -1
- package/dist/{ones-ZdgQGBCP.js → ones-BAqVh-eA.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 +1 -1
- 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 +5 -5
- 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 +13 -13
- 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 +4 -4
- 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-542ai2vG.js +1525 -0
- package/dist/{random_width-D8Pwy_na.js → random_width-DKGeiFuR.js} +1514 -1581
- package/dist/{range-LVHrSLdi.js → range-BcUvLuf5.js} +1 -1
- package/dist/{reciprocal-CaR9e67G.js → reciprocal-DhDWSKiD.js} +1 -1
- package/dist/{register_all_kernels-DUshvVWP.js → register_all_kernels-Do9VvZmo.js} +2312 -2335
- package/dist/{max-B3JOcNGb.js → relu-B1AXs7p5.js} +6 -6
- package/dist/{reshape-DEfQGSin.js → reshape-WeJkT3ja.js} +1 -1
- package/dist/{scatter_nd_util-CUPPNLaA.js → scatter_nd_util-B7yDhiQr.js} +1 -1
- package/dist/{selu_util-8vv5JxQV.js → selu_util-BgUO9gHY.js} +125 -146
- package/dist/{shared-D1elLckx.js → shared-CZiWmQCI.js} +1 -1
- package/dist/{shared-CkNorDcU.js → shared-V6D_md-c.js} +120 -120
- package/dist/{sin-D2CKKmyR.js → sin-CPxad7Am.js} +1 -1
- package/dist/{slice-BnyE-M_7.js → slice-B7jXtPnp.js} +1 -1
- package/dist/{softmax-DLoZWYBx.js → softmax-BfsyI4As.js} +1 -1
- package/dist/{split-By_n4TKP.js → split-BPxr8_8m.js} +1 -1
- package/dist/{stack-DkdFLq37.js → stack-BNwLzE43.js} +1 -1
- package/dist/{sum-l_0SqM4h.js → sum-ByFINZgi.js} +1 -1
- package/dist/{tensor-BAQdLqoU.js → tensor-DbqgIV9B.js} +1 -1
- package/dist/tensor1d-CtJq5BOv.js +27 -0
- package/dist/{tensor2d-BHy261cI.js → tensor2d-CObBWBkW.js} +1 -1
- package/dist/tensor4d-DLtk7Nxh.js +30 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +2 -2
- package/dist/training/sparseCrossEntropy.js +8 -9
- package/dist/utilities/arrayClose.d.ts +1 -1
- package/dist/utilities/arrayClose.js +16 -7
- package/dist/utilities/dummy.js +2 -2
- package/dist/utilities/multinomialCPU.js +2 -2
- 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-C9hihzDB.js → variable-DPFOJyRG.js} +1 -1
- package/dist/{webgpu_program-dFEVbDPL.js → webgpu_program-Dhk9R5aG.js} +1 -1
- package/dist/{webgpu_util-DLImlSc6.js → webgpu_util-BqGnZg8t.js} +1 -1
- package/dist/{zeros-VZ72lWXM.js → zeros-Dnwix0p4.js} +1 -1
- package/package.json +1 -1
- package/dist/ops-C_1K_-35.js +0 -1202
package/dist/ops-C_1K_-35.js
DELETED
|
@@ -1,1202 +0,0 @@
|
|
|
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
|
-
import { n as ne, a as ee, b as se } from "./non_max_suppression_impl-CsEgBuMA.js";
|
|
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
|
-
/**
|
|
18
|
-
* @license
|
|
19
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
20
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
-
* you may not use this file except in compliance with the License.
|
|
22
|
-
* You may obtain a copy of the License at
|
|
23
|
-
*
|
|
24
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
-
*
|
|
26
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
27
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
-
* See the License for the specific language governing permissions and
|
|
30
|
-
* limitations under the License.
|
|
31
|
-
* =============================================================================
|
|
32
|
-
*/
|
|
33
|
-
function ie(s, e, n) {
|
|
34
|
-
const r = u(s, "x", "bincount"), t = u(e, "weights", "bincount");
|
|
35
|
-
l(r.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${r.dtype}`), l(n >= 0, () => `size must be non-negative, but got ${n}.`), l(t.size === r.size || t.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${t.shape}.`);
|
|
36
|
-
const a = { x: r, weights: t }, o = { size: n };
|
|
37
|
-
return f.runKernel(gn, a, o);
|
|
38
|
-
}
|
|
39
|
-
const ce = /* @__PURE__ */ m({ bincount_: ie });
|
|
40
|
-
/**
|
|
41
|
-
* @license
|
|
42
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
43
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
44
|
-
* you may not use this file except in compliance with the License.
|
|
45
|
-
* You may obtain a copy of the License at
|
|
46
|
-
*
|
|
47
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
48
|
-
*
|
|
49
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
50
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
51
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
52
|
-
* See the License for the specific language governing permissions and
|
|
53
|
-
* limitations under the License.
|
|
54
|
-
* =============================================================================
|
|
55
|
-
*/
|
|
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 = J(a, o), p = J(r, o), c = J(t, o), h = {
|
|
58
|
-
condition: i,
|
|
59
|
-
t: p,
|
|
60
|
-
e: c
|
|
61
|
-
};
|
|
62
|
-
return f.runKernel($n, h);
|
|
63
|
-
}
|
|
64
|
-
const K = /* @__PURE__ */ m({ where_: ue });
|
|
65
|
-
/**
|
|
66
|
-
* @license
|
|
67
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
68
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
69
|
-
* you may not use this file except in compliance with the License.
|
|
70
|
-
* You may obtain a copy of the License at
|
|
71
|
-
*
|
|
72
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
73
|
-
*
|
|
74
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
75
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
76
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
77
|
-
* See the License for the specific language governing permissions and
|
|
78
|
-
* limitations under the License.
|
|
79
|
-
* =============================================================================
|
|
80
|
-
*/
|
|
81
|
-
function le(s, ...e) {
|
|
82
|
-
const n = e.map((t, a) => u(t, `tensors${a}`, "einsum")), r = { equation: s };
|
|
83
|
-
return f.runKernel(kn, n, r);
|
|
84
|
-
}
|
|
85
|
-
const D = /* @__PURE__ */ m({ einsum_: le });
|
|
86
|
-
/**
|
|
87
|
-
* @license
|
|
88
|
-
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
89
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
90
|
-
* you may not use this file except in compliance with the License.
|
|
91
|
-
* You may obtain a copy of the License at
|
|
92
|
-
*
|
|
93
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
94
|
-
*
|
|
95
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
96
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
97
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
98
|
-
* See the License for the specific language governing permissions and
|
|
99
|
-
* limitations under the License.
|
|
100
|
-
* =============================================================================
|
|
101
|
-
*/
|
|
102
|
-
function pe(s, e = null, n = !1) {
|
|
103
|
-
const t = { x: u(s, "x", "min") }, a = { axis: e, keepDims: n };
|
|
104
|
-
return f.runKernel(yn, t, a);
|
|
105
|
-
}
|
|
106
|
-
const an = /* @__PURE__ */ m({ min_: pe });
|
|
107
|
-
/**
|
|
108
|
-
* @license
|
|
109
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
110
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
111
|
-
* you may not use this file except in compliance with the License.
|
|
112
|
-
* You may obtain a copy of the License at
|
|
113
|
-
*
|
|
114
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
115
|
-
*
|
|
116
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
117
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
118
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
119
|
-
* See the License for the specific language governing permissions and
|
|
120
|
-
* limitations under the License.
|
|
121
|
-
* =============================================================================
|
|
122
|
-
*/
|
|
123
|
-
function me(s, e = "euclidean", n = null, r = !1) {
|
|
124
|
-
s = u(s, "x", "norm");
|
|
125
|
-
const t = fn(s, e, n);
|
|
126
|
-
let a = t.shape;
|
|
127
|
-
if (r) {
|
|
128
|
-
const o = En(n, s.shape);
|
|
129
|
-
a = oe(t.shape, o);
|
|
130
|
-
}
|
|
131
|
-
return k(t, a);
|
|
132
|
-
}
|
|
133
|
-
function fn(s, e, n = null) {
|
|
134
|
-
if (s.rank === 0)
|
|
135
|
-
return w(s);
|
|
136
|
-
if (s.rank !== 1 && n === null)
|
|
137
|
-
return fn(k(s, [-1]), e, n);
|
|
138
|
-
if (s.rank === 1 || typeof n == "number" || Array.isArray(n) && n.length === 1) {
|
|
139
|
-
if (e === 1)
|
|
140
|
-
return E(w(s), n);
|
|
141
|
-
if (e === 1 / 0)
|
|
142
|
-
return Z(w(s), n);
|
|
143
|
-
if (e === -1 / 0)
|
|
144
|
-
return an(w(s), n);
|
|
145
|
-
if (e === "euclidean" || e === 2)
|
|
146
|
-
return rn(E(_n(w(s), pn(2, "int32")), n));
|
|
147
|
-
throw new Error(`Error in norm: invalid ord value: ${e}`);
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(n) && n.length === 2) {
|
|
150
|
-
if (e === 1)
|
|
151
|
-
return Z(E(w(s), n[0]), n[1] - 1);
|
|
152
|
-
if (e === 1 / 0)
|
|
153
|
-
return Z(E(w(s), n[1]), n[0]);
|
|
154
|
-
if (e === -1 / 0)
|
|
155
|
-
return an(E(w(s), n[1]), n[0]);
|
|
156
|
-
if (e === "fro" || e === "euclidean")
|
|
157
|
-
return rn(E(In(s), n));
|
|
158
|
-
throw new Error(`Error in norm: invalid ord value: ${e}`);
|
|
159
|
-
}
|
|
160
|
-
throw new Error(`Error in norm: invalid axis: ${n}`);
|
|
161
|
-
}
|
|
162
|
-
const bn = /* @__PURE__ */ m({ norm_: me });
|
|
163
|
-
/**
|
|
164
|
-
* @license
|
|
165
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
166
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
167
|
-
* you may not use this file except in compliance with the License.
|
|
168
|
-
* You may obtain a copy of the License at
|
|
169
|
-
*
|
|
170
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
171
|
-
*
|
|
172
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
173
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
174
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
175
|
-
* See the License for the specific language governing permissions and
|
|
176
|
-
* limitations under the License.
|
|
177
|
-
* =============================================================================
|
|
178
|
-
*/
|
|
179
|
-
function fe(s, e = 0) {
|
|
180
|
-
const n = u(s, "x", "expandDims", "string_or_numeric");
|
|
181
|
-
l(e <= n.rank, () => "Axis must be <= rank of the tensor");
|
|
182
|
-
const r = { input: n }, t = { dim: e };
|
|
183
|
-
return f.runKernel(An, r, t);
|
|
184
|
-
}
|
|
185
|
-
const z = /* @__PURE__ */ m({ expandDims_: fe });
|
|
186
|
-
/**
|
|
187
|
-
* @license
|
|
188
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
189
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
190
|
-
* you may not use this file except in compliance with the License.
|
|
191
|
-
* You may obtain a copy of the License at
|
|
192
|
-
*
|
|
193
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
194
|
-
*
|
|
195
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
196
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
197
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
198
|
-
* See the License for the specific language governing permissions and
|
|
199
|
-
* limitations under the License.
|
|
200
|
-
* =============================================================================
|
|
201
|
-
*/
|
|
202
|
-
function be(s, e) {
|
|
203
|
-
const n = u(s, "x", "tile", "string_or_numeric");
|
|
204
|
-
l(n.rank === e.length, () => `Error in transpose: rank of input ${n.rank} must match length of reps ${e}.`);
|
|
205
|
-
const r = { x: n }, t = { reps: e };
|
|
206
|
-
return f.runKernel(Nn, r, t);
|
|
207
|
-
}
|
|
208
|
-
const F = /* @__PURE__ */ m({ tile_: be });
|
|
209
|
-
/**
|
|
210
|
-
* @license
|
|
211
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
212
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
213
|
-
* you may not use this file except in compliance with the License.
|
|
214
|
-
* You may obtain a copy of the License at
|
|
215
|
-
*
|
|
216
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
217
|
-
*
|
|
218
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
219
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
220
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
221
|
-
* See the License for the specific language governing permissions and
|
|
222
|
-
* limitations under the License.
|
|
223
|
-
* =============================================================================
|
|
224
|
-
*/
|
|
225
|
-
function he(s, e, n, r = "float32") {
|
|
226
|
-
e == null && (e = s);
|
|
227
|
-
const t = Tn([s, e], r), a = s <= e ? s : e;
|
|
228
|
-
for (let i = 0; i < a; ++i)
|
|
229
|
-
t.set(1, i, i);
|
|
230
|
-
const o = k(t.toTensor(), [s, e]);
|
|
231
|
-
if (n == null)
|
|
232
|
-
return o;
|
|
233
|
-
if (n.length === 1)
|
|
234
|
-
return F(z(o, 0), [n[0], 1, 1]);
|
|
235
|
-
if (n.length === 2)
|
|
236
|
-
return F(z(z(o, 0), 0), [n[0], n[1], 1, 1]);
|
|
237
|
-
if (n.length === 3)
|
|
238
|
-
return F(z(z(z(o, 0), 0), 0), [
|
|
239
|
-
n[0],
|
|
240
|
-
n[1],
|
|
241
|
-
n[2],
|
|
242
|
-
1,
|
|
243
|
-
1
|
|
244
|
-
]);
|
|
245
|
-
throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`);
|
|
246
|
-
}
|
|
247
|
-
const de = /* @__PURE__ */ m({ eye_: he });
|
|
248
|
-
/**
|
|
249
|
-
* @license
|
|
250
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
251
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
252
|
-
* you may not use this file except in compliance with the License.
|
|
253
|
-
* You may obtain a copy of the License at
|
|
254
|
-
*
|
|
255
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
256
|
-
*
|
|
257
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
258
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
259
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
260
|
-
* See the License for the specific language governing permissions and
|
|
261
|
-
* limitations under the License.
|
|
262
|
-
* =============================================================================
|
|
263
|
-
*/
|
|
264
|
-
function ge(s, e) {
|
|
265
|
-
let n = u(s, "a", "greater", "string_or_numeric"), r = u(e, "b", "greater", "string_or_numeric");
|
|
266
|
-
[n, r] = v(n, r), S(n.shape, r.shape);
|
|
267
|
-
const t = { a: n, b: r };
|
|
268
|
-
return f.runKernel(xn, t);
|
|
269
|
-
}
|
|
270
|
-
const nn = /* @__PURE__ */ m({ greater_: ge });
|
|
271
|
-
/**
|
|
272
|
-
* @license
|
|
273
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
274
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
275
|
-
* you may not use this file except in compliance with the License.
|
|
276
|
-
* You may obtain a copy of the License at
|
|
277
|
-
*
|
|
278
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
279
|
-
*
|
|
280
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
281
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
282
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
283
|
-
* See the License for the specific language governing permissions and
|
|
284
|
-
* limitations under the License.
|
|
285
|
-
* =============================================================================
|
|
286
|
-
*/
|
|
287
|
-
function $e(s, e) {
|
|
288
|
-
let n = u(s, "a", "greaterEqual", "string_or_numeric"), r = u(e, "b", "greaterEqual", "string_or_numeric");
|
|
289
|
-
[n, r] = v(n, r), S(n.shape, r.shape);
|
|
290
|
-
const t = { a: n, b: r };
|
|
291
|
-
return f.runKernel(wn, t);
|
|
292
|
-
}
|
|
293
|
-
const ke = /* @__PURE__ */ m({ greaterEqual_: $e });
|
|
294
|
-
/**
|
|
295
|
-
* @license
|
|
296
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
297
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
298
|
-
* you may not use this file except in compliance with the License.
|
|
299
|
-
* You may obtain a copy of the License at
|
|
300
|
-
*
|
|
301
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
302
|
-
*
|
|
303
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
304
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
305
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
306
|
-
* See the License for the specific language governing permissions and
|
|
307
|
-
* limitations under the License.
|
|
308
|
-
* =============================================================================
|
|
309
|
-
*/
|
|
310
|
-
function ye(s) {
|
|
311
|
-
const n = { input: u(s, "input", "imag") };
|
|
312
|
-
return f.runKernel(Sn, n);
|
|
313
|
-
}
|
|
314
|
-
const Ee = /* @__PURE__ */ m({ imag_: ye });
|
|
315
|
-
/**
|
|
316
|
-
* @license
|
|
317
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
318
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
319
|
-
* you may not use this file except in compliance with the License.
|
|
320
|
-
* You may obtain a copy of the License at
|
|
321
|
-
*
|
|
322
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
323
|
-
*
|
|
324
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
325
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
326
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
327
|
-
* See the License for the specific language governing permissions and
|
|
328
|
-
* limitations under the License.
|
|
329
|
-
* =============================================================================
|
|
330
|
-
*/
|
|
331
|
-
function _e(s, e) {
|
|
332
|
-
let n = u(s, "a", "less", "string_or_numeric"), r = u(e, "b", "less", "string_or_numeric");
|
|
333
|
-
[n, r] = v(n, r), S(n.shape, r.shape);
|
|
334
|
-
const t = { a: n, b: r };
|
|
335
|
-
return f.runKernel(Mn, t);
|
|
336
|
-
}
|
|
337
|
-
const on = /* @__PURE__ */ m({ less_: _e });
|
|
338
|
-
/**
|
|
339
|
-
* @license
|
|
340
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
341
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
342
|
-
* you may not use this file except in compliance with the License.
|
|
343
|
-
* You may obtain a copy of the License at
|
|
344
|
-
*
|
|
345
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
346
|
-
*
|
|
347
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
348
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
349
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
350
|
-
* See the License for the specific language governing permissions and
|
|
351
|
-
* limitations under the License.
|
|
352
|
-
* =============================================================================
|
|
353
|
-
*/
|
|
354
|
-
function Ie(s, e) {
|
|
355
|
-
let n = u(s, "a", "lessEqual", "string_or_numeric"), r = u(e, "b", "lessEqual", "string_or_numeric");
|
|
356
|
-
[n, r] = v(n, r), S(n.shape, r.shape);
|
|
357
|
-
const t = { a: n, b: r };
|
|
358
|
-
return f.runKernel(zn, t);
|
|
359
|
-
}
|
|
360
|
-
const hn = /* @__PURE__ */ m({ lessEqual_: Ie });
|
|
361
|
-
/**
|
|
362
|
-
* @license
|
|
363
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
364
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
365
|
-
* you may not use this file except in compliance with the License.
|
|
366
|
-
* You may obtain a copy of the License at
|
|
367
|
-
*
|
|
368
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
369
|
-
*
|
|
370
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
371
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
372
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
373
|
-
* See the License for the specific language governing permissions and
|
|
374
|
-
* limitations under the License.
|
|
375
|
-
* =============================================================================
|
|
376
|
-
*/
|
|
377
|
-
function Ae(s) {
|
|
378
|
-
const n = { x: u(s, "x", "neg") };
|
|
379
|
-
return f.runKernel(qn, n);
|
|
380
|
-
}
|
|
381
|
-
const en = /* @__PURE__ */ m({ neg_: Ae });
|
|
382
|
-
/**
|
|
383
|
-
* @license
|
|
384
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
385
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
386
|
-
* you may not use this file except in compliance with the License.
|
|
387
|
-
* You may obtain a copy of the License at
|
|
388
|
-
*
|
|
389
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
390
|
-
*
|
|
391
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
392
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
393
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
394
|
-
* See the License for the specific language governing permissions and
|
|
395
|
-
* limitations under the License.
|
|
396
|
-
* =============================================================================
|
|
397
|
-
*/
|
|
398
|
-
function Ne(s, e) {
|
|
399
|
-
const n = u(s, "a", "logicalAnd", "bool"), r = u(e, "b", "logicalAnd", "bool");
|
|
400
|
-
S(n.shape, r.shape);
|
|
401
|
-
const t = { a: n, b: r };
|
|
402
|
-
return f.runKernel(Bn, t);
|
|
403
|
-
}
|
|
404
|
-
const Te = /* @__PURE__ */ m({ logicalAnd_: Ne });
|
|
405
|
-
/**
|
|
406
|
-
* @license
|
|
407
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
408
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
409
|
-
* you may not use this file except in compliance with the License.
|
|
410
|
-
* You may obtain a copy of the License at
|
|
411
|
-
*
|
|
412
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
413
|
-
*
|
|
414
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
415
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
416
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
417
|
-
* See the License for the specific language governing permissions and
|
|
418
|
-
* limitations under the License.
|
|
419
|
-
* =============================================================================
|
|
420
|
-
*/
|
|
421
|
-
function xe(s, e) {
|
|
422
|
-
let n = u(s, "a", "minimum"), r = u(e, "b", "minimum");
|
|
423
|
-
[n, r] = v(n, r), n.dtype === "bool" && (n = G(n, "int32"), r = G(r, "int32")), S(n.shape, r.shape);
|
|
424
|
-
const t = { a: n, b: r };
|
|
425
|
-
return f.runKernel(Kn, t);
|
|
426
|
-
}
|
|
427
|
-
const cn = /* @__PURE__ */ m({ minimum_: xe });
|
|
428
|
-
/**
|
|
429
|
-
* @license
|
|
430
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
431
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
432
|
-
* you may not use this file except in compliance with the License.
|
|
433
|
-
* You may obtain a copy of the License at
|
|
434
|
-
*
|
|
435
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
436
|
-
*
|
|
437
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
438
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
439
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
440
|
-
* See the License for the specific language governing permissions and
|
|
441
|
-
* limitations under the License.
|
|
442
|
-
* =============================================================================
|
|
443
|
-
*/
|
|
444
|
-
function we(s) {
|
|
445
|
-
const n = { input: u(s, "input", "real") };
|
|
446
|
-
return f.runKernel(Gn, n);
|
|
447
|
-
}
|
|
448
|
-
const Se = /* @__PURE__ */ m({ real_: we });
|
|
449
|
-
/**
|
|
450
|
-
* @license
|
|
451
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
452
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
453
|
-
* you may not use this file except in compliance with the License.
|
|
454
|
-
* You may obtain a copy of the License at
|
|
455
|
-
*
|
|
456
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
457
|
-
*
|
|
458
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
459
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
460
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
461
|
-
* See the License for the specific language governing permissions and
|
|
462
|
-
* limitations under the License.
|
|
463
|
-
* =============================================================================
|
|
464
|
-
*/
|
|
465
|
-
function Me(s) {
|
|
466
|
-
const n = { x: u(s, "x", "round") };
|
|
467
|
-
return f.runKernel(Rn, n);
|
|
468
|
-
}
|
|
469
|
-
const ze = /* @__PURE__ */ m({ round_: Me });
|
|
470
|
-
/**
|
|
471
|
-
* @license
|
|
472
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
473
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
474
|
-
* you may not use this file except in compliance with the License.
|
|
475
|
-
* You may obtain a copy of the License at
|
|
476
|
-
*
|
|
477
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
478
|
-
*
|
|
479
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
480
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
481
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
482
|
-
* See the License for the specific language governing permissions and
|
|
483
|
-
* limitations under the License.
|
|
484
|
-
* =============================================================================
|
|
485
|
-
*/
|
|
486
|
-
function qe(s, e) {
|
|
487
|
-
const n = u(s, "x", "squeeze", "string_or_numeric");
|
|
488
|
-
return k(n, Dn(n.shape, e).newShape);
|
|
489
|
-
}
|
|
490
|
-
const Be = /* @__PURE__ */ m({ squeeze_: qe });
|
|
491
|
-
/**
|
|
492
|
-
* @license
|
|
493
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
494
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
495
|
-
* you may not use this file except in compliance with the License.
|
|
496
|
-
* You may obtain a copy of the License at
|
|
497
|
-
*
|
|
498
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
499
|
-
*
|
|
500
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
501
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
502
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
503
|
-
* See the License for the specific language governing permissions and
|
|
504
|
-
* limitations under the License.
|
|
505
|
-
* =============================================================================
|
|
506
|
-
*/
|
|
507
|
-
function I(s, e) {
|
|
508
|
-
vn(s);
|
|
509
|
-
const n = Vn(s, e);
|
|
510
|
-
if (n.length !== 1)
|
|
511
|
-
throw new Error("tensor1d() requires values to be a flat/TypedArray");
|
|
512
|
-
return Pn(s, null, n, e);
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* @license
|
|
516
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
517
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
518
|
-
* you may not use this file except in compliance with the License.
|
|
519
|
-
* You may obtain a copy of the License at
|
|
520
|
-
*
|
|
521
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
522
|
-
*
|
|
523
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
524
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
525
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
526
|
-
* See the License for the specific language governing permissions and
|
|
527
|
-
* limitations under the License.
|
|
528
|
-
* =============================================================================
|
|
529
|
-
*/
|
|
530
|
-
function Ke(s, e = 0) {
|
|
531
|
-
const n = u(s, "x", "unstack", "string_or_numeric");
|
|
532
|
-
l(e >= -n.shape.length && e < n.shape.length, () => `Axis = ${e} is not in [-${n.shape.length}, ${n.shape.length})`);
|
|
533
|
-
const r = { value: n }, t = { axis: e };
|
|
534
|
-
return f.runKernel(jn, r, t);
|
|
535
|
-
}
|
|
536
|
-
const dn = /* @__PURE__ */ m({ unstack_: Ke });
|
|
537
|
-
/**
|
|
538
|
-
* @license
|
|
539
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
540
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
541
|
-
* you may not use this file except in compliance with the License.
|
|
542
|
-
* You may obtain a copy of the License at
|
|
543
|
-
*
|
|
544
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
545
|
-
*
|
|
546
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
547
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
548
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
549
|
-
* See the License for the specific language governing permissions and
|
|
550
|
-
* limitations under the License.
|
|
551
|
-
* =============================================================================
|
|
552
|
-
*/
|
|
553
|
-
function Ge(s, e, n) {
|
|
554
|
-
const r = u(s, "x", "transpose");
|
|
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
|
-
l(o >= 0 && o < r.rank, () => `All entries in 'perm' must be between 0 and ${r.rank - 1} but got ${e}`);
|
|
557
|
-
}), r.rank <= 1)
|
|
558
|
-
return r.clone();
|
|
559
|
-
const t = { x: r }, a = { perm: e };
|
|
560
|
-
return r.dtype === "complex64" ? Fn(() => {
|
|
561
|
-
let o = Se(r), i = Ee(r);
|
|
562
|
-
return o = f.runKernel(L, { x: o }, a), i = f.runKernel(L, { x: i }, a), n && (i = en(i)), re(o, i);
|
|
563
|
-
}) : f.runKernel(L, t, a);
|
|
564
|
-
}
|
|
565
|
-
const un = /* @__PURE__ */ m({ transpose_: Ge });
|
|
566
|
-
/**
|
|
567
|
-
* @license
|
|
568
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
569
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
570
|
-
* you may not use this file except in compliance with the License.
|
|
571
|
-
* You may obtain a copy of the License at
|
|
572
|
-
*
|
|
573
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
574
|
-
*
|
|
575
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
576
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
577
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
578
|
-
* See the License for the specific language governing permissions and
|
|
579
|
-
* limitations under the License.
|
|
580
|
-
* =============================================================================
|
|
581
|
-
*/
|
|
582
|
-
function Re(s, e, n, r, t = "bilinear", a = 0) {
|
|
583
|
-
const o = u(s, "image", "cropAndResize"), i = u(e, "boxes", "cropAndResize", "float32"), p = u(n, "boxInd", "cropAndResize", "int32"), c = i.shape[0];
|
|
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 h = { image: o, boxes: i, boxInd: p }, b = { method: t, extrapolationValue: a, cropSize: r };
|
|
586
|
-
return f.runKernel(Wn, h, b);
|
|
587
|
-
}
|
|
588
|
-
const De = /* @__PURE__ */ m({ cropAndResize_: Re });
|
|
589
|
-
/**
|
|
590
|
-
* @license
|
|
591
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
592
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
593
|
-
* you may not use this file except in compliance with the License.
|
|
594
|
-
* You may obtain a copy of the License at
|
|
595
|
-
*
|
|
596
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
597
|
-
*
|
|
598
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
599
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
600
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
601
|
-
* See the License for the specific language governing permissions and
|
|
602
|
-
* limitations under the License.
|
|
603
|
-
* =============================================================================
|
|
604
|
-
*/
|
|
605
|
-
function ve(s) {
|
|
606
|
-
const e = u(s, "image", "flipLeftRight", "float32");
|
|
607
|
-
l(e.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);
|
|
608
|
-
const n = { image: e };
|
|
609
|
-
return f.runKernel(Yn, n, {});
|
|
610
|
-
}
|
|
611
|
-
const Ve = /* @__PURE__ */ m({ flipLeftRight_: ve });
|
|
612
|
-
/**
|
|
613
|
-
* @license
|
|
614
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
615
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
616
|
-
* you may not use this file except in compliance with the License.
|
|
617
|
-
* You may obtain a copy of the License at
|
|
618
|
-
*
|
|
619
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
620
|
-
*
|
|
621
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
622
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
623
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
624
|
-
* See the License for the specific language governing permissions and
|
|
625
|
-
* limitations under the License.
|
|
626
|
-
* =============================================================================
|
|
627
|
-
*/
|
|
628
|
-
function Pe(s) {
|
|
629
|
-
const e = u(s, "image", "grayscaleToRGB"), n = e.rank - 1, r = e.shape[n];
|
|
630
|
-
l(e.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`), l(r === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);
|
|
631
|
-
const t = new Array(e.rank);
|
|
632
|
-
return t.fill(1, 0, n), t[n] = 3, F(e, t);
|
|
633
|
-
}
|
|
634
|
-
const je = /* @__PURE__ */ m({ grayscaleToRGB_: Pe });
|
|
635
|
-
/**
|
|
636
|
-
* @license
|
|
637
|
-
* Copyright 2023 Google LLC.
|
|
638
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
639
|
-
* you may not use this file except in compliance with the License.
|
|
640
|
-
* You may obtain a copy of the License at
|
|
641
|
-
*
|
|
642
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
643
|
-
*
|
|
644
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
645
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
646
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
647
|
-
* See the License for the specific language governing permissions and
|
|
648
|
-
* limitations under the License.
|
|
649
|
-
* =============================================================================
|
|
650
|
-
*/
|
|
651
|
-
function Fe(s) {
|
|
652
|
-
const e = u(s, "image", "RGBToGrayscale"), n = e.rank - 1, r = e.shape[n];
|
|
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 = G(e, "float32"), o = I([0.2989, 0.587, 0.114]);
|
|
655
|
-
let i;
|
|
656
|
-
switch (e.rank) {
|
|
657
|
-
case 2:
|
|
658
|
-
i = D("ij,j->i", a, o);
|
|
659
|
-
break;
|
|
660
|
-
case 3:
|
|
661
|
-
i = D("ijk,k->ij", a, o);
|
|
662
|
-
break;
|
|
663
|
-
case 4:
|
|
664
|
-
i = D("ijkl,l->ijk", a, o);
|
|
665
|
-
break;
|
|
666
|
-
case 5:
|
|
667
|
-
i = D("ijklm,m->ijkl", a, o);
|
|
668
|
-
break;
|
|
669
|
-
case 6:
|
|
670
|
-
i = D("ijklmn,n->ijklm", a, o);
|
|
671
|
-
break;
|
|
672
|
-
default:
|
|
673
|
-
throw new Error("Not a valid tensor rank.");
|
|
674
|
-
}
|
|
675
|
-
return i = z(i, -1), G(i, t);
|
|
676
|
-
}
|
|
677
|
-
const We = /* @__PURE__ */ m({ rgbToGrayscale_: Fe });
|
|
678
|
-
/**
|
|
679
|
-
* @license
|
|
680
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
681
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
682
|
-
* you may not use this file except in compliance with the License.
|
|
683
|
-
* You may obtain a copy of the License at
|
|
684
|
-
*
|
|
685
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
686
|
-
*
|
|
687
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
688
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
689
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
690
|
-
* See the License for the specific language governing permissions and
|
|
691
|
-
* limitations under the License.
|
|
692
|
-
* =============================================================================
|
|
693
|
-
*/
|
|
694
|
-
function Ye(s, e, n = 0, r = 0.5) {
|
|
695
|
-
const t = u(s, "image", "rotateWithOffset", "float32");
|
|
696
|
-
l(t.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${t.rank}.`);
|
|
697
|
-
const a = { image: t }, o = { radians: e, fillValue: n, center: r };
|
|
698
|
-
return f.runKernel(On, a, o);
|
|
699
|
-
}
|
|
700
|
-
const Oe = /* @__PURE__ */ m({ rotateWithOffset_: Ye });
|
|
701
|
-
/**
|
|
702
|
-
* @license
|
|
703
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
704
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
705
|
-
* you may not use this file except in compliance with the License.
|
|
706
|
-
* You may obtain a copy of the License at
|
|
707
|
-
*
|
|
708
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
709
|
-
*
|
|
710
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
711
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
712
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
713
|
-
* See the License for the specific language governing permissions and
|
|
714
|
-
* limitations under the License.
|
|
715
|
-
* =============================================================================
|
|
716
|
-
*/
|
|
717
|
-
function R(s, e, n, r, t, a) {
|
|
718
|
-
r == null && (r = 0.5), t == null && (t = Number.NEGATIVE_INFINITY), a == null && (a = 0);
|
|
719
|
-
const o = s.shape[0];
|
|
720
|
-
return n = Math.min(n, o), l(0 <= r && r <= 1, () => `iouThreshold must be in [0, 1], but was '${r}'`), l(s.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${s.rank}'`), l(s.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${s.shape[1]}`), l(e.rank === 1, () => "scores must be a 1D tensor"), l(e.shape[0] === o, () => `scores has incompatible shape with boxes. Expected ${o}, but was ${e.shape[0]}`), l(0 <= a && a <= 1, () => `softNmsSigma must be in [0, 1], but was '${a}'`), { maxOutputSize: n, iouThreshold: r, scoreThreshold: t, softNmsSigma: a };
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* @license
|
|
724
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
725
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
726
|
-
* you may not use this file except in compliance with the License.
|
|
727
|
-
* You may obtain a copy of the License at
|
|
728
|
-
*
|
|
729
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
730
|
-
*
|
|
731
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
732
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
733
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
734
|
-
* See the License for the specific language governing permissions and
|
|
735
|
-
* limitations under the License.
|
|
736
|
-
* =============================================================================
|
|
737
|
-
*/
|
|
738
|
-
function Ce(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY) {
|
|
739
|
-
const a = u(s, "boxes", "nonMaxSuppression", "float32"), o = u(e, "scores", "nonMaxSuppression", "float32"), i = R(a, o, n, r, t);
|
|
740
|
-
n = i.maxOutputSize, r = i.iouThreshold, t = i.scoreThreshold;
|
|
741
|
-
const p = { maxOutputSize: n, iouThreshold: r, scoreThreshold: t };
|
|
742
|
-
return f.runKernel(Cn, { boxes: a, scores: o }, p);
|
|
743
|
-
}
|
|
744
|
-
const Le = /* @__PURE__ */ m({ nonMaxSuppression_: Ce });
|
|
745
|
-
/**
|
|
746
|
-
* @license
|
|
747
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
748
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
749
|
-
* you may not use this file except in compliance with the License.
|
|
750
|
-
* You may obtain a copy of the License at
|
|
751
|
-
*
|
|
752
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
753
|
-
*
|
|
754
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
755
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
756
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
757
|
-
* See the License for the specific language governing permissions and
|
|
758
|
-
* limitations under the License.
|
|
759
|
-
* =============================================================================
|
|
760
|
-
*/
|
|
761
|
-
async function Xe(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY) {
|
|
762
|
-
const a = u(s, "boxes", "nonMaxSuppressionAsync"), o = u(e, "scores", "nonMaxSuppressionAsync"), i = R(a, o, n, r, t);
|
|
763
|
-
n = i.maxOutputSize, r = i.iouThreshold, t = i.scoreThreshold;
|
|
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
|
-
}
|
|
767
|
-
const Je = Xe;
|
|
768
|
-
/**
|
|
769
|
-
* @license
|
|
770
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
771
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
772
|
-
* you may not use this file except in compliance with the License.
|
|
773
|
-
* You may obtain a copy of the License at
|
|
774
|
-
*
|
|
775
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
776
|
-
*
|
|
777
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
778
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
779
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
780
|
-
* See the License for the specific language governing permissions and
|
|
781
|
-
* limitations under the License.
|
|
782
|
-
* =============================================================================
|
|
783
|
-
*/
|
|
784
|
-
function Ze(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = 0) {
|
|
785
|
-
const o = u(s, "boxes", "nonMaxSuppression"), i = u(e, "scores", "nonMaxSuppression"), p = R(o, i, n, r, t, a);
|
|
786
|
-
n = p.maxOutputSize, r = p.iouThreshold, t = p.scoreThreshold, a = p.softNmsSigma;
|
|
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
|
-
}
|
|
790
|
-
const He = /* @__PURE__ */ m({ nonMaxSuppressionWithScore_: Ze });
|
|
791
|
-
/**
|
|
792
|
-
* @license
|
|
793
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
794
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
795
|
-
* you may not use this file except in compliance with the License.
|
|
796
|
-
* You may obtain a copy of the License at
|
|
797
|
-
*
|
|
798
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
799
|
-
*
|
|
800
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
801
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
802
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
803
|
-
* See the License for the specific language governing permissions and
|
|
804
|
-
* limitations under the License.
|
|
805
|
-
* =============================================================================
|
|
806
|
-
*/
|
|
807
|
-
async function Qe(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = 0) {
|
|
808
|
-
const o = u(s, "boxes", "nonMaxSuppressionAsync"), i = u(e, "scores", "nonMaxSuppressionAsync"), p = R(o, i, n, r, t, a);
|
|
809
|
-
n = p.maxOutputSize, r = p.iouThreshold, t = p.scoreThreshold, a = p.softNmsSigma;
|
|
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
|
-
return o !== s && o.dispose(), i !== e && i.dispose(), {
|
|
812
|
-
selectedIndices: I(g, "int32"),
|
|
813
|
-
selectedScores: I(d)
|
|
814
|
-
};
|
|
815
|
-
}
|
|
816
|
-
const Ue = Qe;
|
|
817
|
-
/**
|
|
818
|
-
* @license
|
|
819
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
820
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
821
|
-
* you may not use this file except in compliance with the License.
|
|
822
|
-
* You may obtain a copy of the License at
|
|
823
|
-
*
|
|
824
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
825
|
-
*
|
|
826
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
827
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
828
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
829
|
-
* See the License for the specific language governing permissions and
|
|
830
|
-
* limitations under the License.
|
|
831
|
-
* =============================================================================
|
|
832
|
-
*/
|
|
833
|
-
function ns(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = !1) {
|
|
834
|
-
const o = u(s, "boxes", "nonMaxSuppression"), i = u(e, "scores", "nonMaxSuppression"), p = R(
|
|
835
|
-
o,
|
|
836
|
-
i,
|
|
837
|
-
n,
|
|
838
|
-
r,
|
|
839
|
-
t,
|
|
840
|
-
null
|
|
841
|
-
/* softNmsSigma */
|
|
842
|
-
), c = p.maxOutputSize, h = p.iouThreshold, b = p.scoreThreshold, g = { boxes: o, scores: i }, d = {
|
|
843
|
-
maxOutputSize: c,
|
|
844
|
-
iouThreshold: h,
|
|
845
|
-
scoreThreshold: b,
|
|
846
|
-
padToMaxOutputSize: a
|
|
847
|
-
}, y = f.runKernel(Xn, g, d);
|
|
848
|
-
return { selectedIndices: y[0], validOutputs: y[1] };
|
|
849
|
-
}
|
|
850
|
-
const es = /* @__PURE__ */ m({ nonMaxSuppressionPadded_: ns });
|
|
851
|
-
/**
|
|
852
|
-
* @license
|
|
853
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
854
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
855
|
-
* you may not use this file except in compliance with the License.
|
|
856
|
-
* You may obtain a copy of the License at
|
|
857
|
-
*
|
|
858
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
859
|
-
*
|
|
860
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
861
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
862
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
863
|
-
* See the License for the specific language governing permissions and
|
|
864
|
-
* limitations under the License.
|
|
865
|
-
* =============================================================================
|
|
866
|
-
*/
|
|
867
|
-
async function ss(s, e, n, r = 0.5, t = Number.NEGATIVE_INFINITY, a = !1) {
|
|
868
|
-
const o = u(s, "boxes", "nonMaxSuppressionAsync"), i = u(e, "scores", "nonMaxSuppressionAsync"), p = R(
|
|
869
|
-
o,
|
|
870
|
-
i,
|
|
871
|
-
n,
|
|
872
|
-
r,
|
|
873
|
-
t,
|
|
874
|
-
null
|
|
875
|
-
/* softNmsSigma */
|
|
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
|
-
return o !== s && o.dispose(), i !== e && i.dispose(), {
|
|
878
|
-
selectedIndices: I(y, "int32"),
|
|
879
|
-
validOutputs: pn(M, "int32")
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
const ts = ss;
|
|
883
|
-
/**
|
|
884
|
-
* @license
|
|
885
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
886
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
887
|
-
* you may not use this file except in compliance with the License.
|
|
888
|
-
* You may obtain a copy of the License at
|
|
889
|
-
*
|
|
890
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
891
|
-
*
|
|
892
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
893
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
894
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
895
|
-
* See the License for the specific language governing permissions and
|
|
896
|
-
* limitations under the License.
|
|
897
|
-
* =============================================================================
|
|
898
|
-
*/
|
|
899
|
-
function rs(s, e, n = !1, r = !1) {
|
|
900
|
-
const t = u(s, "images", "resizeBilinear");
|
|
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
|
-
let a = t, o = !1;
|
|
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(Jn, i, p);
|
|
905
|
-
return o ? k(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
|
|
906
|
-
}
|
|
907
|
-
const as = /* @__PURE__ */ m({ resizeBilinear_: rs });
|
|
908
|
-
/**
|
|
909
|
-
* @license
|
|
910
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
911
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
912
|
-
* you may not use this file except in compliance with the License.
|
|
913
|
-
* You may obtain a copy of the License at
|
|
914
|
-
*
|
|
915
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
916
|
-
*
|
|
917
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
918
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
919
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
920
|
-
* See the License for the specific language governing permissions and
|
|
921
|
-
* limitations under the License.
|
|
922
|
-
* =============================================================================
|
|
923
|
-
*/
|
|
924
|
-
function os(s, e, n = !1, r = !1) {
|
|
925
|
-
const t = u(s, "images", "resizeNearestNeighbor");
|
|
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
|
-
let a = t, o = !1;
|
|
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(Zn, i, p);
|
|
930
|
-
return o ? k(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
|
|
931
|
-
}
|
|
932
|
-
const is = /* @__PURE__ */ m({ resizeNearestNeighbor_: os });
|
|
933
|
-
/**
|
|
934
|
-
* @license
|
|
935
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
936
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
937
|
-
* you may not use this file except in compliance with the License.
|
|
938
|
-
* You may obtain a copy of the License at
|
|
939
|
-
*
|
|
940
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
941
|
-
*
|
|
942
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
943
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
944
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
945
|
-
* See the License for the specific language governing permissions and
|
|
946
|
-
* limitations under the License.
|
|
947
|
-
* =============================================================================
|
|
948
|
-
*/
|
|
949
|
-
function cs(s, e = "binary", n = !1, r = 0.5) {
|
|
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), h, b, g, d;
|
|
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
|
-
[h, b, g] = mn(t, [1, 1, 1], -1);
|
|
954
|
-
const T = $(h, a), B = $(b, o), x = $(g, i);
|
|
955
|
-
d = U(U(T, B), x);
|
|
956
|
-
} else
|
|
957
|
-
d = s;
|
|
958
|
-
if (e === "otsu") {
|
|
959
|
-
const T = ce(G(ze(d), "int32"), te([]), 256);
|
|
960
|
-
c = us(T, p);
|
|
961
|
-
}
|
|
962
|
-
const y = n ? hn(d, c) : nn(d, c);
|
|
963
|
-
return G($(y, 255), "int32");
|
|
964
|
-
}
|
|
965
|
-
function us(s, e) {
|
|
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
|
-
const g = E($(a, W(0, a.size)));
|
|
970
|
-
i = q(g, E(a));
|
|
971
|
-
const d = Hn(o.shape, a.size), y = U(W(0, o.size), d), M = $(o, y);
|
|
972
|
-
p = q(E(M), E(o));
|
|
973
|
-
const T = N(i, p), B = N(i, p), x = $(c, h);
|
|
974
|
-
t = $($(x, T), B);
|
|
975
|
-
const V = nn(t, r);
|
|
976
|
-
r = K(V, t, r), n = K(V, I([b]), n);
|
|
977
|
-
}
|
|
978
|
-
return n;
|
|
979
|
-
}
|
|
980
|
-
const ls = /* @__PURE__ */ m({ threshold_: cs });
|
|
981
|
-
/**
|
|
982
|
-
* @license
|
|
983
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
984
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
985
|
-
* you may not use this file except in compliance with the License.
|
|
986
|
-
* You may obtain a copy of the License at
|
|
987
|
-
*
|
|
988
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
989
|
-
*
|
|
990
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
991
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
992
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
993
|
-
* See the License for the specific language governing permissions and
|
|
994
|
-
* limitations under the License.
|
|
995
|
-
* =============================================================================
|
|
996
|
-
*/
|
|
997
|
-
function ps(s, e, n = "nearest", r = "constant", t = 0, a) {
|
|
998
|
-
const o = u(s, "image", "transform", "float32"), i = u(e, "transforms", "transform", "float32");
|
|
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
|
-
const p = { image: o, transforms: i }, c = { interpolation: n, fillMode: r, fillValue: t, outputShape: a };
|
|
1001
|
-
return f.runKernel(Qn, p, c);
|
|
1002
|
-
}
|
|
1003
|
-
const ms = /* @__PURE__ */ m({ transform_: ps });
|
|
1004
|
-
/**
|
|
1005
|
-
* @license
|
|
1006
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1007
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1008
|
-
* you may not use this file except in compliance with the License.
|
|
1009
|
-
* You may obtain a copy of the License at
|
|
1010
|
-
*
|
|
1011
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1012
|
-
*
|
|
1013
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1014
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1015
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1016
|
-
* See the License for the specific language governing permissions and
|
|
1017
|
-
* limitations under the License.
|
|
1018
|
-
* =============================================================================
|
|
1019
|
-
*/
|
|
1020
|
-
function fs(s, e, n) {
|
|
1021
|
-
const r = u(s, "a", "bandPart");
|
|
1022
|
-
l(r.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${r.rank}.`);
|
|
1023
|
-
const t = r.shape, [a, o] = r.shape.slice(-2);
|
|
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 = 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
|
-
}
|
|
1029
|
-
const bs = /* @__PURE__ */ m({ bandPart_: fs });
|
|
1030
|
-
/**
|
|
1031
|
-
* @license
|
|
1032
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1033
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1034
|
-
* you may not use this file except in compliance with the License.
|
|
1035
|
-
* You may obtain a copy of the License at
|
|
1036
|
-
*
|
|
1037
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1038
|
-
*
|
|
1039
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1040
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1041
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1042
|
-
* See the License for the specific language governing permissions and
|
|
1043
|
-
* limitations under the License.
|
|
1044
|
-
* =============================================================================
|
|
1045
|
-
*/
|
|
1046
|
-
function hs(s) {
|
|
1047
|
-
let e;
|
|
1048
|
-
if (Array.isArray(s)) {
|
|
1049
|
-
e = !1, l(s != null && s.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
|
|
1050
|
-
const t = s[0].shape[0];
|
|
1051
|
-
for (let a = 1; a < s.length; ++a)
|
|
1052
|
-
l(s[a].shape[0] === t, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${s[a].shape[0]} vs. ${t})`);
|
|
1053
|
-
} else
|
|
1054
|
-
e = !0, s = mn(s, s.shape[0], 0).map((t) => Be(t, [0]));
|
|
1055
|
-
l(s.length <= s[0].shape[0], () => `Gram-Schmidt: Number of vectors (${s.length}) exceeds number of dimensions (${s[0].shape[0]}).`);
|
|
1056
|
-
const n = [], r = s;
|
|
1057
|
-
for (let t = 0; t < s.length; ++t)
|
|
1058
|
-
n.push(f.tidy(() => {
|
|
1059
|
-
let a = r[t];
|
|
1060
|
-
if (t > 0)
|
|
1061
|
-
for (let o = 0; o < t; ++o) {
|
|
1062
|
-
const i = $(E($(n[o], a)), n[o]);
|
|
1063
|
-
a = N(a, i);
|
|
1064
|
-
}
|
|
1065
|
-
return q(a, bn(a, "euclidean"));
|
|
1066
|
-
}));
|
|
1067
|
-
return e ? Y(n, 0) : n;
|
|
1068
|
-
}
|
|
1069
|
-
const ds = /* @__PURE__ */ m({ gramSchmidt_: hs });
|
|
1070
|
-
/**
|
|
1071
|
-
* @license
|
|
1072
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1073
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1074
|
-
* you may not use this file except in compliance with the License.
|
|
1075
|
-
* You may obtain a copy of the License at
|
|
1076
|
-
*
|
|
1077
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1078
|
-
*
|
|
1079
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1080
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1081
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1082
|
-
* See the License for the specific language governing permissions and
|
|
1083
|
-
* limitations under the License.
|
|
1084
|
-
* =============================================================================
|
|
1085
|
-
*/
|
|
1086
|
-
function gs(s, e = !1) {
|
|
1087
|
-
if (l(s.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${s.rank}`), s.rank === 2)
|
|
1088
|
-
return ln(s, e);
|
|
1089
|
-
{
|
|
1090
|
-
const n = s.shape.slice(0, s.shape.length - 2).reduce((p, c) => p * c), r = dn(k(s, [
|
|
1091
|
-
n,
|
|
1092
|
-
s.shape[s.shape.length - 2],
|
|
1093
|
-
s.shape[s.shape.length - 1]
|
|
1094
|
-
]), 0), t = [], a = [];
|
|
1095
|
-
r.forEach((p) => {
|
|
1096
|
-
const [c, h] = ln(p, e);
|
|
1097
|
-
t.push(c), a.push(h);
|
|
1098
|
-
});
|
|
1099
|
-
const o = k(Y(t, 0), s.shape), i = k(Y(a, 0), s.shape);
|
|
1100
|
-
return [o, i];
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
function ln(s, e = !1) {
|
|
1104
|
-
return f.tidy(() => {
|
|
1105
|
-
l(s.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${s.shape.length}D Tensor.`);
|
|
1106
|
-
const n = s.shape[0], r = s.shape[1];
|
|
1107
|
-
let t = de(n), a = X(s);
|
|
1108
|
-
const o = Q([[1]], [1, 1]);
|
|
1109
|
-
let i = X(o);
|
|
1110
|
-
const p = n >= r ? r : n;
|
|
1111
|
-
for (let c = 0; c < p; ++c) {
|
|
1112
|
-
const h = a, b = i, g = t;
|
|
1113
|
-
[i, a, t] = f.tidy(() => {
|
|
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
|
-
o,
|
|
1117
|
-
_(x, [1, 0], [x.shape[0] - 1, x.shape[1]])
|
|
1118
|
-
], 0);
|
|
1119
|
-
const V = en(q(A(T, B), y)), P = _(a, [c, 0], [n - c, r]), O = $(V, i), sn = un(i);
|
|
1120
|
-
if (c === 0)
|
|
1121
|
-
a = N(P, A(O, A(sn, P)));
|
|
1122
|
-
else {
|
|
1123
|
-
const C = N(P, A(O, A(sn, P)));
|
|
1124
|
-
a = H([_(a, [0, 0], [c, r]), C], 0);
|
|
1125
|
-
}
|
|
1126
|
-
const tn = un(O), j = _(t, [0, c], [n, t.shape[1] - c]);
|
|
1127
|
-
if (c === 0)
|
|
1128
|
-
t = N(j, A(A(j, i), tn));
|
|
1129
|
-
else {
|
|
1130
|
-
const C = N(j, A(A(j, i), tn));
|
|
1131
|
-
t = H([_(t, [0, 0], [n, c]), C], 1);
|
|
1132
|
-
}
|
|
1133
|
-
return [i, a, t];
|
|
1134
|
-
}), Un([h, b, g]);
|
|
1135
|
-
}
|
|
1136
|
-
return !e && n > r && (t = _(t, [0, 0], [n, r]), a = _(a, [0, 0], [r, r])), [t, a];
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
const $s = /* @__PURE__ */ m({ qr_: gs });
|
|
1140
|
-
/**
|
|
1141
|
-
* @license
|
|
1142
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1143
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1144
|
-
* you may not use this file except in compliance with the License.
|
|
1145
|
-
* You may obtain a copy of the License at
|
|
1146
|
-
*
|
|
1147
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1148
|
-
*
|
|
1149
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1150
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1151
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1152
|
-
* See the License for the specific language governing permissions and
|
|
1153
|
-
* limitations under the License.
|
|
1154
|
-
* =============================================================================
|
|
1155
|
-
*/
|
|
1156
|
-
const Gs = {
|
|
1157
|
-
flipLeftRight: Ve,
|
|
1158
|
-
grayscaleToRGB: je,
|
|
1159
|
-
resizeNearestNeighbor: is,
|
|
1160
|
-
resizeBilinear: as,
|
|
1161
|
-
rgbToGrayscale: We,
|
|
1162
|
-
rotateWithOffset: Oe,
|
|
1163
|
-
cropAndResize: De,
|
|
1164
|
-
nonMaxSuppression: Le,
|
|
1165
|
-
nonMaxSuppressionAsync: Je,
|
|
1166
|
-
nonMaxSuppressionWithScore: He,
|
|
1167
|
-
nonMaxSuppressionWithScoreAsync: Ue,
|
|
1168
|
-
nonMaxSuppressionPadded: es,
|
|
1169
|
-
nonMaxSuppressionPaddedAsync: ts,
|
|
1170
|
-
threshold: ls,
|
|
1171
|
-
transform: ms
|
|
1172
|
-
}, Rs = {
|
|
1173
|
-
bandPart: bs,
|
|
1174
|
-
gramSchmidt: ds,
|
|
1175
|
-
qr: $s
|
|
1176
|
-
};
|
|
1177
|
-
export {
|
|
1178
|
-
Te as a,
|
|
1179
|
-
hn as b,
|
|
1180
|
-
F as c,
|
|
1181
|
-
nn as d,
|
|
1182
|
-
on as e,
|
|
1183
|
-
z as f,
|
|
1184
|
-
ke as g,
|
|
1185
|
-
I as h,
|
|
1186
|
-
de as i,
|
|
1187
|
-
Gs as j,
|
|
1188
|
-
an as k,
|
|
1189
|
-
Rs as l,
|
|
1190
|
-
cn as m,
|
|
1191
|
-
en as n,
|
|
1192
|
-
bn as o,
|
|
1193
|
-
Ee as p,
|
|
1194
|
-
as as q,
|
|
1195
|
-
Se as r,
|
|
1196
|
-
Be as s,
|
|
1197
|
-
un as t,
|
|
1198
|
-
dn as u,
|
|
1199
|
-
is as v,
|
|
1200
|
-
K as w,
|
|
1201
|
-
ze as x
|
|
1202
|
-
};
|