@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
package/dist/shared-DmRsFyaJ.js
DELETED
|
@@ -1,3134 +0,0 @@
|
|
|
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-BzFyqcy-.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-CJIiDoV1.js";
|
|
3
|
-
import { g as pn, a as wn, e as In, c as bn } from "./axis_util-TbGYJ208.js";
|
|
4
|
-
import { b as xn } from "./broadcast_to-DzlNweb8.js";
|
|
5
|
-
import { r as En } from "./reshape-CnIwVG1c.js";
|
|
6
|
-
import { p as Fn, q as yn, r as kn, u as Nn } from "./selu_util-OtRzVwW5.js";
|
|
7
|
-
import { g as vn } from "./_commonjsHelpers-ByX85dGu.js";
|
|
8
|
-
function Sn(e, t) {
|
|
9
|
-
for (var n = 0; n < t.length; n++) {
|
|
10
|
-
const s = t[n];
|
|
11
|
-
if (typeof s != "string" && !Array.isArray(s)) {
|
|
12
|
-
for (const o in s)
|
|
13
|
-
if (o !== "default" && !(o in e)) {
|
|
14
|
-
const a = Object.getOwnPropertyDescriptor(s, o);
|
|
15
|
-
a && Object.defineProperty(e, o, a.get ? a : {
|
|
16
|
-
enumerable: !0,
|
|
17
|
-
get: () => s[o]
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
|
|
23
|
-
}
|
|
24
|
-
var wt, vt;
|
|
25
|
-
function Tn() {
|
|
26
|
-
if (vt) return wt;
|
|
27
|
-
vt = 1, wt = t;
|
|
28
|
-
var e = null;
|
|
29
|
-
try {
|
|
30
|
-
e = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
|
|
31
|
-
0,
|
|
32
|
-
97,
|
|
33
|
-
115,
|
|
34
|
-
109,
|
|
35
|
-
1,
|
|
36
|
-
0,
|
|
37
|
-
0,
|
|
38
|
-
0,
|
|
39
|
-
1,
|
|
40
|
-
13,
|
|
41
|
-
2,
|
|
42
|
-
96,
|
|
43
|
-
0,
|
|
44
|
-
1,
|
|
45
|
-
127,
|
|
46
|
-
96,
|
|
47
|
-
4,
|
|
48
|
-
127,
|
|
49
|
-
127,
|
|
50
|
-
127,
|
|
51
|
-
127,
|
|
52
|
-
1,
|
|
53
|
-
127,
|
|
54
|
-
3,
|
|
55
|
-
7,
|
|
56
|
-
6,
|
|
57
|
-
0,
|
|
58
|
-
1,
|
|
59
|
-
1,
|
|
60
|
-
1,
|
|
61
|
-
1,
|
|
62
|
-
1,
|
|
63
|
-
6,
|
|
64
|
-
6,
|
|
65
|
-
1,
|
|
66
|
-
127,
|
|
67
|
-
1,
|
|
68
|
-
65,
|
|
69
|
-
0,
|
|
70
|
-
11,
|
|
71
|
-
7,
|
|
72
|
-
50,
|
|
73
|
-
6,
|
|
74
|
-
3,
|
|
75
|
-
109,
|
|
76
|
-
117,
|
|
77
|
-
108,
|
|
78
|
-
0,
|
|
79
|
-
1,
|
|
80
|
-
5,
|
|
81
|
-
100,
|
|
82
|
-
105,
|
|
83
|
-
118,
|
|
84
|
-
95,
|
|
85
|
-
115,
|
|
86
|
-
0,
|
|
87
|
-
2,
|
|
88
|
-
5,
|
|
89
|
-
100,
|
|
90
|
-
105,
|
|
91
|
-
118,
|
|
92
|
-
95,
|
|
93
|
-
117,
|
|
94
|
-
0,
|
|
95
|
-
3,
|
|
96
|
-
5,
|
|
97
|
-
114,
|
|
98
|
-
101,
|
|
99
|
-
109,
|
|
100
|
-
95,
|
|
101
|
-
115,
|
|
102
|
-
0,
|
|
103
|
-
4,
|
|
104
|
-
5,
|
|
105
|
-
114,
|
|
106
|
-
101,
|
|
107
|
-
109,
|
|
108
|
-
95,
|
|
109
|
-
117,
|
|
110
|
-
0,
|
|
111
|
-
5,
|
|
112
|
-
8,
|
|
113
|
-
103,
|
|
114
|
-
101,
|
|
115
|
-
116,
|
|
116
|
-
95,
|
|
117
|
-
104,
|
|
118
|
-
105,
|
|
119
|
-
103,
|
|
120
|
-
104,
|
|
121
|
-
0,
|
|
122
|
-
0,
|
|
123
|
-
10,
|
|
124
|
-
191,
|
|
125
|
-
1,
|
|
126
|
-
6,
|
|
127
|
-
4,
|
|
128
|
-
0,
|
|
129
|
-
35,
|
|
130
|
-
0,
|
|
131
|
-
11,
|
|
132
|
-
36,
|
|
133
|
-
1,
|
|
134
|
-
1,
|
|
135
|
-
126,
|
|
136
|
-
32,
|
|
137
|
-
0,
|
|
138
|
-
173,
|
|
139
|
-
32,
|
|
140
|
-
1,
|
|
141
|
-
173,
|
|
142
|
-
66,
|
|
143
|
-
32,
|
|
144
|
-
134,
|
|
145
|
-
132,
|
|
146
|
-
32,
|
|
147
|
-
2,
|
|
148
|
-
173,
|
|
149
|
-
32,
|
|
150
|
-
3,
|
|
151
|
-
173,
|
|
152
|
-
66,
|
|
153
|
-
32,
|
|
154
|
-
134,
|
|
155
|
-
132,
|
|
156
|
-
126,
|
|
157
|
-
34,
|
|
158
|
-
4,
|
|
159
|
-
66,
|
|
160
|
-
32,
|
|
161
|
-
135,
|
|
162
|
-
167,
|
|
163
|
-
36,
|
|
164
|
-
0,
|
|
165
|
-
32,
|
|
166
|
-
4,
|
|
167
|
-
167,
|
|
168
|
-
11,
|
|
169
|
-
36,
|
|
170
|
-
1,
|
|
171
|
-
1,
|
|
172
|
-
126,
|
|
173
|
-
32,
|
|
174
|
-
0,
|
|
175
|
-
173,
|
|
176
|
-
32,
|
|
177
|
-
1,
|
|
178
|
-
173,
|
|
179
|
-
66,
|
|
180
|
-
32,
|
|
181
|
-
134,
|
|
182
|
-
132,
|
|
183
|
-
32,
|
|
184
|
-
2,
|
|
185
|
-
173,
|
|
186
|
-
32,
|
|
187
|
-
3,
|
|
188
|
-
173,
|
|
189
|
-
66,
|
|
190
|
-
32,
|
|
191
|
-
134,
|
|
192
|
-
132,
|
|
193
|
-
127,
|
|
194
|
-
34,
|
|
195
|
-
4,
|
|
196
|
-
66,
|
|
197
|
-
32,
|
|
198
|
-
135,
|
|
199
|
-
167,
|
|
200
|
-
36,
|
|
201
|
-
0,
|
|
202
|
-
32,
|
|
203
|
-
4,
|
|
204
|
-
167,
|
|
205
|
-
11,
|
|
206
|
-
36,
|
|
207
|
-
1,
|
|
208
|
-
1,
|
|
209
|
-
126,
|
|
210
|
-
32,
|
|
211
|
-
0,
|
|
212
|
-
173,
|
|
213
|
-
32,
|
|
214
|
-
1,
|
|
215
|
-
173,
|
|
216
|
-
66,
|
|
217
|
-
32,
|
|
218
|
-
134,
|
|
219
|
-
132,
|
|
220
|
-
32,
|
|
221
|
-
2,
|
|
222
|
-
173,
|
|
223
|
-
32,
|
|
224
|
-
3,
|
|
225
|
-
173,
|
|
226
|
-
66,
|
|
227
|
-
32,
|
|
228
|
-
134,
|
|
229
|
-
132,
|
|
230
|
-
128,
|
|
231
|
-
34,
|
|
232
|
-
4,
|
|
233
|
-
66,
|
|
234
|
-
32,
|
|
235
|
-
135,
|
|
236
|
-
167,
|
|
237
|
-
36,
|
|
238
|
-
0,
|
|
239
|
-
32,
|
|
240
|
-
4,
|
|
241
|
-
167,
|
|
242
|
-
11,
|
|
243
|
-
36,
|
|
244
|
-
1,
|
|
245
|
-
1,
|
|
246
|
-
126,
|
|
247
|
-
32,
|
|
248
|
-
0,
|
|
249
|
-
173,
|
|
250
|
-
32,
|
|
251
|
-
1,
|
|
252
|
-
173,
|
|
253
|
-
66,
|
|
254
|
-
32,
|
|
255
|
-
134,
|
|
256
|
-
132,
|
|
257
|
-
32,
|
|
258
|
-
2,
|
|
259
|
-
173,
|
|
260
|
-
32,
|
|
261
|
-
3,
|
|
262
|
-
173,
|
|
263
|
-
66,
|
|
264
|
-
32,
|
|
265
|
-
134,
|
|
266
|
-
132,
|
|
267
|
-
129,
|
|
268
|
-
34,
|
|
269
|
-
4,
|
|
270
|
-
66,
|
|
271
|
-
32,
|
|
272
|
-
135,
|
|
273
|
-
167,
|
|
274
|
-
36,
|
|
275
|
-
0,
|
|
276
|
-
32,
|
|
277
|
-
4,
|
|
278
|
-
167,
|
|
279
|
-
11,
|
|
280
|
-
36,
|
|
281
|
-
1,
|
|
282
|
-
1,
|
|
283
|
-
126,
|
|
284
|
-
32,
|
|
285
|
-
0,
|
|
286
|
-
173,
|
|
287
|
-
32,
|
|
288
|
-
1,
|
|
289
|
-
173,
|
|
290
|
-
66,
|
|
291
|
-
32,
|
|
292
|
-
134,
|
|
293
|
-
132,
|
|
294
|
-
32,
|
|
295
|
-
2,
|
|
296
|
-
173,
|
|
297
|
-
32,
|
|
298
|
-
3,
|
|
299
|
-
173,
|
|
300
|
-
66,
|
|
301
|
-
32,
|
|
302
|
-
134,
|
|
303
|
-
132,
|
|
304
|
-
130,
|
|
305
|
-
34,
|
|
306
|
-
4,
|
|
307
|
-
66,
|
|
308
|
-
32,
|
|
309
|
-
135,
|
|
310
|
-
167,
|
|
311
|
-
36,
|
|
312
|
-
0,
|
|
313
|
-
32,
|
|
314
|
-
4,
|
|
315
|
-
167,
|
|
316
|
-
11
|
|
317
|
-
])), {}).exports;
|
|
318
|
-
} catch {
|
|
319
|
-
}
|
|
320
|
-
function t(I, c, E) {
|
|
321
|
-
this.low = I | 0, this.high = c | 0, this.unsigned = !!E;
|
|
322
|
-
}
|
|
323
|
-
t.prototype.__isLong__, Object.defineProperty(t.prototype, "__isLong__", { value: !0 });
|
|
324
|
-
function n(I) {
|
|
325
|
-
return (I && I.__isLong__) === !0;
|
|
326
|
-
}
|
|
327
|
-
t.isLong = n;
|
|
328
|
-
var s = {}, o = {};
|
|
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
|
-
}
|
|
333
|
-
t.fromInt = a;
|
|
334
|
-
function r(I, c) {
|
|
335
|
-
if (isNaN(I))
|
|
336
|
-
return c ? b : g;
|
|
337
|
-
if (c) {
|
|
338
|
-
if (I < 0)
|
|
339
|
-
return b;
|
|
340
|
-
if (I >= m)
|
|
341
|
-
return O;
|
|
342
|
-
} else {
|
|
343
|
-
if (I <= -F)
|
|
344
|
-
return S;
|
|
345
|
-
if (I + 1 >= F)
|
|
346
|
-
return M;
|
|
347
|
-
}
|
|
348
|
-
return I < 0 ? r(-I, c).neg() : i(I % w | 0, I / w | 0, c);
|
|
349
|
-
}
|
|
350
|
-
t.fromNumber = r;
|
|
351
|
-
function i(I, c, E) {
|
|
352
|
-
return new t(I, c, E);
|
|
353
|
-
}
|
|
354
|
-
t.fromBits = i;
|
|
355
|
-
var l = Math.pow;
|
|
356
|
-
function u(I, c, E) {
|
|
357
|
-
if (I.length === 0)
|
|
358
|
-
throw Error("empty string");
|
|
359
|
-
if (I === "NaN" || I === "Infinity" || I === "+Infinity" || I === "-Infinity")
|
|
360
|
-
return g;
|
|
361
|
-
if (typeof c == "number" ? (E = c, c = !1) : c = !!c, E = E || 10, E < 2 || 36 < E)
|
|
362
|
-
throw RangeError("radix");
|
|
363
|
-
var N;
|
|
364
|
-
if ((N = I.indexOf("-")) > 0)
|
|
365
|
-
throw Error("interior hyphen");
|
|
366
|
-
if (N === 0)
|
|
367
|
-
return u(I.substring(1), c, E).neg();
|
|
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
|
-
if (U < 8) {
|
|
371
|
-
var C = r(l(E, U));
|
|
372
|
-
R = R.mul(C).add(r(j));
|
|
373
|
-
} else
|
|
374
|
-
R = R.mul(L), R = R.add(r(j));
|
|
375
|
-
}
|
|
376
|
-
return R.unsigned = c, R;
|
|
377
|
-
}
|
|
378
|
-
t.fromString = u;
|
|
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
|
-
}
|
|
382
|
-
t.fromValue = h;
|
|
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
|
-
var b = a(0, !0);
|
|
386
|
-
t.UZERO = b;
|
|
387
|
-
var k = a(1);
|
|
388
|
-
t.ONE = k;
|
|
389
|
-
var y = a(1, !0);
|
|
390
|
-
t.UONE = y;
|
|
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
|
-
var x = t.prototype;
|
|
400
|
-
return x.toInt = function() {
|
|
401
|
-
return this.unsigned ? this.low >>> 0 : this.low;
|
|
402
|
-
}, x.toNumber = function() {
|
|
403
|
-
return this.unsigned ? (this.high >>> 0) * w + (this.low >>> 0) : this.high * w + (this.low >>> 0);
|
|
404
|
-
}, x.toString = function(c) {
|
|
405
|
-
if (c = c || 10, c < 2 || 36 < c)
|
|
406
|
-
throw RangeError("radix");
|
|
407
|
-
if (this.isZero())
|
|
408
|
-
return "0";
|
|
409
|
-
if (this.isNegative())
|
|
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
|
-
} else
|
|
414
|
-
return "-" + this.neg().toString(c);
|
|
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
|
-
return P + U;
|
|
419
|
-
for (; P.length < 6; )
|
|
420
|
-
P = "0" + P;
|
|
421
|
-
U = "" + P + U;
|
|
422
|
-
}
|
|
423
|
-
}, x.getHighBits = function() {
|
|
424
|
-
return this.high;
|
|
425
|
-
}, x.getHighBitsUnsigned = function() {
|
|
426
|
-
return this.high >>> 0;
|
|
427
|
-
}, x.getLowBits = function() {
|
|
428
|
-
return this.low;
|
|
429
|
-
}, x.getLowBitsUnsigned = function() {
|
|
430
|
-
return this.low >>> 0;
|
|
431
|
-
}, x.getNumBitsAbs = function() {
|
|
432
|
-
if (this.isNegative())
|
|
433
|
-
return this.eq(S) ? 64 : this.neg().getNumBitsAbs();
|
|
434
|
-
for (var c = this.high != 0 ? this.high : this.low, E = 31; E > 0 && (c & 1 << E) == 0; E--)
|
|
435
|
-
;
|
|
436
|
-
return this.high != 0 ? E + 33 : E + 1;
|
|
437
|
-
}, x.isZero = function() {
|
|
438
|
-
return this.high === 0 && this.low === 0;
|
|
439
|
-
}, x.eqz = x.isZero, x.isNegative = function() {
|
|
440
|
-
return !this.unsigned && this.high < 0;
|
|
441
|
-
}, x.isPositive = function() {
|
|
442
|
-
return this.unsigned || this.high >= 0;
|
|
443
|
-
}, x.isOdd = function() {
|
|
444
|
-
return (this.low & 1) === 1;
|
|
445
|
-
}, x.isEven = function() {
|
|
446
|
-
return (this.low & 1) === 0;
|
|
447
|
-
}, x.equals = function(c) {
|
|
448
|
-
return n(c) || (c = h(c)), this.unsigned !== c.unsigned && this.high >>> 31 === 1 && c.high >>> 31 === 1 ? !1 : this.high === c.high && this.low === c.low;
|
|
449
|
-
}, x.eq = x.equals, x.notEquals = function(c) {
|
|
450
|
-
return !this.eq(
|
|
451
|
-
/* validates */
|
|
452
|
-
c
|
|
453
|
-
);
|
|
454
|
-
}, x.neq = x.notEquals, x.ne = x.notEquals, x.lessThan = function(c) {
|
|
455
|
-
return this.comp(
|
|
456
|
-
/* validates */
|
|
457
|
-
c
|
|
458
|
-
) < 0;
|
|
459
|
-
}, x.lt = x.lessThan, x.lessThanOrEqual = function(c) {
|
|
460
|
-
return this.comp(
|
|
461
|
-
/* validates */
|
|
462
|
-
c
|
|
463
|
-
) <= 0;
|
|
464
|
-
}, x.lte = x.lessThanOrEqual, x.le = x.lessThanOrEqual, x.greaterThan = function(c) {
|
|
465
|
-
return this.comp(
|
|
466
|
-
/* validates */
|
|
467
|
-
c
|
|
468
|
-
) > 0;
|
|
469
|
-
}, x.gt = x.greaterThan, x.greaterThanOrEqual = function(c) {
|
|
470
|
-
return this.comp(
|
|
471
|
-
/* validates */
|
|
472
|
-
c
|
|
473
|
-
) >= 0;
|
|
474
|
-
}, x.gte = x.greaterThanOrEqual, x.ge = x.greaterThanOrEqual, x.compare = function(c) {
|
|
475
|
-
if (n(c) || (c = h(c)), this.eq(c))
|
|
476
|
-
return 0;
|
|
477
|
-
var E = this.isNegative(), N = c.isNegative();
|
|
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
|
-
}, x.comp = x.compare, x.negate = function() {
|
|
480
|
-
return !this.unsigned && this.eq(S) ? S : this.not().add(k);
|
|
481
|
-
}, x.neg = x.negate, x.add = function(c) {
|
|
482
|
-
n(c) || (c = h(c));
|
|
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
|
-
}, x.subtract = function(c) {
|
|
486
|
-
return n(c) || (c = h(c)), this.add(c.neg());
|
|
487
|
-
}, x.sub = x.subtract, x.multiply = function(c) {
|
|
488
|
-
if (this.isZero())
|
|
489
|
-
return g;
|
|
490
|
-
if (n(c) || (c = h(c)), e) {
|
|
491
|
-
var E = e.mul(
|
|
492
|
-
this.low,
|
|
493
|
-
this.high,
|
|
494
|
-
c.low,
|
|
495
|
-
c.high
|
|
496
|
-
);
|
|
497
|
-
return i(E, e.get_high(), this.unsigned);
|
|
498
|
-
}
|
|
499
|
-
if (c.isZero())
|
|
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
|
-
if (this.isNegative())
|
|
506
|
-
return c.isNegative() ? this.neg().mul(c.neg()) : this.neg().mul(c).neg();
|
|
507
|
-
if (c.isNegative())
|
|
508
|
-
return this.mul(c.neg()).neg();
|
|
509
|
-
if (this.lt(d) && c.lt(d))
|
|
510
|
-
return r(this.toNumber() * c.toNumber(), this.unsigned);
|
|
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
|
-
}, x.mul = x.multiply, x.divide = function(c) {
|
|
514
|
-
if (n(c) || (c = h(c)), c.isZero())
|
|
515
|
-
throw Error("division by zero");
|
|
516
|
-
if (e) {
|
|
517
|
-
if (!this.unsigned && this.high === -2147483648 && c.low === -1 && c.high === -1)
|
|
518
|
-
return this;
|
|
519
|
-
var E = (this.unsigned ? e.div_u : e.div_s)(
|
|
520
|
-
this.low,
|
|
521
|
-
this.high,
|
|
522
|
-
c.low,
|
|
523
|
-
c.high
|
|
524
|
-
);
|
|
525
|
-
return i(E, e.get_high(), this.unsigned);
|
|
526
|
-
}
|
|
527
|
-
if (this.isZero())
|
|
528
|
-
return this.unsigned ? b : g;
|
|
529
|
-
var N, L, R;
|
|
530
|
-
if (this.unsigned) {
|
|
531
|
-
if (c.unsigned || (c = c.toUnsigned()), c.gt(this))
|
|
532
|
-
return b;
|
|
533
|
-
if (c.gt(this.shru(1)))
|
|
534
|
-
return y;
|
|
535
|
-
R = b;
|
|
536
|
-
} else {
|
|
537
|
-
if (this.eq(S)) {
|
|
538
|
-
if (c.eq(k) || c.eq(v))
|
|
539
|
-
return S;
|
|
540
|
-
if (c.eq(S))
|
|
541
|
-
return k;
|
|
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
|
-
} else if (c.eq(S))
|
|
545
|
-
return this.unsigned ? b : g;
|
|
546
|
-
if (this.isNegative())
|
|
547
|
-
return c.isNegative() ? this.neg().div(c.neg()) : this.neg().div(c).neg();
|
|
548
|
-
if (c.isNegative())
|
|
549
|
-
return this.div(c.neg()).neg();
|
|
550
|
-
R = g;
|
|
551
|
-
}
|
|
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
|
-
}
|
|
558
|
-
return R;
|
|
559
|
-
}, x.div = x.divide, x.modulo = function(c) {
|
|
560
|
-
if (n(c) || (c = h(c)), e) {
|
|
561
|
-
var E = (this.unsigned ? e.rem_u : e.rem_s)(
|
|
562
|
-
this.low,
|
|
563
|
-
this.high,
|
|
564
|
-
c.low,
|
|
565
|
-
c.high
|
|
566
|
-
);
|
|
567
|
-
return i(E, e.get_high(), this.unsigned);
|
|
568
|
-
}
|
|
569
|
-
return this.sub(this.div(c).mul(c));
|
|
570
|
-
}, x.mod = x.modulo, x.rem = x.modulo, x.not = function() {
|
|
571
|
-
return i(~this.low, ~this.high, this.unsigned);
|
|
572
|
-
}, x.and = function(c) {
|
|
573
|
-
return n(c) || (c = h(c)), i(this.low & c.low, this.high & c.high, this.unsigned);
|
|
574
|
-
}, x.or = function(c) {
|
|
575
|
-
return n(c) || (c = h(c)), i(this.low | c.low, this.high | c.high, this.unsigned);
|
|
576
|
-
}, x.xor = function(c) {
|
|
577
|
-
return n(c) || (c = h(c)), i(this.low ^ c.low, this.high ^ c.high, this.unsigned);
|
|
578
|
-
}, x.shiftLeft = function(c) {
|
|
579
|
-
return n(c) && (c = c.toInt()), (c &= 63) === 0 ? this : c < 32 ? i(this.low << c, this.high << c | this.low >>> 32 - c, this.unsigned) : i(0, this.low << c - 32, this.unsigned);
|
|
580
|
-
}, x.shl = x.shiftLeft, x.shiftRight = function(c) {
|
|
581
|
-
return n(c) && (c = c.toInt()), (c &= 63) === 0 ? this : c < 32 ? i(this.low >>> c | this.high << 32 - c, this.high >> c, this.unsigned) : i(this.high >> c - 32, this.high >= 0 ? 0 : -1, this.unsigned);
|
|
582
|
-
}, x.shr = x.shiftRight, x.shiftRightUnsigned = function(c) {
|
|
583
|
-
if (n(c) && (c = c.toInt()), c &= 63, c === 0)
|
|
584
|
-
return this;
|
|
585
|
-
var E = this.high;
|
|
586
|
-
if (c < 32) {
|
|
587
|
-
var N = this.low;
|
|
588
|
-
return i(N >>> c | E << 32 - c, E >>> c, this.unsigned);
|
|
589
|
-
} else return c === 32 ? i(E, 0, this.unsigned) : i(E >>> c - 32, 0, this.unsigned);
|
|
590
|
-
}, x.shru = x.shiftRightUnsigned, x.shr_u = x.shiftRightUnsigned, x.toSigned = function() {
|
|
591
|
-
return this.unsigned ? i(this.low, this.high, !1) : this;
|
|
592
|
-
}, x.toUnsigned = function() {
|
|
593
|
-
return this.unsigned ? this : i(this.low, this.high, !0);
|
|
594
|
-
}, x.toBytes = function(c) {
|
|
595
|
-
return c ? this.toBytesLE() : this.toBytesBE();
|
|
596
|
-
}, x.toBytesLE = function() {
|
|
597
|
-
var c = this.high, E = this.low;
|
|
598
|
-
return [
|
|
599
|
-
E & 255,
|
|
600
|
-
E >>> 8 & 255,
|
|
601
|
-
E >>> 16 & 255,
|
|
602
|
-
E >>> 24,
|
|
603
|
-
c & 255,
|
|
604
|
-
c >>> 8 & 255,
|
|
605
|
-
c >>> 16 & 255,
|
|
606
|
-
c >>> 24
|
|
607
|
-
];
|
|
608
|
-
}, x.toBytesBE = function() {
|
|
609
|
-
var c = this.high, E = this.low;
|
|
610
|
-
return [
|
|
611
|
-
c >>> 24,
|
|
612
|
-
c >>> 16 & 255,
|
|
613
|
-
c >>> 8 & 255,
|
|
614
|
-
c & 255,
|
|
615
|
-
E >>> 24,
|
|
616
|
-
E >>> 16 & 255,
|
|
617
|
-
E >>> 8 & 255,
|
|
618
|
-
E & 255
|
|
619
|
-
];
|
|
620
|
-
}, t.fromBytes = function(c, E, N) {
|
|
621
|
-
return N ? t.fromBytesLE(c, E) : t.fromBytesBE(c, E);
|
|
622
|
-
}, t.fromBytesLE = function(c, E) {
|
|
623
|
-
return new t(
|
|
624
|
-
c[0] | c[1] << 8 | c[2] << 16 | c[3] << 24,
|
|
625
|
-
c[4] | c[5] << 8 | c[6] << 16 | c[7] << 24,
|
|
626
|
-
E
|
|
627
|
-
);
|
|
628
|
-
}, t.fromBytesBE = function(c, E) {
|
|
629
|
-
return new t(
|
|
630
|
-
c[4] << 24 | c[5] << 16 | c[6] << 8 | c[7],
|
|
631
|
-
c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3],
|
|
632
|
-
E
|
|
633
|
-
);
|
|
634
|
-
}, wt;
|
|
635
|
-
}
|
|
636
|
-
var oe = Tn();
|
|
637
|
-
const re = /* @__PURE__ */ vn(oe), Rn = /* @__PURE__ */ Sn({
|
|
638
|
-
__proto__: null,
|
|
639
|
-
default: re
|
|
640
|
-
}, [oe]);
|
|
641
|
-
/**
|
|
642
|
-
* @license
|
|
643
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
644
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
645
|
-
* you may not use this file except in compliance with the License.
|
|
646
|
-
* You may obtain a copy of the License at
|
|
647
|
-
*
|
|
648
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
649
|
-
*
|
|
650
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
651
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
652
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
653
|
-
* See the License for the specific language governing permissions and
|
|
654
|
-
* limitations under the License.
|
|
655
|
-
* =============================================================================
|
|
656
|
-
*/
|
|
657
|
-
const tt = (
|
|
658
|
-
// tslint:disable-next-line
|
|
659
|
-
re || Rn
|
|
660
|
-
);
|
|
661
|
-
function gt(e) {
|
|
662
|
-
return tt.fromString(e, !0, 16);
|
|
663
|
-
}
|
|
664
|
-
const ae = gt("c3a5c85c97cb3127"), Y = gt("b492b66fbe98f273"), D = gt("9ae16a3b2f90404f");
|
|
665
|
-
function bt(e) {
|
|
666
|
-
return e.xor(e.shru(47));
|
|
667
|
-
}
|
|
668
|
-
function ie(e, t, n) {
|
|
669
|
-
const s = e.slice(t, t + n);
|
|
670
|
-
return tt.fromBytes(Array.from(s), !0, !0);
|
|
671
|
-
}
|
|
672
|
-
function T(e, t) {
|
|
673
|
-
return ie(e, t, 8);
|
|
674
|
-
}
|
|
675
|
-
function St(e, t) {
|
|
676
|
-
return ie(e, t, 4);
|
|
677
|
-
}
|
|
678
|
-
function q(e, t) {
|
|
679
|
-
return t === 0 ? e : e.shru(t).or(e.shl(64 - t));
|
|
680
|
-
}
|
|
681
|
-
function J(e, t, n = gt("9ddfea08eb382d69")) {
|
|
682
|
-
let s = e.xor(t).mul(n);
|
|
683
|
-
s = s.xor(s.shru(47));
|
|
684
|
-
let o = t.xor(s).mul(n);
|
|
685
|
-
return o = o.xor(o.shru(47)), o = o.mul(n), o;
|
|
686
|
-
}
|
|
687
|
-
function Mn(e, t, n, s, o, a) {
|
|
688
|
-
o = o.add(e), a = q(a.add(o).add(s), 21);
|
|
689
|
-
const r = o;
|
|
690
|
-
return o = o.add(t), o = o.add(n), a = a.add(q(o, 44)), [o.add(s), a.add(r)];
|
|
691
|
-
}
|
|
692
|
-
function ut(e, t, n, s) {
|
|
693
|
-
return Mn(T(e, t), T(e, t + 8), T(e, t + 16), T(e, t + 24), n, s);
|
|
694
|
-
}
|
|
695
|
-
function On(e, t = e.length) {
|
|
696
|
-
if (t >= 8) {
|
|
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
|
-
return J(a, r, n);
|
|
699
|
-
}
|
|
700
|
-
if (t >= 4) {
|
|
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
|
-
}
|
|
704
|
-
if (t > 0) {
|
|
705
|
-
const n = e[0], s = e[t >> 1], o = e[t - 1], a = n + (s << 8), r = t + (o << 2);
|
|
706
|
-
return bt(D.mul(a).xor(ae.mul(r))).mul(D);
|
|
707
|
-
}
|
|
708
|
-
return D;
|
|
709
|
-
}
|
|
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(q(s.add(o), 43).add(q(a, 30)).add(r), s.add(q(o.add(D), 18)).add(a), n);
|
|
713
|
-
}
|
|
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 = 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
|
-
}
|
|
718
|
-
function An(e, t = e.length) {
|
|
719
|
-
const n = tt.fromNumber(81, !0);
|
|
720
|
-
if (t <= 32)
|
|
721
|
-
return t <= 16 ? On(e, t) : Ln(e, t);
|
|
722
|
-
if (t <= 64)
|
|
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
|
-
let l = 0;
|
|
727
|
-
const u = (t - 1 >> 6) * 64, h = u + (t - 1 & 63) - 63;
|
|
728
|
-
do
|
|
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
|
-
while (l !== u);
|
|
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 = 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
|
-
}
|
|
734
|
-
/**
|
|
735
|
-
* @license
|
|
736
|
-
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
737
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
738
|
-
* you may not use this file except in compliance with the License.
|
|
739
|
-
* You may obtain a copy of the License at
|
|
740
|
-
*
|
|
741
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
742
|
-
*
|
|
743
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
744
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
745
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
746
|
-
* See the License for the specific language governing permissions and
|
|
747
|
-
* limitations under the License.
|
|
748
|
-
* =============================================================================
|
|
749
|
-
*/
|
|
750
|
-
function nt(e, t) {
|
|
751
|
-
Array.isArray(e) || (e = [e]), e.forEach((n) => {
|
|
752
|
-
n != null && Lt(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the CPU backend.`);
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* @license
|
|
757
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
758
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
759
|
-
* you may not use this file except in compliance with the License.
|
|
760
|
-
* You may obtain a copy of the License at
|
|
761
|
-
*
|
|
762
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
763
|
-
*
|
|
764
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
765
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
766
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
767
|
-
* See the License for the specific language governing permissions and
|
|
768
|
-
* limitations under the License.
|
|
769
|
-
* =============================================================================
|
|
770
|
-
*/
|
|
771
|
-
function le(e) {
|
|
772
|
-
const t = new Float32Array(e.length);
|
|
773
|
-
for (let n = 0; n < e.length; ++n)
|
|
774
|
-
t[n] = Math.abs(e[n]);
|
|
775
|
-
return t;
|
|
776
|
-
}
|
|
777
|
-
const qn = (e) => {
|
|
778
|
-
const { x: t } = e.inputs, n = e.backend;
|
|
779
|
-
nt(t, "abs");
|
|
780
|
-
let s = new Float32Array(V(t.shape));
|
|
781
|
-
const o = n.data.get(t.dataId).values;
|
|
782
|
-
return s = le(o), n.makeOutput(s, t.shape, t.dtype);
|
|
783
|
-
}, Xs = {
|
|
784
|
-
kernelName: Ce,
|
|
785
|
-
backendName: "cpu",
|
|
786
|
-
kernelFunc: qn
|
|
787
|
-
};
|
|
788
|
-
/**
|
|
789
|
-
* @license
|
|
790
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
791
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
792
|
-
* you may not use this file except in compliance with the License.
|
|
793
|
-
* You may obtain a copy of the License at
|
|
794
|
-
*
|
|
795
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
796
|
-
*
|
|
797
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
798
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
799
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
800
|
-
* See the License for the specific language governing permissions and
|
|
801
|
-
* limitations under the License.
|
|
802
|
-
* =============================================================================
|
|
803
|
-
*/
|
|
804
|
-
function $(e) {
|
|
805
|
-
return (t, n, s, o, a) => {
|
|
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
|
-
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
|
-
else
|
|
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
|
-
}
|
|
819
|
-
return [h, r];
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* @license
|
|
824
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
825
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
826
|
-
* you may not use this file except in compliance with the License.
|
|
827
|
-
* You may obtain a copy of the License at
|
|
828
|
-
*
|
|
829
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
830
|
-
*
|
|
831
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
832
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
833
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
834
|
-
* See the License for the specific language governing permissions and
|
|
835
|
-
* limitations under the License.
|
|
836
|
-
* =============================================================================
|
|
837
|
-
*/
|
|
838
|
-
function mt(e) {
|
|
839
|
-
const { inputs: t, backend: n } = e, { real: s, imag: o } = t, a = n.data.get(s.dataId).values, r = n.data.get(o.dataId).values, i = n.makeTensorInfo(s.shape, "complex64"), l = n.data.get(i.dataId);
|
|
840
|
-
return l.complexTensorInfos = {
|
|
841
|
-
real: n.makeTensorInfo(s.shape, "float32", a),
|
|
842
|
-
imag: n.makeTensorInfo(o.shape, "float32", r)
|
|
843
|
-
}, i;
|
|
844
|
-
}
|
|
845
|
-
const Js = {
|
|
846
|
-
kernelName: De,
|
|
847
|
-
backendName: "cpu",
|
|
848
|
-
kernelFunc: mt
|
|
849
|
-
};
|
|
850
|
-
/**
|
|
851
|
-
* @license
|
|
852
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
853
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
854
|
-
* you may not use this file except in compliance with the License.
|
|
855
|
-
* You may obtain a copy of the License at
|
|
856
|
-
*
|
|
857
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
858
|
-
*
|
|
859
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
860
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
861
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
862
|
-
* See the License for the specific language governing permissions and
|
|
863
|
-
* limitations under the License.
|
|
864
|
-
* =============================================================================
|
|
865
|
-
*/
|
|
866
|
-
function xt(e, t, n = "float32") {
|
|
867
|
-
if (n === "complex64") {
|
|
868
|
-
const o = xt(e, t, "float32"), a = xt(e, t, "float32");
|
|
869
|
-
return mt({ inputs: { real: o, imag: a }, backend: e });
|
|
870
|
-
}
|
|
871
|
-
const s = st(V(t), n);
|
|
872
|
-
return e.makeTensorInfo(t, n, s);
|
|
873
|
-
}
|
|
874
|
-
/**
|
|
875
|
-
* @license
|
|
876
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
877
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
878
|
-
* you may not use this file except in compliance with the License.
|
|
879
|
-
* You may obtain a copy of the License at
|
|
880
|
-
*
|
|
881
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
882
|
-
*
|
|
883
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
884
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
885
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
886
|
-
* See the License for the specific language governing permissions and
|
|
887
|
-
* limitations under the License.
|
|
888
|
-
* =============================================================================
|
|
889
|
-
*/
|
|
890
|
-
function Et(e) {
|
|
891
|
-
const { inputs: t, backend: n } = e, { x: s } = t;
|
|
892
|
-
return n.incRef(s.dataId), { dataId: s.dataId, shape: s.shape, dtype: s.dtype };
|
|
893
|
-
}
|
|
894
|
-
const Qs = {
|
|
895
|
-
kernelName: We,
|
|
896
|
-
backendName: "cpu",
|
|
897
|
-
kernelFunc: Et
|
|
898
|
-
};
|
|
899
|
-
/**
|
|
900
|
-
* @license
|
|
901
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
902
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
903
|
-
* you may not use this file except in compliance with the License.
|
|
904
|
-
* You may obtain a copy of the License at
|
|
905
|
-
*
|
|
906
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
907
|
-
*
|
|
908
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
909
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
910
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
911
|
-
* See the License for the specific language governing permissions and
|
|
912
|
-
* limitations under the License.
|
|
913
|
-
* =============================================================================
|
|
914
|
-
*/
|
|
915
|
-
function ce(e) {
|
|
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
|
-
return n.makeTensorInfo(o.shape, o.dtype, a);
|
|
918
|
-
}
|
|
919
|
-
const Ys = {
|
|
920
|
-
kernelName: $e,
|
|
921
|
-
backendName: "cpu",
|
|
922
|
-
kernelFunc: ce
|
|
923
|
-
};
|
|
924
|
-
/**
|
|
925
|
-
* @license
|
|
926
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
927
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
928
|
-
* you may not use this file except in compliance with the License.
|
|
929
|
-
* You may obtain a copy of the License at
|
|
930
|
-
*
|
|
931
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
932
|
-
*
|
|
933
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
934
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
935
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
936
|
-
* See the License for the specific language governing permissions and
|
|
937
|
-
* limitations under the License.
|
|
938
|
-
* =============================================================================
|
|
939
|
-
*/
|
|
940
|
-
function ue(e, t, n, s) {
|
|
941
|
-
if (s === "int32") {
|
|
942
|
-
const o = Int32Array.from(e);
|
|
943
|
-
return [t, "int32", o];
|
|
944
|
-
}
|
|
945
|
-
if (s === "bool") {
|
|
946
|
-
const o = Be([0], n), [a, r] = $((i, l) => i !== l ? 1 : 0)(t, [], e, o, "bool");
|
|
947
|
-
return [r, "bool", a];
|
|
948
|
-
}
|
|
949
|
-
throw new Error(`Error in Cast: failed to cast ${n} to ${s}`);
|
|
950
|
-
}
|
|
951
|
-
function lt(e) {
|
|
952
|
-
const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { dtype: a } = s;
|
|
953
|
-
if (a === "complex64") {
|
|
954
|
-
if (o.dtype === "complex64")
|
|
955
|
-
return Et({ inputs: { x: o }, backend: n });
|
|
956
|
-
const h = xt(n, o.shape, o.dtype), f = lt({ inputs: { x: o }, backend: n, attrs: { dtype: "float32" } }), p = mt({ inputs: { real: f, imag: h }, backend: n });
|
|
957
|
-
return n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(f), p;
|
|
958
|
-
}
|
|
959
|
-
if (o.dtype === "complex64") {
|
|
960
|
-
const h = ce({ inputs: { input: o }, backend: n }), f = lt({ inputs: { x: h }, backend: n, attrs: { dtype: a } });
|
|
961
|
-
return n.disposeIntermediateTensorInfo(h), f;
|
|
962
|
-
}
|
|
963
|
-
if (!ze(o.dtype, a)) {
|
|
964
|
-
const h = Et({ inputs: { x: o }, backend: n });
|
|
965
|
-
return { dataId: h.dataId, shape: h.shape, dtype: a };
|
|
966
|
-
}
|
|
967
|
-
const r = n.data.get(o.dataId).values, [i, l, u] = ue(r, o.shape, o.dtype, a);
|
|
968
|
-
return n.makeTensorInfo(i, l, u);
|
|
969
|
-
}
|
|
970
|
-
const to = {
|
|
971
|
-
kernelName: Ue,
|
|
972
|
-
backendName: "cpu",
|
|
973
|
-
kernelFunc: lt
|
|
974
|
-
};
|
|
975
|
-
/**
|
|
976
|
-
* @license
|
|
977
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
978
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
979
|
-
* you may not use this file except in compliance with the License.
|
|
980
|
-
* You may obtain a copy of the License at
|
|
981
|
-
*
|
|
982
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
983
|
-
*
|
|
984
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
985
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
986
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
987
|
-
* See the License for the specific language governing permissions and
|
|
988
|
-
* limitations under the License.
|
|
989
|
-
* =============================================================================
|
|
990
|
-
*/
|
|
991
|
-
function z(e, t, n, s) {
|
|
992
|
-
return n == null ? ({ inputs: o, backend: a }) => {
|
|
993
|
-
const { a: r, b: i } = o, l = a;
|
|
994
|
-
nt([r, i], e);
|
|
995
|
-
const u = l.data.get(r.dataId).values, h = l.data.get(i.dataId).values, f = r.dtype === "string" ? (
|
|
996
|
-
// tslint:disable-next-line: no-any
|
|
997
|
-
it(u)
|
|
998
|
-
) : u, p = r.dtype === "string" ? (
|
|
999
|
-
// tslint:disable-next-line: no-any
|
|
1000
|
-
it(h)
|
|
1001
|
-
) : h, w = s || r.dtype, [m, F] = t(r.shape, i.shape, f, p, w);
|
|
1002
|
-
return l.makeTensorInfo(F, w, m);
|
|
1003
|
-
} : ({ inputs: o, backend: a }) => {
|
|
1004
|
-
const { a: r, b: i } = o, l = a;
|
|
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, 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
|
-
} else {
|
|
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
|
-
}
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
function Ft(e) {
|
|
1015
|
-
return (t, n, s, o, a, r) => {
|
|
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
|
-
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
|
-
}
|
|
1022
|
-
else
|
|
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
|
-
m.forEach((E) => x[E] = 0);
|
|
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
|
-
}
|
|
1031
|
-
return [f, p, i];
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* @license
|
|
1036
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1037
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1038
|
-
* you may not use this file except in compliance with the License.
|
|
1039
|
-
* You may obtain a copy of the License at
|
|
1040
|
-
*
|
|
1041
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1042
|
-
*
|
|
1043
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1044
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1045
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1046
|
-
* See the License for the specific language governing permissions and
|
|
1047
|
-
* limitations under the License.
|
|
1048
|
-
* =============================================================================
|
|
1049
|
-
*/
|
|
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
|
-
backendName: "cpu",
|
|
1053
|
-
kernelFunc: Vn
|
|
1054
|
-
};
|
|
1055
|
-
/**
|
|
1056
|
-
* @license
|
|
1057
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1058
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1059
|
-
* you may not use this file except in compliance with the License.
|
|
1060
|
-
* You may obtain a copy of the License at
|
|
1061
|
-
*
|
|
1062
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1063
|
-
*
|
|
1064
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1065
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1066
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1067
|
-
* See the License for the specific language governing permissions and
|
|
1068
|
-
* limitations under the License.
|
|
1069
|
-
* =============================================================================
|
|
1070
|
-
*/
|
|
1071
|
-
function Cn(e, t, n, s, o) {
|
|
1072
|
-
const a = V(s), r = st(o, n);
|
|
1073
|
-
for (let i = 0; i < e.length; i++) {
|
|
1074
|
-
const l = e[i];
|
|
1075
|
-
if (l < 0)
|
|
1076
|
-
throw new Error("Input x must be non-negative!");
|
|
1077
|
-
l >= o || (a > 0 ? r[l] += t[i] : r[l] += 1);
|
|
1078
|
-
}
|
|
1079
|
-
return r;
|
|
1080
|
-
}
|
|
1081
|
-
function Dn(e, t, n, s = !1) {
|
|
1082
|
-
const o = e.shape[0], a = e.shape[1], r = H([o, n], t.dtype);
|
|
1083
|
-
for (let i = 0; i < o; i++)
|
|
1084
|
-
for (let l = 0; l < a; l++) {
|
|
1085
|
-
const u = e.get(i, l);
|
|
1086
|
-
if (u < 0)
|
|
1087
|
-
throw new Error("Input x must be non-negative!");
|
|
1088
|
-
u >= n || (s ? r.set(1, i, u) : t.size > 0 ? r.set(r.get(i, u) + t.get(i, l), i, u) : r.set(r.get(i, u) + 1, i, u));
|
|
1089
|
-
}
|
|
1090
|
-
return r;
|
|
1091
|
-
}
|
|
1092
|
-
/**
|
|
1093
|
-
* @license
|
|
1094
|
-
* Copyright 2023 Google LLC.
|
|
1095
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1096
|
-
* you may not use this file except in compliance with the License.
|
|
1097
|
-
* You may obtain a copy of the License at
|
|
1098
|
-
*
|
|
1099
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1100
|
-
*
|
|
1101
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1102
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1103
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1104
|
-
* See the License for the specific language governing permissions and
|
|
1105
|
-
* limitations under the License.
|
|
1106
|
-
* =============================================================================
|
|
1107
|
-
*/
|
|
1108
|
-
const fe = $((e, t) => e & t), Wn = z(qt, fe), no = {
|
|
1109
|
-
kernelName: qt,
|
|
1110
|
-
backendName: "cpu",
|
|
1111
|
-
kernelFunc: Wn
|
|
1112
|
-
};
|
|
1113
|
-
/**
|
|
1114
|
-
* @license
|
|
1115
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1116
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1117
|
-
* you may not use this file except in compliance with the License.
|
|
1118
|
-
* You may obtain a copy of the License at
|
|
1119
|
-
*
|
|
1120
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1121
|
-
*
|
|
1122
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1123
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1124
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1125
|
-
* See the License for the specific language governing permissions and
|
|
1126
|
-
* limitations under the License.
|
|
1127
|
-
* =============================================================================
|
|
1128
|
-
*/
|
|
1129
|
-
function X(e) {
|
|
1130
|
-
return (t, n, s) => {
|
|
1131
|
-
const o = W(n, t.length);
|
|
1132
|
-
for (let a = 0; a < t.length; ++a)
|
|
1133
|
-
o[a] = e(t[a], s);
|
|
1134
|
-
return o;
|
|
1135
|
-
};
|
|
1136
|
-
}
|
|
1137
|
-
/**
|
|
1138
|
-
* @license
|
|
1139
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1140
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1141
|
-
* you may not use this file except in compliance with the License.
|
|
1142
|
-
* You may obtain a copy of the License at
|
|
1143
|
-
*
|
|
1144
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1145
|
-
*
|
|
1146
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1147
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1148
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1149
|
-
* See the License for the specific language governing permissions and
|
|
1150
|
-
* limitations under the License.
|
|
1151
|
-
* =============================================================================
|
|
1152
|
-
*/
|
|
1153
|
-
function de(e, t, n) {
|
|
1154
|
-
const s = X(t);
|
|
1155
|
-
return Q(e, s, n);
|
|
1156
|
-
}
|
|
1157
|
-
function Q(e, t, n) {
|
|
1158
|
-
return ({ inputs: s, attrs: o, backend: a }) => {
|
|
1159
|
-
const { x: r } = s;
|
|
1160
|
-
nt(r, e);
|
|
1161
|
-
const i = a, l = i.data.get(r.dataId).values;
|
|
1162
|
-
let u;
|
|
1163
|
-
if (r.dtype === "string") {
|
|
1164
|
-
if (!Array.isArray(l))
|
|
1165
|
-
throw new Error("String tensor's value was not an instance of Array");
|
|
1166
|
-
u = it(l);
|
|
1167
|
-
} else
|
|
1168
|
-
u = l;
|
|
1169
|
-
const h = n || r.dtype, f = t(u, h, o);
|
|
1170
|
-
return i.makeTensorInfo(r.shape, h, f);
|
|
1171
|
-
};
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* @license
|
|
1175
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1176
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
1177
|
-
* you may not use this file except in compliance with the License.
|
|
1178
|
-
* You may obtain a copy of the License at
|
|
1179
|
-
*
|
|
1180
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1181
|
-
*
|
|
1182
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1183
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
1184
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1185
|
-
* See the License for the specific language governing permissions and
|
|
1186
|
-
* limitations under the License.
|
|
1187
|
-
* =============================================================================
|
|
1188
|
-
*/
|
|
1189
|
-
const ge = X((e) => Math.ceil(e)), $n = Q(_t, ge), so = {
|
|
1190
|
-
kernelName: _t,
|
|
1191
|
-
backendName: "cpu",
|
|
1192
|
-
kernelFunc: $n
|
|
1193
|
-
};
|
|
1194
|
-
/**
|
|
1195
|
-
* @license
|
|
1196
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1197
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1198
|
-
* you may not use this file except in compliance with the License.
|
|
1199
|
-
* You may obtain a copy of the License at
|
|
1200
|
-
*
|
|
1201
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1202
|
-
*
|
|
1203
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1204
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1205
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1206
|
-
* See the License for the specific language governing permissions and
|
|
1207
|
-
* limitations under the License.
|
|
1208
|
-
* =============================================================================
|
|
1209
|
-
*/
|
|
1210
|
-
function Un(e, t, n, s) {
|
|
1211
|
-
const o = W(n, V(t));
|
|
1212
|
-
if (s && n !== "string") {
|
|
1213
|
-
let a = 0;
|
|
1214
|
-
e.forEach((r) => {
|
|
1215
|
-
const i = V(r.shape);
|
|
1216
|
-
o.set(r.vals, a), a += i;
|
|
1217
|
-
});
|
|
1218
|
-
} else {
|
|
1219
|
-
let a = 0;
|
|
1220
|
-
e.forEach((r) => {
|
|
1221
|
-
const i = n === "string" ? it(r.vals) : r.vals;
|
|
1222
|
-
let l = 0;
|
|
1223
|
-
for (let u = 0; u < r.shape[0]; ++u) {
|
|
1224
|
-
const h = u * t[1] + a;
|
|
1225
|
-
for (let f = 0; f < r.shape[1]; ++f)
|
|
1226
|
-
o[h + f] = i[l++];
|
|
1227
|
-
}
|
|
1228
|
-
a += r.shape[1];
|
|
1229
|
-
});
|
|
1230
|
-
}
|
|
1231
|
-
return o;
|
|
1232
|
-
}
|
|
1233
|
-
/**
|
|
1234
|
-
* @license
|
|
1235
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1236
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1237
|
-
* you may not use this file except in compliance with the License.
|
|
1238
|
-
* You may obtain a copy of the License at
|
|
1239
|
-
*
|
|
1240
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1241
|
-
*
|
|
1242
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1243
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1244
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1245
|
-
* See the License for the specific language governing permissions and
|
|
1246
|
-
* limitations under the License.
|
|
1247
|
-
* =============================================================================
|
|
1248
|
-
*/
|
|
1249
|
-
const me = $((e, t) => e === t ? 1 : 0), zn = z(Vt, me, null, "bool"), oo = {
|
|
1250
|
-
kernelName: Vt,
|
|
1251
|
-
backendName: "cpu",
|
|
1252
|
-
kernelFunc: zn
|
|
1253
|
-
};
|
|
1254
|
-
/**
|
|
1255
|
-
* @license
|
|
1256
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1257
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
1258
|
-
* you may not use this file except in compliance with the License.
|
|
1259
|
-
* You may obtain a copy of the License at
|
|
1260
|
-
*
|
|
1261
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1262
|
-
*
|
|
1263
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1264
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
1265
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1266
|
-
* See the License for the specific language governing permissions and
|
|
1267
|
-
* limitations under the License.
|
|
1268
|
-
* =============================================================================
|
|
1269
|
-
*/
|
|
1270
|
-
const pe = X((e) => Math.exp(e)), Bn = Q(Ct, pe, "float32"), ro = {
|
|
1271
|
-
kernelName: Ct,
|
|
1272
|
-
backendName: "cpu",
|
|
1273
|
-
kernelFunc: Bn
|
|
1274
|
-
};
|
|
1275
|
-
/**
|
|
1276
|
-
* @license
|
|
1277
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1278
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
1279
|
-
* you may not use this file except in compliance with the License.
|
|
1280
|
-
* You may obtain a copy of the License at
|
|
1281
|
-
*
|
|
1282
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1283
|
-
*
|
|
1284
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1285
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
1286
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1287
|
-
* See the License for the specific language governing permissions and
|
|
1288
|
-
* limitations under the License.
|
|
1289
|
-
* =============================================================================
|
|
1290
|
-
*/
|
|
1291
|
-
const we = X((e) => Math.expm1(e)), jn = Q(Dt, we), ao = {
|
|
1292
|
-
kernelName: Dt,
|
|
1293
|
-
backendName: "cpu",
|
|
1294
|
-
kernelFunc: jn
|
|
1295
|
-
};
|
|
1296
|
-
/**
|
|
1297
|
-
* @license
|
|
1298
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1299
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
1300
|
-
* you may not use this file except in compliance with the License.
|
|
1301
|
-
* You may obtain a copy of the License at
|
|
1302
|
-
*
|
|
1303
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1304
|
-
*
|
|
1305
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1306
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
1307
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1308
|
-
* See the License for the specific language governing permissions and
|
|
1309
|
-
* limitations under the License.
|
|
1310
|
-
* =============================================================================
|
|
1311
|
-
*/
|
|
1312
|
-
const Ie = X((e) => Math.floor(e)), Gn = Q(Wt, Ie), io = {
|
|
1313
|
-
kernelName: Wt,
|
|
1314
|
-
backendName: "cpu",
|
|
1315
|
-
kernelFunc: Gn
|
|
1316
|
-
};
|
|
1317
|
-
/**
|
|
1318
|
-
* @license
|
|
1319
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1320
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1321
|
-
* you may not use this file except in compliance with the License.
|
|
1322
|
-
* You may obtain a copy of the License at
|
|
1323
|
-
*
|
|
1324
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1325
|
-
*
|
|
1326
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1327
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1328
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1329
|
-
* See the License for the specific language governing permissions and
|
|
1330
|
-
* limitations under the License.
|
|
1331
|
-
* =============================================================================
|
|
1332
|
-
*/
|
|
1333
|
-
const be = $((e, t) => Math.floor(e / t)), Zn = z($t, be, null, "int32"), lo = {
|
|
1334
|
-
kernelName: $t,
|
|
1335
|
-
backendName: "cpu",
|
|
1336
|
-
kernelFunc: Zn
|
|
1337
|
-
};
|
|
1338
|
-
/**
|
|
1339
|
-
* @license
|
|
1340
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
1341
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1342
|
-
* you may not use this file except in compliance with the License.
|
|
1343
|
-
* You may obtain a copy of the License at
|
|
1344
|
-
*
|
|
1345
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1346
|
-
*
|
|
1347
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1348
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1349
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1350
|
-
* See the License for the specific language governing permissions and
|
|
1351
|
-
* limitations under the License.
|
|
1352
|
-
* =============================================================================
|
|
1353
|
-
*/
|
|
1354
|
-
function Hn(e, t, n, s, o, a, r, i, l) {
|
|
1355
|
-
const u = H([s, a], n);
|
|
1356
|
-
for (let h = 0; h < s; h++) {
|
|
1357
|
-
const f = [];
|
|
1358
|
-
let p = 0;
|
|
1359
|
-
for (let w = 0; w < o; w++) {
|
|
1360
|
-
const m = e[h * o + w];
|
|
1361
|
-
p += m * r[w], f.push(m);
|
|
1362
|
-
}
|
|
1363
|
-
if (p < 0 || p >= l / a)
|
|
1364
|
-
throw new Error(`Invalid indices: ${f} does not index into ${i}`);
|
|
1365
|
-
for (let w = 0; w < a; w++)
|
|
1366
|
-
u.values[h * a + w] = t.get(...t.indexToLoc(p * a + w));
|
|
1367
|
-
}
|
|
1368
|
-
return u;
|
|
1369
|
-
}
|
|
1370
|
-
/**
|
|
1371
|
-
* @license
|
|
1372
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1373
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1374
|
-
* you may not use this file except in compliance with the License.
|
|
1375
|
-
* You may obtain a copy of the License at
|
|
1376
|
-
*
|
|
1377
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1378
|
-
*
|
|
1379
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1380
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1381
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1382
|
-
* See the License for the specific language governing permissions and
|
|
1383
|
-
* limitations under the License.
|
|
1384
|
-
* =============================================================================
|
|
1385
|
-
*/
|
|
1386
|
-
function Kn(e, t, n) {
|
|
1387
|
-
const s = H(n, e.dtype);
|
|
1388
|
-
for (let o = 0; o < s.size; ++o) {
|
|
1389
|
-
const r = s.indexToLoc(o).slice(), i = r[0], l = r[2], u = t.locToIndex([i, l]);
|
|
1390
|
-
r[2] = t.values[u];
|
|
1391
|
-
const h = e.locToIndex(r);
|
|
1392
|
-
0 <= h && h < e.values.length && (s.values[o] = e.values[h]);
|
|
1393
|
-
}
|
|
1394
|
-
return s;
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* @license
|
|
1398
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1399
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1400
|
-
* you may not use this file except in compliance with the License.
|
|
1401
|
-
* You may obtain a copy of the License at
|
|
1402
|
-
*
|
|
1403
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1404
|
-
*
|
|
1405
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1406
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1407
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1408
|
-
* See the License for the specific language governing permissions and
|
|
1409
|
-
* limitations under the License.
|
|
1410
|
-
* =============================================================================
|
|
1411
|
-
*/
|
|
1412
|
-
const xe = $((e, t) => e > t ? 1 : 0), Xn = z(Ut, xe, null, "bool"), co = {
|
|
1413
|
-
kernelName: Ut,
|
|
1414
|
-
backendName: "cpu",
|
|
1415
|
-
kernelFunc: Xn
|
|
1416
|
-
};
|
|
1417
|
-
/**
|
|
1418
|
-
* @license
|
|
1419
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1420
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1421
|
-
* you may not use this file except in compliance with the License.
|
|
1422
|
-
* You may obtain a copy of the License at
|
|
1423
|
-
*
|
|
1424
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1425
|
-
*
|
|
1426
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1427
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1428
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1429
|
-
* See the License for the specific language governing permissions and
|
|
1430
|
-
* limitations under the License.
|
|
1431
|
-
* =============================================================================
|
|
1432
|
-
*/
|
|
1433
|
-
const Ee = $((e, t) => e >= t ? 1 : 0), Jn = z(zt, Ee, null, "bool"), uo = {
|
|
1434
|
-
kernelName: zt,
|
|
1435
|
-
backendName: "cpu",
|
|
1436
|
-
kernelFunc: Jn
|
|
1437
|
-
};
|
|
1438
|
-
/**
|
|
1439
|
-
* @license
|
|
1440
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1441
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1442
|
-
* you may not use this file except in compliance with the License.
|
|
1443
|
-
* You may obtain a copy of the License at
|
|
1444
|
-
*
|
|
1445
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1446
|
-
*
|
|
1447
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1448
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1449
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1450
|
-
* See the License for the specific language governing permissions and
|
|
1451
|
-
* limitations under the License.
|
|
1452
|
-
* =============================================================================
|
|
1453
|
-
*/
|
|
1454
|
-
const Fe = $((e, t) => e < t ? 1 : 0), Qn = z(Bt, Fe, null, "bool"), ho = {
|
|
1455
|
-
kernelName: Bt,
|
|
1456
|
-
backendName: "cpu",
|
|
1457
|
-
kernelFunc: Qn
|
|
1458
|
-
};
|
|
1459
|
-
/**
|
|
1460
|
-
* @license
|
|
1461
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1462
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1463
|
-
* you may not use this file except in compliance with the License.
|
|
1464
|
-
* You may obtain a copy of the License at
|
|
1465
|
-
*
|
|
1466
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1467
|
-
*
|
|
1468
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1469
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1470
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1471
|
-
* See the License for the specific language governing permissions and
|
|
1472
|
-
* limitations under the License.
|
|
1473
|
-
* =============================================================================
|
|
1474
|
-
*/
|
|
1475
|
-
const ye = $((e, t) => e <= t ? 1 : 0), Yn = z(jt, ye, null, "bool"), fo = {
|
|
1476
|
-
kernelName: jt,
|
|
1477
|
-
backendName: "cpu",
|
|
1478
|
-
kernelFunc: Yn
|
|
1479
|
-
};
|
|
1480
|
-
/**
|
|
1481
|
-
* @license
|
|
1482
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1483
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1484
|
-
* you may not use this file except in compliance with the License.
|
|
1485
|
-
* You may obtain a copy of the License at
|
|
1486
|
-
*
|
|
1487
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1488
|
-
*
|
|
1489
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1490
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1491
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1492
|
-
* See the License for the specific language governing permissions and
|
|
1493
|
-
* limitations under the License.
|
|
1494
|
-
* =============================================================================
|
|
1495
|
-
*/
|
|
1496
|
-
function ts(e, t, n) {
|
|
1497
|
-
const s = (t - e) / (n - 1), o = st(n, "float32");
|
|
1498
|
-
o[0] = e;
|
|
1499
|
-
for (let a = 1; a < o.length; a++)
|
|
1500
|
-
o[a] = o[a - 1] + s;
|
|
1501
|
-
return o;
|
|
1502
|
-
}
|
|
1503
|
-
/**
|
|
1504
|
-
* @license
|
|
1505
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1506
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
1507
|
-
* you may not use this file except in compliance with the License.
|
|
1508
|
-
* You may obtain a copy of the License at
|
|
1509
|
-
*
|
|
1510
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1511
|
-
*
|
|
1512
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1513
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
1514
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1515
|
-
* See the License for the specific language governing permissions and
|
|
1516
|
-
* limitations under the License.
|
|
1517
|
-
* =============================================================================
|
|
1518
|
-
*/
|
|
1519
|
-
const ke = X((e) => Math.log(e)), es = Q(Gt, ke), go = {
|
|
1520
|
-
kernelName: Gt,
|
|
1521
|
-
backendName: "cpu",
|
|
1522
|
-
kernelFunc: es
|
|
1523
|
-
};
|
|
1524
|
-
/**
|
|
1525
|
-
* @license
|
|
1526
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1527
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1528
|
-
* you may not use this file except in compliance with the License.
|
|
1529
|
-
* You may obtain a copy of the License at
|
|
1530
|
-
*
|
|
1531
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1532
|
-
*
|
|
1533
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1534
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1535
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1536
|
-
* See the License for the specific language governing permissions and
|
|
1537
|
-
* limitations under the License.
|
|
1538
|
-
* =============================================================================
|
|
1539
|
-
*/
|
|
1540
|
-
function ns(e, t, n, s) {
|
|
1541
|
-
const o = et(s, V(n));
|
|
1542
|
-
for (let a = 0; a < o.length; ++a) {
|
|
1543
|
-
const r = a * t;
|
|
1544
|
-
let i = e[r];
|
|
1545
|
-
for (let l = 0; l < t; ++l) {
|
|
1546
|
-
const u = e[r + l];
|
|
1547
|
-
(Number.isNaN(u) || u > i) && (i = u);
|
|
1548
|
-
}
|
|
1549
|
-
o[a] = i;
|
|
1550
|
-
}
|
|
1551
|
-
return o;
|
|
1552
|
-
}
|
|
1553
|
-
/**
|
|
1554
|
-
* @license
|
|
1555
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1556
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1557
|
-
* you may not use this file except in compliance with the License.
|
|
1558
|
-
* You may obtain a copy of the License at
|
|
1559
|
-
*
|
|
1560
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1561
|
-
*
|
|
1562
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1563
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1564
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1565
|
-
* See the License for the specific language governing permissions and
|
|
1566
|
-
* limitations under the License.
|
|
1567
|
-
* =============================================================================
|
|
1568
|
-
*/
|
|
1569
|
-
const Ne = $((e, t) => Math.max(e, t)), ss = z(Zt, Ne), mo = {
|
|
1570
|
-
kernelName: Zt,
|
|
1571
|
-
backendName: "cpu",
|
|
1572
|
-
kernelFunc: ss
|
|
1573
|
-
};
|
|
1574
|
-
/**
|
|
1575
|
-
* @license
|
|
1576
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1577
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1578
|
-
* you may not use this file except in compliance with the License.
|
|
1579
|
-
* You may obtain a copy of the License at
|
|
1580
|
-
*
|
|
1581
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1582
|
-
*
|
|
1583
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1584
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1585
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1586
|
-
* See the License for the specific language governing permissions and
|
|
1587
|
-
* limitations under the License.
|
|
1588
|
-
* =============================================================================
|
|
1589
|
-
*/
|
|
1590
|
-
const ve = $((e, t) => Math.min(e, t)), os = z(Ht, ve), po = {
|
|
1591
|
-
kernelName: Ht,
|
|
1592
|
-
backendName: "cpu",
|
|
1593
|
-
kernelFunc: os
|
|
1594
|
-
};
|
|
1595
|
-
/**
|
|
1596
|
-
* @license
|
|
1597
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1598
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1599
|
-
* you may not use this file except in compliance with the License.
|
|
1600
|
-
* You may obtain a copy of the License at
|
|
1601
|
-
*
|
|
1602
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1603
|
-
*
|
|
1604
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1605
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1606
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1607
|
-
* See the License for the specific language governing permissions and
|
|
1608
|
-
* limitations under the License.
|
|
1609
|
-
* =============================================================================
|
|
1610
|
-
*/
|
|
1611
|
-
const yt = $((e, t) => e * t), rs = Ft((e, t, n, s) => ({
|
|
1612
|
-
real: e * n - t * s,
|
|
1613
|
-
imag: e * s + t * n
|
|
1614
|
-
})), as = z(Kt, yt, rs), wo = {
|
|
1615
|
-
kernelName: Kt,
|
|
1616
|
-
backendName: "cpu",
|
|
1617
|
-
kernelFunc: as
|
|
1618
|
-
};
|
|
1619
|
-
/**
|
|
1620
|
-
* @license
|
|
1621
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1622
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1623
|
-
* you may not use this file except in compliance with the License.
|
|
1624
|
-
* You may obtain a copy of the License at
|
|
1625
|
-
*
|
|
1626
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1627
|
-
*
|
|
1628
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1629
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1630
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1631
|
-
* See the License for the specific language governing permissions and
|
|
1632
|
-
* limitations under the License.
|
|
1633
|
-
* =============================================================================
|
|
1634
|
-
*/
|
|
1635
|
-
function Se(e, t, n) {
|
|
1636
|
-
const s = Ge(-1, n);
|
|
1637
|
-
return yt([], t, s, e, n);
|
|
1638
|
-
}
|
|
1639
|
-
function is(e) {
|
|
1640
|
-
const { inputs: t, backend: n } = e, { x: s } = t;
|
|
1641
|
-
nt(s, "neg");
|
|
1642
|
-
const o = n.data.get(s.dataId).values, [a, r] = Se(o, s.shape, s.dtype);
|
|
1643
|
-
return n.makeTensorInfo(r, s.dtype, a);
|
|
1644
|
-
}
|
|
1645
|
-
const Io = {
|
|
1646
|
-
kernelName: je,
|
|
1647
|
-
backendName: "cpu",
|
|
1648
|
-
kernelFunc: is
|
|
1649
|
-
};
|
|
1650
|
-
/**
|
|
1651
|
-
* @license
|
|
1652
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1653
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1654
|
-
* you may not use this file except in compliance with the License.
|
|
1655
|
-
* You may obtain a copy of the License at
|
|
1656
|
-
*
|
|
1657
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1658
|
-
*
|
|
1659
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1660
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1661
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1662
|
-
* See the License for the specific language governing permissions and
|
|
1663
|
-
* limitations under the License.
|
|
1664
|
-
* =============================================================================
|
|
1665
|
-
*/
|
|
1666
|
-
const Te = $((e, t) => e !== t ? 1 : 0), ls = z(Xt, Te, null, "bool"), bo = {
|
|
1667
|
-
kernelName: Xt,
|
|
1668
|
-
backendName: "cpu",
|
|
1669
|
-
kernelFunc: ls
|
|
1670
|
-
};
|
|
1671
|
-
/**
|
|
1672
|
-
* @license
|
|
1673
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1674
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1675
|
-
* you may not use this file except in compliance with the License.
|
|
1676
|
-
* You may obtain a copy of the License at
|
|
1677
|
-
*
|
|
1678
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1679
|
-
*
|
|
1680
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1681
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1682
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1683
|
-
* See the License for the specific language governing permissions and
|
|
1684
|
-
* limitations under the License.
|
|
1685
|
-
* =============================================================================
|
|
1686
|
-
*/
|
|
1687
|
-
function Re(e, t, n, s, o) {
|
|
1688
|
-
const a = t.length, r = V(t), i = K(t), l = K(o), u = et(n, V(o));
|
|
1689
|
-
for (let h = 0; h < r; ++h) {
|
|
1690
|
-
const f = dt(h, a, i), p = new Array(f.length);
|
|
1691
|
-
for (let m = 0; m < p.length; m++)
|
|
1692
|
-
p[m] = f[s[m]];
|
|
1693
|
-
const w = at(p, a, l);
|
|
1694
|
-
u[w] = e[h];
|
|
1695
|
-
}
|
|
1696
|
-
return u;
|
|
1697
|
-
}
|
|
1698
|
-
/**
|
|
1699
|
-
* @license
|
|
1700
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1701
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1702
|
-
* you may not use this file except in compliance with the License.
|
|
1703
|
-
* You may obtain a copy of the License at
|
|
1704
|
-
*
|
|
1705
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1706
|
-
*
|
|
1707
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1708
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1709
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1710
|
-
* See the License for the specific language governing permissions and
|
|
1711
|
-
* limitations under the License.
|
|
1712
|
-
* =============================================================================
|
|
1713
|
-
*/
|
|
1714
|
-
function Me(e) {
|
|
1715
|
-
const { inputs: t, attrs: n, backend: s } = e, { x: o } = t, { perm: a } = n;
|
|
1716
|
-
nt(o, "transpose");
|
|
1717
|
-
const r = o.shape.length, i = new Array(r);
|
|
1718
|
-
for (let f = 0; f < i.length; f++)
|
|
1719
|
-
i[f] = o.shape[a[f]];
|
|
1720
|
-
const l = s.data.get(o.dataId).values, u = Re(l, o.shape, o.dtype, a, i);
|
|
1721
|
-
return { dataId: s.write(u, i, o.dtype), shape: i, dtype: o.dtype };
|
|
1722
|
-
}
|
|
1723
|
-
const xo = {
|
|
1724
|
-
kernelName: Ze,
|
|
1725
|
-
backendName: "cpu",
|
|
1726
|
-
kernelFunc: Me
|
|
1727
|
-
};
|
|
1728
|
-
/**
|
|
1729
|
-
* @license
|
|
1730
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
1731
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1732
|
-
* you may not use this file except in compliance with the License.
|
|
1733
|
-
* You may obtain a copy of the License at
|
|
1734
|
-
*
|
|
1735
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1736
|
-
*
|
|
1737
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1738
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1739
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1740
|
-
* See the License for the specific language governing permissions and
|
|
1741
|
-
* limitations under the License.
|
|
1742
|
-
* =============================================================================
|
|
1743
|
-
*/
|
|
1744
|
-
function Oe(e, t, n, s) {
|
|
1745
|
-
const [o, a] = bn(e, s), r = Ke(t, "int32"), i = st(V(o), r), l = V(a);
|
|
1746
|
-
for (let u = 0; u < i.length; ++u) {
|
|
1747
|
-
const h = u * l;
|
|
1748
|
-
let f = 1;
|
|
1749
|
-
for (let p = 0; p < l; ++p)
|
|
1750
|
-
f *= n[h + p];
|
|
1751
|
-
i[u] = f;
|
|
1752
|
-
}
|
|
1753
|
-
return { outVals: i, outShape: o, outDtype: r };
|
|
1754
|
-
}
|
|
1755
|
-
function cs(e) {
|
|
1756
|
-
const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { axis: a, keepDims: r } = s;
|
|
1757
|
-
nt(o, "prod");
|
|
1758
|
-
const i = o.shape.length, l = Jt(a, o.shape), u = pn(l, i);
|
|
1759
|
-
let h = l, f = o;
|
|
1760
|
-
const p = [];
|
|
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
|
-
}
|
|
1766
|
-
const Eo = {
|
|
1767
|
-
kernelName: He,
|
|
1768
|
-
backendName: "cpu",
|
|
1769
|
-
kernelFunc: cs
|
|
1770
|
-
};
|
|
1771
|
-
/**
|
|
1772
|
-
* @license
|
|
1773
|
-
* Copyright 2022 Google LLC. All Rights Reserved.
|
|
1774
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1775
|
-
* you may not use this file except in compliance with the License.
|
|
1776
|
-
* You may obtain a copy of the License at
|
|
1777
|
-
*
|
|
1778
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1779
|
-
*
|
|
1780
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1781
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1782
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1783
|
-
* See the License for the specific language governing permissions and
|
|
1784
|
-
* limitations under the License.
|
|
1785
|
-
* =============================================================================
|
|
1786
|
-
*/
|
|
1787
|
-
function us(e, t, n) {
|
|
1788
|
-
e.forEach((s, o) => {
|
|
1789
|
-
if (s < 0 || s >= n) {
|
|
1790
|
-
const a = dt(o, t.length, K(t)).join(",");
|
|
1791
|
-
throw new Error(`indices[${a}] = ${s} is not in [0, ${n})`);
|
|
1792
|
-
}
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
|
-
function hs(e, t) {
|
|
1796
|
-
for (let n = 0; n < e.length; ++n) {
|
|
1797
|
-
const s = e[n], o = n === e.length - 1 ? t : e[n + 1].length;
|
|
1798
|
-
if (s.length === 0)
|
|
1799
|
-
throw new Error("Ragged splits may not be empty");
|
|
1800
|
-
if (s[0] < 0)
|
|
1801
|
-
throw new Error("Ragged splits must be non-negative");
|
|
1802
|
-
if (s[s.length - 1] > o)
|
|
1803
|
-
throw new Error("Ragged splits must not point past values");
|
|
1804
|
-
for (let a = 1; a < s.length; ++a)
|
|
1805
|
-
if (s[a - 1] > s[a])
|
|
1806
|
-
throw new Error("Ragged splits must be sorted in ascending order");
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
function fs(e, t, n, s) {
|
|
1810
|
-
const o = [];
|
|
1811
|
-
let a = 0;
|
|
1812
|
-
const r = t.length - 1 + n.length, i = new Array(r).fill(null).map(() => [0]);
|
|
1813
|
-
hs(n, s);
|
|
1814
|
-
let l = 1;
|
|
1815
|
-
for (let u = 0; u < t.length - 1; ++u) {
|
|
1816
|
-
l *= t[u];
|
|
1817
|
-
const h = t[u + 1];
|
|
1818
|
-
for (let f = 1; f < l + 1; ++f)
|
|
1819
|
-
i[u].push(f * h);
|
|
1820
|
-
}
|
|
1821
|
-
for (let u = 0; u < e.length; ++u) {
|
|
1822
|
-
let h = e[u], f = e[u] + 1;
|
|
1823
|
-
for (let p = 0; p < n.length; ++p) {
|
|
1824
|
-
const w = n[p], m = p + t.length - 1;
|
|
1825
|
-
if (m >= 0) {
|
|
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
|
-
}
|
|
1830
|
-
h = w[h], f = w[f];
|
|
1831
|
-
}
|
|
1832
|
-
f !== h && (o.push([h, f]), a += f - h);
|
|
1833
|
-
}
|
|
1834
|
-
return { outSplits: i, valueSlices: o, numValues: a };
|
|
1835
|
-
}
|
|
1836
|
-
function ds(e) {
|
|
1837
|
-
const t = [];
|
|
1838
|
-
for (let n = 0; n < e.length; ++n) {
|
|
1839
|
-
const s = e[n].length, o = W("int32", s);
|
|
1840
|
-
t.push(o), e[n].forEach((a, r) => o[r] = a);
|
|
1841
|
-
}
|
|
1842
|
-
return t;
|
|
1843
|
-
}
|
|
1844
|
-
function Tt(e, t) {
|
|
1845
|
-
const n = e.slice(0, t);
|
|
1846
|
-
for (; n.length < t; )
|
|
1847
|
-
n.push(1);
|
|
1848
|
-
for (let s = t; s < e.length; s++)
|
|
1849
|
-
n[t - 1] *= e[s];
|
|
1850
|
-
return n;
|
|
1851
|
-
}
|
|
1852
|
-
function gs(e, t, n, s, o, a) {
|
|
1853
|
-
const r = Tt(t, 2)[1], i = Tt(a, 2)[1];
|
|
1854
|
-
let l = 0;
|
|
1855
|
-
for (const u of n)
|
|
1856
|
-
for (let h = u[0]; h < u[1]; ++h) {
|
|
1857
|
-
for (let f = 0; f < s; ++f)
|
|
1858
|
-
o[l * i + f] = e[h * r + f];
|
|
1859
|
-
++l;
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
function ms(e, t, n, s, o) {
|
|
1863
|
-
const a = t.slice();
|
|
1864
|
-
a[0] = o;
|
|
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
|
-
}
|
|
1868
|
-
function ps(e, t, n, s, o, a, r, i) {
|
|
1869
|
-
if (e.length === 0)
|
|
1870
|
-
throw new Error("paramsNestedSplits must be non empty");
|
|
1871
|
-
if (t[0].length === 0)
|
|
1872
|
-
throw new Error("Split tensors must not be scalars");
|
|
1873
|
-
const l = t[0][0] - 1;
|
|
1874
|
-
if (us(a, r, l), s.length === 0)
|
|
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), w = ds(h), m = ms(n, s, o, f, p);
|
|
1877
|
-
return [w, m[0], m[1]];
|
|
1878
|
-
}
|
|
1879
|
-
/**
|
|
1880
|
-
* @license
|
|
1881
|
-
* Copyright 2022 Google LLC.
|
|
1882
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1883
|
-
* you may not use this file except in compliance with the License.
|
|
1884
|
-
* You may obtain a copy of the License at
|
|
1885
|
-
*
|
|
1886
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1887
|
-
*
|
|
1888
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1889
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1890
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1891
|
-
* See the License for the specific language governing permissions and
|
|
1892
|
-
* limitations under the License.
|
|
1893
|
-
* =============================================================================
|
|
1894
|
-
*/
|
|
1895
|
-
const Rt = 2147483647;
|
|
1896
|
-
function ws(e, t, n, s, o, a, r) {
|
|
1897
|
-
if (t.length > 1)
|
|
1898
|
-
throw new Error("starts must be a scalar or vector");
|
|
1899
|
-
if (o.length > 1)
|
|
1900
|
-
throw new Error("limits must be a scalar or vector");
|
|
1901
|
-
if (r.length > 1)
|
|
1902
|
-
throw new Error("deltas must be a scalar or vector");
|
|
1903
|
-
const i = t.length === 0, l = o.length === 0, u = r.length === 0, h = [];
|
|
1904
|
-
i || h.push(t[0]), l || h.push(o[0]), u || h.push(r[0]);
|
|
1905
|
-
for (let d = 1; d < h.length; ++d)
|
|
1906
|
-
if (h[d] !== h[d - 1])
|
|
1907
|
-
throw new Error("starts, limits, and deltas must have the same shape");
|
|
1908
|
-
const f = h.length === 0 ? 1 : h[0], p = W("int32", f + 1);
|
|
1909
|
-
p[0] = 0;
|
|
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
|
-
if (k === 0)
|
|
1913
|
-
throw new Error("Requires delta != 0");
|
|
1914
|
-
let y;
|
|
1915
|
-
if (k > 0 && b < g || k < 0 && b > g)
|
|
1916
|
-
y = 0;
|
|
1917
|
-
else if (y = Math.ceil(Math.abs((b - g) / k)), y > Rt)
|
|
1918
|
-
throw new Error(`Requires ((limit - start) / delta) <= ${Rt}`);
|
|
1919
|
-
p[d + 1] = p[d] + y;
|
|
1920
|
-
}
|
|
1921
|
-
const w = p[f], m = W(n, w);
|
|
1922
|
-
let F = 0;
|
|
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
|
-
m[F++] = b, b += k;
|
|
1929
|
-
}
|
|
1930
|
-
return [p, m];
|
|
1931
|
-
}
|
|
1932
|
-
/**
|
|
1933
|
-
* @license
|
|
1934
|
-
* Copyright 2022 Google LLC. All Rights Reserved.
|
|
1935
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1936
|
-
* you may not use this file except in compliance with the License.
|
|
1937
|
-
* You may obtain a copy of the License at
|
|
1938
|
-
*
|
|
1939
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1940
|
-
*
|
|
1941
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1942
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1943
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1944
|
-
* See the License for the specific language governing permissions and
|
|
1945
|
-
* limitations under the License.
|
|
1946
|
-
* =============================================================================
|
|
1947
|
-
*/
|
|
1948
|
-
var Z = tn;
|
|
1949
|
-
class ft {
|
|
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 = Qe(h), this.raggedRank = Ye(this.rowPartitionTypes);
|
|
1952
|
-
}
|
|
1953
|
-
getRowPartitionTypeByDimension(t) {
|
|
1954
|
-
return this.rowPartitionTypes[0] === Z.FIRST_DIM_SIZE ? this.rowPartitionTypes[t + 1] : this.rowPartitionTypes[t];
|
|
1955
|
-
}
|
|
1956
|
-
// Returns the relationship between dimension and dimension + 1.
|
|
1957
|
-
getRowPartitionTensor(t) {
|
|
1958
|
-
return this.rowPartitionTypes[0] === Z.FIRST_DIM_SIZE ? this.rowPartitionValues[t + 1] : this.rowPartitionValues[t];
|
|
1959
|
-
}
|
|
1960
|
-
getMaxWidth(t) {
|
|
1961
|
-
const n = this.getRowPartitionTensor(t - 1);
|
|
1962
|
-
switch (this.getRowPartitionTypeByDimension(t - 1)) {
|
|
1963
|
-
case Z.VALUE_ROWIDS:
|
|
1964
|
-
return ft.getMaxWidthValueRowID(n);
|
|
1965
|
-
case Z.ROW_SPLITS:
|
|
1966
|
-
return ft.getMaxWidthRowSplit(n);
|
|
1967
|
-
default:
|
|
1968
|
-
throw new Error(`Cannot handle partition type ${Z[this.getRowPartitionTypeByDimension(t - 1)]}`);
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
static getMaxWidthRowSplit(t) {
|
|
1972
|
-
const n = t.length;
|
|
1973
|
-
if (n === 0 || n === 1)
|
|
1974
|
-
return 0;
|
|
1975
|
-
let s = 0;
|
|
1976
|
-
for (let o = 0; o < n - 1; ++o) {
|
|
1977
|
-
const a = t[o + 1] - t[o];
|
|
1978
|
-
a > s && (s = a);
|
|
1979
|
-
}
|
|
1980
|
-
return s;
|
|
1981
|
-
}
|
|
1982
|
-
static getMaxWidthValueRowID(t) {
|
|
1983
|
-
const n = t.length;
|
|
1984
|
-
if (n === 0)
|
|
1985
|
-
return 0;
|
|
1986
|
-
let s = 0, o = t[0], a = 0;
|
|
1987
|
-
for (let r = 1; r < n; ++r) {
|
|
1988
|
-
const i = t[r];
|
|
1989
|
-
i !== o && (o = i, a = Math.max(r - s, a), s = r);
|
|
1990
|
-
}
|
|
1991
|
-
return Math.max(n - s, a);
|
|
1992
|
-
}
|
|
1993
|
-
tensorShapeFromTensor(t, n, s = !0) {
|
|
1994
|
-
if (n.length === 0) {
|
|
1995
|
-
if (t[0] === -1)
|
|
1996
|
-
return [];
|
|
1997
|
-
throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.");
|
|
1998
|
-
}
|
|
1999
|
-
return Ot(t, s);
|
|
2000
|
-
}
|
|
2001
|
-
calculateOutputSize(t) {
|
|
2002
|
-
const n = this.valuesShape, s = this.defaultValueShape;
|
|
2003
|
-
en(s, n);
|
|
2004
|
-
const o = this.tensorShapeFromTensor(this.shape, this.shapeShape), r = nn(this.raggedRank, o, n);
|
|
2005
|
-
r[0] < 0 && (r[0] = t);
|
|
2006
|
-
for (let i = 1; i <= this.raggedRank; ++i)
|
|
2007
|
-
r[i] < 0 && (r[i] = this.getMaxWidth(i));
|
|
2008
|
-
return r;
|
|
2009
|
-
}
|
|
2010
|
-
/**
|
|
2011
|
-
* The outputIndex represents the index in the output tensor
|
|
2012
|
-
* where the first element of a particular dimension would be written.
|
|
2013
|
-
* If it is -1, it indicates that the index is out of scope.
|
|
2014
|
-
* Example, given firstDimension = 10, firstDimensionOutput = 6,
|
|
2015
|
-
* and outputIndexMultiplier = 100:
|
|
2016
|
-
* result = [0 100 200 300 400 500 -1 -1 -1 -1]
|
|
2017
|
-
* If firstDimensionOutput = 11 instead, then:
|
|
2018
|
-
* result = [0 100 200 300 400 500 600 700 800 900]
|
|
2019
|
-
*/
|
|
2020
|
-
calculateFirstParentOutputIndex(t, n, s) {
|
|
2021
|
-
const o = Math.min(t, s), a = [];
|
|
2022
|
-
let r = 0;
|
|
2023
|
-
for (let i = 0; i < o; ++i, r += n)
|
|
2024
|
-
a.push(r);
|
|
2025
|
-
for (let i = o; i < t; ++i)
|
|
2026
|
-
a.push(-1);
|
|
2027
|
-
return Lt(a.length === t, () => "Final length of result must be equal to firstDimension."), a;
|
|
2028
|
-
}
|
|
2029
|
-
calculateOutputIndexRowSplit(t, n, s, o) {
|
|
2030
|
-
const a = t.length, r = [];
|
|
2031
|
-
for (let i = 0; i < a - 1; ++i) {
|
|
2032
|
-
const l = t[i + 1] - t[i];
|
|
2033
|
-
let u = Math.min(o, l), h = n[i];
|
|
2034
|
-
h === -1 && (u = 0);
|
|
2035
|
-
for (let f = 0; f < u; ++f)
|
|
2036
|
-
r.push(h), h += s;
|
|
2037
|
-
for (let f = 0; f < l - u; ++f)
|
|
2038
|
-
r.push(-1);
|
|
2039
|
-
}
|
|
2040
|
-
if (a > 0 && r.length !== t[a - 1])
|
|
2041
|
-
throw new Error("Invalid row split size.");
|
|
2042
|
-
return r;
|
|
2043
|
-
}
|
|
2044
|
-
// Calculate the output index of the first element of a list.
|
|
2045
|
-
// The parentOutputIndex is the same computation for the previous list.
|
|
2046
|
-
// -1 indicates an element or list that is out of range.
|
|
2047
|
-
// The outputIndexMultiplier is the number of output indices one moves
|
|
2048
|
-
// forward for each column.
|
|
2049
|
-
// E.g., given:
|
|
2050
|
-
// valueRowIds:[0 1 2 2 2 3 5 5 6]
|
|
2051
|
-
// parentOutputIndex:[1000 1100 2000 2100 -1 3000 4000]
|
|
2052
|
-
// outputIndexMultiplier: 10
|
|
2053
|
-
// outputSize: 2
|
|
2054
|
-
// You get:
|
|
2055
|
-
// result = [1000 1100 2000 2010 -1 2100 -1 -1 3000]
|
|
2056
|
-
// result[0] = parentOutputIndex[valueRowIds[0]]
|
|
2057
|
-
// result[1] = parentOutputIndex[valueRowIds[1]]
|
|
2058
|
-
// result[2] = parentOutputIndex[valueRowIds[2]]
|
|
2059
|
-
// result[3] = parentOutputIndex[valueRowIds[2] + 10]
|
|
2060
|
-
// result[4] = -1 because it is the third element the size is 2.
|
|
2061
|
-
// result[5] = parentOutputIndex[valueRowIds[3]]
|
|
2062
|
-
// result[6] = -1 because parentOutputIndex[valueRowIds[6]] == -1
|
|
2063
|
-
// result[7] = -1 because parentOutputIndex[valueRowIds[6]] == -1
|
|
2064
|
-
// result[8] = parentOutputIndex[valueRowIds[7]]
|
|
2065
|
-
calculateOutputIndexValueRowID(t, n, s, o) {
|
|
2066
|
-
const a = t.length, r = [];
|
|
2067
|
-
if (a === 0)
|
|
2068
|
-
return [];
|
|
2069
|
-
let i = 0, l = t[0];
|
|
2070
|
-
if (l >= n.length)
|
|
2071
|
-
throw new Error(`Got currentValueRowId=${l}, which is not less than ${n.length}`);
|
|
2072
|
-
let u = n[l];
|
|
2073
|
-
r.push(u);
|
|
2074
|
-
for (let h = 1; h < a; ++h) {
|
|
2075
|
-
const f = t[h];
|
|
2076
|
-
if (f === l)
|
|
2077
|
-
u >= 0 && (++i, i < o ? u += s : u = -1);
|
|
2078
|
-
else {
|
|
2079
|
-
if (i = 0, l = f, f >= n.length)
|
|
2080
|
-
throw new Error(`Got nextValueRowId=${f} which is not less than ${n.length}`);
|
|
2081
|
-
u = n[f];
|
|
2082
|
-
}
|
|
2083
|
-
r.push(u);
|
|
2084
|
-
}
|
|
2085
|
-
if (r.length !== t.length)
|
|
2086
|
-
throw new Error("Invalid row ids.");
|
|
2087
|
-
return r;
|
|
2088
|
-
}
|
|
2089
|
-
calculateOutputIndex(t, n, s, o) {
|
|
2090
|
-
const a = this.getRowPartitionTensor(t), r = this.getRowPartitionTypeByDimension(t);
|
|
2091
|
-
switch (r) {
|
|
2092
|
-
case Z.VALUE_ROWIDS:
|
|
2093
|
-
return this.calculateOutputIndexValueRowID(a, n, s, o);
|
|
2094
|
-
case Z.ROW_SPLITS:
|
|
2095
|
-
if (a.length - 1 > n.length)
|
|
2096
|
-
throw new Error(`Row partition size is greater than output size: ${a.length - 1} > ${n.length}`);
|
|
2097
|
-
return this.calculateOutputIndexRowSplit(a, n, s, o);
|
|
2098
|
-
default:
|
|
2099
|
-
throw new Error(`Unsupported partition type: ${Z[r]}`);
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
getFirstDimensionSize() {
|
|
2103
|
-
const t = this.rowPartitionValues[0];
|
|
2104
|
-
if (this.rowPartitionTypes.length === 0)
|
|
2105
|
-
throw new Error("No row_partition_types given.");
|
|
2106
|
-
const n = this.rowPartitionTypes[0];
|
|
2107
|
-
switch (n) {
|
|
2108
|
-
case Z.FIRST_DIM_SIZE:
|
|
2109
|
-
return t[0];
|
|
2110
|
-
case Z.VALUE_ROWIDS:
|
|
2111
|
-
throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");
|
|
2112
|
-
case Z.ROW_SPLITS:
|
|
2113
|
-
return this.rowPartitionValuesShapes[0][0] - 1;
|
|
2114
|
-
default:
|
|
2115
|
-
throw new Error(`Cannot handle type ${Z[n]}`);
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
compute() {
|
|
2119
|
-
if (this.rowPartitionValues[0].length <= 0)
|
|
2120
|
-
throw new Error("Invalid first partition input. Tensor requires at least one element.");
|
|
2121
|
-
const n = this.getFirstDimensionSize(), s = this.calculateOutputSize(n), o = new Array(this.raggedRank + 1);
|
|
2122
|
-
o[o.length - 1] = 1;
|
|
2123
|
-
for (let l = o.length - 2; l >= 0; --l)
|
|
2124
|
-
o[l] = o[l + 1] * s[l + 1];
|
|
2125
|
-
const a = Ot(s, !1), r = W(this.valuesDType, V(a));
|
|
2126
|
-
if (o[0] * s[0] > 0) {
|
|
2127
|
-
let l = this.calculateFirstParentOutputIndex(n, o[0], s[0]);
|
|
2128
|
-
for (let u = 1; u <= this.raggedRank; ++u)
|
|
2129
|
-
l = this.calculateOutputIndex(u - 1, l, o[u], s[u]);
|
|
2130
|
-
this.setOutput(this.raggedRank, l, r, a);
|
|
2131
|
-
}
|
|
2132
|
-
return [a, r];
|
|
2133
|
-
}
|
|
2134
|
-
setOutput(t, n, s, o) {
|
|
2135
|
-
if (s.length === 0)
|
|
2136
|
-
return;
|
|
2137
|
-
const a = this.values, r = s;
|
|
2138
|
-
let i = o.slice();
|
|
2139
|
-
i = i.slice(t + 1);
|
|
2140
|
-
const l = V(i), u = n.length;
|
|
2141
|
-
let h = this.defaultValue;
|
|
2142
|
-
if (h.length !== l && h.length !== 1) {
|
|
2143
|
-
const m = this.defaultValueShape;
|
|
2144
|
-
Xe(() => {
|
|
2145
|
-
const F = En(h, m);
|
|
2146
|
-
h = xn(F, i).dataSync();
|
|
2147
|
-
});
|
|
2148
|
-
}
|
|
2149
|
-
let f = 0, p = 0, w = 0;
|
|
2150
|
-
for (let m = 0; m <= u; ++m) {
|
|
2151
|
-
let F = m < u ? n[m] : -1;
|
|
2152
|
-
if (F === w) {
|
|
2153
|
-
++w;
|
|
2154
|
-
continue;
|
|
2155
|
-
}
|
|
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
|
-
}
|
|
2160
|
-
if (m >= u) {
|
|
2161
|
-
const d = s.length;
|
|
2162
|
-
F = Math.floor(d / l);
|
|
2163
|
-
}
|
|
2164
|
-
if (F > w)
|
|
2165
|
-
if (this.defaultValue.length === 1)
|
|
2166
|
-
r.subarray(w * l, F * l).fill(this.defaultValue[0]), w = F;
|
|
2167
|
-
else
|
|
2168
|
-
for (; F > w; ) {
|
|
2169
|
-
const d = r.slice(w * l);
|
|
2170
|
-
Mt(d, h, l), ++w;
|
|
2171
|
-
}
|
|
2172
|
-
F < 0 ? (f = m + 1, p = w) : (f = m, p = w, w = p + 1);
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
function Mt(e, t, n) {
|
|
2177
|
-
for (let s = 0; s < n; s++)
|
|
2178
|
-
e[s] = t[s];
|
|
2179
|
-
}
|
|
2180
|
-
function Ot(e, t) {
|
|
2181
|
-
const n = [];
|
|
2182
|
-
for (let s of e) {
|
|
2183
|
-
if (s < 0) {
|
|
2184
|
-
if (!t)
|
|
2185
|
-
throw new Error(`Dimension ${s} must be >= 0`);
|
|
2186
|
-
if (s < -1)
|
|
2187
|
-
throw new Error(`Dimension ${s} must be >= -1`);
|
|
2188
|
-
s = -1;
|
|
2189
|
-
}
|
|
2190
|
-
n.push(s);
|
|
2191
|
-
}
|
|
2192
|
-
return n;
|
|
2193
|
-
}
|
|
2194
|
-
function Is(e, t, n, s, o, a, r, i, l, u) {
|
|
2195
|
-
return new ft(e, t, n, s, o, a, r, i, l, u).compute();
|
|
2196
|
-
}
|
|
2197
|
-
/**
|
|
2198
|
-
* @license
|
|
2199
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2200
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2201
|
-
* you may not use this file except in compliance with the License.
|
|
2202
|
-
* You may obtain a copy of the License at
|
|
2203
|
-
*
|
|
2204
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2205
|
-
*
|
|
2206
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2207
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2208
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2209
|
-
* See the License for the specific language governing permissions and
|
|
2210
|
-
* limitations under the License.
|
|
2211
|
-
* =============================================================================
|
|
2212
|
-
*/
|
|
2213
|
-
function bs(e, t, n, s) {
|
|
2214
|
-
const o = e === t, a = e < t && n < 0, r = t < e && n > 1;
|
|
2215
|
-
if (o || a || r)
|
|
2216
|
-
return st(0, s);
|
|
2217
|
-
const i = Math.abs(Math.ceil((t - e) / n)), l = st(i, s);
|
|
2218
|
-
t < e && n === 1 && (n = -1), l[0] = e;
|
|
2219
|
-
for (let u = 1; u < l.length; u++)
|
|
2220
|
-
l[u] = l[u - 1] + n;
|
|
2221
|
-
return l;
|
|
2222
|
-
}
|
|
2223
|
-
/**
|
|
2224
|
-
* @license
|
|
2225
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2226
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
2227
|
-
* you may not use this file except in compliance with the License.
|
|
2228
|
-
* You may obtain a copy of the License at
|
|
2229
|
-
*
|
|
2230
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2231
|
-
*
|
|
2232
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2233
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
2234
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2235
|
-
* See the License for the specific language governing permissions and
|
|
2236
|
-
* limitations under the License.
|
|
2237
|
-
* =============================================================================
|
|
2238
|
-
*/
|
|
2239
|
-
const Le = X((e) => 1 / Math.sqrt(e)), xs = Q(Qt, Le), Fo = {
|
|
2240
|
-
kernelName: Qt,
|
|
2241
|
-
backendName: "cpu",
|
|
2242
|
-
kernelFunc: xs
|
|
2243
|
-
};
|
|
2244
|
-
/**
|
|
2245
|
-
* @license
|
|
2246
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2247
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2248
|
-
* you may not use this file except in compliance with the License.
|
|
2249
|
-
* You may obtain a copy of the License at
|
|
2250
|
-
*
|
|
2251
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2252
|
-
*
|
|
2253
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2254
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2255
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2256
|
-
* See the License for the specific language governing permissions and
|
|
2257
|
-
* limitations under the License.
|
|
2258
|
-
* =============================================================================
|
|
2259
|
-
*/
|
|
2260
|
-
function Es(e, t, n, s, o, a, r, i, l, u) {
|
|
2261
|
-
const h = [s / o, o], f = e.values, p = t.values;
|
|
2262
|
-
if (s === 0)
|
|
2263
|
-
return H(n, t.dtype);
|
|
2264
|
-
const w = l instanceof It ? l : H(h, t.dtype);
|
|
2265
|
-
typeof l == "string" || typeof l == "number" ? w.values.fill(l) : typeof l == "boolean" && w.values.fill(+l);
|
|
2266
|
-
for (let m = 0; m < a; m++) {
|
|
2267
|
-
const F = [];
|
|
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
|
-
}
|
|
2273
|
-
if (d < 0 || d >= s / o)
|
|
2274
|
-
throw new Error(`Invalid indices: ${F} does not index into ${n}`);
|
|
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
|
-
}
|
|
2278
|
-
return w;
|
|
2279
|
-
}
|
|
2280
|
-
/**
|
|
2281
|
-
* @license
|
|
2282
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2283
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
2284
|
-
* you may not use this file except in compliance with the License.
|
|
2285
|
-
* You may obtain a copy of the License at
|
|
2286
|
-
*
|
|
2287
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2288
|
-
*
|
|
2289
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2290
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
2291
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2292
|
-
* See the License for the specific language governing permissions and
|
|
2293
|
-
* limitations under the License.
|
|
2294
|
-
* =============================================================================
|
|
2295
|
-
*/
|
|
2296
|
-
const Fs = X((e) => 1 / (1 + Math.exp(-e))), ys = de(Yt, (e) => 1 / (1 + Math.exp(-e))), yo = {
|
|
2297
|
-
kernelName: Yt,
|
|
2298
|
-
backendName: "cpu",
|
|
2299
|
-
kernelFunc: ys
|
|
2300
|
-
};
|
|
2301
|
-
/**
|
|
2302
|
-
* @license
|
|
2303
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2304
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2305
|
-
* you may not use this file except in compliance with the License.
|
|
2306
|
-
* You may obtain a copy of the License at
|
|
2307
|
-
*
|
|
2308
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2309
|
-
*
|
|
2310
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2311
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2312
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2313
|
-
* See the License for the specific language governing permissions and
|
|
2314
|
-
* limitations under the License.
|
|
2315
|
-
* =============================================================================
|
|
2316
|
-
*/
|
|
2317
|
-
function Pe(e, t, n, s, o) {
|
|
2318
|
-
const a = kn(s, t, n), r = V(n), i = K(s);
|
|
2319
|
-
if (a) {
|
|
2320
|
-
const f = Nn(t, i);
|
|
2321
|
-
return o === "string" ? e.slice(f, f + r) : e.subarray(f, f + r);
|
|
2322
|
-
}
|
|
2323
|
-
const l = o === "string" ? it(e) : e, u = H(s, o, l), h = H(n, o);
|
|
2324
|
-
for (let f = 0; f < h.size; ++f) {
|
|
2325
|
-
const p = h.indexToLoc(f), w = p.map((m, F) => m + t[F]);
|
|
2326
|
-
h.set(u.get(...w), ...p);
|
|
2327
|
-
}
|
|
2328
|
-
return o === "string" ? sn(h.values) : h.values;
|
|
2329
|
-
}
|
|
2330
|
-
function ks(e) {
|
|
2331
|
-
const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { begin: a, size: r } = s;
|
|
2332
|
-
nt(o, "slice");
|
|
2333
|
-
const [i, l] = Fn(o, a, r);
|
|
2334
|
-
yn(o, i, l);
|
|
2335
|
-
const u = n.data.get(o.dataId).values, h = Pe(u, i, l, o.shape, o.dtype);
|
|
2336
|
-
return n.makeTensorInfo(l, o.dtype, h);
|
|
2337
|
-
}
|
|
2338
|
-
const ko = {
|
|
2339
|
-
kernelName: Je,
|
|
2340
|
-
backendName: "cpu",
|
|
2341
|
-
kernelFunc: ks
|
|
2342
|
-
};
|
|
2343
|
-
/**
|
|
2344
|
-
* @license
|
|
2345
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
2346
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2347
|
-
* you may not use this file except in compliance with the License.
|
|
2348
|
-
* You may obtain a copy of the License at
|
|
2349
|
-
*
|
|
2350
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2351
|
-
*
|
|
2352
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2353
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2354
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2355
|
-
* See the License for the specific language governing permissions and
|
|
2356
|
-
* limitations under the License.
|
|
2357
|
-
* =============================================================================
|
|
2358
|
-
*/
|
|
2359
|
-
function Ns(e, t, n, s, o, a, r) {
|
|
2360
|
-
const i = t[0], l = a[0], u = new Array(l), h = new Array(i), f = t[1];
|
|
2361
|
-
if (l === 0) {
|
|
2362
|
-
if (i !== 0)
|
|
2363
|
-
throw new Error(on(i));
|
|
2364
|
-
const d = W(n, 0), g = W(o, 0);
|
|
2365
|
-
return [
|
|
2366
|
-
d,
|
|
2367
|
-
[0, f],
|
|
2368
|
-
g,
|
|
2369
|
-
u,
|
|
2370
|
-
h
|
|
2371
|
-
];
|
|
2372
|
-
}
|
|
2373
|
-
let p = !0, w = 0;
|
|
2374
|
-
const m = new Array(l).fill(0);
|
|
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
|
-
}
|
|
2383
|
-
let F = !0;
|
|
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
|
-
}
|
|
2388
|
-
if (F && p) {
|
|
2389
|
-
const d = e, g = s;
|
|
2390
|
-
for (let b = 0; b < i; ++b)
|
|
2391
|
-
h[b] = b;
|
|
2392
|
-
return [
|
|
2393
|
-
d,
|
|
2394
|
-
[i, f],
|
|
2395
|
-
g,
|
|
2396
|
-
u,
|
|
2397
|
-
h
|
|
2398
|
-
];
|
|
2399
|
-
} else {
|
|
2400
|
-
const d = m[l - 1], g = W(n, d * f), b = W(o, d), k = new Array(l).fill(0);
|
|
2401
|
-
for (let y = 0; y < i; ++y) {
|
|
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
|
-
}
|
|
2408
|
-
for (let y = 0; y < l; ++y)
|
|
2409
|
-
if (k[y] === 0) {
|
|
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
|
-
}
|
|
2416
|
-
return [
|
|
2417
|
-
g,
|
|
2418
|
-
[d, f],
|
|
2419
|
-
b,
|
|
2420
|
-
u,
|
|
2421
|
-
h
|
|
2422
|
-
];
|
|
2423
|
-
}
|
|
2424
|
-
}
|
|
2425
|
-
/**
|
|
2426
|
-
* @license
|
|
2427
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
2428
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2429
|
-
* you may not use this file except in compliance with the License.
|
|
2430
|
-
* You may obtain a copy of the License at
|
|
2431
|
-
*
|
|
2432
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2433
|
-
*
|
|
2434
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2435
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2436
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2437
|
-
* See the License for the specific language governing permissions and
|
|
2438
|
-
* limitations under the License.
|
|
2439
|
-
* =============================================================================
|
|
2440
|
-
*/
|
|
2441
|
-
function vs(e, t, n, s, o) {
|
|
2442
|
-
const a = V(s), r = t[0], i = o.length, l = [];
|
|
2443
|
-
let u = 1, h = -1;
|
|
2444
|
-
for (let d = 0; d < i; ++d) {
|
|
2445
|
-
const g = o[d];
|
|
2446
|
-
if (g === -1) {
|
|
2447
|
-
if (h !== -1)
|
|
2448
|
-
throw new Error(ln(h, d));
|
|
2449
|
-
h = d, l.push(1);
|
|
2450
|
-
} else {
|
|
2451
|
-
if (g < 0)
|
|
2452
|
-
throw new Error(cn(d, g));
|
|
2453
|
-
u *= g, l.push(g);
|
|
2454
|
-
}
|
|
2455
|
-
}
|
|
2456
|
-
if (h !== -1) {
|
|
2457
|
-
if (u <= 0)
|
|
2458
|
-
throw new Error(un());
|
|
2459
|
-
const d = Math.trunc(a / u);
|
|
2460
|
-
if (u * d !== a)
|
|
2461
|
-
throw new Error(hn(s, l));
|
|
2462
|
-
l[h] = d;
|
|
2463
|
-
}
|
|
2464
|
-
if (V(l) !== a)
|
|
2465
|
-
throw new Error(fn(s, l));
|
|
2466
|
-
const p = s.length, w = [];
|
|
2467
|
-
if (p > 0) {
|
|
2468
|
-
w[p - 1] = 1;
|
|
2469
|
-
for (let d = p - 2; d >= 0; --d)
|
|
2470
|
-
w[d] = w[d + 1] * s[d + 1];
|
|
2471
|
-
}
|
|
2472
|
-
const m = [];
|
|
2473
|
-
if (i > 0) {
|
|
2474
|
-
m[i - 1] = 1;
|
|
2475
|
-
for (let d = i - 2; d >= 0; --d)
|
|
2476
|
-
m[d] = m[d + 1] * l[d + 1];
|
|
2477
|
-
}
|
|
2478
|
-
const F = W(n, r * i);
|
|
2479
|
-
for (let d = 0; d < r; ++d) {
|
|
2480
|
-
let g = 0;
|
|
2481
|
-
for (let b = 0; b < p; ++b)
|
|
2482
|
-
g += e[d * p + b] * w[b];
|
|
2483
|
-
for (let b = 0; b < i; ++b)
|
|
2484
|
-
F[d * i + b] = Math.trunc(g / m[b]), g %= m[b];
|
|
2485
|
-
}
|
|
2486
|
-
return [F, [r, i], l];
|
|
2487
|
-
}
|
|
2488
|
-
/**
|
|
2489
|
-
* @license
|
|
2490
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
2491
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2492
|
-
* you may not use this file except in compliance with the License.
|
|
2493
|
-
* You may obtain a copy of the License at
|
|
2494
|
-
*
|
|
2495
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2496
|
-
*
|
|
2497
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2498
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2499
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2500
|
-
* See the License for the specific language governing permissions and
|
|
2501
|
-
* limitations under the License.
|
|
2502
|
-
* =============================================================================
|
|
2503
|
-
*/
|
|
2504
|
-
function Ss(e, t, n, s, o, a = !1, r = 0) {
|
|
2505
|
-
const i = s.length, l = [t[0], e.length / t[0]], u = l[1], f = i > 0 ? o[i - 1] + 1 : 0;
|
|
2506
|
-
if (f < 0)
|
|
2507
|
-
throw new Error(Nt());
|
|
2508
|
-
const p = t.slice();
|
|
2509
|
-
p[0] = f;
|
|
2510
|
-
const w = p.reduce((k, y) => k * y, 1), m = W(n, w);
|
|
2511
|
-
if (i === 0)
|
|
2512
|
-
return f > 0 && m.fill(r), [m, p];
|
|
2513
|
-
if (f <= 0)
|
|
2514
|
-
throw new Error(Nt());
|
|
2515
|
-
let F = 0, d = 1, g = 0, b = o[F];
|
|
2516
|
-
for (; ; ) {
|
|
2517
|
-
let k = 0;
|
|
2518
|
-
if (d < i) {
|
|
2519
|
-
if (k = o[d], b === k) {
|
|
2520
|
-
++d;
|
|
2521
|
-
continue;
|
|
2522
|
-
}
|
|
2523
|
-
if (b >= k)
|
|
2524
|
-
throw new Error(dn());
|
|
2525
|
-
}
|
|
2526
|
-
if (b < 0 || b >= f)
|
|
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
|
-
throw new Error(mn(y, s[y], l[0]));
|
|
2533
|
-
for (let M = 0; M < u; M++)
|
|
2534
|
-
m[b * u + M] += e[v * u + M];
|
|
2535
|
-
}
|
|
2536
|
-
if (a)
|
|
2537
|
-
for (let y = 0; y < u; y++)
|
|
2538
|
-
m[b * u + y] /= d - F;
|
|
2539
|
-
if (F = d, ++d, g = b + 1, b = k, d > i)
|
|
2540
|
-
break;
|
|
2541
|
-
}
|
|
2542
|
-
return g < f && m.fill(r, g * u, f * u), [m, p];
|
|
2543
|
-
}
|
|
2544
|
-
/**
|
|
2545
|
-
* @license
|
|
2546
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2547
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
2548
|
-
* you may not use this file except in compliance with the License.
|
|
2549
|
-
* You may obtain a copy of the License at
|
|
2550
|
-
*
|
|
2551
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2552
|
-
*
|
|
2553
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2554
|
-
* distributed under the License is distributed on an AS IS BASIS,
|
|
2555
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2556
|
-
* See the License for the specific language governing permissions and
|
|
2557
|
-
* limitations under the License.
|
|
2558
|
-
* =============================================================================
|
|
2559
|
-
*/
|
|
2560
|
-
const Ts = X((e) => Math.sqrt(e)), Rs = de(te, (e) => Math.sqrt(e)), No = {
|
|
2561
|
-
kernelName: te,
|
|
2562
|
-
backendName: "cpu",
|
|
2563
|
-
kernelFunc: Rs
|
|
2564
|
-
};
|
|
2565
|
-
/**
|
|
2566
|
-
* @license
|
|
2567
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2568
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2569
|
-
* you may not use this file except in compliance with the License.
|
|
2570
|
-
* You may obtain a copy of the License at
|
|
2571
|
-
*
|
|
2572
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2573
|
-
*
|
|
2574
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2575
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2576
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2577
|
-
* See the License for the specific language governing permissions and
|
|
2578
|
-
* limitations under the License.
|
|
2579
|
-
* =============================================================================
|
|
2580
|
-
*/
|
|
2581
|
-
const Ae = $((e, t) => {
|
|
2582
|
-
const n = e - t;
|
|
2583
|
-
return n * n;
|
|
2584
|
-
}), Ms = z(ee, Ae), vo = {
|
|
2585
|
-
kernelName: ee,
|
|
2586
|
-
backendName: "cpu",
|
|
2587
|
-
kernelFunc: Ms
|
|
2588
|
-
};
|
|
2589
|
-
/**
|
|
2590
|
-
* @license
|
|
2591
|
-
* Copyright 2023 Google LLC.
|
|
2592
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2593
|
-
* you may not use this file except in compliance with the License.
|
|
2594
|
-
* You may obtain a copy of the License at
|
|
2595
|
-
*
|
|
2596
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2597
|
-
*
|
|
2598
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2599
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2600
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2601
|
-
* See the License for the specific language governing permissions and
|
|
2602
|
-
* limitations under the License.
|
|
2603
|
-
* =============================================================================
|
|
2604
|
-
*/
|
|
2605
|
-
const qe = X((e, t) => {
|
|
2606
|
-
const { pattern: n, replaceGlobal: s, rewrite: o } = t;
|
|
2607
|
-
return e.replace(new RegExp(n, s ? "g" : ""), o);
|
|
2608
|
-
}), Os = Q(ne, qe), So = {
|
|
2609
|
-
kernelName: ne,
|
|
2610
|
-
backendName: "cpu",
|
|
2611
|
-
kernelFunc: Os
|
|
2612
|
-
};
|
|
2613
|
-
/**
|
|
2614
|
-
* @license
|
|
2615
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2616
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2617
|
-
* you may not use this file except in compliance with the License.
|
|
2618
|
-
* You may obtain a copy of the License at
|
|
2619
|
-
*
|
|
2620
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2621
|
-
*
|
|
2622
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2623
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2624
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2625
|
-
* See the License for the specific language governing permissions and
|
|
2626
|
-
* limitations under the License.
|
|
2627
|
-
* =============================================================================
|
|
2628
|
-
*/
|
|
2629
|
-
function Ls(e, t, n, s) {
|
|
2630
|
-
const o = H(e, t.dtype);
|
|
2631
|
-
for (let a = 0; a < o.size; a++) {
|
|
2632
|
-
const r = o.indexToLoc(a), i = new Array(r.length);
|
|
2633
|
-
for (let l = 0; l < i.length; l++)
|
|
2634
|
-
i[l] = r[l] * n[l] + s[l];
|
|
2635
|
-
o.set(t.get(...i), ...r);
|
|
2636
|
-
}
|
|
2637
|
-
return o;
|
|
2638
|
-
}
|
|
2639
|
-
/**
|
|
2640
|
-
* @license
|
|
2641
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
2642
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2643
|
-
* you may not use this file except in compliance with the License.
|
|
2644
|
-
* You may obtain a copy of the License at
|
|
2645
|
-
*
|
|
2646
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2647
|
-
*
|
|
2648
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2649
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2650
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2651
|
-
* See the License for the specific language governing permissions and
|
|
2652
|
-
* limitations under the License.
|
|
2653
|
-
* =============================================================================
|
|
2654
|
-
*/
|
|
2655
|
-
class Ps {
|
|
2656
|
-
constructor(t, n, s, o, a, r) {
|
|
2657
|
-
this.separator = pt(t), this.nGramWidths = n, this.leftPad = pt(s), this.rightPad = pt(o), this.padWidth = a, this.preserveShort = r;
|
|
2658
|
-
}
|
|
2659
|
-
getPadWidth(t) {
|
|
2660
|
-
return Math.min(this.padWidth < 0 ? t - 1 : this.padWidth, t - 1);
|
|
2661
|
-
}
|
|
2662
|
-
getNumNGrams(t, n) {
|
|
2663
|
-
const s = this.getPadWidth(n);
|
|
2664
|
-
return Math.max(0, t + 2 * s - n + 1);
|
|
2665
|
-
}
|
|
2666
|
-
createNGrams(t, n, s, o, a, r) {
|
|
2667
|
-
for (let i = 0; i < a; ++i) {
|
|
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 w = 0;
|
|
2670
|
-
w += u * this.leftPad.length;
|
|
2671
|
-
for (let b = 0; b < f; ++b)
|
|
2672
|
-
w += t[p + b].length;
|
|
2673
|
-
w += h * this.rightPad.length;
|
|
2674
|
-
const m = u + h + f - 1;
|
|
2675
|
-
w += m * this.separator.length, s[o + i] = new Uint8Array(w);
|
|
2676
|
-
const F = s[o + i];
|
|
2677
|
-
let d = 0;
|
|
2678
|
-
const g = (b) => b.forEach((k) => F[d++] = k);
|
|
2679
|
-
for (let b = 0; b < u; ++b)
|
|
2680
|
-
g(this.leftPad), g(this.separator);
|
|
2681
|
-
for (let b = 0; b < f - 1; ++b)
|
|
2682
|
-
g(t[p + b]), g(this.separator);
|
|
2683
|
-
if (f > 0) {
|
|
2684
|
-
g(t[p + f - 1]);
|
|
2685
|
-
for (let b = 0; b < h; ++b)
|
|
2686
|
-
g(this.separator), g(this.rightPad);
|
|
2687
|
-
} else {
|
|
2688
|
-
for (let b = 0; b < h - 1; ++b)
|
|
2689
|
-
g(this.rightPad), g(this.separator);
|
|
2690
|
-
g(this.rightPad);
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
}
|
|
2694
|
-
// Data and splits together form the definition of the ragged tensor,
|
|
2695
|
-
// where data is 1 dimensional and contains the values of the tensor
|
|
2696
|
-
// and splits denotes the indices at which each row starts.
|
|
2697
|
-
compute(t, n) {
|
|
2698
|
-
const s = t.length, o = n.length;
|
|
2699
|
-
if (o > 0) {
|
|
2700
|
-
let l = n[0];
|
|
2701
|
-
if (l !== 0)
|
|
2702
|
-
throw new Error(`First split value must be 0, got ${l}`);
|
|
2703
|
-
for (let u = 1; u < o; ++u) {
|
|
2704
|
-
let h = n[u] >= l;
|
|
2705
|
-
if (h = h && n[u] <= s, !h)
|
|
2706
|
-
throw new Error(`Invalid split value ${n[u]}, must be in [${l}, ${s}]`);
|
|
2707
|
-
l = n[u];
|
|
2708
|
-
}
|
|
2709
|
-
if (l !== s)
|
|
2710
|
-
throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`);
|
|
2711
|
-
}
|
|
2712
|
-
const a = o - 1, r = W("int32", o);
|
|
2713
|
-
if (s === 0 || o === 0) {
|
|
2714
|
-
const l = new Array(s);
|
|
2715
|
-
for (let u = 0; u <= a; ++u)
|
|
2716
|
-
r[u] = 0;
|
|
2717
|
-
return [l, r];
|
|
2718
|
-
}
|
|
2719
|
-
r[0] = 0;
|
|
2720
|
-
for (let l = 1; l <= a; ++l) {
|
|
2721
|
-
const u = n[l] - n[l - 1];
|
|
2722
|
-
let h = 0;
|
|
2723
|
-
this.nGramWidths.forEach((f) => {
|
|
2724
|
-
h += this.getNumNGrams(u, f);
|
|
2725
|
-
}), this.preserveShort && u > 0 && h === 0 && (h = 1), r[l] = r[l - 1] + h;
|
|
2726
|
-
}
|
|
2727
|
-
const i = new Array(r[a]);
|
|
2728
|
-
for (let l = 0; l < a; ++l) {
|
|
2729
|
-
const u = n[l];
|
|
2730
|
-
let h = r[l];
|
|
2731
|
-
if (this.nGramWidths.forEach((f) => {
|
|
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
|
-
}), this.preserveShort && h === r[l]) {
|
|
2735
|
-
const f = n[l + 1] - n[l];
|
|
2736
|
-
if (f === 0)
|
|
2737
|
-
continue;
|
|
2738
|
-
const p = f + 2 * this.padWidth;
|
|
2739
|
-
this.createNGrams(t, u, i, h, 1, p);
|
|
2740
|
-
}
|
|
2741
|
-
}
|
|
2742
|
-
return [i, r];
|
|
2743
|
-
}
|
|
2744
|
-
}
|
|
2745
|
-
function As(e, t, n, s, o, a, r, i) {
|
|
2746
|
-
return new Ps(n, s, o, a, r, i).compute(e, t);
|
|
2747
|
-
}
|
|
2748
|
-
/**
|
|
2749
|
-
* @license
|
|
2750
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
2751
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2752
|
-
* you may not use this file except in compliance with the License.
|
|
2753
|
-
* You may obtain a copy of the License at
|
|
2754
|
-
*
|
|
2755
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2756
|
-
*
|
|
2757
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2758
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2759
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2760
|
-
* See the License for the specific language governing permissions and
|
|
2761
|
-
* limitations under the License.
|
|
2762
|
-
* =============================================================================
|
|
2763
|
-
*/
|
|
2764
|
-
function qs(e, t, n, s) {
|
|
2765
|
-
if (!e.length)
|
|
2766
|
-
return;
|
|
2767
|
-
if (t.length === 0) {
|
|
2768
|
-
for (let a = 0; a < e.length; ++a)
|
|
2769
|
-
s.push(e.subarray(a, a + 1));
|
|
2770
|
-
return;
|
|
2771
|
-
}
|
|
2772
|
-
if (t.length === 1) {
|
|
2773
|
-
const a = t[0];
|
|
2774
|
-
let r = e.indexOf(a);
|
|
2775
|
-
for (; r !== -1; ) {
|
|
2776
|
-
const i = e.subarray(0, r);
|
|
2777
|
-
(!n || i.length !== 0) && s.push(i), e = e.subarray(r + 1), r = e.indexOf(a);
|
|
2778
|
-
}
|
|
2779
|
-
(!n || e.length !== 0) && s.push(e);
|
|
2780
|
-
return;
|
|
2781
|
-
}
|
|
2782
|
-
let o = 0;
|
|
2783
|
-
for (let a = 0; a < e.length + 1; a++)
|
|
2784
|
-
if (a === e.length || t.indexOf(e[a]) !== -1) {
|
|
2785
|
-
const r = e.subarray(o, a);
|
|
2786
|
-
(!n || r.length !== 0) && s.push(r), o = a + 1;
|
|
2787
|
-
}
|
|
2788
|
-
}
|
|
2789
|
-
function _s(e, t, n) {
|
|
2790
|
-
const s = e.length, o = [];
|
|
2791
|
-
let a = 0, r = 0;
|
|
2792
|
-
const i = new Array(s);
|
|
2793
|
-
for (let p = 0; p < s; ++p) {
|
|
2794
|
-
const w = o.length;
|
|
2795
|
-
qs(e[p], t, n, o);
|
|
2796
|
-
const m = o.length - w;
|
|
2797
|
-
i[p] = m, a += m, r = Math.max(r, m);
|
|
2798
|
-
}
|
|
2799
|
-
const l = W("int32", a * 2), u = new Array(a), h = [s, r];
|
|
2800
|
-
let f = 0;
|
|
2801
|
-
for (let p = 0; p < s; ++p)
|
|
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
|
-
return [l, u, h];
|
|
2805
|
-
}
|
|
2806
|
-
/**
|
|
2807
|
-
* @license
|
|
2808
|
-
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
2809
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2810
|
-
* you may not use this file except in compliance with the License.
|
|
2811
|
-
* You may obtain a copy of the License at
|
|
2812
|
-
*
|
|
2813
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2814
|
-
*
|
|
2815
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2816
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2817
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2818
|
-
* See the License for the specific language governing permissions and
|
|
2819
|
-
* limitations under the License.
|
|
2820
|
-
* =============================================================================
|
|
2821
|
-
*/
|
|
2822
|
-
function Vs(e, t) {
|
|
2823
|
-
const n = W("int32", e.length);
|
|
2824
|
-
for (let s = 0; s < e.length; ++s)
|
|
2825
|
-
n[s] = An(e[s]).modulo(t).getLowBitsUnsigned();
|
|
2826
|
-
return n;
|
|
2827
|
-
}
|
|
2828
|
-
/**
|
|
2829
|
-
* @license
|
|
2830
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2831
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2832
|
-
* you may not use this file except in compliance with the License.
|
|
2833
|
-
* You may obtain a copy of the License at
|
|
2834
|
-
*
|
|
2835
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2836
|
-
*
|
|
2837
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2838
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2839
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2840
|
-
* See the License for the specific language governing permissions and
|
|
2841
|
-
* limitations under the License.
|
|
2842
|
-
* =============================================================================
|
|
2843
|
-
*/
|
|
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
|
-
kernelName: se,
|
|
2846
|
-
backendName: "cpu",
|
|
2847
|
-
kernelFunc: Ds
|
|
2848
|
-
};
|
|
2849
|
-
/**
|
|
2850
|
-
* @license
|
|
2851
|
-
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
2852
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2853
|
-
* you may not use this file except in compliance with the License.
|
|
2854
|
-
* You may obtain a copy of the License at
|
|
2855
|
-
*
|
|
2856
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2857
|
-
*
|
|
2858
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2859
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2860
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2861
|
-
* See the License for the specific language governing permissions and
|
|
2862
|
-
* limitations under the License.
|
|
2863
|
-
* =============================================================================
|
|
2864
|
-
*/
|
|
2865
|
-
function Ws(e, t) {
|
|
2866
|
-
const n = new Array(e.rank);
|
|
2867
|
-
for (let o = 0; o < n.length; o++)
|
|
2868
|
-
n[o] = e.shape[o] * t[o];
|
|
2869
|
-
const s = H(n, e.dtype);
|
|
2870
|
-
for (let o = 0; o < s.values.length; ++o) {
|
|
2871
|
-
const a = s.indexToLoc(o), r = new Array(e.rank);
|
|
2872
|
-
for (let l = 0; l < r.length; l++)
|
|
2873
|
-
r[l] = a[l] % e.shape[l];
|
|
2874
|
-
const i = e.locToIndex(r);
|
|
2875
|
-
s.values[o] = e.values[i];
|
|
2876
|
-
}
|
|
2877
|
-
return s;
|
|
2878
|
-
}
|
|
2879
|
-
/**
|
|
2880
|
-
* @license
|
|
2881
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2882
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2883
|
-
* you may not use this file except in compliance with the License.
|
|
2884
|
-
* You may obtain a copy of the License at
|
|
2885
|
-
*
|
|
2886
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2887
|
-
*
|
|
2888
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2889
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2890
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2891
|
-
* See the License for the specific language governing permissions and
|
|
2892
|
-
* limitations under the License.
|
|
2893
|
-
* =============================================================================
|
|
2894
|
-
*/
|
|
2895
|
-
const rt = (e, t) => {
|
|
2896
|
-
const n = t.value - e.value;
|
|
2897
|
-
return n === 0 ? e.index - t.index : n;
|
|
2898
|
-
};
|
|
2899
|
-
function Ve(e, t, n = 0, s = e.length - 1) {
|
|
2900
|
-
for (; s > n; ) {
|
|
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)), w = Math.min(s, Math.floor(t + (i - l) * h / i + f));
|
|
2903
|
-
Ve(e, t, p, w);
|
|
2904
|
-
}
|
|
2905
|
-
const o = e[t];
|
|
2906
|
-
let a = n, r = s;
|
|
2907
|
-
for (ot(e, n, t), rt(e[s], o) > 0 && ot(e, n, s); a < r; ) {
|
|
2908
|
-
for (ot(e, a, r), a++, r--; rt(e[a], o) < 0; )
|
|
2909
|
-
a = a + 1;
|
|
2910
|
-
for (; rt(e[r], o) > 0; )
|
|
2911
|
-
r = r - 1;
|
|
2912
|
-
}
|
|
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
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
function $s(e, t, n, s, o) {
|
|
2917
|
-
const a = t[t.length - 1], [r, i] = [e.length / a, a], l = et(n, r * s), u = et("int32", r * s);
|
|
2918
|
-
for (let f = 0; f < r; f++) {
|
|
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
|
-
for (let b = 0; b < s; b++)
|
|
2924
|
-
d[b] = m[b].value, g[b] = m[b].index;
|
|
2925
|
-
}
|
|
2926
|
-
const h = t.slice();
|
|
2927
|
-
return h[h.length - 1] = s, [
|
|
2928
|
-
H(h, n, l),
|
|
2929
|
-
H(h, "int32", u)
|
|
2930
|
-
];
|
|
2931
|
-
}
|
|
2932
|
-
/**
|
|
2933
|
-
* @license
|
|
2934
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2935
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2936
|
-
* you may not use this file except in compliance with the License.
|
|
2937
|
-
* You may obtain a copy of the License at
|
|
2938
|
-
*
|
|
2939
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2940
|
-
*
|
|
2941
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2942
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2943
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2944
|
-
* See the License for the specific language governing permissions and
|
|
2945
|
-
* limitations under the License.
|
|
2946
|
-
* =============================================================================
|
|
2947
|
-
*/
|
|
2948
|
-
function Us(e, t, n, s) {
|
|
2949
|
-
const o = Jt(t, n)[0], a = [1, n[0], 1];
|
|
2950
|
-
for (let m = 0; m < o; m++)
|
|
2951
|
-
a[0] *= n[m];
|
|
2952
|
-
a[1] = n[o];
|
|
2953
|
-
for (let m = o + 1; m < n.length; m++)
|
|
2954
|
-
a[2] *= n[m];
|
|
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
|
-
for (let m = 0; m < n[o]; m++) {
|
|
2957
|
-
let F;
|
|
2958
|
-
if (h)
|
|
2959
|
-
F = e[m].toString();
|
|
2960
|
-
else {
|
|
2961
|
-
const g = [];
|
|
2962
|
-
for (let b = 0; b < a[0]; b++)
|
|
2963
|
-
for (let k = 0; k < a[2]; k++)
|
|
2964
|
-
g.push(l.get(b, m, k));
|
|
2965
|
-
F = g.join(",");
|
|
2966
|
-
}
|
|
2967
|
-
const d = r.get(F);
|
|
2968
|
-
if (d != null)
|
|
2969
|
-
i[m] = d;
|
|
2970
|
-
else {
|
|
2971
|
-
const g = r.size;
|
|
2972
|
-
r.set(F, g), i[m] = g, u.push(m);
|
|
2973
|
-
}
|
|
2974
|
-
}
|
|
2975
|
-
const f = a.slice();
|
|
2976
|
-
f[1] = r.size;
|
|
2977
|
-
const p = new It(f, s);
|
|
2978
|
-
u.forEach((m, F) => {
|
|
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
|
-
});
|
|
2983
|
-
const w = n.slice();
|
|
2984
|
-
return w[o] = f[1], {
|
|
2985
|
-
outputValues: p.values,
|
|
2986
|
-
outputShape: w,
|
|
2987
|
-
indices: i
|
|
2988
|
-
};
|
|
2989
|
-
}
|
|
2990
|
-
/**
|
|
2991
|
-
* @license
|
|
2992
|
-
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
2993
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2994
|
-
* you may not use this file except in compliance with the License.
|
|
2995
|
-
* You may obtain a copy of the License at
|
|
2996
|
-
*
|
|
2997
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2998
|
-
*
|
|
2999
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3000
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3001
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3002
|
-
* See the License for the specific language governing permissions and
|
|
3003
|
-
* limitations under the License.
|
|
3004
|
-
* =============================================================================
|
|
3005
|
-
*/
|
|
3006
|
-
const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3007
|
-
__proto__: null,
|
|
3008
|
-
addImpl: he,
|
|
3009
|
-
bincountImpl: Cn,
|
|
3010
|
-
bincountReduceImpl: Dn,
|
|
3011
|
-
bitwiseAndImpl: fe,
|
|
3012
|
-
castImpl: ue,
|
|
3013
|
-
ceilImpl: ge,
|
|
3014
|
-
concatImpl: Un,
|
|
3015
|
-
equalImpl: me,
|
|
3016
|
-
expImpl: pe,
|
|
3017
|
-
expm1Impl: we,
|
|
3018
|
-
floorDivImpl: be,
|
|
3019
|
-
floorImpl: Ie,
|
|
3020
|
-
gatherNdImpl: Hn,
|
|
3021
|
-
gatherV2Impl: Kn,
|
|
3022
|
-
greaterEqualImpl: Ee,
|
|
3023
|
-
greaterImpl: xe,
|
|
3024
|
-
lessEqualImpl: ye,
|
|
3025
|
-
lessImpl: Fe,
|
|
3026
|
-
linSpaceImpl: ts,
|
|
3027
|
-
logImpl: ke,
|
|
3028
|
-
maxImpl: ns,
|
|
3029
|
-
maximumImpl: Ne,
|
|
3030
|
-
minimumImpl: ve,
|
|
3031
|
-
multiplyImpl: yt,
|
|
3032
|
-
negImpl: Se,
|
|
3033
|
-
notEqualImpl: Te,
|
|
3034
|
-
prodImpl: Oe,
|
|
3035
|
-
raggedGatherImpl: ps,
|
|
3036
|
-
raggedRangeImpl: ws,
|
|
3037
|
-
raggedTensorToTensorImpl: Is,
|
|
3038
|
-
rangeImpl: bs,
|
|
3039
|
-
rsqrtImpl: Le,
|
|
3040
|
-
scatterImpl: Es,
|
|
3041
|
-
sigmoidImpl: Fs,
|
|
3042
|
-
simpleAbsImpl: le,
|
|
3043
|
-
sliceImpl: Pe,
|
|
3044
|
-
sparseFillEmptyRowsImpl: Ns,
|
|
3045
|
-
sparseReshapeImpl: vs,
|
|
3046
|
-
sparseSegmentReductionImpl: Ss,
|
|
3047
|
-
sqrtImpl: Ts,
|
|
3048
|
-
squaredDifferenceImpl: Ae,
|
|
3049
|
-
staticRegexReplaceImpl: qe,
|
|
3050
|
-
stridedSliceImpl: Ls,
|
|
3051
|
-
stringNGramsImpl: As,
|
|
3052
|
-
stringSplitImpl: _s,
|
|
3053
|
-
stringToHashBucketFastImpl: Vs,
|
|
3054
|
-
subImpl: _e,
|
|
3055
|
-
tileImpl: Ws,
|
|
3056
|
-
topKImpl: $s,
|
|
3057
|
-
transposeImpl: Re,
|
|
3058
|
-
uniqueImpl: Us
|
|
3059
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
3060
|
-
export {
|
|
3061
|
-
uo as $,
|
|
3062
|
-
ws as A,
|
|
3063
|
-
Is as B,
|
|
3064
|
-
bs as C,
|
|
3065
|
-
Es as D,
|
|
3066
|
-
Ns as E,
|
|
3067
|
-
vs as F,
|
|
3068
|
-
Ss as G,
|
|
3069
|
-
Ls as H,
|
|
3070
|
-
As as I,
|
|
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,
|
|
3079
|
-
no as R,
|
|
3080
|
-
to as S,
|
|
3081
|
-
so as T,
|
|
3082
|
-
Js as U,
|
|
3083
|
-
oo as V,
|
|
3084
|
-
ro as W,
|
|
3085
|
-
ao as X,
|
|
3086
|
-
io as Y,
|
|
3087
|
-
lo as Z,
|
|
3088
|
-
co as _,
|
|
3089
|
-
nt as a,
|
|
3090
|
-
Qs as a0,
|
|
3091
|
-
ho as a1,
|
|
3092
|
-
fo as a2,
|
|
3093
|
-
go as a3,
|
|
3094
|
-
mo as a4,
|
|
3095
|
-
po as a5,
|
|
3096
|
-
wo as a6,
|
|
3097
|
-
Io as a7,
|
|
3098
|
-
bo as a8,
|
|
3099
|
-
Eo as a9,
|
|
3100
|
-
Ys as aa,
|
|
3101
|
-
Fo as ab,
|
|
3102
|
-
yo as ac,
|
|
3103
|
-
ko as ad,
|
|
3104
|
-
No as ae,
|
|
3105
|
-
vo as af,
|
|
3106
|
-
So as ag,
|
|
3107
|
-
To as ah,
|
|
3108
|
-
xo as ai,
|
|
3109
|
-
ys as b,
|
|
3110
|
-
$ as c,
|
|
3111
|
-
Vn as d,
|
|
3112
|
-
z as e,
|
|
3113
|
-
ks as f,
|
|
3114
|
-
Cn as g,
|
|
3115
|
-
mt as h,
|
|
3116
|
-
Et as i,
|
|
3117
|
-
Un as j,
|
|
3118
|
-
Dn as k,
|
|
3119
|
-
lt as l,
|
|
3120
|
-
as as m,
|
|
3121
|
-
Ds as n,
|
|
3122
|
-
Hn as o,
|
|
3123
|
-
Kn as p,
|
|
3124
|
-
ts as q,
|
|
3125
|
-
ce as r,
|
|
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,
|
|
3133
|
-
xt as z
|
|
3134
|
-
};
|