@genai-fi/nanogpt 0.6.3 → 0.7.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 +17 -13
- package/dist/NanoGPTModel.d.ts +2 -2
- package/dist/NanoGPTModel.js +104 -136
- package/dist/{RealDiv-BYViZwhN.js → RealDiv-CVYNbZxu.js} +30 -29
- package/dist/{Reshape-t7Kcikjk.js → Reshape-CEsEp0AI.js} +5 -5
- package/dist/Reshape-Do18N3gO.js +30 -0
- package/dist/TeachableLLM.js +9 -5
- package/dist/{TiedEmbedding-9WeDwvjO.js → TiedEmbedding-ccLBFiZi.js} +4 -4
- package/dist/{axis_util-Bu4h7XWV.js → axis_util-5DTW2tFV.js} +3 -3
- package/dist/backend.d.ts +1 -0
- package/dist/backend.js +7 -0
- package/dist/backend_util-C9Ut8n0Q.js +749 -0
- package/dist/{broadcast_to-DARN-DBD.js → broadcast_to-Ba9h_8DO.js} +2 -2
- package/dist/{concat-5aPGqw3Z.js → concat-CbXTetof.js} +8 -8
- package/dist/{dataset-pgqp-YfL.js → dataset-U3PrjwgU.js} +7 -7
- package/dist/{dropout-Bciw46HT.js → dropout-DPfPgWWe.js} +8 -8
- package/dist/{gather-DjyCjmOD.js → gather-Bbh8DHhM.js} +1 -1
- package/dist/gelu-BFwVnd1r.js +26 -0
- package/dist/gpgpu_math-DffelNS-.js +2371 -0
- package/dist/index-DYD_yPa-.js +12076 -0
- package/dist/{index-BAzbokzv.js → index-UdZhlibC.js} +414 -398
- package/dist/{kernel_funcs_utils-CUxJCg0g.js → kernel_funcs_utils-CXDy3EN7.js} +31 -30
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +8 -8
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.js +5 -5
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +11 -7
- package/dist/{log_sum_exp-YEo2h3gb.js → log_sum_exp-BnmCkHWl.js} +16 -16
- package/dist/main.d.ts +13 -0
- package/dist/main.js +44 -23
- package/dist/{mat_mul-7121rsJk.js → mat_mul-dwmZz69e.js} +4 -4
- package/dist/{max-DtlIuVeW.js → max-ByjEGoFx.js} +3 -3
- package/dist/{mulmat_packed_gpu-D4nKF7Je.js → mulmat_packed_gpu-IGPBp6h9.js} +1 -1
- package/dist/non_max_suppression_impl-CsEgBuMA.js +134 -0
- package/dist/{ones-BBlSRqn1.js → ones-C8Mfln6-.js} +2 -2
- package/dist/ops/adamAdjust.d.ts +2 -0
- package/dist/ops/adamAdjust.js +9 -0
- package/dist/ops/adamMoments.d.ts +2 -0
- package/dist/ops/adamMoments.js +9 -0
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/adamAdjust.d.ts +1 -0
- package/dist/ops/cpu/adamAdjust.js +18 -0
- package/dist/ops/cpu/adamMoments.d.ts +1 -0
- package/dist/ops/cpu/adamMoments.js +16 -0
- package/dist/ops/cpu/appendCache.js +8 -8
- package/dist/ops/cpu/attentionMask.js +9 -9
- package/dist/ops/cpu/fusedSoftmax.js +17 -11
- package/dist/ops/cpu/gatherSub.js +7 -7
- package/dist/ops/cpu/gelu.js +13 -13
- package/dist/ops/cpu/matMulGelu.js +36 -24
- package/dist/ops/cpu/matMulMul.js +14 -8
- package/dist/ops/cpu/mulDropout.js +9 -3
- package/dist/ops/cpu/normRMS.js +5 -5
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +11 -11
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +3 -24
- package/dist/ops/grads/matMulGelu.js +5 -5
- package/dist/ops/grads/normRMS.js +6 -6
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +3 -3
- 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.d.ts +1 -0
- package/dist/ops/webgl/adamAdjust.js +50 -0
- package/dist/ops/webgl/adamMoments.d.ts +1 -0
- package/dist/ops/webgl/adamMoments.js +38 -0
- 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 +8 -8
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +5 -5
- package/dist/ops/webgl/matMulGelu.js +17 -17
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +4 -4
- 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.d.ts +1 -0
- package/dist/ops/webgpu/adamAdjust.js +52 -0
- package/dist/ops/webgpu/adamMoments.d.ts +1 -0
- package/dist/ops/webgpu/adamMoments.js +51 -0
- package/dist/ops/webgpu/appendCache.d.ts +1 -0
- package/dist/ops/webgpu/appendCache.js +57 -0
- package/dist/ops/webgpu/attentionMask.d.ts +1 -0
- package/dist/ops/webgpu/attentionMask.js +65 -0
- package/dist/ops/webgpu/gatherSub.d.ts +1 -0
- package/dist/ops/webgpu/gatherSub.js +52 -0
- package/dist/ops/webgpu/gelu.d.ts +14 -0
- package/dist/ops/webgpu/gelu.js +87 -0
- package/dist/ops/webgpu/index.d.ts +0 -0
- package/dist/ops/webgpu/index.js +11 -0
- package/dist/ops/webgpu/normRMS.d.ts +1 -0
- package/dist/ops/webgpu/normRMS.js +41 -0
- package/dist/ops/webgpu/normRMSGrad.d.ts +1 -0
- package/dist/ops/webgpu/normRMSGrad.js +128 -0
- package/dist/ops/webgpu/qkv.d.ts +1 -0
- package/dist/ops/webgpu/qkv.js +57 -0
- package/dist/ops/webgpu/rope.d.ts +1 -0
- package/dist/ops/webgpu/rope.js +69 -0
- package/dist/ops/webgpu/scatterSub.d.ts +1 -0
- package/dist/ops/webgpu/scatterSub.js +38 -0
- package/dist/ops/webgpu/utils/reductions.d.ts +9 -0
- package/dist/ops/webgpu/utils/reductions.js +68 -0
- package/dist/{ops-C0sQEcPw.js → ops-aRTXR2Sr.js} +433 -508
- package/dist/{random_width-DWzaOgrn.js → random_width-DbSpgl4o.js} +144 -144
- package/dist/{range-DYsrnfiy.js → range-D9CZhVlR.js} +1 -1
- package/dist/{reciprocal-CJQeasVa.js → reciprocal-CGB48wZB.js} +1 -1
- package/dist/{register_all_kernels-BfFCQAqs.js → register_all_kernels-DnbAyBXt.js} +203 -200
- package/dist/{reshape-krWGKraP.js → reshape-BR0eoLYN.js} +1 -1
- package/dist/{scatter_nd_util-93ln7Hut.js → scatter_nd_util-OjyAxku2.js} +3 -3
- package/dist/{selu_util-sntGesxr.js → selu_util-Ce6pu9IM.js} +44 -44
- package/dist/{shared-Ca6iDobD.js → shared-Czipaeb6.js} +541 -606
- package/dist/shared-DS5waSIY.js +69 -0
- package/dist/{sin-D_h-qCSx.js → sin-CiBxrDqX.js} +1 -1
- package/dist/slice-BHbDHObE.js +28 -0
- package/dist/{softmax-fsdtf6JC.js → softmax-JMEIUo2J.js} +1 -1
- package/dist/{split-eiktj-6L.js → split-CRU0PjVV.js} +4 -4
- package/dist/{stack-dfEEz2OY.js → stack-ikk2Y8_P.js} +2 -2
- package/dist/{sum-BE_Irnim.js → sum-NLYbiDag.js} +3 -3
- package/dist/{tensor-Xyi595sG.js → tensor-Do9PKbIE.js} +1 -1
- package/dist/{tensor2d-CPEkynbH.js → tensor2d-CWHxHpLh.js} +1 -1
- package/dist/training/Adam.d.ts +22 -0
- package/dist/training/Adam.js +93 -0
- package/dist/training/AdamExt.d.ts +1 -1
- package/dist/training/AdamExt.js +13 -12
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/Evaluator.js +1 -1
- package/dist/training/FullTrainer.js +27 -27
- package/dist/training/Trainer.d.ts +5 -6
- package/dist/training/Trainer.js +54 -55
- package/dist/training/sparseCrossEntropy.d.ts +0 -4
- package/dist/training/sparseCrossEntropy.js +7 -7
- package/dist/utilities/arrayClose.d.ts +1 -0
- package/dist/utilities/arrayClose.js +11 -0
- package/dist/utilities/dummy.js +19 -19
- package/dist/utilities/generate.js +15 -16
- package/dist/utilities/multinomialCPU.d.ts +2 -0
- package/dist/utilities/multinomialCPU.js +13 -0
- package/dist/utilities/performance.d.ts +2 -0
- package/dist/utilities/performance.js +16 -0
- package/dist/utilities/profile.d.ts +1 -0
- package/dist/utilities/profile.js +9 -6
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-wSS22xj5.js → variable-BTBkayv_.js} +1 -1
- package/dist/webgpu_program-WaoMq-WD.js +548 -0
- package/dist/webgpu_util-DhSeP4b6.js +80 -0
- package/dist/{zeros-YJDE7oRb.js → zeros-DnPT2nD4.js} +10 -10
- package/package.json +2 -1
- package/dist/gpgpu_math-CNslybmD.js +0 -3115
- package/dist/norm-CzltS9Fz.js +0 -86
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { g as pn, a as
|
|
4
|
-
import { b as xn } from "./broadcast_to-
|
|
5
|
-
import { r as En } from "./reshape-
|
|
6
|
-
import { p as Fn, q as yn, r as kn, u as Nn } from "./selu_util-
|
|
7
|
-
import { g as
|
|
8
|
-
function
|
|
1
|
+
import { l as Lt, bf as Ce, j as V, k as Pt, a1 as H, bg as et, aa as ht, bh as dt, bi as at, a6 as De, a7 as st, am as We, b2 as $e, bj as Ue, bk as ze, bl as Be, bm as qt, al as K, bn as At, bo as W, bp as _t, bq as Vt, ae as Ct, br as Dt, ak as Wt, bs as $t, aW as Ut, aX as zt, aZ as Bt, a_ as jt, af as Gt, bt as Zt, b1 as Kt, bu as Ht, a$ as je, ao as Ge, bv as Xt, b5 as Ze, bw as Ke, p as Jt, u as He, t as Xe, bx as Qt, by as It, ar as Yt, W as Je, bz as te, bA as ee, bB as ne, aM as pt, bC as se, bD as ot } from "./index-UdZhlibC.js";
|
|
2
|
+
import { f as it, m as kt, g as Qe, a as Ye, R as tn, v as en, d as nn, e as sn, h as on, i as rn, j as an, k as ln, l as cn, n as un, o as hn, p as fn, q as Nt, r as dn, s as gn, t as mn } from "./backend_util-C9Ut8n0Q.js";
|
|
3
|
+
import { g as pn, a as wn, e as In, c as bn } from "./axis_util-5DTW2tFV.js";
|
|
4
|
+
import { b as xn } from "./broadcast_to-Ba9h_8DO.js";
|
|
5
|
+
import { r as En } from "./reshape-BR0eoLYN.js";
|
|
6
|
+
import { p as Fn, q as yn, r as kn, u as Nn } from "./selu_util-Ce6pu9IM.js";
|
|
7
|
+
import { g as vn } from "./_commonjsHelpers-ByX85dGu.js";
|
|
8
|
+
function Sn(e, t) {
|
|
9
9
|
for (var n = 0; n < t.length; n++) {
|
|
10
10
|
const s = t[n];
|
|
11
11
|
if (typeof s != "string" && !Array.isArray(s)) {
|
|
@@ -21,10 +21,10 @@ function vn(e, t) {
|
|
|
21
21
|
}
|
|
22
22
|
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
|
|
23
23
|
}
|
|
24
|
-
var
|
|
24
|
+
var wt, vt;
|
|
25
25
|
function Tn() {
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (vt) return wt;
|
|
27
|
+
vt = 1, wt = t;
|
|
28
28
|
var e = null;
|
|
29
29
|
try {
|
|
30
30
|
e = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
|
|
@@ -317,108 +317,108 @@ function Tn() {
|
|
|
317
317
|
])), {}).exports;
|
|
318
318
|
} catch {
|
|
319
319
|
}
|
|
320
|
-
function t(
|
|
321
|
-
this.low =
|
|
320
|
+
function t(I, c, E) {
|
|
321
|
+
this.low = I | 0, this.high = c | 0, this.unsigned = !!E;
|
|
322
322
|
}
|
|
323
323
|
t.prototype.__isLong__, Object.defineProperty(t.prototype, "__isLong__", { value: !0 });
|
|
324
|
-
function n(
|
|
325
|
-
return (
|
|
324
|
+
function n(I) {
|
|
325
|
+
return (I && I.__isLong__) === !0;
|
|
326
326
|
}
|
|
327
327
|
t.isLong = n;
|
|
328
328
|
var s = {}, o = {};
|
|
329
|
-
function a(
|
|
330
|
-
var E, N,
|
|
331
|
-
return c ? (
|
|
329
|
+
function a(I, c) {
|
|
330
|
+
var E, N, L;
|
|
331
|
+
return c ? (I >>>= 0, (L = 0 <= I && I < 256) && (N = o[I], N) ? N : (E = i(I, (I | 0) < 0 ? -1 : 0, !0), L && (o[I] = E), E)) : (I |= 0, (L = -128 <= I && I < 128) && (N = s[I], N) ? N : (E = i(I, I < 0 ? -1 : 0, !1), L && (s[I] = E), E));
|
|
332
332
|
}
|
|
333
333
|
t.fromInt = a;
|
|
334
|
-
function r(
|
|
335
|
-
if (isNaN(
|
|
336
|
-
return c ? b :
|
|
334
|
+
function r(I, c) {
|
|
335
|
+
if (isNaN(I))
|
|
336
|
+
return c ? b : g;
|
|
337
337
|
if (c) {
|
|
338
|
-
if (
|
|
338
|
+
if (I < 0)
|
|
339
339
|
return b;
|
|
340
|
-
if (
|
|
341
|
-
return
|
|
340
|
+
if (I >= m)
|
|
341
|
+
return O;
|
|
342
342
|
} else {
|
|
343
|
-
if (
|
|
344
|
-
return
|
|
345
|
-
if (
|
|
346
|
-
return
|
|
343
|
+
if (I <= -F)
|
|
344
|
+
return S;
|
|
345
|
+
if (I + 1 >= F)
|
|
346
|
+
return M;
|
|
347
347
|
}
|
|
348
|
-
return
|
|
348
|
+
return I < 0 ? r(-I, c).neg() : i(I % w | 0, I / w | 0, c);
|
|
349
349
|
}
|
|
350
350
|
t.fromNumber = r;
|
|
351
|
-
function i(
|
|
352
|
-
return new t(
|
|
351
|
+
function i(I, c, E) {
|
|
352
|
+
return new t(I, c, E);
|
|
353
353
|
}
|
|
354
354
|
t.fromBits = i;
|
|
355
355
|
var l = Math.pow;
|
|
356
|
-
function u(
|
|
357
|
-
if (
|
|
356
|
+
function u(I, c, E) {
|
|
357
|
+
if (I.length === 0)
|
|
358
358
|
throw Error("empty string");
|
|
359
|
-
if (
|
|
360
|
-
return
|
|
359
|
+
if (I === "NaN" || I === "Infinity" || I === "+Infinity" || I === "-Infinity")
|
|
360
|
+
return g;
|
|
361
361
|
if (typeof c == "number" ? (E = c, c = !1) : c = !!c, E = E || 10, E < 2 || 36 < E)
|
|
362
362
|
throw RangeError("radix");
|
|
363
363
|
var N;
|
|
364
|
-
if ((N =
|
|
364
|
+
if ((N = I.indexOf("-")) > 0)
|
|
365
365
|
throw Error("interior hyphen");
|
|
366
366
|
if (N === 0)
|
|
367
|
-
return u(
|
|
368
|
-
for (var
|
|
369
|
-
var
|
|
370
|
-
if (
|
|
371
|
-
var
|
|
372
|
-
R = R.mul(
|
|
367
|
+
return u(I.substring(1), c, E).neg();
|
|
368
|
+
for (var L = r(l(E, 8)), R = g, q = 0; q < I.length; q += 8) {
|
|
369
|
+
var U = Math.min(8, I.length - q), j = parseInt(I.substring(q, q + U), E);
|
|
370
|
+
if (U < 8) {
|
|
371
|
+
var C = r(l(E, U));
|
|
372
|
+
R = R.mul(C).add(r(j));
|
|
373
373
|
} else
|
|
374
|
-
R = R.mul(
|
|
374
|
+
R = R.mul(L), R = R.add(r(j));
|
|
375
375
|
}
|
|
376
376
|
return R.unsigned = c, R;
|
|
377
377
|
}
|
|
378
378
|
t.fromString = u;
|
|
379
|
-
function h(
|
|
380
|
-
return typeof
|
|
379
|
+
function h(I, c) {
|
|
380
|
+
return typeof I == "number" ? r(I, c) : typeof I == "string" ? u(I, c) : i(I.low, I.high, typeof c == "boolean" ? c : I.unsigned);
|
|
381
381
|
}
|
|
382
382
|
t.fromValue = h;
|
|
383
|
-
var f = 65536, p = 1 << 24,
|
|
384
|
-
t.ZERO =
|
|
383
|
+
var f = 65536, p = 1 << 24, w = f * f, m = w * w, F = m / 2, d = a(p), g = a(0);
|
|
384
|
+
t.ZERO = g;
|
|
385
385
|
var b = a(0, !0);
|
|
386
386
|
t.UZERO = b;
|
|
387
387
|
var k = a(1);
|
|
388
388
|
t.ONE = k;
|
|
389
389
|
var y = a(1, !0);
|
|
390
390
|
t.UONE = y;
|
|
391
|
-
var
|
|
392
|
-
t.NEG_ONE =
|
|
393
|
-
var
|
|
394
|
-
t.MAX_VALUE =
|
|
395
|
-
var
|
|
396
|
-
t.MAX_UNSIGNED_VALUE =
|
|
397
|
-
var
|
|
398
|
-
t.MIN_VALUE =
|
|
391
|
+
var v = a(-1);
|
|
392
|
+
t.NEG_ONE = v;
|
|
393
|
+
var M = i(-1, 2147483647, !1);
|
|
394
|
+
t.MAX_VALUE = M;
|
|
395
|
+
var O = i(-1, -1, !0);
|
|
396
|
+
t.MAX_UNSIGNED_VALUE = O;
|
|
397
|
+
var S = i(0, -2147483648, !1);
|
|
398
|
+
t.MIN_VALUE = S;
|
|
399
399
|
var x = t.prototype;
|
|
400
400
|
return x.toInt = function() {
|
|
401
401
|
return this.unsigned ? this.low >>> 0 : this.low;
|
|
402
402
|
}, x.toNumber = function() {
|
|
403
|
-
return this.unsigned ? (this.high >>> 0) *
|
|
403
|
+
return this.unsigned ? (this.high >>> 0) * w + (this.low >>> 0) : this.high * w + (this.low >>> 0);
|
|
404
404
|
}, x.toString = function(c) {
|
|
405
405
|
if (c = c || 10, c < 2 || 36 < c)
|
|
406
406
|
throw RangeError("radix");
|
|
407
407
|
if (this.isZero())
|
|
408
408
|
return "0";
|
|
409
409
|
if (this.isNegative())
|
|
410
|
-
if (this.eq(
|
|
411
|
-
var E = r(c), N = this.div(E),
|
|
412
|
-
return N.toString(c) +
|
|
410
|
+
if (this.eq(S)) {
|
|
411
|
+
var E = r(c), N = this.div(E), L = N.mul(E).sub(this);
|
|
412
|
+
return N.toString(c) + L.toInt().toString(c);
|
|
413
413
|
} else
|
|
414
414
|
return "-" + this.neg().toString(c);
|
|
415
|
-
for (var R = r(l(c, 6), this.unsigned),
|
|
416
|
-
var
|
|
417
|
-
if (
|
|
418
|
-
return
|
|
419
|
-
for (;
|
|
420
|
-
|
|
421
|
-
|
|
415
|
+
for (var R = r(l(c, 6), this.unsigned), q = this, U = ""; ; ) {
|
|
416
|
+
var j = q.div(R), C = q.sub(j.mul(R)).toInt() >>> 0, P = C.toString(c);
|
|
417
|
+
if (q = j, q.isZero())
|
|
418
|
+
return P + U;
|
|
419
|
+
for (; P.length < 6; )
|
|
420
|
+
P = "0" + P;
|
|
421
|
+
U = "" + P + U;
|
|
422
422
|
}
|
|
423
423
|
}, x.getHighBits = function() {
|
|
424
424
|
return this.high;
|
|
@@ -430,7 +430,7 @@ function Tn() {
|
|
|
430
430
|
return this.low >>> 0;
|
|
431
431
|
}, x.getNumBitsAbs = function() {
|
|
432
432
|
if (this.isNegative())
|
|
433
|
-
return this.eq(
|
|
433
|
+
return this.eq(S) ? 64 : this.neg().getNumBitsAbs();
|
|
434
434
|
for (var c = this.high != 0 ? this.high : this.low, E = 31; E > 0 && (c & 1 << E) == 0; E--)
|
|
435
435
|
;
|
|
436
436
|
return this.high != 0 ? E + 33 : E + 1;
|
|
@@ -477,16 +477,16 @@ function Tn() {
|
|
|
477
477
|
var E = this.isNegative(), N = c.isNegative();
|
|
478
478
|
return E && !N ? -1 : !E && N ? 1 : this.unsigned ? c.high >>> 0 > this.high >>> 0 || c.high === this.high && c.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(c).isNegative() ? -1 : 1;
|
|
479
479
|
}, x.comp = x.compare, x.negate = function() {
|
|
480
|
-
return !this.unsigned && this.eq(
|
|
480
|
+
return !this.unsigned && this.eq(S) ? S : this.not().add(k);
|
|
481
481
|
}, x.neg = x.negate, x.add = function(c) {
|
|
482
482
|
n(c) || (c = h(c));
|
|
483
|
-
var E = this.high >>> 16, N = this.high & 65535,
|
|
484
|
-
return B += R +
|
|
483
|
+
var E = this.high >>> 16, N = this.high & 65535, L = this.low >>> 16, R = this.low & 65535, q = c.high >>> 16, U = c.high & 65535, j = c.low >>> 16, C = c.low & 65535, P = 0, G = 0, _ = 0, B = 0;
|
|
484
|
+
return B += R + C, _ += B >>> 16, B &= 65535, _ += L + j, G += _ >>> 16, _ &= 65535, G += N + U, P += G >>> 16, G &= 65535, P += E + q, P &= 65535, i(_ << 16 | B, P << 16 | G, this.unsigned);
|
|
485
485
|
}, x.subtract = function(c) {
|
|
486
486
|
return n(c) || (c = h(c)), this.add(c.neg());
|
|
487
487
|
}, x.sub = x.subtract, x.multiply = function(c) {
|
|
488
488
|
if (this.isZero())
|
|
489
|
-
return
|
|
489
|
+
return g;
|
|
490
490
|
if (n(c) || (c = h(c)), e) {
|
|
491
491
|
var E = e.mul(
|
|
492
492
|
this.low,
|
|
@@ -497,19 +497,19 @@ function Tn() {
|
|
|
497
497
|
return i(E, e.get_high(), this.unsigned);
|
|
498
498
|
}
|
|
499
499
|
if (c.isZero())
|
|
500
|
-
return
|
|
501
|
-
if (this.eq(
|
|
502
|
-
return c.isOdd() ?
|
|
503
|
-
if (c.eq(
|
|
504
|
-
return this.isOdd() ?
|
|
500
|
+
return g;
|
|
501
|
+
if (this.eq(S))
|
|
502
|
+
return c.isOdd() ? S : g;
|
|
503
|
+
if (c.eq(S))
|
|
504
|
+
return this.isOdd() ? S : g;
|
|
505
505
|
if (this.isNegative())
|
|
506
506
|
return c.isNegative() ? this.neg().mul(c.neg()) : this.neg().mul(c).neg();
|
|
507
507
|
if (c.isNegative())
|
|
508
508
|
return this.mul(c.neg()).neg();
|
|
509
|
-
if (this.lt(
|
|
509
|
+
if (this.lt(d) && c.lt(d))
|
|
510
510
|
return r(this.toNumber() * c.toNumber(), this.unsigned);
|
|
511
|
-
var N = this.high >>> 16,
|
|
512
|
-
return ct +=
|
|
511
|
+
var N = this.high >>> 16, L = this.high & 65535, R = this.low >>> 16, q = this.low & 65535, U = c.high >>> 16, j = c.high & 65535, C = c.low >>> 16, P = c.low & 65535, G = 0, _ = 0, B = 0, ct = 0;
|
|
512
|
+
return ct += q * P, B += ct >>> 16, ct &= 65535, B += R * P, _ += B >>> 16, B &= 65535, B += q * C, _ += B >>> 16, B &= 65535, _ += L * P, G += _ >>> 16, _ &= 65535, _ += R * C, G += _ >>> 16, _ &= 65535, _ += q * j, G += _ >>> 16, _ &= 65535, G += N * P + L * C + R * j + q * U, G &= 65535, i(B << 16 | ct, G << 16 | _, this.unsigned);
|
|
513
513
|
}, x.mul = x.multiply, x.divide = function(c) {
|
|
514
514
|
if (n(c) || (c = h(c)), c.isZero())
|
|
515
515
|
throw Error("division by zero");
|
|
@@ -525,8 +525,8 @@ function Tn() {
|
|
|
525
525
|
return i(E, e.get_high(), this.unsigned);
|
|
526
526
|
}
|
|
527
527
|
if (this.isZero())
|
|
528
|
-
return this.unsigned ? b :
|
|
529
|
-
var N,
|
|
528
|
+
return this.unsigned ? b : g;
|
|
529
|
+
var N, L, R;
|
|
530
530
|
if (this.unsigned) {
|
|
531
531
|
if (c.unsigned || (c = c.toUnsigned()), c.gt(this))
|
|
532
532
|
return b;
|
|
@@ -534,26 +534,26 @@ function Tn() {
|
|
|
534
534
|
return y;
|
|
535
535
|
R = b;
|
|
536
536
|
} else {
|
|
537
|
-
if (this.eq(
|
|
538
|
-
if (c.eq(k) || c.eq(
|
|
539
|
-
return
|
|
540
|
-
if (c.eq(
|
|
537
|
+
if (this.eq(S)) {
|
|
538
|
+
if (c.eq(k) || c.eq(v))
|
|
539
|
+
return S;
|
|
540
|
+
if (c.eq(S))
|
|
541
541
|
return k;
|
|
542
|
-
var
|
|
543
|
-
return N =
|
|
544
|
-
} else if (c.eq(
|
|
545
|
-
return this.unsigned ? b :
|
|
542
|
+
var q = this.shr(1);
|
|
543
|
+
return N = q.div(c).shl(1), N.eq(g) ? c.isNegative() ? k : v : (L = this.sub(c.mul(N)), R = N.add(L.div(c)), R);
|
|
544
|
+
} else if (c.eq(S))
|
|
545
|
+
return this.unsigned ? b : g;
|
|
546
546
|
if (this.isNegative())
|
|
547
547
|
return c.isNegative() ? this.neg().div(c.neg()) : this.neg().div(c).neg();
|
|
548
548
|
if (c.isNegative())
|
|
549
549
|
return this.div(c.neg()).neg();
|
|
550
|
-
R =
|
|
550
|
+
R = g;
|
|
551
551
|
}
|
|
552
|
-
for (
|
|
553
|
-
N = Math.max(1, Math.floor(
|
|
554
|
-
for (var
|
|
555
|
-
N -=
|
|
556
|
-
|
|
552
|
+
for (L = this; L.gte(c); ) {
|
|
553
|
+
N = Math.max(1, Math.floor(L.toNumber() / c.toNumber()));
|
|
554
|
+
for (var U = Math.ceil(Math.log(N) / Math.LN2), j = U <= 48 ? 1 : l(2, U - 48), C = r(N), P = C.mul(c); P.isNegative() || P.gt(L); )
|
|
555
|
+
N -= j, C = r(N, this.unsigned), P = C.mul(c);
|
|
556
|
+
C.isZero() && (C = k), R = R.add(C), L = L.sub(P);
|
|
557
557
|
}
|
|
558
558
|
return R;
|
|
559
559
|
}, x.div = x.divide, x.modulo = function(c) {
|
|
@@ -631,10 +631,10 @@ function Tn() {
|
|
|
631
631
|
c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3],
|
|
632
632
|
E
|
|
633
633
|
);
|
|
634
|
-
},
|
|
634
|
+
}, wt;
|
|
635
635
|
}
|
|
636
636
|
var oe = Tn();
|
|
637
|
-
const re = /* @__PURE__ */
|
|
637
|
+
const re = /* @__PURE__ */ vn(oe), Rn = /* @__PURE__ */ Sn({
|
|
638
638
|
__proto__: null,
|
|
639
639
|
default: re
|
|
640
640
|
}, [oe]);
|
|
@@ -658,10 +658,10 @@ const tt = (
|
|
|
658
658
|
// tslint:disable-next-line
|
|
659
659
|
re || Rn
|
|
660
660
|
);
|
|
661
|
-
function
|
|
661
|
+
function gt(e) {
|
|
662
662
|
return tt.fromString(e, !0, 16);
|
|
663
663
|
}
|
|
664
|
-
const ae =
|
|
664
|
+
const ae = gt("c3a5c85c97cb3127"), Y = gt("b492b66fbe98f273"), D = gt("9ae16a3b2f90404f");
|
|
665
665
|
function bt(e) {
|
|
666
666
|
return e.xor(e.shru(47));
|
|
667
667
|
}
|
|
@@ -672,64 +672,64 @@ function ie(e, t, n) {
|
|
|
672
672
|
function T(e, t) {
|
|
673
673
|
return ie(e, t, 8);
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function St(e, t) {
|
|
676
676
|
return ie(e, t, 4);
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function A(e, t) {
|
|
679
679
|
return t === 0 ? e : e.shru(t).or(e.shl(64 - t));
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function J(e, t, n = gt("9ddfea08eb382d69")) {
|
|
682
682
|
let s = e.xor(t).mul(n);
|
|
683
683
|
s = s.xor(s.shru(47));
|
|
684
684
|
let o = t.xor(s).mul(n);
|
|
685
685
|
return o = o.xor(o.shru(47)), o = o.mul(n), o;
|
|
686
686
|
}
|
|
687
|
-
function
|
|
688
|
-
o = o.add(e), a =
|
|
687
|
+
function Mn(e, t, n, s, o, a) {
|
|
688
|
+
o = o.add(e), a = A(a.add(o).add(s), 21);
|
|
689
689
|
const r = o;
|
|
690
|
-
return o = o.add(t), o = o.add(n), a = a.add(
|
|
690
|
+
return o = o.add(t), o = o.add(n), a = a.add(A(o, 44)), [o.add(s), a.add(r)];
|
|
691
691
|
}
|
|
692
692
|
function ut(e, t, n, s) {
|
|
693
|
-
return
|
|
693
|
+
return Mn(T(e, t), T(e, t + 8), T(e, t + 16), T(e, t + 24), n, s);
|
|
694
694
|
}
|
|
695
|
-
function
|
|
695
|
+
function On(e, t = e.length) {
|
|
696
696
|
if (t >= 8) {
|
|
697
|
-
const n =
|
|
698
|
-
return
|
|
697
|
+
const n = D.add(t * 2), s = T(e, 0).add(D), o = T(e, t - 8), a = A(o, 37).mul(n).add(s), r = A(s, 25).add(o).mul(n);
|
|
698
|
+
return J(a, r, n);
|
|
699
699
|
}
|
|
700
700
|
if (t >= 4) {
|
|
701
|
-
const n =
|
|
702
|
-
return
|
|
701
|
+
const n = D.add(t * 2), s = St(e, 0);
|
|
702
|
+
return J(s.shl(3).add(t), St(e, t - 4), n);
|
|
703
703
|
}
|
|
704
704
|
if (t > 0) {
|
|
705
705
|
const n = e[0], s = e[t >> 1], o = e[t - 1], a = n + (s << 8), r = t + (o << 2);
|
|
706
|
-
return bt(
|
|
706
|
+
return bt(D.mul(a).xor(ae.mul(r))).mul(D);
|
|
707
707
|
}
|
|
708
|
-
return
|
|
708
|
+
return D;
|
|
709
709
|
}
|
|
710
|
-
function
|
|
711
|
-
const n =
|
|
712
|
-
return
|
|
710
|
+
function Ln(e, t = e.length) {
|
|
711
|
+
const n = D.add(t * 2), s = T(e, 0).mul(Y), o = T(e, 8), a = T(e, t - 8).mul(n), r = T(e, t - 16).mul(D);
|
|
712
|
+
return J(A(s.add(o), 43).add(A(a, 30)).add(r), s.add(A(o.add(D), 18)).add(a), n);
|
|
713
713
|
}
|
|
714
|
-
function
|
|
715
|
-
const n =
|
|
716
|
-
return
|
|
714
|
+
function Pn(e, t = e.length) {
|
|
715
|
+
const n = D.add(t * 2), s = T(e, 0).mul(D), o = T(e, 8), a = T(e, t - 8).mul(n), r = T(e, t - 16).mul(D), i = A(s.add(o), 43).add(A(a, 30)).add(r), l = J(i, s.add(A(o.add(D), 18)).add(a), n), u = T(e, 16).mul(n), h = T(e, 24), f = i.add(T(e, t - 32)).mul(n), p = l.add(T(e, t - 24)).mul(n);
|
|
716
|
+
return J(A(u.add(h), 43).add(A(f, 30)).add(p), u.add(A(h.add(s), 18)).add(f), n);
|
|
717
717
|
}
|
|
718
|
-
function
|
|
718
|
+
function qn(e, t = e.length) {
|
|
719
719
|
const n = tt.fromNumber(81, !0);
|
|
720
720
|
if (t <= 32)
|
|
721
|
-
return t <= 16 ?
|
|
721
|
+
return t <= 16 ? On(e, t) : Ln(e, t);
|
|
722
722
|
if (t <= 64)
|
|
723
|
-
return
|
|
724
|
-
let s = n, o = n.mul(
|
|
725
|
-
s = s.mul(
|
|
723
|
+
return Pn(e, t);
|
|
724
|
+
let s = n, o = n.mul(Y).add(113), a = bt(o.mul(D).add(113)).mul(D), r = [tt.UZERO, tt.UZERO], i = [tt.UZERO, tt.UZERO];
|
|
725
|
+
s = s.mul(D).add(T(e, 0));
|
|
726
726
|
let l = 0;
|
|
727
727
|
const u = (t - 1 >> 6) * 64, h = u + (t - 1 & 63) - 63;
|
|
728
728
|
do
|
|
729
|
-
s =
|
|
729
|
+
s = A(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(Y), o = A(o.add(r[1]).add(T(e, l + 48)), 42).mul(Y), s = s.xor(i[1]), o = o.add(r[0]).add(T(e, l + 40)), a = A(a.add(i[0]), 33).mul(Y), r = ut(e, l, r[1].mul(Y), s.add(i[0])), i = ut(e, l + 32, a.add(i[1]), o.add(T(e, l + 16))), [a, s] = [s, a], l += 64;
|
|
730
730
|
while (l !== u);
|
|
731
|
-
const f =
|
|
732
|
-
return l = h, i[0] = i[0].add(t - 1 & 63), r[0] = r[0].add(i[0]), i[0] = i[0].add(r[0]), s =
|
|
731
|
+
const f = Y.add(a.and(255).shl(1));
|
|
732
|
+
return l = h, i[0] = i[0].add(t - 1 & 63), r[0] = r[0].add(i[0]), i[0] = i[0].add(r[0]), s = A(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(f), o = A(o.add(r[1]).add(T(e, l + 48)), 42).mul(f), s = s.xor(i[1].mul(9)), o = o.add(r[0].mul(9).add(T(e, l + 40))), a = A(a.add(i[0]), 33).mul(f), r = ut(e, l, r[1].mul(f), s.add(i[0])), i = ut(e, l + 32, a.add(i[1]), o.add(T(e, l + 16))), [a, s] = [s, a], J(J(r[0], i[0], f).add(bt(o).mul(ae)).add(a), J(r[1], i[1], f).add(s), f);
|
|
733
733
|
}
|
|
734
734
|
/**
|
|
735
735
|
* @license
|
|
@@ -749,7 +749,7 @@ function Mn(e, t = e.length) {
|
|
|
749
749
|
*/
|
|
750
750
|
function nt(e, t) {
|
|
751
751
|
Array.isArray(e) || (e = [e]), e.forEach((n) => {
|
|
752
|
-
n != null &&
|
|
752
|
+
n != null && Lt(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the CPU backend.`);
|
|
753
753
|
});
|
|
754
754
|
}
|
|
755
755
|
/**
|
|
@@ -774,16 +774,16 @@ function le(e) {
|
|
|
774
774
|
t[n] = Math.abs(e[n]);
|
|
775
775
|
return t;
|
|
776
776
|
}
|
|
777
|
-
const
|
|
777
|
+
const An = (e) => {
|
|
778
778
|
const { x: t } = e.inputs, n = e.backend;
|
|
779
779
|
nt(t, "abs");
|
|
780
|
-
let s = new Float32Array(
|
|
780
|
+
let s = new Float32Array(V(t.shape));
|
|
781
781
|
const o = n.data.get(t.dataId).values;
|
|
782
782
|
return s = le(o), n.makeOutput(s, t.shape, t.dtype);
|
|
783
|
-
},
|
|
784
|
-
kernelName:
|
|
783
|
+
}, Xs = {
|
|
784
|
+
kernelName: Ce,
|
|
785
785
|
backendName: "cpu",
|
|
786
|
-
kernelFunc:
|
|
786
|
+
kernelFunc: An
|
|
787
787
|
};
|
|
788
788
|
/**
|
|
789
789
|
* @license
|
|
@@ -801,20 +801,20 @@ const On = (e) => {
|
|
|
801
801
|
* limitations under the License.
|
|
802
802
|
* =============================================================================
|
|
803
803
|
*/
|
|
804
|
-
function
|
|
804
|
+
function $(e) {
|
|
805
805
|
return (t, n, s, o, a) => {
|
|
806
|
-
const r =
|
|
807
|
-
if (F.length +
|
|
808
|
-
for (let
|
|
809
|
-
h[
|
|
806
|
+
const r = Pt(t, n), i = r.length, l = H(r), u = V(r), h = et(a, u), f = t.length, p = n.length, w = H(t), m = H(n), F = ht(t, r), d = ht(n, r);
|
|
807
|
+
if (F.length + d.length === 0)
|
|
808
|
+
for (let g = 0; g < h.length; ++g)
|
|
809
|
+
h[g] = e(s[g % s.length], o[g % o.length]);
|
|
810
810
|
else
|
|
811
|
-
for (let
|
|
812
|
-
const b =
|
|
813
|
-
F.forEach((
|
|
814
|
-
const y = at(k, f,
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
h[
|
|
811
|
+
for (let g = 0; g < h.length; ++g) {
|
|
812
|
+
const b = dt(g, i, l), k = b.slice(-f);
|
|
813
|
+
F.forEach((O) => k[O] = 0);
|
|
814
|
+
const y = at(k, f, w), v = b.slice(-p);
|
|
815
|
+
d.forEach((O) => v[O] = 0);
|
|
816
|
+
const M = at(v, p, m);
|
|
817
|
+
h[g] = e(s[y], o[M]);
|
|
818
818
|
}
|
|
819
819
|
return [h, r];
|
|
820
820
|
};
|
|
@@ -843,7 +843,7 @@ function mt(e) {
|
|
|
843
843
|
}, i;
|
|
844
844
|
}
|
|
845
845
|
const Js = {
|
|
846
|
-
kernelName:
|
|
846
|
+
kernelName: De,
|
|
847
847
|
backendName: "cpu",
|
|
848
848
|
kernelFunc: mt
|
|
849
849
|
};
|
|
@@ -868,7 +868,7 @@ function xt(e, t, n = "float32") {
|
|
|
868
868
|
const o = xt(e, t, "float32"), a = xt(e, t, "float32");
|
|
869
869
|
return mt({ inputs: { real: o, imag: a }, backend: e });
|
|
870
870
|
}
|
|
871
|
-
const s = st(
|
|
871
|
+
const s = st(V(t), n);
|
|
872
872
|
return e.makeTensorInfo(t, n, s);
|
|
873
873
|
}
|
|
874
874
|
/**
|
|
@@ -892,7 +892,7 @@ function Et(e) {
|
|
|
892
892
|
return n.incRef(s.dataId), { dataId: s.dataId, shape: s.shape, dtype: s.dtype };
|
|
893
893
|
}
|
|
894
894
|
const Qs = {
|
|
895
|
-
kernelName:
|
|
895
|
+
kernelName: We,
|
|
896
896
|
backendName: "cpu",
|
|
897
897
|
kernelFunc: Et
|
|
898
898
|
};
|
|
@@ -916,8 +916,8 @@ function ce(e) {
|
|
|
916
916
|
const { inputs: t, backend: n } = e, { input: s } = t, o = n.data.get(s.dataId).complexTensorInfos.real, a = n.data.get(o.dataId).values;
|
|
917
917
|
return n.makeTensorInfo(o.shape, o.dtype, a);
|
|
918
918
|
}
|
|
919
|
-
const
|
|
920
|
-
kernelName:
|
|
919
|
+
const Ys = {
|
|
920
|
+
kernelName: $e,
|
|
921
921
|
backendName: "cpu",
|
|
922
922
|
kernelFunc: ce
|
|
923
923
|
};
|
|
@@ -943,7 +943,7 @@ function ue(e, t, n, s) {
|
|
|
943
943
|
return [t, "int32", o];
|
|
944
944
|
}
|
|
945
945
|
if (s === "bool") {
|
|
946
|
-
const o = Be([0], n), [a, r] =
|
|
946
|
+
const o = Be([0], n), [a, r] = $((i, l) => i !== l ? 1 : 0)(t, [], e, o, "bool");
|
|
947
947
|
return [r, "bool", a];
|
|
948
948
|
}
|
|
949
949
|
throw new Error(`Error in Cast: failed to cast ${n} to ${s}`);
|
|
@@ -967,8 +967,8 @@ function lt(e) {
|
|
|
967
967
|
const r = n.data.get(o.dataId).values, [i, l, u] = ue(r, o.shape, o.dtype, a);
|
|
968
968
|
return n.makeTensorInfo(i, l, u);
|
|
969
969
|
}
|
|
970
|
-
const
|
|
971
|
-
kernelName:
|
|
970
|
+
const to = {
|
|
971
|
+
kernelName: Ue,
|
|
972
972
|
backendName: "cpu",
|
|
973
973
|
kernelFunc: lt
|
|
974
974
|
};
|
|
@@ -998,35 +998,35 @@ function z(e, t, n, s) {
|
|
|
998
998
|
) : u, p = r.dtype === "string" ? (
|
|
999
999
|
// tslint:disable-next-line: no-any
|
|
1000
1000
|
it(h)
|
|
1001
|
-
) : h,
|
|
1002
|
-
return l.makeTensorInfo(F,
|
|
1001
|
+
) : h, w = s || r.dtype, [m, F] = t(r.shape, i.shape, f, p, w);
|
|
1002
|
+
return l.makeTensorInfo(F, w, m);
|
|
1003
1003
|
} : ({ inputs: o, backend: a }) => {
|
|
1004
1004
|
const { a: r, b: i } = o, l = a;
|
|
1005
1005
|
if (r.dtype === "complex64" || i.dtype === "complex64") {
|
|
1006
|
-
const u = lt({ inputs: { x: r }, backend: l, attrs: { dtype: "complex64" } }), h = l.data.get(u.dataId), f = h.complexTensorInfos.real, p = h.complexTensorInfos.imag,
|
|
1007
|
-
return l.disposeIntermediateTensorInfo(u), l.disposeIntermediateTensorInfo(F), l.disposeIntermediateTensorInfo(
|
|
1006
|
+
const u = lt({ inputs: { x: r }, backend: l, attrs: { dtype: "complex64" } }), h = l.data.get(u.dataId), f = h.complexTensorInfos.real, p = h.complexTensorInfos.imag, w = l.data.get(f.dataId).values, m = l.data.get(p.dataId).values, F = lt({ inputs: { x: i }, backend: l, attrs: { dtype: "complex64" } }), d = l.data.get(F.dataId), g = d.complexTensorInfos.real, b = d.complexTensorInfos.imag, k = l.data.get(g.dataId).values, y = l.data.get(b.dataId).values, [v, M, O] = n(r.shape, i.shape, w, m, k, y), S = l.makeTensorInfo(O, "float32", v), x = l.makeTensorInfo(O, "float32", M), I = mt({ inputs: { real: S, imag: x }, backend: l });
|
|
1007
|
+
return l.disposeIntermediateTensorInfo(u), l.disposeIntermediateTensorInfo(F), l.disposeIntermediateTensorInfo(S), l.disposeIntermediateTensorInfo(x), I;
|
|
1008
1008
|
} else {
|
|
1009
|
-
const u = l.data.get(r.dataId).values, h = l.data.get(i.dataId).values, f = s || r.dtype, [p,
|
|
1010
|
-
return l.makeTensorInfo(
|
|
1009
|
+
const u = l.data.get(r.dataId).values, h = l.data.get(i.dataId).values, f = s || r.dtype, [p, w] = t(r.shape, i.shape, u, h, f);
|
|
1010
|
+
return l.makeTensorInfo(w, f, p);
|
|
1011
1011
|
}
|
|
1012
1012
|
};
|
|
1013
1013
|
}
|
|
1014
1014
|
function Ft(e) {
|
|
1015
1015
|
return (t, n, s, o, a, r) => {
|
|
1016
|
-
const i =
|
|
1017
|
-
if (
|
|
1018
|
-
for (let
|
|
1019
|
-
const
|
|
1020
|
-
f[
|
|
1016
|
+
const i = Pt(t, n), l = V(i), u = i.length, h = H(i), f = et("float32", l), p = et("float32", l), w = ht(t, i), m = ht(n, i), F = kt(s, o), d = kt(a, r), g = t.length, b = H(t), k = n.length, y = H(n);
|
|
1017
|
+
if (w.length + m.length === 0)
|
|
1018
|
+
for (let v = 0; v < f.length; v++) {
|
|
1019
|
+
const M = v % F.length, O = v % d.length, S = e(F[M * 2], F[M * 2 + 1], d[O * 2], d[O * 2 + 1]);
|
|
1020
|
+
f[v] = S.real, p[v] = S.imag;
|
|
1021
1021
|
}
|
|
1022
1022
|
else
|
|
1023
|
-
for (let
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
const
|
|
1023
|
+
for (let v = 0; v < f.length; v++) {
|
|
1024
|
+
const M = dt(v, u, h), O = M.slice(-g);
|
|
1025
|
+
w.forEach((E) => O[E] = 0);
|
|
1026
|
+
const S = at(O, g, b), x = M.slice(-k);
|
|
1027
1027
|
m.forEach((E) => x[E] = 0);
|
|
1028
|
-
const
|
|
1029
|
-
f[
|
|
1028
|
+
const I = at(x, k, y), c = e(F[S * 2], F[S * 2 + 1], d[I * 2], d[I * 2 + 1]);
|
|
1029
|
+
f[v] = c.real, p[v] = c.imag;
|
|
1030
1030
|
}
|
|
1031
1031
|
return [f, p, i];
|
|
1032
1032
|
};
|
|
@@ -1047,10 +1047,10 @@ function Ft(e) {
|
|
|
1047
1047
|
* limitations under the License.
|
|
1048
1048
|
* =============================================================================
|
|
1049
1049
|
*/
|
|
1050
|
-
const he =
|
|
1051
|
-
kernelName:
|
|
1050
|
+
const he = $((e, t) => e + t), _n = Ft((e, t, n, s) => ({ real: e + n, imag: t + s })), Vn = z(qt, he, _n), eo = {
|
|
1051
|
+
kernelName: qt,
|
|
1052
1052
|
backendName: "cpu",
|
|
1053
|
-
kernelFunc:
|
|
1053
|
+
kernelFunc: Vn
|
|
1054
1054
|
};
|
|
1055
1055
|
/**
|
|
1056
1056
|
* @license
|
|
@@ -1068,8 +1068,8 @@ const he = W((e, t) => e + t), Ln = Ft((e, t, n, s) => ({ real: e + n, imag: t +
|
|
|
1068
1068
|
* limitations under the License.
|
|
1069
1069
|
* =============================================================================
|
|
1070
1070
|
*/
|
|
1071
|
-
function
|
|
1072
|
-
const a =
|
|
1071
|
+
function Cn(e, t, n, s, o) {
|
|
1072
|
+
const a = V(s), r = st(o, n);
|
|
1073
1073
|
for (let i = 0; i < e.length; i++) {
|
|
1074
1074
|
const l = e[i];
|
|
1075
1075
|
if (l < 0)
|
|
@@ -1078,8 +1078,8 @@ function _n(e, t, n, s, o) {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
return r;
|
|
1080
1080
|
}
|
|
1081
|
-
function
|
|
1082
|
-
const o = e.shape[0], a = e.shape[1], r =
|
|
1081
|
+
function Dn(e, t, n, s = !1) {
|
|
1082
|
+
const o = e.shape[0], a = e.shape[1], r = K([o, n], t.dtype);
|
|
1083
1083
|
for (let i = 0; i < o; i++)
|
|
1084
1084
|
for (let l = 0; l < a; l++) {
|
|
1085
1085
|
const u = e.get(i, l);
|
|
@@ -1105,10 +1105,10 @@ function Vn(e, t, n, s = !1) {
|
|
|
1105
1105
|
* limitations under the License.
|
|
1106
1106
|
* =============================================================================
|
|
1107
1107
|
*/
|
|
1108
|
-
const fe =
|
|
1109
|
-
kernelName:
|
|
1108
|
+
const fe = $((e, t) => e & t), Wn = z(At, fe), no = {
|
|
1109
|
+
kernelName: At,
|
|
1110
1110
|
backendName: "cpu",
|
|
1111
|
-
kernelFunc:
|
|
1111
|
+
kernelFunc: Wn
|
|
1112
1112
|
};
|
|
1113
1113
|
/**
|
|
1114
1114
|
* @license
|
|
@@ -1128,7 +1128,7 @@ const fe = W((e, t) => e & t), Dn = z(Ot, fe), so = {
|
|
|
1128
1128
|
*/
|
|
1129
1129
|
function X(e) {
|
|
1130
1130
|
return (t, n, s) => {
|
|
1131
|
-
const o =
|
|
1131
|
+
const o = W(n, t.length);
|
|
1132
1132
|
for (let a = 0; a < t.length; ++a)
|
|
1133
1133
|
o[a] = e(t[a], s);
|
|
1134
1134
|
return o;
|
|
@@ -1150,11 +1150,11 @@ function X(e) {
|
|
|
1150
1150
|
* limitations under the License.
|
|
1151
1151
|
* =============================================================================
|
|
1152
1152
|
*/
|
|
1153
|
-
function
|
|
1153
|
+
function de(e, t, n) {
|
|
1154
1154
|
const s = X(t);
|
|
1155
|
-
return
|
|
1155
|
+
return Q(e, s, n);
|
|
1156
1156
|
}
|
|
1157
|
-
function
|
|
1157
|
+
function Q(e, t, n) {
|
|
1158
1158
|
return ({ inputs: s, attrs: o, backend: a }) => {
|
|
1159
1159
|
const { x: r } = s;
|
|
1160
1160
|
nt(r, e);
|
|
@@ -1186,10 +1186,10 @@ function J(e, t, n) {
|
|
|
1186
1186
|
* limitations under the License.
|
|
1187
1187
|
* =============================================================================
|
|
1188
1188
|
*/
|
|
1189
|
-
const
|
|
1190
|
-
kernelName:
|
|
1189
|
+
const ge = X((e) => Math.ceil(e)), $n = Q(_t, ge), so = {
|
|
1190
|
+
kernelName: _t,
|
|
1191
1191
|
backendName: "cpu",
|
|
1192
|
-
kernelFunc:
|
|
1192
|
+
kernelFunc: $n
|
|
1193
1193
|
};
|
|
1194
1194
|
/**
|
|
1195
1195
|
* @license
|
|
@@ -1207,12 +1207,12 @@ const de = X((e) => Math.ceil(e)), Wn = J(Lt, de), oo = {
|
|
|
1207
1207
|
* limitations under the License.
|
|
1208
1208
|
* =============================================================================
|
|
1209
1209
|
*/
|
|
1210
|
-
function
|
|
1211
|
-
const o =
|
|
1210
|
+
function Un(e, t, n, s) {
|
|
1211
|
+
const o = W(n, V(t));
|
|
1212
1212
|
if (s && n !== "string") {
|
|
1213
1213
|
let a = 0;
|
|
1214
1214
|
e.forEach((r) => {
|
|
1215
|
-
const i =
|
|
1215
|
+
const i = V(r.shape);
|
|
1216
1216
|
o.set(r.vals, a), a += i;
|
|
1217
1217
|
});
|
|
1218
1218
|
} else {
|
|
@@ -1246,8 +1246,8 @@ function $n(e, t, n, s) {
|
|
|
1246
1246
|
* limitations under the License.
|
|
1247
1247
|
* =============================================================================
|
|
1248
1248
|
*/
|
|
1249
|
-
const me =
|
|
1250
|
-
kernelName:
|
|
1249
|
+
const me = $((e, t) => e === t ? 1 : 0), zn = z(Vt, me, null, "bool"), oo = {
|
|
1250
|
+
kernelName: Vt,
|
|
1251
1251
|
backendName: "cpu",
|
|
1252
1252
|
kernelFunc: zn
|
|
1253
1253
|
};
|
|
@@ -1267,8 +1267,8 @@ const me = W((e, t) => e === t ? 1 : 0), zn = z(At, me, null, "bool"), ro = {
|
|
|
1267
1267
|
* limitations under the License.
|
|
1268
1268
|
* =============================================================================
|
|
1269
1269
|
*/
|
|
1270
|
-
const pe = X((e) => Math.exp(e)), Bn =
|
|
1271
|
-
kernelName:
|
|
1270
|
+
const pe = X((e) => Math.exp(e)), Bn = Q(Ct, pe, "float32"), ro = {
|
|
1271
|
+
kernelName: Ct,
|
|
1272
1272
|
backendName: "cpu",
|
|
1273
1273
|
kernelFunc: Bn
|
|
1274
1274
|
};
|
|
@@ -1288,10 +1288,10 @@ const pe = X((e) => Math.exp(e)), Bn = J(_t, pe, "float32"), ao = {
|
|
|
1288
1288
|
* limitations under the License.
|
|
1289
1289
|
* =============================================================================
|
|
1290
1290
|
*/
|
|
1291
|
-
const
|
|
1292
|
-
kernelName:
|
|
1291
|
+
const we = X((e) => Math.expm1(e)), jn = Q(Dt, we), ao = {
|
|
1292
|
+
kernelName: Dt,
|
|
1293
1293
|
backendName: "cpu",
|
|
1294
|
-
kernelFunc:
|
|
1294
|
+
kernelFunc: jn
|
|
1295
1295
|
};
|
|
1296
1296
|
/**
|
|
1297
1297
|
* @license
|
|
@@ -1309,10 +1309,10 @@ const Ie = X((e) => Math.expm1(e)), Gn = J(Vt, Ie), io = {
|
|
|
1309
1309
|
* limitations under the License.
|
|
1310
1310
|
* =============================================================================
|
|
1311
1311
|
*/
|
|
1312
|
-
const
|
|
1313
|
-
kernelName:
|
|
1312
|
+
const Ie = X((e) => Math.floor(e)), Gn = Q(Wt, Ie), io = {
|
|
1313
|
+
kernelName: Wt,
|
|
1314
1314
|
backendName: "cpu",
|
|
1315
|
-
kernelFunc:
|
|
1315
|
+
kernelFunc: Gn
|
|
1316
1316
|
};
|
|
1317
1317
|
/**
|
|
1318
1318
|
* @license
|
|
@@ -1330,8 +1330,8 @@ const we = X((e) => Math.floor(e)), jn = J(Dt, we), lo = {
|
|
|
1330
1330
|
* limitations under the License.
|
|
1331
1331
|
* =============================================================================
|
|
1332
1332
|
*/
|
|
1333
|
-
const be =
|
|
1334
|
-
kernelName:
|
|
1333
|
+
const be = $((e, t) => Math.floor(e / t)), Zn = z($t, be, null, "int32"), lo = {
|
|
1334
|
+
kernelName: $t,
|
|
1335
1335
|
backendName: "cpu",
|
|
1336
1336
|
kernelFunc: Zn
|
|
1337
1337
|
};
|
|
@@ -1351,19 +1351,19 @@ const be = W((e, t) => Math.floor(e / t)), Zn = z(Wt, be, null, "int32"), co = {
|
|
|
1351
1351
|
* limitations under the License.
|
|
1352
1352
|
* =============================================================================
|
|
1353
1353
|
*/
|
|
1354
|
-
function
|
|
1355
|
-
const u =
|
|
1354
|
+
function Kn(e, t, n, s, o, a, r, i, l) {
|
|
1355
|
+
const u = K([s, a], n);
|
|
1356
1356
|
for (let h = 0; h < s; h++) {
|
|
1357
1357
|
const f = [];
|
|
1358
1358
|
let p = 0;
|
|
1359
|
-
for (let
|
|
1360
|
-
const m = e[h * o +
|
|
1361
|
-
p += m * r[
|
|
1359
|
+
for (let w = 0; w < o; w++) {
|
|
1360
|
+
const m = e[h * o + w];
|
|
1361
|
+
p += m * r[w], f.push(m);
|
|
1362
1362
|
}
|
|
1363
1363
|
if (p < 0 || p >= l / a)
|
|
1364
1364
|
throw new Error(`Invalid indices: ${f} does not index into ${i}`);
|
|
1365
|
-
for (let
|
|
1366
|
-
u.values[h * a +
|
|
1365
|
+
for (let w = 0; w < a; w++)
|
|
1366
|
+
u.values[h * a + w] = t.get(...t.indexToLoc(p * a + w));
|
|
1367
1367
|
}
|
|
1368
1368
|
return u;
|
|
1369
1369
|
}
|
|
@@ -1383,8 +1383,8 @@ function Hn(e, t, n, s, o, a, r, i, l) {
|
|
|
1383
1383
|
* limitations under the License.
|
|
1384
1384
|
* =============================================================================
|
|
1385
1385
|
*/
|
|
1386
|
-
function
|
|
1387
|
-
const s =
|
|
1386
|
+
function Hn(e, t, n) {
|
|
1387
|
+
const s = K(n, e.dtype);
|
|
1388
1388
|
for (let o = 0; o < s.size; ++o) {
|
|
1389
1389
|
const r = s.indexToLoc(o).slice(), i = r[0], l = r[2], u = t.locToIndex([i, l]);
|
|
1390
1390
|
r[2] = t.values[u];
|
|
@@ -1409,8 +1409,8 @@ function Kn(e, t, n) {
|
|
|
1409
1409
|
* limitations under the License.
|
|
1410
1410
|
* =============================================================================
|
|
1411
1411
|
*/
|
|
1412
|
-
const xe =
|
|
1413
|
-
kernelName:
|
|
1412
|
+
const xe = $((e, t) => e > t ? 1 : 0), Xn = z(Ut, xe, null, "bool"), co = {
|
|
1413
|
+
kernelName: Ut,
|
|
1414
1414
|
backendName: "cpu",
|
|
1415
1415
|
kernelFunc: Xn
|
|
1416
1416
|
};
|
|
@@ -1430,10 +1430,10 @@ const xe = W((e, t) => e > t ? 1 : 0), Xn = z($t, xe, null, "bool"), uo = {
|
|
|
1430
1430
|
* limitations under the License.
|
|
1431
1431
|
* =============================================================================
|
|
1432
1432
|
*/
|
|
1433
|
-
const Ee =
|
|
1433
|
+
const Ee = $((e, t) => e >= t ? 1 : 0), Jn = z(zt, Ee, null, "bool"), uo = {
|
|
1434
1434
|
kernelName: zt,
|
|
1435
1435
|
backendName: "cpu",
|
|
1436
|
-
kernelFunc:
|
|
1436
|
+
kernelFunc: Jn
|
|
1437
1437
|
};
|
|
1438
1438
|
/**
|
|
1439
1439
|
* @license
|
|
@@ -1451,10 +1451,10 @@ const Ee = W((e, t) => e >= t ? 1 : 0), Yn = z(zt, Ee, null, "bool"), ho = {
|
|
|
1451
1451
|
* limitations under the License.
|
|
1452
1452
|
* =============================================================================
|
|
1453
1453
|
*/
|
|
1454
|
-
const Fe =
|
|
1454
|
+
const Fe = $((e, t) => e < t ? 1 : 0), Qn = z(Bt, Fe, null, "bool"), ho = {
|
|
1455
1455
|
kernelName: Bt,
|
|
1456
1456
|
backendName: "cpu",
|
|
1457
|
-
kernelFunc:
|
|
1457
|
+
kernelFunc: Qn
|
|
1458
1458
|
};
|
|
1459
1459
|
/**
|
|
1460
1460
|
* @license
|
|
@@ -1472,10 +1472,10 @@ const Fe = W((e, t) => e < t ? 1 : 0), Jn = z(Bt, Fe, null, "bool"), fo = {
|
|
|
1472
1472
|
* limitations under the License.
|
|
1473
1473
|
* =============================================================================
|
|
1474
1474
|
*/
|
|
1475
|
-
const ye =
|
|
1476
|
-
kernelName:
|
|
1475
|
+
const ye = $((e, t) => e <= t ? 1 : 0), Yn = z(jt, ye, null, "bool"), fo = {
|
|
1476
|
+
kernelName: jt,
|
|
1477
1477
|
backendName: "cpu",
|
|
1478
|
-
kernelFunc:
|
|
1478
|
+
kernelFunc: Yn
|
|
1479
1479
|
};
|
|
1480
1480
|
/**
|
|
1481
1481
|
* @license
|
|
@@ -1516,8 +1516,8 @@ function ts(e, t, n) {
|
|
|
1516
1516
|
* limitations under the License.
|
|
1517
1517
|
* =============================================================================
|
|
1518
1518
|
*/
|
|
1519
|
-
const ke = X((e) => Math.log(e)), es =
|
|
1520
|
-
kernelName:
|
|
1519
|
+
const ke = X((e) => Math.log(e)), es = Q(Gt, ke), go = {
|
|
1520
|
+
kernelName: Gt,
|
|
1521
1521
|
backendName: "cpu",
|
|
1522
1522
|
kernelFunc: es
|
|
1523
1523
|
};
|
|
@@ -1538,7 +1538,7 @@ const ke = X((e) => Math.log(e)), es = J(jt, ke), mo = {
|
|
|
1538
1538
|
* =============================================================================
|
|
1539
1539
|
*/
|
|
1540
1540
|
function ns(e, t, n, s) {
|
|
1541
|
-
const o = et(s,
|
|
1541
|
+
const o = et(s, V(n));
|
|
1542
1542
|
for (let a = 0; a < o.length; ++a) {
|
|
1543
1543
|
const r = a * t;
|
|
1544
1544
|
let i = e[r];
|
|
@@ -1566,7 +1566,7 @@ function ns(e, t, n, s) {
|
|
|
1566
1566
|
* limitations under the License.
|
|
1567
1567
|
* =============================================================================
|
|
1568
1568
|
*/
|
|
1569
|
-
const Ne =
|
|
1569
|
+
const Ne = $((e, t) => Math.max(e, t)), ss = z(Zt, Ne), mo = {
|
|
1570
1570
|
kernelName: Zt,
|
|
1571
1571
|
backendName: "cpu",
|
|
1572
1572
|
kernelFunc: ss
|
|
@@ -1587,8 +1587,8 @@ const Ne = W((e, t) => Math.max(e, t)), ss = z(Zt, Ne), po = {
|
|
|
1587
1587
|
* limitations under the License.
|
|
1588
1588
|
* =============================================================================
|
|
1589
1589
|
*/
|
|
1590
|
-
const
|
|
1591
|
-
kernelName:
|
|
1590
|
+
const ve = $((e, t) => Math.min(e, t)), os = z(Kt, ve), po = {
|
|
1591
|
+
kernelName: Kt,
|
|
1592
1592
|
backendName: "cpu",
|
|
1593
1593
|
kernelFunc: os
|
|
1594
1594
|
};
|
|
@@ -1608,11 +1608,11 @@ const Se = W((e, t) => Math.min(e, t)), os = z(Ht, Se), Io = {
|
|
|
1608
1608
|
* limitations under the License.
|
|
1609
1609
|
* =============================================================================
|
|
1610
1610
|
*/
|
|
1611
|
-
const yt =
|
|
1611
|
+
const yt = $((e, t) => e * t), rs = Ft((e, t, n, s) => ({
|
|
1612
1612
|
real: e * n - t * s,
|
|
1613
1613
|
imag: e * s + t * n
|
|
1614
|
-
})), as = z(
|
|
1615
|
-
kernelName:
|
|
1614
|
+
})), as = z(Ht, yt, rs), wo = {
|
|
1615
|
+
kernelName: Ht,
|
|
1616
1616
|
backendName: "cpu",
|
|
1617
1617
|
kernelFunc: as
|
|
1618
1618
|
};
|
|
@@ -1632,18 +1632,18 @@ const yt = W((e, t) => e * t), rs = Ft((e, t, n, s) => ({
|
|
|
1632
1632
|
* limitations under the License.
|
|
1633
1633
|
* =============================================================================
|
|
1634
1634
|
*/
|
|
1635
|
-
function
|
|
1636
|
-
const s =
|
|
1635
|
+
function Se(e, t, n) {
|
|
1636
|
+
const s = Ge(-1, n);
|
|
1637
1637
|
return yt([], t, s, e, n);
|
|
1638
1638
|
}
|
|
1639
1639
|
function is(e) {
|
|
1640
1640
|
const { inputs: t, backend: n } = e, { x: s } = t;
|
|
1641
1641
|
nt(s, "neg");
|
|
1642
|
-
const o = n.data.get(s.dataId).values, [a, r] =
|
|
1642
|
+
const o = n.data.get(s.dataId).values, [a, r] = Se(o, s.shape, s.dtype);
|
|
1643
1643
|
return n.makeTensorInfo(r, s.dtype, a);
|
|
1644
1644
|
}
|
|
1645
|
-
const
|
|
1646
|
-
kernelName:
|
|
1645
|
+
const Io = {
|
|
1646
|
+
kernelName: je,
|
|
1647
1647
|
backendName: "cpu",
|
|
1648
1648
|
kernelFunc: is
|
|
1649
1649
|
};
|
|
@@ -1663,7 +1663,7 @@ const bo = {
|
|
|
1663
1663
|
* limitations under the License.
|
|
1664
1664
|
* =============================================================================
|
|
1665
1665
|
*/
|
|
1666
|
-
const Te =
|
|
1666
|
+
const Te = $((e, t) => e !== t ? 1 : 0), ls = z(Xt, Te, null, "bool"), bo = {
|
|
1667
1667
|
kernelName: Xt,
|
|
1668
1668
|
backendName: "cpu",
|
|
1669
1669
|
kernelFunc: ls
|
|
@@ -1685,13 +1685,13 @@ const Te = W((e, t) => e !== t ? 1 : 0), ls = z(Xt, Te, null, "bool"), xo = {
|
|
|
1685
1685
|
* =============================================================================
|
|
1686
1686
|
*/
|
|
1687
1687
|
function Re(e, t, n, s, o) {
|
|
1688
|
-
const a = t.length, r =
|
|
1688
|
+
const a = t.length, r = V(t), i = H(t), l = H(o), u = et(n, V(o));
|
|
1689
1689
|
for (let h = 0; h < r; ++h) {
|
|
1690
|
-
const f =
|
|
1690
|
+
const f = dt(h, a, i), p = new Array(f.length);
|
|
1691
1691
|
for (let m = 0; m < p.length; m++)
|
|
1692
1692
|
p[m] = f[s[m]];
|
|
1693
|
-
const
|
|
1694
|
-
u[
|
|
1693
|
+
const w = at(p, a, l);
|
|
1694
|
+
u[w] = e[h];
|
|
1695
1695
|
}
|
|
1696
1696
|
return u;
|
|
1697
1697
|
}
|
|
@@ -1711,7 +1711,7 @@ function Re(e, t, n, s, o) {
|
|
|
1711
1711
|
* limitations under the License.
|
|
1712
1712
|
* =============================================================================
|
|
1713
1713
|
*/
|
|
1714
|
-
function
|
|
1714
|
+
function Me(e) {
|
|
1715
1715
|
const { inputs: t, attrs: n, backend: s } = e, { x: o } = t, { perm: a } = n;
|
|
1716
1716
|
nt(o, "transpose");
|
|
1717
1717
|
const r = o.shape.length, i = new Array(r);
|
|
@@ -1720,10 +1720,10 @@ function Pe(e) {
|
|
|
1720
1720
|
const l = s.data.get(o.dataId).values, u = Re(l, o.shape, o.dtype, a, i);
|
|
1721
1721
|
return { dataId: s.write(u, i, o.dtype), shape: i, dtype: o.dtype };
|
|
1722
1722
|
}
|
|
1723
|
-
const
|
|
1723
|
+
const xo = {
|
|
1724
1724
|
kernelName: Ze,
|
|
1725
1725
|
backendName: "cpu",
|
|
1726
|
-
kernelFunc:
|
|
1726
|
+
kernelFunc: Me
|
|
1727
1727
|
};
|
|
1728
1728
|
/**
|
|
1729
1729
|
* @license
|
|
@@ -1741,8 +1741,8 @@ const Eo = {
|
|
|
1741
1741
|
* limitations under the License.
|
|
1742
1742
|
* =============================================================================
|
|
1743
1743
|
*/
|
|
1744
|
-
function
|
|
1745
|
-
const [o, a] = bn(e, s), r =
|
|
1744
|
+
function Oe(e, t, n, s) {
|
|
1745
|
+
const [o, a] = bn(e, s), r = He(t, "int32"), i = st(V(o), r), l = V(a);
|
|
1746
1746
|
for (let u = 0; u < i.length; ++u) {
|
|
1747
1747
|
const h = u * l;
|
|
1748
1748
|
let f = 1;
|
|
@@ -1755,16 +1755,16 @@ function Ce(e, t, n, s) {
|
|
|
1755
1755
|
function cs(e) {
|
|
1756
1756
|
const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { axis: a, keepDims: r } = s;
|
|
1757
1757
|
nt(o, "prod");
|
|
1758
|
-
const i = o.shape.length, l =
|
|
1758
|
+
const i = o.shape.length, l = Jt(a, o.shape), u = pn(l, i);
|
|
1759
1759
|
let h = l, f = o;
|
|
1760
1760
|
const p = [];
|
|
1761
|
-
u != null && (f =
|
|
1762
|
-
const
|
|
1763
|
-
let
|
|
1764
|
-
return r && (
|
|
1761
|
+
u != null && (f = Me({ inputs: { x: o }, backend: n, attrs: { perm: u } }), p.push(f), h = wn(h.length, i));
|
|
1762
|
+
const w = n.data.get(f.dataId).values, { outVals: m, outShape: F, outDtype: d } = Oe(f.shape, f.dtype, w, h);
|
|
1763
|
+
let g = F;
|
|
1764
|
+
return r && (g = In(F, l)), p.forEach((b) => n.disposeIntermediateTensorInfo(b)), n.makeTensorInfo(g, d, m);
|
|
1765
1765
|
}
|
|
1766
|
-
const
|
|
1767
|
-
kernelName:
|
|
1766
|
+
const Eo = {
|
|
1767
|
+
kernelName: Ke,
|
|
1768
1768
|
backendName: "cpu",
|
|
1769
1769
|
kernelFunc: cs
|
|
1770
1770
|
};
|
|
@@ -1787,7 +1787,7 @@ const Fo = {
|
|
|
1787
1787
|
function us(e, t, n) {
|
|
1788
1788
|
e.forEach((s, o) => {
|
|
1789
1789
|
if (s < 0 || s >= n) {
|
|
1790
|
-
const a =
|
|
1790
|
+
const a = dt(o, t.length, H(t)).join(",");
|
|
1791
1791
|
throw new Error(`indices[${a}] = ${s} is not in [0, ${n})`);
|
|
1792
1792
|
}
|
|
1793
1793
|
});
|
|
@@ -1821,22 +1821,22 @@ function fs(e, t, n, s) {
|
|
|
1821
1821
|
for (let u = 0; u < e.length; ++u) {
|
|
1822
1822
|
let h = e[u], f = e[u] + 1;
|
|
1823
1823
|
for (let p = 0; p < n.length; ++p) {
|
|
1824
|
-
const
|
|
1824
|
+
const w = n[p], m = p + t.length - 1;
|
|
1825
1825
|
if (m >= 0) {
|
|
1826
|
-
const F = i[m],
|
|
1827
|
-
for (let
|
|
1828
|
-
i[m].push(
|
|
1826
|
+
const F = i[m], d = F[F.length - 1] - w[h];
|
|
1827
|
+
for (let g = h; g < f; ++g)
|
|
1828
|
+
i[m].push(w[g + 1] + d);
|
|
1829
1829
|
}
|
|
1830
|
-
h =
|
|
1830
|
+
h = w[h], f = w[f];
|
|
1831
1831
|
}
|
|
1832
1832
|
f !== h && (o.push([h, f]), a += f - h);
|
|
1833
1833
|
}
|
|
1834
1834
|
return { outSplits: i, valueSlices: o, numValues: a };
|
|
1835
1835
|
}
|
|
1836
|
-
function
|
|
1836
|
+
function ds(e) {
|
|
1837
1837
|
const t = [];
|
|
1838
1838
|
for (let n = 0; n < e.length; ++n) {
|
|
1839
|
-
const s = e[n].length, o =
|
|
1839
|
+
const s = e[n].length, o = W("int32", s);
|
|
1840
1840
|
t.push(o), e[n].forEach((a, r) => o[r] = a);
|
|
1841
1841
|
}
|
|
1842
1842
|
return t;
|
|
@@ -1849,7 +1849,7 @@ function Tt(e, t) {
|
|
|
1849
1849
|
n[t - 1] *= e[s];
|
|
1850
1850
|
return n;
|
|
1851
1851
|
}
|
|
1852
|
-
function
|
|
1852
|
+
function gs(e, t, n, s, o, a) {
|
|
1853
1853
|
const r = Tt(t, 2)[1], i = Tt(a, 2)[1];
|
|
1854
1854
|
let l = 0;
|
|
1855
1855
|
for (const u of n)
|
|
@@ -1862,8 +1862,8 @@ function ds(e, t, n, s, o, a) {
|
|
|
1862
1862
|
function ms(e, t, n, s, o) {
|
|
1863
1863
|
const a = t.slice();
|
|
1864
1864
|
a[0] = o;
|
|
1865
|
-
const r =
|
|
1866
|
-
return
|
|
1865
|
+
const r = W(n, V(a)), i = e.length, l = i === 0 ? 0 : i / t[0];
|
|
1866
|
+
return gs(e, t, s, l, r, a), [r, a];
|
|
1867
1867
|
}
|
|
1868
1868
|
function ps(e, t, n, s, o, a, r, i) {
|
|
1869
1869
|
if (e.length === 0)
|
|
@@ -1873,8 +1873,8 @@ function ps(e, t, n, s, o, a, r, i) {
|
|
|
1873
1873
|
const l = t[0][0] - 1;
|
|
1874
1874
|
if (us(a, r, l), s.length === 0)
|
|
1875
1875
|
throw new Error("params.rank must be nonzero");
|
|
1876
|
-
const u = s[0], { outSplits: h, valueSlices: f, numValues: p } = fs(a, r, e, u),
|
|
1877
|
-
return [
|
|
1876
|
+
const u = s[0], { outSplits: h, valueSlices: f, numValues: p } = fs(a, r, e, u), w = ds(h), m = ms(n, s, o, f, p);
|
|
1877
|
+
return [w, m[0], m[1]];
|
|
1878
1878
|
}
|
|
1879
1879
|
/**
|
|
1880
1880
|
* @license
|
|
@@ -1893,7 +1893,7 @@ function ps(e, t, n, s, o, a, r, i) {
|
|
|
1893
1893
|
* =============================================================================
|
|
1894
1894
|
*/
|
|
1895
1895
|
const Rt = 2147483647;
|
|
1896
|
-
function
|
|
1896
|
+
function ws(e, t, n, s, o, a, r) {
|
|
1897
1897
|
if (t.length > 1)
|
|
1898
1898
|
throw new Error("starts must be a scalar or vector");
|
|
1899
1899
|
if (o.length > 1)
|
|
@@ -1902,29 +1902,29 @@ function Is(e, t, n, s, o, a, r) {
|
|
|
1902
1902
|
throw new Error("deltas must be a scalar or vector");
|
|
1903
1903
|
const i = t.length === 0, l = o.length === 0, u = r.length === 0, h = [];
|
|
1904
1904
|
i || h.push(t[0]), l || h.push(o[0]), u || h.push(r[0]);
|
|
1905
|
-
for (let
|
|
1906
|
-
if (h[
|
|
1905
|
+
for (let d = 1; d < h.length; ++d)
|
|
1906
|
+
if (h[d] !== h[d - 1])
|
|
1907
1907
|
throw new Error("starts, limits, and deltas must have the same shape");
|
|
1908
|
-
const f = h.length === 0 ? 1 : h[0], p =
|
|
1908
|
+
const f = h.length === 0 ? 1 : h[0], p = W("int32", f + 1);
|
|
1909
1909
|
p[0] = 0;
|
|
1910
|
-
for (let
|
|
1911
|
-
const
|
|
1910
|
+
for (let d = 0; d < f; ++d) {
|
|
1911
|
+
const g = i ? e[0] : e[d], b = l ? s[0] : s[d], k = u ? a[0] : a[d];
|
|
1912
1912
|
if (k === 0)
|
|
1913
1913
|
throw new Error("Requires delta != 0");
|
|
1914
1914
|
let y;
|
|
1915
|
-
if (k > 0 && b <
|
|
1915
|
+
if (k > 0 && b < g || k < 0 && b > g)
|
|
1916
1916
|
y = 0;
|
|
1917
|
-
else if (y = Math.ceil(Math.abs((b -
|
|
1917
|
+
else if (y = Math.ceil(Math.abs((b - g) / k)), y > Rt)
|
|
1918
1918
|
throw new Error(`Requires ((limit - start) / delta) <= ${Rt}`);
|
|
1919
|
-
p[
|
|
1919
|
+
p[d + 1] = p[d] + y;
|
|
1920
1920
|
}
|
|
1921
|
-
const
|
|
1921
|
+
const w = p[f], m = W(n, w);
|
|
1922
1922
|
let F = 0;
|
|
1923
|
-
for (let
|
|
1924
|
-
const
|
|
1925
|
-
let b = i ? e[0] : e[
|
|
1926
|
-
const k = u ? a[0] : a[
|
|
1927
|
-
for (let y = 0; y <
|
|
1923
|
+
for (let d = 0; d < f; ++d) {
|
|
1924
|
+
const g = p[d + 1] - p[d];
|
|
1925
|
+
let b = i ? e[0] : e[d];
|
|
1926
|
+
const k = u ? a[0] : a[d];
|
|
1927
|
+
for (let y = 0; y < g; ++y)
|
|
1928
1928
|
m[F++] = b, b += k;
|
|
1929
1929
|
}
|
|
1930
1930
|
return [p, m];
|
|
@@ -1948,7 +1948,7 @@ function Is(e, t, n, s, o, a, r) {
|
|
|
1948
1948
|
var Z = tn;
|
|
1949
1949
|
class ft {
|
|
1950
1950
|
constructor(t, n, s, o, a, r, i, l, u, h) {
|
|
1951
|
-
this.shape = t, this.shapeShape = n, this.values = s, this.valuesShape = o, this.valuesDType = a, this.defaultValue = r, this.defaultValueShape = i, this.rowPartitionValues = l, this.rowPartitionValuesShapes = u, this.rowPartitionTypes =
|
|
1951
|
+
this.shape = t, this.shapeShape = n, this.values = s, this.valuesShape = o, this.valuesDType = a, this.defaultValue = r, this.defaultValueShape = i, this.rowPartitionValues = l, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = Qe(h), this.raggedRank = Ye(this.rowPartitionTypes);
|
|
1952
1952
|
}
|
|
1953
1953
|
getRowPartitionTypeByDimension(t) {
|
|
1954
1954
|
return this.rowPartitionTypes[0] === Z.FIRST_DIM_SIZE ? this.rowPartitionTypes[t + 1] : this.rowPartitionTypes[t];
|
|
@@ -1996,7 +1996,7 @@ class ft {
|
|
|
1996
1996
|
return [];
|
|
1997
1997
|
throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.");
|
|
1998
1998
|
}
|
|
1999
|
-
return
|
|
1999
|
+
return Ot(t, s);
|
|
2000
2000
|
}
|
|
2001
2001
|
calculateOutputSize(t) {
|
|
2002
2002
|
const n = this.valuesShape, s = this.defaultValueShape;
|
|
@@ -2024,7 +2024,7 @@ class ft {
|
|
|
2024
2024
|
a.push(r);
|
|
2025
2025
|
for (let i = o; i < t; ++i)
|
|
2026
2026
|
a.push(-1);
|
|
2027
|
-
return
|
|
2027
|
+
return Lt(a.length === t, () => "Final length of result must be equal to firstDimension."), a;
|
|
2028
2028
|
}
|
|
2029
2029
|
calculateOutputIndexRowSplit(t, n, s, o) {
|
|
2030
2030
|
const a = t.length, r = [];
|
|
@@ -2122,7 +2122,7 @@ class ft {
|
|
|
2122
2122
|
o[o.length - 1] = 1;
|
|
2123
2123
|
for (let l = o.length - 2; l >= 0; --l)
|
|
2124
2124
|
o[l] = o[l + 1] * s[l + 1];
|
|
2125
|
-
const a =
|
|
2125
|
+
const a = Ot(s, !1), r = W(this.valuesDType, V(a));
|
|
2126
2126
|
if (o[0] * s[0] > 0) {
|
|
2127
2127
|
let l = this.calculateFirstParentOutputIndex(n, o[0], s[0]);
|
|
2128
2128
|
for (let u = 1; u <= this.raggedRank; ++u)
|
|
@@ -2137,7 +2137,7 @@ class ft {
|
|
|
2137
2137
|
const a = this.values, r = s;
|
|
2138
2138
|
let i = o.slice();
|
|
2139
2139
|
i = i.slice(t + 1);
|
|
2140
|
-
const l =
|
|
2140
|
+
const l = V(i), u = n.length;
|
|
2141
2141
|
let h = this.defaultValue;
|
|
2142
2142
|
if (h.length !== l && h.length !== 1) {
|
|
2143
2143
|
const m = this.defaultValueShape;
|
|
@@ -2146,38 +2146,38 @@ class ft {
|
|
|
2146
2146
|
h = xn(F, i).dataSync();
|
|
2147
2147
|
});
|
|
2148
2148
|
}
|
|
2149
|
-
let f = 0, p = 0,
|
|
2149
|
+
let f = 0, p = 0, w = 0;
|
|
2150
2150
|
for (let m = 0; m <= u; ++m) {
|
|
2151
2151
|
let F = m < u ? n[m] : -1;
|
|
2152
|
-
if (F ===
|
|
2153
|
-
++
|
|
2152
|
+
if (F === w) {
|
|
2153
|
+
++w;
|
|
2154
2154
|
continue;
|
|
2155
2155
|
}
|
|
2156
|
-
if (p <
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2156
|
+
if (p < w) {
|
|
2157
|
+
const d = a.subarray(f * l), g = r.subarray(p * l), b = (w - p) * l;
|
|
2158
|
+
Mt(g, d, b);
|
|
2159
2159
|
}
|
|
2160
2160
|
if (m >= u) {
|
|
2161
|
-
const
|
|
2162
|
-
F = Math.floor(
|
|
2161
|
+
const d = s.length;
|
|
2162
|
+
F = Math.floor(d / l);
|
|
2163
2163
|
}
|
|
2164
|
-
if (F >
|
|
2164
|
+
if (F > w)
|
|
2165
2165
|
if (this.defaultValue.length === 1)
|
|
2166
|
-
r.subarray(
|
|
2166
|
+
r.subarray(w * l, F * l).fill(this.defaultValue[0]), w = F;
|
|
2167
2167
|
else
|
|
2168
|
-
for (; F >
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2168
|
+
for (; F > w; ) {
|
|
2169
|
+
const d = r.slice(w * l);
|
|
2170
|
+
Mt(d, h, l), ++w;
|
|
2171
2171
|
}
|
|
2172
|
-
F < 0 ? (f = m + 1, p =
|
|
2172
|
+
F < 0 ? (f = m + 1, p = w) : (f = m, p = w, w = p + 1);
|
|
2173
2173
|
}
|
|
2174
2174
|
}
|
|
2175
2175
|
}
|
|
2176
|
-
function
|
|
2176
|
+
function Mt(e, t, n) {
|
|
2177
2177
|
for (let s = 0; s < n; s++)
|
|
2178
2178
|
e[s] = t[s];
|
|
2179
2179
|
}
|
|
2180
|
-
function
|
|
2180
|
+
function Ot(e, t) {
|
|
2181
2181
|
const n = [];
|
|
2182
2182
|
for (let s of e) {
|
|
2183
2183
|
if (s < 0) {
|
|
@@ -2191,7 +2191,7 @@ function Ct(e, t) {
|
|
|
2191
2191
|
}
|
|
2192
2192
|
return n;
|
|
2193
2193
|
}
|
|
2194
|
-
function
|
|
2194
|
+
function Is(e, t, n, s, o, a, r, i, l, u) {
|
|
2195
2195
|
return new ft(e, t, n, s, o, a, r, i, l, u).compute();
|
|
2196
2196
|
}
|
|
2197
2197
|
/**
|
|
@@ -2236,8 +2236,8 @@ function bs(e, t, n, s) {
|
|
|
2236
2236
|
* limitations under the License.
|
|
2237
2237
|
* =============================================================================
|
|
2238
2238
|
*/
|
|
2239
|
-
const
|
|
2240
|
-
kernelName:
|
|
2239
|
+
const Le = X((e) => 1 / Math.sqrt(e)), xs = Q(Qt, Le), Fo = {
|
|
2240
|
+
kernelName: Qt,
|
|
2241
2241
|
backendName: "cpu",
|
|
2242
2242
|
kernelFunc: xs
|
|
2243
2243
|
};
|
|
@@ -2260,22 +2260,22 @@ const qe = X((e) => 1 / Math.sqrt(e)), xs = J(Jt, qe), yo = {
|
|
|
2260
2260
|
function Es(e, t, n, s, o, a, r, i, l, u) {
|
|
2261
2261
|
const h = [s / o, o], f = e.values, p = t.values;
|
|
2262
2262
|
if (s === 0)
|
|
2263
|
-
return
|
|
2264
|
-
const
|
|
2265
|
-
typeof l == "string" || typeof l == "number" ?
|
|
2263
|
+
return K(n, t.dtype);
|
|
2264
|
+
const w = l instanceof It ? l : K(h, t.dtype);
|
|
2265
|
+
typeof l == "string" || typeof l == "number" ? w.values.fill(l) : typeof l == "boolean" && w.values.fill(+l);
|
|
2266
2266
|
for (let m = 0; m < a; m++) {
|
|
2267
2267
|
const F = [];
|
|
2268
|
-
let
|
|
2269
|
-
for (let
|
|
2270
|
-
const b = f[m * r +
|
|
2271
|
-
F.push(b),
|
|
2268
|
+
let d = 0;
|
|
2269
|
+
for (let g = 0; g < r; g++) {
|
|
2270
|
+
const b = f[m * r + g];
|
|
2271
|
+
F.push(b), d += b * i[g];
|
|
2272
2272
|
}
|
|
2273
|
-
if (
|
|
2273
|
+
if (d < 0 || d >= s / o)
|
|
2274
2274
|
throw new Error(`Invalid indices: ${F} does not index into ${n}`);
|
|
2275
|
-
for (let
|
|
2276
|
-
u ?
|
|
2275
|
+
for (let g = 0; g < o; g++)
|
|
2276
|
+
u ? w.values[d * o + g] += p[m * o + g] : w.values[d * o + g] = t.rank === 0 ? p[0] : p[m * o + g];
|
|
2277
2277
|
}
|
|
2278
|
-
return
|
|
2278
|
+
return w;
|
|
2279
2279
|
}
|
|
2280
2280
|
/**
|
|
2281
2281
|
* @license
|
|
@@ -2293,8 +2293,8 @@ function Es(e, t, n, s, o, a, r, i, l, u) {
|
|
|
2293
2293
|
* limitations under the License.
|
|
2294
2294
|
* =============================================================================
|
|
2295
2295
|
*/
|
|
2296
|
-
const Fs = X((e) => 1 / (1 + Math.exp(-e))), ys =
|
|
2297
|
-
kernelName:
|
|
2296
|
+
const Fs = X((e) => 1 / (1 + Math.exp(-e))), ys = de(Yt, (e) => 1 / (1 + Math.exp(-e))), yo = {
|
|
2297
|
+
kernelName: Yt,
|
|
2298
2298
|
backendName: "cpu",
|
|
2299
2299
|
kernelFunc: ys
|
|
2300
2300
|
};
|
|
@@ -2314,16 +2314,16 @@ const Fs = X((e) => 1 / (1 + Math.exp(-e))), ys = ge(Qt, (e) => 1 / (1 + Math.ex
|
|
|
2314
2314
|
* limitations under the License.
|
|
2315
2315
|
* =============================================================================
|
|
2316
2316
|
*/
|
|
2317
|
-
function
|
|
2318
|
-
const a = kn(s, t, n), r =
|
|
2317
|
+
function Pe(e, t, n, s, o) {
|
|
2318
|
+
const a = kn(s, t, n), r = V(n), i = H(s);
|
|
2319
2319
|
if (a) {
|
|
2320
2320
|
const f = Nn(t, i);
|
|
2321
2321
|
return o === "string" ? e.slice(f, f + r) : e.subarray(f, f + r);
|
|
2322
2322
|
}
|
|
2323
|
-
const l = o === "string" ? it(e) : e, u =
|
|
2323
|
+
const l = o === "string" ? it(e) : e, u = K(s, o, l), h = K(n, o);
|
|
2324
2324
|
for (let f = 0; f < h.size; ++f) {
|
|
2325
|
-
const p = h.indexToLoc(f),
|
|
2326
|
-
h.set(u.get(...
|
|
2325
|
+
const p = h.indexToLoc(f), w = p.map((m, F) => m + t[F]);
|
|
2326
|
+
h.set(u.get(...w), ...p);
|
|
2327
2327
|
}
|
|
2328
2328
|
return o === "string" ? sn(h.values) : h.values;
|
|
2329
2329
|
}
|
|
@@ -2332,11 +2332,11 @@ function ks(e) {
|
|
|
2332
2332
|
nt(o, "slice");
|
|
2333
2333
|
const [i, l] = Fn(o, a, r);
|
|
2334
2334
|
yn(o, i, l);
|
|
2335
|
-
const u = n.data.get(o.dataId).values, h =
|
|
2335
|
+
const u = n.data.get(o.dataId).values, h = Pe(u, i, l, o.shape, o.dtype);
|
|
2336
2336
|
return n.makeTensorInfo(l, o.dtype, h);
|
|
2337
2337
|
}
|
|
2338
|
-
const
|
|
2339
|
-
kernelName:
|
|
2338
|
+
const ko = {
|
|
2339
|
+
kernelName: Je,
|
|
2340
2340
|
backendName: "cpu",
|
|
2341
2341
|
kernelFunc: ks
|
|
2342
2342
|
};
|
|
@@ -2361,61 +2361,61 @@ function Ns(e, t, n, s, o, a, r) {
|
|
|
2361
2361
|
if (l === 0) {
|
|
2362
2362
|
if (i !== 0)
|
|
2363
2363
|
throw new Error(on(i));
|
|
2364
|
-
const
|
|
2364
|
+
const d = W(n, 0), g = W(o, 0);
|
|
2365
2365
|
return [
|
|
2366
|
-
g,
|
|
2367
|
-
[0, f],
|
|
2368
2366
|
d,
|
|
2367
|
+
[0, f],
|
|
2368
|
+
g,
|
|
2369
2369
|
u,
|
|
2370
2370
|
h
|
|
2371
2371
|
];
|
|
2372
2372
|
}
|
|
2373
|
-
let p = !0,
|
|
2373
|
+
let p = !0, w = 0;
|
|
2374
2374
|
const m = new Array(l).fill(0);
|
|
2375
|
-
for (let
|
|
2376
|
-
const
|
|
2377
|
-
if (
|
|
2378
|
-
throw new Error(rn(
|
|
2379
|
-
if (
|
|
2380
|
-
throw new Error(an(
|
|
2381
|
-
++m[
|
|
2375
|
+
for (let d = 0; d < i; ++d) {
|
|
2376
|
+
const g = e[d * f];
|
|
2377
|
+
if (g < 0)
|
|
2378
|
+
throw new Error(rn(d, g));
|
|
2379
|
+
if (g >= l)
|
|
2380
|
+
throw new Error(an(d, g, l));
|
|
2381
|
+
++m[g], p = p && g >= w, w = g;
|
|
2382
2382
|
}
|
|
2383
2383
|
let F = !0;
|
|
2384
|
-
for (let
|
|
2385
|
-
const
|
|
2386
|
-
u[
|
|
2384
|
+
for (let d = 0; d < l; ++d) {
|
|
2385
|
+
const g = m[d] === 0;
|
|
2386
|
+
u[d] = g, F = F && !g, m[d] = Math.max(m[d], 1), d > 0 && (m[d] += m[d - 1]);
|
|
2387
2387
|
}
|
|
2388
2388
|
if (F && p) {
|
|
2389
|
-
const
|
|
2389
|
+
const d = e, g = s;
|
|
2390
2390
|
for (let b = 0; b < i; ++b)
|
|
2391
2391
|
h[b] = b;
|
|
2392
2392
|
return [
|
|
2393
|
-
g,
|
|
2394
|
-
[i, f],
|
|
2395
2393
|
d,
|
|
2394
|
+
[i, f],
|
|
2395
|
+
g,
|
|
2396
2396
|
u,
|
|
2397
2397
|
h
|
|
2398
2398
|
];
|
|
2399
2399
|
} else {
|
|
2400
|
-
const
|
|
2400
|
+
const d = m[l - 1], g = W(n, d * f), b = W(o, d), k = new Array(l).fill(0);
|
|
2401
2401
|
for (let y = 0; y < i; ++y) {
|
|
2402
|
-
const
|
|
2403
|
-
k[
|
|
2404
|
-
for (let
|
|
2405
|
-
|
|
2406
|
-
b[
|
|
2402
|
+
const v = e[y * f], M = k[v], O = (v === 0 ? 0 : m[v - 1]) + M;
|
|
2403
|
+
k[v]++;
|
|
2404
|
+
for (let S = 0; S < f; ++S)
|
|
2405
|
+
g[O * f + S] = e[y * f + S];
|
|
2406
|
+
b[O] = s[y], h[y] = O;
|
|
2407
2407
|
}
|
|
2408
2408
|
for (let y = 0; y < l; ++y)
|
|
2409
2409
|
if (k[y] === 0) {
|
|
2410
|
-
const
|
|
2411
|
-
|
|
2412
|
-
for (let
|
|
2413
|
-
|
|
2414
|
-
b[
|
|
2410
|
+
const M = y === 0 ? 0 : m[y - 1];
|
|
2411
|
+
g[M * f + 0] = y;
|
|
2412
|
+
for (let O = 1; O < f; ++O)
|
|
2413
|
+
g[M * f + O] = 0;
|
|
2414
|
+
b[M] = r;
|
|
2415
2415
|
}
|
|
2416
2416
|
return [
|
|
2417
|
-
|
|
2418
|
-
[
|
|
2417
|
+
g,
|
|
2418
|
+
[d, f],
|
|
2419
2419
|
b,
|
|
2420
2420
|
u,
|
|
2421
2421
|
h
|
|
@@ -2438,50 +2438,50 @@ function Ns(e, t, n, s, o, a, r) {
|
|
|
2438
2438
|
* limitations under the License.
|
|
2439
2439
|
* =============================================================================
|
|
2440
2440
|
*/
|
|
2441
|
-
function
|
|
2442
|
-
const a =
|
|
2441
|
+
function vs(e, t, n, s, o) {
|
|
2442
|
+
const a = V(s), r = t[0], i = o.length, l = [];
|
|
2443
2443
|
let u = 1, h = -1;
|
|
2444
|
-
for (let
|
|
2445
|
-
const
|
|
2446
|
-
if (
|
|
2444
|
+
for (let d = 0; d < i; ++d) {
|
|
2445
|
+
const g = o[d];
|
|
2446
|
+
if (g === -1) {
|
|
2447
2447
|
if (h !== -1)
|
|
2448
|
-
throw new Error(ln(h,
|
|
2449
|
-
h =
|
|
2448
|
+
throw new Error(ln(h, d));
|
|
2449
|
+
h = d, l.push(1);
|
|
2450
2450
|
} else {
|
|
2451
|
-
if (
|
|
2452
|
-
throw new Error(cn(
|
|
2453
|
-
u *=
|
|
2451
|
+
if (g < 0)
|
|
2452
|
+
throw new Error(cn(d, g));
|
|
2453
|
+
u *= g, l.push(g);
|
|
2454
2454
|
}
|
|
2455
2455
|
}
|
|
2456
2456
|
if (h !== -1) {
|
|
2457
2457
|
if (u <= 0)
|
|
2458
2458
|
throw new Error(un());
|
|
2459
|
-
const
|
|
2460
|
-
if (u *
|
|
2459
|
+
const d = Math.trunc(a / u);
|
|
2460
|
+
if (u * d !== a)
|
|
2461
2461
|
throw new Error(hn(s, l));
|
|
2462
|
-
l[h] =
|
|
2462
|
+
l[h] = d;
|
|
2463
2463
|
}
|
|
2464
|
-
if (
|
|
2464
|
+
if (V(l) !== a)
|
|
2465
2465
|
throw new Error(fn(s, l));
|
|
2466
|
-
const p = s.length,
|
|
2466
|
+
const p = s.length, w = [];
|
|
2467
2467
|
if (p > 0) {
|
|
2468
|
-
|
|
2469
|
-
for (let
|
|
2470
|
-
|
|
2468
|
+
w[p - 1] = 1;
|
|
2469
|
+
for (let d = p - 2; d >= 0; --d)
|
|
2470
|
+
w[d] = w[d + 1] * s[d + 1];
|
|
2471
2471
|
}
|
|
2472
2472
|
const m = [];
|
|
2473
2473
|
if (i > 0) {
|
|
2474
2474
|
m[i - 1] = 1;
|
|
2475
|
-
for (let
|
|
2476
|
-
m[
|
|
2475
|
+
for (let d = i - 2; d >= 0; --d)
|
|
2476
|
+
m[d] = m[d + 1] * l[d + 1];
|
|
2477
2477
|
}
|
|
2478
|
-
const F =
|
|
2479
|
-
for (let
|
|
2480
|
-
let
|
|
2478
|
+
const F = W(n, r * i);
|
|
2479
|
+
for (let d = 0; d < r; ++d) {
|
|
2480
|
+
let g = 0;
|
|
2481
2481
|
for (let b = 0; b < p; ++b)
|
|
2482
|
-
|
|
2482
|
+
g += e[d * p + b] * w[b];
|
|
2483
2483
|
for (let b = 0; b < i; ++b)
|
|
2484
|
-
F[
|
|
2484
|
+
F[d * i + b] = Math.trunc(g / m[b]), g %= m[b];
|
|
2485
2485
|
}
|
|
2486
2486
|
return [F, [r, i], l];
|
|
2487
2487
|
}
|
|
@@ -2501,45 +2501,45 @@ function Ss(e, t, n, s, o) {
|
|
|
2501
2501
|
* limitations under the License.
|
|
2502
2502
|
* =============================================================================
|
|
2503
2503
|
*/
|
|
2504
|
-
function
|
|
2504
|
+
function Ss(e, t, n, s, o, a = !1, r = 0) {
|
|
2505
2505
|
const i = s.length, l = [t[0], e.length / t[0]], u = l[1], f = i > 0 ? o[i - 1] + 1 : 0;
|
|
2506
2506
|
if (f < 0)
|
|
2507
2507
|
throw new Error(Nt());
|
|
2508
2508
|
const p = t.slice();
|
|
2509
2509
|
p[0] = f;
|
|
2510
|
-
const
|
|
2510
|
+
const w = p.reduce((k, y) => k * y, 1), m = W(n, w);
|
|
2511
2511
|
if (i === 0)
|
|
2512
2512
|
return f > 0 && m.fill(r), [m, p];
|
|
2513
2513
|
if (f <= 0)
|
|
2514
2514
|
throw new Error(Nt());
|
|
2515
|
-
let F = 0,
|
|
2515
|
+
let F = 0, d = 1, g = 0, b = o[F];
|
|
2516
2516
|
for (; ; ) {
|
|
2517
2517
|
let k = 0;
|
|
2518
|
-
if (
|
|
2519
|
-
if (k = o[
|
|
2520
|
-
++
|
|
2518
|
+
if (d < i) {
|
|
2519
|
+
if (k = o[d], b === k) {
|
|
2520
|
+
++d;
|
|
2521
2521
|
continue;
|
|
2522
2522
|
}
|
|
2523
2523
|
if (b >= k)
|
|
2524
|
-
throw new Error(
|
|
2524
|
+
throw new Error(dn());
|
|
2525
2525
|
}
|
|
2526
2526
|
if (b < 0 || b >= f)
|
|
2527
|
-
throw new Error(
|
|
2528
|
-
b >
|
|
2529
|
-
for (let y = F; y <
|
|
2530
|
-
const
|
|
2531
|
-
if (
|
|
2527
|
+
throw new Error(gn(b, f));
|
|
2528
|
+
b > g && m.fill(r, g * u, b * u);
|
|
2529
|
+
for (let y = F; y < d; ++y) {
|
|
2530
|
+
const v = s[y];
|
|
2531
|
+
if (v < 0 || v >= l[0])
|
|
2532
2532
|
throw new Error(mn(y, s[y], l[0]));
|
|
2533
|
-
for (let
|
|
2534
|
-
m[b * u +
|
|
2533
|
+
for (let M = 0; M < u; M++)
|
|
2534
|
+
m[b * u + M] += e[v * u + M];
|
|
2535
2535
|
}
|
|
2536
2536
|
if (a)
|
|
2537
2537
|
for (let y = 0; y < u; y++)
|
|
2538
|
-
m[b * u + y] /=
|
|
2539
|
-
if (F =
|
|
2538
|
+
m[b * u + y] /= d - F;
|
|
2539
|
+
if (F = d, ++d, g = b + 1, b = k, d > i)
|
|
2540
2540
|
break;
|
|
2541
2541
|
}
|
|
2542
|
-
return
|
|
2542
|
+
return g < f && m.fill(r, g * u, f * u), [m, p];
|
|
2543
2543
|
}
|
|
2544
2544
|
/**
|
|
2545
2545
|
* @license
|
|
@@ -2557,7 +2557,7 @@ function vs(e, t, n, s, o, a = !1, r = 0) {
|
|
|
2557
2557
|
* limitations under the License.
|
|
2558
2558
|
* =============================================================================
|
|
2559
2559
|
*/
|
|
2560
|
-
const Ts = X((e) => Math.sqrt(e)), Rs =
|
|
2560
|
+
const Ts = X((e) => Math.sqrt(e)), Rs = de(te, (e) => Math.sqrt(e)), No = {
|
|
2561
2561
|
kernelName: te,
|
|
2562
2562
|
backendName: "cpu",
|
|
2563
2563
|
kernelFunc: Rs
|
|
@@ -2578,13 +2578,13 @@ const Ts = X((e) => Math.sqrt(e)), Rs = ge(te, (e) => Math.sqrt(e)), So = {
|
|
|
2578
2578
|
* limitations under the License.
|
|
2579
2579
|
* =============================================================================
|
|
2580
2580
|
*/
|
|
2581
|
-
const
|
|
2581
|
+
const qe = $((e, t) => {
|
|
2582
2582
|
const n = e - t;
|
|
2583
2583
|
return n * n;
|
|
2584
|
-
}),
|
|
2584
|
+
}), Ms = z(ee, qe), vo = {
|
|
2585
2585
|
kernelName: ee,
|
|
2586
2586
|
backendName: "cpu",
|
|
2587
|
-
kernelFunc:
|
|
2587
|
+
kernelFunc: Ms
|
|
2588
2588
|
};
|
|
2589
2589
|
/**
|
|
2590
2590
|
* @license
|
|
@@ -2602,13 +2602,13 @@ const Me = W((e, t) => {
|
|
|
2602
2602
|
* limitations under the License.
|
|
2603
2603
|
* =============================================================================
|
|
2604
2604
|
*/
|
|
2605
|
-
const
|
|
2605
|
+
const Ae = X((e, t) => {
|
|
2606
2606
|
const { pattern: n, replaceGlobal: s, rewrite: o } = t;
|
|
2607
2607
|
return e.replace(new RegExp(n, s ? "g" : ""), o);
|
|
2608
|
-
}),
|
|
2608
|
+
}), Os = Q(ne, Ae), So = {
|
|
2609
2609
|
kernelName: ne,
|
|
2610
2610
|
backendName: "cpu",
|
|
2611
|
-
kernelFunc:
|
|
2611
|
+
kernelFunc: Os
|
|
2612
2612
|
};
|
|
2613
2613
|
/**
|
|
2614
2614
|
* @license
|
|
@@ -2626,8 +2626,8 @@ const Oe = X((e, t) => {
|
|
|
2626
2626
|
* limitations under the License.
|
|
2627
2627
|
* =============================================================================
|
|
2628
2628
|
*/
|
|
2629
|
-
function
|
|
2630
|
-
const o =
|
|
2629
|
+
function Ls(e, t, n, s) {
|
|
2630
|
+
const o = K(e, t.dtype);
|
|
2631
2631
|
for (let a = 0; a < o.size; a++) {
|
|
2632
2632
|
const r = o.indexToLoc(a), i = new Array(r.length);
|
|
2633
2633
|
for (let l = 0; l < i.length; l++)
|
|
@@ -2652,7 +2652,7 @@ function qs(e, t, n, s) {
|
|
|
2652
2652
|
* limitations under the License.
|
|
2653
2653
|
* =============================================================================
|
|
2654
2654
|
*/
|
|
2655
|
-
class
|
|
2655
|
+
class Ps {
|
|
2656
2656
|
constructor(t, n, s, o, a, r) {
|
|
2657
2657
|
this.separator = pt(t), this.nGramWidths = n, this.leftPad = pt(s), this.rightPad = pt(o), this.padWidth = a, this.preserveShort = r;
|
|
2658
2658
|
}
|
|
@@ -2666,28 +2666,28 @@ class Us {
|
|
|
2666
2666
|
createNGrams(t, n, s, o, a, r) {
|
|
2667
2667
|
for (let i = 0; i < a; ++i) {
|
|
2668
2668
|
const l = this.getPadWidth(r), u = Math.max(0, l - i), h = Math.max(0, l - (a - (i + 1))), f = r - (u + h), p = n + (u > 0 ? 0 : i - l);
|
|
2669
|
-
let
|
|
2670
|
-
|
|
2669
|
+
let w = 0;
|
|
2670
|
+
w += u * this.leftPad.length;
|
|
2671
2671
|
for (let b = 0; b < f; ++b)
|
|
2672
|
-
|
|
2673
|
-
|
|
2672
|
+
w += t[p + b].length;
|
|
2673
|
+
w += h * this.rightPad.length;
|
|
2674
2674
|
const m = u + h + f - 1;
|
|
2675
|
-
|
|
2675
|
+
w += m * this.separator.length, s[o + i] = new Uint8Array(w);
|
|
2676
2676
|
const F = s[o + i];
|
|
2677
|
-
let
|
|
2678
|
-
const
|
|
2677
|
+
let d = 0;
|
|
2678
|
+
const g = (b) => b.forEach((k) => F[d++] = k);
|
|
2679
2679
|
for (let b = 0; b < u; ++b)
|
|
2680
|
-
|
|
2680
|
+
g(this.leftPad), g(this.separator);
|
|
2681
2681
|
for (let b = 0; b < f - 1; ++b)
|
|
2682
|
-
|
|
2682
|
+
g(t[p + b]), g(this.separator);
|
|
2683
2683
|
if (f > 0) {
|
|
2684
|
-
|
|
2684
|
+
g(t[p + f - 1]);
|
|
2685
2685
|
for (let b = 0; b < h; ++b)
|
|
2686
|
-
|
|
2686
|
+
g(this.separator), g(this.rightPad);
|
|
2687
2687
|
} else {
|
|
2688
2688
|
for (let b = 0; b < h - 1; ++b)
|
|
2689
|
-
|
|
2690
|
-
|
|
2689
|
+
g(this.rightPad), g(this.separator);
|
|
2690
|
+
g(this.rightPad);
|
|
2691
2691
|
}
|
|
2692
2692
|
}
|
|
2693
2693
|
}
|
|
@@ -2709,7 +2709,7 @@ class Us {
|
|
|
2709
2709
|
if (l !== s)
|
|
2710
2710
|
throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`);
|
|
2711
2711
|
}
|
|
2712
|
-
const a = o - 1, r =
|
|
2712
|
+
const a = o - 1, r = W("int32", o);
|
|
2713
2713
|
if (s === 0 || o === 0) {
|
|
2714
2714
|
const l = new Array(s);
|
|
2715
2715
|
for (let u = 0; u <= a; ++u)
|
|
@@ -2729,8 +2729,8 @@ class Us {
|
|
|
2729
2729
|
const u = n[l];
|
|
2730
2730
|
let h = r[l];
|
|
2731
2731
|
if (this.nGramWidths.forEach((f) => {
|
|
2732
|
-
const p = n[l + 1] - n[l],
|
|
2733
|
-
this.createNGrams(t, u, i, h,
|
|
2732
|
+
const p = n[l + 1] - n[l], w = this.getNumNGrams(p, f);
|
|
2733
|
+
this.createNGrams(t, u, i, h, w, f), h += w;
|
|
2734
2734
|
}), this.preserveShort && h === r[l]) {
|
|
2735
2735
|
const f = n[l + 1] - n[l];
|
|
2736
2736
|
if (f === 0)
|
|
@@ -2742,8 +2742,8 @@ class Us {
|
|
|
2742
2742
|
return [i, r];
|
|
2743
2743
|
}
|
|
2744
2744
|
}
|
|
2745
|
-
function
|
|
2746
|
-
return new
|
|
2745
|
+
function qs(e, t, n, s, o, a, r, i) {
|
|
2746
|
+
return new Ps(n, s, o, a, r, i).compute(e, t);
|
|
2747
2747
|
}
|
|
2748
2748
|
/**
|
|
2749
2749
|
* @license
|
|
@@ -2761,7 +2761,7 @@ function Ms(e, t, n, s, o, a, r, i) {
|
|
|
2761
2761
|
* limitations under the License.
|
|
2762
2762
|
* =============================================================================
|
|
2763
2763
|
*/
|
|
2764
|
-
function
|
|
2764
|
+
function As(e, t, n, s) {
|
|
2765
2765
|
if (!e.length)
|
|
2766
2766
|
return;
|
|
2767
2767
|
if (t.length === 0) {
|
|
@@ -2786,21 +2786,21 @@ function Os(e, t, n, s) {
|
|
|
2786
2786
|
(!n || r.length !== 0) && s.push(r), o = a + 1;
|
|
2787
2787
|
}
|
|
2788
2788
|
}
|
|
2789
|
-
function
|
|
2789
|
+
function _s(e, t, n) {
|
|
2790
2790
|
const s = e.length, o = [];
|
|
2791
2791
|
let a = 0, r = 0;
|
|
2792
2792
|
const i = new Array(s);
|
|
2793
2793
|
for (let p = 0; p < s; ++p) {
|
|
2794
|
-
const
|
|
2795
|
-
|
|
2796
|
-
const m = o.length -
|
|
2794
|
+
const w = o.length;
|
|
2795
|
+
As(e[p], t, n, o);
|
|
2796
|
+
const m = o.length - w;
|
|
2797
2797
|
i[p] = m, a += m, r = Math.max(r, m);
|
|
2798
2798
|
}
|
|
2799
|
-
const l =
|
|
2799
|
+
const l = W("int32", a * 2), u = new Array(a), h = [s, r];
|
|
2800
2800
|
let f = 0;
|
|
2801
2801
|
for (let p = 0; p < s; ++p)
|
|
2802
|
-
for (let
|
|
2803
|
-
l[f * 2] = p, l[f * 2 + 1] =
|
|
2802
|
+
for (let w = 0; w < i[p]; ++w)
|
|
2803
|
+
l[f * 2] = p, l[f * 2 + 1] = w, u[f] = o[f], ++f;
|
|
2804
2804
|
return [l, u, h];
|
|
2805
2805
|
}
|
|
2806
2806
|
/**
|
|
@@ -2819,10 +2819,10 @@ function Ls(e, t, n) {
|
|
|
2819
2819
|
* limitations under the License.
|
|
2820
2820
|
* =============================================================================
|
|
2821
2821
|
*/
|
|
2822
|
-
function
|
|
2823
|
-
const n =
|
|
2822
|
+
function Vs(e, t) {
|
|
2823
|
+
const n = W("int32", e.length);
|
|
2824
2824
|
for (let s = 0; s < e.length; ++s)
|
|
2825
|
-
n[s] =
|
|
2825
|
+
n[s] = qn(e[s]).modulo(t).getLowBitsUnsigned();
|
|
2826
2826
|
return n;
|
|
2827
2827
|
}
|
|
2828
2828
|
/**
|
|
@@ -2841,10 +2841,10 @@ function As(e, t) {
|
|
|
2841
2841
|
* limitations under the License.
|
|
2842
2842
|
* =============================================================================
|
|
2843
2843
|
*/
|
|
2844
|
-
const
|
|
2844
|
+
const _e = $((e, t) => e - t), Cs = Ft((e, t, n, s) => ({ real: e - n, imag: t - s })), Ds = z(se, _e, Cs), To = {
|
|
2845
2845
|
kernelName: se,
|
|
2846
2846
|
backendName: "cpu",
|
|
2847
|
-
kernelFunc:
|
|
2847
|
+
kernelFunc: Ds
|
|
2848
2848
|
};
|
|
2849
2849
|
/**
|
|
2850
2850
|
* @license
|
|
@@ -2862,11 +2862,11 @@ const Le = W((e, t) => e - t), _s = Ft((e, t, n, s) => ({ real: e - n, imag: t -
|
|
|
2862
2862
|
* limitations under the License.
|
|
2863
2863
|
* =============================================================================
|
|
2864
2864
|
*/
|
|
2865
|
-
function
|
|
2865
|
+
function Ws(e, t) {
|
|
2866
2866
|
const n = new Array(e.rank);
|
|
2867
2867
|
for (let o = 0; o < n.length; o++)
|
|
2868
2868
|
n[o] = e.shape[o] * t[o];
|
|
2869
|
-
const s =
|
|
2869
|
+
const s = K(n, e.dtype);
|
|
2870
2870
|
for (let o = 0; o < s.values.length; ++o) {
|
|
2871
2871
|
const a = s.indexToLoc(o), r = new Array(e.rank);
|
|
2872
2872
|
for (let l = 0; l < r.length; l++)
|
|
@@ -2896,11 +2896,11 @@ const rt = (e, t) => {
|
|
|
2896
2896
|
const n = t.value - e.value;
|
|
2897
2897
|
return n === 0 ? e.index - t.index : n;
|
|
2898
2898
|
};
|
|
2899
|
-
function
|
|
2899
|
+
function Ve(e, t, n = 0, s = e.length - 1) {
|
|
2900
2900
|
for (; s > n; ) {
|
|
2901
2901
|
if (s - n > 600) {
|
|
2902
|
-
const i = s - n + 1, l = t - n + 1, u = Math.log(i), h = 0.5 * Math.exp(2 * u / 3), f = 0.5 * Math.sqrt(u * h * (i - h) / i) * Math.sign(l - i / 2), p = Math.max(n, Math.floor(t - l * h / i + f)),
|
|
2903
|
-
|
|
2902
|
+
const i = s - n + 1, l = t - n + 1, u = Math.log(i), h = 0.5 * Math.exp(2 * u / 3), f = 0.5 * Math.sqrt(u * h * (i - h) / i) * Math.sign(l - i / 2), p = Math.max(n, Math.floor(t - l * h / i + f)), w = Math.min(s, Math.floor(t + (i - l) * h / i + f));
|
|
2903
|
+
Ve(e, t, p, w);
|
|
2904
2904
|
}
|
|
2905
2905
|
const o = e[t];
|
|
2906
2906
|
let a = n, r = s;
|
|
@@ -2913,20 +2913,20 @@ function Ae(e, t, n = 0, s = e.length - 1) {
|
|
|
2913
2913
|
rt(e[n], o) === 0 ? ot(e, n, r) : (r = r + 1, ot(e, r, s)), r <= t && (n = r + 1), t <= r && (s = r - 1);
|
|
2914
2914
|
}
|
|
2915
2915
|
}
|
|
2916
|
-
function
|
|
2916
|
+
function $s(e, t, n, s, o) {
|
|
2917
2917
|
const a = t[t.length - 1], [r, i] = [e.length / a, a], l = et(n, r * s), u = et("int32", r * s);
|
|
2918
2918
|
for (let f = 0; f < r; f++) {
|
|
2919
|
-
const p = f * i,
|
|
2920
|
-
let m = new Array(
|
|
2921
|
-
|
|
2922
|
-
const F = f * s,
|
|
2919
|
+
const p = f * i, w = e.subarray(p, p + i);
|
|
2920
|
+
let m = new Array(w.length);
|
|
2921
|
+
w.forEach((b, k) => m[k] = { value: b, index: k }), s < m.length && (Ve(m, s), m = m.slice(0, s)), o && m.sort(rt);
|
|
2922
|
+
const F = f * s, d = l.subarray(F, F + s), g = u.subarray(F, F + s);
|
|
2923
2923
|
for (let b = 0; b < s; b++)
|
|
2924
|
-
|
|
2924
|
+
d[b] = m[b].value, g[b] = m[b].index;
|
|
2925
2925
|
}
|
|
2926
2926
|
const h = t.slice();
|
|
2927
2927
|
return h[h.length - 1] = s, [
|
|
2928
|
-
|
|
2929
|
-
|
|
2928
|
+
K(h, n, l),
|
|
2929
|
+
K(h, "int32", u)
|
|
2930
2930
|
];
|
|
2931
2931
|
}
|
|
2932
2932
|
/**
|
|
@@ -2945,45 +2945,45 @@ function Ws(e, t, n, s, o) {
|
|
|
2945
2945
|
* limitations under the License.
|
|
2946
2946
|
* =============================================================================
|
|
2947
2947
|
*/
|
|
2948
|
-
function
|
|
2949
|
-
const o =
|
|
2948
|
+
function Us(e, t, n, s) {
|
|
2949
|
+
const o = Jt(t, n)[0], a = [1, n[0], 1];
|
|
2950
2950
|
for (let m = 0; m < o; m++)
|
|
2951
2951
|
a[0] *= n[m];
|
|
2952
2952
|
a[1] = n[o];
|
|
2953
2953
|
for (let m = o + 1; m < n.length; m++)
|
|
2954
2954
|
a[2] *= n[m];
|
|
2955
|
-
const r = /* @__PURE__ */ new Map(), i = new Int32Array(n[o]), l = new
|
|
2955
|
+
const r = /* @__PURE__ */ new Map(), i = new Int32Array(n[o]), l = new It(a, s, e), u = [], h = a[0] === 1 && a[2] === 1;
|
|
2956
2956
|
for (let m = 0; m < n[o]; m++) {
|
|
2957
2957
|
let F;
|
|
2958
2958
|
if (h)
|
|
2959
2959
|
F = e[m].toString();
|
|
2960
2960
|
else {
|
|
2961
|
-
const
|
|
2961
|
+
const g = [];
|
|
2962
2962
|
for (let b = 0; b < a[0]; b++)
|
|
2963
2963
|
for (let k = 0; k < a[2]; k++)
|
|
2964
|
-
|
|
2965
|
-
F =
|
|
2964
|
+
g.push(l.get(b, m, k));
|
|
2965
|
+
F = g.join(",");
|
|
2966
2966
|
}
|
|
2967
|
-
const
|
|
2968
|
-
if (
|
|
2969
|
-
i[m] =
|
|
2967
|
+
const d = r.get(F);
|
|
2968
|
+
if (d != null)
|
|
2969
|
+
i[m] = d;
|
|
2970
2970
|
else {
|
|
2971
|
-
const
|
|
2972
|
-
r.set(F,
|
|
2971
|
+
const g = r.size;
|
|
2972
|
+
r.set(F, g), i[m] = g, u.push(m);
|
|
2973
2973
|
}
|
|
2974
2974
|
}
|
|
2975
2975
|
const f = a.slice();
|
|
2976
2976
|
f[1] = r.size;
|
|
2977
|
-
const p = new
|
|
2977
|
+
const p = new It(f, s);
|
|
2978
2978
|
u.forEach((m, F) => {
|
|
2979
|
-
for (let
|
|
2980
|
-
for (let
|
|
2981
|
-
p.set(l.get(
|
|
2979
|
+
for (let d = 0; d < a[0]; d++)
|
|
2980
|
+
for (let g = 0; g < a[2]; g++)
|
|
2981
|
+
p.set(l.get(d, m, g), d, F, g);
|
|
2982
2982
|
});
|
|
2983
|
-
const
|
|
2984
|
-
return
|
|
2983
|
+
const w = n.slice();
|
|
2984
|
+
return w[o] = f[1], {
|
|
2985
2985
|
outputValues: p.values,
|
|
2986
|
-
outputShape:
|
|
2986
|
+
outputShape: w,
|
|
2987
2987
|
indices: i
|
|
2988
2988
|
};
|
|
2989
2989
|
}
|
|
@@ -3003,22 +3003,22 @@ function $s(e, t, n, s) {
|
|
|
3003
3003
|
* limitations under the License.
|
|
3004
3004
|
* =============================================================================
|
|
3005
3005
|
*/
|
|
3006
|
-
const
|
|
3006
|
+
const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3007
3007
|
__proto__: null,
|
|
3008
3008
|
addImpl: he,
|
|
3009
|
-
bincountImpl:
|
|
3010
|
-
bincountReduceImpl:
|
|
3009
|
+
bincountImpl: Cn,
|
|
3010
|
+
bincountReduceImpl: Dn,
|
|
3011
3011
|
bitwiseAndImpl: fe,
|
|
3012
3012
|
castImpl: ue,
|
|
3013
|
-
ceilImpl:
|
|
3014
|
-
concatImpl:
|
|
3013
|
+
ceilImpl: ge,
|
|
3014
|
+
concatImpl: Un,
|
|
3015
3015
|
equalImpl: me,
|
|
3016
3016
|
expImpl: pe,
|
|
3017
|
-
expm1Impl:
|
|
3017
|
+
expm1Impl: we,
|
|
3018
3018
|
floorDivImpl: be,
|
|
3019
|
-
floorImpl:
|
|
3020
|
-
gatherNdImpl:
|
|
3021
|
-
gatherV2Impl:
|
|
3019
|
+
floorImpl: Ie,
|
|
3020
|
+
gatherNdImpl: Kn,
|
|
3021
|
+
gatherV2Impl: Hn,
|
|
3022
3022
|
greaterEqualImpl: Ee,
|
|
3023
3023
|
greaterImpl: xe,
|
|
3024
3024
|
lessEqualImpl: ye,
|
|
@@ -3027,173 +3027,108 @@ const zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3027
3027
|
logImpl: ke,
|
|
3028
3028
|
maxImpl: ns,
|
|
3029
3029
|
maximumImpl: Ne,
|
|
3030
|
-
minimumImpl:
|
|
3030
|
+
minimumImpl: ve,
|
|
3031
3031
|
multiplyImpl: yt,
|
|
3032
|
-
negImpl:
|
|
3032
|
+
negImpl: Se,
|
|
3033
3033
|
notEqualImpl: Te,
|
|
3034
|
-
prodImpl:
|
|
3034
|
+
prodImpl: Oe,
|
|
3035
3035
|
raggedGatherImpl: ps,
|
|
3036
|
-
raggedRangeImpl:
|
|
3037
|
-
raggedTensorToTensorImpl:
|
|
3036
|
+
raggedRangeImpl: ws,
|
|
3037
|
+
raggedTensorToTensorImpl: Is,
|
|
3038
3038
|
rangeImpl: bs,
|
|
3039
|
-
rsqrtImpl:
|
|
3039
|
+
rsqrtImpl: Le,
|
|
3040
3040
|
scatterImpl: Es,
|
|
3041
3041
|
sigmoidImpl: Fs,
|
|
3042
3042
|
simpleAbsImpl: le,
|
|
3043
|
-
sliceImpl:
|
|
3043
|
+
sliceImpl: Pe,
|
|
3044
3044
|
sparseFillEmptyRowsImpl: Ns,
|
|
3045
|
-
sparseReshapeImpl:
|
|
3046
|
-
sparseSegmentReductionImpl:
|
|
3045
|
+
sparseReshapeImpl: vs,
|
|
3046
|
+
sparseSegmentReductionImpl: Ss,
|
|
3047
3047
|
sqrtImpl: Ts,
|
|
3048
|
-
squaredDifferenceImpl:
|
|
3049
|
-
staticRegexReplaceImpl:
|
|
3050
|
-
stridedSliceImpl:
|
|
3051
|
-
stringNGramsImpl:
|
|
3052
|
-
stringSplitImpl:
|
|
3053
|
-
stringToHashBucketFastImpl:
|
|
3054
|
-
subImpl:
|
|
3055
|
-
tileImpl:
|
|
3056
|
-
topKImpl:
|
|
3048
|
+
squaredDifferenceImpl: qe,
|
|
3049
|
+
staticRegexReplaceImpl: Ae,
|
|
3050
|
+
stridedSliceImpl: Ls,
|
|
3051
|
+
stringNGramsImpl: qs,
|
|
3052
|
+
stringSplitImpl: _s,
|
|
3053
|
+
stringToHashBucketFastImpl: Vs,
|
|
3054
|
+
subImpl: _e,
|
|
3055
|
+
tileImpl: Ws,
|
|
3056
|
+
topKImpl: $s,
|
|
3057
3057
|
transposeImpl: Re,
|
|
3058
|
-
uniqueImpl:
|
|
3058
|
+
uniqueImpl: Us
|
|
3059
3059
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3060
|
-
/**
|
|
3061
|
-
* @license
|
|
3062
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
3063
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3064
|
-
* you may not use this file except in compliance with the License.
|
|
3065
|
-
* You may obtain a copy of the License at
|
|
3066
|
-
*
|
|
3067
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3068
|
-
*
|
|
3069
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3070
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3071
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3072
|
-
* See the License for the specific language governing permissions and
|
|
3073
|
-
* limitations under the License.
|
|
3074
|
-
* =============================================================================
|
|
3075
|
-
*/
|
|
3076
|
-
const { addImpl: Po, bincountImpl: Co, bincountReduceImpl: qo, bitwiseAndImpl: Uo, castImpl: Mo, ceilImpl: Oo, concatImpl: Lo, equalImpl: Ao, expImpl: _o, expm1Impl: Vo, floorImpl: Do, gatherNdImpl: Wo, gatherV2Impl: $o, greaterImpl: zo, greaterEqualImpl: Bo, lessImpl: Go, lessEqualImpl: jo, linSpaceImpl: Zo, logImpl: Ho, maxImpl: Ko, maximumImpl: Xo, minimumImpl: Yo, multiplyImpl: Jo, negImpl: Qo, notEqualImpl: tr, prodImpl: er, raggedGatherImpl: nr, raggedRangeImpl: sr, raggedTensorToTensorImpl: or, rangeImpl: rr, rsqrtImpl: ar, scatterImpl: ir, sigmoidImpl: lr, simpleAbsImpl: cr, sliceImpl: ur, sparseFillEmptyRowsImpl: hr, sparseReshapeImpl: fr, sparseSegmentReductionImpl: gr, sqrtImpl: dr, staticRegexReplaceImpl: mr, stridedSliceImpl: pr, stringNGramsImpl: Ir, stringSplitImpl: wr, stringToHashBucketFastImpl: br, subImpl: xr, tileImpl: Er, topKImpl: Fr, transposeImpl: yr, uniqueImpl: kr } = zs;
|
|
3077
3060
|
export {
|
|
3078
3061
|
uo as $,
|
|
3079
|
-
|
|
3062
|
+
ws as A,
|
|
3080
3063
|
Is as B,
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3064
|
+
bs as C,
|
|
3065
|
+
Es as D,
|
|
3066
|
+
Ns as E,
|
|
3067
|
+
vs as F,
|
|
3085
3068
|
Ss as G,
|
|
3086
|
-
|
|
3069
|
+
Ls as H,
|
|
3087
3070
|
qs as I,
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3071
|
+
_s as J,
|
|
3072
|
+
Vs as K,
|
|
3073
|
+
Ws as L,
|
|
3074
|
+
$s as M,
|
|
3075
|
+
Us as N,
|
|
3076
|
+
zn as O,
|
|
3077
|
+
Xs as P,
|
|
3078
|
+
eo as Q,
|
|
3096
3079
|
no as R,
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3080
|
+
to as S,
|
|
3081
|
+
so as T,
|
|
3082
|
+
Js as U,
|
|
3083
|
+
oo as V,
|
|
3101
3084
|
ro as W,
|
|
3102
3085
|
ao as X,
|
|
3103
3086
|
io as Y,
|
|
3104
3087
|
lo as Z,
|
|
3105
3088
|
co as _,
|
|
3106
3089
|
nt as a,
|
|
3107
|
-
|
|
3108
|
-
ho as
|
|
3109
|
-
Qs as a1,
|
|
3090
|
+
Qs as a0,
|
|
3091
|
+
ho as a1,
|
|
3110
3092
|
fo as a2,
|
|
3111
3093
|
go as a3,
|
|
3112
3094
|
mo as a4,
|
|
3113
3095
|
po as a5,
|
|
3114
|
-
|
|
3115
|
-
|
|
3096
|
+
wo as a6,
|
|
3097
|
+
Io as a7,
|
|
3116
3098
|
bo as a8,
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
Bo as aC,
|
|
3121
|
-
Go as aD,
|
|
3122
|
-
jo as aE,
|
|
3123
|
-
Zo as aF,
|
|
3124
|
-
Ho as aG,
|
|
3125
|
-
Xo as aH,
|
|
3126
|
-
Yo as aI,
|
|
3127
|
-
xr as aJ,
|
|
3128
|
-
Qo as aK,
|
|
3129
|
-
er as aL,
|
|
3130
|
-
nr as aM,
|
|
3131
|
-
sr as aN,
|
|
3132
|
-
or as aO,
|
|
3133
|
-
rr as aP,
|
|
3134
|
-
ar as aQ,
|
|
3135
|
-
lr as aR,
|
|
3136
|
-
hr as aS,
|
|
3137
|
-
fr as aT,
|
|
3138
|
-
gr as aU,
|
|
3139
|
-
ir as aV,
|
|
3140
|
-
dr as aW,
|
|
3141
|
-
mr as aX,
|
|
3142
|
-
pr as aY,
|
|
3143
|
-
Ir as aZ,
|
|
3144
|
-
wr as a_,
|
|
3145
|
-
Fo as aa,
|
|
3146
|
-
to as ab,
|
|
3099
|
+
Eo as a9,
|
|
3100
|
+
Ys as aa,
|
|
3101
|
+
Fo as ab,
|
|
3147
3102
|
yo as ac,
|
|
3148
3103
|
ko as ad,
|
|
3149
3104
|
No as ae,
|
|
3150
|
-
|
|
3151
|
-
|
|
3105
|
+
vo as af,
|
|
3106
|
+
So as ag,
|
|
3152
3107
|
To as ah,
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
Po as am,
|
|
3158
|
-
ur as an,
|
|
3159
|
-
Co as ao,
|
|
3160
|
-
Uo as ap,
|
|
3161
|
-
tr as aq,
|
|
3162
|
-
Mo as ar,
|
|
3163
|
-
Oo as as,
|
|
3164
|
-
Lo as at,
|
|
3165
|
-
qo as au,
|
|
3166
|
-
Ao as av,
|
|
3167
|
-
_o as aw,
|
|
3168
|
-
Vo as ax,
|
|
3169
|
-
Do as ay,
|
|
3170
|
-
Wo as az,
|
|
3171
|
-
An as b,
|
|
3172
|
-
Er as b0,
|
|
3173
|
-
Fr as b1,
|
|
3174
|
-
kr as b2,
|
|
3175
|
-
W as c,
|
|
3176
|
-
Pe as d,
|
|
3108
|
+
xo as ai,
|
|
3109
|
+
ys as b,
|
|
3110
|
+
$ as c,
|
|
3111
|
+
Vn as d,
|
|
3177
3112
|
z as e,
|
|
3178
3113
|
ks as f,
|
|
3179
|
-
|
|
3114
|
+
Cn as g,
|
|
3180
3115
|
mt as h,
|
|
3181
3116
|
Et as i,
|
|
3182
|
-
|
|
3183
|
-
|
|
3117
|
+
Un as j,
|
|
3118
|
+
Dn as k,
|
|
3184
3119
|
lt as l,
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3120
|
+
as as m,
|
|
3121
|
+
Ds as n,
|
|
3122
|
+
Kn as o,
|
|
3188
3123
|
Hn as p,
|
|
3189
|
-
|
|
3124
|
+
ts as q,
|
|
3190
3125
|
ce as r,
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3126
|
+
Ro as s,
|
|
3127
|
+
Me as t,
|
|
3128
|
+
de as u,
|
|
3129
|
+
Re as v,
|
|
3130
|
+
ns as w,
|
|
3131
|
+
Bn as x,
|
|
3132
|
+
ps as y,
|
|
3198
3133
|
xt as z
|
|
3199
3134
|
};
|