@genai-fi/nanogpt 0.9.1 → 0.10.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/README.md +352 -14
- package/dist/Generator.js +69 -78
- package/dist/{RealDiv-D4EzDsC0.js → RealDiv-DgA3z9oO.js} +32 -206
- package/dist/Reshape-CF6odzV4.js +16 -0
- package/dist/Reshape-_kILl6tK.js +81 -0
- package/dist/TeachableLLM.js +28 -22
- package/dist/Trainer.d.ts +2 -0
- package/dist/Trainer.js +3 -2
- package/dist/{axis_util-TbGYJ208.js → axis_util-BvHEw88j.js} +7 -23
- package/dist/backend.d.ts +2 -1
- package/dist/backend.js +10 -4
- package/dist/backend_util-D-rUb2ty.js +474 -0
- package/dist/backend_webgpu-B0u2ndUn.js +547 -0
- package/dist/binary_op_util-pKXltfxI.js +192 -0
- package/dist/broadcast_to-CwF7XIeu.js +30 -0
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/check.d.ts +1 -1
- package/dist/checks/check.js +8 -8
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/index.d.ts +2 -0
- package/dist/checks/index.js +7 -5
- package/dist/checks/matMulGelu.js +6 -6
- package/dist/checks/normRMS.js +7 -7
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.d.ts +1 -0
- package/dist/checks/packUnpack.js +18 -0
- package/dist/checks/qkv.js +12 -27
- package/dist/checks/rope.js +2 -2
- package/dist/checks/weights.js +18 -16
- package/dist/complex-CSlYz-2T.js +13 -0
- package/dist/complex_util-Yc1A_gV1.js +55 -0
- package/dist/concat-BHlIJeyT.js +19 -0
- package/dist/concat_util-DcJk7YHS.js +22 -0
- package/dist/data/docx.js +1 -1
- package/dist/data/parquet.js +2 -2
- package/dist/data/pdf.js +1 -1
- package/dist/data/textLoader.js +1 -1
- package/dist/{dataset-DlZtKmBq.js → dataset-0xP8GjwI.js} +136 -236
- package/dist/dropout-C1pM3f11.js +99 -0
- package/dist/expand_dims-BPG4fwBP.js +13 -0
- package/dist/exports_initializers-xuidcwI4.js +7 -0
- package/dist/gather-DykLGqmW.js +10 -0
- package/dist/{gelu-Bp_-935b.js → gelu-CNLFZWea.js} +11 -10
- package/dist/{gpgpu_math-CDaYiyE_.js → gpgpu_math-DDVJCn6-.js} +90 -265
- package/dist/{index-C4L8Cm77.js → index-CieiGp4Y.js} +14 -14
- package/dist/index-CjOj7j-u.js +7308 -0
- package/dist/{index-Tf7vU29b.js → index-Cp39cXWe.js} +3 -10
- package/dist/{index-Dwqa6Zy2.js → index-DvYrXKkX.js} +2 -2
- package/dist/index-ZyQhjEPo.js +2157 -0
- package/dist/{jszip.min-CjP2V1VV.js → jszip.min-Bz5-11Bk.js} +56 -57
- package/dist/kernel_funcs_utils-Dg_-E44D.js +308 -0
- package/dist/layers/BaseLayer.d.ts +1 -0
- package/dist/layers/BaseLayer.js +7 -6
- package/dist/layers/CausalSelfAttention.d.ts +0 -1
- package/dist/layers/CausalSelfAttention.js +56 -55
- package/dist/layers/MLP.js +15 -16
- package/dist/layers/PositionEmbedding.js +5 -14
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.d.ts +2 -0
- package/dist/layers/RoPECache.js +22 -17
- package/dist/layers/TiedEmbedding.js +22 -17
- package/dist/layers/TransformerBlock.js +21 -20
- package/dist/loader/load.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +39 -33
- package/dist/loader/save.js +1 -1
- package/dist/log_sum_exp-DWI-76TI.js +41 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.js +63 -52
- package/dist/matMul16--R5hOwDG.js +77 -0
- package/dist/mat_mul-DeAh4uTH.js +12 -0
- package/dist/mod-Gt1rMB4n.js +12 -0
- package/dist/models/NanoGPTV1.js +40 -31
- package/dist/models/model.d.ts +2 -0
- package/dist/models/model.js +37 -29
- package/dist/{mulmat_packed_gpu-BT60jmzP.js → mulmat_packed_gpu-BMFhLwta.js} +1 -17
- package/dist/{non_max_suppression_impl-CsEgBuMA.js → non_max_suppression_impl-B2W7YjZB.js} +0 -32
- package/dist/ones-CAMiP4I2.js +15 -0
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.d.ts +1 -1
- package/dist/ops/adamMoments.js +4 -4
- package/dist/ops/add16.d.ts +2 -0
- package/dist/ops/add16.js +9 -0
- package/dist/ops/appendCache.js +16 -9
- package/dist/ops/attentionMask.js +4 -4
- package/dist/ops/concat16.d.ts +2 -0
- package/dist/ops/concat16.js +9 -0
- package/dist/ops/cpu/adamAdjust.js +14 -13
- package/dist/ops/cpu/adamMoments.js +10 -9
- package/dist/ops/cpu/appendCache.js +9 -8
- package/dist/ops/cpu/attentionMask.js +15 -14
- package/dist/ops/cpu/fusedSoftmax.js +13 -12
- package/dist/ops/cpu/gatherSub.js +9 -24
- package/dist/ops/cpu/gelu.js +13 -12
- package/dist/ops/cpu/matMul16.d.ts +1 -0
- package/dist/ops/cpu/matMul16.js +16 -0
- package/dist/ops/cpu/matMulGelu.js +18 -16
- package/dist/ops/cpu/matMulMul.js +8 -7
- package/dist/ops/cpu/mulDropout.js +4 -3
- package/dist/ops/cpu/normRMS.js +11 -10
- package/dist/ops/cpu/qkv.js +17 -13
- package/dist/ops/cpu/rope.js +23 -22
- package/dist/ops/cpu/scatterSub.js +16 -30
- package/dist/ops/dot16.d.ts +2 -0
- package/dist/ops/dot16.js +42 -0
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/add16.d.ts +1 -0
- package/dist/ops/grads/add16.js +27 -0
- package/dist/ops/grads/attentionMask.js +12 -19
- package/dist/ops/grads/gelu.js +4 -3
- package/dist/ops/grads/matMul16.d.ts +2 -0
- package/dist/ops/grads/matMul16.js +9 -0
- package/dist/ops/grads/matMulGelu.js +8 -7
- package/dist/ops/grads/normRMS.js +8 -7
- package/dist/ops/grads/{fusedSoftmax.d.ts → pack16.d.ts} +1 -1
- package/dist/ops/grads/pack16.js +7 -0
- package/dist/ops/grads/qkv.d.ts +3 -1
- package/dist/ops/grads/qkv.js +28 -22
- package/dist/ops/grads/rope.d.ts +2 -1
- package/dist/ops/grads/rope.js +6 -13
- package/dist/ops/grads/softmax16.d.ts +2 -0
- package/dist/ops/grads/softmax16.js +26 -0
- package/dist/ops/grads/unpack16.d.ts +2 -0
- package/dist/ops/grads/unpack16.js +6 -0
- package/dist/ops/grads/utils.d.ts +3 -0
- package/dist/ops/grads/utils.js +10 -0
- package/dist/ops/matMul16.d.ts +15 -0
- package/dist/ops/matMul16.js +13 -0
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mul16.d.ts +2 -0
- package/dist/ops/mul16.js +8 -0
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/pack16.d.ts +2 -0
- package/dist/ops/pack16.js +6 -0
- package/dist/ops/qkv.d.ts +1 -1
- package/dist/ops/qkv.js +8 -4
- package/dist/ops/reshape16.d.ts +2 -0
- package/dist/ops/reshape16.js +43 -0
- package/dist/ops/rope.d.ts +1 -1
- package/dist/ops/rope.js +8 -10
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.d.ts +2 -0
- package/dist/ops/slice16.js +9 -0
- package/dist/ops/softmax16.d.ts +2 -0
- package/dist/ops/softmax16.js +12 -0
- package/dist/ops/sub16.d.ts +2 -0
- package/dist/ops/sub16.js +8 -0
- package/dist/ops/sum16.d.ts +2 -0
- package/dist/ops/sum16.js +13 -0
- package/dist/ops/transpose16.d.ts +3 -0
- package/dist/ops/transpose16.js +41 -0
- package/dist/ops/unpack16.d.ts +2 -0
- package/dist/ops/unpack16.js +6 -0
- package/dist/ops/webgl/adamAdjust.js +3 -2
- package/dist/ops/webgl/adamMoments.js +2 -1
- package/dist/ops/webgl/appendCache.js +2 -1
- package/dist/ops/webgl/attentionMask.js +5 -4
- package/dist/ops/webgl/fusedSoftmax.js +6 -4
- package/dist/ops/webgl/gatherSub.js +7 -6
- package/dist/ops/webgl/gelu.js +3 -2
- package/dist/ops/webgl/log.js +12 -27
- package/dist/ops/webgl/matMul16.d.ts +1 -0
- package/dist/ops/webgl/matMul16.js +37 -0
- package/dist/ops/webgl/matMulGelu.js +17 -15
- package/dist/ops/webgl/matMulMul.js +13 -12
- package/dist/ops/webgl/mulDropout.js +9 -8
- package/dist/ops/webgl/normRMS.js +8 -7
- package/dist/ops/webgl/qkv.js +6 -5
- package/dist/ops/webgl/rope.js +11 -10
- package/dist/ops/webgl/scatterSub.js +6 -5
- package/dist/ops/webgpu/adamAdjust.js +12 -10
- package/dist/ops/webgpu/adamMoments.js +27 -22
- package/dist/ops/webgpu/add16.d.ts +1 -0
- package/dist/ops/webgpu/add16.js +14 -0
- package/dist/ops/webgpu/appendCache.js +64 -17
- package/dist/ops/webgpu/attentionMask.js +19 -62
- package/dist/ops/webgpu/attentionMask32_program.d.ts +19 -0
- package/dist/ops/webgpu/attentionMask32_program.js +54 -0
- package/dist/ops/webgpu/concat16.d.ts +19 -0
- package/dist/ops/webgpu/concat16.js +128 -0
- package/dist/ops/webgpu/gatherSub.js +9 -7
- package/dist/ops/webgpu/gelu.js +78 -31
- package/dist/ops/webgpu/index.js +12 -0
- package/dist/ops/webgpu/matMul16.d.ts +1 -0
- package/dist/ops/webgpu/matMul16.js +58 -0
- package/dist/ops/webgpu/matMul16_program.d.ts +42 -0
- package/dist/ops/webgpu/matMul16_program.js +336 -0
- package/dist/ops/webgpu/mul16.d.ts +1 -0
- package/dist/ops/webgpu/mul16.js +14 -0
- package/dist/ops/webgpu/normRMS.js +21 -40
- package/dist/ops/webgpu/normRMS16_program.d.ts +9 -0
- package/dist/ops/webgpu/normRMS16_program.js +24 -0
- package/dist/ops/webgpu/normRMS32_program.d.ts +9 -0
- package/dist/ops/webgpu/normRMS32_program.js +24 -0
- package/dist/ops/webgpu/normRMSGrad.js +113 -64
- package/dist/ops/webgpu/pack16.d.ts +1 -0
- package/dist/ops/webgpu/pack16.js +19 -0
- package/dist/ops/webgpu/pack16_program.d.ts +19 -0
- package/dist/ops/webgpu/pack16_program.js +92 -0
- package/dist/ops/webgpu/qkv.js +20 -55
- package/dist/ops/webgpu/rope.js +77 -22
- package/dist/ops/webgpu/scatterSub.js +9 -7
- package/dist/ops/webgpu/slice16.d.ts +7 -0
- package/dist/ops/webgpu/slice16.js +71 -0
- package/dist/{variable-Bm2OFwGI.js → ops/webgpu/softmax16.d.ts} +2 -8
- package/dist/ops/webgpu/softmax16.js +23 -0
- package/dist/ops/webgpu/softmax16_program.d.ts +13 -0
- package/dist/ops/webgpu/softmax16_program.js +73 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +17 -0
- package/dist/ops/webgpu/softmax16_subgroup_program.js +75 -0
- package/dist/ops/webgpu/softmax16grad.d.ts +1 -0
- package/dist/ops/webgpu/softmax16grad.js +38 -0
- package/dist/ops/webgpu/sub16.d.ts +1 -0
- package/dist/ops/webgpu/sub16.js +14 -0
- package/dist/ops/webgpu/sum16.d.ts +1 -0
- package/dist/ops/webgpu/sum16.js +40 -0
- package/dist/ops/webgpu/transpose16.d.ts +1 -0
- package/dist/ops/webgpu/transpose16.js +35 -0
- package/dist/ops/webgpu/transpose16_program.d.ts +16 -0
- package/dist/ops/webgpu/transpose16_program.js +50 -0
- package/dist/ops/webgpu/transpose16_shared_program.d.ts +15 -0
- package/dist/ops/webgpu/transpose16_shared_program.js +71 -0
- package/dist/ops/webgpu/unpack16.d.ts +1 -0
- package/dist/ops/webgpu/unpack16.js +49 -0
- package/dist/ops/webgpu/utils/binary_op.d.ts +19 -0
- package/dist/ops/webgpu/utils/binary_op.js +79 -0
- package/dist/ops/webgpu/utils/deviceInfo.d.ts +7 -0
- package/dist/ops/webgpu/utils/deviceInfo.js +11 -0
- package/dist/ops/webgpu/utils/reductions.d.ts +32 -4
- package/dist/ops/webgpu/utils/reductions.js +236 -45
- package/dist/ops-CNI3TwqM.js +645 -0
- package/dist/pack16-CFUqumar.js +41 -0
- package/dist/{papaparse.min-C8l2Kvo1.js → papaparse.min-C0cScC2i.js} +2 -8
- package/dist/{parquet-C0Tlmv9c.js → parquet-BE8MU_ge.js} +201 -278
- package/dist/patches/PackedTensor.d.ts +12 -0
- package/dist/patches/PackedTensor.js +11 -0
- package/dist/patches/engine.d.ts +261 -0
- package/dist/patches/engine.js +10 -0
- package/dist/patches/tape.d.ts +12 -0
- package/dist/patches/tape.js +5 -0
- package/dist/patches/webgpu_backend.d.ts +18 -0
- package/dist/patches/webgpu_backend.js +57 -0
- package/dist/{tensor-CZr4dh61.js → patches/webgpu_base.d.ts} +5 -8
- package/dist/patches/webgpu_base.js +34 -0
- package/dist/patches/webgpu_program.d.ts +36 -0
- package/dist/patches/webgpu_program.js +401 -0
- package/dist/{pdf-kJD-f258.js → pdf-NIhmP3sq.js} +424 -428
- package/dist/random_width-DY6Kk2Dl.js +10051 -0
- package/dist/range-BMS52eQi.js +11 -0
- package/dist/reciprocal-CTmshQ9J.js +10 -0
- package/dist/{register_all_kernels-DIGpEwcf.js → register_all_kernels-Bwu1PTuU.js} +719 -9766
- package/dist/relu-yZ2-7WxU.js +10 -0
- package/dist/reshape-DevtBWtf.js +10 -0
- package/dist/rope-B5UUMsPi.js +32 -0
- package/dist/{scatter_nd_util-BQdz--Gn.js → scatter_nd_util-5EL-8VAQ.js} +1 -1
- package/dist/selu_util-D1w6yyTO.js +303 -0
- package/dist/{shared-DuP7ue-R.js → shared-BRksrJb3.js} +1 -17
- package/dist/shared-BuAXb4CI.js +2145 -0
- package/dist/sin-BGfy2HZo.js +16 -0
- package/dist/slice-D_gkkqZK.js +13 -0
- package/dist/slice_util-DtEldBfK.js +261 -0
- package/dist/softmax-ZHVebtR1.js +13 -0
- package/dist/split-DrfihRpZ.js +10 -0
- package/dist/squeeze-DZEpeblb.js +11 -0
- package/dist/stack-yOIAalTq.js +13 -0
- package/dist/sum-_fzj5ZTB.js +12 -0
- package/dist/tensor-DdQUJZlz.js +909 -0
- package/dist/tensor-f35l8Odg.js +8 -0
- package/dist/tensor1d-CeZuc-Rv.js +12 -0
- package/dist/tensor2d-G4Ys2GxX.js +15 -0
- package/dist/tensor4d-B8roDgtc.js +15 -0
- package/dist/tensor_util-DV-FP5Q3.js +523 -0
- package/dist/tfjs_backend-kNyO5L2d.js +653 -0
- package/dist/tile-BzyEiF-F.js +13 -0
- package/dist/tokeniser/CharTokeniser.js +1 -1
- package/dist/tokeniser/bpe.js +1 -1
- package/dist/training/Adam.d.ts +2 -1
- package/dist/training/Adam.js +12 -28
- package/dist/training/AdamExt.d.ts +1 -0
- package/dist/training/AdamExt.js +2 -2
- package/dist/training/DatasetBuilder.js +3 -20
- package/dist/training/FullTrainer.js +55 -48
- package/dist/training/Trainer.d.ts +11 -6
- package/dist/training/Trainer.js +51 -39
- package/dist/training/sparseCrossEntropy.js +3 -3
- package/dist/transpose-DKELTqhe.js +38 -0
- package/dist/utilities/arrayClose.js +7 -7
- package/dist/utilities/dummy.js +35 -27
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.d.ts +7 -0
- package/dist/utilities/packed.js +716 -0
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/sentences.d.ts +5 -0
- package/dist/utilities/sentences.js +41 -0
- package/dist/utilities/weights.js +2 -2
- package/dist/variable-Bhn5bHYv.js +7 -0
- package/dist/{webgpu_program-DkQJOJSd.js → webgpu_program-Cigz-7RF.js} +15 -44
- package/dist/webgpu_util-BBCnKm2X.js +65 -0
- package/dist/zeros-2gldETuK.js +14 -0
- package/package.json +4 -3
- package/dist/Reshape-Bowtk9BP.js +0 -127
- package/dist/Reshape-DUqYftGC.js +0 -30
- package/dist/backend_util-CJIiDoV1.js +0 -749
- package/dist/broadcast_to-DzlNweb8.js +0 -44
- package/dist/concat-B912vBbo.js +0 -33
- package/dist/dropout-C-csYCLj.js +0 -193
- package/dist/exports_initializers-B8iZMgQ0.js +0 -16
- package/dist/gather-Dnpgw-YQ.js +0 -25
- package/dist/index-BzFyqcy-.js +0 -4457
- package/dist/index-C1rx_Ajs.js +0 -12076
- package/dist/kernel_funcs_utils-DKLK0Mg3.js +0 -466
- package/dist/log_sum_exp-DO6z8tSE.js +0 -103
- package/dist/mat_mul-DzjTFx-u.js +0 -27
- package/dist/mod-Dobti4j4.js +0 -27
- package/dist/ones-tIJeHlq-.js +0 -29
- package/dist/ops/fusedSoftmax.d.ts +0 -2
- package/dist/ops/fusedSoftmax.js +0 -10
- package/dist/ops/grads/fusedSoftmax.js +0 -22
- package/dist/ops-LuCMAnmM.js +0 -1525
- package/dist/random_width-CXVRloNK.js +0 -13670
- package/dist/range-CWcz7xFA.js +0 -26
- package/dist/reciprocal-C4rNcM-S.js +0 -25
- package/dist/relu-BjCh_SYb.js +0 -25
- package/dist/reshape-CnIwVG1c.js +0 -25
- package/dist/selu_util-OtRzVwW5.js +0 -719
- package/dist/shared-DmRsFyaJ.js +0 -3134
- package/dist/sin-gpDNRxE0.js +0 -47
- package/dist/slice-d0Vo9XTN.js +0 -28
- package/dist/softmax-D7Jj3p_P.js +0 -28
- package/dist/split-DK2k5eHf.js +0 -25
- package/dist/stack-DFatutCx.js +0 -27
- package/dist/sum-CJ0ULhmt.js +0 -27
- package/dist/tensor1d-vML0r3q6.js +0 -27
- package/dist/tensor2d-D76QGjF3.js +0 -30
- package/dist/tensor4d-Df1WlVDY.js +0 -30
- package/dist/webgpu_util-pLEV9tks.js +0 -80
- package/dist/zeros-Bj5rMYA7.js +0 -52
|
@@ -1,749 +0,0 @@
|
|
|
1
|
-
import { j as m, a3 as R, n as g, aN as $, aO as O, aP as _, l as M, ae as y, ax as D, aQ as T, u as b, aR as F } from "./index-BzFyqcy-.js";
|
|
2
|
-
import { b as L, d as W, f as v, c as N, e as x, g as P, a as C, h as z } from "./axis_util-TbGYJ208.js";
|
|
3
|
-
import { S as U, a as B, b as V, c as j, d as G, e as H, f as k, g as q, h as Z, i as X, j as J, k as K, l as Q, m as Y, s as ee, n as te, o as ne, t as se } from "./selu_util-OtRzVwW5.js";
|
|
4
|
-
import { c as re, v as oe, a as ae } from "./scatter_nd_util-BQdz--Gn.js";
|
|
5
|
-
function ie(e, n) {
|
|
6
|
-
const r = e.shape.length, t = n.shape.length;
|
|
7
|
-
if (r < 1)
|
|
8
|
-
throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${r}.`);
|
|
9
|
-
if (t < 1)
|
|
10
|
-
throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${t}.`);
|
|
11
|
-
if (n.dtype !== "int32")
|
|
12
|
-
throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${n.dtype}.`);
|
|
13
|
-
if (n.shape[t - 1] > r)
|
|
14
|
-
throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${n.shape[t - 1]} vs. ${r}`);
|
|
15
|
-
if (m(e.shape) === 0)
|
|
16
|
-
throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);
|
|
17
|
-
const s = n.shape, o = s[s.length - 1];
|
|
18
|
-
let a = 1;
|
|
19
|
-
for (let i = 0; i < s.length - 1; ++i)
|
|
20
|
-
a *= s[i];
|
|
21
|
-
const u = e.shape, c = s.slice();
|
|
22
|
-
c.pop();
|
|
23
|
-
let h = 1;
|
|
24
|
-
for (let i = o; i < r; ++i)
|
|
25
|
-
h *= u[i], c.push(u[i]);
|
|
26
|
-
const d = [
|
|
27
|
-
...R(e.shape).map((i) => i / h),
|
|
28
|
-
1
|
|
29
|
-
].slice(0, o);
|
|
30
|
-
return [c, a, h, d];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @license
|
|
34
|
-
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
35
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
36
|
-
* you may not use this file except in compliance with the License.
|
|
37
|
-
* You may obtain a copy of the License at
|
|
38
|
-
*
|
|
39
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
-
*
|
|
41
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
43
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
-
* See the License for the specific language governing permissions and
|
|
45
|
-
* limitations under the License.
|
|
46
|
-
* =============================================================================
|
|
47
|
-
*/
|
|
48
|
-
function ue(e, n) {
|
|
49
|
-
const r = e[0].length;
|
|
50
|
-
e.forEach((s, o) => {
|
|
51
|
-
g(s.length === r, () => `Error in concat${r}D: rank of tensors[${o}] must be the same as the rank of the rest (${r})`);
|
|
52
|
-
}), g(n >= 0 && n < r, () => `Error in concat${r}D: axis must be between 0 and ${r - 1}.`);
|
|
53
|
-
const t = e[0];
|
|
54
|
-
e.forEach((s, o) => {
|
|
55
|
-
for (let a = 0; a < r; a++)
|
|
56
|
-
g(a === n || s[a] === t[a], () => `Error in concat${r}D: Shape of tensors[${o}] (${s}) does not match the shape of the rest (${t}) along the non-concatenated axis ${o}.`);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function le(e, n) {
|
|
60
|
-
const r = e[0].slice();
|
|
61
|
-
for (let t = 1; t < e.length; t++)
|
|
62
|
-
r[n] += e[t][n];
|
|
63
|
-
return r;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @license
|
|
67
|
-
* Copyright 2022 Google LLC. All Rights Reserved.
|
|
68
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
69
|
-
* you may not use this file except in compliance with the License.
|
|
70
|
-
* You may obtain a copy of the License at
|
|
71
|
-
*
|
|
72
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
73
|
-
*
|
|
74
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
75
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
76
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
77
|
-
* See the License for the specific language governing permissions and
|
|
78
|
-
* limitations under the License.
|
|
79
|
-
* =============================================================================
|
|
80
|
-
*/
|
|
81
|
-
var p;
|
|
82
|
-
(function(e) {
|
|
83
|
-
e[e.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", e[e.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", e[e.ROW_LENGTHS = 2] = "ROW_LENGTHS", e[e.ROW_SPLITS = 3] = "ROW_SPLITS", e[e.ROW_LIMITS = 4] = "ROW_LIMITS", e[e.ROW_STARTS = 5] = "ROW_STARTS";
|
|
84
|
-
})(p || (p = {}));
|
|
85
|
-
function ce(e, n, r) {
|
|
86
|
-
let t = new Array();
|
|
87
|
-
if (r == null && n == null)
|
|
88
|
-
return t;
|
|
89
|
-
if (n == null)
|
|
90
|
-
for (; t.length < e + r.length; )
|
|
91
|
-
t.push(-1);
|
|
92
|
-
else
|
|
93
|
-
t = n.slice();
|
|
94
|
-
if (r == null)
|
|
95
|
-
return t;
|
|
96
|
-
if (e + r.length !== t.length)
|
|
97
|
-
throw new Error(`rt input.shape and shape=${n} are incompatible: rt input.rank = ${e + r.length}, but shape.rank = ${t.length}`);
|
|
98
|
-
for (let s = 1; s < r.length; ++s) {
|
|
99
|
-
const o = r[s], a = t[t.length - r.length + s], u = t[a];
|
|
100
|
-
if (o >= 0)
|
|
101
|
-
if (u >= 0) {
|
|
102
|
-
if (u !== o)
|
|
103
|
-
throw new Error(`rt input.shape and shape=${n} are incompatible: rt input.shape[${s + e}] = ${o} but shape[${s + e}] = ${u}`);
|
|
104
|
-
} else
|
|
105
|
-
t[a] = o;
|
|
106
|
-
}
|
|
107
|
-
return t;
|
|
108
|
-
}
|
|
109
|
-
function he(e) {
|
|
110
|
-
const n = {
|
|
111
|
-
FIRST_DIM_SIZE: p.FIRST_DIM_SIZE,
|
|
112
|
-
VALUE_ROWIDS: p.VALUE_ROWIDS,
|
|
113
|
-
ROW_LENGTHS: p.ROW_LENGTHS,
|
|
114
|
-
ROW_SPLITS: p.ROW_SPLITS,
|
|
115
|
-
ROW_LIMITS: p.ROW_LIMITS,
|
|
116
|
-
ROW_STARTS: p.ROW_STARTS
|
|
117
|
-
}, r = [];
|
|
118
|
-
for (const t of e)
|
|
119
|
-
if (t in n)
|
|
120
|
-
r.push(n[t]);
|
|
121
|
-
else
|
|
122
|
-
break;
|
|
123
|
-
return r;
|
|
124
|
-
}
|
|
125
|
-
function fe(e) {
|
|
126
|
-
return e.length === 0 ? 0 : e[0] === p.FIRST_DIM_SIZE ? e.length - 1 : e.length;
|
|
127
|
-
}
|
|
128
|
-
function pe(e, n) {
|
|
129
|
-
if (e == null || n == null)
|
|
130
|
-
return;
|
|
131
|
-
const r = e.length, t = n.length;
|
|
132
|
-
if (r >= t)
|
|
133
|
-
throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${n}, are incompatible: defaultValue.rank = ${r} must be less than ragged tensor input flatValues.rank = ${t})`);
|
|
134
|
-
for (let s = 0; s < Math.min(r, t - 1); ++s) {
|
|
135
|
-
const o = e[s], a = n[s + 1];
|
|
136
|
-
if (o >= 0 && a >= 0 && o !== 1 && o !== a)
|
|
137
|
-
throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${n} are incompatible: defaultValue.shape[${s - e.length}] = ${o} but ragged tensor input.flatValues.shape[${s - e.length}] = ${a}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* @license
|
|
142
|
-
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
143
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
144
|
-
* you may not use this file except in compliance with the License.
|
|
145
|
-
* You may obtain a copy of the License at
|
|
146
|
-
*
|
|
147
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
148
|
-
*
|
|
149
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
150
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
151
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
152
|
-
* See the License for the specific language governing permissions and
|
|
153
|
-
* limitations under the License.
|
|
154
|
-
* =============================================================================
|
|
155
|
-
*/
|
|
156
|
-
const I = 30;
|
|
157
|
-
function ge(e) {
|
|
158
|
-
return e <= I ? e : $(e, Math.floor(Math.sqrt(e)));
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* @license
|
|
162
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
163
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
164
|
-
* you may not use this file except in compliance with the License.
|
|
165
|
-
* You may obtain a copy of the License at
|
|
166
|
-
*
|
|
167
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
168
|
-
*
|
|
169
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
170
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
171
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
172
|
-
* See the License for the specific language governing permissions and
|
|
173
|
-
* limitations under the License.
|
|
174
|
-
* =============================================================================
|
|
175
|
-
*/
|
|
176
|
-
function de(e, n, r) {
|
|
177
|
-
const t = r * (typeof e == "number" ? e : e[0]), s = n * (typeof e == "number" ? e : e[1]);
|
|
178
|
-
return [t, s];
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* @license
|
|
182
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
183
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
184
|
-
* you may not use this file except in compliance with the License.
|
|
185
|
-
* You may obtain a copy of the License at
|
|
186
|
-
*
|
|
187
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
188
|
-
*
|
|
189
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
190
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
191
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
192
|
-
* See the License for the specific language governing permissions and
|
|
193
|
-
* limitations under the License.
|
|
194
|
-
* =============================================================================
|
|
195
|
-
*/
|
|
196
|
-
function me(e, n, r, t = !0) {
|
|
197
|
-
let s = [];
|
|
198
|
-
if (t)
|
|
199
|
-
s = s.concat(n.slice(0)), s.push(e[0] / r), s = s.concat(e.slice(1));
|
|
200
|
-
else {
|
|
201
|
-
s = s.concat(e[0]);
|
|
202
|
-
const o = n.length;
|
|
203
|
-
for (let a = 0; a < o; ++a)
|
|
204
|
-
s = s.concat([e[a + 1] / n[a], n[a]]);
|
|
205
|
-
s = s.concat(e.slice(o + 1));
|
|
206
|
-
}
|
|
207
|
-
return s;
|
|
208
|
-
}
|
|
209
|
-
function Ee(e, n, r = !0) {
|
|
210
|
-
const t = [];
|
|
211
|
-
if (r) {
|
|
212
|
-
t.push(n);
|
|
213
|
-
for (let s = n + 1; s < e; ++s)
|
|
214
|
-
s <= 2 * n ? (t.push(s), t.push(s - (n + 1))) : t.push(s);
|
|
215
|
-
} else {
|
|
216
|
-
const s = [], o = [];
|
|
217
|
-
for (let a = 1; a < e; ++a)
|
|
218
|
-
a >= n * 2 + 1 || a % 2 === 1 ? o.push(a) : s.push(a);
|
|
219
|
-
t.push(...s), t.push(0), t.push(...o);
|
|
220
|
-
}
|
|
221
|
-
return t;
|
|
222
|
-
}
|
|
223
|
-
function $e(e, n, r, t = !0) {
|
|
224
|
-
const s = [];
|
|
225
|
-
t ? s.push(e[0] / r) : s.push(e[0] * r);
|
|
226
|
-
for (let o = 1; o < e.length; ++o)
|
|
227
|
-
o <= n.length ? t ? s.push(n[o - 1] * e[o]) : s.push(e[o] / n[o - 1]) : s.push(e[o]);
|
|
228
|
-
return s;
|
|
229
|
-
}
|
|
230
|
-
function Ie(e, n) {
|
|
231
|
-
const r = [0];
|
|
232
|
-
for (let t = 0; t < n; ++t)
|
|
233
|
-
r.push(e[t][0]);
|
|
234
|
-
return r;
|
|
235
|
-
}
|
|
236
|
-
function Se(e, n, r) {
|
|
237
|
-
const t = e.slice(0, 1);
|
|
238
|
-
for (let s = 0; s < r; ++s)
|
|
239
|
-
t.push(e[s + 1] - n[s][0] - n[s][1]);
|
|
240
|
-
return t;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* @license
|
|
244
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
245
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
246
|
-
* you may not use this file except in compliance with the License.
|
|
247
|
-
* You may obtain a copy of the License at
|
|
248
|
-
*
|
|
249
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
250
|
-
*
|
|
251
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
252
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
253
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
254
|
-
* See the License for the specific language governing permissions and
|
|
255
|
-
* limitations under the License.
|
|
256
|
-
* =============================================================================
|
|
257
|
-
*/
|
|
258
|
-
const we = 0.3275911, Ae = 0.254829592, Re = -0.284496736, Oe = 1.421413741, _e = -1.453152027, Me = 1.061405429;
|
|
259
|
-
/**
|
|
260
|
-
* @license
|
|
261
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
262
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
263
|
-
* you may not use this file except in compliance with the License.
|
|
264
|
-
* You may obtain a copy of the License at
|
|
265
|
-
*
|
|
266
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
267
|
-
*
|
|
268
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
269
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
270
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
271
|
-
* See the License for the specific language governing permissions and
|
|
272
|
-
* limitations under the License.
|
|
273
|
-
* =============================================================================
|
|
274
|
-
*/
|
|
275
|
-
function ye(e, n) {
|
|
276
|
-
if (e.length !== n.length)
|
|
277
|
-
throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${n.length}.`);
|
|
278
|
-
const r = new Float32Array(e.length * 2);
|
|
279
|
-
for (let t = 0; t < r.length; t += 2)
|
|
280
|
-
r[t] = e[t / 2], r[t + 1] = n[t / 2];
|
|
281
|
-
return r;
|
|
282
|
-
}
|
|
283
|
-
function De(e) {
|
|
284
|
-
const n = new Float32Array(e.length / 2), r = new Float32Array(e.length / 2);
|
|
285
|
-
for (let t = 0; t < e.length; t += 2)
|
|
286
|
-
n[t / 2] = e[t], r[t / 2] = e[t + 1];
|
|
287
|
-
return { real: n, imag: r };
|
|
288
|
-
}
|
|
289
|
-
function Te(e) {
|
|
290
|
-
const n = Math.ceil(e.length / 4), r = new Float32Array(n), t = new Float32Array(n);
|
|
291
|
-
for (let s = 0; s < e.length; s += 4)
|
|
292
|
-
r[Math.floor(s / 4)] = e[s], t[Math.floor(s / 4)] = e[s + 1];
|
|
293
|
-
return { real: r, imag: t };
|
|
294
|
-
}
|
|
295
|
-
function be(e) {
|
|
296
|
-
const n = Math.floor(e.length / 4), r = new Float32Array(n), t = new Float32Array(n);
|
|
297
|
-
for (let s = 2; s < e.length; s += 4)
|
|
298
|
-
r[Math.floor(s / 4)] = e[s], t[Math.floor(s / 4)] = e[s + 1];
|
|
299
|
-
return { real: r, imag: t };
|
|
300
|
-
}
|
|
301
|
-
function Fe(e, n) {
|
|
302
|
-
const r = e[n * 2], t = e[n * 2 + 1];
|
|
303
|
-
return { real: r, imag: t };
|
|
304
|
-
}
|
|
305
|
-
function Le(e, n, r, t) {
|
|
306
|
-
e[t * 2] = n, e[t * 2 + 1] = r;
|
|
307
|
-
}
|
|
308
|
-
function We(e, n) {
|
|
309
|
-
const r = new Float32Array(e / 2), t = new Float32Array(e / 2);
|
|
310
|
-
for (let s = 0; s < Math.ceil(e / 2); s++) {
|
|
311
|
-
const o = (n ? 2 : -2) * Math.PI * (s / e);
|
|
312
|
-
r[s] = Math.cos(o), t[s] = Math.sin(o);
|
|
313
|
-
}
|
|
314
|
-
return { real: r, imag: t };
|
|
315
|
-
}
|
|
316
|
-
function ve(e, n, r) {
|
|
317
|
-
const t = (r ? 2 : -2) * Math.PI * (e / n), s = Math.cos(t), o = Math.sin(t);
|
|
318
|
-
return { real: s, imag: o };
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* @license
|
|
322
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
323
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
324
|
-
* you may not use this file except in compliance with the License.
|
|
325
|
-
* You may obtain a copy of the License at
|
|
326
|
-
*
|
|
327
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
328
|
-
*
|
|
329
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
330
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
331
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
332
|
-
* See the License for the specific language governing permissions and
|
|
333
|
-
* limitations under the License.
|
|
334
|
-
* =============================================================================
|
|
335
|
-
*/
|
|
336
|
-
const E = "->", Ne = /->/g, S = ",", w = "...";
|
|
337
|
-
function xe(e, n) {
|
|
338
|
-
e = e.replace(/\s/g, "");
|
|
339
|
-
const r = (e.length - e.replace(Ne, "").length) / E.length;
|
|
340
|
-
if (r < 1)
|
|
341
|
-
throw new Error("Equations without an arrow are not supported.");
|
|
342
|
-
if (r > 1)
|
|
343
|
-
throw new Error(`Equation must contain exactly one arrow ("${E}").`);
|
|
344
|
-
const [t, s] = e.split(E);
|
|
345
|
-
g(t.indexOf(w) === -1, () => `The ellipsis notation ("${w}") is not supported yet.`);
|
|
346
|
-
const o = t.split(S), a = o.length;
|
|
347
|
-
if (n !== a)
|
|
348
|
-
throw new Error(`Expected ${a} input tensors, received ${n}`);
|
|
349
|
-
if (a > 2)
|
|
350
|
-
throw new Error("Support for more than 2 input tensors is not implemented yet.");
|
|
351
|
-
const u = [];
|
|
352
|
-
for (let l = 0; l < s.length; ++l) {
|
|
353
|
-
const f = s[l];
|
|
354
|
-
if (!o.some((A) => A.indexOf(f) !== -1))
|
|
355
|
-
throw new Error(`Output subscripts contain the label ${f} not present in the input subscripts.`);
|
|
356
|
-
u.indexOf(f) === -1 && u.push(f);
|
|
357
|
-
}
|
|
358
|
-
for (let l = 0; l < t.length; ++l) {
|
|
359
|
-
const f = t[l];
|
|
360
|
-
u.indexOf(f) === -1 && f !== S && u.push(f);
|
|
361
|
-
}
|
|
362
|
-
const c = new Array(o.length);
|
|
363
|
-
for (let l = 0; l < a; ++l) {
|
|
364
|
-
if (new Set(o[l].split("")).size !== o[l].length)
|
|
365
|
-
throw new Error(`Found duplicate axes in input component ${o[l]}. Support for duplicate axes in input is not implemented yet.`);
|
|
366
|
-
c[l] = [];
|
|
367
|
-
for (let f = 0; f < o[l].length; ++f)
|
|
368
|
-
c[l].push(u.indexOf(o[l][f]));
|
|
369
|
-
}
|
|
370
|
-
const h = u.length, d = s.length, i = [];
|
|
371
|
-
for (let l = d; l < h; ++l)
|
|
372
|
-
i.push(l);
|
|
373
|
-
return { allDims: u, summedDims: i, idDims: c };
|
|
374
|
-
}
|
|
375
|
-
function Pe(e, n) {
|
|
376
|
-
let r = new Array(e);
|
|
377
|
-
r.fill(-1);
|
|
378
|
-
for (let s = 0; s < n.length; ++s)
|
|
379
|
-
r[n[s]] = s;
|
|
380
|
-
const t = [];
|
|
381
|
-
for (let s = 0; s < e; ++s)
|
|
382
|
-
r[s] === -1 && t.push(s);
|
|
383
|
-
return r = r.filter((s) => s !== -1), { permutationIndices: r, expandDims: t };
|
|
384
|
-
}
|
|
385
|
-
function Ce(e, n, r) {
|
|
386
|
-
const t = new Array(e);
|
|
387
|
-
for (let s = 0; s < r.length; ++s) {
|
|
388
|
-
const o = r[s].shape;
|
|
389
|
-
for (let a = 0; a < n[s].length; ++a)
|
|
390
|
-
t[n[s][a]] === void 0 ? t[n[s][a]] = o[a] : g(t[n[s][a]] === o[a], () => `Expected dimension ${t[n[s][a]]} at axis ${a} of input shaped ${JSON.stringify(o)}, but got dimension ${o[a]}`);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
function ze(e, n) {
|
|
394
|
-
const r = e, t = [];
|
|
395
|
-
let s = 0;
|
|
396
|
-
e.length === 0 && r.push(-1), s = e.length + 1;
|
|
397
|
-
for (let a = 0; a < s; ++a)
|
|
398
|
-
t.push([]);
|
|
399
|
-
const o = [];
|
|
400
|
-
for (let a = 0; a < r.length; ++a) {
|
|
401
|
-
const u = r[a], c = Be(n, u);
|
|
402
|
-
for (const h of c)
|
|
403
|
-
o.indexOf(h) === -1 && (t[a].push(h), o.push(h));
|
|
404
|
-
}
|
|
405
|
-
return { path: r, steps: t };
|
|
406
|
-
}
|
|
407
|
-
function Ue(e) {
|
|
408
|
-
return e.every((n, r) => n === r);
|
|
409
|
-
}
|
|
410
|
-
function Be(e, n) {
|
|
411
|
-
const r = [];
|
|
412
|
-
for (let t = 0; t < e.length; ++t)
|
|
413
|
-
(e[t].length === 0 || e[t].indexOf(n) !== -1 || n === -1) && r.push(t);
|
|
414
|
-
return r;
|
|
415
|
-
}
|
|
416
|
-
function Ve(e, n, r = 0) {
|
|
417
|
-
let t = [];
|
|
418
|
-
if (typeof n == "number")
|
|
419
|
-
g(e.shape[r] % n === 0, () => "Number of splits must evenly divide the axis."), t = new Array(n).fill(e.shape[r] / n);
|
|
420
|
-
else {
|
|
421
|
-
const s = n.reduce((a, u) => (u === -1 && (a += 1), a), 0);
|
|
422
|
-
g(s <= 1, () => "There should be only one negative value in split array.");
|
|
423
|
-
const o = n.indexOf(-1);
|
|
424
|
-
if (o !== -1) {
|
|
425
|
-
const a = n.reduce((u, c) => c > 0 ? u + c : u);
|
|
426
|
-
n[o] = e.shape[r] - a;
|
|
427
|
-
}
|
|
428
|
-
g(e.shape[r] === n.reduce((a, u) => a + u), () => "The sum of sizes must match the size of the axis dimension."), t = n;
|
|
429
|
-
}
|
|
430
|
-
return t;
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* @license
|
|
434
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
435
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
436
|
-
* you may not use this file except in compliance with the License.
|
|
437
|
-
* You may obtain a copy of the License at
|
|
438
|
-
*
|
|
439
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
440
|
-
*
|
|
441
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
442
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
443
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
444
|
-
* See the License for the specific language governing permissions and
|
|
445
|
-
* limitations under the License.
|
|
446
|
-
* =============================================================================
|
|
447
|
-
*/
|
|
448
|
-
function je(e) {
|
|
449
|
-
return `Received SparseTensor with denseShape[0] = 0 but
|
|
450
|
-
indices.shape[0] = ${e}`;
|
|
451
|
-
}
|
|
452
|
-
function Ge(e, n) {
|
|
453
|
-
return `indices(${e}, 0) is invalid: ${n} < 0`;
|
|
454
|
-
}
|
|
455
|
-
function He(e, n, r) {
|
|
456
|
-
return `indices(${e}, 0) is invalid: ${n} >= ${r}`;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* @license
|
|
460
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
461
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
462
|
-
* you may not use this file except in compliance with the License.
|
|
463
|
-
* You may obtain a copy of the License at
|
|
464
|
-
*
|
|
465
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
466
|
-
*
|
|
467
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
468
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
469
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
470
|
-
* See the License for the specific language governing permissions and
|
|
471
|
-
* limitations under the License.
|
|
472
|
-
* =============================================================================
|
|
473
|
-
*/
|
|
474
|
-
function ke(e, n) {
|
|
475
|
-
return `only one output dimension may be -1, not both ${e} and ${n}`;
|
|
476
|
-
}
|
|
477
|
-
function qe(e, n) {
|
|
478
|
-
return `size ${e} must be non-negative, not ${n}`;
|
|
479
|
-
}
|
|
480
|
-
function Ze() {
|
|
481
|
-
return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
|
|
482
|
-
}
|
|
483
|
-
function Xe(e, n) {
|
|
484
|
-
const r = m(e), t = m(n);
|
|
485
|
-
return `Input to reshape is a SparseTensor with ${r}
|
|
486
|
-
dense values, but the requested shape requires a multiple of ${t}. inputShape=${e} outputShape= ${n}`;
|
|
487
|
-
}
|
|
488
|
-
function Je(e, n) {
|
|
489
|
-
const r = m(e), t = m(n);
|
|
490
|
-
return `Input to reshape is a tensor with ${r} dense values, but the requested shape has ${t}. inputShape=${e} outputShape=${n}`;
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* @license
|
|
494
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
495
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
496
|
-
* you may not use this file except in compliance with the License.
|
|
497
|
-
* You may obtain a copy of the License at
|
|
498
|
-
*
|
|
499
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
500
|
-
*
|
|
501
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
502
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
503
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
504
|
-
* See the License for the specific language governing permissions and
|
|
505
|
-
* limitations under the License.
|
|
506
|
-
* =============================================================================
|
|
507
|
-
*/
|
|
508
|
-
function Ke() {
|
|
509
|
-
return "segment ids must be >= 0";
|
|
510
|
-
}
|
|
511
|
-
function Qe() {
|
|
512
|
-
return "segment ids are not increasing";
|
|
513
|
-
}
|
|
514
|
-
function Ye(e, n) {
|
|
515
|
-
return `Segment id ${e} out of range [0, ${n}), possibly because segmentIds input is not sorted.`;
|
|
516
|
-
}
|
|
517
|
-
function et(e, n, r) {
|
|
518
|
-
return `Bad: indices[${e}] == ${n} out of range [0, ${r})`;
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* @license
|
|
522
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
523
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
524
|
-
* you may not use this file except in compliance with the License.
|
|
525
|
-
* You may obtain a copy of the License at
|
|
526
|
-
*
|
|
527
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
528
|
-
*
|
|
529
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
530
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
531
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
532
|
-
* See the License for the specific language governing permissions and
|
|
533
|
-
* limitations under the License.
|
|
534
|
-
* =============================================================================
|
|
535
|
-
*/
|
|
536
|
-
function tt(e, n) {
|
|
537
|
-
let r = !1, t;
|
|
538
|
-
for (e <= I ? (t = e, r = !0) : t = $(e, Math.floor(Math.sqrt(e))); !r; )
|
|
539
|
-
t > n || t === e ? r = !0 : t = $(e, t + 1);
|
|
540
|
-
return t;
|
|
541
|
-
}
|
|
542
|
-
function nt(e, n, r) {
|
|
543
|
-
const t = [], s = e.length;
|
|
544
|
-
for (let o = 0; o < s; o++)
|
|
545
|
-
o !== n ? t.push(e[o]) : t.push(r);
|
|
546
|
-
return t;
|
|
547
|
-
}
|
|
548
|
-
function st(e, n, r, t) {
|
|
549
|
-
const s = n.shape.length, o = e.shape.length;
|
|
550
|
-
if (t !== 0 && (t < -s || t > s))
|
|
551
|
-
throw new Error(`Expect batchDims in the range of [-${s}, ${s}], but got ${t}`);
|
|
552
|
-
if (t < 0 && (t += s), t > o)
|
|
553
|
-
throw new Error(`batchDims (${t}) must be less than rank(x) (
|
|
554
|
-
${o}).`);
|
|
555
|
-
if (r < t)
|
|
556
|
-
throw new Error(`batchDims (${t}) must be less than or equal to axis (${r}).`);
|
|
557
|
-
for (let i = 0; i < t; ++i)
|
|
558
|
-
if (e.shape[i] !== n.shape[i])
|
|
559
|
-
throw new Error(`x.shape[${i}]: ${e.shape[i]} should be equal to indices.shape[${i}]: ${n.shape[i]}.`);
|
|
560
|
-
const a = e.shape[r], u = [];
|
|
561
|
-
let c = 1, h = 1, d = 1;
|
|
562
|
-
for (let i = 0; i < t; ++i)
|
|
563
|
-
u.push(e.shape[i]), c *= e.shape[i];
|
|
564
|
-
for (let i = t; i < r; i++)
|
|
565
|
-
u.push(e.shape[i]), h *= e.shape[i];
|
|
566
|
-
for (let i = t; i < s; i++)
|
|
567
|
-
u.push(n.shape[i]);
|
|
568
|
-
for (let i = r + 1; i < o; i++)
|
|
569
|
-
u.push(e.shape[i]), d *= e.shape[i];
|
|
570
|
-
return { batchSize: c, sliceSize: d, outerSize: h, dimSize: a, outputShape: u };
|
|
571
|
-
}
|
|
572
|
-
const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
573
|
-
__proto__: null,
|
|
574
|
-
collectGatherOpShapeInfo: st,
|
|
575
|
-
computeOutShape: nt,
|
|
576
|
-
segOpComputeOptimalWindowSize: tt
|
|
577
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
578
|
-
/**
|
|
579
|
-
* @license
|
|
580
|
-
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
581
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
582
|
-
* you may not use this file except in compliance with the License.
|
|
583
|
-
* You may obtain a copy of the License at
|
|
584
|
-
*
|
|
585
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
586
|
-
*
|
|
587
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
588
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
589
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
590
|
-
* See the License for the specific language governing permissions and
|
|
591
|
-
* limitations under the License.
|
|
592
|
-
* =============================================================================
|
|
593
|
-
*/
|
|
594
|
-
function ot(e) {
|
|
595
|
-
try {
|
|
596
|
-
return e.map((n) => O(n));
|
|
597
|
-
} catch (n) {
|
|
598
|
-
throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${n}`);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
function at(e) {
|
|
602
|
-
return e.map((n) => _(n));
|
|
603
|
-
}
|
|
604
|
-
const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
605
|
-
__proto__: null,
|
|
606
|
-
ERF_A1: Ae,
|
|
607
|
-
ERF_A2: Re,
|
|
608
|
-
ERF_A3: Oe,
|
|
609
|
-
ERF_A4: _e,
|
|
610
|
-
ERF_A5: Me,
|
|
611
|
-
ERF_P: we,
|
|
612
|
-
PARALLELIZE_THRESHOLD: I,
|
|
613
|
-
get RowPartitionType() {
|
|
614
|
-
return p;
|
|
615
|
-
},
|
|
616
|
-
SELU_SCALE: U,
|
|
617
|
-
SELU_SCALEALPHA: B,
|
|
618
|
-
applyActivation: V,
|
|
619
|
-
assertAndGetBroadcastShape: M,
|
|
620
|
-
assertAxesAreInnerMostDims: L,
|
|
621
|
-
assertParamsConsistent: ue,
|
|
622
|
-
assignToTypedArray: Le,
|
|
623
|
-
axesAreInnerMostDims: W,
|
|
624
|
-
calculateShapes: re,
|
|
625
|
-
checkEinsumDimSizes: Ce,
|
|
626
|
-
checkPadOnDimRoundingMode: j,
|
|
627
|
-
combineLocations: v,
|
|
628
|
-
combineRaggedTensorToTensorShapes: ce,
|
|
629
|
-
complexWithEvenIndex: Te,
|
|
630
|
-
complexWithOddIndex: be,
|
|
631
|
-
computeConv2DInfo: G,
|
|
632
|
-
computeConv3DInfo: H,
|
|
633
|
-
computeDefaultPad: k,
|
|
634
|
-
computeDilation2DInfo: q,
|
|
635
|
-
computeOptimalWindowSize: ge,
|
|
636
|
-
computeOutAndReduceShapes: N,
|
|
637
|
-
computeOutShape: le,
|
|
638
|
-
computePool2DInfo: Z,
|
|
639
|
-
computePool3DInfo: X,
|
|
640
|
-
convertConv2DDataFormat: J,
|
|
641
|
-
decodeEinsumEquation: xe,
|
|
642
|
-
eitherStridesOrDilationsAreOne: K,
|
|
643
|
-
expandShapeToKeepDim: x,
|
|
644
|
-
exponent: ve,
|
|
645
|
-
exponents: We,
|
|
646
|
-
fromStringArrayToUint8: at,
|
|
647
|
-
fromUint8ToStringArray: ot,
|
|
648
|
-
getAxesPermutation: P,
|
|
649
|
-
getBroadcastDims: y,
|
|
650
|
-
getComplexWithIndex: Fe,
|
|
651
|
-
getEinsumComputePath: ze,
|
|
652
|
-
getEinsumPermutation: Pe,
|
|
653
|
-
getFusedBiasGradient: Q,
|
|
654
|
-
getFusedDyActivation: Y,
|
|
655
|
-
getImageCenter: de,
|
|
656
|
-
getInnerMostAxes: C,
|
|
657
|
-
getPermuted: Ee,
|
|
658
|
-
getRaggedRank: fe,
|
|
659
|
-
getReductionAxes: D,
|
|
660
|
-
getReshaped: me,
|
|
661
|
-
getReshapedPermuted: $e,
|
|
662
|
-
getRowPartitionTypesHelper: he,
|
|
663
|
-
getSliceBeginCoords: Ie,
|
|
664
|
-
getSliceSize: Se,
|
|
665
|
-
getSparseFillEmptyRowsIndicesDenseShapeMismatch: je,
|
|
666
|
-
getSparseFillEmptyRowsNegativeIndexErrorMessage: Ge,
|
|
667
|
-
getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: He,
|
|
668
|
-
getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: Ze,
|
|
669
|
-
getSparseReshapeInputOutputMismatchErrorMessage: Je,
|
|
670
|
-
getSparseReshapeInputOutputMultipleErrorMessage: Xe,
|
|
671
|
-
getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: ke,
|
|
672
|
-
getSparseReshapeNegativeOutputDimErrorMessage: qe,
|
|
673
|
-
getSparseSegmentReductionIndicesOutOfRangeErrorMessage: et,
|
|
674
|
-
getSparseSegmentReductionNegativeSegmentIdsErrorMessage: Ke,
|
|
675
|
-
getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: Qe,
|
|
676
|
-
getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: Ye,
|
|
677
|
-
getUndoAxesPermutation: z,
|
|
678
|
-
isIdentityPermutation: Ue,
|
|
679
|
-
log: T,
|
|
680
|
-
mergeRealAndImagArrays: ye,
|
|
681
|
-
prepareAndValidate: ie,
|
|
682
|
-
prepareSplitSize: Ve,
|
|
683
|
-
segment_util: rt,
|
|
684
|
-
shouldFuse: ee,
|
|
685
|
-
slice_util: te,
|
|
686
|
-
splitRealAndImagArrays: De,
|
|
687
|
-
stridesOrDilationsArePositive: ne,
|
|
688
|
-
tupleValuesAreOne: se,
|
|
689
|
-
upcastType: b,
|
|
690
|
-
validateDefaultValueShape: pe,
|
|
691
|
-
validateInput: oe,
|
|
692
|
-
validateUpdateShape: ae,
|
|
693
|
-
warn: F
|
|
694
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
695
|
-
export {
|
|
696
|
-
me as A,
|
|
697
|
-
Ee as B,
|
|
698
|
-
$e as C,
|
|
699
|
-
Ie as D,
|
|
700
|
-
we as E,
|
|
701
|
-
Se as F,
|
|
702
|
-
le as G,
|
|
703
|
-
ue as H,
|
|
704
|
-
xe as I,
|
|
705
|
-
Ce as J,
|
|
706
|
-
ze as K,
|
|
707
|
-
Pe as L,
|
|
708
|
-
Ue as M,
|
|
709
|
-
ie as N,
|
|
710
|
-
st as O,
|
|
711
|
-
de as P,
|
|
712
|
-
Ve as Q,
|
|
713
|
-
p as R,
|
|
714
|
-
nt as S,
|
|
715
|
-
Fe as T,
|
|
716
|
-
De as U,
|
|
717
|
-
Te as V,
|
|
718
|
-
be as W,
|
|
719
|
-
We as X,
|
|
720
|
-
Le as Y,
|
|
721
|
-
ve as Z,
|
|
722
|
-
tt as _,
|
|
723
|
-
fe as a,
|
|
724
|
-
ht as b,
|
|
725
|
-
ge as c,
|
|
726
|
-
ce as d,
|
|
727
|
-
at as e,
|
|
728
|
-
ot as f,
|
|
729
|
-
he as g,
|
|
730
|
-
je as h,
|
|
731
|
-
Ge as i,
|
|
732
|
-
He as j,
|
|
733
|
-
ke as k,
|
|
734
|
-
qe as l,
|
|
735
|
-
ye as m,
|
|
736
|
-
Ze as n,
|
|
737
|
-
Xe as o,
|
|
738
|
-
Je as p,
|
|
739
|
-
Ke as q,
|
|
740
|
-
Qe as r,
|
|
741
|
-
Ye as s,
|
|
742
|
-
et as t,
|
|
743
|
-
Ae as u,
|
|
744
|
-
pe as v,
|
|
745
|
-
Re as w,
|
|
746
|
-
Oe as x,
|
|
747
|
-
_e as y,
|
|
748
|
-
Me as z
|
|
749
|
-
};
|