@genai-fi/nanogpt 0.7.3 → 0.8.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.d.ts +25 -2
- package/dist/Generator.js +152 -49
- package/dist/{RealDiv-Dy0p8Bvo.js → RealDiv-D_q39E3A.js} +13 -13
- package/dist/{Reshape-DvudQDvJ.js → Reshape-41YpQqEo.js} +1 -1
- package/dist/{Reshape-DH5srBP0.js → Reshape-Bh_jzKzV.js} +5 -5
- package/dist/TeachableLLM.d.ts +6 -6
- package/dist/TeachableLLM.js +33 -31
- package/dist/Trainer.d.ts +13 -2
- package/dist/Trainer.js +21 -12
- package/dist/{axis_util-BzbKo31C.js → axis_util-Did9235A.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-TE7aTPhZ.js → backend_util-yC3YH1jo.js} +58 -58
- package/dist/{broadcast_to-CdbwV-Dj.js → broadcast_to-CUvOdOT5.js} +2 -2
- package/dist/checks/appendCache.d.ts +1 -0
- package/dist/checks/appendCache.js +22 -0
- package/dist/checks/attentionMask.d.ts +1 -0
- package/dist/checks/attentionMask.js +37 -0
- package/dist/checks/check.d.ts +9 -0
- package/dist/checks/check.js +20 -0
- package/dist/checks/gelu.d.ts +1 -0
- package/dist/checks/gelu.js +18 -0
- package/dist/checks/index.d.ts +19 -0
- package/dist/checks/index.js +21 -0
- package/dist/checks/normRMS.d.ts +1 -0
- package/dist/checks/normRMS.js +16 -0
- package/dist/checks/normRMSGrad.d.ts +1 -0
- package/dist/checks/normRMSGrad.js +12 -0
- package/dist/checks/qkv.d.ts +1 -0
- package/dist/checks/qkv.js +25 -0
- package/dist/checks/rope.d.ts +1 -0
- package/dist/checks/rope.js +21 -0
- package/dist/{concat-CsxrgovM.js → concat-pHiVqR3L.js} +1 -1
- package/dist/{dataset-CtdBYwjo.js → dataset-DPPl-iLT.js} +9 -9
- package/dist/{dropout-DYs5QFGQ.js → dropout-CcKSfOYE.js} +18 -18
- package/dist/exports_initializers-DKk7-bsx.js +16 -0
- package/dist/{gather-CMMy2KEG.js → gather-CPg6ZlQA.js} +1 -1
- package/dist/{gelu-C-dPj6Ku.js → gelu-BkcmEEyD.js} +1 -1
- package/dist/{gpgpu_math-DGNLNL4I.js → gpgpu_math-D_ODOLix.js} +26 -26
- package/dist/{index-BoWRt-10.js → index-DdmHGZjq.js} +659 -650
- package/dist/{index-CLthM0TO.js → index-evZ57wr4.js} +185 -185
- package/dist/{kernel_funcs_utils-BYKWV8Aa.js → kernel_funcs_utils-CDfFpUab.js} +21 -21
- package/dist/layers/BaseLayer.d.ts +8 -13
- package/dist/layers/BaseLayer.js +25 -13
- package/dist/layers/CausalSelfAttention.d.ts +3 -2
- package/dist/layers/CausalSelfAttention.js +28 -28
- package/dist/layers/MLP.d.ts +3 -2
- package/dist/layers/MLP.js +16 -20
- package/dist/layers/PositionEmbedding.d.ts +9 -0
- package/dist/layers/PositionEmbedding.js +45 -0
- package/dist/layers/RMSNorm.d.ts +3 -2
- package/dist/layers/RMSNorm.js +6 -6
- package/dist/layers/RoPECache.d.ts +1 -1
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.d.ts +3 -2
- package/dist/layers/TiedEmbedding.js +29 -7
- package/dist/layers/TransformerBlock.d.ts +3 -2
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/load.d.ts +2 -2
- package/dist/loader/loadHF.d.ts +2 -2
- package/dist/loader/loadTransformers.d.ts +4 -2
- package/dist/loader/loadTransformers.js +10 -9
- package/dist/loader/newZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.js +44 -51
- package/dist/loader/save.d.ts +8 -0
- package/dist/loader/save.js +62 -0
- package/dist/{log_sum_exp-DbjkV734.js → log_sum_exp-C8yFJfZz.js} +45 -24
- package/dist/main.d.ts +6 -4
- package/dist/main.js +24 -18
- package/dist/{mat_mul-8m8pfdcx.js → mat_mul-Dpy2mMRu.js} +1 -1
- package/dist/mod-CbibJi3D.js +27 -0
- package/dist/models/NanoGPTV1.d.ts +15 -0
- package/dist/models/NanoGPTV1.js +71 -0
- package/dist/{config.d.ts → models/config.d.ts} +1 -0
- package/dist/{config.js → models/config.js} +1 -0
- package/dist/models/factory.d.ts +3 -0
- package/dist/models/factory.js +14 -0
- package/dist/models/model.d.ts +26 -0
- package/dist/models/model.js +70 -0
- package/dist/{mulmat_packed_gpu-VSekgsNv.js → mulmat_packed_gpu-q_Gmwyld.js} +1 -1
- package/dist/{ones-Dj0SDhHf.js → ones-BAqVh-eA.js} +2 -2
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/adamAdjust.js +9 -9
- package/dist/ops/cpu/adamMoments.js +2 -2
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +5 -5
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +2 -2
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +7 -7
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +2 -2
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +4 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/adamAdjust.js +2 -2
- package/dist/ops/webgl/adamMoments.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +4 -4
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMulGelu.js +10 -10
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/ops/webgpu/adamAdjust.js +3 -3
- package/dist/ops/webgpu/adamMoments.js +3 -3
- package/dist/ops/webgpu/appendCache.js +3 -3
- package/dist/ops/webgpu/attentionMask.js +3 -3
- package/dist/ops/webgpu/gatherSub.js +3 -3
- package/dist/ops/webgpu/gelu.js +3 -3
- package/dist/ops/webgpu/normRMS.js +2 -2
- package/dist/ops/webgpu/normRMSGrad.js +5 -5
- package/dist/ops/webgpu/qkv.js +3 -3
- package/dist/ops/webgpu/rope.js +3 -3
- package/dist/ops/webgpu/scatterSub.js +3 -3
- package/dist/ops/webgpu/utils/reductions.js +4 -4
- package/dist/ops-542ai2vG.js +1525 -0
- package/dist/{random_width-sZORGo5k.js → random_width-DKGeiFuR.js} +1471 -1538
- package/dist/{range-CRuAh-gd.js → range-BcUvLuf5.js} +1 -1
- package/dist/{reciprocal-BvGAyKyu.js → reciprocal-DhDWSKiD.js} +1 -1
- package/dist/{register_all_kernels-BwDSRN-f.js → register_all_kernels-Do9VvZmo.js} +2488 -2534
- package/dist/{max-Ddnnb5xe.js → relu-B1AXs7p5.js} +6 -6
- package/dist/{reshape-CdBq1WJ6.js → reshape-WeJkT3ja.js} +1 -1
- package/dist/{scatter_nd_util-DUstGbU1.js → scatter_nd_util-B7yDhiQr.js} +1 -1
- package/dist/{selu_util-BJEXVvjX.js → selu_util-BgUO9gHY.js} +125 -146
- package/dist/{shared-wS99K7_n.js → shared-CZiWmQCI.js} +1 -1
- package/dist/{shared-B8ztnyEk.js → shared-V6D_md-c.js} +72 -72
- package/dist/{sin-BeA3tsEd.js → sin-CPxad7Am.js} +1 -1
- package/dist/{slice-BiOsknYS.js → slice-B7jXtPnp.js} +1 -1
- package/dist/{softmax-Bv_6lyMX.js → softmax-BfsyI4As.js} +1 -1
- package/dist/{split-B-dikLRw.js → split-BPxr8_8m.js} +1 -1
- package/dist/{stack-B17UN2nn.js → stack-BNwLzE43.js} +1 -1
- package/dist/{sum-66ew2byf.js → sum-ByFINZgi.js} +3 -3
- package/dist/{tensor-JwS7ZYY6.js → tensor-DbqgIV9B.js} +1 -1
- package/dist/tensor1d-CtJq5BOv.js +27 -0
- package/dist/{tensor2d-wxPAnDQy.js → tensor2d-CObBWBkW.js} +1 -1
- package/dist/tensor3d-BOukqWwr.js +30 -0
- package/dist/tensor4d-DLtk7Nxh.js +30 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/Evaluator.d.ts +2 -2
- package/dist/training/FullTrainer.d.ts +3 -3
- package/dist/training/FullTrainer.js +61 -69
- package/dist/training/Trainer.d.ts +15 -3
- package/dist/training/Trainer.js +39 -47
- package/dist/training/sparseCrossEntropy.js +12 -13
- package/dist/utilities/arrayClose.d.ts +1 -1
- package/dist/utilities/arrayClose.js +16 -7
- package/dist/utilities/dummy.d.ts +4 -4
- package/dist/utilities/dummy.js +13 -13
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/parameters.d.ts +1 -1
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-BuddVFLa.js → variable-DPFOJyRG.js} +1 -1
- package/dist/{webgpu_program-PFzf1hAQ.js → webgpu_program-Dhk9R5aG.js} +1 -1
- package/dist/{webgpu_util-D____QpY.js → webgpu_util-BqGnZg8t.js} +27 -27
- package/dist/{zeros--BdLQ3oG.js → zeros-Dnwix0p4.js} +1 -1
- package/package.json +2 -3
- package/dist/NanoGPTModel.d.ts +0 -52
- package/dist/NanoGPTModel.js +0 -203
- package/dist/TiedEmbedding-BxOerUmB.js +0 -43
- package/dist/ops-BFGCx8Ri.js +0 -1202
- package/dist/utilities/generate.d.ts +0 -3
- package/dist/utilities/generate.js +0 -22
- package/dist/utilities/save.d.ts +0 -9
- package/dist/utilities/save.js +0 -61
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
3
|
-
import { g as pn, a as wn, e as In, c as bn } from "./axis_util-
|
|
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-
|
|
1
|
+
import { n as Lt, bm as Ce, j as V, l as Pt, a3 as K, bn as et, ae as ht, bo as dt, bp as at, aa as De, ab as st, az as We, b8 as $e, bq as Ue, br as ze, bs as Be, bt as At, ap as H, bu as qt, bv as W, bw as _t, bx as Vt, ai as Ct, by as Dt, ao as Wt, bz as $t, aZ as Ut, a_ as zt, b0 as Bt, b1 as jt, aj as Gt, bA as Zt, b6 as Ht, bB as Kt, b3 as je, aA as Ge, b7 as Xt, bc as Ze, bC as He, p as Jt, u as Ke, t as Xe, bD as Qt, bE as It, ar as Yt, $ as Je, bF as te, ba as ee, bG as ne, aP as pt, bH as se, bI as ot } from "./index-DdmHGZjq.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-yC3YH1jo.js";
|
|
3
|
+
import { g as pn, a as wn, e as In, c as bn } from "./axis_util-Did9235A.js";
|
|
4
|
+
import { b as xn } from "./broadcast_to-CUvOdOT5.js";
|
|
5
|
+
import { r as En } from "./reshape-WeJkT3ja.js";
|
|
6
|
+
import { p as Fn, q as yn, r as kn, u as Nn } from "./selu_util-BgUO9gHY.js";
|
|
7
7
|
import { g as vn } from "./_commonjsHelpers-ByX85dGu.js";
|
|
8
8
|
function Sn(e, t) {
|
|
9
9
|
for (var n = 0; n < t.length; n++) {
|
|
@@ -365,8 +365,8 @@ function Tn() {
|
|
|
365
365
|
throw Error("interior hyphen");
|
|
366
366
|
if (N === 0)
|
|
367
367
|
return u(I.substring(1), c, E).neg();
|
|
368
|
-
for (var L = r(l(E, 8)), R = g,
|
|
369
|
-
var U = Math.min(8, I.length -
|
|
368
|
+
for (var L = r(l(E, 8)), R = g, A = 0; A < I.length; A += 8) {
|
|
369
|
+
var U = Math.min(8, I.length - A), j = parseInt(I.substring(A, A + U), E);
|
|
370
370
|
if (U < 8) {
|
|
371
371
|
var C = r(l(E, U));
|
|
372
372
|
R = R.mul(C).add(r(j));
|
|
@@ -412,9 +412,9 @@ function Tn() {
|
|
|
412
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 j =
|
|
417
|
-
if (
|
|
415
|
+
for (var R = r(l(c, 6), this.unsigned), A = this, U = ""; ; ) {
|
|
416
|
+
var j = A.div(R), C = A.sub(j.mul(R)).toInt() >>> 0, P = C.toString(c);
|
|
417
|
+
if (A = j, A.isZero())
|
|
418
418
|
return P + U;
|
|
419
419
|
for (; P.length < 6; )
|
|
420
420
|
P = "0" + P;
|
|
@@ -480,8 +480,8 @@ function Tn() {
|
|
|
480
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, L = this.low >>> 16, R = this.low & 65535,
|
|
484
|
-
return B += R + C, _ += B >>> 16, B &= 65535, _ += L + j, G += _ >>> 16, _ &= 65535, G += N + U, P += G >>> 16, G &= 65535, P += E +
|
|
483
|
+
var E = this.high >>> 16, N = this.high & 65535, L = this.low >>> 16, R = this.low & 65535, A = 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 + A, 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) {
|
|
@@ -508,8 +508,8 @@ function Tn() {
|
|
|
508
508
|
return this.mul(c.neg()).neg();
|
|
509
509
|
if (this.lt(d) && c.lt(d))
|
|
510
510
|
return r(this.toNumber() * c.toNumber(), this.unsigned);
|
|
511
|
-
var N = this.high >>> 16, L = this.high & 65535, R = this.low >>> 16,
|
|
512
|
-
return ct +=
|
|
511
|
+
var N = this.high >>> 16, L = this.high & 65535, R = this.low >>> 16, A = 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 += A * P, B += ct >>> 16, ct &= 65535, B += R * P, _ += B >>> 16, B &= 65535, B += A * C, _ += B >>> 16, B &= 65535, _ += L * P, G += _ >>> 16, _ &= 65535, _ += R * C, G += _ >>> 16, _ &= 65535, _ += A * j, G += _ >>> 16, _ &= 65535, G += N * P + L * C + R * j + A * 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");
|
|
@@ -539,8 +539,8 @@ function Tn() {
|
|
|
539
539
|
return S;
|
|
540
540
|
if (c.eq(S))
|
|
541
541
|
return k;
|
|
542
|
-
var
|
|
543
|
-
return N =
|
|
542
|
+
var A = this.shr(1);
|
|
543
|
+
return N = A.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
544
|
} else if (c.eq(S))
|
|
545
545
|
return this.unsigned ? b : g;
|
|
546
546
|
if (this.isNegative())
|
|
@@ -675,7 +675,7 @@ function T(e, t) {
|
|
|
675
675
|
function St(e, t) {
|
|
676
676
|
return ie(e, t, 4);
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function q(e, t) {
|
|
679
679
|
return t === 0 ? e : e.shru(t).or(e.shl(64 - t));
|
|
680
680
|
}
|
|
681
681
|
function J(e, t, n = gt("9ddfea08eb382d69")) {
|
|
@@ -685,16 +685,16 @@ function J(e, t, n = gt("9ddfea08eb382d69")) {
|
|
|
685
685
|
return o = o.xor(o.shru(47)), o = o.mul(n), o;
|
|
686
686
|
}
|
|
687
687
|
function Mn(e, t, n, s, o, a) {
|
|
688
|
-
o = o.add(e), a =
|
|
688
|
+
o = o.add(e), a = q(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(q(o, 44)), [o.add(s), a.add(r)];
|
|
691
691
|
}
|
|
692
692
|
function ut(e, t, n, s) {
|
|
693
693
|
return Mn(T(e, t), T(e, t + 8), T(e, t + 16), T(e, t + 24), n, s);
|
|
694
694
|
}
|
|
695
695
|
function On(e, t = e.length) {
|
|
696
696
|
if (t >= 8) {
|
|
697
|
-
const n = D.add(t * 2), s = T(e, 0).add(D), o = T(e, t - 8), a =
|
|
697
|
+
const n = D.add(t * 2), s = T(e, 0).add(D), o = T(e, t - 8), a = q(o, 37).mul(n).add(s), r = q(s, 25).add(o).mul(n);
|
|
698
698
|
return J(a, r, n);
|
|
699
699
|
}
|
|
700
700
|
if (t >= 4) {
|
|
@@ -709,13 +709,13 @@ function On(e, t = e.length) {
|
|
|
709
709
|
}
|
|
710
710
|
function Ln(e, t = e.length) {
|
|
711
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(
|
|
712
|
+
return J(q(s.add(o), 43).add(q(a, 30)).add(r), s.add(q(o.add(D), 18)).add(a), n);
|
|
713
713
|
}
|
|
714
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 =
|
|
716
|
-
return J(
|
|
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 = q(s.add(o), 43).add(q(a, 30)).add(r), l = J(i, s.add(q(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(q(u.add(h), 43).add(q(f, 30)).add(p), u.add(q(h.add(s), 18)).add(f), n);
|
|
717
717
|
}
|
|
718
|
-
function
|
|
718
|
+
function An(e, t = e.length) {
|
|
719
719
|
const n = tt.fromNumber(81, !0);
|
|
720
720
|
if (t <= 32)
|
|
721
721
|
return t <= 16 ? On(e, t) : Ln(e, t);
|
|
@@ -726,10 +726,10 @@ function qn(e, t = e.length) {
|
|
|
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 = q(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(Y), o = q(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 = q(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
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 =
|
|
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 = q(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(f), o = q(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 = q(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
|
|
@@ -774,7 +774,7 @@ function le(e) {
|
|
|
774
774
|
t[n] = Math.abs(e[n]);
|
|
775
775
|
return t;
|
|
776
776
|
}
|
|
777
|
-
const
|
|
777
|
+
const qn = (e) => {
|
|
778
778
|
const { x: t } = e.inputs, n = e.backend;
|
|
779
779
|
nt(t, "abs");
|
|
780
780
|
let s = new Float32Array(V(t.shape));
|
|
@@ -783,7 +783,7 @@ const An = (e) => {
|
|
|
783
783
|
}, Xs = {
|
|
784
784
|
kernelName: Ce,
|
|
785
785
|
backendName: "cpu",
|
|
786
|
-
kernelFunc:
|
|
786
|
+
kernelFunc: qn
|
|
787
787
|
};
|
|
788
788
|
/**
|
|
789
789
|
* @license
|
|
@@ -803,7 +803,7 @@ const An = (e) => {
|
|
|
803
803
|
*/
|
|
804
804
|
function $(e) {
|
|
805
805
|
return (t, n, s, o, a) => {
|
|
806
|
-
const r = Pt(t, n), i = r.length, l =
|
|
806
|
+
const r = Pt(t, n), i = r.length, l = K(r), u = V(r), h = et(a, u), f = t.length, p = n.length, w = K(t), m = K(n), F = ht(t, r), d = ht(n, r);
|
|
807
807
|
if (F.length + d.length === 0)
|
|
808
808
|
for (let g = 0; g < h.length; ++g)
|
|
809
809
|
h[g] = e(s[g % s.length], o[g % o.length]);
|
|
@@ -1013,7 +1013,7 @@ function z(e, t, n, s) {
|
|
|
1013
1013
|
}
|
|
1014
1014
|
function Ft(e) {
|
|
1015
1015
|
return (t, n, s, o, a, r) => {
|
|
1016
|
-
const i = Pt(t, n), l = V(i), u = i.length, h =
|
|
1016
|
+
const i = Pt(t, n), l = V(i), u = i.length, h = K(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 = K(t), k = n.length, y = K(n);
|
|
1017
1017
|
if (w.length + m.length === 0)
|
|
1018
1018
|
for (let v = 0; v < f.length; v++) {
|
|
1019
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]);
|
|
@@ -1047,8 +1047,8 @@ function Ft(e) {
|
|
|
1047
1047
|
* limitations under the License.
|
|
1048
1048
|
* =============================================================================
|
|
1049
1049
|
*/
|
|
1050
|
-
const he = $((e, t) => e + t), _n = Ft((e, t, n, s) => ({ real: e + n, imag: t + s })), Vn = z(
|
|
1051
|
-
kernelName:
|
|
1050
|
+
const he = $((e, t) => e + t), _n = Ft((e, t, n, s) => ({ real: e + n, imag: t + s })), Vn = z(At, he, _n), eo = {
|
|
1051
|
+
kernelName: At,
|
|
1052
1052
|
backendName: "cpu",
|
|
1053
1053
|
kernelFunc: Vn
|
|
1054
1054
|
};
|
|
@@ -1079,7 +1079,7 @@ function Cn(e, t, n, s, o) {
|
|
|
1079
1079
|
return r;
|
|
1080
1080
|
}
|
|
1081
1081
|
function Dn(e, t, n, s = !1) {
|
|
1082
|
-
const o = e.shape[0], a = e.shape[1], r =
|
|
1082
|
+
const o = e.shape[0], a = e.shape[1], r = H([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,8 +1105,8 @@ function Dn(e, t, n, s = !1) {
|
|
|
1105
1105
|
* limitations under the License.
|
|
1106
1106
|
* =============================================================================
|
|
1107
1107
|
*/
|
|
1108
|
-
const fe = $((e, t) => e & t), Wn = z(
|
|
1109
|
-
kernelName:
|
|
1108
|
+
const fe = $((e, t) => e & t), Wn = z(qt, fe), no = {
|
|
1109
|
+
kernelName: qt,
|
|
1110
1110
|
backendName: "cpu",
|
|
1111
1111
|
kernelFunc: Wn
|
|
1112
1112
|
};
|
|
@@ -1351,8 +1351,8 @@ const be = $((e, t) => Math.floor(e / t)), Zn = z($t, be, null, "int32"), lo = {
|
|
|
1351
1351
|
* limitations under the License.
|
|
1352
1352
|
* =============================================================================
|
|
1353
1353
|
*/
|
|
1354
|
-
function
|
|
1355
|
-
const u =
|
|
1354
|
+
function Hn(e, t, n, s, o, a, r, i, l) {
|
|
1355
|
+
const u = H([s, a], n);
|
|
1356
1356
|
for (let h = 0; h < s; h++) {
|
|
1357
1357
|
const f = [];
|
|
1358
1358
|
let p = 0;
|
|
@@ -1383,8 +1383,8 @@ function Kn(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 Kn(e, t, n) {
|
|
1387
|
+
const s = H(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];
|
|
@@ -1587,8 +1587,8 @@ const Ne = $((e, t) => Math.max(e, t)), ss = z(Zt, Ne), mo = {
|
|
|
1587
1587
|
* limitations under the License.
|
|
1588
1588
|
* =============================================================================
|
|
1589
1589
|
*/
|
|
1590
|
-
const ve = $((e, t) => Math.min(e, t)), os = z(
|
|
1591
|
-
kernelName:
|
|
1590
|
+
const ve = $((e, t) => Math.min(e, t)), os = z(Ht, ve), po = {
|
|
1591
|
+
kernelName: Ht,
|
|
1592
1592
|
backendName: "cpu",
|
|
1593
1593
|
kernelFunc: os
|
|
1594
1594
|
};
|
|
@@ -1611,8 +1611,8 @@ const ve = $((e, t) => Math.min(e, t)), os = z(Kt, ve), po = {
|
|
|
1611
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(Kt, yt, rs), wo = {
|
|
1615
|
+
kernelName: Kt,
|
|
1616
1616
|
backendName: "cpu",
|
|
1617
1617
|
kernelFunc: as
|
|
1618
1618
|
};
|
|
@@ -1685,7 +1685,7 @@ const Te = $((e, t) => e !== t ? 1 : 0), ls = z(Xt, Te, null, "bool"), bo = {
|
|
|
1685
1685
|
* =============================================================================
|
|
1686
1686
|
*/
|
|
1687
1687
|
function Re(e, t, n, s, o) {
|
|
1688
|
-
const a = t.length, r = V(t), i =
|
|
1688
|
+
const a = t.length, r = V(t), i = K(t), l = K(o), u = et(n, V(o));
|
|
1689
1689
|
for (let h = 0; h < r; ++h) {
|
|
1690
1690
|
const f = dt(h, a, i), p = new Array(f.length);
|
|
1691
1691
|
for (let m = 0; m < p.length; m++)
|
|
@@ -1742,7 +1742,7 @@ const xo = {
|
|
|
1742
1742
|
* =============================================================================
|
|
1743
1743
|
*/
|
|
1744
1744
|
function Oe(e, t, n, s) {
|
|
1745
|
-
const [o, a] = bn(e, s), r =
|
|
1745
|
+
const [o, a] = bn(e, s), r = Ke(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;
|
|
@@ -1764,7 +1764,7 @@ function cs(e) {
|
|
|
1764
1764
|
return r && (g = In(F, l)), p.forEach((b) => n.disposeIntermediateTensorInfo(b)), n.makeTensorInfo(g, d, m);
|
|
1765
1765
|
}
|
|
1766
1766
|
const Eo = {
|
|
1767
|
-
kernelName:
|
|
1767
|
+
kernelName: He,
|
|
1768
1768
|
backendName: "cpu",
|
|
1769
1769
|
kernelFunc: cs
|
|
1770
1770
|
};
|
|
@@ -1787,7 +1787,7 @@ const Eo = {
|
|
|
1787
1787
|
function us(e, t, n) {
|
|
1788
1788
|
e.forEach((s, o) => {
|
|
1789
1789
|
if (s < 0 || s >= n) {
|
|
1790
|
-
const a = dt(o, t.length,
|
|
1790
|
+
const a = dt(o, t.length, K(t)).join(",");
|
|
1791
1791
|
throw new Error(`indices[${a}] = ${s} is not in [0, ${n})`);
|
|
1792
1792
|
}
|
|
1793
1793
|
});
|
|
@@ -2260,8 +2260,8 @@ const Le = X((e) => 1 / Math.sqrt(e)), xs = Q(Qt, Le), Fo = {
|
|
|
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 w = l instanceof It ? l :
|
|
2263
|
+
return H(n, t.dtype);
|
|
2264
|
+
const w = l instanceof It ? l : H(h, t.dtype);
|
|
2265
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 = [];
|
|
@@ -2315,12 +2315,12 @@ const Fs = X((e) => 1 / (1 + Math.exp(-e))), ys = de(Yt, (e) => 1 / (1 + Math.ex
|
|
|
2315
2315
|
* =============================================================================
|
|
2316
2316
|
*/
|
|
2317
2317
|
function Pe(e, t, n, s, o) {
|
|
2318
|
-
const a = kn(s, t, n), r = V(n), i =
|
|
2318
|
+
const a = kn(s, t, n), r = V(n), i = K(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 = H(s, o, l), h = H(n, o);
|
|
2324
2324
|
for (let f = 0; f < h.size; ++f) {
|
|
2325
2325
|
const p = h.indexToLoc(f), w = p.map((m, F) => m + t[F]);
|
|
2326
2326
|
h.set(u.get(...w), ...p);
|
|
@@ -2578,10 +2578,10 @@ const Ts = X((e) => Math.sqrt(e)), Rs = de(te, (e) => Math.sqrt(e)), No = {
|
|
|
2578
2578
|
* limitations under the License.
|
|
2579
2579
|
* =============================================================================
|
|
2580
2580
|
*/
|
|
2581
|
-
const
|
|
2581
|
+
const Ae = $((e, t) => {
|
|
2582
2582
|
const n = e - t;
|
|
2583
2583
|
return n * n;
|
|
2584
|
-
}), Ms = z(ee,
|
|
2584
|
+
}), Ms = z(ee, Ae), vo = {
|
|
2585
2585
|
kernelName: ee,
|
|
2586
2586
|
backendName: "cpu",
|
|
2587
2587
|
kernelFunc: Ms
|
|
@@ -2602,10 +2602,10 @@ const qe = $((e, t) => {
|
|
|
2602
2602
|
* limitations under the License.
|
|
2603
2603
|
* =============================================================================
|
|
2604
2604
|
*/
|
|
2605
|
-
const
|
|
2605
|
+
const qe = 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
|
-
}), Os = Q(ne,
|
|
2608
|
+
}), Os = Q(ne, qe), So = {
|
|
2609
2609
|
kernelName: ne,
|
|
2610
2610
|
backendName: "cpu",
|
|
2611
2611
|
kernelFunc: Os
|
|
@@ -2627,7 +2627,7 @@ const Ae = X((e, t) => {
|
|
|
2627
2627
|
* =============================================================================
|
|
2628
2628
|
*/
|
|
2629
2629
|
function Ls(e, t, n, s) {
|
|
2630
|
-
const o =
|
|
2630
|
+
const o = H(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++)
|
|
@@ -2742,7 +2742,7 @@ class Ps {
|
|
|
2742
2742
|
return [i, r];
|
|
2743
2743
|
}
|
|
2744
2744
|
}
|
|
2745
|
-
function
|
|
2745
|
+
function As(e, t, n, s, o, a, r, i) {
|
|
2746
2746
|
return new Ps(n, s, o, a, r, i).compute(e, t);
|
|
2747
2747
|
}
|
|
2748
2748
|
/**
|
|
@@ -2761,7 +2761,7 @@ function qs(e, t, n, s, o, a, r, i) {
|
|
|
2761
2761
|
* limitations under the License.
|
|
2762
2762
|
* =============================================================================
|
|
2763
2763
|
*/
|
|
2764
|
-
function
|
|
2764
|
+
function qs(e, t, n, s) {
|
|
2765
2765
|
if (!e.length)
|
|
2766
2766
|
return;
|
|
2767
2767
|
if (t.length === 0) {
|
|
@@ -2792,7 +2792,7 @@ function _s(e, t, n) {
|
|
|
2792
2792
|
const i = new Array(s);
|
|
2793
2793
|
for (let p = 0; p < s; ++p) {
|
|
2794
2794
|
const w = o.length;
|
|
2795
|
-
|
|
2795
|
+
qs(e[p], t, n, o);
|
|
2796
2796
|
const m = o.length - w;
|
|
2797
2797
|
i[p] = m, a += m, r = Math.max(r, m);
|
|
2798
2798
|
}
|
|
@@ -2822,7 +2822,7 @@ function _s(e, t, n) {
|
|
|
2822
2822
|
function Vs(e, t) {
|
|
2823
2823
|
const n = W("int32", e.length);
|
|
2824
2824
|
for (let s = 0; s < e.length; ++s)
|
|
2825
|
-
n[s] =
|
|
2825
|
+
n[s] = An(e[s]).modulo(t).getLowBitsUnsigned();
|
|
2826
2826
|
return n;
|
|
2827
2827
|
}
|
|
2828
2828
|
/**
|
|
@@ -2866,7 +2866,7 @@ 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 = H(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++)
|
|
@@ -2925,8 +2925,8 @@ function $s(e, t, n, s, o) {
|
|
|
2925
2925
|
}
|
|
2926
2926
|
const h = t.slice();
|
|
2927
2927
|
return h[h.length - 1] = s, [
|
|
2928
|
-
|
|
2929
|
-
|
|
2928
|
+
H(h, n, l),
|
|
2929
|
+
H(h, "int32", u)
|
|
2930
2930
|
];
|
|
2931
2931
|
}
|
|
2932
2932
|
/**
|
|
@@ -3017,8 +3017,8 @@ const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3017
3017
|
expm1Impl: we,
|
|
3018
3018
|
floorDivImpl: be,
|
|
3019
3019
|
floorImpl: Ie,
|
|
3020
|
-
gatherNdImpl:
|
|
3021
|
-
gatherV2Impl:
|
|
3020
|
+
gatherNdImpl: Hn,
|
|
3021
|
+
gatherV2Impl: Kn,
|
|
3022
3022
|
greaterEqualImpl: Ee,
|
|
3023
3023
|
greaterImpl: xe,
|
|
3024
3024
|
lessEqualImpl: ye,
|
|
@@ -3045,10 +3045,10 @@ const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3045
3045
|
sparseReshapeImpl: vs,
|
|
3046
3046
|
sparseSegmentReductionImpl: Ss,
|
|
3047
3047
|
sqrtImpl: Ts,
|
|
3048
|
-
squaredDifferenceImpl:
|
|
3049
|
-
staticRegexReplaceImpl:
|
|
3048
|
+
squaredDifferenceImpl: Ae,
|
|
3049
|
+
staticRegexReplaceImpl: qe,
|
|
3050
3050
|
stridedSliceImpl: Ls,
|
|
3051
|
-
stringNGramsImpl:
|
|
3051
|
+
stringNGramsImpl: As,
|
|
3052
3052
|
stringSplitImpl: _s,
|
|
3053
3053
|
stringToHashBucketFastImpl: Vs,
|
|
3054
3054
|
subImpl: _e,
|
|
@@ -3067,7 +3067,7 @@ export {
|
|
|
3067
3067
|
vs as F,
|
|
3068
3068
|
Ss as G,
|
|
3069
3069
|
Ls as H,
|
|
3070
|
-
|
|
3070
|
+
As as I,
|
|
3071
3071
|
_s as J,
|
|
3072
3072
|
Vs as K,
|
|
3073
3073
|
Ws as L,
|
|
@@ -3119,8 +3119,8 @@ export {
|
|
|
3119
3119
|
lt as l,
|
|
3120
3120
|
as as m,
|
|
3121
3121
|
Ds as n,
|
|
3122
|
-
|
|
3123
|
-
|
|
3122
|
+
Hn as o,
|
|
3123
|
+
Kn as p,
|
|
3124
3124
|
ts as q,
|
|
3125
3125
|
ce as r,
|
|
3126
3126
|
Ro as s,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as e, D as u, a0 as c, E as l, a1 as m } from "./index-DdmHGZjq.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -18,8 +18,8 @@ import { B as e, C as u, X as c, E as l, Y as m } from "./index-BoWRt-10.js";
|
|
|
18
18
|
function i(t, n = null, o = !1) {
|
|
19
19
|
let s = u(t, "x", "sum");
|
|
20
20
|
s.dtype === "bool" && (s = c(s, "int32"));
|
|
21
|
-
const
|
|
22
|
-
return l.runKernel(m,
|
|
21
|
+
const a = { x: s }, r = { axis: n, keepDims: o };
|
|
22
|
+
return l.runKernel(m, a, r);
|
|
23
23
|
}
|
|
24
24
|
const f = /* @__PURE__ */ e({ sum_: i });
|
|
25
25
|
export {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z as o, A as s, B as t } from "./index-DdmHGZjq.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
* =============================================================================
|
|
17
|
+
*/
|
|
18
|
+
function h(r, e) {
|
|
19
|
+
o(r);
|
|
20
|
+
const n = s(r, e);
|
|
21
|
+
if (n.length !== 1)
|
|
22
|
+
throw new Error("tensor1d() requires values to be a flat/TypedArray");
|
|
23
|
+
return t(r, null, n, e);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
h as t
|
|
27
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z as o, A as a, B as s } from "./index-DdmHGZjq.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
* =============================================================================
|
|
17
|
+
*/
|
|
18
|
+
function h(n, r, t) {
|
|
19
|
+
if (o(n), r != null && r.length !== 3)
|
|
20
|
+
throw new Error("tensor3d() requires shape to have three numbers");
|
|
21
|
+
const e = a(n, t);
|
|
22
|
+
if (e.length !== 3 && e.length !== 1)
|
|
23
|
+
throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");
|
|
24
|
+
if (e.length === 1 && r == null)
|
|
25
|
+
throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");
|
|
26
|
+
return s(n, r, e, t);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
h as t
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z as t, A as a, B as s } from "./index-DdmHGZjq.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
* =============================================================================
|
|
17
|
+
*/
|
|
18
|
+
function i(n, r, o) {
|
|
19
|
+
if (t(n), r != null && r.length !== 4)
|
|
20
|
+
throw new Error("tensor4d() requires shape to have four numbers");
|
|
21
|
+
const e = a(n, o);
|
|
22
|
+
if (e.length !== 4 && e.length !== 1)
|
|
23
|
+
throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");
|
|
24
|
+
if (e.length === 1 && r == null)
|
|
25
|
+
throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");
|
|
26
|
+
return s(n, r, e, o);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
i as t
|
|
30
|
+
};
|
package/dist/training/Adam.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { adamAdjust as b } from "../ops/adamAdjust.js";
|
|
2
2
|
import { adamMoments as d } from "../ops/adamMoments.js";
|
|
3
|
-
import { O as g, e as h, t as o, d as B } from "../index-
|
|
4
|
-
import { z as M } from "../zeros
|
|
3
|
+
import { O as g, e as h, t as o, d as B } from "../index-DdmHGZjq.js";
|
|
4
|
+
import { z as M } from "../zeros-Dnwix0p4.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
package/dist/training/AdamExt.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { default as NanoGPT } from '../NanoGPTModel';
|
|
2
1
|
import { Dataset } from '@tensorflow/tfjs-data';
|
|
3
2
|
import { TensorContainer } from '@tensorflow/tfjs-core';
|
|
3
|
+
import { default as Model, ModelForwardAttributes } from '../models/model';
|
|
4
4
|
export default class Evaluator {
|
|
5
5
|
private model;
|
|
6
6
|
private iterator;
|
|
7
|
-
constructor(model:
|
|
7
|
+
constructor(model: Model<ModelForwardAttributes>, dataset: Dataset<TensorContainer>);
|
|
8
8
|
evaluate(maxBatches?: number): Promise<number>;
|
|
9
9
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ITokeniser } from '../tokeniser/type';
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as GPTTrainer, TrainingOptions, TrainingProgress } from './Trainer';
|
|
2
|
+
import { default as GPTTrainer, TrainingLogEntry, TrainingOptions, TrainingProgress } from './Trainer';
|
|
4
3
|
import { Tensor } from '@tensorflow/tfjs-core';
|
|
5
4
|
import { Dataset } from '@tensorflow/tfjs-data';
|
|
5
|
+
import { default as Model, ModelForwardAttributes } from '../models/model';
|
|
6
6
|
export default class FullTrainer extends GPTTrainer {
|
|
7
|
-
constructor(model:
|
|
7
|
+
constructor(model: Model<ModelForwardAttributes>, tokenizer: ITokeniser, learningRate?: number);
|
|
8
8
|
private createEmptyState;
|
|
9
9
|
private createLogEntry;
|
|
10
10
|
private createProgress;
|